@vantran-se/openchamber-web 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/assets/{AboutDialog-BItSBkkK.js → AboutDialog-C8mAGhnz.js} +1 -1
  2. package/dist/assets/{ArchiveView-CEGi3y1V.js → ArchiveView-4-LVDLmf.js} +1 -1
  3. package/dist/assets/{ChangedPathLabel-CQNGnF-T.js → ChangedPathLabel-BCiU4QDF.js} +1 -1
  4. package/dist/assets/{CommandPalette-DWX1HV4m.js → CommandPalette-DEcmPHdC.js} +1 -1
  5. package/dist/assets/{DiffView-Be1Xoy_F.js → DiffView-CaDZ4gTk.js} +3 -3
  6. package/dist/assets/{FilesView-DONPk8-K.js → FilesView-Csrs_BGv.js} +1 -1
  7. package/dist/assets/{GitView-D10y-u46.js → GitView-DvxCZgCW.js} +3 -3
  8. package/dist/assets/{GuestSurfacePane-Cot0OO7x.js → GuestSurfacePane-DNg0xBTD.js} +1 -1
  9. package/dist/assets/{HelpDialog-Bw836_tH.js → HelpDialog-CLyz3_xd.js} +1 -1
  10. package/dist/assets/{InProgressOperationBanner-saAihIub.js → InProgressOperationBanner-BVDKUDqn.js} +2 -2
  11. package/dist/assets/{IntegrationsCatalogView-BtdMeTHf.js → IntegrationsCatalogView-u1gS0Vk8.js} +1 -1
  12. package/dist/assets/{JsonTreeView-BOQC0uTM.js → JsonTreeView-BpJU14WJ.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-CuZntPVf.js → MarkdownRendererImpl-t3OoYn_0.js} +1 -1
  14. package/dist/assets/{MemoryDebugPanel-BZgSuf-z.js → MemoryDebugPanel-9z1jGWze.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-Bx2h2w69.js → OnboardingScreen-xzT7ckY0.js} +1 -1
  16. package/dist/assets/{OpenCodeStatusDialog-N9JgIC1p.js → OpenCodeStatusDialog-skpJZSjK.js} +1 -1
  17. package/dist/assets/{PatchDiff-Ca_Ci2CX.js → PatchDiff-BWW_8bob.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-Ck0P8Q2W.js → PierreDiffViewer-BZDNV4Uj.js} +1 -1
  19. package/dist/assets/{PlanView-dx70wKWR.js → PlanView-D7wshtfZ.js} +1 -1
  20. package/dist/assets/{ProjectActionsDialog-BS20dYCJ.js → ProjectActionsDialog-BPh74BCt.js} +1 -1
  21. package/dist/assets/{PullRequestComparisonSelector-DOW9_VlK.js → PullRequestComparisonSelector-BBdU2rL1.js} +3 -3
  22. package/dist/assets/{RunOverview-DtxjzGnX.js → RunOverview-Cngm2OOp.js} +2 -2
  23. package/dist/assets/{ScheduledTasksDialog-HcypGtky.js → ScheduledTasksDialog-DUjDdkw2.js} +1 -1
  24. package/dist/assets/{SettingsView-IBrGwDoM.js → SettingsView-CCZOw018.js} +2 -2
  25. package/dist/assets/{SettingsWindow-Bugr9Hmx.js → SettingsWindow-Cndsj5Vu.js} +1 -1
  26. package/dist/assets/{SourceBoardView-BD5rmib8.js → SourceBoardView-8Wp0oUvB.js} +1 -1
  27. package/dist/assets/{SpaceAccessDialog-BYhp5gfB.js → SpaceAccessDialog-CxfCzTpe.js} +1 -1
  28. package/dist/assets/{SpaceApplyDialog-CC0axZal.js → SpaceApplyDialog-CYp0A76N.js} +1 -1
  29. package/dist/assets/{SpaceRow-DDWTQgfP.js → SpaceRow-CQp4PkPJ.js} +1 -1
  30. package/dist/assets/{SpaceSetupOutput-BqurG7V4.js → SpaceSetupOutput-RNo0mWrR.js} +1 -1
  31. package/dist/assets/{SpacesView-Bcbb9aXY.js → SpacesView-BwcDCv3D.js} +1 -1
  32. package/dist/assets/{SubmoduleDiffSummary-BS1PSa4l.js → SubmoduleDiffSummary-BQduif5s.js} +1 -1
  33. package/dist/assets/{ToolOutputDialog-DXWQ17Fv.js → ToolOutputDialog-BVCvqYsK.js} +1 -1
  34. package/dist/assets/{ToolPartDiffPreview-DXRs6cSg.js → ToolPartDiffPreview-BXpCHBW9.js} +1 -1
  35. package/dist/assets/{UsageStatsView-DFVydqMY.js → UsageStatsView-CsC_RzAH.js} +1 -1
  36. package/dist/assets/{Virtualizer-B8rX50qD.js → Virtualizer-nenVQKi3.js} +1 -1
  37. package/dist/assets/{WalkthroughView-CECS5lDs.js → WalkthroughView-CdIYpttA.js} +1 -1
  38. package/dist/assets/{WorktreesView-FH0uzPQG.js → WorktreesView-D102xE1o.js} +1 -1
  39. package/dist/assets/{appThemeRegistry-CnS_OWEL.js → appThemeRegistry-BWap7OfW.js} +1 -1
  40. package/dist/assets/{ar-BlEU--PN.js → ar-9CiK5cuu.js} +3 -3
  41. package/dist/assets/{computeVirtualFileMetrics-rZJ-MSfY.js → computeVirtualFileMetrics-DDyA16hp.js} +1 -1
  42. package/dist/assets/{de-DWs4Mcjc.js → de-Drq6oIkP.js} +3 -3
  43. package/dist/assets/{decorate-Bbbyq0tX.js → decorate-CemSwkUs.js} +1 -1
  44. package/dist/assets/{es-k5T7CE97.js → es-0bkFr34F.js} +3 -3
  45. package/dist/assets/{flexokiTheme-DECIbITo.js → flexokiTheme-PoX6Vqyn.js} +1 -1
  46. package/dist/assets/{fr-CzmypgZ8.js → fr-CjgWVupK.js} +3 -3
  47. package/dist/assets/{he-DdkxJnUn.js → he-BrJa9oPB.js} +4 -4
  48. package/dist/assets/{index-DElZNtel.js → index-B2WHEal3.js} +1 -1
  49. package/dist/assets/{initializeSharedPreferences-C5qncsHs.js → initializeSharedPreferences-1Vo6G7CM.js} +1 -1
  50. package/dist/assets/{install-D-H6uk7D.js → install-FletzeYD.js} +1 -1
  51. package/dist/assets/{isDiffPlainText-DMFSMXcK.js → isDiffPlainText-yXcpftjI.js} +1 -1
  52. package/dist/assets/{isFilePlainText-BQGSJxcX.js → isFilePlainText-Dpm-_Qu8.js} +1 -1
  53. package/dist/assets/{ja-Qqkyglaf.js → ja-cfyrqWPa.js} +3 -3
  54. package/dist/assets/katex.min-F4TD1ekM.js +69 -0
  55. package/dist/assets/{ko-B8idPK2d.js → ko-herKAlGO.js} +3 -3
  56. package/dist/assets/{main-DMdUGpFx.js → main-CO7wKNtS.js} +2 -2
  57. package/dist/assets/{main-CcnDurk6.js → main-DN47yDMe.js} +19 -19
  58. package/dist/assets/markdownCore-BY21GJ_M.js +10 -0
  59. package/dist/assets/{miniChat-B8DW3cmv.js → miniChat-BmFJFQph.js} +2 -2
  60. package/dist/assets/{mobile-Caqsx1Op.js → mobile-DTi98S93.js} +2 -2
  61. package/dist/assets/{moveWorkspacePath-By4gjwmW.js → moveWorkspacePath-CENAo75W.js} +1 -1
  62. package/dist/assets/{nl-CFXZKHp7.js → nl-mZ4VCoiQ.js} +3 -3
  63. package/dist/assets/{parseDiffFromFile-C9ASoy7R.js → parseDiffFromFile-BSmRvd3V.js} +1 -1
  64. package/dist/assets/{pierreDiffTint-IfgQ6oty.js → pierreDiffTint-cyYFR1bm.js} +1 -1
  65. package/dist/assets/{pl-slLgZWDu.js → pl-C98lvkcZ.js} +4 -4
  66. package/dist/assets/{pt-BR-C319g_nn.js → pt-BR-CB63WPLS.js} +3 -3
  67. package/dist/assets/{relocateRestoredSession-DBWTClOj.js → relocateRestoredSession-D8Sf_FG_.js} +1 -1
  68. package/dist/assets/{renderElectronMiniChatApp-C5irgP-w.js → renderElectronMiniChatApp-DmQ8i5jp.js} +2 -2
  69. package/dist/assets/{renderMobileApp-DnyN_ARh.js → renderMobileApp-CND9CafV.js} +3 -3
  70. package/dist/assets/{restartOpenCode-VU-OEAvZ.js → restartOpenCode-D8ExMl55.js} +1 -1
  71. package/dist/assets/{runtimeEndpointReset-BJUtkqal.js → runtimeEndpointReset-lg1O2gVX.js} +3 -3
  72. package/dist/assets/{scheduledTasksApi-FZ9stPNl.js → scheduledTasksApi-CJBNpwgy.js} +1 -1
  73. package/dist/assets/{selectionMarkdown-DV_HvvmZ.js → selectionMarkdown-B_3WTOUr.js} +1 -1
  74. package/dist/assets/{shikiHighlight-BKmAuapa.js → shikiHighlight-DBj_a_TN.js} +1 -1
  75. package/dist/assets/{space-apply-Br_BRuH8.js → space-apply-COMscpEL.js} +1 -1
  76. package/dist/assets/{space-close-D_1iLJrX.js → space-close-DDLvYCUc.js} +1 -1
  77. package/dist/assets/{spaceNetwork-Dcj-qJy-.js → spaceNetwork-CNxs51y4.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-Bye_bpEL.js → textMateThemeFromAppTheme-tYpAceV3.js} +1 -1
  79. package/dist/assets/{tr-DNnJ5oqk.js → tr-C5KUa-8X.js} +3 -3
  80. package/dist/assets/{uk-Bw0BJwHw.js → uk-D44Grdmc.js} +3 -3
  81. package/dist/assets/{useAppFontEffects-d9vsRNKm.js → useAppFontEffects-Dm6zEvrf.js} +200 -199
  82. package/dist/assets/{useCallableModelProviders-8CrUkERW.js → useCallableModelProviders-BK3j8Sde.js} +1 -1
  83. package/dist/assets/{useDiffFindSurface-sw5jZ-9V.js → useDiffFindSurface-CaCh-qt2.js} +1 -1
  84. package/dist/assets/{useInlineCommentController-Cw5IRM5Y.js → useInlineCommentController-a2JepiF3.js} +1 -1
  85. package/dist/assets/{useMarkdownLocalAssets-D3a1j44d.js → useMarkdownLocalAssets-BEApAshz.js} +2 -2
  86. package/dist/assets/{useRootScrollLock-BWsNuapq.js → useRootScrollLock-mqVhK2HB.js} +2 -2
  87. package/dist/assets/{useWalkthroughReview-D7I1H6_J.js → useWalkthroughReview-BspAr9Aa.js} +1 -1
  88. package/dist/assets/{vendor-codemirror-language-data-DP_Bh3S8.js → vendor-codemirror-language-data-VzNDjH03.js} +2 -2
  89. package/dist/assets/{zh-CN-Brx5Btej.js → zh-CN-DwBC4Qtd.js} +3 -3
  90. package/dist/assets/{zh-TW-WokiutLA.js → zh-TW-DXEqDBAm.js} +3 -3
  91. package/dist/index.html +2 -2
  92. package/dist/mini-chat.html +2 -2
  93. package/dist/mobile.html +2 -2
  94. package/package.json +2 -2
  95. package/server/index.js +4 -2
  96. package/server/lib/git/service.test.js +1 -1
  97. package/server/lib/opencode/openchamber-routes.test.js +1 -0
  98. package/server/lib/opencode/settings-helpers.js +2 -2
  99. package/server/lib/opencode/settings-helpers.test.js +1 -1
  100. package/server/lib/opencode/settings-registry.json +1 -1
  101. package/server/lib/outbound-proxy.test.js +2 -2
  102. package/server/lib/spaces/tools.test.js +2 -2
  103. package/dist/assets/katex.min-u4DtE8E5.js +0 -69
  104. package/dist/assets/markdownCore-BwFkWhmZ.js +0 -10
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-D10y-u46.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-d9vsRNKm.js","assets/katex.min-u4DtE8E5.js","assets/vendor-zod-DDir2TeQ.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-h8RufjAw.js","assets/katex-CQK6Iqoe.css","assets/vendor-base-ui-CPKyhvxM.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-Bmi0tTrf.js","assets/vendor-tanstack-virtual-core-CdGDGrnp.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-DP_Bh3S8.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-D2O6oUGf.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-BJUtkqal.js","assets/InProgressOperationBanner-saAihIub.js","assets/PierreDiffViewer-Ck0P8Q2W.js","assets/parseDiffFromFile-C9ASoy7R.js","assets/computeVirtualFileMetrics-rZJ-MSfY.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-DMFSMXcK.js","assets/pierreDiffTint-IfgQ6oty.js","assets/Virtualizer-B8rX50qD.js","assets/useInlineCommentController-Cw5IRM5Y.js","assets/appThemeRegistry-CnS_OWEL.js","assets/textMateThemeFromAppTheme-Bye_bpEL.js","assets/ChangedPathLabel-CQNGnF-T.js","assets/useRootScrollLock-BWsNuapq.js","assets/moveWorkspacePath-By4gjwmW.js","assets/WalkthroughView-CECS5lDs.js","assets/PullRequestComparisonSelector-DOW9_VlK.js","assets/useDiffFindSurface-sw5jZ-9V.js","assets/useWalkthroughReview-D7I1H6_J.js","assets/useCallableModelProviders-8CrUkERW.js","assets/DiffView-Be1Xoy_F.js","assets/SubmoduleDiffSummary-BS1PSa4l.js","assets/FilesView-DONPk8-K.js","assets/flexokiTheme-DECIbITo.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-D3a1j44d.js","assets/JsonTreeView-BOQC0uTM.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-BQGSJxcX.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-BKmAuapa.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-FZ9stPNl.js","assets/GuestSurfacePane-Cot0OO7x.js","assets/SettingsWindow-Bugr9Hmx.js","assets/SettingsView-IBrGwDoM.js","assets/install-D-H6uk7D.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/restartOpenCode-VU-OEAvZ.js","assets/SpaceRow-DDWTQgfP.js","assets/CommandPalette-DWX1HV4m.js","assets/HelpDialog-Bw836_tH.js","assets/ProjectActionsDialog-BS20dYCJ.js","assets/OpenCodeStatusDialog-N9JgIC1p.js","assets/RunOverview-DtxjzGnX.js","assets/ScheduledTasksDialog-HcypGtky.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-CEGi3y1V.js","assets/IntegrationsCatalogView-BtdMeTHf.js","assets/UsageStatsView-DFVydqMY.js","assets/SourceBoardView-BD5rmib8.js","assets/WorktreesView-FH0uzPQG.js","assets/SpacesView-Bcbb9aXY.js","assets/SpaceAccessDialog-BYhp5gfB.js","assets/spaceNetwork-Dcj-qJy-.js","assets/SpaceApplyDialog-CC0axZal.js","assets/space-apply-Br_BRuH8.js","assets/SpaceSetupOutput-BqurG7V4.js","assets/OnboardingScreen-Bx2h2w69.js","assets/AboutDialog-BItSBkkK.js","assets/MemoryDebugPanel-BZgSuf-z.js"])))=>i.map(i=>d[i]);
2
- import{f as Ze,j as n,R as l,r as us,c as gl,h as jg}from"./vendor-react-BUCujlKS.js";import{u as le,cE as $s,b as Gs,l as Dn,e as Ps,cF as Vu,a8 as ni,a5 as Jt,a7 as ri,n as yt,b0 as As,ax as hn,au as Do,av as vn,aw as Tr,aS as kg,aA as Gu,cG as Cg,bd as Ds,cH as bl,cI as Ro,cJ as oi,cK as Ig,cL as Ca,cM as Dr,cN as Ia,cO as Yi,cP as Pg,cQ as ii,cR as dr,af as No,k as Ys,cS as nr,aZ as Eg,cT as ai,cU as qu,cV as Tg,cW as wn,cX as Dg,cY as Yu,cZ as Rg,c_ as Ng,c$ as Zu,d0 as Mg,m as Ag,q as Og,bh as Bg,b4 as li,b5 as Fg,b7 as _g,b8 as Lg,ap as $g,at as zg,ao as Vs,t as Mo,d1 as Kg,d2 as Wg,aI as Ao,d3 as Qu,d4 as Xu,d5 as Hg,az as yl,d6 as xl,bj as Oo,aU as en,bv as ts,ae as Ju,aL as ci,d7 as Ug,d8 as Vg,d9 as Gg,aV as ef,da as zt,db as tf,dc as qg,dd as Pa,de as Yg,bW as sf,bX as nf,a6 as Zg,bw as Qg,bk as Xg,bz as rf,df as Pc,dg as Jg,b3 as eb,dh as Ec,bL as of,ay as af,bn as Tc,bo as lf,bB as tb,bm as sb,di as nb,dj as rb,aQ as ob,aO as ib,dk as ab,aW as lb,bl as cb,bO as db,dl as ub,dm as fb,dn as Dc,dp as Zi,dq as Rc,dr as Nc,ds as pb,aC as Mc,dt as hb,du as mb,dv as gb,aP as bb,dw as yb,i as xb,a as Sb}from"./katex.min-u4DtE8E5.js";import{_ as as}from"./vendor-vite-runtime-DD1OZmLC.js";import{bj as wb,bk as Sl,ai as vb,$ as Yr,bl as Bo,aq as wl,bm as jb,ad as kb,ae as Cb,ag as Ea,m as cf,p as df,x as uf,n as ff,l as vl,v as pf,w as hf,y as mf,a0 as Ib,a1 as Pb,X as Eb,a6 as Tb,a7 as Db,W as Rb,a2 as Nb,N as Mb,d as Ab,i as Ob,q as Bb,bn as Fb,t as _b,u as Lb,C as $b,bo as rr,ay as zb,bp as gf,bq as xo,br as bf,bs as Kb,bt as yf,bu as Un,bv as Ac,bw as Oc,bx as Qi,by as Bc,a4 as So,av as Wb,aw as Hb,aa as Ub,aN as Vb,aO as xf,bz as Gb,ax as qb,bA as Yb,be as Zb,b4 as Qb,S as Fc,bB as Xb,aS as jl,aR as Jb,bC as Ta,bD as ey,aj as ty,ah as Sf,bE as Ln,bF as sy,z as ny,bG as wf,ap as ry,bH as vf,bI as oy,bJ as _c,ak as iy,al as ay,ao as ly,b as cy,a as dy,am as Lc,ac as Rr,af as uy,an as fy,b5 as $c,bK as py,bL as hy,bM as my,bN as gy,bO as by,bP as yy,bQ as zc,bR as xy,az as Sy,aM as wy,aD as vy,aQ as jy,bS as ky,aJ as Cy,aK as Iy,bT as Py,bU as Ey,ba as Ty,bV as Dy,aT as Ry,aP as Ny,bW as My,aB as Ay,bX as Oy,bY as By,aF as Fy,aE as _y,aG as Ly,aI as $y,aH as zy,aL as Ky,bZ as Wy,b_ as Hy}from"./runtimeEndpointReset-BJUtkqal.js";import{u as Et,k4 as Uy,I as Z,W as Ht,X as Kt,V as Ut,aG as br,a5 as ns,G as mt,cy as jf,N as Pe,cR as kl,cS as Cl,cT as Il,k5 as Vn,H as Os,K as ur,eH as Pl,eG as kf,b0 as Da,k6 as Vy,k7 as Cf,b1 as If,e0 as El,aR as Rs,aS as Ns,aT as Ms,bg as In,aU as rs,gN as Zr,c2 as Gy,l as nn,F as rn,D as on,U as di,a0 as fr,q as Zs,t as Qs,T as qy,A as He,k8 as Yy,k9 as Zy,ka as Kc,kb as Wc,b$ as Pf,a4 as Ef,kc as Qy,kd as Hc,ke as Xy,kf as Ra,kg as Tl,kh as Tf,ki as Df,kj as Na,b_ as Rf,kk as Jy,kl as ex,km as tx,dA as Lr,h2 as Nf,kn as ui,ko as sx,gV as Jn,aF as Rn,kp as nx,gW as rx,dx as Mf,kq as ox,fZ as fi,dy as ix,kr as Af,aA as pi,ks as Of,kt as Bf,ku as Ff,kv as _f,kw as Lf,kx as $f,i_ as yr,bl as Dl,dD as zf,o as Pn,B as Nt,ky as pr,kz as Kf,fD as Rl,n as Qr,aV as Cs,kA as ax,br as Nl,am as Wf,ap as Hf,kB as lx,kC as cx,b7 as Ks,j9 as Uf,j8 as Vf,b9 as kn,bi as Ma,iW as dx,ez as ux,aE as Nn,kD as Ml,kE as fx,kF as Gf,ct as Al,cs as Ol,fX as px,fp as hx,gc as mx,e$ as qf,bc as pn,b4 as gx,ah as ys,b8 as Yf,bb as Aa,ba as er,bh as Zf,kG as Qf,kH as Xf,kI as bx,kJ as yx,kK as xx,f1 as Bl,z as Fo,cc as Sx,ca as wx,c9 as vx,cb as jx,c3 as kx,y as _o,cL as Uc,bj as Jf,bf as Lo,kL as Cx,kM as Ix,kN as Px,cx as xr,b3 as Ex,b5 as hi,b6 as Tx,bd as Dx,aD as Cn,g3 as ep,cQ as Rx,kO as tp,kP as Nx,cn as Mx,kQ as Ax,cl as Ox,cw as Bx,cq as Fx,kR as _x,kS as Lx,kT as $x,cv as zx,cz as Kx,kU as Xn,af as Wx,kV as Hx,a1 as ps,gY as sp,kW as Ux,c5 as Vx,x as np,bS as Gx,kX as qx,kY as Yx,fC as rp,kZ as Xr,k_ as Zx,k$ as Oa,l0 as Xi,go as Qx,gI as $n,gH as wo,cD as Xx,l1 as Jx,l2 as op,l3 as Jr,dp as mi,l4 as Fl,l5 as e1,cU as En,l6 as t1,ac as s1,l7 as n1,l8 as r1,l9 as o1,la as Ji,lb as i1,lc as a1,es as _l,gq as l1,gt as c1,el as d1,gu as u1,d0 as f1,eq as eo,gG as Ll,gJ as ip,ld as $r,ep as ap,eo as $l,gK as p1,gL as h1,gM as zl,d8 as m1,C as g1,aH as b1,le as ea,lf as y1,lg as x1,lh as lp,li as cp,lj as S1,lk as w1,ll as v1,lm as j1,ln as k1,ck as C1,an as I1,lo as Vc,lp as Gc,lq as qc,hk as $o,gS as Kl,d7 as dp,lr as P1,dc as gi,hl as Nr,ls as up,lt as xs,df as E1,iZ as fp,i$ as pp,gD as hp,gE as mp,gF as gp,lu as T1,lv as bp,lw as D1,lx as yp,ly as Ba,c8 as xp,lz as Wl,lA as R1,lB as N1,lC as M1,hi as is,lD as A1,lE as Sp,lF as wp,lG as vp,lH as zr,lI as Yc,lJ as O1,lK as Kr,lL as B1,lM as F1,lN as Hl,lO as zo,lP as Ul,lQ as jp,lR as kp,lS as Cp,lT as Ip,ae as _1,lU as L1,g_ as $1,h6 as z1,h9 as Vl,hm as K1,jN as Zc,lV as W1,h7 as H1,h8 as U1,lW as V1,eI as G1,O as q1,eJ as Pp,lX as Y1,lY as Z1,lZ as Q1,l_ as or,l$ as X1,g$ as J1,m0 as vo,dJ as bi,de as Fa,m1 as eS,hn as tS,m2 as sS,m3 as Ep,P as Tn,m4 as nS,hc as rS,m5 as oS,m6 as iS,en as aS,d5 as lS,cF as Tp,m7 as cS,m8 as dS,m9 as uS,ma as ta,mb as fS,mc as pS,md as hS,a7 as mS,a6 as gS,hh as bS,me as yS,mf as Gn,hj as xS,mg as SS,fq as Mn,mh as wS,mi as vS,mj as jS,dk as kS,mk as CS,he as IS,dT as Qc,dS as Xc,c1 as Jc,ml as PS,mm as ES,cC as TS,mn as DS,h1 as ed,h3 as sa,h4 as RS,mo as NS,h5 as MS,mp as AS,k as OS,mq as td,mr as na,ms as An,mt as qn,mu as sd,mv as BS,mw as FS,mx as _S,my as LS,mz as $S,mA as zS,eO as _a,gj as KS,mB as WS,mC as Dp,mD as HS,db as US,mE as nd,mF as VS,d9 as GS,e2 as Rp,mG as La,Y as Np,e1 as Mp,d6 as Ap,mH as qS,a8 as YS,mI as Op,cj as $a,iG as ZS,gT as QS,iH as XS,gX as JS,mJ as ew,ce as tw,mK as rd,mL as sw,dF as nw,mM as rw,dm as od,dG as ow,dI as iw,dH as aw,dO as lw,dN as cw,hG as dw,dM as uw,dK as fw,dL as pw,a as hw,s as mw,b as gw,c as bw,hN as yw,dU as xw,dV as Sw,dW as ww,dX as vw}from"./useAppFontEffects-d9vsRNKm.js";import{u as Bp,S as jw,W as Fp,f as _p,a as kw,G as Cw,b as Iw,c as Pw}from"./useRootScrollLock-BWsNuapq.js";import{f as yi,h as mn,T as xi,M as Si,D as wi,j as vi,d as Ew,b as Tw,k as Dw,i as Rw}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as Nw,h as Mw,u as ji,S as Gl,a as Lp,v as $p,s as Aw}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ki}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as zp,M as Kp,C as Wp,i as za,j as Ka,k as Wa,l as Ow,m as Bw}from"./vendor-base-ui-CPKyhvxM.js";import{c as to,u as hr,p as Fw}from"./vendor-zustand-BAGL70zf.js";import{r as Wr,a as Ci,n as Hp,s as zs,o as Ko,b as Ha}from"./vendor-zod-DDir2TeQ.js";import{u as Up}from"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import{D as _w,a as Lw,m as id,G as $w}from"./moveWorkspacePath-By4gjwmW.js";import{d as Vp,m as zw}from"./vendor-tanstack-virtual-core-CdGDGrnp.js";const Kw=t=>{const e=Ze.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=Et(),a=le(Ww);let d;e[0]!==s?(d=$s(s),e[0]=s,e[1]=d):d=e[1];const c=d;let u;e[2]!==c?(u=w=>Uy(c?w.journey?.get(c):void 0),e[2]=c,e[3]=u):u=e[3];const f=Gs(u);let p;e[4]!==c?(p=w=>c?w.actions.get(c)?.kind==="running":!1,e[4]=c,e[5]=p):p=e[5];const h=Gs(p);if(!a||!c||!f||Dn())return null;let g;e[6]!==i?(g=i("spaces.header.apply"),e[6]=i,e[7]=g):g=e[7];const b=g;let x;e[8]!==c?(x=()=>Gs.getState().openApplyDialog(c),e[8]=c,e[9]=x):x=e[9];let y;e[10]!==o?(y=n.jsx(Z,{name:"git-merge",className:o}),e[10]=o,e[11]=y):y=e[11];let S;e[12]!==h||e[13]!==r||e[14]!==b||e[15]!==x||e[16]!==y?(S=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":b,disabled:h,onClick:x,className:r,children:y})}),e[12]=h,e[13]=r,e[14]=b,e[15]=x,e[16]=y,e[17]=S):S=e[17];let m;e[18]!==b?(m=n.jsx(Kt,{side:"bottom",children:b}),e[18]=b,e[19]=m):m=e[19];let v;return e[20]!==S||e[21]!==m?(v=n.jsxs(Ut,{children:[S,m]}),e[20]=S,e[21]=m,e[22]=v):v=e[22],v};function Ww(t){return t.isolatedSpacesEnabled}function Hw(t){const e=Ze.c(36),{directory:s,className:r}=t,{currentTheme:o}=br(),i=ns(Gw),a=mt(Vw),d=Ps(Uw);let c;e[0]!==s||e[1]!==d?(c=Vu(s,d),e[0]=s,e[1]=d,e[2]=c):c=e[2];const u=c;let f;e[3]!==s||e[4]!==u||e[5]!==i||e[6]!==a?(f=u||!s?null:jf(i,a,s),e[3]=s,e[4]=u,e[5]=i,e[6]=a,e[7]=f):f=e[7];const p=f;if(u){let I;e[8]!==r?(I=Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=I):I=e[9];let F;return e[10]!==I?(F=n.jsx(Z,{name:"chat-4",className:I}),e[10]=I,e[11]=F):F=e[11],F}if(!p)return null;const h=p.icon?kl[p.icon]:null;let g;e[12]!==p.color?(g=Cl(p.color)??void 0,e[12]=p.color,e[13]=g):g=e[13];const b=g;let x;e[14]!==r||e[15]!==b||e[16]!==h?(x=h?n.jsx(Z,{name:h,className:Pe("h-3.5 w-3.5 shrink-0",r),style:b?{color:b}:void 0}):n.jsx(Z,{name:"folder",className:Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),style:b?{color:b}:void 0}),e[14]=r,e[15]=b,e[16]=h,e[17]=x):x=e[17];const y=x;if(!p.iconImage)return y;let S;e[18]!==r?(S=Pe("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[18]=r,e[19]=S):S=e[19];let m;e[20]!==p.iconBackground?(m=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[20]=p.iconBackground,e[21]=m):m=e[21];let v;e[22]!==p.iconImage||e[23]!==p.id?(v={id:p.id,iconImage:p.iconImage},e[22]=p.iconImage,e[23]=p.id,e[24]=v):v=e[24];let w;e[25]!==o.colors.surface.foreground||e[26]!==o.metadata.variant?(w={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[25]=o.colors.surface.foreground,e[26]=o.metadata.variant,e[27]=w):w=e[27];let T;e[28]!==y||e[29]!==v||e[30]!==w?(T=n.jsx(Il,{project:v,options:w,className:"h-full w-full object-contain",fallback:y}),e[28]=y,e[29]=v,e[30]=w,e[31]=T):T=e[31];let k;return e[32]!==S||e[33]!==m||e[34]!==T?(k=n.jsx("span",{className:S,style:m,children:T}),e[32]=S,e[33]=m,e[34]=T,e[35]=k):k=e[35],k}function Uw(t){return t.homeDirectory}function Vw(t){return t.availableWorktreesByProject}function Gw(t){return t.projects}const Er=24,qw=(t,e,s=Er)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},Yw=({transform:t})=>({...t,y:0}),Zw=16,Qw=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*Zw:t.deltaY;t.currentTarget.scrollLeft+=ni(t.currentTarget)?-e:e},Xw={Item:rs,Separator:In},Jw={Item:({className:t,...e})=>n.jsx(Kp,{className:Pe(If,t),...e}),Separator:({className:t,...e})=>n.jsx(zp,{className:Pe(Cf,t),...e})},ev=t=>{const e=Ze.c(65),{tab:s,isActive:r,isPreview:o,suppressControls:i,onSelect:a,onPin:d,onClose:c,renderMenu:u,closeOtherTabs:f,onMenuOpenChangeComplete:p,children:h}=t,{t:g}=Et(),[b,x]=l.useState(!1),[y,S]=l.useState(!1),[m,v]=l.useState(!1);let w;e[0]!==s.id?(w={id:s.id},e[0]=s.id,e[1]=w):w=e[1];const{attributes:T,listeners:k,setNodeRef:I,transform:F,transition:O,isDragging:B}=ji(w);let j;e[2]!==g||e[3]!==s.session.title?(j=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[2]=g,e[3]=s.session.title,e[4]=j):j=e[4];const P=j,L=!i&&(b||y),z=s.id;let H;e[5]!==s.session?(H=ur(s.session),e[5]=s.session,e[6]=H):H=e[6];const R=Sl(z,H),G=Pl(s.id),_=G!==null,E=kf(s.id)>0&&!r&&!_,D=_||E;let C;e[7]!==f||e[8]!==m||e[9]!==r||e[10]!==b||e[11]!==a||e[12]!==s?(C=fe=>({session:s.session,open:b||m,isActive:r,select:()=>a(s),closeOtherTabs:()=>f(s.id),components:fe}),e[7]=f,e[8]=m,e[9]=r,e[10]=b,e[11]=a,e[12]=s,e[13]=C):C=e[13];const N=C;let A;e[14]!==F?(A=ki.Translate.toString(F),e[14]=F,e[15]=A):A=e[15];let q;e[16]!==A||e[17]!==O?(q={transform:A,transition:O},e[16]=A,e[17]=O,e[18]=q):q=e[18];const ee=B&&"z-10 opacity-60";let Q;e[19]!==ee?(Q=Pe("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",ee),e[19]=ee,e[20]=Q):Q=e[20];const he=r?"true":"false";let M;e[21]!==r?(M=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=M):M=e[22];let V;e[23]!==p?(V=fe=>p?.(fe),e[23]=p,e[24]=V):V=e[24];let ie;e[25]!==h||e[26]!==r||e[27]!==R||e[28]!==o||e[29]!==N||e[30]!==b||e[31]!==c||e[32]!==p||e[33]!==d||e[34]!==a||e[35]!==L||e[36]!==u||e[37]!==D||e[38]!==i||e[39]!==g||e[40]!==s||e[41]!==P||e[42]!==G?(ie=n.jsx(Wp,{render:fe=>n.jsxs("div",{...fe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>a(s),onDoubleClick:o?()=>d(s.id):void 0,onKeyDown:r?void 0:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),a(s))},onAuxClick:be=>{be.button===1&&(be.preventDefault(),c(s.id))},"data-controls-open":L?"true":"false",className:Pe("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":Pe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",L&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:Pe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pe-10",L&&"pe-10"),children:[n.jsx(Hw,{directory:ur(s.session),className:"me-1.5"}),n.jsx("div",{className:Pe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title",o&&!i&&"italic"),children:r?h:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4",children:P})})}),R?n.jsx(Z,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):D?n.jsx(El,{state:G??"unread",className:Pe("ms-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",L&&"opacity-0")}):null]}),i?null:n.jsxs("div",{onClick:sv,onPointerDown:nv,className:Pe("absolute inset-e-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",L&&"flex opacity-100"),children:[n.jsxs(Rs,{open:b,onOpenChange:be=>{x(be),be&&S(!0)},onOpenChangeComplete:be=>{be||S(!1),p?.(be)},children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsx(Ms,{align:"start",className:"min-w-[190px]",children:u(N(Xw))})]}),n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:()=>c(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]})]})}),e[25]=h,e[26]=r,e[27]=R,e[28]=o,e[29]=N,e[30]=b,e[31]=c,e[32]=p,e[33]=d,e[34]=a,e[35]=L,e[36]=u,e[37]=D,e[38]=i,e[39]=g,e[40]=s,e[41]=P,e[42]=G,e[43]=ie):ie=e[43];let ce,ne;e[44]===Symbol.for("react.memo_cache_sentinel")?(ce={color:"var(--surface-elevated-foreground)"},ne=Pe(Da,"min-w-[190px]"),e[44]=ce,e[45]=ne):(ce=e[44],ne=e[45]);let je;e[46]!==N||e[47]!==u?(je=u(N(Jw)),e[46]=N,e[47]=u,e[48]=je):je=e[48];let Ee;e[49]!==je?(Ee=n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-content",style:ce,className:ne,children:je})})}),e[49]=je,e[50]=Ee):Ee=e[50];let we;e[51]!==m||e[52]!==V||e[53]!==ie||e[54]!==Ee?(we=n.jsxs(Zr,{open:m,onOpenChange:v,onOpenChangeComplete:V,children:[ie,Ee]}),e[51]=m,e[52]=V,e[53]=ie,e[54]=Ee,e[55]=we):we=e[55];let Me;return e[56]!==T||e[57]!==k||e[58]!==I||e[59]!==he||e[60]!==M||e[61]!==we||e[62]!==q||e[63]!==Q?(Me=n.jsx("div",{ref:I,style:q,className:Q,"data-active":he,...M,...T,...k,children:we}),e[56]=T,e[57]=k,e[58]=I,e[59]=he,e[60]=M,e[61]=we,e[62]=q,e[63]=Q,e[64]=Me):Me=e[64],Me},tv=t=>{const e=Ze.c(68),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:d,direction:c}=Et(),u=c==="rtl",f=Vn(rv),p=Vn(ov),h=Vn(iv),g=Vn(av),b=Vn(lv),x=Vn(cv),y=mt(dv),S=mt(uv),m=Os(fv),v=wb(y);let w,T;e[0]!==v||e[1]!==y||e[2]!==h?(w=()=>{y&&h(y,v)},T=[y,v,h],e[0]=v,e[1]=y,e[2]=h,e[3]=w,e[4]=T):(w=e[3],T=e[4]),l.useEffect(w,T);let k;if(e[5]!==m){k=new Map;for(const me of m)k.set(me.id,me);e[5]=m,e[6]=k}else k=e[6];const I=k;let F;if(e[7]!==I||e[8]!==f){F=[];for(const me of f){const re=I.get(me);re&&F.push({id:me,session:re})}e[7]=I,e[8]=f,e[9]=F}else F=e[9];const O=F;let B;e[10]!==S?(B=me=>{S(me.id,ur(me.session))},e[10]=S,e[11]=B):B=e[11];const j=B,P=pv;let L;e[12]!==b||e[13]!==y||e[14]!==j||e[15]!==O?(L=me=>{if(b(me),y&&y!==me){const re=O.find(pe=>pe.id===me);re&&j(re)}},e[12]=b,e[13]=y,e[14]=j,e[15]=O,e[16]=L):L=e[16];const z=L;let H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{distance:8}},e[17]=H):H=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{delay:200,tolerance:6}},e[18]=R):R=e[18];const G=yi(mn(Si,H),mn(xi,R));let _;e[19]!==x?(_=me=>{const{active:re,over:pe}=me;pe&&re.id!==pe.id&&x(String(re.id),String(pe.id))},e[19]=x,e[20]=_):_=e[20];const $=_,E=l.useRef(null);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D={left:!1,right:!1},e[21]=D):D=e[21];const[C,N]=l.useState(D);let A;e[22]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const me=E.current;if(!me)return;const re=me.scrollWidth-me.clientWidth,pe=ni(me)?re+me.scrollLeft:me.scrollLeft,U=pe>2,ae=pe<re-2;N(Re=>Re.left===U&&Re.right===ae?Re:{left:U,right:ae})},e[22]=A):A=e[22];const q=A;let ee;e[23]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{q();const me=E.current;if(!me||!globalThis.ResizeObserver)return;const re=new ResizeObserver(q);return re.observe(me),()=>re.disconnect()},e[23]=ee):ee=e[23];let Q;e[24]!==O.length?(Q=[q,O.length],e[24]=O.length,e[25]=Q):Q=e[25],l.useEffect(ee,Q);let he;e[26]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{const me=E.current,re=me?.querySelector("[data-active-session-tab]");if(!me||!re)return;const pe=qw(me.getBoundingClientRect(),re.getBoundingClientRect());pe!==0&&(me.scrollLeft=me.scrollLeft+pe,q())},e[26]=he):he=e[26];let M;e[27]!==y?(M=[y,q],e[27]=y,e[28]=M):M=e[28],l.useEffect(he,M);const V=C.left&&C.right?`linear-gradient(to right, transparent, black ${Er}px, black calc(100% - ${Er}px), transparent)`:C.left?`linear-gradient(to right, transparent, black ${Er}px)`:C.right?`linear-gradient(to right, black calc(100% - ${Er}px), transparent)`:void 0;let ie;e[29]!==O?(ie=O.map(hv),e[29]=O,e[30]=ie):ie=e[30];const ce=ie;let ne;e[31]!==y||e[32]!==O?(ne=!!y&&!O.some(me=>me.id===y),e[31]=y,e[32]=O,e[33]=ne):ne=e[33];const je=ne;let Ee;e[34]!==d?(Ee=d("header.sessionTabs.stripAria"),e[34]=d,e[35]=Ee):Ee=e[35];let we;e[36]!==V?(we=V?{maskImage:V,WebkitMaskImage:V}:void 0,e[36]=V,e[37]=we):we=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=[Yw],e[38]=Me):Me=e[38];const fe=u?Nw:Mw;let be;e[39]!==i||e[40]!==y||e[41]!==z||e[42]!==j||e[43]!==r||e[44]!==g||e[45]!==p||e[46]!==s||e[47]!==a||e[48]!==O?(be=O.map(me=>n.jsx(ev,{tab:me,isActive:me.id===y,isPreview:me.id===p,suppressControls:me.id===y&&a,onSelect:j,onPin:g,onClose:P,renderMenu:s,closeOtherTabs:z,onMenuOpenChangeComplete:r,children:me.id===y?i:null},me.id)),e[39]=i,e[40]=y,e[41]=z,e[42]=j,e[43]=r,e[44]=g,e[45]=p,e[46]=s,e[47]=a,e[48]=O,e[49]=be):be=e[49];let ke;e[50]!==fe||e[51]!==be||e[52]!==ce?(ke=n.jsx(Gl,{items:ce,strategy:fe,children:be}),e[50]=fe,e[51]=be,e[52]=ce,e[53]=ke):ke=e[53];let Ie;e[54]!==$||e[55]!==G||e[56]!==ke?(Ie=n.jsx(wi,{sensors:G,collisionDetection:vi,modifiers:Me,onDragEnd:$,children:ke}),e[54]=$,e[55]=G,e[56]=ke,e[57]=Ie):Ie=e[57];let Te;e[58]!==i||e[59]!==je?(Te=je?n.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:n.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[58]=i,e[59]=je,e[60]=Te):Te=e[60];let Y;e[61]!==we||e[62]!==Ie||e[63]!==Te?(Y=n.jsxs("div",{ref:E,onScroll:q,onWheel:Qw,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:we,children:[Ie,Te]}),e[61]=we,e[62]=Ie,e[63]=Te,e[64]=Y):Y=e[64];let ue;return e[65]!==Ee||e[66]!==Y?(ue=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ee,children:Y}),e[65]=Ee,e[66]=Y,e[67]=ue):ue=e[67],ue};function sv(t){return t.stopPropagation()}function nv(t){return t.stopPropagation()}function rv(t){return t.tabIds}function ov(t){return t.previewTabId}function iv(t){return t.ensureTab}function av(t){return t.pinTab}function lv(t){return t.closeOtherTabs}function cv(t){return t.reorderTabs}function dv(t){return t.currentSessionId}function uv(t){return t.setCurrentSession}function fv(t){return t.activeSessions}function pv(t){Vy(t)}function hv(t){return t.id}const mv=500;function os(t){const e=Ze.c(9),{hint:s,children:r}=t,[o,i]=l.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(f,p)=>{f&&p.reason==="trigger-focus"||i(f)},e[0]=a):a=e[0];let d;e[1]!==r?(d=n.jsx(Ht,{asChild:!0,children:r}),e[1]=r,e[2]=d):d=e[2];let c;e[3]!==s?(c=n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=c):c=e[4];let u;return e[5]!==o||e[6]!==d||e[7]!==c?(u=n.jsxs(Ut,{delayDuration:mv,open:o,onOpenChange:a,children:[d,c]}),e[5]=o,e[6]=d,e[7]=c,e[8]=u):u=e[8],u}const gv=t=>{const e=Ze.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=Et(),a=Gy(ns(bv),s),d=Ps(yv);let c;e[0]!==i?(c=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=c):c=e[1];let u;e[2]!==c?(u=n.jsx(nn,{children:c}),e[2]=c,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let p;e[6]!==f?(p=n.jsx(rn,{children:f}),e[6]=f,e[7]=p):p=e[7];let h;e[8]!==u||e[9]!==p?(h=n.jsxs(on,{children:[u,p]}),e[8]=u,e[9]=p,e[10]=h):h=e[10];let g;if(e[11]!==d||e[12]!==r||e[13]!==o||e[14]!==a){let S;e[16]!==d||e[17]!==r||e[18]!==o?(S=m=>n.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(m.path)},children:[n.jsx(Z,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label?.trim()||di(m.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:fr(m.path,d)})]},m.id),e[16]=d,e[17]=r,e[18]=o,e[19]=S):S=e[19],g=a.map(S),e[11]=d,e[12]=r,e[13]=o,e[14]=a,e[15]=g}else g=e[15];let b;e[20]!==g?(b=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:g}),e[20]=g,e[21]=b):b=e[21];let x;e[22]!==h||e[23]!==b?(x=n.jsxs(Zs,{className:"max-w-md",children:[h,b]}),e[22]=h,e[23]=b,e[24]=x):x=e[24];let y;return e[25]!==r||e[26]!==s||e[27]!==x?(y=n.jsx(Qs,{open:s,onOpenChange:r,children:x}),e[25]=r,e[26]=s,e[27]=x,e[28]=y):y=e[28],y};function bv(t){return t.projects}function yv(t){return t.homeDirectory}function ad(t){const e=Ze.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=Et();let a;e[0]!==s?(a=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=a):a=e[1];const d=Os(a);let c;e[2]!==s?(c=k=>{const I=k.entityById.get(s);return!I||qy(I,k.entityById)},e[2]=s,e[3]=c):c=e[3];const u=Os(c),f=mt(xv);let p;e[4]!==s||e[5]!==i||e[6]!==f?(p=async()=>{await f(s)?He.success(i("sessions.sidebar.session.restore.success")):He.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=p):p=e[7];const h=p;if(d&&!u)return null;const g=d?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let b;e[8]!==i||e[9]!==g?(b=i(g),e[8]=i,e[9]=g,e[10]=b):b=e[10];let x;e[11]!==d||e[12]!==r||e[13]!==h?(x=d?()=>{h()}:r,e[11]=d,e[12]=r,e[13]=h,e[14]=x):x=e[14];const y=d?"inbox-unarchive":"inbox-archive";let S;e[15]!==y?(S=n.jsx(Z,{name:y,className:"me-1 size-4"}),e[15]=y,e[16]=S):S=e[16];const m=d?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let v;e[17]!==i||e[18]!==m?(v=i(m),e[17]=i,e[18]=m,e[19]=v):v=e[19];let w;e[20]!==o||e[21]!==v||e[22]!==x||e[23]!==S?(w=n.jsxs(o,{onClick:x,children:[S,v]}),e[20]=o,e[21]=v,e[22]=x,e[23]=S,e[24]=w):w=e[24];let T;return e[25]!==w||e[26]!==b?(T=n.jsx(os,{hint:b,children:w}),e[25]=w,e[26]=b,e[27]=T):T=e[27],T}function xv(t){return t.unarchiveSession}const Gp=async t=>{const{entry:e,session:s}=t,r=Jt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(Yy(e.action)&&Zy(e.guest,"conversation"))){await Kc(e,Wc(e.action.id,o),t.t,r);return}let a=!1;const d=ri(()=>{a=!0});let c;try{c=await t.loadRecords()}finally{d()}if(!a){if(!c){t.onLoadFailed();return}await Kc(e,Wc(e.action.id,o,c),t.t,r)}};function Ua(t){const e=Ze.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:a}=Et(),{pending:d,disabled:c,hint:u,run:f}=vb(s,r,o),p=d?"loader-4":"ai-generate-2",h=d?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==p||e[1]!==h?(g=n.jsx(Z,{name:p,className:h}),e[0]=p,e[1]=h,e[2]=g):g=e[2];let b;e[3]!==a?(b=a("sessions.aiRename.action"),e[3]=a,e[4]=b):b=e[4];let x;e[5]!==i||e[6]!==c||e[7]!==f||e[8]!==g||e[9]!==b?(x=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:c,onClick:f,className:"w-full",children:[g,b]})}),e[5]=i,e[6]=c,e[7]=f,e[8]=g,e[9]=b,e[10]=x):x=e[10];let y;return e[11]!==u||e[12]!==x?(y=n.jsx(os,{hint:u,children:x}),e[11]=u,e[12]=x,e[13]=y):y=e[13],y}const Wo=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class qp extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const Ii=to(()=>({pendingSessionIds:new Set})),Yp=t=>{const e=Ze.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],Ii(s)},ld=(t,e)=>{Ii.setState(s=>{if(s.pendingSessionIds.has(t)===e)return s;const r=new Set(s.pendingSessionIds);return e?r.add(t):r.delete(t),{...s,pendingSessionIds:r}})},Sv=async(t,e)=>{try{const c=(await tx(t,{mode:"light"})).current?.trim();if(c)return c}catch{}const s=yt(t),r=yt(e)??e,o=mt.getState().availableWorktreesByProject,a=Lr(o.get(r)??o.get(e)??[],s??t)?.branch?.trim();if(a)return a;throw new Error("Unable to determine the current branch")},cd=t=>{for(const e of t){const s=Xy(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class wv extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const vv=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new wv(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},jv=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(Ra(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Ef(i,s,e),mt.getState().setWorktreeMetadata(i.id,r.get(i.id)??null,e)}catch(a){o.push({sessionId:i.id,error:a instanceof Error?a:new Error(String(a))})}}return o},dd=async(t,e,s)=>{try{await Nf(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},ud=async(t,e)=>{const s=e?[t,e]:[t];try{await Tl(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},ql=async(t,e)=>{if(Ii.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");ld(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(d=>[d.id,mt.getState().getWorktreeMetadata(d.id)]));cd(s);let o=null;const i=[];let a=!1;try{o=await e();for(const[d,c]of s.entries()){cd(s.slice(d));try{await Ef(c,t.sourceDirectory,o.directory)}catch(u){throw Qy(u)&&(a=!0),u}i.push(c),c.id!==t.root.id&&mt.getState().setWorktreeMetadata(c.id,o.metadata?Hc(o.metadata):null,o.directory)}}catch(d){const c=d instanceof Error?d:new Error(String(d)),u=await jv(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(a&&await ud(t.sourceDirectory,o?.directory),u.length>0)throw vv(c,u);if(o?.onMoveFailure&&!a)return o.onMoveFailure(c);throw o?.onMoveFailure&&a?new qp(c):c}return mt.getState().setWorktreeMetadata(t.root.id,o.metadata?Hc(o.metadata):null,o.directory),await ud(t.sourceDirectory,o.directory),o.directory}finally{ld(t.root.id,!1)}},kv=async t=>{const e=yt(t.sourceDirectory)??t.sourceDirectory,s=yt(t.destination.path)??t.destination.path;if(Pf(s,e))throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return ql(t,async()=>{const r=await Tf(t.sourceDirectory);return{directory:r?await Df(r,t.destination.path):t.destination.path,metadata:t.destination}})},Cv=async t=>{if((yt(t.sourceDirectory)??t.sourceDirectory)===(yt(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return ql(t,async()=>({directory:t.projectDirectory,metadata:null}))},Iv=async t=>ql(t,async()=>{const e=Na(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await Rf(t.sourceDirectory)?await Sv(t.sourceDirectory,e.path):null,r=await Jy(e,s?{startRef:s}:{});if(!r)throw new Error("Worktree creation cancelled");try{await ex(r.path)}catch(i){const a=i instanceof Error?i:new Error(String(i));return dd(e,r,a)}const o=await Tf(t.sourceDirectory)??e;return{directory:await Df(o,r.path),metadata:r,onMoveFailure:async i=>dd(e,r,i)}}),Pv=t=>{(t.kind==="existing"?kv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?Cv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):Iv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>He.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));He.error(t.messages.failure,{description:r instanceof qp?t.messages.outcomeUnknown:r.message})})},Ho=t=>{Ii.getState().pendingSessionIds.has(t.root.id)||Pv(t)},ra="--oc-titlebar-controls-width",Va=new Set;let Mr=null;const Zp=t=>{Mr===null?t.style.removeProperty(ra):t.style.getPropertyValue(ra)!==Mr&&t.style.setProperty(ra,Mr)},Ev=t=>{const e=`${Math.round(t)}px`;e!==Mr&&(Mr=e,Va.forEach(Zp))},Qp=t=>{if(t)return Va.add(t),Zp(t),()=>{Va.delete(t)}},vr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",Yn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Tv=()=>{As("ui.header.render");const{t,direction:e}=Et(),s=le(te=>te.isSidebarOpen),r=ui(),o=le(te=>te.sessionTabsEnabled),i=mt(te=>!!te.newSessionDraft?.open),a=mt(te=>te.currentSessionId),d=sx(a??""),c=Yp(a??""),u=Os(hr(l.useCallback(te=>{if(!a)return null;const et=[...te.activeSessions,...te.archivedSessions].find(It=>It.id===a);if(!et)return null;const xt=et;return{title:et.title??null,directory:xt.directory??null,created:et.time?.created??null,slug:xt.slug??null,parentId:et.parentID??null}},[a]))),f=ns(hr(te=>{if(!te.activeProjectId)return null;const et=te.projects.find(xt=>xt.id===te.activeProjectId);return et?{id:et.id,path:et.path,label:et.label}:null})),p=l.useMemo(()=>{if(!f)return null;const te=f.label?.trim();if(te)return te;const et=f.path.split(/[\\/]/).filter(Boolean);return et[et.length-1]??null},[f]),h=Jn(te=>te.loadSettings),{isMobile:g}=Rn(),b=l.useRef(null),[x,y]=l.useState(()=>typeof window>"u"?!1:hn()),S=l.useMemo(()=>Do(),[]),m=nx(),[v,w]=l.useState(!1),T=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:I}=Bp(),F=l.useMemo(()=>{if(typeof window>"u")return null;const te=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof te=="number"&&Number.isFinite(te)&&te>0)return te;if(typeof navigator>"u")return null;const et=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!et)return null;const xt=Number.parseInt(et[1],10),It=Number.parseInt(et[2],10);return Number.isNaN(xt)?null:xt===10?It:xt},[]);us.useEffect(()=>{typeof window>"u"||y(hn())},[]);const O=l.useMemo(()=>Dn(),[]),B=le(te=>te.workStatusPanelVisible),j=le(te=>te.workStatusPanelEnabled),P=le(te=>te.setWorkStatusPanelEnabled),L=le(te=>te.workStatusPanelFits),z=le(te=>te.workStatusOverlayOpen),H=le(te=>te.setWorkStatusOverlayOpen),G=j&&L||z,_=l.useCallback(()=>{if(j&&!L){H(!z);return}P(!j)},[H,P,z,j,L]);rx(),l.useEffect(()=>{h()},[h]);const $=a?u??null:null,E=l.useRef(null),[D,C]=l.useState(0);l.useEffect(()=>{if(!a){E.current&&(E.current=null,C(It=>It+1));return}if($){E.current={sessionId:a,session:$,expiresAt:Date.now()+2e3};return}const te=E.current;if(!te||te.sessionId!==a)return;const et=te.expiresAt-Date.now();if(et<=0){E.current=null,C(It=>It+1);return}const xt=window.setTimeout(()=>{E.current?.sessionId===a&&(E.current=null),C(It=>It+1)},et);return()=>{window.clearTimeout(xt)}},[a,$]);const N=(()=>{if($)return $;if(!a)return null;const te=E.current;return te&&te.sessionId===a&&te.expiresAt>Date.now()?te.session:null})(),A=mt(te=>a?te.worktreeMetadata.get(a)?.path??"":""),q=mt(te=>a?te.worktreeMetadata.get(a)?.branch?.trim()??null:null),ee=Mf(te=>a?te.getAttachment(a):void 0),Q=l.useMemo(()=>ee?ox(ee,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ee]),he=l.useMemo(()=>ee?ee.legacy?"legacy":ee.degraded?"degraded":ee.worktreeStatus==="pending"?"pending":ee.worktreeStatus==="missing"?"missing":ee.worktreeStatus==="invalid"?"invalid":ee.attentionReason?"attention":null:null,[ee]),M=l.useMemo(()=>Yn(A||""),[A]),V=l.useMemo(()=>{const te=typeof N?.directory=="string"?N.directory:"";return Yn(te||"")},[N?.directory]),ie=Sl(a??"",V),ce=mt(te=>te.newSessionDraft?.open?Yn(te.newSessionDraft.bootstrapPendingDirectory??te.newSessionDraft.directoryOverride??""):""),ne=mt(te=>te.newSessionDraft.target),je=mt(te=>te.newSessionDraft.selectedProjectId),Ee=mt(te=>te.currentSessionDirectory),we=Ps(te=>te.homeDirectory),Me=Yr(),fe=l.useMemo(()=>M||V||(fi(Me,ce)??""),[ce,Me,V,M]),be=mt(te=>{const et=Yn(M||V||"");if(!et)return null;for(const xt of te.availableWorktreesByProject.values()){const St=Lr(xt,et)?.branch?.trim();if(St)return St}return null}),Ie=ix(fe||null)||q||be,Te=i?ne==="chat":Vu(V||Ee,we),Y=!Te&&!B&&!!(p||Ie||!i&&he),ue=l.useMemo(()=>{if(!a)return p??"OpenChamber";const te=N?.title?.trim();return te&&te.length>0?te:"Untitled Session"},[p,N?.title,a]),me=Af(),re=mt(te=>te.updateSessionTitle),pe=mt(te=>te.archiveSessions),U=mt(te=>te.deleteSessions),[ae,Re]=l.useState(!1),[W,ye]=l.useState(!1),de=l.useRef(null),[Ne,Je]=l.useState(""),[Ge,ge]=l.useState(!1),Ae=ns(te=>te.projects.length>0),[Ye,nt]=l.useState(null),oe=l.useRef(null),tt=l.useCallback(()=>{a&&(Je(N?.title?.trim()||ue),Re(!0))},[N?.title,a,ue]),Ue=l.useRef(tt);Ue.current=tt;const gt=l.useCallback(te=>{te&&(te.focus(),te.select())},[]);l.useEffect(()=>{if(ye(!1),nt(null),a&&de.current===a){de.current=null,Ue.current();return}Re(!1),Je("")},[a]);const bt=l.useCallback(async()=>{if(!a)return;const te=Ne.trim();te&&te!==N?.title?.trim()&&await re(a,te),Re(!1)},[N?.title,a,Ne,re]);l.useEffect(()=>{if(!ae)return;const te=et=>{const xt=et.target;(!xt||!oe.current?.contains(xt))&&bt()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[ae,bt]);const Ce=l.useCallback(te=>{te&&pi(te).then(et=>{He[et.ok?"success":"error"](t(et.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>He.error(t("sessions.sidebar.session.copyId.error")))},[t]),_e=l.useCallback(async()=>{if(!a||!fe){He.error(t("sessions.sidebar.session.export.nothingToExport"));return}const te=await me({sessionID:a,directory:fe}).catch(()=>null);if(!te){He.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(te.length===0){He.error(t("sessions.sidebar.session.export.nothingToExport"));return}const et=Of(te,N?.title??null),xt=Bf(N?.title??null);await Ff(et,xt)||_f(et,xt),He.success(t("sessions.sidebar.session.export.success"))},[N?.title,a,me,fe,t]),ze=Lf(),Oe=l.useMemo(()=>$f(ze),[ze]),it=l.useCallback(te=>{a&&Gp({entry:te,t,session:{id:a,title:N?.title,directory:V??fe},loadRecords:async()=>{if(!fe)return null;try{return await me({sessionID:a,directory:fe})}catch{return null}},onLoadFailed:()=>He.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[N?.title,a,me,fe,V,t]),X=l.useCallback(te=>Oe.map(et=>n.jsxs(te,{onClick:()=>it(et),children:[n.jsx(yr,{icon:et.icon,iconSrc:et.iconSrc,className:"me-1 size-4"}),et.action.label]},`${et.guest.id}:${et.action.id}`)),[Oe,it]),Be=d?.type==="busy"||d?.type==="retry",Le=l.useCallback(()=>{if(!a||!V||Be||c)return;const et=Os.getState().activeSessions.find(xt=>xt.id===a);et&&Ho({kind:"quick",root:et,descendants:Bo(et,[]),sourceDirectory:V,messages:Wo(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,Be,c,V,t]),at=l.useCallback(te=>{if(!a||!V||Be||c)return;const xt=Os.getState().activeSessions.find(It=>It.id===a);xt&&Ho({kind:"project",root:xt,descendants:Bo(xt,[]),sourceDirectory:V,projectDirectory:te,messages:Wo(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[a,Be,c,V,t]),qe=l.useCallback(async(te,et)=>{const xt=[et,...wl(et,[],te==="delete")],It=mt.getState().currentSessionId===et?et:null;if(te==="delete"){const{failedIds:We}=await U(xt);We.length>0?He.error(t("sessions.sidebar.session.delete.error")):He.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:St,failedIds:Se}=await pe(xt);if(Se.length>0){He.error(t("sessions.sidebar.session.archive.error"));return}He.success(t("sessions.sidebar.session.archive.success"),jb(St,It,t))},[pe,U,t]),ut=l.useCallback(async()=>{if(!Ye)return;const{action:te,sessionId:et}=Ye;nt(null),await qe(te,et)},[Ye,qe]),dt=le(te=>te.openGuestPageId),ft=Dl(te=>te.guests.find(et=>et.id===dt)),st=le(te=>te.isScheduledTasksDialogOpen),Rt=le(te=>te.isArchivePageOpen),Ke=le(te=>te.isIntegrationsCatalogOpen),jt=le(te=>te.isUsageStatsPageOpen),Lt=le(te=>te.isSourceBoardOpen),Mt=le(te=>te.worktreesPageProjectId),De=le(te=>te.isolatedSpacesEnabled?te.spacesPageProjectId:null),Tt=le(te=>te.runOverviewKey),At=kb(Tt),kt=Mt??De,pt=ns(te=>{if(!kt)return null;const et=te.projects.find(xt=>xt.id===kt);return et?.label?.trim()||et?.path?.split("/").pop()||null}),Dt=l.useMemo(()=>ft?{title:ft.pageTitle??ft.name,subtitle:null}:st?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Rt?{title:t("sessions.archivePage.title"),subtitle:null}:Ke?{title:t("integrationsCatalog.page.title"),subtitle:null}:jt?{title:t("usageStats.title"),subtitle:null}:Lt?{title:t("sourceBoard.title"),subtitle:null}:Mt?{title:t("sessions.worktreesPage.title",{project:pt??""}),subtitle:null}:De?{title:t("spaces.page.title",{project:pt??""}),subtitle:null}:Tt?{title:At??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[ft,Rt,Ke,At,Tt,st,Lt,jt,De,pt,t,Mt]),Ve=V||Yn(Ee||"")||M,rt=l.useCallback(()=>{vn("desktop_open_draft_mini_chat_window",{directory:Te?"":ce,projectId:Te?null:je,...Tr()}).catch(te=>{console.warn("[header] failed to open draft mini chat window",te)})},[ce,je,Te]),wt=l.useCallback(()=>{if(i){rt();return}a&&vn("desktop_open_session_mini_chat_window",{sessionId:a,directory:V||Yn(Ee||"")||M,...Tr()}).catch(te=>{console.warn("[header] failed to open session mini chat window",te)})},[a,rt,i,Ee,V,M]),se=S&&(i||!!a),Fe=l.useCallback((te,et)=>{vn("desktop_open_session_mini_chat_window",{sessionId:te,directory:et,...Tr()}).catch(xt=>{console.warn("[header] failed to open session mini chat window",xt)})},[]),ot=vr,$e=l.useMemo(()=>x&&T&&!v?"88px":m?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!x||k)&&!O?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[x,v,T,m,O,k]),Ct=(!x||k)&&!O?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Yt=e==="rtl",es=Yt?Ct:$e,Zt=Yt?$e:Ct,ss=k&&I!==Gu(e);us.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",es)},[es]);const bs=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ls=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";us.useEffect(()=>{if(!x||!T){w(!1);return}let te=!1;const et=async()=>{try{const It=await vn("desktop_is_window_fullscreen");te||w(It===!0)}catch{te||w(!1)}},xt=()=>{et()};return et(),window.addEventListener("openchamber:window-resized",xt),()=>{te=!0,window.removeEventListener("openchamber:window-resized",xt)}},[x,T]);const ms=l.useMemo(()=>!x||!T||F===null?"":F>=26?"h-11":F<=15?"h-14":"",[x,T,F]),fs=l.useMemo(()=>x&&T&&!v?F!==null&&F<=15?"56px":"44px":"0px",[x,v,T,F]),Es=l.useMemo(()=>{const et=`max(${x&&T?"2.75rem":"3rem"}, ${fs}, var(--oc-wco-titlebar-height, 0px))`,xt=x&&!k||O;if(xt&&fs==="0px")return{};const It={minHeight:et,height:et};return!ss&&(!xt||Yt)&&(It.paddingInlineEnd=Zt),It},[ss,x,T,Yt,O,Zt,fs,k]),cs=l.useRef(null),Qe=l.useCallback(te=>{!te||te===cs.current||(cs.current=te,document.documentElement.style.setProperty("--oc-header-height",`${te}px`))},[]),vt=l.useCallback(()=>{typeof document>"u"||Qe(b.current?.getBoundingClientRect().height)},[Qe]);us.useEffect(()=>{if(typeof window>"u")return;vt();const te=b.current;if(!te||typeof ResizeObserver>"u")return()=>{};let et=0;const xt=()=>{et||(et=requestAnimationFrame(()=>{et=0,vt()}))},It=new ResizeObserver(St=>{const Se=St[St.length-1];Qe(Se?.borderBoxSize?.[0]?.blockSize??Se?.target.getBoundingClientRect().height)});return It.observe(te),window.addEventListener("resize",xt),window.addEventListener("orientationchange",xt),()=>{et&&cancelAnimationFrame(et),It.disconnect(),window.removeEventListener("resize",xt),window.removeEventListener("orientationchange",xt)}},[Qe,vt]),us.useEffect(()=>{vt()},[vt,g,ms]);const $t=l.useCallback(async te=>{const et=te.target;et.closest(".app-region-no-drag")||et.closest("button, a, input, select, textarea")||te.button===0&&x&&await kg()},[x]);zf({rename_current_session:()=>{if(!a||g)return!1;tt()},archive_current_session:()=>{if(!a||g||Os.getState().entityById.get(a)?.time.archived)return!1;if(le.getState().showDeletionDialog){nt({action:"archive",sessionId:a});return}qe("archive",a)}});const ve=n.jsxs(n.Fragment,{children:[n.jsx(Kw,{directory:fe,className:Pe(vr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(Cb,{directory:fe,className:Pe(vr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),ct=l.useCallback(({session:te,open:et,isActive:xt,select:It,closeOtherTabs:St,components:Se})=>{const{Item:We,Separator:K}=Se,xe=xt&&!O&&!Te&&N&&!N.parentId,Xe=xt&&!O&&Te&&N&&!N.parentId&&Ae;return n.jsxs(n.Fragment,{children:[n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(We,{onClick:()=>{xt||It(),de.current=te.id},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:te.id,directory:te.directory,open:et,Item:We}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(We,{onClick:()=>Ce(te.id),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(K,{}),xt?n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(We,{onClick:()=>{_e()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,S?n.jsxs(We,{onClick:()=>Fe(te.id,xt?Ve:te.directory??""),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,xt?X(We):null,xe?n.jsx(os,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(We,{disabled:!V||Be||c,onClick:Le,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Xe?n.jsx(os,{hint:t(Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(We,{disabled:!V||Be||c,onClick:()=>ge(!0),className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(K,{}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(We,{onClick:St,children:[n.jsx(Z,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(K,{}),n.jsx(ad,{sessionId:te.id,Item:We,onArchive:()=>nt({action:"archive",sessionId:te.id})}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(We,{className:"text-destructive focus:text-destructive",onClick:()=>nt({action:"delete",sessionId:te.id}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[Ce,N,Ve,_e,S,Ae,Te,Be,c,O,Le,Fe,X,V,t]),ht=()=>n.jsxs("div",{onMouseDown:$t,className:Pe("app-region-drag relative flex h-12 select-none items-center",ss?"pe-0":"pe-2.5",ms),style:Es,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:bs,transitionDuration:`${r}ms`,transitionTimingFunction:pr}}),n.jsx("div",{ref:Qp,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ls,transitionDuration:`${r}ms`,transitionTimingFunction:pr}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Dt?n.jsxs(n.Fragment,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>le.getState().closeMainSurfaces(),children:n.jsx(Z,{name:"arrow-left",className:"size-4"})})}),n.jsx(Kt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Dt.title}),Dt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Dt.subtitle}):null]})]}):O||!o?n.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[ie?n.jsx(Z,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsx(jw,{align:"start",children:n.jsx("button",{type:"button",className:ot,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(Z,{name:"history",className:"h-4 w-4"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ae?n.jsxs("form",{ref:oe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:te=>te.stopPropagation(),onSubmit:te=>{te.preventDefault(),bt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:te=>Je(te.target.value),onKeyDown:te=>Ea(te,()=>Re(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Re(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):i?null:n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:ue}),Y?n.jsxs("span",{className:Pe("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[p?n.jsx("span",{className:"truncate",children:p}):null,Ie?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Z,{name:"git-branch",className:Pe("flex-shrink-0 text-muted-foreground/70",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:Pe("truncate",i&&"text-muted-foreground"),children:Ie})]}):null,!i&&he?n.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",he==="attention"||he==="invalid"||he==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(Z,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:Q})]}):null]}):null]}),n.jsx("div",{className:Pe("flex h-[18px] shrink-0 items-center justify-center",Y?"self-start":"self-center"),children:a&&!i&&!ae?n.jsxs(Rs,{open:W,onOpenChange:ye,onOpenChangeComplete:te=>{!te&&de.current&&de.current===a&&(de.current=null,tt())},children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{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:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsxs(Ms,{align:"end",className:"min-w-[190px]",children:[n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(rs,{onClick:()=>{de.current=a},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:a,directory:V,open:W,Item:rs}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(rs,{onClick:()=>a&&Ce(a),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(In,{}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(rs,{onClick:()=>{_e()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),S?n.jsxs(rs,{onClick:()=>Fe(a,Ve),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,X(rs),!O&&!Te&&N&&!N.parentId?n.jsx(os,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(rs,{disabled:!V||Be||c,onClick:Le,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(In,{}),n.jsx(ad,{sessionId:a,Item:rs,onArchive:()=>nt({action:"archive",sessionId:a})}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(rs,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&nt({action:"delete",sessionId:a})},children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(tv,{renderMenu:ct,suppressActiveTabControls:ae,onMenuOpenChangeComplete:te=>{!te&&de.current&&de.current===a&&(de.current=null,tt())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ae?n.jsxs("form",{ref:oe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:te=>te.stopPropagation(),onSubmit:te=>{te.preventDefault(),bt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:te=>Je(te.target.value),onKeyDown:te=>Ea(te,()=>Re(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Re(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):ue})})})}),Dt||O||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[se?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:wt,className:vr,children:n.jsx(Z,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",children:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,O?null:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":G,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:_,className:Pe(vr,G&&"text-foreground"),children:n.jsx(Z,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",children:t(j&&!L?z?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":j?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ve,n.jsx(Fp,{visible:ss,position:I})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:ht()}),n.jsx(gv,{open:Ge,onOpenChange:ge,onPick:at}),n.jsx(Qs,{open:Ye!==null,onOpenChange:te=>{te||nt(null)},children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:Ye?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(rn,{children:Ye?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:ue}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:ue})})]}),n.jsxs(Pn,{children:[n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>nt(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",size:"sm",onClick:()=>{ut()},children:Ye?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},fd=280,pd=264,hd=500,Dv=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=Et(),c=le(_=>_.sidebarWidth),u=le(_=>_.setSidebarWidth),[f,p]=l.useState(!1),h=l.useRef(0),g=l.useRef(c||fd),b=l.useRef(null),x=l.useRef(null),y=l.useRef(null),S=l.useCallback(_=>Math.min(hd,Math.max(pd,_)),[]),m=l.useCallback(_=>{const $=y.current;$&&($.style.width=`${_}px`,$.style.minWidth=`${_}px`,$.style.maxWidth=`${_}px`,$.style.setProperty("--oc-left-sidebar-width",`${_}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${_}px`))},[]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(b.current=null,x.current=null)},[f]);const v=Math.min(hd,Math.max(pd,c||fd)),w=t?v:0,T=f?b.current??w:w,k=f?T:v;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`)},[k]);const[I,F]=l.useState(!t);t&&I&&F(!1);const O=ui(),B=l.useRef(t),j=l.useRef(t);if(l.useLayoutEffect(()=>{B.current=t,j.current!==t&&(j.current=t,Kf(O),t||Rl(()=>{B.current||F(!0)}))},[t,O]),e)return null;const P=_=>{if(t){try{_.currentTarget.setPointerCapture(_.pointerId)}catch{}x.current=_.pointerId,p(!0),h.current=_.clientX,g.current=w,b.current=w,m(w),_.preventDefault()}},L=_=>{if(e||!f||x.current!==_.pointerId)return;const $=(_.clientX-h.current)*(d==="rtl"?-1:1),E=S(g.current+$);b.current!==E&&(b.current=E,m(E))},z=_=>{if(x.current!==_.pointerId||e)return;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}const $=S(b.current??w);x.current=null,b.current=null,p(!1),u($)},H=!t&&i?i.state:!1,R=H!==!1,G=R&&i&&i.animationMs>0?`${H==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${pr} forwards`:void 0;return n.jsxs("div",{ref:y,"data-left-sidebar":"",className:Pe("relative flex h-full border-e border-border",!R&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${T}px`,minWidth:`${T}px`,maxWidth:`${T}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:R?void 0:"clip",transitionDuration:`${O}ms`,transitionTimingFunction:pr},children:[t&&n.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)] rtl:shadow-[inset_2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&n.jsx("div",{className:Pe("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:P,onPointerMove:L,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":R?H:void 0,className:Pe("flex h-full shrink-0 flex-col",R?"absolute inset-s-0 top-0 z-[25] border-e border-border bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!R&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${O}ms`,overflowX:"hidden",contentVisibility:I&&!R?"hidden":void 0,animation:G,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!R||void 0,onPointerEnter:R?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:R?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:R?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(Qr,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(Cs,{children:s})})]})]})},Rv=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),t[1]=s):s=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[s,n.jsx("div",{ref:Qp,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),n.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Nv=50,Mv=18,Av=300,Ov='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',Xp=t=>!document.getElementById("root")?.contains(t),Bv=t=>{if((ni(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Mv)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},md=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Ov)).some(s=>Xp(s)&&s.getClientRects().length>0)},Fv=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=l.useState(!1),o=ax()?0:e,i=o>0,a=l.useRef(null),d=l.useRef(null),c=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&clearTimeout(d.current),c.current!==null&&clearTimeout(c.current),d.current=null,c.current=null},[]),f=l.useCallback(()=>{u(),r(b=>b==="in"&&i?"out":!1)},[i,u]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,md(a.current)){p();return}f()},Av)},[f]),h=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(u(),r(!1))},[u,t]),l.useEffect(()=>u,[u]),l.useEffect(()=>{if(s!=="in")return;const b=S=>{const m=S.target;m instanceof Element&&(a.current?.contains(m)||Xp(m)||f())},x=S=>{Nl(S)||S.key!=="Escape"||S.defaultPrevented||md(a.current)||f()},y=S=>{S.relatedTarget===null&&p()};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",x),document.addEventListener("pointerout",y),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",x),document.removeEventListener("pointerout",y)}},[f,p,s]),l.useEffect(()=>{if(!t||s!==!1)return;const b=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},x=S=>{if(S.pointerType!=="mouse"||S.buttons!==0||!Bv(S)){b();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Nv))},y=S=>{S.relatedTarget===null&&b()};return document.addEventListener("pointermove",x,{passive:!0}),document.addEventListener("pointerout",y),()=>{document.removeEventListener("pointermove",x),document.removeEventListener("pointerout",y),b()}},[t,s]);const g=l.useMemo(()=>({onPointerEnter:()=>{h(),r(b=>b==="out"?"in":b)},onPointerLeave:()=>{s==="in"&&p()},onAnimationEnd:b=>{b.target===b.currentTarget&&r(x=>x==="out"?!1:x)}}),[h,p,s]);return{state:t?s:!1,animationMs:o,overlayRef:a,overlayHandlers:g}},io="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",_v=()=>{const t=Ze.c(45),{t:e,locale:s,direction:r}=Et(),o=le(Lv),i=le($v),a=le(zv),d=l.useRef(null),c=Wf(Hf("toggle_sidebar",a)),u=Kv,{usesFramelessChrome:f,side:p}=Bp();let h;t[0]!==s?(h=E=>{const D=E.currentTarget.getBoundingClientRect();vn("desktop_show_app_menu",{x:D.left,y:D.bottom,locale:s}).catch(Wv)},t[0]=s,t[1]=h):h=t[1];const g=h;let b,x;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const E=d.current;if(!E)return;const D=()=>{const N=Math.max(E.getBoundingClientRect().width,E.scrollWidth);Ev(N)};if(D(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(D);return C.observe(E),()=>{C.disconnect()}},x=[],t[2]=b,t[3]=x):(b=t[2],x=t[3]),l.useEffect(b,x);const y="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",S=i?"var(--oc-left-sidebar-width, 100%)":void 0;let m;t[4]!==S?(m={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=m):m=t[5];const v="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==p?(w=f&&p===Gu(r)?n.jsx(Fp,{visible:!0,position:p}):null,t[6]=r,t[7]=f,t[8]=p,t[9]=w):w=t[9];let T;t[10]!==g||t[11]!==e||t[12]!==f?(T=f?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(io,"shrink-0"),children:n.jsx(Z,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Kt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=g,t[11]=e,t[12]=f,t[13]=T):T=t[13];const k=Ut;let I;t[14]!==e?(I=e("header.actions.openSessionsAria"),t[14]=e,t[15]=I):I=t[15];const F=i&&"text-foreground";let O;t[16]!==F?(O=Pe(io,"shrink-0",F),t[16]=F,t[17]=O):O=t[17];let B;t[18]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Z,{name:"layout-left",className:"h-4 w-4"}),t[18]=B):B=t[18];let j;t[19]!==i||t[20]!==O||t[21]!==I||t[22]!==o?(j=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":I,"aria-pressed":i,className:O,children:B})}),t[19]=i,t[20]=O,t[21]=I,t[22]=o,t[23]=j):j=t[23];const P=Kt,L=e("header.actions.openSessionsWithShortcut",{shortcut:c});let z;t[24]!==L?(z=n.jsx("p",{children:L}),t[24]=L,t[25]=z):z=t[25];let H;t[26]!==P||t[27]!==z?(H=n.jsx(P,{children:z}),t[26]=P,t[27]=z,t[28]=H):H=t[28];let R;t[29]!==k||t[30]!==j||t[31]!==H?(R=n.jsxs(k,{children:[j,H]}),t[29]=k,t[30]=j,t[31]=H,t[32]=R):R=t[32];let G;t[33]!==u||t[34]!==i||t[35]!==e?(G=i?n.jsxs("button",{type:"button",onClick:u,className:Pe(io,"-ms-1 w-auto min-w-0 px-1.5 font-normal"),children:[n.jsx(Z,{name:"chat-new",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Pe(io,"-ms-1 shrink-0"),children:n.jsx(Z,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Kt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=i,t[35]=e,t[36]=G):G=t[36];let _;t[37]!==R||t[38]!==G||t[39]!==w||t[40]!==T?(_=n.jsxs("div",{ref:d,className:v,children:[w,T,R,G]}),t[37]=R,t[38]=G,t[39]=w,t[40]=T,t[41]=_):_=t[41];let $;return t[42]!==_||t[43]!==m?($=n.jsx("div",{className:y,style:m,children:_}),t[42]=_,t[43]=m,t[44]=$):$=t[44],$};function Lv(t){return t.toggleSidebar}function $v(t){return t.isSidebarOpen}function zv(t){return t.shortcutOverrides}function Kv(){le.getState().closeMainSurfaces(),mt.getState().openNewSessionDraft()}function Wv(t){console.warn("[titlebar] failed to open app menu",t)}function Hv(t,e,s){const r=Ze.c(5),[o,i]=l.useState();let a,d;return r[0]!==s||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[u,f]=await Promise.all([lx(t),cx(t)]).catch(Uv);if(c)return;const p=yt(u),h=yt(f);if(!p||!h||h===p)return;const g=s||"",b=h.split("/").filter(Boolean).pop()||h;i({source:"sdk",path:h,projectDirectory:p,branch:g,label:g||b,name:b,worktreeRoot:h,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},d=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=a,r[4]=d):(a=r[3],d=r[4]),l.useEffect(a,d),e??o}function Uv(){return["",""]}const Vv=()=>{const t=Ze.c(3),e=le(Gv),s=le(qv);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function Gv(t){return t.setSettingsDialogOpen}function qv(t){return t.setSettingsPage}const gd="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Yv=({className:t,identity:e=Vf})=>{const{t:s}=Et(),{sourceControl:r}=Ks(),o=Uf(e),i=e.provider==="gitlab",a=i?"gitlab":"github-fill",d=o?.status??null,c=kn(S=>S.setStatus),[u,f]=l.useState(!1),p=l.useCallback(async S=>{if(!(!S||u)){f(!0);try{c(e,await r.authActivate(e,S))}catch(m){console.error("Failed to switch source control account:",m)}finally{f(!1)}}},[e,u,c,r]);if(d?.status!=="connected")return null;const h=d.user.username||null,g=d.user.avatarUrl??null,b=d.accounts,x=i?h?s("header.gitlab.connectedWithLogin",{login:h}):s("header.gitlab.connected"):h?s("header.github.connectedWithLogin",{login:h}):s("header.github.connected"),y=g?n.jsx("img",{src:g,alt:h?s("header.github.avatarWithLogin",{login:h}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Z,{name:a,className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?n.jsx("div",{className:Pe(gd,t),title:x,children:y}):n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe(gd,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:x,disabled:u,children:y})}),n.jsxs(Ms,{align:"end",className:"w-64",children:[n.jsx(Ma,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(In,{}),b.map(S=>{const m=S.user,v=!!S.current,w=s(dx(S.source??"oauth"));return n.jsxs(rs,{className:"gap-2",disabled:u,onSelect:()=>{v||p(S.id)},children:[m?.avatarUrl?n.jsx("img",{src:m.avatarUrl,alt:m.username?s("header.github.avatarWithLogin",{login:m.username}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:n.jsx(Z,{name:a,className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:m?.name?.trim()||m.username||(i?"GitLab":"GitHub")}),m.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:m.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),v?n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}):null]},S.id)})]})]})},Zv=t=>JSON.stringify(ux(t)),Qv=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},Jp=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Xv(t){if(!Jp(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function Jv(t,e,s){const r=Ze.c(16),{sourceControl:o}=Ks(),[i,a]=us.useState(null);let d;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(d=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=d):d=r[4];const c=d;let u;r[5]!==t||r[6]!==c||r[7]!==e||r[8]!==o?(u=()=>{if(t.provider!=="github")return;let p=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const g=h.items.find(b=>b.kind==="pull"&&b.number===e);g&&a({key:c,pull:g})}).catch(e0),()=>{p=!0}},r[5]=t,r[6]=c,r[7]=e,r[8]=o,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==c||r[12]!==e||r[13]!==s||r[14]!==o?(f=[t,c,e,s,o],r[10]=t,r[11]=c,r[12]=e,r[13]=s,r[14]=o,r[15]=f):f=r[15],us.useEffect(u,f),i?.key===c?i.pull:null}function e0(){}const t0=t=>{const e=Ze.c(60),{directory:s,context:r,changeRequest:o,onChanged:i}=t,a=Nn(),d=ns(s0),[c,u]=us.useState(0),[f,p]=us.useState(!1),h=Ml(),g=Jv(r,o.number,c);let b;e[0]!==o?(b=fx(o),e[0]=o,e[1]=b):b=e[1];const x=b;let y;e[2]!==g||e[3]!==x?(y=g?{...x,labels:g.labels,commentCount:g.commentCount}:x,e[2]=g,e[3]=x,e[4]=y):y=e[4];const S=y,{detail:m,refresh:v}=Gf(s,S,!0),w=cf(S);let T;e[5]!==i||e[6]!==v?(T=()=>{v(),u(n0),i()},e[5]=i,e[6]=v,e[7]=T):T=e[7];const k=T,I=df(S,r,k);let F;e[8]!==S?(F={source:"github",reference:S},e[8]=S,e[9]=F):F=e[9];const O=F,B=a??s;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j={status:"idle"},e[10]=j):j=e[10];let P;e[11]!==r||e[12]!==O||e[13]!==k?(P=n.jsx(vl,{item:O,project:null,context:r,onStartWorktree:o0,onChanged:k,worktreeAvailable:!1}),e[11]=r,e[12]=O,e[13]=k,e[14]=P):P=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=()=>p(!0),e[15]=L):L=e[15];let z;e[16]!==w.attachComment||e[17]!==w.attachComments?(z={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=z):z=e[18];let H;e[19]!==r||e[20]!==S||e[21]!==k?(H=n.jsx(pf,{reference:S,context:r,onChanged:k}),e[19]=r,e[20]=S,e[21]=k,e[22]=H):H=e[22];let R;e[23]!==r||e[24]!==m||e[25]!==S||e[26]!==k?(R=n.jsx(hf,{pull:S,detail:m,context:r,onChanged:k}),e[23]=r,e[24]=m,e[25]=S,e[26]=k,e[27]=R):R=e[27];let G;e[28]!==r||e[29]!==S||e[30]!==k?(G=n.jsx(uf,{reference:S,context:r,onRefresh:k},S.number),e[28]=r,e[29]=S,e[30]=k,e[31]=G):G=e[31];const _=d??"";let $;e[32]!==B||e[33]!==_?($={id:_,path:B},e[32]=B,e[33]=_,e[34]=$):$=e[34];let E;e[35]!==r||e[36]!==B||e[37]!==S||e[38]!==$?(E=n.jsx(mf,{pull:S,project:$,repository:null,context:r,projectOwnsDirectory:i0,currentDirectory:B}),e[35]=r,e[36]=B,e[37]=S,e[38]=$,e[39]=E):E=e[39];let D;e[40]!==m||e[41]!==s||e[42]!==O||e[43]!==h||e[44]!==R||e[45]!==G||e[46]!==E||e[47]!==P||e[48]!==z||e[49]!==H||e[50]!==I?(D=n.jsx(Al,{item:O,directory:s,pullStatus:Ol,linearDetail:j,githubDetail:m,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:r0,now:h,footer:P,onOpenChecks:L,commentAttachments:z,threadActions:I,labelsControl:H,reviewersControl:R,reply:G,pullLinks:E}),e[40]=m,e[41]=s,e[42]=O,e[43]=h,e[44]=R,e[45]=G,e[46]=E,e[47]=P,e[48]=z,e[49]=H,e[50]=I,e[51]=D):D=e[51];let C;e[52]!==w.attachFailedChecks||e[53]!==f||e[54]!==r||e[55]!==S?(C=n.jsx(ff,{pull:S,context:r,open:f,onOpenChange:p,onAttachFailed:w.attachFailedChecks}),e[52]=w.attachFailedChecks,e[53]=f,e[54]=r,e[55]=S,e[56]=C):C=e[56];let N;return e[57]!==D||e[58]!==C?(N=n.jsxs(n.Fragment,{children:[D,C]}),e[57]=D,e[58]=C,e[59]=N):N=e[59],N};function s0(t){return t.activeProjectId}function n0(t){return t+1}function r0(){}function o0(){}function i0(){return!0}function a0(t,e){const{git:s,sourceControl:r}=Ks(),{t:o}=Et(),i=Ib(),a=Pb({directory:t,branch:e,chooseContributor:i.choose}),d=Eb(t,s,r),c=async()=>{const f=d.start();if(!f)return He.info(o("gitView.pr.toast.gitBusy")),!1;const p=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await a.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(h){if(h instanceof px){if(h.code==="stale-runtime")return!1;const g=a.errorMessage(h);return g?He.info(g):He.error(p),!1}return h instanceof hx||h instanceof mx?(He.error(p,{description:h.message||void 0}),!1):(He.error(p,{description:h instanceof Error?h.message:String(h)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[a.context?n.jsx(Tb,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,n.jsx(Db,{candidates:i.candidates,onSelect:i.settle})]});return{push:c,dialogs:u}}const l0=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"}},c0=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=mt.getState(),o=s?r(s):null;!s||!o||yt(o)!==yt(t)||Cx(s,o,Ix({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},d0=t=>{const e=t?.changeRequest??t?.pr;return e?Px({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},u0=[2e3,5e3];let bd=0;const f0=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(bd+=1,`source-control-${Date.now().toString(36)}-${bd.toString(36)}`)},p0=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),eh="openchamber:pr-create-as-draft:v1",yd=()=>{try{return localStorage.getItem(eh)==="true"}catch{return!1}},h0=t=>{try{localStorage.setItem(eh,String(t))}catch{}},oa=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Sn=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):""},m0=(t,e)=>{const s=Sn(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},g0=(t,e)=>`${t}::${e}`,ia=new Map,xd=xr;function b0(t,e,s){const r=Ze.c(14);let o;r[0]!==s?(o=s?Zv(s):null,r[0]=s,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[d,c]=l.useState(a);let u,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!i)return;let h=!1;return(async()=>{try{const g=await Qv(e,s);h||c({contextKey:i,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{h=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),l.useEffect(u,f);let p;return r[9]!==i||r[10]!==d.contextKey||r[11]!==d.detectedUpstream||r[12]!==d.upstreamBranches?(p=d.contextKey===i?{detectedUpstream:d.detectedUpstream,upstreamBranches:d.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=d.contextKey,r[11]=d.detectedUpstream,r[12]=d.upstreamBranches,r[13]=p):p=r[13],p}const y0=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:d}=Et(),c=qf(t),u=l.useCallback((Qe,vt)=>d(pn(Qe,c?.provider),vt),[c?.provider,d]),f=Vv(),{sourceControl:p}=Ks(),h=kn(Qe=>Qe.entries),{isMobile:g,hasTouchInput:b,screenWidth:x}=Rn(),y=le(Qe=>Qe.openContextSurface),S=gx(Qe=>Qe.requestTarget),m=!g&&x>=768&&!Dn(),v=l.useMemo(()=>g0(t,e),[t,e]),w=l.useMemo(()=>ia.get(v)??null,[v]),T=ys(Qe=>Qe.ensureEntry),k=ys(Qe=>Qe.setParams),I=ys(Qe=>Qe.beginActiveContextsLoad),F=ys(Qe=>Qe.commitActiveContexts),O=ys(Qe=>Qe.releaseActiveContexts),B=l.useId(),j=ys(Qe=>Qe.startWatching),P=ys(Qe=>Qe.stopWatching),L=ys(Qe=>Qe.refresh),[z,H]=l.useState(()=>w?.title??oa(e)),[R,G]=l.useState(()=>w?.body??""),[_,$]=l.useState(()=>w?.draft??yd()),[E,D]=l.useState(()=>w?.additionalContext??""),[C,N]=l.useState(()=>{const Qe=typeof w?.targetBaseBranch=="string"?Sn(w.targetBaseBranch):"";return Qe||Sn(s)}),[A,q]=l.useState(!1),[ee,Q]=l.useState(!1),[he,M]=l.useState(!1),V=Yf(t,p),ie=V.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const Qe=V.scope.runtimeKey,vt=I(Qe,t,B),$t=V.contexts.filter(ve=>Aa(h[er(ve)],ve).connected);return F(Qe,t,B,vt,$t),()=>{O(Qe,t,B)}},[I,V.contexts,V.scope.runtimeKey,F,t,O,h,B]);const ne=V.contexts[0]??null,je=kn(Qe=>c?Qe.entries[er(c)]?.hasChecked===!0:!1),Ee=ne?.primaryRemote??null,we=l.useMemo(()=>ne?er(ne):"",[ne]),Me=kn(Qe=>Qe.entries[we]),fe=ne?Aa(Me,ne):{authChecked:Me?.hasChecked??!1,connected:!1},be=fe.authChecked,[ke,Ie]=l.useState(0),[Te,Y]=l.useState({key:"",status:"loading",capabilities:null}),[ue,me]=l.useState(!1),{detectedUpstream:re,upstreamBranches:pe}=b0(t,p,ne);l.useEffect(()=>{if(!ne)return;let Qe=!1;const vt=er(ne);return Y({key:vt,status:"loading",capabilities:null}),p.capabilities(ne).then($t=>{Qe||Y({key:vt,status:"ready",capabilities:$t})}).catch(()=>{Qe||Y({key:vt,status:"error",capabilities:null})}),()=>{Qe=!0}},[ke,ne,p]);const U=Te.key===we?Te:null,ae=U?.status==="ready"?U.capabilities:null;l.useEffect(()=>{me(!1)},[t]);const W=!!(t&&e&&s&&(e!==s||re!==null)),ye=l.useMemo(()=>ne?Zf(ne,e):"",[e,ne]),de=l.useRef(ye);de.current=ye;const Ne=l.useCallback((Qe,vt)=>Qe===Jt()&&vt===de.current,[]),Je=ys(Qe=>Qe.entries[ye]),Ge=l.useMemo(()=>ye?[ye]:[],[ye]);Qf(Xf(Ge));const ge=Je?.isLoading??!1,Ae=fe.connected?Je?.status??null:null,Ye=V.error?u("settings.gitlab.status.operationFailed"):Je?.error??null,nt=Je?.isInitialStatusResolved??!1,oe=l.useMemo(()=>{const Qe=ue?null:Ee,vt=new Set;for(const ct of i){const ht=m0(ct,Qe);!ht||ht==="HEAD"||vt.add(ht)}if(ue)for(const ct of pe)ct&&ct!=="HEAD"&&vt.add(ct);const $t=Sn(s);$t&&$t!=="HEAD"&&vt.add($t);const ve=Sn(C);return ve&&ve!=="HEAD"&&vt.add(ve),Array.from(vt).sort((ct,ht)=>ct.localeCompare(ht))},[s,i,Ee,C,pe,ue]);l.useEffect(()=>{const Qe=Sn(s);if(!C&&Qe){N(Qe);return}if(oe.length!==0&&!oe.includes(C)){const vt=oe.includes(Qe)?Qe:oe[0];vt&&N(vt)}},[oe,s,C]);const tt=l.useRef([]),Ue=l.useRef(new Map),gt=l.useCallback(Qe=>{const vt=Ue.current.get(Qe);if(vt?.inFlight)return null;if(vt)return vt.inFlight=!0,vt.key;const $t=f0();return Ue.current.set(Qe,{key:$t,inFlight:!0}),$t},[]),bt=l.useCallback((Qe,vt,$t)=>{const ve=Ue.current.get(Qe);!ve||ve.key!==vt||($t?ve.inFlight=!1:Ue.current.delete(Qe))},[]);l.useEffect(()=>{re&&me(!0)},[re]),l.useEffect(()=>{ue&&re?.defaultBranch&&N(re.defaultBranch)},[ue,re?.defaultBranch]);const Ce=Ae?.changeRequest??Ae?.pr??null,_e=Ae?.identity??ne,ze=l.useMemo(()=>Ae?.project??(Ae?.repo&&_e?{...Ae.repo,..._e,id:`${Ae.repo.owner}/${Ae.repo.repo}`,name:Ae.repo.repo}:null),[Ae?.project,Ae?.repo,_e]),Oe=Ce?.state==="merged"||Ce?.state==="closed",it=Oe?null:Ce,X=Ae?.ci?.summary??Ae?.checks??null,[Be,Le]=l.useState(!1),at=l.useRef(!0);l.useEffect(()=>(at.current=!0,()=>{at.current=!1}),[]);const qe=l.useCallback(async Qe=>{await L(ye,Qe)},[ye,L]),ut=l.useCallback((Qe,vt)=>{tt.current.forEach($t=>{window.clearTimeout($t)}),tt.current=u0.map($t=>window.setTimeout(()=>{Ne(Qe,vt)&&L(vt,{force:!0,silent:!0,markInitialResolved:!0})},$t))},[Ne,L]),dt=l.useCallback(async(Qe,vt,$t)=>{await Xv({error:Qe,isCurrent:()=>Ne(vt,$t),refresh:()=>L($t,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>ut(vt,$t)})},[Ne,L,ut]);l.useEffect(()=>{!ne||!ye||(T(ye),k(ye,{directory:t,branch:e,remoteName:ne.primaryRemote,canShow:W,identity:ne,readContext:ne,sourceControl:p,authChecked:fe.authChecked,connected:fe.connected}))},[e,W,t,T,ye,ne,p,fe.authChecked,fe.connected,k]);const ft=600,st=l.useCallback(async()=>{if(Be)return;Le(!0);const Qe=Date.now();try{await qe({force:!0})}finally{const vt=ft-(Date.now()-Qe);vt>0&&await new Promise($t=>window.setTimeout($t,vt)),at.current&&Le(!1)}},[Be,qe]);l.useEffect(()=>{if(!(!ne||!ye))return j(ye),()=>{P(ye)}},[ye,ne,j,P]),l.useEffect(()=>{const Qe=ia.get(v)??null;H(Qe?.title??oa(e)),G(Qe?.body??""),$(Qe?.draft??yd()),N(Qe?.targetBaseBranch?Sn(Qe.targetBaseBranch):Sn(s))},[s,e,v]),l.useEffect(()=>{!ne||!ye||!fe.connected||qe({markInitialResolved:!0})},[ye,ne,qe,fe.connected]),l.useEffect(()=>{!W||!ne||!fe.connected||qe({force:!0,silent:!0,markInitialResolved:!0})},[W,ne,qe,fe.connected]),l.useEffect(()=>{const Qe=()=>{const $t=ys.getState().entries[ye]?.lastRefreshAt??0;Date.now()-$t>6e4&&qe({force:!0,silent:!0})},vt=()=>{document.visibilityState==="visible"&&Qe()};return window.addEventListener("focus",Qe),document.addEventListener("visibilitychange",vt),()=>{window.removeEventListener("focus",Qe),document.removeEventListener("visibilitychange",vt)}},[ye,qe]),l.useEffect(()=>{be&&!fe.connected&&qe({force:!0,silent:!0,markInitialResolved:!0})},[qe,fe.connected,be]),l.useEffect(()=>{!t||!e||ia.set(v,{title:z,body:R,draft:_,additionalContext:E,targetBaseBranch:C})},[v,z,R,_,E,C,t,e]),l.useEffect(()=>()=>{tt.current.forEach(Qe=>{window.clearTimeout(Qe)}),tt.current=[]},[ye,ie]),l.useEffect(()=>()=>{Ue.current.clear()},[]);const Rt=ue&&re?.defaultBranchSha?re.defaultBranchSha:ne?`${ne.primaryRemote}/${C}`:C;l.useEffect(()=>{if(!t||!e||!Rt)return;let Qe=!1;return bx(t,{from:Rt,to:e,maxCount:2}).then(vt=>{const $t=vt.all.length===1?vt.all[0]?.message.trim():"";Qe||!$t||H(ve=>ve===oa(e)?$t:ve)}).catch(()=>{}),()=>{Qe=!0}},[e,Rt,t]);const Ke=!r||o>0,jt=a0(t,e),Lt=l.useId(),Mt=Qe=>{$(Qe),h0(Qe)},De=l.useCallback(async()=>{if(!A&&t){q(!0);try{const vt={base:Rt,head:e,...ne?.provider?{changeRequestProvider:ne.provider}:{}};E&&(vt.context=E);const $t=await yx(t,vt);$t.title?.trim()&&H($t.title.trim()),$t.body?.trim()&&G($t.body.trim()),a?.()}catch(Qe){const vt=Qe instanceof Error?Qe.message:String(Qe);He.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:vt})}finally{q(!1)}}},[E,e,Rt,t,A,a,ne,u]),Tt=l.useCallback(async()=>{if(ae?.changeRequests!==!0){He.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const Qe=z.trim();if(!Qe){He.error(u("gitView.pr.toast.titleRequired"));return}const vt=C.trim();if(!vt){He.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!ue&&vt===e){He.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const $t=ue?re:ze;if(!ne||!$t){He.error(u("gitView.pr.toast.createPrFailed"),{description:Ye??u("gitView.pr.statusUnavailable")});return}if(Ke&&(Q(!0),!await jt.push())){Q(!1);return}const ve=Jt(),ct=ye,ht={owner:$t.owner,name:$t.name},Ot=R.trim()?R:void 0,te=ue?void 0:ne.primaryRemote,et=ue?ne.primaryRemote:void 0,xt=p0(ve,ne,[ht.owner,ht.name,e,vt,Qe,Ot,_,te,et]),It=gt(xt);if(!It){Q(!1);return}Q(!0);let St=!1,Se=!1;try{const We={...ne,idempotencyKey:It,target:{project:ht,head:e,base:vt},title:Qe,draft:_};Ot!==void 0&&(We.body=Ot),te&&(We.remote=te),et&&(We.headRemote=et);const K=await p.changeRequestCreate(We);if(Se=!0,bt(xt,It,!1),!Ne(ve,ct)||(He.success(u("gitView.pr.toast.prCreated")),await qe({force:!0}),!Ne(ve,ct)))return;const xe=ys.getState().entries[ct]?.status,Xe=xe?.changeRequest??xe?.pr;Xe&&Xe.number===K.target.number&&c0(t,Xe),ut(ve,ct)}catch(We){const K=We instanceof Error?We:new Error(String(We));St=Jp(K);const xe=K.message;He.error(u("gitView.pr.toast.createPrFailed"),{description:xe}),St&&await dt(K,ve,ct)}finally{Se||bt(xt,It,St),Q(!1)}},[gt,R,e,jt,re,t,_,Ye,bt,Ne,Ke,ye,ne,dt,qe,ut,p,ae?.changeRequests,ze,C,z,ue,u]),At="border-0 bg-transparent rounded-none px-4 py-3";if(!W)return n.jsx("section",{className:At,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:u("gitView.pullRequest.availableOnFeatureBranches")}),n.jsx(Yv,{identity:c??void 0})]})});const kt=Ae?.changeRequest&&Ae.changeRequest.state==="open"?Ae.changeRequest:it&&ze&&_e?{..._e,id:`${ze.owner}/${ze.name}#${it.number}`,number:it.number,project:{..._e,id:ze.id,owner:ze.owner,name:ze.name,url:ze.url??""},title:it.title,body:it.body,url:it.url,state:it.state,draft:it.draft,base:it.base,head:it.head,headSha:it.headSha,mergeable:it.mergeable,mergeableState:it.mergeableState}:null;if(kt&&ne)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(t0,{directory:t,context:ne,changeRequest:kt,onChanged:()=>{qe({force:!0,silent:!0,markInitialResolved:!0})}})});const pt=ze?.url||null,Dt=ue&&re?.url?re.url:pt,Ve=U?.status==="error",rt=!!Ae?.connected,wt=!!(!ne&&c&&V.status==="ready"&&je),se=!!(_e&&be&&Ae?.connected===!1)||wt,Fe=_e??c,ot=Fe?xx(Fe.provider):null,$e=d0(Ae),Ct=$e?`var(--pr-${$e})`:"var(--status-info)",Yt=$e==="draft"?"git-pr-draft":$e==="merged"?"git-merge":$e==="closed"?"git-close-pull-request":"git-pull-request",es=Ce?[`${Ce.state}${Ce.draft?" (draft)":""}`,Ce.state==="open"&&Ce.mergeable===!1?u("gitView.pr.notMergeable"):null,Ce.state==="open"&&typeof Ce.mergeableState=="string"&&Ce.mergeableState&&Ce.mergeableState!=="unknown"?Ce.mergeableState:null].filter(Boolean).join(" · "):"",Zt=X?X.total>0?`${X.success}/${X.total} ${u("gitView.pr.checks.label")}`:`${X.state} ${u("gitView.pr.checks.label")}`:"",ss="px-0 py-3 border-b border-border/40 flex flex-col gap-1",bs="flex flex-col gap-3 py-3",ls=n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:ge||Be,onClick:()=>{st()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Z,{name:ge||Be?"loader-4":"refresh",className:Pe("size-4 text-muted-foreground",(ge||Be)&&"animate-spin")})})}),n.jsx(Kt,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),ms=he||E.trim().length>0,fs=Ke?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,Es=u(Ke?_?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":_?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),cs=ee||!rt||ae?.changeRequests!==!0||!C.trim()||!ue&&C.trim()===e;return n.jsxs("section",{className:At,children:[Ce?n.jsxs("div",{className:ss,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs(Nt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{xd(Ce.url)},"aria-label":ot?u("gitView.pr.actions.openOnProviderAria",{provider:ot}):u("gitView.header.openPullRequest"),children:[n.jsx(Z,{name:Yt,className:"size-4 shrink-0",style:{color:Ct}}),ot?u("gitView.pr.actions.openOnProvider",{provider:ot}):u("gitView.header.openPullRequest")]}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:u("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:Bl(_e?.provider,Ce.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:ls})]}),n.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:Ct},children:es}),X?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${l0(X.state)}`}),Zt]}):null,r&&Ee&&r.split("/")[0]!==Ee?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Ee]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:m&&(ne?.provider==="github"||ne?.provider==="gitlab")?n.jsxs(Nt,{variant:"outline",size:"sm",className:Pe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Rb),onClick:()=>{S(t,{source:{kind:"pr",number:Ce.number,...ze?{sourceRepo:{owner:ze.owner,repo:ze.name}}:{}},context:ne}),y(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx(Z,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}):null})]})]}):null,n.jsxs("div",{className:bs,children:[Ve?n.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:u("gitView.pr.capabilitiesUnavailable")}),n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>Ie(Qe=>Qe+1),children:u("settings.sourceControl.transport.retry")})]}):null,se&&ot?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:ot})}),n.jsx(Nt,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,Ye?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:u("gitView.pr.statusUnavailable")}),n.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:Ye}),V.error?n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>{V.retry()},disabled:V.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,Dt?n.jsx(Nt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:Dt,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Z,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(it||!Ce&&!nt)&&!Ye&&!se&&(V.status==="loading"||ne)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Fo,{className:"size-4"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Ce&&Oe?n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[n.jsx(Z,{name:Ce.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ct}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ce.state==="merged"?u("gitView.pr.history.merged",{number:Ce.number,base:Ce.base||C}):u("gitView.pr.history.closed",{number:Ce.number})}),n.jsx(Nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{xd(Ce.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:ot}),children:n.jsx(Z,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(Z,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(Z,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),ue&&re?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[re.owner,"/",re.name]}):null,oe.length>0?n.jsxs(Sx,{value:C,onValueChange:N,children:[n.jsx(wx,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(vx,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(jx,{children:oe.map(Qe=>n.jsx(kx,{value:Qe,children:Qe},Qe))})]}):n.jsx(_o,{value:C,onChange:Qe=>N(Qe.target.value),placeholder:u("gitView.pr.placeholder.main"),"aria-label":u("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Dt?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:Dt,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx(Z,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Kt,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,ls]})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.title")}),n.jsx(_o,{value:z,onChange:Qe=>H(Qe.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:Lt,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Nt,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:De,disabled:A||ee,children:[A?n.jsx(Z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(Z,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:A||ee,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Ms,{align:"end",className:"w-60",children:n.jsxs(rs,{onSelect:()=>M(!0),children:[n.jsx(Z,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),ms?n.jsxs("div",{className:"relative",children:[n.jsx(Uc,{value:E,onChange:Qe=>D(Qe.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:he&&!E}),n.jsx(Nt,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{D(""),M(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Z,{name:"close",className:"size-3.5"})})]}):null,n.jsx(Uc,{id:Lt,value:R,onChange:Qe=>G(Qe.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),fs?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(Z,{name:"arrow-up",className:"size-3.5 shrink-0"}),fs]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Nt,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:Tt,disabled:cs,children:[ee?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Z,{name:_?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Es})]}),n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:ee,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Ms,{align:"end",className:"w-56",children:n.jsxs(Jf,{value:_?"draft":"ready",onValueChange:Qe=>Mt(Qe==="draft"),children:[n.jsx(Lo,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(Lo,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),jt.dialogs]})]})]})},x0=()=>{const t=Ze.c(94),{t:e}=Et(),{git:s,sourceControl:r}=Ks(),o=Nn(),{rootIsGitRepo:i,gitDirectory:a,nestedRepos:d,repositoryOptions:c}=Ex(o??null),u=hi(a??null),f=Tx(a??null),p=Dx(a??null),h=Yf(a,r),{ensureAll:g,ensureNestedRepos:b,selectNestedRepo:x}=Cn(hr(S0)),y=mt(w0),S=mt(v0),m=mt(j0),v=mt(k0);let w;t[0]!==o?(w=yt(o),t[0]=o,t[1]=w):w=t[1];const T=w;let k;e:{if(!T){k=void 0;break e}let be;t[2]!==v||t[3]!==T||t[4]!==m?(be=Lr(v,T)??Lr(m.values(),T),t[2]=v,t[3]=T,t[4]=m,t[5]=be):be=t[5],k=be}const I=k;let F;t[6]!==y||t[7]!==I||t[8]!==S?.open||t[9]!==m?(F=()=>{if(y)return m.get(y)??I;if(S?.open)return I},t[6]=y,t[7]=I,t[8]=S?.open,t[9]=m,t[10]=F):F=t[10],S?.open;let O;t[11]!==F?(O=F(),t[11]=F,t[12]=O):O=t[12];const B=O;let j;t[13]!==y?(j=be=>y?be.getAttachment(y):void 0,t[13]=y,t[14]=j):j=t[14];const P=Mf(j),L=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,z=Hv(o,B,u?.current??void 0);let H,R;t[15]!==g||t[16]!==s||t[17]!==a?(H=()=>{!a||!s||g(a,s)},R=[a,g,s],t[15]=g,t[16]=s,t[17]=a,t[18]=H,t[19]=R):(H=t[18],R=t[19]),l.useEffect(H,R);const[G,_]=l.useState(null);let $;t[20]!==L||t[21]!==z?.projectDirectory?($=()=>{const be=L||z?.projectDirectory;if(!be){_(null);return}let ke=!1;return ep(be).then(Ie=>{if(ke)return;const Te=Ie.trim();_(Te&&Te!=="HEAD"?Te:null)}).catch(()=>{ke||_(null)}),()=>{ke=!0}},t[20]=L,t[21]=z?.projectDirectory,t[22]=$):$=t[22];const E=z?.projectDirectory;let D;t[23]!==L||t[24]!==E?(D=[L,E],t[23]=L,t[24]=E,t[25]=D):D=t[25],l.useEffect($,D);let C;e:{if(!f?.all){let ke;t[26]===Symbol.for("react.memo_cache_sentinel")?(ke=[],t[26]=ke):ke=t[26],C=ke;break e}let be;t[27]!==f.all?(be=f.all.filter(C0).sort(),t[27]=f.all,t[28]=be):be=t[28],C=be}const N=C;let A;e:{if(!f?.all){let ke;t[29]===Symbol.for("react.memo_cache_sentinel")?(ke=[],t[29]=ke):ke=t[29],A=ke;break e}let be;t[30]!==f.all?(be=f.all.filter(I0).map(P0).sort(),t[30]=f.all,t[31]=be):be=t[31],A=be}const q=A,ee=u?.current??null,Q=h.contexts[0]?.primaryRemote,he=Q?f?.defaultBranches?.[Q]:void 0;let M;t[32]!==h.contexts[0]||t[33]!==h.read?.repository.remotes||t[34]!==ee||t[35]!==he||t[36]!==N||t[37]!==G||t[38]!==z?.createdFromBranch?(M=()=>Nb({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(E0)??[]),localBranches:N,worktreeCreatedFromBranch:z?.createdFromBranch,rootBranchHint:G,defaultBranch:he,headBranch:ee,fallbackToConventional:!1}),t[32]=h.contexts[0],t[33]=h.read?.repository.remotes,t[34]=ee,t[35]=he,t[36]=N,t[37]=G,t[38]=z?.createdFromBranch,t[39]=M):M=t[39],z?.createdFromBranch;let V;t[40]!==M?(V=M(),t[40]=M,t[41]=V):V=t[41];const ie=V,ce=qf(o??null)?.provider;if(!o){let be;t[42]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[42]=be):be=t[42];let ke;t[43]!==ce||t[44]!==e?(ke=e(pn("gitView.pullRequest.title",ce)),t[43]=ce,t[44]=e,t[45]=ke):ke=t[45];let Ie;t[46]!==ke?(Ie=n.jsx("div",{className:"typography-ui-header text-foreground",children:ke}),t[46]=ke,t[47]=Ie):Ie=t[47];let Te;t[48]!==ce||t[49]!==e?(Te=e(pn("gitView.pullRequest.createHint",ce)),t[48]=ce,t[49]=e,t[50]=Te):Te=t[50];let Y;t[51]!==Te?(Y=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[51]=Te,t[52]=Y):Y=t[52];let ue;return t[53]!==Ie||t[54]!==Y?(ue=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ie,Y]}),t[53]=Ie,t[54]=Y,t[55]=ue):ue=t[55],ue}if(i===!1&&p!==!0){let be;t[56]!==o||t[57]!==b?(be=()=>{b(o,{force:!0})},t[56]=o,t[57]=b,t[58]=be):be=t[58];let ke;return t[59]!==o||t[60]!==p||t[61]!==d||t[62]!==i||t[63]!==be?(ke=n.jsx(Mb,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:p,nestedRepos:d,onRetryDiscovery:be}),t[59]=o,t[60]=p,t[61]=d,t[62]=i,t[63]=be,t[64]=ke):ke=t[64],ke}if(!ee){let be;t[65]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[65]=be):be=t[65];let ke;t[66]!==ce||t[67]!==e?(ke=e(pn("gitView.pullRequest.title",ce)),t[66]=ce,t[67]=e,t[68]=ke):ke=t[68];let Ie;t[69]!==ke?(Ie=n.jsx("div",{className:"typography-ui-header text-foreground",children:ke}),t[69]=ke,t[70]=Ie):Ie=t[70];let Te;t[71]!==ce||t[72]!==e?(Te=e(pn("gitView.pullRequest.createHint",ce)),t[71]=ce,t[72]=e,t[73]=Te):Te=t[73];let Y;t[74]!==Te?(Y=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[74]=Te,t[75]=Y):Y=t[75];let ue;return t[76]!==Ie||t[77]!==Y?(ue=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ie,Y]}),t[76]=Ie,t[77]=Y,t[78]=ue):ue=t[78],ue}let ne;t[79]!==o||t[80]!==a||t[81]!==c||t[82]!==x?(ne=c?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(Ab,{repositories:c,selectedRepository:a??null,onSelectRepository:be=>{o&&x(o,be)},repositoryRoot:o??void 0})}):null,t[79]=o,t[80]=a,t[81]=c,t[82]=x,t[83]=ne):ne=t[83];const je=a??o,Ee=u?.tracking??void 0,we=u?.ahead??0;let Me;t[84]!==ie||t[85]!==ee||t[86]!==q||t[87]!==je||t[88]!==Ee||t[89]!==we?(Me=n.jsx(Qr,{as:Rx,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(y0,{directory:je,branch:ee,baseBranch:ie,trackingBranch:Ee,ahead:we,remoteBranches:q})}),t[84]=ie,t[85]=ee,t[86]=q,t[87]=je,t[88]=Ee,t[89]=we,t[90]=Me):Me=t[90];let fe;return t[91]!==ne||t[92]!==Me?(fe=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ne,Me]}),t[91]=ne,t[92]=Me,t[93]=fe):fe=t[93],fe};function S0(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function w0(t){return t.currentSessionId}function v0(t){return t.newSessionDraft}function j0(t){return t.worktreeMetadata}function k0(t){return t.availableWorktrees}function C0(t){return!t.startsWith("remotes/")}function I0(t){return t.startsWith("remotes/")}function P0(t){return t.replace(/^remotes\//,"")}function E0(t){return t.name}const T0=t=>{const e=Ze.c(15);let s;e[0]!==t.url?(s=tp(t.url),e[0]=t.url,e[1]=s):s=e[1];const r=s;Ob(t.visible);const{panelDirectory:o,tabId:i,url:a}=t;let d;e[2]!==o||e[3]!==i||e[4]!==a?(d=()=>{Lx(o,i)&&(xr(a),le.getState().closeContextPanelTab(o,i))},e[2]=o,e[3]=i,e[4]=a,e[5]=d):d=e[5];const c=d;let u;e[6]!==o||e[7]!==i?(u=()=>$x(o,i),e[6]=o,e[7]=i,e[8]=u):u=e[8];const f=u;let p;if(e[9]!==c||e[10]!==t||e[11]!==f||e[12]!==r||e[13]!==a){const h=r?r.source==="linear"?n.jsx(R0,{url:a,identifier:r.identifier,onUnavailable:c,onShown:f}):n.jsx(D0,{...t,kind:r.kind,onUnavailable:c,onShown:f}):n.jsx(Yl,{url:a});p=n.jsx("div",{className:"h-full min-h-0",children:h}),e[9]=c,e[10]=t,e[11]=f,e[12]=r,e[13]=a,e[14]=p}else p=e[14];return p},Ar=t=>{const e=Ze.c(8),{message:s,onRetry:r}=t,{t:o}=Et();let i;e[0]!==s?(i=n.jsx("span",{children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?n.jsx(Nt,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=a):a=e[4];let d;return e[5]!==i||e[6]!==a?(d=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,a]}),e[5]=i,e[6]=a,e[7]=d):d=e[7],d},Yl=t=>{const e=Ze.c(14),{url:s}=t,{t:r}=Et();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=n.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==s?(a=()=>{xr(s)},e[4]=s,e[5]=a):a=e[5];let d;e[6]!==r?(d=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==d?(c=n.jsx(Nt,{size:"sm",variant:"outline",onClick:a,children:d}),e[8]=a,e[9]=d,e[10]=c):c=e[10];let u;return e[11]!==i||e[12]!==c?(u=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u},D0=t=>{const e=Ze.c(105),{url:s,directory:r,panelDirectory:o,foreign:i,kind:a,onUnavailable:d,onShown:c}=t,{t:u}=Et(),{sourceControl:f}=Ks(),p=ns(N0),h=Fb(r,s),g=h.directory,b=h.status==="ready";let x;e[0]!==a||e[1]!==g||e[2]!==b||e[3]!==s?(x={enabled:b,directory:g,kind:a,filter:zx,query:s},e[0]=a,e[1]=g,e[2]=b,e[3]=s,e[4]=x):x=e[4];const y=Ox(x);let S;e[5]!==y.items||e[6]!==s?(S=y.items.find(Y=>Bx(Y.url,s))??null,e[5]=y.items,e[6]=s,e[7]=S):S=e[7];const m=S,v=Fx(g),w=v&&v!=="missing"?v:null,T=(y.status==="ready"||y.status==="unavailable")&&!y.refreshing&&!m;let k,I;e[8]!==d||e[9]!==T?(k=()=>{T&&d()},I=[d,T],e[8]=d,e[9]=T,e[10]=k,e[11]=I):(k=e[10],I=e[11]),us.useEffect(k,I);const F=m!==null;let O,B;e[12]!==F||e[13]!==c?(O=()=>{F&&c()},B=[F,c],e[12]=F,e[13]=c,e[14]=O,e[15]=B):(O=e[14],B=e[15]),us.useEffect(O,B);const{detail:j,refresh:P}=Gf(g,m,!0);let L;e[16]!==m?(L=m?[m]:[],e[16]=m,e[17]=L):L=e[17];const z=_x(g,L),H=cf(m),[R,G]=us.useState(!1),_=Ml(),{retry:$}=y;let E;e[18]!==P||e[19]!==$?(E=()=>Promise.all([P(),$()]).then(M0),e[18]=P,e[19]=$,e[20]=E):E=e[20];const D=E,C=df(m,w,D);let N;e[21]!==w||e[22]!==D||e[23]!==f?(N=async()=>{w&&await f.refreshProviderReads(w).catch(A0),Kx(),await D()},e[21]=w,e[22]=D,e[23]=f,e[24]=N):N=e[24];const A=N;if(!m){if(T){let ue;return e[25]!==s?(ue=n.jsx(Yl,{url:s}),e[25]=s,e[26]=ue):ue=e[26],ue}if(h.status==="failed"){let ue;e[27]!==u?(ue=u("gitView.empty.discoverFailed"),e[27]=u,e[28]=ue):ue=e[28];let me;return e[29]!==h.retry||e[30]!==ue?(me=n.jsx(Ar,{message:ue,onRetry:h.retry}),e[29]=h.retry,e[30]=ue,e[31]=me):me=e[31],me}let Y;return e[32]!==y.error||e[33]!==y.status||e[34]!==$||e[35]!==u?(Y=y.status==="error"?n.jsx(Ar,{message:y.error??u("contextPanel.tracker.loadFailed"),onRetry:()=>{$()}}):n.jsx(Ar,{message:u("common.loading")}),e[32]=y.error,e[33]=y.status,e[34]=$,e[35]=u,e[36]=Y):Y=e[36],Y}let q;e[37]!==m?(q={source:"github",reference:m},e[37]=m,e[38]=q):q=e[38];const ee=q,Q=m.kind==="pull"?m:null;let he;e[39]!==Q||e[40]!==z?(he=Q?z(Q):Ol,e[39]=Q,e[40]=z,e[41]=he):he=e[41];let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M={status:"idle"},e[42]=M):M=e[42];let V;e[43]!==D?(V=()=>{D()},e[43]=D,e[44]=V):V=e[44];let ie;e[45]!==w||e[46]!==ee||e[47]!==V?(ie=n.jsx(vl,{item:ee,project:null,context:w,onStartWorktree:B0,onChanged:V,worktreeAvailable:!1}),e[45]=w,e[46]=ee,e[47]=V,e[48]=ie):ie=e[48];let ce;e[49]!==w||e[50]!==Q?(ce=Q&&w?()=>G(!0):void 0,e[49]=w,e[50]=Q,e[51]=ce):ce=e[51];const ne=w?A:void 0;let je;e[52]!==w||e[53]!==ee||e[54]!==m.state||e[55]!==D?(je=m.state!=="merged"&&w?n.jsx(_b,{item:ee,context:w,onChanged:()=>{D()}}):void 0,e[52]=w,e[53]=ee,e[54]=m.state,e[55]=D,e[56]=je):je=e[56];let Ee;e[57]!==H.attachComment||e[58]!==H.attachComments?(Ee={onAttach:H.attachComment,onAttachAll:H.attachComments},e[57]=H.attachComment,e[58]=H.attachComments,e[59]=Ee):Ee=e[59];let we;e[60]!==w||e[61]!==m||e[62]!==D?(we=w?n.jsx(pf,{reference:m,context:w,onChanged:D}):void 0,e[60]=w,e[61]=m,e[62]=D,e[63]=we):we=e[63];let Me;e[64]!==w||e[65]!==j||e[66]!==Q||e[67]!==D?(Me=Q&&w?n.jsx(hf,{pull:Q,detail:j,context:w,onChanged:D}):void 0,e[64]=w,e[65]=j,e[66]=Q,e[67]=D,e[68]=Me):Me=e[68];let fe;e[69]!==w||e[70]!==m||e[71]!==D?(fe=w?n.jsx(uf,{reference:m,context:w,onRefresh:D}):void 0,e[69]=w,e[70]=m,e[71]=D,e[72]=fe):fe=e[72];let be;e[73]!==p||e[74]!==w||e[75]!==r||e[76]!==i||e[77]!==o||e[78]!==Q||e[79]!==g?(be=Q&&w?n.jsx(mf,{pull:Q,project:{id:p??"",path:r},repository:g,context:w,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[73]=p,e[74]=w,e[75]=r,e[76]=i,e[77]=o,e[78]=Q,e[79]=g,e[80]=be):be=e[80];let ke;e[81]!==j||e[82]!==ee||e[83]!==_||e[84]!==g||e[85]!==he||e[86]!==ie||e[87]!==ce||e[88]!==ne||e[89]!==je||e[90]!==Ee||e[91]!==we||e[92]!==Me||e[93]!==fe||e[94]!==be||e[95]!==C?(ke=n.jsx(Al,{item:ee,directory:g,pullStatus:he,linearDetail:M,githubDetail:j,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:O0,now:_,footer:ie,onOpenChecks:ce,onRefresh:ne,threadActions:C,stateMenu:je,commentAttachments:Ee,labelsControl:we,reviewersControl:Me,reply:fe,pullLinks:be}),e[81]=j,e[82]=ee,e[83]=_,e[84]=g,e[85]=he,e[86]=ie,e[87]=ce,e[88]=ne,e[89]=je,e[90]=Ee,e[91]=we,e[92]=Me,e[93]=fe,e[94]=be,e[95]=C,e[96]=ke):ke=e[96];let Ie;e[97]!==H.attachFailedChecks||e[98]!==R||e[99]!==w||e[100]!==Q?(Ie=Q&&w?n.jsx(ff,{pull:Q,context:w,open:R,onOpenChange:G,onAttachFailed:H.attachFailedChecks}):null,e[97]=H.attachFailedChecks,e[98]=R,e[99]=w,e[100]=Q,e[101]=Ie):Ie=e[101];let Te;return e[102]!==ke||e[103]!==Ie?(Te=n.jsxs(n.Fragment,{children:[ke,Ie]}),e[102]=ke,e[103]=Ie,e[104]=Te):Te=e[104],Te},R0=t=>{const e=Ze.c(45),{url:s,identifier:r,onUnavailable:o,onShown:i}=t,{t:a}=Et(),d=Nx(),{detail:c,refresh:u}=Mx(d==="ready"?r:null,!0),f=Ax(),p=Ml(),h=d!=="ready",g=c.status==="error",b=c.status==="ready";let x,y;e[0]!==h||e[1]!==g||e[2]!==o?(x=()=>{(h||g)&&o()},y=[h,g,o],e[0]=h,e[1]=g,e[2]=o,e[3]=x,e[4]=y):(x=e[3],y=e[4]),us.useEffect(x,y);let S,m;if(e[5]!==i||e[6]!==b?(S=()=>{b&&i()},m=[i,b],e[5]=i,e[6]=b,e[7]=S,e[8]=m):(S=e[7],m=e[8]),us.useEffect(S,m),h){let P;return e[9]!==s?(P=n.jsx(Yl,{url:s}),e[9]=s,e[10]=P):P=e[10],P}if(c.status==="error"){let P;e[11]!==c.error||e[12]!==a?(P=c.error||a("contextPanel.tracker.loadFailed"),e[11]=c.error,e[12]=a,e[13]=P):P=e[13];let L;e[14]!==u?(L=()=>{u()},e[14]=u,e[15]=L):L=e[15];let z;return e[16]!==P||e[17]!==L?(z=n.jsx(Ar,{message:P,onRetry:L}),e[16]=P,e[17]=L,e[18]=z):z=e[18],z}if(c.status!=="ready"){let P;e[19]!==a?(P=a("common.loading"),e[19]=a,e[20]=P):P=e[20];let L;return e[21]!==P?(L=n.jsx(Ar,{message:P}),e[21]=P,e[22]=L):L=e[22],L}let v;e[23]!==c.value?(v={source:"linear",issue:c.value},e[23]=c.value,e[24]=v):v=e[24];const w=v;let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T={status:"idle"},e[25]=T):T=e[25];let k;e[26]!==u?(k=()=>{u()},e[26]=u,e[27]=k):k=e[27];let I;e[28]!==w||e[29]!==k?(I=n.jsx(vl,{item:w,project:null,context:null,onStartWorktree:_0,onChanged:k,worktreeAvailable:!1}),e[28]=w,e[29]=k,e[30]=I):I=e[30];let F;e[31]!==u?(F=()=>{u()},e[31]=u,e[32]=F):F=e[32];let O;e[33]!==c.value||e[34]!==F?(O=n.jsx(Bb,{issue:c.value,onChanged:F}),e[33]=c.value,e[34]=F,e[35]=O):O=e[35];let B;e[36]!==f?(B=P=>{f(P.url,null)},e[36]=f,e[37]=B):B=e[37];let j;return e[38]!==c||e[39]!==w||e[40]!==p||e[41]!==O||e[42]!==B||e[43]!==I?(j=n.jsx(Al,{item:w,directory:null,pullStatus:Ol,linearDetail:c,githubDetail:T,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:F0,now:p,footer:I,linearStateControl:O,onOpenLinearIssue:B}),e[38]=c,e[39]=w,e[40]=p,e[41]=O,e[42]=B,e[43]=I,e[44]=j):j=e[44],j};function N0(t){return t.activeProjectId}function M0(){}function A0(){}function O0(){}function B0(){}function F0(){}function _0(){}const Uo=new Map,L0=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},$0=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},z0=(t,e)=>{if(e.length===0)return Uo;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!s.has(a.id))continue;const d=a.title?.trim();if(!d)continue;const c=$0(a),u=r.get(a.id);u!==void 0&&u>c||(r.set(a.id,c),o.set(a.id,d))}return o.size===0?Uo:o},Pi=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Sd=60,K0=t=>{try{return new URL(t).origin}catch{return""}},aa=new Set,th=to()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=K0(s);!i||!r||e().byOrigin[i]||aa.has(i)||(aa.add(i),Xn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const d=typeof a?.dataUrl=="string"?a.dataUrl:"";d&&t(c=>{const u={...c.byOrigin,[i]:d},f=Object.keys(u);if(f.length<=Sd)return{byOrigin:u};for(const p of f.slice(0,f.length-Sd))delete u[p];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{aa.delete(i)}))}})),Zl=t=>t,Ga=t=>{const e=Zl(t).type;return typeof e=="string"?e:""},W0=t=>{const e=Zl(t).tool;return typeof e=="string"?e:""},H0=t=>{const e=Zl(t).text;return typeof e=="string"?e:""},U0=t=>{const e=Ga(t);return e==="tool"?W0(t).trim().toLowerCase()||"tool":e||"unknown"},V0=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=U0(s);e.includes(r)||e.push(r)}return e.join(" + ")},G0=t=>t.replace(/\s+/g," ").trim(),q0=t=>{for(const s of t)if(Ga(s)==="text"){const r=G0(H0(s));if(r.length===0)continue;return r}const e=t.filter(s=>Ga(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Y0=(t,e,s)=>`${s(t)} / ${s(e)}`,Z0=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Q0=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Z0(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},X0=(t,{windowTokens:e,compacted:s=!1})=>{const r=s?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},qa={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},jo={user:0,assistant:0,tool:0,other:0},dn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,wd=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...qa,total:dn(s)};if(!s||typeof s!="object")return qa;const r=s,o=dn(r.input),i=dn(r.output),a=dn(r.reasoning),d=dn(r.cache?.read),c=dn(r.cache?.write),u=dn(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:c,total:u>0?u:o+i+a+d+c}},J0=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ls=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Ls(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Ls(s),0):0,ej=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...jo,assistant:Ls(s.text)+Ls(s.content)};const o=J0(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ls(s.input)+Ls(s.output)+Ls(s.error)+Ls(s.call?.input)+Ls(s.call?.output)+Ls(s.call?.error)+Ls(s.raw)+Math.round(Ls(s.metadata)*.25)+Math.round(Ls(s.state)*.1)+Math.round((Cg(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},vd=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),tj=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",sj=(t,e)=>{if(t.length===0)return{...jo};const s=t.reduce((r,o)=>{const i=tj(o);let a={...jo};for(const d of o.parts)a=vd(a,ej(d,i));return vd(r,a)},{...jo});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},Fn=t=>t.toLocaleString(np()),nj=(t,e)=>!t||!Number.isFinite(t)?"-":Vx(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),rj=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},oj=()=>{const t=Ze.c(215),{t:e}=Et(),s=Lb(),r=le(ij);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[d,c]=l.useState(null),u=l.useRef(null),f=mt(aj),p=mt(lj),h=Wx(p??void 0),g=Hx(f??"",p??void 0),b=ps(cj);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),a(dj),c(null)},t[1]=x):x=t[1];let y;t[2]!==p||t[3]!==f?(y=[p,f],t[2]=p,t[3]=f,t[4]=y):y=t[4],l.useEffect(x,y);let S,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},m=[],t[5]=S,t[6]=m):(S=t[5],m=t[6]),l.useEffect(S,m);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=async(Ke,jt)=>{(await pi(jt)).ok?(c(Ke),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{c(Mt=>Mt===Ke?null:Mt),u.current=null},2e3)):c(null)},t[7]=v):v=t[7];const w=v;let T,k,I,F,O,B,j,P,L,z;if(t[8]!==f||t[9]!==b||t[10]!==g||t[11]!==h){F=f?h.find(se=>se.id===f)??null:null,T=g.filter(uj);let Ke;t[22]!==g?(Ke=g.filter(fj),t[22]=g,t[23]=Ke):Ke=t[23],z=Ke;let jt;t[24]!==g?(jt=sp(g.map(pj)),t[24]=g,t[25]=jt):jt=t[25];const Lt=jt,Mt=Lt?g[Lt.index]??null:null,De=Lt?.state==="compacted";j=Mt?wd(Mt):qa,k=Ux({input:j.input,cache:{read:j.cacheRead,write:j.cacheWrite}}),P=Number.isFinite(F?.cost)?dn(F?.cost):T.reduce(hj,0);const Tt=Mt?.info??null,At=b,kt=Tt?.providerID||"",pt=Tt?.modelID||"";let Dt;t[26]!==kt||t[27]!==pt||t[28]!==At?(Dt=rj(At,kt,pt),t[26]=kt,t[27]=pt,t[28]=At,t[29]=Dt):Dt=t[29],O=Dt,I=O.contextLimit,L=De?null:I&&I>0?Math.min(999,j.total/I*100):0;const Ve=[...g].reverse().find(mj),rt=Ve?.info.role==="system"?Ve.info.text:"",wt=sj(g,rt);B=X0(wt,{windowTokens:j.total,compacted:De}),t[8]=f,t[9]=b,t[10]=g,t[11]=h,t[12]=T,t[13]=k,t[14]=I,t[15]=F,t[16]=O,t[17]=B,t[18]=j,t[19]=P,t[20]=L,t[21]=z}else T=t[12],k=t[13],I=t[14],F=t[15],O=t[16],B=t[17],j=t[18],P=t[19],L=t[20],z=t[21];const H=B,R=g[0]?.info?.time?.created,G=g.length>0?g[g.length-1]?.info?.time?.created:null;let _;t[30]!==F?.title||t[31]!==e?(_=F?.title||e("contextSidebar.session.untitled"),t[30]=F?.title,t[31]=e,t[32]=_):_=t[32];const $=F?.time?.created??R??null,E=G??F?.time?.created??null;let D;t[33]!==T.length||t[34]!==H||t[35]!==k||t[36]!==I||t[37]!==O||t[38]!==g.length||t[39]!==_||t[40]!==$||t[41]!==E||t[42]!==j||t[43]!==P||t[44]!==L||t[45]!==z.length?(D={sessionTitle:_,messagesCount:g.length,userMessagesCount:z.length,assistantMessagesCount:T.length,createdAt:$,lastActivityAt:E,providerModel:O,tokenBreakdown:j,usagePercent:L,cacheHitRate:k,totalAssistantCost:P,contextLimit:I,breakdown:H,breakdownTotal:H.total},t[33]=T.length,t[34]=H,t[35]=k,t[36]=I,t[37]=O,t[38]=g.length,t[39]=_,t[40]=$,t[41]=E,t[42]=j,t[43]=P,t[44]=L,t[45]=z.length,t[46]=D):D=t[46];const C=D;if(!f){let Ke;t[47]!==e?(Ke=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=Ke):Ke=t[48];let jt;return t[49]!==Ke?(jt=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ke}),t[49]=Ke,t[50]=jt):jt=t[50],jt}let N;t[51]!==e?(N=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=N):N=t[52];let A;t[53]!==N||t[54]!==C.breakdown.user?(A={key:"user",label:N,value:C.breakdown.user,color:"var(--status-success)"},t[53]=N,t[54]=C.breakdown.user,t[55]=A):A=t[55];let q;t[56]!==e?(q=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=q):q=t[57];let ee;t[58]!==q||t[59]!==C.breakdown.assistant?(ee={key:"assistant",label:q,value:C.breakdown.assistant,color:"var(--primary-base)"},t[58]=q,t[59]=C.breakdown.assistant,t[60]=ee):ee=t[60];let Q;t[61]!==e?(Q=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=Q):Q=t[62];let he;t[63]!==Q||t[64]!==C.breakdown.tool?(he={key:"tool",label:Q,value:C.breakdown.tool,color:"var(--status-warning)"},t[63]=Q,t[64]=C.breakdown.tool,t[65]=he):he=t[65];let M;t[66]!==e?(M=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=M):M=t[67];let V;t[68]!==M||t[69]!==C.breakdown.other?(V={key:"other",label:M,value:C.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=M,t[69]=C.breakdown.other,t[70]=V):V=t[70];let ie;t[71]!==A||t[72]!==ee||t[73]!==he||t[74]!==V?(ie=[A,ee,he,V],t[71]=A,t[72]=ee,t[73]=he,t[74]=V,t[75]=ie):ie=t[75];const ce=ie;let ne;t[76]!==s||t[77]!==C.sessionTitle?(ne=s?n.jsx($b,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:C.sessionTitle,children:C.sessionTitle})})}):null,t[76]=s,t[77]=C.sessionTitle,t[78]=ne):ne=t[78];let je;t[79]!==s||t[80]!==C.sessionTitle?(je=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:C.sessionTitle}),t[79]=s,t[80]=C.sessionTitle,t[81]=je):je=t[81];const Ee=!s&&"mt-1";let we;t[82]!==Ee?(we=Pe(Ee,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[82]=Ee,t[83]=we):we=t[83];let Me;t[84]!==C.providerModel.modelName||t[85]!==C.providerModel.providerName?(Me=n.jsxs("span",{children:[C.providerModel.providerName," / ",C.providerModel.modelName]}),t[84]=C.providerModel.modelName,t[85]=C.providerModel.providerName,t[86]=Me):Me=t[86];let fe;t[87]!==r||t[88]!==C.createdAt?(fe=C.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:nj(C.createdAt,r)})]}),t[87]=r,t[88]=C.createdAt,t[89]=fe):fe=t[89];let be;t[90]!==we||t[91]!==Me||t[92]!==fe?(be=n.jsxs("div",{className:we,children:[Me,fe]}),t[90]=we,t[91]=Me,t[92]=fe,t[93]=be):be=t[93];let ke;t[94]!==je||t[95]!==be?(ke=n.jsxs("div",{className:"mb-6",children:[je,be]}),t[94]=je,t[95]=be,t[96]=ke):ke=t[96];let Ie;t[97]!==e?(Ie=e("contextSidebar.section.context"),t[97]=e,t[98]=Ie):Ie=t[98];let Te;t[99]!==Ie?(Te=n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ie}),t[99]=Ie,t[100]=Te):Te=t[100];let Y;t[101]!==C.tokenBreakdown.total||t[102]!==C.usagePercent?(Y=C.usagePercent===null?"—":Fn(C.tokenBreakdown.total),t[101]=C.tokenBreakdown.total,t[102]=C.usagePercent,t[103]=Y):Y=t[103];let ue;t[104]!==C.contextLimit?(ue=C.contextLimit?` / ${Fn(C.contextLimit)}`:"",t[104]=C.contextLimit,t[105]=ue):ue=t[105];let me;t[106]!==Y||t[107]!==ue?(me=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Y,ue]}),t[106]=Y,t[107]=ue,t[108]=me):me=t[108];let re;t[109]!==Te||t[110]!==me?(re=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Te,me]}),t[109]=Te,t[110]=me,t[111]=re):re=t[111];let pe;t[112]!==C.usagePercent?(pe=C.usagePercent!==null&&C.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,C.usagePercent)}%`,backgroundColor:C.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=C.usagePercent,t[113]=pe):pe=t[113];let U;t[114]!==pe?(U=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:pe}),t[114]=pe,t[115]=U):U=t[115];let ae;t[116]!==e||t[117]!==C.usagePercent?(ae=C.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:C.usagePercent.toFixed(1)}),t[116]=e,t[117]=C.usagePercent,t[118]=ae):ae=t[118];let Re;t[119]!==ae?(Re=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ae}),t[119]=ae,t[120]=Re):Re=t[120];let W;t[121]!==re||t[122]!==U||t[123]!==Re?(W=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[re,U,Re]}),t[121]=re,t[122]=U,t[123]=Re,t[124]=W):W=t[124];let ye;t[125]!==e?(ye=e("contextSidebar.stats.messages"),t[125]=e,t[126]=ye):ye=t[126];let de;t[127]!==C.messagesCount?(de=Fn(C.messagesCount),t[127]=C.messagesCount,t[128]=de):de=t[128];let Ne;t[129]!==ye||t[130]!==de?(Ne={label:ye,value:de},t[129]=ye,t[130]=de,t[131]=Ne):Ne=t[131];let Je;t[132]!==e?(Je=e("contextSidebar.stats.user"),t[132]=e,t[133]=Je):Je=t[133];let Ge;t[134]!==C.userMessagesCount?(Ge=Fn(C.userMessagesCount),t[134]=C.userMessagesCount,t[135]=Ge):Ge=t[135];let ge;t[136]!==Je||t[137]!==Ge?(ge={label:Je,value:Ge},t[136]=Je,t[137]=Ge,t[138]=ge):ge=t[138];let Ae;t[139]!==e?(Ae=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ae):Ae=t[140];let Ye;t[141]!==C.assistantMessagesCount?(Ye=Fn(C.assistantMessagesCount),t[141]=C.assistantMessagesCount,t[142]=Ye):Ye=t[142];let nt;t[143]!==Ae||t[144]!==Ye?(nt={label:Ae,value:Ye},t[143]=Ae,t[144]=Ye,t[145]=nt):nt=t[145];let oe;t[146]!==e?(oe=e("contextSidebar.stats.cost"),t[146]=e,t[147]=oe):oe=t[147];let tt;t[148]!==C.totalAssistantCost?(tt=_p(C.totalAssistantCost),t[148]=C.totalAssistantCost,t[149]=tt):tt=t[149];let Ue;t[150]!==oe||t[151]!==tt?(Ue={label:oe,value:tt},t[150]=oe,t[151]=tt,t[152]=Ue):Ue=t[152];let gt;t[153]!==Ne||t[154]!==ge||t[155]!==nt||t[156]!==Ue?(gt=[Ne,ge,nt,Ue],t[153]=Ne,t[154]=ge,t[155]=nt,t[156]=Ue,t[157]=gt):gt=t[157];const bt=gt;let Ce;t[158]!==bt?(Ce=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(gj)}),t[158]=bt,t[159]=Ce):Ce=t[159];let _e;t[160]!==e?(_e=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=_e):_e=t[161];let ze;t[162]!==_e?(ze=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:_e}),t[162]=_e,t[163]=ze):ze=t[163];let Oe;t[164]!==e||t[165]!==C.cacheHitRate.hasInput||t[166]!==C.cacheHitRate.percent||t[167]!==C.tokenBreakdown.cacheRead||t[168]!==C.tokenBreakdown.cacheWrite||t[169]!==C.tokenBreakdown.input||t[170]!==C.tokenBreakdown.output||t[171]!==C.tokenBreakdown.reasoning?(Oe=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:C.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:C.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:C.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:C.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:C.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:C.cacheHitRate.hasInput?C.cacheHitRate.percent:null,format:"percent"}].map(bj)}),t[164]=e,t[165]=C.cacheHitRate.hasInput,t[166]=C.cacheHitRate.percent,t[167]=C.tokenBreakdown.cacheRead,t[168]=C.tokenBreakdown.cacheWrite,t[169]=C.tokenBreakdown.input,t[170]=C.tokenBreakdown.output,t[171]=C.tokenBreakdown.reasoning,t[172]=Oe):Oe=t[172];let it;t[173]!==ze||t[174]!==Oe?(it=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ze,Oe]}),t[173]=ze,t[174]=Oe,t[175]=it):it=t[175];let X;t[176]!==ce||t[177]!==C.breakdownTotal?(X=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ce.map(Ke=>Ke.value<=0||C.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Ke.value/C.breakdownTotal*100}%`,backgroundColor:Ke.color}},Ke.key))}),t[176]=ce,t[177]=C.breakdownTotal,t[178]=X):X=t[178];let Be;t[179]!==ce||t[180]!==C.breakdownTotal?(Be=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ce.map(Ke=>{const jt=C.breakdownTotal>0?Ke.value/C.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ke.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Ke.label," ",n.jsxs("span",{className:"tabular-nums",children:[jt.toFixed(0),"%"]})]})]},Ke.key)})}),t[179]=ce,t[180]=C.breakdownTotal,t[181]=Be):Be=t[181];let Le;t[182]!==X||t[183]!==Be?(Le=n.jsxs("div",{className:"mb-6",children:[X,Be]}),t[182]=X,t[183]=Be,t[184]=Le):Le=t[184];let at;t[185]!==e?(at=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=at):at=t[186];let qe;t[187]!==at?(qe=n.jsx("div",{className:"typography-micro text-muted-foreground",children:at}),t[187]=at,t[188]=qe):qe=t[188];let ut;if(t[189]!==d||t[190]!==i||t[191]!==g||t[192]!==e||t[193]!==r){let Ke;t[195]!==d||t[196]!==i||t[197]!==e||t[198]!==r?(Ke=jt=>{const Lt=jt.info.role,Mt=Lt==="assistant",De=Lt==="user",Tt=i[jt.info.id]===!0,At=d===jt.info.id,kt=jt.info.time?.created??null,pt=V0(jt.parts),Dt=Mt?wd({info:jt.info,parts:jt.parts}):null,Ve=De?q0(jt.parts):"",rt=Q0(kt,r),wt=pt||"—",se=Dt?Y0(Dt.input,Dt.output,Fn):"",Fe=Lt||"unknown",ot=pt?`${Fe}: ${pt}`:Fe,$e=Tt?JSON.stringify({info:jt.info,parts:jt.parts},null,2):"";return n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":Tt,onClick:()=>{a(Ct=>({...Ct,[jt.info.id]:Ct[jt.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Mt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[De?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Ve]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Mt?wt:ot}),Mt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:se})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:rt})]})}),Tt&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Ct=>{Ct.stopPropagation(),w(jt.info.id,$e)},"aria-label":e(At?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(At?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:At?n.jsx(Z,{name:"check",className:"size-3.5"}):n.jsx(Z,{name:"file-copy",className:"size-3.5"})})}),n.jsx(Gx,{language:"json",code:$e,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},jt.info.id)},t[195]=d,t[196]=i,t[197]=e,t[198]=r,t[199]=Ke):Ke=t[199],ut=[...g].reverse().map(Ke),t[189]=d,t[190]=i,t[191]=g,t[192]=e,t[193]=r,t[194]=ut}else ut=t[194];let dt;t[200]!==ut?(dt=n.jsx("div",{className:"mt-2.5 space-y-1",children:ut}),t[200]=ut,t[201]=dt):dt=t[201];let ft;t[202]!==qe||t[203]!==dt?(ft=n.jsxs("div",{children:[qe,dt]}),t[202]=qe,t[203]=dt,t[204]=ft):ft=t[204];let st;t[205]!==ke||t[206]!==W||t[207]!==Ce||t[208]!==it||t[209]!==Le||t[210]!==ft?(st=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ke,W,Ce,it,Le,ft]}),t[205]=ke,t[206]=W,t[207]=Ce,t[208]=it,t[209]=Le,t[210]=ft,t[211]=st):st=t[211];let Rt;return t[212]!==ne||t[213]!==st?(Rt=n.jsxs(Qr,{outerClassName:"h-full",className:"bg-background",children:[ne,st]}),t[212]=ne,t[213]=st,t[214]=Rt):Rt=t[214],Rt};function ij(t){return t.timeFormatPreference}function aj(t){return t.currentSessionId}function lj(t){return t.currentSessionDirectory}function cj(t){return t.providers}function dj(t){return Object.keys(t).length>0?{}:t}function uj(t){return t.info.role==="assistant"}function fj(t){return t.info.role==="user"}function pj(t){return t.info}function hj(t,e){const s=dn(e.info.cost);return t+s}function mj(t){return t.info.role==="system"}function gj(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function bj(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.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)}%`:Fn(t.value):"—"})]},t.label)}const sh=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||qx(t.target)||Yx(t.target)||Nl(t)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},yj=280,xj=.28,Sj=240,wj=.35,vj=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=s?s.top:i-Math.min(Sj,e.height*wj),d=Math.min(yj,t.width*xj,e.width/4),c=e.left-t.left>=1,u=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+d,h=u?o:r-d;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:h,top:t.top,width:r-h,height:u?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},la=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,jj=(t,e)=>la(t.bottom,e)?"bottom":la(t.left,e)?"left":la(t.right,e)?"right":null,gn=to(()=>({drag:null,hovered:null})),ko=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},ca=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),da=t=>ko(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),nh=t=>{const e=ko(document.querySelector("[data-workspace-row]")),s=ko(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=vj(e,s,ko(r)),i={left:da("left")??ca(o.left),right:da("right")??ca(o.right),bottom:da("bottom")??ca(o.bottom)};return gn.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},rh=t=>{const{drag:e,hovered:s}=gn.getState();if(!e)return;const r=jj(e.targets,t);r!==s&&gn.setState({hovered:r})},Ya=()=>{gn.getState().drag&&gn.setState({drag:null,hovered:null})},oh=t=>{const{drag:e,hovered:s}=gn.getState();if(gn.setState({drag:null,hovered:null}),!e||!s)return!1;const r=le.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?Ds(t):"";if(o){const i=le.getState();bl(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Ql=(t,e)=>{let s=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(s||(s=nh(t)),s&&rh(a)):s&&(Ya(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(oh(i),!0):!1),cancel:()=>{o(),s&&Ya()}}},jd={left:null,right:null,bottom:null},Hr=to(()=>({body:jd,headerSlot:jd})),ih=(t,e,s)=>{const r=Hr.getState()[t];r[e]!==s&&Hr.setState({[t]:{...r,[e]:s}})},kj=(t,e)=>ih("body",t,e),Cj=(t,e)=>ih("headerSlot",t,e),Or=t=>{const e=l.useRef(t);e.current=t;const[s,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Rl(o)},[t,o]),l.useEffect(()=>()=>rp(o),[o]),s},Co=t=>{const e=Or(t);return t||e},Ij=Xr(()=>as(()=>import("./GitView-D10y-u46.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),ah=320,lh=Pg.regular,ch=400,Pj=100,Ej=24,Tj=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},kd=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(ah,Math.round(t))):lh,Dj=t=>t===null?Number.POSITIVE_INFINITY:Math.max(ah,t-ch),Cd=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Io=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):dr(t)?Dl.getState().guests.find(r=>r.id===No(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Rj=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},Nj=(t,e,s)=>{if(t.mode==="chat"){const r=Pi(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?ii(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Rj(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Io(t.mode,s)},Mj=t=>{const e=Ze.c(8),{mode:s}=t,r=Fl();let o;if(e[0]!==s||e[1]!==r){let u;e[3]!==s?(u=f=>f.mode===s,e[3]=s,e[4]=u):u=e[4],o=r.find(u),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??e1,d=i?.iconSrc;let c;return e[5]!==a||e[6]!==d?(c=n.jsx(yr,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=c):c=e[7],c},Aj=t=>{const e=Ze.c(2),{sessionId:s}=t,r=Pl(s);let o;return e[0]!==r?(o=r?n.jsx(El,{state:r,className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},Id=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(mi,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(bf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(Z,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Z,{name:Oj(t.targetPath),className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(Z,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(Z,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(Z,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const s=Pi(t.dedupeKey);return s?n.jsx(Aj,{sessionId:s}):n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"})}if(dr(t.mode))return n.jsx(Mj,{mode:t.mode});if(t.mode==="browser"){const s=Bj(t.targetPath??"",e);return s?n.jsx("img",{src:s,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(Z,{name:"global",className:"h-3.5 w-3.5"})}},Oj=t=>{const e=t?tp(t):null;return e?e.source==="linear"?"linear":e.kind==="pull"?"git-pull-request":"record-circle":"git-branch"},Bj=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Fj=t=>{const e=Jr(),s=l.useRef(Uo),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),d=>d.getState()),a=z0(i,r.current);return L0(s.current,a)?s.current:(s.current=a,a)},[e]),()=>Uo)},_j=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Lj=8,$j='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',zj=t=>t==="context"||t==="git"||t==="pr"||t==="notes",dh=320,uh=160,fh=200,Kj={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-e-0 z-20 min-w-0",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-s-0 z-20 min-w-0",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",expanded:"absolute inset-x-0 bottom-0 z-20 min-h-0",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},Pd=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(uh,Math.round(t))):dh,Wj=t=>t===null?Number.POSITIVE_INFINITY:Math.max(uh,t-fh),ua=({zone:t="right"})=>{const e=Kj[t],s=ui(),r=e.axis==="y",{t:o,direction:i}=Et(),a=i==="rtl",d=Nn()??"",c=Zx(d||null),u=l.useCallback((se,Fe)=>o(pn(se,c),Fe),[c,o]),f=l.useMemo(()=>Tj(d),[d]),p=le(se=>f?se.contextPanelByDirectory[f]:void 0),h=le(se=>se.contextSurfaceZones),g=le(se=>se.closeContextZone),b=le(se=>se.closeContextPanelTab),x=le(se=>se.pinContextPanelTab),y=le(se=>se.toggleContextPanelExpanded),S=le(se=>se.setContextPanelWidth),m=le(se=>se.setContextPanelHeight),v=le(se=>se.setActiveContextPanelTab),w=le(se=>se.reorderContextPanelTabs),T=le(se=>se.contextEditorTreeVisible),k=le(se=>se.contextEditorTreeWidth),I=le(se=>se.setContextEditorTreeWidth),F=le(se=>se.toggleContextEditorTree),O=le(se=>se.contextEditorVisible),B=le(se=>se.toggleContextEditor),j=le(se=>se.fileTreeSide),P=le(se=>se.openNewContextBrowserTab),L=th(se=>se.byOrigin),[z,H]=l.useState(null),R=l.useCallback(se=>{H(se),Cj(t,se)},[t]),G=l.useCallback(se=>{kj(t,se)},[t]),_=l.useMemo(()=>p?.tabs??[],[p?.tabs]),$=p?Ro(p,h,t):null,E=p?oi(p,t):Ig,D=Oa(se=>se.workStatusReserved),C=Oa(se=>se.chatCovered),N=t==="bottom"&&C,A=!!(E.isOpen&&$)&&!N,q=l.useMemo(()=>_.some(se=>se.mode==="file"&&se.targetPath),[_]),ee=q&&(O||!T),Q=$?.mode??null,he=!r&&Q==="file"&&!ee,M=!!(A&&E.expanded&&!he),V=Q?r?p?.heightByMode?.[Q]:p?.widthByMode?.[Q]:void 0,ie=he?k:r?Pd(V??dh,Number.POSITIVE_INFINITY):kd(V??(Q?Ca(Q):lh),Number.POSITIVE_INFINITY),ce=l.useCallback((se,Fe)=>r?Pd(se,Wj(Fe)):kd(se,Dj(Fe)),[r]),ne=r?fh:ch,je=t==="right"?"left":t==="left"?"right":null,Ee=le(se=>{if(!je||!f)return 0;const Fe=se.contextPanelByDirectory[f],ot=Fe&&Dr(Fe,se.contextSurfaceZones,je)?Ro(Fe,se.contextSurfaceZones,je):null;if(!Fe||!ot)return 0;const $e=Fe.tabs.some(Ct=>Ct.mode==="file"&&Ct.targetPath)&&(se.contextEditorVisible||!se.contextEditorTreeVisible);return ot.mode==="file"&&!$e?se.contextEditorTreeWidth:Fe.widthByMode[ot.mode]??Ca(ot.mode)}),we=je==="right"&&D&&!C&&Ee===0?Xi:Ee,[Me,fe]=l.useState(null),be=l.useRef(null),ke=l.useRef(we);ke.current=we;const Ie=l.useRef(()=>!1);Ie.current=se=>M||!he&&se-ke.current-ne<ie;const Te=l.useCallback(()=>{const se=be.current;fe(se!==null&&Ie.current(se)?se:null)},[]),Y=Me!==null?Me-we:null,ue=t==="left"?Me:Y,me=he?ie:ce(ie,Y),re=A&&$?.mode==="chat",pe=l.useMemo(()=>{const se=[];if(!re)return se;for(const Fe of _){if(Fe.mode!=="chat")continue;const ot=Pi(Fe.dedupeKey);ot&&!se.includes(ot)&&se.push(ot)}return se},[re,_]),U=Fj(pe),[ae,Re]=l.useState(!1),W=l.useRef(0),ye=l.useRef(me),de=l.useRef(null),Ne=l.useRef(null),Je=l.useRef(null),Ge=l.useRef(null),ge=l.useRef(!1);l.useLayoutEffect(()=>{const se=r?Je.current?.parentElement:Je.current?.closest("[data-workspace-row]");if(!se||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(ot=>{const $e=ot[ot.length-1]?.contentRect,Ct=r?$e?.height:$e?.width;be.current=Ct?Math.round(Ct):null,Rl(Te)});return Fe.observe(se),be.current=(r?se.clientHeight:se.clientWidth)||null,Te(),()=>{Fe.disconnect(),rp(Te)}},[Te,r]),l.useLayoutEffect(()=>{Te()},[Te,ie,M,we]),l.useEffect(()=>{if(!A||ge.current){ge.current=A;return}const se=window.requestAnimationFrame(()=>{Ge.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(se)},[A]);const Ae=l.useRef(null),Ye=l.useRef(null),nt=l.useCallback(()=>{Ye.current=null;const se=Je.current,Fe=de.current;!se||Fe===null||se.style.setProperty(e.sizeVariable,`${Fe}px`)},[e.sizeVariable]);l.useEffect(()=>()=>{Ye.current!==null&&clearTimeout(Ye.current)},[]);const oe=l.useCallback(se=>{const Fe=Ae.current,ot=he?Ia(se):ce(se,Fe);return Fe===null?ot:Math.min(ot,Math.max(1,Fe))},[ce,he]),tt=l.useCallback(se=>{if(!A||M||!f)return;Ne.current=se.pointerId,Re(!0),W.current=r?se.clientY:se.clientX,ye.current=me,de.current=me;const Fe=r?Je.current?.parentElement?.clientHeight:(Je.current?.closest("[data-workspace-row]")?.clientWidth??0)-ke.current;Ae.current=Fe&&Fe>0?Fe:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",se.preventDefault()},[f,M,A,r,me]),Ue=l.useCallback(()=>{const se=oe(de.current??me);de.current=null,Ae.current=null,Ye.current!==null&&(clearTimeout(Ye.current),Ye.current=null),document.documentElement.style.cursor="",he?I(se):f&&Q&&(r?m(f,Q,se):S(f,Q,se)),Re(!1),Ne.current=null},[Q,oe,f,he,r,I,m,S,me]);l.useEffect(()=>{if(!ae)return;const se=$e=>{if(Ne.current!==$e.pointerId)return;const Ct=r?$e.clientY:$e.clientX,Yt=t==="left"?Ct-W.current:W.current-Ct,es=!r&&a?-Yt:Yt,Zt=oe(ye.current+es);de.current!==Zt&&(de.current=Zt,Ye.current===null&&(Ye.current=setTimeout(nt,Pj)))},Fe=$e=>{Ne.current===$e.pointerId&&Ue()},ot=()=>{Ue()};return window.addEventListener("pointermove",se),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",ot),()=>{window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",ot)}},[nt,oe,Ue,ae,a,r,t]),l.useEffect(()=>{ae||(de.current=null,document.documentElement.style.cursor="")},[ae]);const gt=l.useCallback(()=>{f&&g(f,t)},[g,f,t]),bt=l.useCallback(()=>{f&&y(f,t)},[f,y,t]),Ce=l.useCallback(se=>{sh(se,A,gt)},[gt,A]),_e=$?.mode==="file"||$?.mode==="chat"||$?.mode==="browser"||$?.mode==="pr",ze=l.useMemo(()=>{if(!$)return[];const se=_.filter(Fe=>Fe.mode===$.mode);return $.mode==="pr"?[...se.filter(Yi),...se.filter(Fe=>!Yi(Fe))]:se},[$,_]),Oe=hi($?.mode==="pr"&&f?f:null)?.current??null,it=l.useMemo(()=>{const se=Qx(ze.filter(Fe=>Fe.mode==="file").map(Fe=>Cd(Fe.targetPath,d)));return ze.map(Fe=>{const ot=Yi(Fe),$e=ot?Oe||o("contextPanel.tracker.branchTab"):Nj(Fe,U,u),Ct=_j($e,Ej),Yt=Cd(Fe.targetPath,d);return{id:Fe.id,label:Ct,labelFolder:Fe.mode==="file"?se.get(Yt):void 0,icon:Id(Fe,L),title:Yt?`${$e}: ${Yt}`:$e,closeLabel:o("contextPanel.tab.closeTabAria",{label:Ct}),closable:!ot,preview:Fe.preview}})},[ze,d,L,U,o,u,Oe]),X=$?.mode==="context"?n.jsx(rr,{value:z,children:n.jsx(oj,{})}):$?.mode==="git"?n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:z,children:n.jsx(Ij,{isActive:A})})}):$?.mode==="pr"?$.targetPath?n.jsx(T0,{url:$.targetPath,directory:$.targetDirectory??d,panelDirectory:d,tabId:$.id,foreign:!!$.targetDirectory,visible:A},$.id):n.jsx(x0,{}):$?.mode==="notes"?n.jsx(rr,{value:z,children:n.jsx(zb,{visible:A})}):null,Be=$?.mode==="file",Le=le(se=>se.closeContextPanelTabs),at=l.useCallback(se=>{if(!f)return null;const{id:Fe,index:ot,allIds:$e,close:Ct}=se,Yt=()=>Le(f,$e.filter(cs=>cs!==Fe)),es=$e.slice(0,ot),Zt=$e.slice(ot+1),ss=()=>Le(f,a?Zt:es),bs=()=>Le(f,a?es:Zt),ls=()=>Le(f,$e),ms=$e.length>1,fs=a?ot===$e.length-1:ot===0,Es=a?ot===0:ot===$e.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs($n,{onClick:Ct,children:[n.jsx(Z,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(wo,{}),n.jsxs($n,{onClick:Yt,disabled:!ms,children:[n.jsx(Z,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs($n,{onClick:ss,disabled:fs,children:[n.jsx(Z,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs($n,{onClick:bs,disabled:Es,children:[n.jsx(Z,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(wo,{}),n.jsxs($n,{onClick:ls,disabled:!ms,children:[n.jsx(Z,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),$?n.jsxs(n.Fragment,{children:[n.jsx(wo,{}),n.jsx(gf,{mode:$.mode})]}):null]})},[$,Le,f,a,o]),qe=l.useCallback((se,Fe)=>{const ot=_.find(Ct=>Ct.id===se);if(!ot)return null;const $e=Ql({mode:ot.mode,label:Io(ot.mode,u),from:t},Fe);return{finish:()=>$e.finish(f),cancel:$e.cancel}},[f,u,_,t]),[ut,dt]=l.useState(null),ft=l.useCallback(se=>{if(!$||se.button!==0||se.pointerType==="touch"||se.target instanceof Element&&se.target.closest($j))return;const Fe=$.mode,ot=Io(Fe,u),$e={x:se.clientX,y:se.clientY};let Ct=!1;const Yt=bs=>{const ls={x:bs.clientX,y:bs.clientY};!Ct&&(Math.hypot(ls.x-$e.x,ls.y-$e.y)<Lj||(Ct=nh({mode:Fe,label:ot,from:t}),!Ct))||rh(ls)},es=()=>{window.removeEventListener("pointermove",Yt),window.removeEventListener("pointerup",Zt),window.removeEventListener("pointercancel",ss),window.removeEventListener("blur",ss)},Zt=()=>{es(),Ct&&oh(f)},ss=()=>{es(),Ct&&Ya()};window.addEventListener("pointermove",Yt),window.addEventListener("pointerup",Zt),window.addEventListener("pointercancel",ss),window.addEventListener("blur",ss)},[$,f,u,t]);l.useEffect(()=>{if(ut)return ut.addEventListener("pointerdown",ft),()=>ut.removeEventListener("pointerdown",ft)},[ft,ut]);const st=n.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[_e?n.jsx(Xx,{items:it,activeId:$?.id??null,onSelect:se=>{f&&v(f,se)},onClose:se=>{f&&b(f,se)},onReorder:(se,Fe)=>{f&&w(f,se,Fe)},onDoubleClickTab:se=>{f&&x(f,se)},layoutMode:"scrollable",variant:"default",tabContextMenu:at,onTabDragOut:qe}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[$?Id($,L):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:$?Io($.mode,u):null})]}),n.jsx("div",{ref:R,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[$?.mode==="browser"?n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&P(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,Be?["left","right"].map(se=>{const Fe=se===j;if(!Fe&&!q)return null;const ot=o(Fe?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:Fe?F:B,className:"h-7 w-7 p-0",title:ot,"aria-label":ot,"aria-pressed":Fe?T:ee,children:n.jsx(Z,{name:se==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},se)}):null,he?null:n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:bt,className:"h-7 w-7 p-0",title:o(M?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":o(M?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:M?n.jsx(Z,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:gt,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(Z,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Rt=t==="right"&&D&&!C,Ke=ue!==null?`${ue}px`:"100%",jt=A?M?Ke:`min(var(${e.sizeVariable}), 100%)`:Rt?`${Xi}px`:"0px",Lt=t==="bottom"&&Dr(p,h,"left"),Mt=t==="bottom"&&(D&&!C||Dr(p,h,"right")),De=`${A}|${M}|${Rt}|${A?ie:""}`,Tt=l.useRef(De),At=l.useRef(C),kt=At.current!==C;l.useLayoutEffect(()=>{At.current=C},[C]),l.useLayoutEffect(()=>{Tt.current!==De&&(Tt.current=De,kt||Kf(s))},[De,kt,s]);const pt=!xo(A,Or(A),$?.mode),Dt=Co(M),Ve=A?`${me}px`:Rt?`${Xi}px`:"0px",rt={[e.sizeVariable]:A&&M?Ke:`${me}px`,...r?{height:jt,maxHeight:"100%"}:{width:jt,maxWidth:"100%"},transitionDuration:kt?"0ms":`${s}ms`,transitionTimingFunction:pr},wt=M?ue!==null?`calc(${ue}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs(n.Fragment,{children:[Dt?n.jsx("div",{"aria-hidden":"true",className:"flex-shrink-0",style:r?{height:Ve,maxHeight:"100%"}:{width:Ve,maxWidth:"100%"}}):null,n.jsxs("aside",{ref:Je,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":A?"true":"false",tabIndex:-1,className:Pe("flex min-h-0 flex-col overflow-clip bg-background","isolate",Dt?e.expanded:r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),onKeyDownCapture:Ce,style:rt,children:[n.jsx("div",{ref:Ge,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:Jx,className:Pe("absolute inset-y-0 inset-e-0 z-0 flex",C&&"invisible")}):null,A&&!M&&n.jsx("div",{className:e.handle,onPointerDown:tt,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{"data-zone-card":"",className:Pe("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Lt?"ms-0":"ms-2"),t==="bottom"&&(Mt?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity]",!A&&"opacity-0",pt&&"pointer-events-none select-none"),style:{...r?{height:wt,width:`calc(100% - ${(Lt?0:.5)+(Mt?0:.375)}rem)`}:{width:wt},transitionDuration:`${s}ms`,transitionTimingFunction:pr},inert:pt||void 0,children:n.jsxs(op.Provider,{value:!0,children:[st,n.jsx("div",{ref:G,className:Pe("relative min-h-0 flex-1 overflow-hidden",ae&&"pointer-events-none"),children:$&&zj($.mode)?X:null})]})})]})]})},Hj=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"},Uj=async(t,e)=>{try{const s=await Ys("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=await s.json();if(!r||typeof r!="object")return{kind:"unavailable"};const o=r.servers;return Array.isArray(o)?{kind:"ready",servers:o.filter(Hj)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Vj=async t=>{try{const e=await Ys("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Gj=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},qj=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=Gj(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Yj=t=>({sessionId:t.sessionId,directory:t.directory?Ds(t.directory):null}),Zj=2e3,Qj=50,Br=400,Bs=new Map,sn=new Map;let Za=null,Qa=null;const Ur=new Map;let un=null,jn=null,Fr=null;const fn=async t=>{try{const e=await Ys("/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}},Xj=async(t,e)=>{try{const s=await Ys("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},ph=async(t,e=Zj)=>{const s=Date.now()+e;for(;!Bs.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,Qj));return Bs.get(t)??null},Vo=t=>Bs.has(t)||sn.has(t),mr=t=>Bs.get(t)??sn.get(t)??null,Xa=()=>[...Bs.values(),...[...sn.values()].filter(t=>!Bs.has(t.tabId))],Xl=t=>{const e=Qa?mr(Qa):null,s=e?.directory===Za?e:null;if(!t.sessionId){if(s)return s.tabId;const i=Xa().filter(c=>c.directory===Za),a=i.filter(c=>Bs.has(c.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=Ur.get(t.sessionId);if(r&&mr(r)?.ownerSessionId===t.sessionId)return r;const o=Xa().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},Jj=t=>{const e=Xl(t);return e&&mr(e)?.ownerSessionId===t.sessionId?e:null},ek=(t,e)=>{t.sessionId&&mr(e)?.ownerSessionId===t.sessionId&&Ur.set(t.sessionId,e)},hh=async t=>{const e=Bs.get(t);if(e)return e;const s=sn.get(t);return s?(s.wake(),ph(t)):null},mh=t=>{const e=Xl(t);return Xa().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},gh=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,bh=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,tk=t=>{const e=mh(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-DvxCZgCW.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Dm6zEvrf.js","assets/katex.min-F4TD1ekM.js","assets/vendor-zod-DDir2TeQ.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-h8RufjAw.js","assets/katex-CQK6Iqoe.css","assets/vendor-base-ui-CPKyhvxM.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-Bmi0tTrf.js","assets/vendor-tanstack-virtual-core-CdGDGrnp.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-VzNDjH03.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-D2O6oUGf.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-lg1O2gVX.js","assets/InProgressOperationBanner-BVDKUDqn.js","assets/PierreDiffViewer-BZDNV4Uj.js","assets/parseDiffFromFile-BSmRvd3V.js","assets/computeVirtualFileMetrics-DDyA16hp.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/isDiffPlainText-yXcpftjI.js","assets/pierreDiffTint-cyYFR1bm.js","assets/Virtualizer-nenVQKi3.js","assets/useInlineCommentController-a2JepiF3.js","assets/appThemeRegistry-BWap7OfW.js","assets/textMateThemeFromAppTheme-tYpAceV3.js","assets/ChangedPathLabel-BCiU4QDF.js","assets/useRootScrollLock-mqVhK2HB.js","assets/moveWorkspacePath-CENAo75W.js","assets/WalkthroughView-CdIYpttA.js","assets/PullRequestComparisonSelector-BBdU2rL1.js","assets/useDiffFindSurface-CaCh-qt2.js","assets/useWalkthroughReview-BspAr9Aa.js","assets/useCallableModelProviders-BK3j8Sde.js","assets/DiffView-CaDZ4gTk.js","assets/SubmoduleDiffSummary-BQduif5s.js","assets/FilesView-Csrs_BGv.js","assets/flexokiTheme-PoX6Vqyn.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useMarkdownLocalAssets-BEApAshz.js","assets/JsonTreeView-BpJU14WJ.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-Dpm-_Qu8.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/shikiHighlight-DBj_a_TN.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-CJBNpwgy.js","assets/GuestSurfacePane-DNg0xBTD.js","assets/SettingsWindow-Cndsj5Vu.js","assets/SettingsView-CCZOw018.js","assets/install-FletzeYD.js","assets/vendor-yaml-CE-D_49-.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/restartOpenCode-D8ExMl55.js","assets/SpaceRow-CQp4PkPJ.js","assets/CommandPalette-DEcmPHdC.js","assets/HelpDialog-CLyz3_xd.js","assets/ProjectActionsDialog-BPh74BCt.js","assets/OpenCodeStatusDialog-skpJZSjK.js","assets/RunOverview-Cngm2OOp.js","assets/ScheduledTasksDialog-DUjDdkw2.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-4-LVDLmf.js","assets/IntegrationsCatalogView-u1gS0Vk8.js","assets/UsageStatsView-CsC_RzAH.js","assets/SourceBoardView-8Wp0oUvB.js","assets/WorktreesView-D102xE1o.js","assets/SpacesView-BwcDCv3D.js","assets/SpaceAccessDialog-CxfCzTpe.js","assets/spaceNetwork-CNxs51y4.js","assets/SpaceApplyDialog-CYp0A76N.js","assets/space-apply-COMscpEL.js","assets/SpaceSetupOutput-RNo0mWrR.js","assets/OnboardingScreen-xzT7ckY0.js","assets/AboutDialog-C8mAGhnz.js","assets/MemoryDebugPanel-9z1jGWze.js"])))=>i.map(i=>d[i]);
2
+ import{f as Ze,j as n,R as l,r as us,c as gl,h as kg}from"./vendor-react-BUCujlKS.js";import{u as le,cE as $s,b as Gs,l as Dn,e as Ps,cF as Gu,a8 as ni,a5 as Jt,a7 as ri,n as yt,b0 as As,ax as hn,au as Do,av as vn,aw as Tr,aS as Cg,aA as qu,cG as Ig,bd as Ds,cH as bl,cI as Ro,cJ as oi,cK as Pg,cL as Ca,cM as Dr,cN as Ia,cO as Yi,cP as Eg,cQ as ii,cR as dr,af as No,k as Ys,cS as nr,aZ as Tg,cT as ai,cU as Yu,cV as Dg,cW as wn,cX as Rg,cY as Zu,cZ as Ng,c_ as Mg,c$ as Qu,d0 as Ag,m as Og,q as Bg,bh as Fg,b4 as li,b5 as _g,b7 as Lg,b8 as $g,ap as zg,at as Kg,ao as Vs,t as Mo,d1 as Wg,d2 as Hg,aI as Ao,d3 as Xu,d4 as Ju,d5 as Ug,az as yl,d6 as xl,bj as Oo,aU as en,bv as ts,ae as ef,aL as ci,d7 as Pc,d8 as Vg,d9 as Gg,da as qg,aV as tf,db as zt,dc as sf,dd as Yg,de as Pa,df as Zg,bW as nf,bX as rf,a6 as Qg,bw as Xg,bk as Jg,bz as of,dg as Ec,dh as eb,b3 as tb,di as Tc,bL as af,ay as lf,bn as Dc,bo as cf,bB as sb,bm as nb,dj as rb,dk as ob,aQ as ib,aO as ab,dl as lb,aW as cb,bl as db,bO as ub,dm as fb,dn as pb,dp as Rc,dq as Zi,dr as Nc,ds as Mc,dt as hb,aC as Ac,du as mb,dv as gb,dw as bb,aP as yb,dx as xb,i as Sb,a as wb}from"./katex.min-F4TD1ekM.js";import{_ as as}from"./vendor-vite-runtime-DD1OZmLC.js";import{bj as vb,bk as Sl,ai as jb,$ as Yr,bl as Bo,aq as wl,bm as kb,ad as Cb,ae as Ib,ag as Ea,m as df,p as uf,x as ff,n as pf,l as vl,v as hf,w as mf,y as gf,a0 as Pb,a1 as Eb,X as Tb,a6 as Db,a7 as Rb,W as Nb,a2 as Mb,N as Ab,d as Ob,i as Bb,q as Fb,bn as _b,t as Lb,u as $b,C as zb,bo as rr,ay as Kb,bp as bf,bq as xo,br as yf,bs as Wb,bt as xf,bu as Un,bv as Oc,bw as Bc,bx as Qi,by as Fc,a4 as So,av as Hb,aw as Ub,aa as Vb,aN as Gb,aO as Sf,bz as qb,ax as Yb,bA as Zb,be as Qb,b4 as Xb,S as _c,bB as Jb,aS as jl,aR as ey,bC as Ta,bD as ty,aj as sy,ah as wf,bE as Ln,bF as ny,z as ry,bG as vf,ap as oy,bH as jf,bI as iy,bJ as Lc,ak as ay,al as ly,ao as cy,b as dy,a as uy,am as $c,ac as Rr,af as fy,an as py,b5 as zc,bK as hy,bL as my,bM as gy,bN as by,bO as yy,bP as xy,bQ as Kc,bR as Sy,az as wy,aM as vy,aD as jy,aQ as ky,bS as Cy,aJ as Iy,aK as Py,bT as Ey,bU as Ty,ba as Dy,bV as Ry,aT as Ny,aP as My,bW as Ay,aB as Oy,bX as By,bY as Fy,aF as _y,aE as Ly,aG as $y,aI as zy,aH as Ky,aL as Wy,bZ as Hy,b_ as Uy}from"./runtimeEndpointReset-lg1O2gVX.js";import{u as Et,k5 as Vy,I as Z,W as Ht,X as Kt,V as Ut,aG as br,a5 as ns,G as mt,cz as kf,N as Pe,cS as kl,cT as Cl,cU as Il,k6 as Vn,H as Os,K as ur,eI as Pl,eH as Cf,b0 as Da,k7 as Gy,k8 as If,b1 as Pf,e1 as El,aR as Rs,aS as Ns,aT as Ms,bg as In,aU as rs,gO as Zr,c3 as qy,l as nn,F as rn,D as on,U as di,a0 as fr,q as Zs,t as Qs,T as Yy,A as He,k9 as Zy,ka as Qy,kb as Wc,kc as Hc,c0 as Ef,a4 as Tf,kd as Xy,ke as Uc,kf as Jy,kg as Ra,kh as Tl,ki as Df,kj as Rf,kk as Na,b$ as Nf,kl as ex,km as tx,kn as sx,dB as Lr,h3 as Mf,ko as ui,kp as nx,gW as Jn,aF as Rn,kq as rx,gX as ox,dy as Af,kr as ix,f_ as fi,dz as ax,ks as Of,aA as pi,kt as Bf,ku as Ff,kv as _f,kw as Lf,kx as $f,ky as zf,i$ as yr,bl as Dl,dE as Kf,o as Pn,B as Nt,kz as pr,kA as Wf,fE as Rl,n as Qr,aV as Cs,kB as lx,br as Nl,am as Hf,ap as Uf,kC as cx,kD as dx,b7 as Ks,ja as Vf,j9 as Gf,b9 as kn,bi as Ma,iX as ux,eA as fx,aE as Nn,kE as Ml,kF as px,kG as qf,cu as Al,ct as Ol,fY as hx,fq as mx,gd as gx,f0 as Yf,bc as pn,b4 as bx,ah as ys,b8 as Zf,bb as Aa,ba as er,bh as Qf,kH as Xf,kI as Jf,kJ as yx,kK as xx,kL as Sx,f2 as Bl,z as Fo,cd as wx,cb as vx,ca as jx,cc as kx,c4 as Cx,y as _o,cM as Vc,bj as ep,bf as Lo,kM as Ix,kN as Px,kO as Ex,cy as xr,b3 as Tx,b5 as hi,b6 as Dx,bd as Rx,aD as Cn,g4 as tp,cR as Nx,kP as sp,kQ as Mx,co as Ax,kR as Ox,cm as Bx,cx as Fx,cr as _x,kS as Lx,kT as $x,kU as zx,cw as Kx,cA as Wx,kV as Xn,af as Hx,kW as Ux,a1 as ps,gZ as np,kX as Vx,c6 as Gx,x as rp,bT as qx,kY as Yx,kZ as Zx,fD as op,k_ as Xr,k$ as Qx,l0 as Oa,l1 as Xi,gp as Xx,gJ as $n,gI as wo,cE as Jx,l2 as e1,l3 as ip,l4 as Jr,dq as mi,l5 as Fl,l6 as t1,cV as En,l7 as s1,ac as n1,l8 as r1,l9 as o1,la as i1,lb as Ji,lc as a1,ld as l1,et as _l,gr as c1,gu as d1,em as u1,gv as f1,d1 as p1,er as eo,gH as Ll,gK as ap,le as $r,eq as lp,ep as $l,gL as h1,gM as m1,gN as zl,d9 as g1,C as b1,aH as y1,lf as ea,lg as x1,lh as S1,li as cp,lj as dp,lk as w1,ll as v1,lm as j1,ln as k1,lo as C1,cl as I1,an as P1,lp as Gc,lq as qc,lr as Yc,hl as $o,gT as Kl,d8 as up,ls as E1,dd as gi,hm as Nr,lt as fp,lu as xs,dg as T1,i_ as pp,j0 as hp,gE as mp,gF as gp,gG as bp,lv as D1,lw as yp,lx as R1,ly as xp,lz as Ba,c9 as Sp,lA as Wl,lB as N1,lC as M1,lD as A1,hj as is,lE as O1,lF as wp,lG as vp,lH as jp,lI as zr,lJ as Zc,lK as B1,lL as Kr,lM as F1,lN as _1,lO as Hl,lP as zo,lQ as Ul,lR as kp,lS as Cp,lT as Ip,lU as Pp,ae as L1,lV as $1,g$ as z1,h7 as K1,ha as Vl,hn as W1,jO as Qc,lW as H1,h8 as U1,h9 as V1,lX as G1,eJ as q1,O as Y1,eK as Ep,lY as Z1,lZ as Q1,l_ as X1,l$ as or,m0 as J1,h0 as eS,m1 as vo,dK as bi,df as Fa,m2 as tS,ho as sS,m3 as nS,m4 as Tp,P as Tn,m5 as rS,hd as oS,m6 as iS,m7 as aS,eo as lS,d6 as cS,cG as Dp,m8 as dS,m9 as uS,ma as fS,mb as ta,mc as pS,md as hS,me as mS,a7 as gS,a6 as bS,hi as yS,mf as xS,mg as Gn,hk as SS,mh as wS,fr as Mn,mi as vS,mj as jS,mk as kS,dl as CS,ml as IS,hf as PS,dU as Xc,dT as Jc,c2 as ed,mm as ES,mn as TS,cD as DS,mo as RS,h2 as td,h4 as sa,h5 as NS,mp as MS,h6 as AS,mq as OS,k as BS,mr as sd,ms as na,mt as An,mu as qn,mv as nd,mw as FS,mx as _S,my as LS,mz as $S,mA as zS,mB as KS,eP as _a,gk as WS,mC as HS,mD as Rp,mE as US,dc as VS,mF as rd,mG as GS,da as qS,e3 as Np,mH as La,Y as Mp,e2 as Ap,d7 as Op,mI as YS,a8 as ZS,mJ as Bp,ck as $a,iH as QS,gU as XS,iI as JS,gY as ew,mK as tw,cf as sw,mL as od,mM as nw,dG as rw,mN as ow,dn as id,dH as iw,dJ as aw,dI as lw,dP as cw,dO as dw,hH as uw,dN as fw,dL as pw,dM as hw,a as mw,s as gw,b as bw,c as yw,hO as xw,dV as Sw,dW as ww,dX as vw,dY as jw}from"./useAppFontEffects-Dm6zEvrf.js";import{u as Fp,S as kw,W as _p,f as Lp,a as Cw,G as Iw,b as Pw,c as Ew}from"./useRootScrollLock-mqVhK2HB.js";import{f as yi,h as mn,T as xi,M as Si,D as wi,j as vi,d as Tw,b as Dw,k as Rw,i as Nw}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as Mw,h as Aw,u as ji,S as Gl,a as $p,v as zp,s as Ow}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ki}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Kp,M as Wp,C as Hp,i as za,j as Ka,k as Wa,l as Bw,m as Fw}from"./vendor-base-ui-CPKyhvxM.js";import{c as to,u as hr,p as _w}from"./vendor-zustand-BAGL70zf.js";import{r as Wr,a as Ci,n as Up,s as zs,o as Ko,b as Ha}from"./vendor-zod-DDir2TeQ.js";import{u as Vp}from"./vendor-tanstack-react-virtual-Bmi0tTrf.js";import{D as Lw,a as $w,m as ad,G as zw}from"./moveWorkspacePath-CENAo75W.js";import{d as Gp,m as Kw}from"./vendor-tanstack-virtual-core-CdGDGrnp.js";const Ww=t=>{const e=Ze.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=Et(),a=le(Hw);let d;e[0]!==s?(d=$s(s),e[0]=s,e[1]=d):d=e[1];const c=d;let u;e[2]!==c?(u=w=>Vy(c?w.journey?.get(c):void 0),e[2]=c,e[3]=u):u=e[3];const f=Gs(u);let p;e[4]!==c?(p=w=>c?w.actions.get(c)?.kind==="running":!1,e[4]=c,e[5]=p):p=e[5];const h=Gs(p);if(!a||!c||!f||Dn())return null;let g;e[6]!==i?(g=i("spaces.header.apply"),e[6]=i,e[7]=g):g=e[7];const b=g;let x;e[8]!==c?(x=()=>Gs.getState().openApplyDialog(c),e[8]=c,e[9]=x):x=e[9];let y;e[10]!==o?(y=n.jsx(Z,{name:"git-merge",className:o}),e[10]=o,e[11]=y):y=e[11];let S;e[12]!==h||e[13]!==r||e[14]!==b||e[15]!==x||e[16]!==y?(S=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":b,disabled:h,onClick:x,className:r,children:y})}),e[12]=h,e[13]=r,e[14]=b,e[15]=x,e[16]=y,e[17]=S):S=e[17];let m;e[18]!==b?(m=n.jsx(Kt,{side:"bottom",children:b}),e[18]=b,e[19]=m):m=e[19];let v;return e[20]!==S||e[21]!==m?(v=n.jsxs(Ut,{children:[S,m]}),e[20]=S,e[21]=m,e[22]=v):v=e[22],v};function Hw(t){return t.isolatedSpacesEnabled}function Uw(t){const e=Ze.c(36),{directory:s,className:r}=t,{currentTheme:o}=br(),i=ns(qw),a=mt(Gw),d=Ps(Vw);let c;e[0]!==s||e[1]!==d?(c=Gu(s,d),e[0]=s,e[1]=d,e[2]=c):c=e[2];const u=c;let f;e[3]!==s||e[4]!==u||e[5]!==i||e[6]!==a?(f=u||!s?null:kf(i,a,s),e[3]=s,e[4]=u,e[5]=i,e[6]=a,e[7]=f):f=e[7];const p=f;if(u){let I;e[8]!==r?(I=Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=I):I=e[9];let B;return e[10]!==I?(B=n.jsx(Z,{name:"chat-4",className:I}),e[10]=I,e[11]=B):B=e[11],B}if(!p)return null;const h=p.icon?kl[p.icon]:null;let g;e[12]!==p.color?(g=Cl(p.color)??void 0,e[12]=p.color,e[13]=g):g=e[13];const b=g;let x;e[14]!==r||e[15]!==b||e[16]!==h?(x=h?n.jsx(Z,{name:h,className:Pe("h-3.5 w-3.5 shrink-0",r),style:b?{color:b}:void 0}):n.jsx(Z,{name:"folder",className:Pe("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),style:b?{color:b}:void 0}),e[14]=r,e[15]=b,e[16]=h,e[17]=x):x=e[17];const y=x;if(!p.iconImage)return y;let S;e[18]!==r?(S=Pe("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",r),e[18]=r,e[19]=S):S=e[19];let m;e[20]!==p.iconBackground?(m=p.iconBackground?{backgroundColor:p.iconBackground}:void 0,e[20]=p.iconBackground,e[21]=m):m=e[21];let v;e[22]!==p.iconImage||e[23]!==p.id?(v={id:p.id,iconImage:p.iconImage},e[22]=p.iconImage,e[23]=p.id,e[24]=v):v=e[24];let w;e[25]!==o.colors.surface.foreground||e[26]!==o.metadata.variant?(w={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[25]=o.colors.surface.foreground,e[26]=o.metadata.variant,e[27]=w):w=e[27];let T;e[28]!==y||e[29]!==v||e[30]!==w?(T=n.jsx(Il,{project:v,options:w,className:"h-full w-full object-contain",fallback:y}),e[28]=y,e[29]=v,e[30]=w,e[31]=T):T=e[31];let k;return e[32]!==S||e[33]!==m||e[34]!==T?(k=n.jsx("span",{className:S,style:m,children:T}),e[32]=S,e[33]=m,e[34]=T,e[35]=k):k=e[35],k}function Vw(t){return t.homeDirectory}function Gw(t){return t.availableWorktreesByProject}function qw(t){return t.projects}const Er=24,Yw=(t,e,s=Er)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},Zw=({transform:t})=>({...t,y:0}),Qw=16,Xw=t=>{if(t.shiftKey||t.ctrlKey||t.metaKey||Math.abs(t.deltaY)<=Math.abs(t.deltaX))return;const e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?t.deltaY*Qw:t.deltaY;t.currentTarget.scrollLeft+=ni(t.currentTarget)?-e:e},Jw={Item:rs,Separator:In},ev={Item:({className:t,...e})=>n.jsx(Wp,{className:Pe(Pf,t),...e}),Separator:({className:t,...e})=>n.jsx(Kp,{className:Pe(If,t),...e})},tv=t=>{const e=Ze.c(65),{tab:s,isActive:r,isPreview:o,suppressControls:i,onSelect:a,onPin:d,onClose:c,renderMenu:u,closeOtherTabs:f,onMenuOpenChangeComplete:p,children:h}=t,{t:g}=Et(),[b,x]=l.useState(!1),[y,S]=l.useState(!1),[m,v]=l.useState(!1);let w;e[0]!==s.id?(w={id:s.id},e[0]=s.id,e[1]=w):w=e[1];const{attributes:T,listeners:k,setNodeRef:I,transform:B,transition:O,isDragging:F}=ji(w);let j;e[2]!==g||e[3]!==s.session.title?(j=s.session.title?.trim()||g("sessions.sidebar.session.untitled"),e[2]=g,e[3]=s.session.title,e[4]=j):j=e[4];const P=j,L=!i&&(b||y),z=s.id;let H;e[5]!==s.session?(H=ur(s.session),e[5]=s.session,e[6]=H):H=e[6];const R=Sl(z,H),G=Pl(s.id),_=G!==null,E=Cf(s.id)>0&&!r&&!_,D=_||E;let C;e[7]!==f||e[8]!==m||e[9]!==r||e[10]!==b||e[11]!==a||e[12]!==s?(C=fe=>({session:s.session,open:b||m,isActive:r,select:()=>a(s),closeOtherTabs:()=>f(s.id),components:fe}),e[7]=f,e[8]=m,e[9]=r,e[10]=b,e[11]=a,e[12]=s,e[13]=C):C=e[13];const N=C;let A;e[14]!==B?(A=ki.Translate.toString(B),e[14]=B,e[15]=A):A=e[15];let q;e[16]!==A||e[17]!==O?(q={transform:A,transition:O},e[16]=A,e[17]=O,e[18]=q):q=e[18];const ee=F&&"z-10 opacity-60";let Q;e[19]!==ee?(Q=Pe("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",ee),e[19]=ee,e[20]=Q):Q=e[20];const he=r?"true":"false";let M;e[21]!==r?(M=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=M):M=e[22];let V;e[23]!==p?(V=fe=>p?.(fe),e[23]=p,e[24]=V):V=e[24];let ie;e[25]!==h||e[26]!==r||e[27]!==R||e[28]!==o||e[29]!==N||e[30]!==b||e[31]!==c||e[32]!==p||e[33]!==d||e[34]!==a||e[35]!==L||e[36]!==u||e[37]!==D||e[38]!==i||e[39]!==g||e[40]!==s||e[41]!==P||e[42]!==G?(ie=n.jsx(Hp,{render:fe=>n.jsxs("div",{...fe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>a(s),onDoubleClick:o?()=>d(s.id):void 0,onKeyDown:r?void 0:be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),a(s))},onAuxClick:be=>{be.button===1&&(be.preventDefault(),c(s.id))},"data-controls-open":L?"true":"false",className:Pe("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":Pe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",L&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:Pe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pe-10",L&&"pe-10"),children:[n.jsx(Uw,{directory:ur(s.session),className:"me-1.5"}),n.jsx("div",{className:Pe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title",o&&!i&&"italic"),children:r?h:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:n.jsx("span",{dir:"auto",className:"block max-w-full overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4",children:P})})}),R?n.jsx(Z,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":g("sessions.aiRename.generating")}):D?n.jsx(El,{state:G??"unread",className:Pe("ms-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",L&&"opacity-0")}):null]}),i?null:n.jsxs("div",{onClick:nv,onPointerDown:rv,className:Pe("absolute inset-e-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",L&&"flex opacity-100"),children:[n.jsxs(Rs,{open:b,onOpenChange:be=>{x(be),be&&S(!0)},onOpenChangeComplete:be=>{be||S(!1),p?.(be)},children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsx(Ms,{align:"start",className:"min-w-[190px]",children:u(N(Jw))})]}),n.jsx("button",{type:"button","aria-label":g("header.sessionTabs.closeTab"),onClick:()=>c(s.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]})]})}),e[25]=h,e[26]=r,e[27]=R,e[28]=o,e[29]=N,e[30]=b,e[31]=c,e[32]=p,e[33]=d,e[34]=a,e[35]=L,e[36]=u,e[37]=D,e[38]=i,e[39]=g,e[40]=s,e[41]=P,e[42]=G,e[43]=ie):ie=e[43];let ce,ne;e[44]===Symbol.for("react.memo_cache_sentinel")?(ce={color:"var(--surface-elevated-foreground)"},ne=Pe(Da,"min-w-[190px]"),e[44]=ce,e[45]=ne):(ce=e[44],ne=e[45]);let je;e[46]!==N||e[47]!==u?(je=u(N(ev)),e[46]=N,e[47]=u,e[48]=je):je=e[48];let Ee;e[49]!==je?(Ee=n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-content",style:ce,className:ne,children:je})})}),e[49]=je,e[50]=Ee):Ee=e[50];let we;e[51]!==m||e[52]!==V||e[53]!==ie||e[54]!==Ee?(we=n.jsxs(Zr,{open:m,onOpenChange:v,onOpenChangeComplete:V,children:[ie,Ee]}),e[51]=m,e[52]=V,e[53]=ie,e[54]=Ee,e[55]=we):we=e[55];let Me;return e[56]!==T||e[57]!==k||e[58]!==I||e[59]!==he||e[60]!==M||e[61]!==we||e[62]!==q||e[63]!==Q?(Me=n.jsx("div",{ref:I,style:q,className:Q,"data-active":he,...M,...T,...k,children:we}),e[56]=T,e[57]=k,e[58]=I,e[59]=he,e[60]=M,e[61]=we,e[62]=q,e[63]=Q,e[64]=Me):Me=e[64],Me},sv=t=>{const e=Ze.c(68),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,a=o===void 0?!1:o,{t:d,direction:c}=Et(),u=c==="rtl",f=Vn(ov),p=Vn(iv),h=Vn(av),g=Vn(lv),b=Vn(cv),x=Vn(dv),y=mt(uv),S=mt(fv),m=Os(pv),v=vb(y);let w,T;e[0]!==v||e[1]!==y||e[2]!==h?(w=()=>{y&&h(y,v)},T=[y,v,h],e[0]=v,e[1]=y,e[2]=h,e[3]=w,e[4]=T):(w=e[3],T=e[4]),l.useEffect(w,T);let k;if(e[5]!==m){k=new Map;for(const me of m)k.set(me.id,me);e[5]=m,e[6]=k}else k=e[6];const I=k;let B;if(e[7]!==I||e[8]!==f){B=[];for(const me of f){const re=I.get(me);re&&B.push({id:me,session:re})}e[7]=I,e[8]=f,e[9]=B}else B=e[9];const O=B;let F;e[10]!==S?(F=me=>{S(me.id,ur(me.session))},e[10]=S,e[11]=F):F=e[11];const j=F,P=hv;let L;e[12]!==b||e[13]!==y||e[14]!==j||e[15]!==O?(L=me=>{if(b(me),y&&y!==me){const re=O.find(pe=>pe.id===me);re&&j(re)}},e[12]=b,e[13]=y,e[14]=j,e[15]=O,e[16]=L):L=e[16];const z=L;let H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{distance:8}},e[17]=H):H=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{delay:200,tolerance:6}},e[18]=R):R=e[18];const G=yi(mn(Si,H),mn(xi,R));let _;e[19]!==x?(_=me=>{const{active:re,over:pe}=me;pe&&re.id!==pe.id&&x(String(re.id),String(pe.id))},e[19]=x,e[20]=_):_=e[20];const $=_,E=l.useRef(null);let D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D={left:!1,right:!1},e[21]=D):D=e[21];const[C,N]=l.useState(D);let A;e[22]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const me=E.current;if(!me)return;const re=me.scrollWidth-me.clientWidth,pe=ni(me)?re+me.scrollLeft:me.scrollLeft,U=pe>2,ae=pe<re-2;N(Re=>Re.left===U&&Re.right===ae?Re:{left:U,right:ae})},e[22]=A):A=e[22];const q=A;let ee;e[23]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{q();const me=E.current;if(!me||!globalThis.ResizeObserver)return;const re=new ResizeObserver(q);return re.observe(me),()=>re.disconnect()},e[23]=ee):ee=e[23];let Q;e[24]!==O.length?(Q=[q,O.length],e[24]=O.length,e[25]=Q):Q=e[25],l.useEffect(ee,Q);let he;e[26]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{const me=E.current,re=me?.querySelector("[data-active-session-tab]");if(!me||!re)return;const pe=Yw(me.getBoundingClientRect(),re.getBoundingClientRect());pe!==0&&(me.scrollLeft=me.scrollLeft+pe,q())},e[26]=he):he=e[26];let M;e[27]!==y?(M=[y,q],e[27]=y,e[28]=M):M=e[28],l.useEffect(he,M);const V=C.left&&C.right?`linear-gradient(to right, transparent, black ${Er}px, black calc(100% - ${Er}px), transparent)`:C.left?`linear-gradient(to right, transparent, black ${Er}px)`:C.right?`linear-gradient(to right, black calc(100% - ${Er}px), transparent)`:void 0;let ie;e[29]!==O?(ie=O.map(mv),e[29]=O,e[30]=ie):ie=e[30];const ce=ie;let ne;e[31]!==y||e[32]!==O?(ne=!!y&&!O.some(me=>me.id===y),e[31]=y,e[32]=O,e[33]=ne):ne=e[33];const je=ne;let Ee;e[34]!==d?(Ee=d("header.sessionTabs.stripAria"),e[34]=d,e[35]=Ee):Ee=e[35];let we;e[36]!==V?(we=V?{maskImage:V,WebkitMaskImage:V}:void 0,e[36]=V,e[37]=we):we=e[37];let Me;e[38]===Symbol.for("react.memo_cache_sentinel")?(Me=[Zw],e[38]=Me):Me=e[38];const fe=u?Mw:Aw;let be;e[39]!==i||e[40]!==y||e[41]!==z||e[42]!==j||e[43]!==r||e[44]!==g||e[45]!==p||e[46]!==s||e[47]!==a||e[48]!==O?(be=O.map(me=>n.jsx(tv,{tab:me,isActive:me.id===y,isPreview:me.id===p,suppressControls:me.id===y&&a,onSelect:j,onPin:g,onClose:P,renderMenu:s,closeOtherTabs:z,onMenuOpenChangeComplete:r,children:me.id===y?i:null},me.id)),e[39]=i,e[40]=y,e[41]=z,e[42]=j,e[43]=r,e[44]=g,e[45]=p,e[46]=s,e[47]=a,e[48]=O,e[49]=be):be=e[49];let ke;e[50]!==fe||e[51]!==be||e[52]!==ce?(ke=n.jsx(Gl,{items:ce,strategy:fe,children:be}),e[50]=fe,e[51]=be,e[52]=ce,e[53]=ke):ke=e[53];let Ie;e[54]!==$||e[55]!==G||e[56]!==ke?(Ie=n.jsx(wi,{sensors:G,collisionDetection:vi,modifiers:Me,onDragEnd:$,children:ke}),e[54]=$,e[55]=G,e[56]=ke,e[57]=Ie):Ie=e[57];let Te;e[58]!==i||e[59]!==je?(Te=je?n.jsx("div",{role:"tab","aria-selected":!0,className:"app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:n.jsx("div",{className:"min-w-0 flex-1",children:i})}):null,e[58]=i,e[59]=je,e[60]=Te):Te=e[60];let Y;e[61]!==we||e[62]!==Ie||e[63]!==Te?(Y=n.jsxs("div",{ref:E,onScroll:q,onWheel:Xw,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:we,children:[Ie,Te]}),e[61]=we,e[62]=Ie,e[63]=Te,e[64]=Y):Y=e[64];let ue;return e[65]!==Ee||e[66]!==Y?(ue=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Ee,children:Y}),e[65]=Ee,e[66]=Y,e[67]=ue):ue=e[67],ue};function nv(t){return t.stopPropagation()}function rv(t){return t.stopPropagation()}function ov(t){return t.tabIds}function iv(t){return t.previewTabId}function av(t){return t.ensureTab}function lv(t){return t.pinTab}function cv(t){return t.closeOtherTabs}function dv(t){return t.reorderTabs}function uv(t){return t.currentSessionId}function fv(t){return t.setCurrentSession}function pv(t){return t.activeSessions}function hv(t){Gy(t)}function mv(t){return t.id}const gv=500;function os(t){const e=Ze.c(9),{hint:s,children:r}=t,[o,i]=l.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(f,p)=>{f&&p.reason==="trigger-focus"||i(f)},e[0]=a):a=e[0];let d;e[1]!==r?(d=n.jsx(Ht,{asChild:!0,children:r}),e[1]=r,e[2]=d):d=e[2];let c;e[3]!==s?(c=n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=c):c=e[4];let u;return e[5]!==o||e[6]!==d||e[7]!==c?(u=n.jsxs(Ut,{delayDuration:gv,open:o,onOpenChange:a,children:[d,c]}),e[5]=o,e[6]=d,e[7]=c,e[8]=u):u=e[8],u}const bv=t=>{const e=Ze.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=Et(),a=qy(ns(yv),s),d=Ps(xv);let c;e[0]!==i?(c=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=c):c=e[1];let u;e[2]!==c?(u=n.jsx(nn,{children:c}),e[2]=c,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("sessions.moveChatToProject.description"),e[4]=i,e[5]=f):f=e[5];let p;e[6]!==f?(p=n.jsx(rn,{children:f}),e[6]=f,e[7]=p):p=e[7];let h;e[8]!==u||e[9]!==p?(h=n.jsxs(on,{children:[u,p]}),e[8]=u,e[9]=p,e[10]=h):h=e[10];let g;if(e[11]!==d||e[12]!==r||e[13]!==o||e[14]!==a){let S;e[16]!==d||e[17]!==r||e[18]!==o?(S=m=>n.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(m.path)},children:[n.jsx(Z,{name:"folder",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label?.trim()||di(m.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:fr(m.path,d)})]},m.id),e[16]=d,e[17]=r,e[18]=o,e[19]=S):S=e[19],g=a.map(S),e[11]=d,e[12]=r,e[13]=o,e[14]=a,e[15]=g}else g=e[15];let b;e[20]!==g?(b=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:g}),e[20]=g,e[21]=b):b=e[21];let x;e[22]!==h||e[23]!==b?(x=n.jsxs(Zs,{className:"max-w-md",children:[h,b]}),e[22]=h,e[23]=b,e[24]=x):x=e[24];let y;return e[25]!==r||e[26]!==s||e[27]!==x?(y=n.jsx(Qs,{open:s,onOpenChange:r,children:x}),e[25]=r,e[26]=s,e[27]=x,e[28]=y):y=e[28],y};function yv(t){return t.projects}function xv(t){return t.homeDirectory}function ld(t){const e=Ze.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=Et();let a;e[0]!==s?(a=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=a):a=e[1];const d=Os(a);let c;e[2]!==s?(c=k=>{const I=k.entityById.get(s);return!I||Yy(I,k.entityById)},e[2]=s,e[3]=c):c=e[3];const u=Os(c),f=mt(Sv);let p;e[4]!==s||e[5]!==i||e[6]!==f?(p=async()=>{await f(s)?He.success(i("sessions.sidebar.session.restore.success")):He.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=p):p=e[7];const h=p;if(d&&!u)return null;const g=d?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let b;e[8]!==i||e[9]!==g?(b=i(g),e[8]=i,e[9]=g,e[10]=b):b=e[10];let x;e[11]!==d||e[12]!==r||e[13]!==h?(x=d?()=>{h()}:r,e[11]=d,e[12]=r,e[13]=h,e[14]=x):x=e[14];const y=d?"inbox-unarchive":"inbox-archive";let S;e[15]!==y?(S=n.jsx(Z,{name:y,className:"me-1 size-4"}),e[15]=y,e[16]=S):S=e[16];const m=d?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let v;e[17]!==i||e[18]!==m?(v=i(m),e[17]=i,e[18]=m,e[19]=v):v=e[19];let w;e[20]!==o||e[21]!==v||e[22]!==x||e[23]!==S?(w=n.jsxs(o,{onClick:x,children:[S,v]}),e[20]=o,e[21]=v,e[22]=x,e[23]=S,e[24]=w):w=e[24];let T;return e[25]!==w||e[26]!==b?(T=n.jsx(os,{hint:b,children:w}),e[25]=w,e[26]=b,e[27]=T):T=e[27],T}function Sv(t){return t.unarchiveSession}const qp=async t=>{const{entry:e,session:s}=t,r=Jt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(Zy(e.action)&&Qy(e.guest,"conversation"))){await Wc(e,Hc(e.action.id,o),t.t,r);return}let a=!1;const d=ri(()=>{a=!0});let c;try{c=await t.loadRecords()}finally{d()}if(!a){if(!c){t.onLoadFailed();return}await Wc(e,Hc(e.action.id,o,c),t.t,r)}};function Ua(t){const e=Ze.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:a}=Et(),{pending:d,disabled:c,hint:u,run:f}=jb(s,r,o),p=d?"loader-4":"ai-generate-2",h=d?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==p||e[1]!==h?(g=n.jsx(Z,{name:p,className:h}),e[0]=p,e[1]=h,e[2]=g):g=e[2];let b;e[3]!==a?(b=a("sessions.aiRename.action"),e[3]=a,e[4]=b):b=e[4];let x;e[5]!==i||e[6]!==c||e[7]!==f||e[8]!==g||e[9]!==b?(x=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:c,onClick:f,className:"w-full",children:[g,b]})}),e[5]=i,e[6]=c,e[7]=f,e[8]=g,e[9]=b,e[10]=x):x=e[10];let y;return e[11]!==u||e[12]!==x?(y=n.jsx(os,{hint:u,children:x}),e[11]=u,e[12]=x,e[13]=y):y=e[13],y}const Wo=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class Yp extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const Ii=to(()=>({pendingSessionIds:new Set})),Zp=t=>{const e=Ze.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],Ii(s)},cd=(t,e)=>{Ii.setState(s=>{if(s.pendingSessionIds.has(t)===e)return s;const r=new Set(s.pendingSessionIds);return e?r.add(t):r.delete(t),{...s,pendingSessionIds:r}})},wv=async(t,e)=>{try{const c=(await sx(t,{mode:"light"})).current?.trim();if(c)return c}catch{}const s=yt(t),r=yt(e)??e,o=mt.getState().availableWorktreesByProject,a=Lr(o.get(r)??o.get(e)??[],s??t)?.branch?.trim();if(a)return a;throw new Error("Unable to determine the current branch")},dd=t=>{for(const e of t){const s=Jy(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class vv extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const jv=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new vv(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},kv=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(Ra(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Tf(i,s,e),mt.getState().setWorktreeMetadata(i.id,r.get(i.id)??null,e)}catch(a){o.push({sessionId:i.id,error:a instanceof Error?a:new Error(String(a))})}}return o},ud=async(t,e,s)=>{try{await Mf(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},fd=async(t,e)=>{const s=e?[t,e]:[t];try{await Tl(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},ql=async(t,e)=>{if(Ii.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");cd(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(d=>[d.id,mt.getState().getWorktreeMetadata(d.id)]));dd(s);let o=null;const i=[];let a=!1;try{o=await e();for(const[d,c]of s.entries()){dd(s.slice(d));try{await Tf(c,t.sourceDirectory,o.directory)}catch(u){throw Xy(u)&&(a=!0),u}i.push(c),c.id!==t.root.id&&mt.getState().setWorktreeMetadata(c.id,o.metadata?Uc(o.metadata):null,o.directory)}}catch(d){const c=d instanceof Error?d:new Error(String(d)),u=await kv(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(a&&await fd(t.sourceDirectory,o?.directory),u.length>0)throw jv(c,u);if(o?.onMoveFailure&&!a)return o.onMoveFailure(c);throw o?.onMoveFailure&&a?new Yp(c):c}return mt.getState().setWorktreeMetadata(t.root.id,o.metadata?Uc(o.metadata):null,o.directory),await fd(t.sourceDirectory,o.directory),o.directory}finally{cd(t.root.id,!1)}},Cv=async t=>{const e=yt(t.sourceDirectory)??t.sourceDirectory,s=yt(t.destination.path)??t.destination.path;if(Ef(s,e))throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return ql(t,async()=>{const r=await Df(t.sourceDirectory);return{directory:r?await Rf(r,t.destination.path):t.destination.path,metadata:t.destination}})},Iv=async t=>{if((yt(t.sourceDirectory)??t.sourceDirectory)===(yt(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return ql(t,async()=>({directory:t.projectDirectory,metadata:null}))},Pv=async t=>ql(t,async()=>{const e=Na(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await Nf(t.sourceDirectory)?await wv(t.sourceDirectory,e.path):null,r=await ex(e,s?{startRef:s}:{});if(!r)throw new Error("Worktree creation cancelled");try{await tx(r.path)}catch(i){const a=i instanceof Error?i:new Error(String(i));return ud(e,r,a)}const o=await Df(t.sourceDirectory)??e;return{directory:await Rf(o,r.path),metadata:r,onMoveFailure:async i=>ud(e,r,i)}}),Ev=t=>{(t.kind==="existing"?Cv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?Iv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):Pv({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>He.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));He.error(t.messages.failure,{description:r instanceof Yp?t.messages.outcomeUnknown:r.message})})},Ho=t=>{Ii.getState().pendingSessionIds.has(t.root.id)||Ev(t)},ra="--oc-titlebar-controls-width",Va=new Set;let Mr=null;const Qp=t=>{Mr===null?t.style.removeProperty(ra):t.style.getPropertyValue(ra)!==Mr&&t.style.setProperty(ra,Mr)},Tv=t=>{const e=`${Math.round(t)}px`;e!==Mr&&(Mr=e,Va.forEach(Qp))},Xp=t=>{if(t)return Va.add(t),Qp(t),()=>{Va.delete(t)}},vr="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground data-[popup-open]:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 transition-colors",Yn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Dv=()=>{As("ui.header.render");const{t,direction:e}=Et(),s=le(te=>te.isSidebarOpen),r=ui(),o=le(te=>te.sessionTabsEnabled),i=mt(te=>!!te.newSessionDraft?.open),a=mt(te=>te.currentSessionId),d=nx(a??""),c=Zp(a??""),u=Os(hr(l.useCallback(te=>{if(!a)return null;const et=[...te.activeSessions,...te.archivedSessions].find(It=>It.id===a);if(!et)return null;const xt=et;return{title:et.title??null,directory:xt.directory??null,created:et.time?.created??null,slug:xt.slug??null,parentId:et.parentID??null}},[a]))),f=ns(hr(te=>{if(!te.activeProjectId)return null;const et=te.projects.find(xt=>xt.id===te.activeProjectId);return et?{id:et.id,path:et.path,label:et.label}:null})),p=l.useMemo(()=>{if(!f)return null;const te=f.label?.trim();if(te)return te;const et=f.path.split(/[\\/]/).filter(Boolean);return et[et.length-1]??null},[f]),h=Jn(te=>te.loadSettings),{isMobile:g}=Rn(),b=l.useRef(null),[x,y]=l.useState(()=>typeof window>"u"?!1:hn()),S=l.useMemo(()=>Do(),[]),m=rx(),[v,w]=l.useState(!1),T=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:I}=Fp(),B=l.useMemo(()=>{if(typeof window>"u")return null;const te=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof te=="number"&&Number.isFinite(te)&&te>0)return te;if(typeof navigator>"u")return null;const et=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!et)return null;const xt=Number.parseInt(et[1],10),It=Number.parseInt(et[2],10);return Number.isNaN(xt)?null:xt===10?It:xt},[]);us.useEffect(()=>{typeof window>"u"||y(hn())},[]);const O=l.useMemo(()=>Dn(),[]),F=le(te=>te.workStatusPanelVisible),j=le(te=>te.workStatusPanelEnabled),P=le(te=>te.setWorkStatusPanelEnabled),L=le(te=>te.workStatusPanelFits),z=le(te=>te.workStatusOverlayOpen),H=le(te=>te.setWorkStatusOverlayOpen),G=j&&L||z,_=l.useCallback(()=>{if(j&&!L){H(!z);return}P(!j)},[H,P,z,j,L]);ox(),l.useEffect(()=>{h()},[h]);const $=a?u??null:null,E=l.useRef(null),[D,C]=l.useState(0);l.useEffect(()=>{if(!a){E.current&&(E.current=null,C(It=>It+1));return}if($){E.current={sessionId:a,session:$,expiresAt:Date.now()+2e3};return}const te=E.current;if(!te||te.sessionId!==a)return;const et=te.expiresAt-Date.now();if(et<=0){E.current=null,C(It=>It+1);return}const xt=window.setTimeout(()=>{E.current?.sessionId===a&&(E.current=null),C(It=>It+1)},et);return()=>{window.clearTimeout(xt)}},[a,$]);const N=(()=>{if($)return $;if(!a)return null;const te=E.current;return te&&te.sessionId===a&&te.expiresAt>Date.now()?te.session:null})(),A=mt(te=>a?te.worktreeMetadata.get(a)?.path??"":""),q=mt(te=>a?te.worktreeMetadata.get(a)?.branch?.trim()??null:null),ee=Af(te=>a?te.getAttachment(a):void 0),Q=l.useMemo(()=>ee?ix(ee,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ee]),he=l.useMemo(()=>ee?ee.legacy?"legacy":ee.degraded?"degraded":ee.worktreeStatus==="pending"?"pending":ee.worktreeStatus==="missing"?"missing":ee.worktreeStatus==="invalid"?"invalid":ee.attentionReason?"attention":null:null,[ee]),M=l.useMemo(()=>Yn(A||""),[A]),V=l.useMemo(()=>{const te=typeof N?.directory=="string"?N.directory:"";return Yn(te||"")},[N?.directory]),ie=Sl(a??"",V),ce=mt(te=>te.newSessionDraft?.open?Yn(te.newSessionDraft.bootstrapPendingDirectory??te.newSessionDraft.directoryOverride??""):""),ne=mt(te=>te.newSessionDraft.target),je=mt(te=>te.newSessionDraft.selectedProjectId),Ee=mt(te=>te.currentSessionDirectory),we=Ps(te=>te.homeDirectory),Me=Yr(),fe=l.useMemo(()=>M||V||(fi(Me,ce)??""),[ce,Me,V,M]),be=mt(te=>{const et=Yn(M||V||"");if(!et)return null;for(const xt of te.availableWorktreesByProject.values()){const St=Lr(xt,et)?.branch?.trim();if(St)return St}return null}),Ie=ax(fe||null)||q||be,Te=i?ne==="chat":Gu(V||Ee,we),Y=!Te&&!F&&!!(p||Ie||!i&&he),ue=l.useMemo(()=>{if(!a)return p??"OpenChamber";const te=N?.title?.trim();return te&&te.length>0?te:"Untitled Session"},[p,N?.title,a]),me=Of(),re=mt(te=>te.updateSessionTitle),pe=mt(te=>te.archiveSessions),U=mt(te=>te.deleteSessions),[ae,Re]=l.useState(!1),[W,ye]=l.useState(!1),de=l.useRef(null),[Ne,Je]=l.useState(""),[Ge,ge]=l.useState(!1),Ae=ns(te=>te.projects.length>0),[Ye,nt]=l.useState(null),oe=l.useRef(null),tt=l.useCallback(()=>{a&&(Je(N?.title?.trim()||ue),Re(!0))},[N?.title,a,ue]),Ue=l.useRef(tt);Ue.current=tt;const gt=l.useCallback(te=>{te&&(te.focus(),te.select())},[]);l.useEffect(()=>{if(ye(!1),nt(null),a&&de.current===a){de.current=null,Ue.current();return}Re(!1),Je("")},[a]);const bt=l.useCallback(async()=>{if(!a)return;const te=Ne.trim();te&&te!==N?.title?.trim()&&await re(a,te),Re(!1)},[N?.title,a,Ne,re]);l.useEffect(()=>{if(!ae)return;const te=et=>{const xt=et.target;(!xt||!oe.current?.contains(xt))&&bt()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[ae,bt]);const Ce=l.useCallback(te=>{te&&pi(te).then(et=>{He[et.ok?"success":"error"](t(et.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>He.error(t("sessions.sidebar.session.copyId.error")))},[t]),_e=l.useCallback(async()=>{if(!a||!fe){He.error(t("sessions.sidebar.session.export.nothingToExport"));return}const te=await me({sessionID:a,directory:fe}).catch(()=>null);if(!te){He.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(te.length===0){He.error(t("sessions.sidebar.session.export.nothingToExport"));return}const et=Bf(te,N?.title??null),xt=Ff(N?.title??null);await _f(et,xt)||Lf(et,xt),He.success(t("sessions.sidebar.session.export.success"))},[N?.title,a,me,fe,t]),ze=$f(),Oe=l.useMemo(()=>zf(ze),[ze]),it=l.useCallback(te=>{a&&qp({entry:te,t,session:{id:a,title:N?.title,directory:V??fe},loadRecords:async()=>{if(!fe)return null;try{return await me({sessionID:a,directory:fe})}catch{return null}},onLoadFailed:()=>He.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[N?.title,a,me,fe,V,t]),X=l.useCallback(te=>Oe.map(et=>n.jsxs(te,{onClick:()=>it(et),children:[n.jsx(yr,{icon:et.icon,iconSrc:et.iconSrc,className:"me-1 size-4"}),et.action.label]},`${et.guest.id}:${et.action.id}`)),[Oe,it]),Be=d?.type==="busy"||d?.type==="retry",Le=l.useCallback(()=>{if(!a||!V||Be||c)return;const et=Os.getState().activeSessions.find(xt=>xt.id===a);et&&Ho({kind:"quick",root:et,descendants:Bo(et,[]),sourceDirectory:V,messages:Wo(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[a,Be,c,V,t]),at=l.useCallback(te=>{if(!a||!V||Be||c)return;const xt=Os.getState().activeSessions.find(It=>It.id===a);xt&&Ho({kind:"project",root:xt,descendants:Bo(xt,[]),sourceDirectory:V,projectDirectory:te,messages:Wo(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[a,Be,c,V,t]),qe=l.useCallback(async(te,et)=>{const xt=[et,...wl(et,[],te==="delete")],It=mt.getState().currentSessionId===et?et:null;if(te==="delete"){const{failedIds:We}=await U(xt);We.length>0?He.error(t("sessions.sidebar.session.delete.error")):He.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:St,failedIds:Se}=await pe(xt);if(Se.length>0){He.error(t("sessions.sidebar.session.archive.error"));return}He.success(t("sessions.sidebar.session.archive.success"),kb(St,It,t))},[pe,U,t]),ut=l.useCallback(async()=>{if(!Ye)return;const{action:te,sessionId:et}=Ye;nt(null),await qe(te,et)},[Ye,qe]),dt=le(te=>te.openGuestPageId),ft=Dl(te=>te.guests.find(et=>et.id===dt)),st=le(te=>te.isScheduledTasksDialogOpen),Rt=le(te=>te.isArchivePageOpen),Ke=le(te=>te.isIntegrationsCatalogOpen),jt=le(te=>te.isUsageStatsPageOpen),Lt=le(te=>te.isSourceBoardOpen),Mt=le(te=>te.worktreesPageProjectId),De=le(te=>te.isolatedSpacesEnabled?te.spacesPageProjectId:null),Tt=le(te=>te.runOverviewKey),At=Cb(Tt),kt=Mt??De,pt=ns(te=>{if(!kt)return null;const et=te.projects.find(xt=>xt.id===kt);return et?.label?.trim()||et?.path?.split("/").pop()||null}),Dt=l.useMemo(()=>ft?{title:ft.pageTitle??ft.name,subtitle:null}:st?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Rt?{title:t("sessions.archivePage.title"),subtitle:null}:Ke?{title:t("integrationsCatalog.page.title"),subtitle:null}:jt?{title:t("usageStats.title"),subtitle:null}:Lt?{title:t("sourceBoard.title"),subtitle:null}:Mt?{title:t("sessions.worktreesPage.title",{project:pt??""}),subtitle:null}:De?{title:t("spaces.page.title",{project:pt??""}),subtitle:null}:Tt?{title:At??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[ft,Rt,Ke,At,Tt,st,Lt,jt,De,pt,t,Mt]),Ve=V||Yn(Ee||"")||M,rt=l.useCallback(()=>{vn("desktop_open_draft_mini_chat_window",{directory:Te?"":ce,projectId:Te?null:je,...Tr()}).catch(te=>{console.warn("[header] failed to open draft mini chat window",te)})},[ce,je,Te]),wt=l.useCallback(()=>{if(i){rt();return}a&&vn("desktop_open_session_mini_chat_window",{sessionId:a,directory:V||Yn(Ee||"")||M,...Tr()}).catch(te=>{console.warn("[header] failed to open session mini chat window",te)})},[a,rt,i,Ee,V,M]),se=S&&(i||!!a),Fe=l.useCallback((te,et)=>{vn("desktop_open_session_mini_chat_window",{sessionId:te,directory:et,...Tr()}).catch(xt=>{console.warn("[header] failed to open session mini chat window",xt)})},[]),ot=vr,$e=l.useMemo(()=>x&&T&&!v?"88px":m?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!x||k)&&!O?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[x,v,T,m,O,k]),Ct=(!x||k)&&!O?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Yt=e==="rtl",es=Yt?Ct:$e,Zt=Yt?$e:Ct,ss=k&&I!==qu(e);us.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",es)},[es]);const bs=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",ls=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";us.useEffect(()=>{if(!x||!T){w(!1);return}let te=!1;const et=async()=>{try{const It=await vn("desktop_is_window_fullscreen");te||w(It===!0)}catch{te||w(!1)}},xt=()=>{et()};return et(),window.addEventListener("openchamber:window-resized",xt),()=>{te=!0,window.removeEventListener("openchamber:window-resized",xt)}},[x,T]);const ms=l.useMemo(()=>!x||!T||B===null?"":B>=26?"h-11":B<=15?"h-14":"",[x,T,B]),fs=l.useMemo(()=>x&&T&&!v?B!==null&&B<=15?"56px":"44px":"0px",[x,v,T,B]),Es=l.useMemo(()=>{const et=`max(${x&&T?"2.75rem":"3rem"}, ${fs}, var(--oc-wco-titlebar-height, 0px))`,xt=x&&!k||O;if(xt&&fs==="0px")return{};const It={minHeight:et,height:et};return!ss&&(!xt||Yt)&&(It.paddingInlineEnd=Zt),It},[ss,x,T,Yt,O,Zt,fs,k]),cs=l.useRef(null),Qe=l.useCallback(te=>{!te||te===cs.current||(cs.current=te,document.documentElement.style.setProperty("--oc-header-height",`${te}px`))},[]),vt=l.useCallback(()=>{typeof document>"u"||Qe(b.current?.getBoundingClientRect().height)},[Qe]);us.useEffect(()=>{if(typeof window>"u")return;vt();const te=b.current;if(!te||typeof ResizeObserver>"u")return()=>{};let et=0;const xt=()=>{et||(et=requestAnimationFrame(()=>{et=0,vt()}))},It=new ResizeObserver(St=>{const Se=St[St.length-1];Qe(Se?.borderBoxSize?.[0]?.blockSize??Se?.target.getBoundingClientRect().height)});return It.observe(te),window.addEventListener("resize",xt),window.addEventListener("orientationchange",xt),()=>{et&&cancelAnimationFrame(et),It.disconnect(),window.removeEventListener("resize",xt),window.removeEventListener("orientationchange",xt)}},[Qe,vt]),us.useEffect(()=>{vt()},[vt,g,ms]);const $t=l.useCallback(async te=>{const et=te.target;et.closest(".app-region-no-drag")||et.closest("button, a, input, select, textarea")||te.button===0&&x&&await Cg()},[x]);Kf({rename_current_session:()=>{if(!a||g)return!1;tt()},archive_current_session:()=>{if(!a||g||Os.getState().entityById.get(a)?.time.archived)return!1;if(le.getState().showDeletionDialog){nt({action:"archive",sessionId:a});return}qe("archive",a)}});const ve=n.jsxs(n.Fragment,{children:[n.jsx(Ww,{directory:fe,className:Pe(vr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(Ib,{directory:fe,className:Pe(vr,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),ct=l.useCallback(({session:te,open:et,isActive:xt,select:It,closeOtherTabs:St,components:Se})=>{const{Item:We,Separator:K}=Se,xe=xt&&!O&&!Te&&N&&!N.parentId,Xe=xt&&!O&&Te&&N&&!N.parentId&&Ae;return n.jsxs(n.Fragment,{children:[n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(We,{onClick:()=>{xt||It(),de.current=te.id},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:te.id,directory:te.directory,open:et,Item:We}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(We,{onClick:()=>Ce(te.id),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(K,{}),xt?n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(We,{onClick:()=>{_e()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,S?n.jsxs(We,{onClick:()=>Fe(te.id,xt?Ve:te.directory??""),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,xt?X(We):null,xe?n.jsx(os,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(We,{disabled:!V||Be||c,onClick:Le,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Xe?n.jsx(os,{hint:t(Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(We,{disabled:!V||Be||c,onClick:()=>ge(!0),className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(K,{}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(We,{onClick:St,children:[n.jsx(Z,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(K,{}),n.jsx(ld,{sessionId:te.id,Item:We,onArchive:()=>nt({action:"archive",sessionId:te.id})}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(We,{className:"text-destructive focus:text-destructive",onClick:()=>nt({action:"delete",sessionId:te.id}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[Ce,N,Ve,_e,S,Ae,Te,Be,c,O,Le,Fe,X,V,t]),ht=()=>n.jsxs("div",{onMouseDown:$t,className:Pe("app-region-drag relative flex h-12 select-none items-center",ss?"pe-0":"pe-2.5",ms),style:Es,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:bs,transitionDuration:`${r}ms`,transitionTimingFunction:pr}}),n.jsx("div",{ref:Xp,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] motion-reduce:transition-none",style:{width:ls,transitionDuration:`${r}ms`,transitionTimingFunction:pr}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Dt?n.jsxs(n.Fragment,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"icon",className:"app-region-no-drag me-1 size-6 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>le.getState().closeMainSurfaces(),children:n.jsx(Z,{name:"arrow-left",className:"size-4"})})}),n.jsx(Kt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"me-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-start",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Dt.title}),Dt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Dt.subtitle}):null]})]}):O||!o?n.jsxs("div",{className:"app-region-no-drag me-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-start",children:[ie?n.jsx(Z,{name:"loader-4",className:"me-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,s?null:n.jsx(kw,{align:"start",children:n.jsx("button",{type:"button",className:ot,"aria-label":t("sessions.switcher.openAria"),children:n.jsx(Z,{name:"history",className:"h-4 w-4"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ae?n.jsxs("form",{ref:oe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:te=>te.stopPropagation(),onSubmit:te=>{te.preventDefault(),bt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:te=>Je(te.target.value),onKeyDown:te=>Ea(te,()=>Re(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Re(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):i?null:n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:ue}),Y?n.jsxs("span",{className:Pe("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",i?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[p?n.jsx("span",{className:"truncate",children:p}):null,Ie?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Z,{name:"git-branch",className:Pe("flex-shrink-0 text-muted-foreground/70",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:Pe("truncate",i&&"text-muted-foreground"),children:Ie})]}):null,!i&&he?n.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",he==="attention"||he==="invalid"||he==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx(Z,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:Q})]}):null]}):null]}),n.jsx("div",{className:Pe("flex h-[18px] shrink-0 items-center justify-center",Y?"self-start":"self-center"),children:a&&!i&&!ae?n.jsxs(Rs,{open:W,onOpenChange:ye,onOpenChangeComplete:te=>{!te&&de.current&&de.current===a&&(de.current=null,tt())},children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{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:n.jsx(Z,{name:"more",className:"size-4"})})}),n.jsxs(Ms,{align:"end",className:"min-w-[190px]",children:[n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(rs,{onClick:()=>{de.current=a},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:a,directory:V,open:W,Item:rs}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(rs,{onClick:()=>a&&Ce(a),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(In,{}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(rs,{onClick:()=>{_e()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),S?n.jsxs(rs,{onClick:()=>Fe(a,Ve),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,X(rs),!O&&!Te&&N&&!N.parentId?n.jsx(os,{hint:t(c?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Be?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(rs,{disabled:!V||Be||c,onClick:Le,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(In,{}),n.jsx(ld,{sessionId:a,Item:rs,onArchive:()=>nt({action:"archive",sessionId:a})}),n.jsx(os,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(rs,{className:"text-destructive focus:text-destructive",onClick:()=>{a&&nt({action:"delete",sessionId:a})},children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-start",children:n.jsx(sv,{renderMenu:ct,suppressActiveTabControls:ae,onMenuOpenChangeComplete:te=>{!te&&de.current&&de.current===a&&(de.current=null,tt())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ae?n.jsxs("form",{ref:oe,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:te=>te.stopPropagation(),onSubmit:te=>{te.preventDefault(),bt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:te=>Je(te.target.value),onKeyDown:te=>Ea(te,()=>Re(!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"}),n.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:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Re(!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:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap oc-ui-start-align text-[13px] font-medium leading-4 text-foreground max-w-full",children:i?t("sessions.switcher.draftTitle"):ue})})})}),Dt||O||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[se?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:wt,className:vr,children:n.jsx(Z,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",children:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,O?null:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":G,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:_,className:Pe(vr,G&&"text-foreground"),children:n.jsx(Z,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",children:t(j&&!L?z?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":j?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ve,n.jsx(_p,{visible:ss,position:I})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:b,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:ht()}),n.jsx(bv,{open:Ge,onOpenChange:ge,onPick:at}),n.jsx(Qs,{open:Ye!==null,onOpenChange:te=>{te||nt(null)},children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:Ye?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(rn,{children:Ye?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:ue}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:ue})})]}),n.jsxs(Pn,{children:[n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>nt(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",size:"sm",onClick:()=>{ut()},children:Ye?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},pd=280,hd=264,md=500,Rv=({isOpen:t,isMobile:e,children:s,className:r,topBar:o,peek:i})=>{const{t:a,direction:d}=Et(),c=le(_=>_.sidebarWidth),u=le(_=>_.setSidebarWidth),[f,p]=l.useState(!1),h=l.useRef(0),g=l.useRef(c||pd),b=l.useRef(null),x=l.useRef(null),y=l.useRef(null),S=l.useCallback(_=>Math.min(md,Math.max(hd,_)),[]),m=l.useCallback(_=>{const $=y.current;$&&($.style.width=`${_}px`,$.style.minWidth=`${_}px`,$.style.maxWidth=`${_}px`,$.style.setProperty("--oc-left-sidebar-width",`${_}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${_}px`))},[]);l.useEffect(()=>{e&&f&&p(!1)},[e,f]),l.useEffect(()=>{f||(b.current=null,x.current=null)},[f]);const v=Math.min(md,Math.max(hd,c||pd)),w=t?v:0,T=f?b.current??w:w,k=f?T:v;l.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`)},[k]);const[I,B]=l.useState(!t);t&&I&&B(!1);const O=ui(),F=l.useRef(t),j=l.useRef(t);if(l.useLayoutEffect(()=>{F.current=t,j.current!==t&&(j.current=t,Wf(O),t||Rl(()=>{F.current||B(!0)}))},[t,O]),e)return null;const P=_=>{if(t){try{_.currentTarget.setPointerCapture(_.pointerId)}catch{}x.current=_.pointerId,p(!0),h.current=_.clientX,g.current=w,b.current=w,m(w),_.preventDefault()}},L=_=>{if(e||!f||x.current!==_.pointerId)return;const $=(_.clientX-h.current)*(d==="rtl"?-1:1),E=S(g.current+$);b.current!==E&&(b.current=E,m(E))},z=_=>{if(x.current!==_.pointerId||e)return;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}const $=S(b.current??w);x.current=null,b.current=null,p(!1),u($)},H=!t&&i?i.state:!1,R=H!==!1,G=R&&i&&i.animationMs>0?`${H==="in"?"oc-sidebar-peek-in":"oc-sidebar-peek-out"} ${i.animationMs}ms ${pr} forwards`:void 0;return n.jsxs("div",{ref:y,"data-left-sidebar":"",className:Pe("relative flex h-full border-e border-border",!R&&"overflow-hidden",f?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${T}px`,minWidth:`${T}px`,maxWidth:`${T}px`,"--oc-left-sidebar-width":`${k}px`,overflowX:R?void 0:"clip",transitionDuration:`${O}ms`,transitionTimingFunction:pr},children:[t&&n.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)] rtl:shadow-[inset_2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&n.jsx("div",{className:Pe("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",f&&"bg-[var(--interactive-border)]"),onPointerDown:P,onPointerMove:L,onPointerUp:z,onPointerCancel:z,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{ref:i?.overlayRef,"data-sidebar-peek":R?H:void 0,className:Pe("flex h-full shrink-0 flex-col",R?"absolute inset-s-0 top-0 z-[25] border-e border-border bg-sidebar shadow-xl":"relative z-10 transition-opacity ease-out motion-reduce:transition-none",f&&"pointer-events-none",!t&&!R&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${O}ms`,overflowX:"hidden",contentVisibility:I&&!R?"hidden":void 0,animation:G,"--oc-peek-offset":d==="rtl"?"100%":"-100%"},inert:!t&&!R||void 0,onPointerEnter:R?i?.overlayHandlers.onPointerEnter:void 0,onPointerLeave:R?i?.overlayHandlers.onPointerLeave:void 0,onAnimationEnd:R?i?.overlayHandlers.onAnimationEnd:void 0,children:[o,n.jsx(Qr,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(Cs,{children:s})})]})]})},Nv=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-start-inset, 0.75rem)"}}),t[1]=s):s=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[s,n.jsx("div",{ref:Xp,className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),n.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Mv=50,Av=18,Ov=300,Bv='[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]',Jp=t=>!document.getElementById("root")?.contains(t),Fv=t=>{if((ni(document.documentElement)?window.innerWidth-t.clientX:t.clientX)>Av)return!1;const s=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--oc-header-height"))||48;return t.clientY>=s},gd=t=>{const e=document.activeElement;return t&&e instanceof HTMLElement&&t.contains(e)&&(e.isContentEditable||e.matches("input, textarea"))?!0:Array.from(document.querySelectorAll(Bv)).some(s=>Jp(s)&&s.getClientRects().length>0)},_v=({enabled:t,layoutAnimationMs:e})=>{const[s,r]=l.useState(!1),o=lx()?0:e,i=o>0,a=l.useRef(null),d=l.useRef(null),c=l.useRef(null),u=l.useCallback(()=>{d.current!==null&&clearTimeout(d.current),c.current!==null&&clearTimeout(c.current),d.current=null,c.current=null},[]),f=l.useCallback(()=>{u(),r(b=>b==="in"&&i?"out":!1)},[i,u]),p=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{if(c.current=null,gd(a.current)){p();return}f()},Ov)},[f]),h=l.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]);l.useEffect(()=>{t||(u(),r(!1))},[u,t]),l.useEffect(()=>u,[u]),l.useEffect(()=>{if(s!=="in")return;const b=S=>{const m=S.target;m instanceof Element&&(a.current?.contains(m)||Jp(m)||f())},x=S=>{Nl(S)||S.key!=="Escape"||S.defaultPrevented||gd(a.current)||f()},y=S=>{S.relatedTarget===null&&p()};return document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",x),document.addEventListener("pointerout",y),()=>{document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",x),document.removeEventListener("pointerout",y)}},[f,p,s]),l.useEffect(()=>{if(!t||s!==!1)return;const b=()=>{d.current!==null&&clearTimeout(d.current),d.current=null},x=S=>{if(S.pointerType!=="mouse"||S.buttons!==0||!Fv(S)){b();return}d.current===null&&(d.current=setTimeout(()=>{d.current=null,r("in")},Mv))},y=S=>{S.relatedTarget===null&&b()};return document.addEventListener("pointermove",x,{passive:!0}),document.addEventListener("pointerout",y),()=>{document.removeEventListener("pointermove",x),document.removeEventListener("pointerout",y),b()}},[t,s]);const g=l.useMemo(()=>({onPointerEnter:()=>{h(),r(b=>b==="out"?"in":b)},onPointerLeave:()=>{s==="in"&&p()},onAnimationEnd:b=>{b.target===b.currentTarget&&r(x=>x==="out"?!1:x)}}),[h,p,s]);return{state:t?s:!1,animationMs:o,overlayRef:a,overlayHandlers:g}},io="app-region-no-drag inline-flex h-6 w-6 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",Lv=()=>{const t=Ze.c(45),{t:e,locale:s,direction:r}=Et(),o=le($v),i=le(zv),a=le(Kv),d=l.useRef(null),c=Hf(Uf("toggle_sidebar",a)),u=Wv,{usesFramelessChrome:f,side:p}=Fp();let h;t[0]!==s?(h=E=>{const D=E.currentTarget.getBoundingClientRect();vn("desktop_show_app_menu",{x:D.left,y:D.bottom,locale:s}).catch(Hv)},t[0]=s,t[1]=h):h=t[1];const g=h;let b,x;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const E=d.current;if(!E)return;const D=()=>{const N=Math.max(E.getBoundingClientRect().width,E.scrollWidth);Tv(N)};if(D(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(D);return C.observe(E),()=>{C.disconnect()}},x=[],t[2]=b,t[3]=x):(b=t[2],x=t[3]),l.useEffect(b,x);const y="app-region-no-drag absolute inset-s-0 top-0 z-30 flex select-none items-center pe-2",S=i?"var(--oc-left-sidebar-width, 100%)":void 0;let m;t[4]!==S?(m={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=m):m=t[5];const v="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==p?(w=f&&p===qu(r)?n.jsx(_p,{visible:!0,position:p}):null,t[6]=r,t[7]=f,t[8]=p,t[9]=w):w=t[9];let T;t[10]!==g||t[11]!==e||t[12]!==f?(T=f?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(io,"shrink-0"),children:n.jsx(Z,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Kt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=g,t[11]=e,t[12]=f,t[13]=T):T=t[13];const k=Ut;let I;t[14]!==e?(I=e("header.actions.openSessionsAria"),t[14]=e,t[15]=I):I=t[15];const B=i&&"text-foreground";let O;t[16]!==B?(O=Pe(io,"shrink-0",B),t[16]=B,t[17]=O):O=t[17];let F;t[18]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(Z,{name:"layout-left",className:"h-4 w-4"}),t[18]=F):F=t[18];let j;t[19]!==i||t[20]!==O||t[21]!==I||t[22]!==o?(j=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":I,"aria-pressed":i,className:O,children:F})}),t[19]=i,t[20]=O,t[21]=I,t[22]=o,t[23]=j):j=t[23];const P=Kt,L=e("header.actions.openSessionsWithShortcut",{shortcut:c});let z;t[24]!==L?(z=n.jsx("p",{children:L}),t[24]=L,t[25]=z):z=t[25];let H;t[26]!==P||t[27]!==z?(H=n.jsx(P,{children:z}),t[26]=P,t[27]=z,t[28]=H):H=t[28];let R;t[29]!==k||t[30]!==j||t[31]!==H?(R=n.jsxs(k,{children:[j,H]}),t[29]=k,t[30]=j,t[31]=H,t[32]=R):R=t[32];let G;t[33]!==u||t[34]!==i||t[35]!==e?(G=i?n.jsxs("button",{type:"button",onClick:u,className:Pe(io,"-ms-1 w-auto min-w-0 px-1.5 font-normal"),children:[n.jsx(Z,{name:"chat-new",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Pe(io,"-ms-1 shrink-0"),children:n.jsx(Z,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Kt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=i,t[35]=e,t[36]=G):G=t[36];let _;t[37]!==R||t[38]!==G||t[39]!==w||t[40]!==T?(_=n.jsxs("div",{ref:d,className:v,children:[w,T,R,G]}),t[37]=R,t[38]=G,t[39]=w,t[40]=T,t[41]=_):_=t[41];let $;return t[42]!==_||t[43]!==m?($=n.jsx("div",{className:y,style:m,children:_}),t[42]=_,t[43]=m,t[44]=$):$=t[44],$};function $v(t){return t.toggleSidebar}function zv(t){return t.isSidebarOpen}function Kv(t){return t.shortcutOverrides}function Wv(){le.getState().closeMainSurfaces(),mt.getState().openNewSessionDraft()}function Hv(t){console.warn("[titlebar] failed to open app menu",t)}function Uv(t,e,s){const r=Ze.c(5),[o,i]=l.useState();let a,d;return r[0]!==s||r[1]!==t||r[2]!==e?(a=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let c=!1;return(async()=>{const[u,f]=await Promise.all([cx(t),dx(t)]).catch(Vv);if(c)return;const p=yt(u),h=yt(f);if(!p||!h||h===p)return;const g=s||"",b=h.split("/").filter(Boolean).pop()||h;i({source:"sdk",path:h,projectDirectory:p,branch:g,label:g||b,name:b,worktreeRoot:h,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{c=!0}},d=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=a,r[4]=d):(a=r[3],d=r[4]),l.useEffect(a,d),e??o}function Vv(){return["",""]}const Gv=()=>{const t=Ze.c(3),e=le(qv),s=le(Yv);let r;return t[0]!==e||t[1]!==s?(r=()=>{s("integrations"),e(!0)},t[0]=e,t[1]=s,t[2]=r):r=t[2],r};function qv(t){return t.setSettingsDialogOpen}function Yv(t){return t.setSettingsPage}const bd="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Zv=({className:t,identity:e=Gf})=>{const{t:s}=Et(),{sourceControl:r}=Ks(),o=Vf(e),i=e.provider==="gitlab",a=i?"gitlab":"github-fill",d=o?.status??null,c=kn(S=>S.setStatus),[u,f]=l.useState(!1),p=l.useCallback(async S=>{if(!(!S||u)){f(!0);try{c(e,await r.authActivate(e,S))}catch(m){console.error("Failed to switch source control account:",m)}finally{f(!1)}}},[e,u,c,r]);if(d?.status!=="connected")return null;const h=d.user.username||null,g=d.user.avatarUrl??null,b=d.accounts,x=i?h?s("header.gitlab.connectedWithLogin",{login:h}):s("header.gitlab.connected"):h?s("header.github.connectedWithLogin",{login:h}):s("header.github.connected"),y=g?n.jsx("img",{src:g,alt:h?s("header.github.avatarWithLogin",{login:h}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Z,{name:a,className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?n.jsx("div",{className:Pe(bd,t),title:x,children:y}):n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe(bd,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:x,disabled:u,children:y})}),n.jsxs(Ms,{align:"end",className:"w-64",children:[n.jsx(Ma,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(In,{}),b.map(S=>{const m=S.user,v=!!S.current,w=s(ux(S.source??"oauth"));return n.jsxs(rs,{className:"gap-2",disabled:u,onSelect:()=>{v||p(S.id)},children:[m?.avatarUrl?n.jsx("img",{src:m.avatarUrl,alt:m.username?s("header.github.avatarWithLogin",{login:m.username}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:n.jsx(Z,{name:a,className:"h-3 w-3 text-muted-foreground"})}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:m?.name?.trim()||m.username||(i?"GitLab":"GitHub")}),m.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:m.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),v?n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}):null]},S.id)})]})]})},Qv=t=>JSON.stringify(fx(t)),Xv=async(t,e)=>{const s=await t.projectUpstream(e);if(!s?.isFork||!s.upstream)return{upstream:null,branches:[]};const r=await t.projectBranches(e,s.upstream.owner,s.upstream.name);return{upstream:s.upstream,branches:r}},eh=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function Jv(t){if(!eh(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function e0(t,e,s){const r=Ze.c(16),{sourceControl:o}=Ks(),[i,a]=us.useState(null);let d;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(d=JSON.stringify([t.provider,t.repositoryId,t.bindingRevision,e]),r[0]=t.bindingRevision,r[1]=t.provider,r[2]=t.repositoryId,r[3]=e,r[4]=d):d=r[4];const c=d;let u;r[5]!==t||r[6]!==c||r[7]!==e||r[8]!==o?(u=()=>{if(t.provider!=="github")return;let p=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(h=>{if(p||!h.connected)return;const g=h.items.find(b=>b.kind==="pull"&&b.number===e);g&&a({key:c,pull:g})}).catch(t0),()=>{p=!0}},r[5]=t,r[6]=c,r[7]=e,r[8]=o,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==c||r[12]!==e||r[13]!==s||r[14]!==o?(f=[t,c,e,s,o],r[10]=t,r[11]=c,r[12]=e,r[13]=s,r[14]=o,r[15]=f):f=r[15],us.useEffect(u,f),i?.key===c?i.pull:null}function t0(){}const s0=t=>{const e=Ze.c(60),{directory:s,context:r,changeRequest:o,onChanged:i}=t,a=Nn(),d=ns(n0),[c,u]=us.useState(0),[f,p]=us.useState(!1),h=Ml(),g=e0(r,o.number,c);let b;e[0]!==o?(b=px(o),e[0]=o,e[1]=b):b=e[1];const x=b;let y;e[2]!==g||e[3]!==x?(y=g?{...x,labels:g.labels,commentCount:g.commentCount}:x,e[2]=g,e[3]=x,e[4]=y):y=e[4];const S=y,{detail:m,refresh:v}=qf(s,S,!0),w=df(S);let T;e[5]!==i||e[6]!==v?(T=()=>{v(),u(r0),i()},e[5]=i,e[6]=v,e[7]=T):T=e[7];const k=T,I=uf(S,r,k);let B;e[8]!==S?(B={source:"github",reference:S},e[8]=S,e[9]=B):B=e[9];const O=B,F=a??s;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j={status:"idle"},e[10]=j):j=e[10];let P;e[11]!==r||e[12]!==O||e[13]!==k?(P=n.jsx(vl,{item:O,project:null,context:r,onStartWorktree:i0,onChanged:k,worktreeAvailable:!1}),e[11]=r,e[12]=O,e[13]=k,e[14]=P):P=e[14];let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=()=>p(!0),e[15]=L):L=e[15];let z;e[16]!==w.attachComment||e[17]!==w.attachComments?(z={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=z):z=e[18];let H;e[19]!==r||e[20]!==S||e[21]!==k?(H=n.jsx(hf,{reference:S,context:r,onChanged:k}),e[19]=r,e[20]=S,e[21]=k,e[22]=H):H=e[22];let R;e[23]!==r||e[24]!==m||e[25]!==S||e[26]!==k?(R=n.jsx(mf,{pull:S,detail:m,context:r,onChanged:k}),e[23]=r,e[24]=m,e[25]=S,e[26]=k,e[27]=R):R=e[27];let G;e[28]!==r||e[29]!==S||e[30]!==k?(G=n.jsx(ff,{reference:S,context:r,onRefresh:k},S.number),e[28]=r,e[29]=S,e[30]=k,e[31]=G):G=e[31];const _=d??"";let $;e[32]!==F||e[33]!==_?($={id:_,path:F},e[32]=F,e[33]=_,e[34]=$):$=e[34];let E;e[35]!==r||e[36]!==F||e[37]!==S||e[38]!==$?(E=n.jsx(gf,{pull:S,project:$,repository:null,context:r,projectOwnsDirectory:a0,currentDirectory:F}),e[35]=r,e[36]=F,e[37]=S,e[38]=$,e[39]=E):E=e[39];let D;e[40]!==m||e[41]!==s||e[42]!==O||e[43]!==h||e[44]!==R||e[45]!==G||e[46]!==E||e[47]!==P||e[48]!==z||e[49]!==H||e[50]!==I?(D=n.jsx(Al,{item:O,directory:s,pullStatus:Ol,linearDetail:j,githubDetail:m,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:o0,now:h,footer:P,onOpenChecks:L,commentAttachments:z,threadActions:I,labelsControl:H,reviewersControl:R,reply:G,pullLinks:E}),e[40]=m,e[41]=s,e[42]=O,e[43]=h,e[44]=R,e[45]=G,e[46]=E,e[47]=P,e[48]=z,e[49]=H,e[50]=I,e[51]=D):D=e[51];let C;e[52]!==w.attachFailedChecks||e[53]!==f||e[54]!==r||e[55]!==S?(C=n.jsx(pf,{pull:S,context:r,open:f,onOpenChange:p,onAttachFailed:w.attachFailedChecks}),e[52]=w.attachFailedChecks,e[53]=f,e[54]=r,e[55]=S,e[56]=C):C=e[56];let N;return e[57]!==D||e[58]!==C?(N=n.jsxs(n.Fragment,{children:[D,C]}),e[57]=D,e[58]=C,e[59]=N):N=e[59],N};function n0(t){return t.activeProjectId}function r0(t){return t+1}function o0(){}function i0(){}function a0(){return!0}function l0(t,e){const{git:s,sourceControl:r}=Ks(),{t:o}=Et(),i=Pb(),a=Eb({directory:t,branch:e,chooseContributor:i.choose}),d=Tb(t,s,r),c=async()=>{const f=d.start();if(!f)return He.info(o("gitView.pr.toast.gitBusy")),!1;const p=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await a.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(h){if(h instanceof hx){if(h.code==="stale-runtime")return!1;const g=a.errorMessage(h);return g?He.info(g):He.error(p),!1}return h instanceof mx||h instanceof gx?(He.error(p,{description:h.message||void 0}),!1):(He.error(p,{description:h instanceof Error?h.message:String(h)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[a.context?n.jsx(Db,{context:a.context,onSelect:a.settle}):null,a.confirmDialog,n.jsx(Rb,{candidates:i.candidates,onSelect:i.settle})]});return{push:c,dialogs:u}}const c0=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"}},d0=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=mt.getState(),o=s?r(s):null;!s||!o||yt(o)!==yt(t)||Ix(s,o,Px({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},u0=t=>{const e=t?.changeRequest??t?.pr;return e?Ex({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},f0=[2e3,5e3];let yd=0;const p0=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(yd+=1,`source-control-${Date.now().toString(36)}-${yd.toString(36)}`)},h0=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),th="openchamber:pr-create-as-draft:v1",xd=()=>{try{return localStorage.getItem(th)==="true"}catch{return!1}},m0=t=>{try{localStorage.setItem(th,String(t))}catch{}},oa=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),Sn=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):""},g0=(t,e)=>{const s=Sn(t);if(!s||s.includes("->"))return"";if(e){const o=`${e}/`;return s.startsWith(o)?s.slice(o.length).trim():""}const r=s.indexOf("/");return r>0?s.slice(r+1).trim():s},b0=(t,e)=>`${t}::${e}`,ia=new Map,Sd=xr;function y0(t,e,s){const r=Ze.c(14);let o;r[0]!==s?(o=s?Qv(s):null,r[0]=s,r[1]=o):o=r[1];const i=o;let a;r[2]===Symbol.for("react.memo_cache_sentinel")?(a={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=a):a=r[2];const[d,c]=l.useState(a);let u,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!i)return;let h=!1;return(async()=>{try{const g=await Xv(e,s);h||c({contextKey:i,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{h=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),l.useEffect(u,f);let p;return r[9]!==i||r[10]!==d.contextKey||r[11]!==d.detectedUpstream||r[12]!==d.upstreamBranches?(p=d.contextKey===i?{detectedUpstream:d.detectedUpstream,upstreamBranches:d.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=d.contextKey,r[11]=d.detectedUpstream,r[12]=d.upstreamBranches,r[13]=p):p=r[13],p}const x0=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:a})=>{const{t:d}=Et(),c=Yf(t),u=l.useCallback((Qe,vt)=>d(pn(Qe,c?.provider),vt),[c?.provider,d]),f=Gv(),{sourceControl:p}=Ks(),h=kn(Qe=>Qe.entries),{isMobile:g,hasTouchInput:b,screenWidth:x}=Rn(),y=le(Qe=>Qe.openContextSurface),S=bx(Qe=>Qe.requestTarget),m=!g&&x>=768&&!Dn(),v=l.useMemo(()=>b0(t,e),[t,e]),w=l.useMemo(()=>ia.get(v)??null,[v]),T=ys(Qe=>Qe.ensureEntry),k=ys(Qe=>Qe.setParams),I=ys(Qe=>Qe.beginActiveContextsLoad),B=ys(Qe=>Qe.commitActiveContexts),O=ys(Qe=>Qe.releaseActiveContexts),F=l.useId(),j=ys(Qe=>Qe.startWatching),P=ys(Qe=>Qe.stopWatching),L=ys(Qe=>Qe.refresh),[z,H]=l.useState(()=>w?.title??oa(e)),[R,G]=l.useState(()=>w?.body??""),[_,$]=l.useState(()=>w?.draft??xd()),[E,D]=l.useState(()=>w?.additionalContext??""),[C,N]=l.useState(()=>{const Qe=typeof w?.targetBaseBranch=="string"?Sn(w.targetBaseBranch):"";return Qe||Sn(s)}),[A,q]=l.useState(!1),[ee,Q]=l.useState(!1),[he,M]=l.useState(!1),V=Zf(t,p),ie=V.scope.runtimeKey;l.useEffect(()=>{if(!t)return;const Qe=V.scope.runtimeKey,vt=I(Qe,t,F),$t=V.contexts.filter(ve=>Aa(h[er(ve)],ve).connected);return B(Qe,t,F,vt,$t),()=>{O(Qe,t,F)}},[I,V.contexts,V.scope.runtimeKey,B,t,O,h,F]);const ne=V.contexts[0]??null,je=kn(Qe=>c?Qe.entries[er(c)]?.hasChecked===!0:!1),Ee=ne?.primaryRemote??null,we=l.useMemo(()=>ne?er(ne):"",[ne]),Me=kn(Qe=>Qe.entries[we]),fe=ne?Aa(Me,ne):{authChecked:Me?.hasChecked??!1,connected:!1},be=fe.authChecked,[ke,Ie]=l.useState(0),[Te,Y]=l.useState({key:"",status:"loading",capabilities:null}),[ue,me]=l.useState(!1),{detectedUpstream:re,upstreamBranches:pe}=y0(t,p,ne);l.useEffect(()=>{if(!ne)return;let Qe=!1;const vt=er(ne);return Y({key:vt,status:"loading",capabilities:null}),p.capabilities(ne).then($t=>{Qe||Y({key:vt,status:"ready",capabilities:$t})}).catch(()=>{Qe||Y({key:vt,status:"error",capabilities:null})}),()=>{Qe=!0}},[ke,ne,p]);const U=Te.key===we?Te:null,ae=U?.status==="ready"?U.capabilities:null;l.useEffect(()=>{me(!1)},[t]);const W=!!(t&&e&&s&&(e!==s||re!==null)),ye=l.useMemo(()=>ne?Qf(ne,e):"",[e,ne]),de=l.useRef(ye);de.current=ye;const Ne=l.useCallback((Qe,vt)=>Qe===Jt()&&vt===de.current,[]),Je=ys(Qe=>Qe.entries[ye]),Ge=l.useMemo(()=>ye?[ye]:[],[ye]);Xf(Jf(Ge));const ge=Je?.isLoading??!1,Ae=fe.connected?Je?.status??null:null,Ye=V.error?u("settings.gitlab.status.operationFailed"):Je?.error??null,nt=Je?.isInitialStatusResolved??!1,oe=l.useMemo(()=>{const Qe=ue?null:Ee,vt=new Set;for(const ct of i){const ht=g0(ct,Qe);!ht||ht==="HEAD"||vt.add(ht)}if(ue)for(const ct of pe)ct&&ct!=="HEAD"&&vt.add(ct);const $t=Sn(s);$t&&$t!=="HEAD"&&vt.add($t);const ve=Sn(C);return ve&&ve!=="HEAD"&&vt.add(ve),Array.from(vt).sort((ct,ht)=>ct.localeCompare(ht))},[s,i,Ee,C,pe,ue]);l.useEffect(()=>{const Qe=Sn(s);if(!C&&Qe){N(Qe);return}if(oe.length!==0&&!oe.includes(C)){const vt=oe.includes(Qe)?Qe:oe[0];vt&&N(vt)}},[oe,s,C]);const tt=l.useRef([]),Ue=l.useRef(new Map),gt=l.useCallback(Qe=>{const vt=Ue.current.get(Qe);if(vt?.inFlight)return null;if(vt)return vt.inFlight=!0,vt.key;const $t=p0();return Ue.current.set(Qe,{key:$t,inFlight:!0}),$t},[]),bt=l.useCallback((Qe,vt,$t)=>{const ve=Ue.current.get(Qe);!ve||ve.key!==vt||($t?ve.inFlight=!1:Ue.current.delete(Qe))},[]);l.useEffect(()=>{re&&me(!0)},[re]),l.useEffect(()=>{ue&&re?.defaultBranch&&N(re.defaultBranch)},[ue,re?.defaultBranch]);const Ce=Ae?.changeRequest??Ae?.pr??null,_e=Ae?.identity??ne,ze=l.useMemo(()=>Ae?.project??(Ae?.repo&&_e?{...Ae.repo,..._e,id:`${Ae.repo.owner}/${Ae.repo.repo}`,name:Ae.repo.repo}:null),[Ae?.project,Ae?.repo,_e]),Oe=Ce?.state==="merged"||Ce?.state==="closed",it=Oe?null:Ce,X=Ae?.ci?.summary??Ae?.checks??null,[Be,Le]=l.useState(!1),at=l.useRef(!0);l.useEffect(()=>(at.current=!0,()=>{at.current=!1}),[]);const qe=l.useCallback(async Qe=>{await L(ye,Qe)},[ye,L]),ut=l.useCallback((Qe,vt)=>{tt.current.forEach($t=>{window.clearTimeout($t)}),tt.current=f0.map($t=>window.setTimeout(()=>{Ne(Qe,vt)&&L(vt,{force:!0,silent:!0,markInitialResolved:!0})},$t))},[Ne,L]),dt=l.useCallback(async(Qe,vt,$t)=>{await Jv({error:Qe,isCurrent:()=>Ne(vt,$t),refresh:()=>L($t,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>ut(vt,$t)})},[Ne,L,ut]);l.useEffect(()=>{!ne||!ye||(T(ye),k(ye,{directory:t,branch:e,remoteName:ne.primaryRemote,canShow:W,identity:ne,readContext:ne,sourceControl:p,authChecked:fe.authChecked,connected:fe.connected}))},[e,W,t,T,ye,ne,p,fe.authChecked,fe.connected,k]);const ft=600,st=l.useCallback(async()=>{if(Be)return;Le(!0);const Qe=Date.now();try{await qe({force:!0})}finally{const vt=ft-(Date.now()-Qe);vt>0&&await new Promise($t=>window.setTimeout($t,vt)),at.current&&Le(!1)}},[Be,qe]);l.useEffect(()=>{if(!(!ne||!ye))return j(ye),()=>{P(ye)}},[ye,ne,j,P]),l.useEffect(()=>{const Qe=ia.get(v)??null;H(Qe?.title??oa(e)),G(Qe?.body??""),$(Qe?.draft??xd()),N(Qe?.targetBaseBranch?Sn(Qe.targetBaseBranch):Sn(s))},[s,e,v]),l.useEffect(()=>{!ne||!ye||!fe.connected||qe({markInitialResolved:!0})},[ye,ne,qe,fe.connected]),l.useEffect(()=>{!W||!ne||!fe.connected||qe({force:!0,silent:!0,markInitialResolved:!0})},[W,ne,qe,fe.connected]),l.useEffect(()=>{const Qe=()=>{const $t=ys.getState().entries[ye]?.lastRefreshAt??0;Date.now()-$t>6e4&&qe({force:!0,silent:!0})},vt=()=>{document.visibilityState==="visible"&&Qe()};return window.addEventListener("focus",Qe),document.addEventListener("visibilitychange",vt),()=>{window.removeEventListener("focus",Qe),document.removeEventListener("visibilitychange",vt)}},[ye,qe]),l.useEffect(()=>{be&&!fe.connected&&qe({force:!0,silent:!0,markInitialResolved:!0})},[qe,fe.connected,be]),l.useEffect(()=>{!t||!e||ia.set(v,{title:z,body:R,draft:_,additionalContext:E,targetBaseBranch:C})},[v,z,R,_,E,C,t,e]),l.useEffect(()=>()=>{tt.current.forEach(Qe=>{window.clearTimeout(Qe)}),tt.current=[]},[ye,ie]),l.useEffect(()=>()=>{Ue.current.clear()},[]);const Rt=ue&&re?.defaultBranchSha?re.defaultBranchSha:ne?`${ne.primaryRemote}/${C}`:C;l.useEffect(()=>{if(!t||!e||!Rt)return;let Qe=!1;return yx(t,{from:Rt,to:e,maxCount:2}).then(vt=>{const $t=vt.all.length===1?vt.all[0]?.message.trim():"";Qe||!$t||H(ve=>ve===oa(e)?$t:ve)}).catch(()=>{}),()=>{Qe=!0}},[e,Rt,t]);const Ke=!r||o>0,jt=l0(t,e),Lt=l.useId(),Mt=Qe=>{$(Qe),m0(Qe)},De=l.useCallback(async()=>{if(!A&&t){q(!0);try{const vt={base:Rt,head:e,...ne?.provider?{changeRequestProvider:ne.provider}:{}};E&&(vt.context=E);const $t=await xx(t,vt);$t.title?.trim()&&H($t.title.trim()),$t.body?.trim()&&G($t.body.trim()),a?.()}catch(Qe){const vt=Qe instanceof Error?Qe.message:String(Qe);He.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:vt})}finally{q(!1)}}},[E,e,Rt,t,A,a,ne,u]),Tt=l.useCallback(async()=>{if(ae?.changeRequests!==!0){He.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const Qe=z.trim();if(!Qe){He.error(u("gitView.pr.toast.titleRequired"));return}const vt=C.trim();if(!vt){He.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!ue&&vt===e){He.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const $t=ue?re:ze;if(!ne||!$t){He.error(u("gitView.pr.toast.createPrFailed"),{description:Ye??u("gitView.pr.statusUnavailable")});return}if(Ke&&(Q(!0),!await jt.push())){Q(!1);return}const ve=Jt(),ct=ye,ht={owner:$t.owner,name:$t.name},Ot=R.trim()?R:void 0,te=ue?void 0:ne.primaryRemote,et=ue?ne.primaryRemote:void 0,xt=h0(ve,ne,[ht.owner,ht.name,e,vt,Qe,Ot,_,te,et]),It=gt(xt);if(!It){Q(!1);return}Q(!0);let St=!1,Se=!1;try{const We={...ne,idempotencyKey:It,target:{project:ht,head:e,base:vt},title:Qe,draft:_};Ot!==void 0&&(We.body=Ot),te&&(We.remote=te),et&&(We.headRemote=et);const K=await p.changeRequestCreate(We);if(Se=!0,bt(xt,It,!1),!Ne(ve,ct)||(He.success(u("gitView.pr.toast.prCreated")),await qe({force:!0}),!Ne(ve,ct)))return;const xe=ys.getState().entries[ct]?.status,Xe=xe?.changeRequest??xe?.pr;Xe&&Xe.number===K.target.number&&d0(t,Xe),ut(ve,ct)}catch(We){const K=We instanceof Error?We:new Error(String(We));St=eh(K);const xe=K.message;He.error(u("gitView.pr.toast.createPrFailed"),{description:xe}),St&&await dt(K,ve,ct)}finally{Se||bt(xt,It,St),Q(!1)}},[gt,R,e,jt,re,t,_,Ye,bt,Ne,Ke,ye,ne,dt,qe,ut,p,ae?.changeRequests,ze,C,z,ue,u]),At="border-0 bg-transparent rounded-none px-4 py-3";if(!W)return n.jsx("section",{className:At,children:n.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[n.jsx("div",{className:"min-w-0 typography-meta text-muted-foreground",children:u("gitView.pullRequest.availableOnFeatureBranches")}),n.jsx(Zv,{identity:c??void 0})]})});const kt=Ae?.changeRequest&&Ae.changeRequest.state==="open"?Ae.changeRequest:it&&ze&&_e?{..._e,id:`${ze.owner}/${ze.name}#${it.number}`,number:it.number,project:{..._e,id:ze.id,owner:ze.owner,name:ze.name,url:ze.url??""},title:it.title,body:it.body,url:it.url,state:it.state,draft:it.draft,base:it.base,head:it.head,headSha:it.headSha,mergeable:it.mergeable,mergeableState:it.mergeableState}:null;if(kt&&ne)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(s0,{directory:t,context:ne,changeRequest:kt,onChanged:()=>{qe({force:!0,silent:!0,markInitialResolved:!0})}})});const pt=ze?.url||null,Dt=ue&&re?.url?re.url:pt,Ve=U?.status==="error",rt=!!Ae?.connected,wt=!!(!ne&&c&&V.status==="ready"&&je),se=!!(_e&&be&&Ae?.connected===!1)||wt,Fe=_e??c,ot=Fe?Sx(Fe.provider):null,$e=u0(Ae),Ct=$e?`var(--pr-${$e})`:"var(--status-info)",Yt=$e==="draft"?"git-pr-draft":$e==="merged"?"git-merge":$e==="closed"?"git-close-pull-request":"git-pull-request",es=Ce?[`${Ce.state}${Ce.draft?" (draft)":""}`,Ce.state==="open"&&Ce.mergeable===!1?u("gitView.pr.notMergeable"):null,Ce.state==="open"&&typeof Ce.mergeableState=="string"&&Ce.mergeableState&&Ce.mergeableState!=="unknown"?Ce.mergeableState:null].filter(Boolean).join(" · "):"",Zt=X?X.total>0?`${X.success}/${X.total} ${u("gitView.pr.checks.label")}`:`${X.state} ${u("gitView.pr.checks.label")}`:"",ss="px-0 py-3 border-b border-border/40 flex flex-col gap-1",bs="flex flex-col gap-3 py-3",ls=n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:ge||Be,onClick:()=>{st()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Z,{name:ge||Be?"loader-4":"refresh",className:Pe("size-4 text-muted-foreground",(ge||Be)&&"animate-spin")})})}),n.jsx(Kt,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),ms=he||E.trim().length>0,fs=Ke?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,Es=u(Ke?_?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":_?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),cs=ee||!rt||ae?.changeRequests!==!0||!C.trim()||!ue&&C.trim()===e;return n.jsxs("section",{className:At,children:[Ce?n.jsxs("div",{className:ss,children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsxs(Nt,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Sd(Ce.url)},"aria-label":ot?u("gitView.pr.actions.openOnProviderAria",{provider:ot}):u("gitView.header.openPullRequest"),children:[n.jsx(Z,{name:Yt,className:"size-4 shrink-0",style:{color:Ct}}),ot?u("gitView.pr.actions.openOnProvider",{provider:ot}):u("gitView.header.openPullRequest")]}),n.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:u("gitView.pullRequest.title")}),n.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:Bl(_e?.provider,Ce.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:ls})]}),n.jsxs("div",{className:"@container/pr-actions flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[n.jsx("span",{style:{color:Ct},children:es}),X?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${c0(X.state)}`}),Zt]}):null,r&&Ee&&r.split("/")[0]!==Ee?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",Ee]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:m&&(ne?.provider==="github"||ne?.provider==="gitlab")?n.jsxs(Nt,{variant:"outline",size:"sm",className:Pe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Nb),onClick:()=>{S(t,{source:{kind:"pr",number:Ce.number,...ze?{sourceRepo:{owner:ze.owner,repo:ze.name}}:{}},context:ne}),y(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx(Z,{name:"route",className:"size-4"}),n.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}):null})]})]}):null,n.jsxs("div",{className:bs,children:[Ve?n.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[n.jsx("div",{className:"typography-ui-label text-[var(--status-error)]",children:u("gitView.pr.capabilitiesUnavailable")}),n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>Ie(Qe=>Qe+1),children:u("settings.sourceControl.transport.retry")})]}):null,se&&ot?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:ot})}),n.jsx(Nt,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,Ye?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-ui-label text-foreground",children:u("gitView.pr.statusUnavailable")}),n.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:Ye}),V.error?n.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>{V.retry()},disabled:V.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,Dt?n.jsx(Nt,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:Dt,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Z,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(it||!Ce&&!nt)&&!Ye&&!se&&(V.status==="loading"||ne)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Fo,{className:"size-4"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Ce&&Oe?n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md oc-tile-inset px-2.5 py-2",children:[n.jsx(Z,{name:Ce.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ct}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ce.state==="merged"?u("gitView.pr.history.merged",{number:Ce.number,base:Ce.base||C}):u("gitView.pr.history.closed",{number:Ce.number})}),n.jsx(Nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Sd(Ce.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:ot}),children:n.jsx(Z,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(Z,{name:"git-pull-request",className:"size-4 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",title:e,children:e}),n.jsx(Z,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),ue&&re?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[re.owner,"/",re.name]}):null,oe.length>0?n.jsxs(wx,{value:C,onValueChange:N,children:[n.jsx(vx,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(jx,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(kx,{children:oe.map(Qe=>n.jsx(Cx,{value:Qe,children:Qe},Qe))})]}):n.jsx(_o,{value:C,onChange:Qe=>N(Qe.target.value),placeholder:u("gitView.pr.placeholder.main"),"aria-label":u("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-0.5",children:[Dt?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:Dt,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx(Z,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Kt,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,ls]})]}),n.jsxs("label",{className:"space-y-1",children:[n.jsx("div",{className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.title")}),n.jsx(_o,{value:z,onChange:Qe=>H(Qe.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:Lt,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Nt,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:De,disabled:A||ee,children:[A?n.jsx(Z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(Z,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:A||ee,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Ms,{align:"end",className:"w-60",children:n.jsxs(rs,{onSelect:()=>M(!0),children:[n.jsx(Z,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),ms?n.jsxs("div",{className:"relative",children:[n.jsx(Vc,{value:E,onChange:Qe=>D(Qe.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:he&&!E}),n.jsx(Nt,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{D(""),M(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Z,{name:"close",className:"size-3.5"})})]}):null,n.jsx(Vc,{id:Lt,value:R,onChange:Qe=>G(Qe.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),fs?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx(Z,{name:"arrow-up",className:"size-3.5 shrink-0"}),fs]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Nt,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:Tt,disabled:cs,children:[ee?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Z,{name:_?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Es})]}),n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:ee,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Ms,{align:"end",className:"w-56",children:n.jsxs(ep,{value:_?"draft":"ready",onValueChange:Qe=>Mt(Qe==="draft"),children:[n.jsx(Lo,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(Lo,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),jt.dialogs]})]})]})},S0=()=>{const t=Ze.c(94),{t:e}=Et(),{git:s,sourceControl:r}=Ks(),o=Nn(),{rootIsGitRepo:i,gitDirectory:a,nestedRepos:d,repositoryOptions:c}=Tx(o??null),u=hi(a??null),f=Dx(a??null),p=Rx(a??null),h=Zf(a,r),{ensureAll:g,ensureNestedRepos:b,selectNestedRepo:x}=Cn(hr(w0)),y=mt(v0),S=mt(j0),m=mt(k0),v=mt(C0);let w;t[0]!==o?(w=yt(o),t[0]=o,t[1]=w):w=t[1];const T=w;let k;e:{if(!T){k=void 0;break e}let be;t[2]!==v||t[3]!==T||t[4]!==m?(be=Lr(v,T)??Lr(m.values(),T),t[2]=v,t[3]=T,t[4]=m,t[5]=be):be=t[5],k=be}const I=k;let B;t[6]!==y||t[7]!==I||t[8]!==S?.open||t[9]!==m?(B=()=>{if(y)return m.get(y)??I;if(S?.open)return I},t[6]=y,t[7]=I,t[8]=S?.open,t[9]=m,t[10]=B):B=t[10],S?.open;let O;t[11]!==B?(O=B(),t[11]=B,t[12]=O):O=t[12];const F=O;let j;t[13]!==y?(j=be=>y?be.getAttachment(y):void 0,t[13]=y,t[14]=j):j=t[14];const P=Af(j),L=P&&!P.degraded&&!P.legacy?P.worktreeRoot??void 0:void 0,z=Uv(o,F,u?.current??void 0);let H,R;t[15]!==g||t[16]!==s||t[17]!==a?(H=()=>{!a||!s||g(a,s)},R=[a,g,s],t[15]=g,t[16]=s,t[17]=a,t[18]=H,t[19]=R):(H=t[18],R=t[19]),l.useEffect(H,R);const[G,_]=l.useState(null);let $;t[20]!==L||t[21]!==z?.projectDirectory?($=()=>{const be=L||z?.projectDirectory;if(!be){_(null);return}let ke=!1;return tp(be).then(Ie=>{if(ke)return;const Te=Ie.trim();_(Te&&Te!=="HEAD"?Te:null)}).catch(()=>{ke||_(null)}),()=>{ke=!0}},t[20]=L,t[21]=z?.projectDirectory,t[22]=$):$=t[22];const E=z?.projectDirectory;let D;t[23]!==L||t[24]!==E?(D=[L,E],t[23]=L,t[24]=E,t[25]=D):D=t[25],l.useEffect($,D);let C;e:{if(!f?.all){let ke;t[26]===Symbol.for("react.memo_cache_sentinel")?(ke=[],t[26]=ke):ke=t[26],C=ke;break e}let be;t[27]!==f.all?(be=f.all.filter(I0).sort(),t[27]=f.all,t[28]=be):be=t[28],C=be}const N=C;let A;e:{if(!f?.all){let ke;t[29]===Symbol.for("react.memo_cache_sentinel")?(ke=[],t[29]=ke):ke=t[29],A=ke;break e}let be;t[30]!==f.all?(be=f.all.filter(P0).map(E0).sort(),t[30]=f.all,t[31]=be):be=t[31],A=be}const q=A,ee=u?.current??null,Q=h.contexts[0]?.primaryRemote,he=Q?f?.defaultBranches?.[Q]:void 0;let M;t[32]!==h.contexts[0]||t[33]!==h.read?.repository.remotes||t[34]!==ee||t[35]!==he||t[36]!==N||t[37]!==G||t[38]!==z?.createdFromBranch?(M=()=>Mb({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(T0)??[]),localBranches:N,worktreeCreatedFromBranch:z?.createdFromBranch,rootBranchHint:G,defaultBranch:he,headBranch:ee,fallbackToConventional:!1}),t[32]=h.contexts[0],t[33]=h.read?.repository.remotes,t[34]=ee,t[35]=he,t[36]=N,t[37]=G,t[38]=z?.createdFromBranch,t[39]=M):M=t[39],z?.createdFromBranch;let V;t[40]!==M?(V=M(),t[40]=M,t[41]=V):V=t[41];const ie=V,ce=Yf(o??null)?.provider;if(!o){let be;t[42]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[42]=be):be=t[42];let ke;t[43]!==ce||t[44]!==e?(ke=e(pn("gitView.pullRequest.title",ce)),t[43]=ce,t[44]=e,t[45]=ke):ke=t[45];let Ie;t[46]!==ke?(Ie=n.jsx("div",{className:"typography-ui-header text-foreground",children:ke}),t[46]=ke,t[47]=Ie):Ie=t[47];let Te;t[48]!==ce||t[49]!==e?(Te=e(pn("gitView.pullRequest.createHint",ce)),t[48]=ce,t[49]=e,t[50]=Te):Te=t[50];let Y;t[51]!==Te?(Y=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[51]=Te,t[52]=Y):Y=t[52];let ue;return t[53]!==Ie||t[54]!==Y?(ue=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ie,Y]}),t[53]=Ie,t[54]=Y,t[55]=ue):ue=t[55],ue}if(i===!1&&p!==!0){let be;t[56]!==o||t[57]!==b?(be=()=>{b(o,{force:!0})},t[56]=o,t[57]=b,t[58]=be):be=t[58];let ke;return t[59]!==o||t[60]!==p||t[61]!==d||t[62]!==i||t[63]!==be?(ke=n.jsx(Ab,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:p,nestedRepos:d,onRetryDiscovery:be}),t[59]=o,t[60]=p,t[61]=d,t[62]=i,t[63]=be,t[64]=ke):ke=t[64],ke}if(!ee){let be;t[65]===Symbol.for("react.memo_cache_sentinel")?(be=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[65]=be):be=t[65];let ke;t[66]!==ce||t[67]!==e?(ke=e(pn("gitView.pullRequest.title",ce)),t[66]=ce,t[67]=e,t[68]=ke):ke=t[68];let Ie;t[69]!==ke?(Ie=n.jsx("div",{className:"typography-ui-header text-foreground",children:ke}),t[69]=ke,t[70]=Ie):Ie=t[70];let Te;t[71]!==ce||t[72]!==e?(Te=e(pn("gitView.pullRequest.createHint",ce)),t[71]=ce,t[72]=e,t[73]=Te):Te=t[73];let Y;t[74]!==Te?(Y=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Te}),t[74]=Te,t[75]=Y):Y=t[75];let ue;return t[76]!==Ie||t[77]!==Y?(ue=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[be,Ie,Y]}),t[76]=Ie,t[77]=Y,t[78]=ue):ue=t[78],ue}let ne;t[79]!==o||t[80]!==a||t[81]!==c||t[82]!==x?(ne=c?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(Ob,{repositories:c,selectedRepository:a??null,onSelectRepository:be=>{o&&x(o,be)},repositoryRoot:o??void 0})}):null,t[79]=o,t[80]=a,t[81]=c,t[82]=x,t[83]=ne):ne=t[83];const je=a??o,Ee=u?.tracking??void 0,we=u?.ahead??0;let Me;t[84]!==ie||t[85]!==ee||t[86]!==q||t[87]!==je||t[88]!==Ee||t[89]!==we?(Me=n.jsx(Qr,{as:Nx,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(x0,{directory:je,branch:ee,baseBranch:ie,trackingBranch:Ee,ahead:we,remoteBranches:q})}),t[84]=ie,t[85]=ee,t[86]=q,t[87]=je,t[88]=Ee,t[89]=we,t[90]=Me):Me=t[90];let fe;return t[91]!==ne||t[92]!==Me?(fe=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ne,Me]}),t[91]=ne,t[92]=Me,t[93]=fe):fe=t[93],fe};function w0(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function v0(t){return t.currentSessionId}function j0(t){return t.newSessionDraft}function k0(t){return t.worktreeMetadata}function C0(t){return t.availableWorktrees}function I0(t){return!t.startsWith("remotes/")}function P0(t){return t.startsWith("remotes/")}function E0(t){return t.replace(/^remotes\//,"")}function T0(t){return t.name}const D0=t=>{const e=Ze.c(15);let s;e[0]!==t.url?(s=sp(t.url),e[0]=t.url,e[1]=s):s=e[1];const r=s;Bb(t.visible);const{panelDirectory:o,tabId:i,url:a}=t;let d;e[2]!==o||e[3]!==i||e[4]!==a?(d=()=>{$x(o,i)&&(xr(a),le.getState().closeContextPanelTab(o,i))},e[2]=o,e[3]=i,e[4]=a,e[5]=d):d=e[5];const c=d;let u;e[6]!==o||e[7]!==i?(u=()=>zx(o,i),e[6]=o,e[7]=i,e[8]=u):u=e[8];const f=u;let p;if(e[9]!==c||e[10]!==t||e[11]!==f||e[12]!==r||e[13]!==a){const h=r?r.source==="linear"?n.jsx(N0,{url:a,identifier:r.identifier,onUnavailable:c,onShown:f}):n.jsx(R0,{...t,kind:r.kind,onUnavailable:c,onShown:f}):n.jsx(Yl,{url:a});p=n.jsx("div",{className:"h-full min-h-0",children:h}),e[9]=c,e[10]=t,e[11]=f,e[12]=r,e[13]=a,e[14]=p}else p=e[14];return p},Ar=t=>{const e=Ze.c(8),{message:s,onRetry:r}=t,{t:o}=Et();let i;e[0]!==s?(i=n.jsx("span",{children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==r||e[3]!==o?(a=r?n.jsx(Nt,{size:"sm",variant:"outline",onClick:r,children:o("references.picker.actions.retry")}):null,e[2]=r,e[3]=o,e[4]=a):a=e[4];let d;return e[5]!==i||e[6]!==a?(d=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,a]}),e[5]=i,e[6]=a,e[7]=d):d=e[7],d},Yl=t=>{const e=Ze.c(14),{url:s}=t,{t:r}=Et();let o;e[0]!==r?(o=r("contextPanel.tracker.unavailable"),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=n.jsx("span",{children:o}),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==s?(a=()=>{xr(s)},e[4]=s,e[5]=a):a=e[5];let d;e[6]!==r?(d=r("contextPanel.preview.actions.openExternal"),e[6]=r,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==d?(c=n.jsx(Nt,{size:"sm",variant:"outline",onClick:a,children:d}),e[8]=a,e[9]=d,e[10]=c):c=e[10];let u;return e[11]!==i||e[12]!==c?(u=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center typography-meta text-muted-foreground",children:[i,c]}),e[11]=i,e[12]=c,e[13]=u):u=e[13],u},R0=t=>{const e=Ze.c(105),{url:s,directory:r,panelDirectory:o,foreign:i,kind:a,onUnavailable:d,onShown:c}=t,{t:u}=Et(),{sourceControl:f}=Ks(),p=ns(M0),h=_b(r,s),g=h.directory,b=h.status==="ready";let x;e[0]!==a||e[1]!==g||e[2]!==b||e[3]!==s?(x={enabled:b,directory:g,kind:a,filter:Kx,query:s},e[0]=a,e[1]=g,e[2]=b,e[3]=s,e[4]=x):x=e[4];const y=Bx(x);let S;e[5]!==y.items||e[6]!==s?(S=y.items.find(Y=>Fx(Y.url,s))??null,e[5]=y.items,e[6]=s,e[7]=S):S=e[7];const m=S,v=_x(g),w=v&&v!=="missing"?v:null,T=(y.status==="ready"||y.status==="unavailable")&&!y.refreshing&&!m;let k,I;e[8]!==d||e[9]!==T?(k=()=>{T&&d()},I=[d,T],e[8]=d,e[9]=T,e[10]=k,e[11]=I):(k=e[10],I=e[11]),us.useEffect(k,I);const B=m!==null;let O,F;e[12]!==B||e[13]!==c?(O=()=>{B&&c()},F=[B,c],e[12]=B,e[13]=c,e[14]=O,e[15]=F):(O=e[14],F=e[15]),us.useEffect(O,F);const{detail:j,refresh:P}=qf(g,m,!0);let L;e[16]!==m?(L=m?[m]:[],e[16]=m,e[17]=L):L=e[17];const z=Lx(g,L),H=df(m),[R,G]=us.useState(!1),_=Ml(),{retry:$}=y;let E;e[18]!==P||e[19]!==$?(E=()=>Promise.all([P(),$()]).then(A0),e[18]=P,e[19]=$,e[20]=E):E=e[20];const D=E,C=uf(m,w,D);let N;e[21]!==w||e[22]!==D||e[23]!==f?(N=async()=>{w&&await f.refreshProviderReads(w).catch(O0),Wx(),await D()},e[21]=w,e[22]=D,e[23]=f,e[24]=N):N=e[24];const A=N;if(!m){if(T){let ue;return e[25]!==s?(ue=n.jsx(Yl,{url:s}),e[25]=s,e[26]=ue):ue=e[26],ue}if(h.status==="failed"){let ue;e[27]!==u?(ue=u("gitView.empty.discoverFailed"),e[27]=u,e[28]=ue):ue=e[28];let me;return e[29]!==h.retry||e[30]!==ue?(me=n.jsx(Ar,{message:ue,onRetry:h.retry}),e[29]=h.retry,e[30]=ue,e[31]=me):me=e[31],me}let Y;return e[32]!==y.error||e[33]!==y.status||e[34]!==$||e[35]!==u?(Y=y.status==="error"?n.jsx(Ar,{message:y.error??u("contextPanel.tracker.loadFailed"),onRetry:()=>{$()}}):n.jsx(Ar,{message:u("common.loading")}),e[32]=y.error,e[33]=y.status,e[34]=$,e[35]=u,e[36]=Y):Y=e[36],Y}let q;e[37]!==m?(q={source:"github",reference:m},e[37]=m,e[38]=q):q=e[38];const ee=q,Q=m.kind==="pull"?m:null;let he;e[39]!==Q||e[40]!==z?(he=Q?z(Q):Ol,e[39]=Q,e[40]=z,e[41]=he):he=e[41];let M;e[42]===Symbol.for("react.memo_cache_sentinel")?(M={status:"idle"},e[42]=M):M=e[42];let V;e[43]!==D?(V=()=>{D()},e[43]=D,e[44]=V):V=e[44];let ie;e[45]!==w||e[46]!==ee||e[47]!==V?(ie=n.jsx(vl,{item:ee,project:null,context:w,onStartWorktree:F0,onChanged:V,worktreeAvailable:!1}),e[45]=w,e[46]=ee,e[47]=V,e[48]=ie):ie=e[48];let ce;e[49]!==w||e[50]!==Q?(ce=Q&&w?()=>G(!0):void 0,e[49]=w,e[50]=Q,e[51]=ce):ce=e[51];const ne=w?A:void 0;let je;e[52]!==w||e[53]!==ee||e[54]!==m.state||e[55]!==D?(je=m.state!=="merged"&&w?n.jsx(Lb,{item:ee,context:w,onChanged:()=>{D()}}):void 0,e[52]=w,e[53]=ee,e[54]=m.state,e[55]=D,e[56]=je):je=e[56];let Ee;e[57]!==H.attachComment||e[58]!==H.attachComments?(Ee={onAttach:H.attachComment,onAttachAll:H.attachComments},e[57]=H.attachComment,e[58]=H.attachComments,e[59]=Ee):Ee=e[59];let we;e[60]!==w||e[61]!==m||e[62]!==D?(we=w?n.jsx(hf,{reference:m,context:w,onChanged:D}):void 0,e[60]=w,e[61]=m,e[62]=D,e[63]=we):we=e[63];let Me;e[64]!==w||e[65]!==j||e[66]!==Q||e[67]!==D?(Me=Q&&w?n.jsx(mf,{pull:Q,detail:j,context:w,onChanged:D}):void 0,e[64]=w,e[65]=j,e[66]=Q,e[67]=D,e[68]=Me):Me=e[68];let fe;e[69]!==w||e[70]!==m||e[71]!==D?(fe=w?n.jsx(ff,{reference:m,context:w,onRefresh:D}):void 0,e[69]=w,e[70]=m,e[71]=D,e[72]=fe):fe=e[72];let be;e[73]!==p||e[74]!==w||e[75]!==r||e[76]!==i||e[77]!==o||e[78]!==Q||e[79]!==g?(be=Q&&w?n.jsx(gf,{pull:Q,project:{id:p??"",path:r},repository:g,context:w,projectOwnsDirectory:()=>!i,currentDirectory:o}):null,e[73]=p,e[74]=w,e[75]=r,e[76]=i,e[77]=o,e[78]=Q,e[79]=g,e[80]=be):be=e[80];let ke;e[81]!==j||e[82]!==ee||e[83]!==_||e[84]!==g||e[85]!==he||e[86]!==ie||e[87]!==ce||e[88]!==ne||e[89]!==je||e[90]!==Ee||e[91]!==we||e[92]!==Me||e[93]!==fe||e[94]!==be||e[95]!==C?(ke=n.jsx(Al,{item:ee,directory:g,pullStatus:he,linearDetail:M,githubDetail:j,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:B0,now:_,footer:ie,onOpenChecks:ce,onRefresh:ne,threadActions:C,stateMenu:je,commentAttachments:Ee,labelsControl:we,reviewersControl:Me,reply:fe,pullLinks:be}),e[81]=j,e[82]=ee,e[83]=_,e[84]=g,e[85]=he,e[86]=ie,e[87]=ce,e[88]=ne,e[89]=je,e[90]=Ee,e[91]=we,e[92]=Me,e[93]=fe,e[94]=be,e[95]=C,e[96]=ke):ke=e[96];let Ie;e[97]!==H.attachFailedChecks||e[98]!==R||e[99]!==w||e[100]!==Q?(Ie=Q&&w?n.jsx(pf,{pull:Q,context:w,open:R,onOpenChange:G,onAttachFailed:H.attachFailedChecks}):null,e[97]=H.attachFailedChecks,e[98]=R,e[99]=w,e[100]=Q,e[101]=Ie):Ie=e[101];let Te;return e[102]!==ke||e[103]!==Ie?(Te=n.jsxs(n.Fragment,{children:[ke,Ie]}),e[102]=ke,e[103]=Ie,e[104]=Te):Te=e[104],Te},N0=t=>{const e=Ze.c(45),{url:s,identifier:r,onUnavailable:o,onShown:i}=t,{t:a}=Et(),d=Mx(),{detail:c,refresh:u}=Ax(d==="ready"?r:null,!0),f=Ox(),p=Ml(),h=d!=="ready",g=c.status==="error",b=c.status==="ready";let x,y;e[0]!==h||e[1]!==g||e[2]!==o?(x=()=>{(h||g)&&o()},y=[h,g,o],e[0]=h,e[1]=g,e[2]=o,e[3]=x,e[4]=y):(x=e[3],y=e[4]),us.useEffect(x,y);let S,m;if(e[5]!==i||e[6]!==b?(S=()=>{b&&i()},m=[i,b],e[5]=i,e[6]=b,e[7]=S,e[8]=m):(S=e[7],m=e[8]),us.useEffect(S,m),h){let P;return e[9]!==s?(P=n.jsx(Yl,{url:s}),e[9]=s,e[10]=P):P=e[10],P}if(c.status==="error"){let P;e[11]!==c.error||e[12]!==a?(P=c.error||a("contextPanel.tracker.loadFailed"),e[11]=c.error,e[12]=a,e[13]=P):P=e[13];let L;e[14]!==u?(L=()=>{u()},e[14]=u,e[15]=L):L=e[15];let z;return e[16]!==P||e[17]!==L?(z=n.jsx(Ar,{message:P,onRetry:L}),e[16]=P,e[17]=L,e[18]=z):z=e[18],z}if(c.status!=="ready"){let P;e[19]!==a?(P=a("common.loading"),e[19]=a,e[20]=P):P=e[20];let L;return e[21]!==P?(L=n.jsx(Ar,{message:P}),e[21]=P,e[22]=L):L=e[22],L}let v;e[23]!==c.value?(v={source:"linear",issue:c.value},e[23]=c.value,e[24]=v):v=e[24];const w=v;let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T={status:"idle"},e[25]=T):T=e[25];let k;e[26]!==u?(k=()=>{u()},e[26]=u,e[27]=k):k=e[27];let I;e[28]!==w||e[29]!==k?(I=n.jsx(vl,{item:w,project:null,context:null,onStartWorktree:L0,onChanged:k,worktreeAvailable:!1}),e[28]=w,e[29]=k,e[30]=I):I=e[30];let B;e[31]!==u?(B=()=>{u()},e[31]=u,e[32]=B):B=e[32];let O;e[33]!==c.value||e[34]!==B?(O=n.jsx(Fb,{issue:c.value,onChanged:B}),e[33]=c.value,e[34]=B,e[35]=O):O=e[35];let F;e[36]!==f?(F=P=>{f(P.url,null)},e[36]=f,e[37]=F):F=e[37];let j;return e[38]!==c||e[39]!==w||e[40]!==p||e[41]!==O||e[42]!==F||e[43]!==I?(j=n.jsx(Al,{item:w,directory:null,pullStatus:Ol,linearDetail:c,githubDetail:T,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:_0,now:p,footer:I,linearStateControl:O,onOpenLinearIssue:F}),e[38]=c,e[39]=w,e[40]=p,e[41]=O,e[42]=F,e[43]=I,e[44]=j):j=e[44],j};function M0(t){return t.activeProjectId}function A0(){}function O0(){}function B0(){}function F0(){}function _0(){}function L0(){}const Uo=new Map,$0=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},z0=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},K0=(t,e)=>{if(e.length===0)return Uo;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const a of i.session){if(!s.has(a.id))continue;const d=a.title?.trim();if(!d)continue;const c=z0(a),u=r.get(a.id);u!==void 0&&u>c||(r.set(a.id,c),o.set(a.id,d))}return o.size===0?Uo:o},Pi=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,wd=60,W0=t=>{try{return new URL(t).origin}catch{return""}},aa=new Set,sh=to()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=W0(s);!i||!r||e().byOrigin[i]||aa.has(i)||(aa.add(i),Xn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(a=>{const d=typeof a?.dataUrl=="string"?a.dataUrl:"";d&&t(c=>{const u={...c.byOrigin,[i]:d},f=Object.keys(u);if(f.length<=wd)return{byOrigin:u};for(const p of f.slice(0,f.length-wd))delete u[p];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{aa.delete(i)}))}})),Zl=t=>t,Ga=t=>{const e=Zl(t).type;return typeof e=="string"?e:""},H0=t=>{const e=Zl(t).tool;return typeof e=="string"?e:""},U0=t=>{const e=Zl(t).text;return typeof e=="string"?e:""},V0=t=>{const e=Ga(t);return e==="tool"?H0(t).trim().toLowerCase()||"tool":e||"unknown"},G0=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=V0(s);e.includes(r)||e.push(r)}return e.join(" + ")},q0=t=>t.replace(/\s+/g," ").trim(),Y0=t=>{for(const s of t)if(Ga(s)==="text"){const r=q0(U0(s));if(r.length===0)continue;return r}const e=t.filter(s=>Ga(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Z0=(t,e,s)=>`${s(t)} / ${s(e)}`,Q0=t=>{if(t==="12h")return!0;if(t==="24h")return!1},X0=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Q0(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},J0=(t,{windowTokens:e,compacted:s=!1})=>{const r=s?0:e,o=Number.isFinite(r)&&r>0?r:0,i=t.user+t.assistant+t.tool+t.other,a=Math.max(o,i);return{user:t.user,assistant:t.assistant,tool:t.tool,other:a-i,total:a}},qa={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},jo={user:0,assistant:0,tool:0,other:0},dn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,vd=t=>{const e=t.info.tokens,s=e!==void 0?e:t.parts.find(f=>f.tokens!==void 0)?.tokens;if(typeof s=="number")return{...qa,total:dn(s)};if(!s||typeof s!="object")return qa;const r=s,o=dn(r.input),i=dn(r.output),a=dn(r.reasoning),d=dn(r.cache?.read),c=dn(r.cache?.write),u=dn(r.total);return{input:o,output:i,reasoning:a,cacheRead:d,cacheWrite:c,total:u>0?u:o+i+a+d+c}},ej=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ls=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Ls(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Ls(s),0):0,tj=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...jo,assistant:Ls(s.text)+Ls(s.content)};const o=ej(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ls(s.input)+Ls(s.output)+Ls(s.error)+Ls(s.call?.input)+Ls(s.call?.output)+Ls(s.call?.error)+Ls(s.raw)+Math.round(Ls(s.metadata)*.25)+Math.round(Ls(s.state)*.1)+Math.round((Ig(t)??0)*.1),other:0}:e==="user"?{user:o.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:o.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:o.length}},jd=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),sj=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",nj=(t,e)=>{if(t.length===0)return{...jo};const s=t.reduce((r,o)=>{const i=sj(o);let a={...jo};for(const d of o.parts)a=jd(a,tj(d,i));return jd(r,a)},{...jo});return s.user+=e.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},Fn=t=>t.toLocaleString(rp()),rj=(t,e)=>!t||!Number.isFinite(t)?"-":Gx(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),oj=(t,e,s)=>{const r=t.find(i=>i.id===e),o=r?.models?.find(i=>i.id===s);return{providerName:r?.name||e||"-",modelName:o?.name||s||"-",contextLimit:typeof o?.limit?.context=="number"?o.limit.context:null}},ij=()=>{const t=Ze.c(215),{t:e}=Et(),s=$b(),r=le(aj);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,a]=l.useState(o),[d,c]=l.useState(null),u=l.useRef(null),f=mt(lj),p=mt(cj),h=Hx(p??void 0),g=Ux(f??"",p??void 0),b=ps(dj);let x;t[1]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),a(uj),c(null)},t[1]=x):x=t[1];let y;t[2]!==p||t[3]!==f?(y=[p,f],t[2]=p,t[3]=f,t[4]=y):y=t[4],l.useEffect(x,y);let S,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},m=[],t[5]=S,t[6]=m):(S=t[5],m=t[6]),l.useEffect(S,m);let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=async(Ke,jt)=>{(await pi(jt)).ok?(c(Ke),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{c(Mt=>Mt===Ke?null:Mt),u.current=null},2e3)):c(null)},t[7]=v):v=t[7];const w=v;let T,k,I,B,O,F,j,P,L,z;if(t[8]!==f||t[9]!==b||t[10]!==g||t[11]!==h){B=f?h.find(se=>se.id===f)??null:null,T=g.filter(fj);let Ke;t[22]!==g?(Ke=g.filter(pj),t[22]=g,t[23]=Ke):Ke=t[23],z=Ke;let jt;t[24]!==g?(jt=np(g.map(hj)),t[24]=g,t[25]=jt):jt=t[25];const Lt=jt,Mt=Lt?g[Lt.index]??null:null,De=Lt?.state==="compacted";j=Mt?vd(Mt):qa,k=Vx({input:j.input,cache:{read:j.cacheRead,write:j.cacheWrite}}),P=Number.isFinite(B?.cost)?dn(B?.cost):T.reduce(mj,0);const Tt=Mt?.info??null,At=b,kt=Tt?.providerID||"",pt=Tt?.modelID||"";let Dt;t[26]!==kt||t[27]!==pt||t[28]!==At?(Dt=oj(At,kt,pt),t[26]=kt,t[27]=pt,t[28]=At,t[29]=Dt):Dt=t[29],O=Dt,I=O.contextLimit,L=De?null:I&&I>0?Math.min(999,j.total/I*100):0;const Ve=[...g].reverse().find(gj),rt=Ve?.info.role==="system"?Ve.info.text:"",wt=nj(g,rt);F=J0(wt,{windowTokens:j.total,compacted:De}),t[8]=f,t[9]=b,t[10]=g,t[11]=h,t[12]=T,t[13]=k,t[14]=I,t[15]=B,t[16]=O,t[17]=F,t[18]=j,t[19]=P,t[20]=L,t[21]=z}else T=t[12],k=t[13],I=t[14],B=t[15],O=t[16],F=t[17],j=t[18],P=t[19],L=t[20],z=t[21];const H=F,R=g[0]?.info?.time?.created,G=g.length>0?g[g.length-1]?.info?.time?.created:null;let _;t[30]!==B?.title||t[31]!==e?(_=B?.title||e("contextSidebar.session.untitled"),t[30]=B?.title,t[31]=e,t[32]=_):_=t[32];const $=B?.time?.created??R??null,E=G??B?.time?.created??null;let D;t[33]!==T.length||t[34]!==H||t[35]!==k||t[36]!==I||t[37]!==O||t[38]!==g.length||t[39]!==_||t[40]!==$||t[41]!==E||t[42]!==j||t[43]!==P||t[44]!==L||t[45]!==z.length?(D={sessionTitle:_,messagesCount:g.length,userMessagesCount:z.length,assistantMessagesCount:T.length,createdAt:$,lastActivityAt:E,providerModel:O,tokenBreakdown:j,usagePercent:L,cacheHitRate:k,totalAssistantCost:P,contextLimit:I,breakdown:H,breakdownTotal:H.total},t[33]=T.length,t[34]=H,t[35]=k,t[36]=I,t[37]=O,t[38]=g.length,t[39]=_,t[40]=$,t[41]=E,t[42]=j,t[43]=P,t[44]=L,t[45]=z.length,t[46]=D):D=t[46];const C=D;if(!f){let Ke;t[47]!==e?(Ke=e("contextSidebar.empty.openSession"),t[47]=e,t[48]=Ke):Ke=t[48];let jt;return t[49]!==Ke?(jt=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Ke}),t[49]=Ke,t[50]=jt):jt=t[50],jt}let N;t[51]!==e?(N=e("contextSidebar.breakdown.user"),t[51]=e,t[52]=N):N=t[52];let A;t[53]!==N||t[54]!==C.breakdown.user?(A={key:"user",label:N,value:C.breakdown.user,color:"var(--status-success)"},t[53]=N,t[54]=C.breakdown.user,t[55]=A):A=t[55];let q;t[56]!==e?(q=e("contextSidebar.breakdown.assistant"),t[56]=e,t[57]=q):q=t[57];let ee;t[58]!==q||t[59]!==C.breakdown.assistant?(ee={key:"assistant",label:q,value:C.breakdown.assistant,color:"var(--primary-base)"},t[58]=q,t[59]=C.breakdown.assistant,t[60]=ee):ee=t[60];let Q;t[61]!==e?(Q=e("contextSidebar.breakdown.toolCalls"),t[61]=e,t[62]=Q):Q=t[62];let he;t[63]!==Q||t[64]!==C.breakdown.tool?(he={key:"tool",label:Q,value:C.breakdown.tool,color:"var(--status-warning)"},t[63]=Q,t[64]=C.breakdown.tool,t[65]=he):he=t[65];let M;t[66]!==e?(M=e("contextSidebar.breakdown.other"),t[66]=e,t[67]=M):M=t[67];let V;t[68]!==M||t[69]!==C.breakdown.other?(V={key:"other",label:M,value:C.breakdown.other,color:"var(--surface-muted-foreground)"},t[68]=M,t[69]=C.breakdown.other,t[70]=V):V=t[70];let ie;t[71]!==A||t[72]!==ee||t[73]!==he||t[74]!==V?(ie=[A,ee,he,V],t[71]=A,t[72]=ee,t[73]=he,t[74]=V,t[75]=ie):ie=t[75];const ce=ie;let ne;t[76]!==s||t[77]!==C.sessionTitle?(ne=s?n.jsx(zb,{children:n.jsx("div",{className:"flex min-w-0 flex-1 items-center ps-1.5 pe-1",children:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-foreground",title:C.sessionTitle,children:C.sessionTitle})})}):null,t[76]=s,t[77]=C.sessionTitle,t[78]=ne):ne=t[78];let je;t[79]!==s||t[80]!==C.sessionTitle?(je=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:C.sessionTitle}),t[79]=s,t[80]=C.sessionTitle,t[81]=je):je=t[81];const Ee=!s&&"mt-1";let we;t[82]!==Ee?(we=Pe(Ee,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[82]=Ee,t[83]=we):we=t[83];let Me;t[84]!==C.providerModel.modelName||t[85]!==C.providerModel.providerName?(Me=n.jsxs("span",{children:[C.providerModel.providerName," / ",C.providerModel.modelName]}),t[84]=C.providerModel.modelName,t[85]=C.providerModel.providerName,t[86]=Me):Me=t[86];let fe;t[87]!==r||t[88]!==C.createdAt?(fe=C.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:rj(C.createdAt,r)})]}),t[87]=r,t[88]=C.createdAt,t[89]=fe):fe=t[89];let be;t[90]!==we||t[91]!==Me||t[92]!==fe?(be=n.jsxs("div",{className:we,children:[Me,fe]}),t[90]=we,t[91]=Me,t[92]=fe,t[93]=be):be=t[93];let ke;t[94]!==je||t[95]!==be?(ke=n.jsxs("div",{className:"mb-6",children:[je,be]}),t[94]=je,t[95]=be,t[96]=ke):ke=t[96];let Ie;t[97]!==e?(Ie=e("contextSidebar.section.context"),t[97]=e,t[98]=Ie):Ie=t[98];let Te;t[99]!==Ie?(Te=n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ie}),t[99]=Ie,t[100]=Te):Te=t[100];let Y;t[101]!==C.tokenBreakdown.total||t[102]!==C.usagePercent?(Y=C.usagePercent===null?"—":Fn(C.tokenBreakdown.total),t[101]=C.tokenBreakdown.total,t[102]=C.usagePercent,t[103]=Y):Y=t[103];let ue;t[104]!==C.contextLimit?(ue=C.contextLimit?` / ${Fn(C.contextLimit)}`:"",t[104]=C.contextLimit,t[105]=ue):ue=t[105];let me;t[106]!==Y||t[107]!==ue?(me=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Y,ue]}),t[106]=Y,t[107]=ue,t[108]=me):me=t[108];let re;t[109]!==Te||t[110]!==me?(re=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Te,me]}),t[109]=Te,t[110]=me,t[111]=re):re=t[111];let pe;t[112]!==C.usagePercent?(pe=C.usagePercent!==null&&C.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,C.usagePercent)}%`,backgroundColor:C.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[112]=C.usagePercent,t[113]=pe):pe=t[113];let U;t[114]!==pe?(U=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:pe}),t[114]=pe,t[115]=U):U=t[115];let ae;t[116]!==e||t[117]!==C.usagePercent?(ae=C.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:C.usagePercent.toFixed(1)}),t[116]=e,t[117]=C.usagePercent,t[118]=ae):ae=t[118];let Re;t[119]!==ae?(Re=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ae}),t[119]=ae,t[120]=Re):Re=t[120];let W;t[121]!==re||t[122]!==U||t[123]!==Re?(W=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[re,U,Re]}),t[121]=re,t[122]=U,t[123]=Re,t[124]=W):W=t[124];let ye;t[125]!==e?(ye=e("contextSidebar.stats.messages"),t[125]=e,t[126]=ye):ye=t[126];let de;t[127]!==C.messagesCount?(de=Fn(C.messagesCount),t[127]=C.messagesCount,t[128]=de):de=t[128];let Ne;t[129]!==ye||t[130]!==de?(Ne={label:ye,value:de},t[129]=ye,t[130]=de,t[131]=Ne):Ne=t[131];let Je;t[132]!==e?(Je=e("contextSidebar.stats.user"),t[132]=e,t[133]=Je):Je=t[133];let Ge;t[134]!==C.userMessagesCount?(Ge=Fn(C.userMessagesCount),t[134]=C.userMessagesCount,t[135]=Ge):Ge=t[135];let ge;t[136]!==Je||t[137]!==Ge?(ge={label:Je,value:Ge},t[136]=Je,t[137]=Ge,t[138]=ge):ge=t[138];let Ae;t[139]!==e?(Ae=e("contextSidebar.stats.assistant"),t[139]=e,t[140]=Ae):Ae=t[140];let Ye;t[141]!==C.assistantMessagesCount?(Ye=Fn(C.assistantMessagesCount),t[141]=C.assistantMessagesCount,t[142]=Ye):Ye=t[142];let nt;t[143]!==Ae||t[144]!==Ye?(nt={label:Ae,value:Ye},t[143]=Ae,t[144]=Ye,t[145]=nt):nt=t[145];let oe;t[146]!==e?(oe=e("contextSidebar.stats.cost"),t[146]=e,t[147]=oe):oe=t[147];let tt;t[148]!==C.totalAssistantCost?(tt=Lp(C.totalAssistantCost),t[148]=C.totalAssistantCost,t[149]=tt):tt=t[149];let Ue;t[150]!==oe||t[151]!==tt?(Ue={label:oe,value:tt},t[150]=oe,t[151]=tt,t[152]=Ue):Ue=t[152];let gt;t[153]!==Ne||t[154]!==ge||t[155]!==nt||t[156]!==Ue?(gt=[Ne,ge,nt,Ue],t[153]=Ne,t[154]=ge,t[155]=nt,t[156]=Ue,t[157]=gt):gt=t[157];const bt=gt;let Ce;t[158]!==bt?(Ce=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:bt.map(bj)}),t[158]=bt,t[159]=Ce):Ce=t[159];let _e;t[160]!==e?(_e=e("contextSidebar.section.lastAssistantMessage"),t[160]=e,t[161]=_e):_e=t[161];let ze;t[162]!==_e?(ze=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:_e}),t[162]=_e,t[163]=ze):ze=t[163];let Oe;t[164]!==e||t[165]!==C.cacheHitRate.hasInput||t[166]!==C.cacheHitRate.percent||t[167]!==C.tokenBreakdown.cacheRead||t[168]!==C.tokenBreakdown.cacheWrite||t[169]!==C.tokenBreakdown.input||t[170]!==C.tokenBreakdown.output||t[171]!==C.tokenBreakdown.reasoning?(Oe=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:C.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:C.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:C.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:C.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:C.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:C.cacheHitRate.hasInput?C.cacheHitRate.percent:null,format:"percent"}].map(yj)}),t[164]=e,t[165]=C.cacheHitRate.hasInput,t[166]=C.cacheHitRate.percent,t[167]=C.tokenBreakdown.cacheRead,t[168]=C.tokenBreakdown.cacheWrite,t[169]=C.tokenBreakdown.input,t[170]=C.tokenBreakdown.output,t[171]=C.tokenBreakdown.reasoning,t[172]=Oe):Oe=t[172];let it;t[173]!==ze||t[174]!==Oe?(it=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ze,Oe]}),t[173]=ze,t[174]=Oe,t[175]=it):it=t[175];let X;t[176]!==ce||t[177]!==C.breakdownTotal?(X=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:ce.map(Ke=>Ke.value<=0||C.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Ke.value/C.breakdownTotal*100}%`,backgroundColor:Ke.color}},Ke.key))}),t[176]=ce,t[177]=C.breakdownTotal,t[178]=X):X=t[178];let Be;t[179]!==ce||t[180]!==C.breakdownTotal?(Be=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:ce.map(Ke=>{const jt=C.breakdownTotal>0?Ke.value/C.breakdownTotal*100:0;return n.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Ke.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Ke.label," ",n.jsxs("span",{className:"tabular-nums",children:[jt.toFixed(0),"%"]})]})]},Ke.key)})}),t[179]=ce,t[180]=C.breakdownTotal,t[181]=Be):Be=t[181];let Le;t[182]!==X||t[183]!==Be?(Le=n.jsxs("div",{className:"mb-6",children:[X,Be]}),t[182]=X,t[183]=Be,t[184]=Le):Le=t[184];let at;t[185]!==e?(at=e("contextSidebar.section.rawMessages"),t[185]=e,t[186]=at):at=t[186];let qe;t[187]!==at?(qe=n.jsx("div",{className:"typography-micro text-muted-foreground",children:at}),t[187]=at,t[188]=qe):qe=t[188];let ut;if(t[189]!==d||t[190]!==i||t[191]!==g||t[192]!==e||t[193]!==r){let Ke;t[195]!==d||t[196]!==i||t[197]!==e||t[198]!==r?(Ke=jt=>{const Lt=jt.info.role,Mt=Lt==="assistant",De=Lt==="user",Tt=i[jt.info.id]===!0,At=d===jt.info.id,kt=jt.info.time?.created??null,pt=G0(jt.parts),Dt=Mt?vd({info:jt.info,parts:jt.parts}):null,Ve=De?Y0(jt.parts):"",rt=X0(kt,r),wt=pt||"—",se=Dt?Z0(Dt.input,Dt.output,Fn):"",Fe=Lt||"unknown",ot=pt?`${Fe}: ${pt}`:Fe,$e=Tt?JSON.stringify({info:jt.info,parts:jt.parts},null,2):"";return n.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[n.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-start hover:bg-[var(--interactive-hover)]","aria-expanded":Tt,onClick:()=>{a(Ct=>({...Ct,[jt.info.id]:Ct[jt.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:Mt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[De?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Ve]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Mt?wt:ot}),Mt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:se})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:rt})]})}),Tt&&n.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:n.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[n.jsx("div",{className:"absolute top-1 inset-e-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:n.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Ct=>{Ct.stopPropagation(),w(jt.info.id,$e)},"aria-label":e(At?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(At?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:At?n.jsx(Z,{name:"check",className:"size-3.5"}):n.jsx(Z,{name:"file-copy",className:"size-3.5"})})}),n.jsx(qx,{language:"json",code:$e,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},jt.info.id)},t[195]=d,t[196]=i,t[197]=e,t[198]=r,t[199]=Ke):Ke=t[199],ut=[...g].reverse().map(Ke),t[189]=d,t[190]=i,t[191]=g,t[192]=e,t[193]=r,t[194]=ut}else ut=t[194];let dt;t[200]!==ut?(dt=n.jsx("div",{className:"mt-2.5 space-y-1",children:ut}),t[200]=ut,t[201]=dt):dt=t[201];let ft;t[202]!==qe||t[203]!==dt?(ft=n.jsxs("div",{children:[qe,dt]}),t[202]=qe,t[203]=dt,t[204]=ft):ft=t[204];let st;t[205]!==ke||t[206]!==W||t[207]!==Ce||t[208]!==it||t[209]!==Le||t[210]!==ft?(st=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ke,W,Ce,it,Le,ft]}),t[205]=ke,t[206]=W,t[207]=Ce,t[208]=it,t[209]=Le,t[210]=ft,t[211]=st):st=t[211];let Rt;return t[212]!==ne||t[213]!==st?(Rt=n.jsxs(Qr,{outerClassName:"h-full",className:"bg-background",children:[ne,st]}),t[212]=ne,t[213]=st,t[214]=Rt):Rt=t[214],Rt};function aj(t){return t.timeFormatPreference}function lj(t){return t.currentSessionId}function cj(t){return t.currentSessionDirectory}function dj(t){return t.providers}function uj(t){return Object.keys(t).length>0?{}:t}function fj(t){return t.info.role==="assistant"}function pj(t){return t.info.role==="user"}function hj(t){return t.info}function mj(t,e){const s=dn(e.info.cost);return t+s}function gj(t){return t.info.role==="system"}function bj(t){return n.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function yj(t){return n.jsxs("div",{children:[n.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),n.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)}%`:Fn(t.value):"—"})]},t.label)}const nh=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||Yx(t.target)||Zx(t.target)||Nl(t)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},xj=280,Sj=.28,wj=240,vj=.35,jj=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,a=s?s.top:i-Math.min(wj,e.height*vj),d=Math.min(xj,t.width*Sj,e.width/4),c=e.left-t.left>=1,u=r-o>=1,f=Math.max(0,a-t.top),p=c?e.left:t.left+d,h=u?o:r-d;return{left:{left:t.left,top:t.top,width:p-t.left,height:c?t.height:f},right:{left:h,top:t.top,width:r-h,height:u?t.height:f},bottom:{left:e.left,top:a,width:e.width,height:Math.max(0,i-a)}}},la=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,kj=(t,e)=>la(t.bottom,e)?"bottom":la(t.left,e)?"left":la(t.right,e)?"right":null,gn=to(()=>({drag:null,hovered:null})),ko=t=>{if(!t)return null;const{left:e,top:s,width:r,height:o}=t.getBoundingClientRect();return r>0&&o>0?{left:e,top:s,width:r,height:o}:null},ca=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),da=t=>ko(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),rh=t=>{const e=ko(document.querySelector("[data-workspace-row]")),s=ko(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=jj(e,s,ko(r)),i={left:da("left")??ca(o.left),right:da("right")??ca(o.right),bottom:da("bottom")??ca(o.bottom)};return gn.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},oh=t=>{const{drag:e,hovered:s}=gn.getState();if(!e)return;const r=kj(e.targets,t);r!==s&&gn.setState({hovered:r})},Ya=()=>{gn.getState().drag&&gn.setState({drag:null,hovered:null})},ih=t=>{const{drag:e,hovered:s}=gn.getState();if(gn.setState({drag:null,hovered:null}),!e||!s)return!1;const r=le.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?Ds(t):"";if(o){const i=le.getState();bl(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},Ql=(t,e)=>{let s=!1;const r=i=>{const a={x:i.clientX,y:i.clientY};e(a)?(s||(s=rh(t)),s&&oh(a)):s&&(Ya(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(ih(i),!0):!1),cancel:()=>{o(),s&&Ya()}}},kd={left:null,right:null,bottom:null},Hr=to(()=>({body:kd,headerSlot:kd})),ah=(t,e,s)=>{const r=Hr.getState()[t];r[e]!==s&&Hr.setState({[t]:{...r,[e]:s}})},Cj=(t,e)=>ah("body",t,e),Ij=(t,e)=>ah("headerSlot",t,e),Or=t=>{const e=l.useRef(t);e.current=t;const[s,r]=l.useState(t),o=l.useCallback(()=>r(e.current),[]);return l.useLayoutEffect(()=>{Rl(o)},[t,o]),l.useEffect(()=>()=>op(o),[o]),s},Co=t=>{const e=Or(t);return t||e},Pj=Xr(()=>as(()=>import("./GitView-DvxCZgCW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123])).then(t=>({default:t.GitView}))),lh=320,ch=Eg.regular,dh=400,Ej=100,Tj=24,Dj=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Cd=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(lh,Math.round(t))):ch,Rj=t=>t===null?Number.POSITIVE_INFINITY:Math.max(lh,t-dh),Id=(t,e)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&s.startsWith(r+"/")?s.slice(r.length+1):s},Io=(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==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):dr(t)?Dl.getState().guests.find(r=>r.id===No(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Nj=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const s=e.split("/").filter(Boolean);return s.length===0?e:s[s.length-1]||null},Mj=(t,e,s)=>{if(t.mode==="chat"){const r=Pi(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||s("contextPanel.mode.chat")}return t.mode==="browser"?ii(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Nj(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):Io(t.mode,s)},Aj=t=>{const e=Ze.c(8),{mode:s}=t,r=Fl();let o;if(e[0]!==s||e[1]!==r){let u;e[3]!==s?(u=f=>f.mode===s,e[3]=s,e[4]=u):u=e[4],o=r.find(u),e[0]=s,e[1]=r,e[2]=o}else o=e[2];const i=o,a=i?.icon??t1,d=i?.iconSrc;let c;return e[5]!==a||e[6]!==d?(c=n.jsx(yr,{icon:a,iconSrc:d,className:"h-3.5 w-3.5"}),e[5]=a,e[6]=d,e[7]=c):c=e[7],c},Oj=t=>{const e=Ze.c(2),{sessionId:s}=t,r=Pl(s);let o;return e[0]!==r?(o=r?n.jsx(El,{state:r,className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"}),e[0]=r,e[1]=o):o=e[1],o},Pd=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(mi,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(yf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx(Z,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx(Z,{name:Bj(t.targetPath),className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx(Z,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx(Z,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx(Z,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat"){const s=Pi(t.dedupeKey);return s?n.jsx(Oj,{sessionId:s}):n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"})}if(dr(t.mode))return n.jsx(Aj,{mode:t.mode});if(t.mode==="browser"){const s=Fj(t.targetPath??"",e);return s?n.jsx("img",{src:s,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):n.jsx(Z,{name:"global",className:"h-3.5 w-3.5"})}},Bj=t=>{const e=t?sp(t):null;return e?e.source==="linear"?"linear":e.kind==="pull"?"git-pull-request":"record-circle":"git-branch"},Fj=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},_j=t=>{const e=Jr(),s=l.useRef(Uo),r=l.useRef(t);r.current=t;const o=t.length>0;return l.useSyncExternalStore(l.useCallback(i=>o?e.subscribeAllSelected(a=>a.session,i):()=>{},[e,o]),l.useCallback(()=>{const i=Array.from(e.children.values(),d=>d.getState()),a=K0(i,r.current);return $0(s.current,a)?s.current:(s.current=a,a)},[e]),()=>Uo)},Lj=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,$j=8,zj='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',Kj=t=>t==="context"||t==="git"||t==="pr"||t==="notes",uh=320,fh=160,ph=200,Wj={right:{axis:"x",gutter:"mb-2 ms-2 me-1.5",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-e-0 z-20 min-w-0",handle:"absolute bottom-2 inset-s-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},left:{axis:"x",gutter:"mb-2 ms-1.5 me-2",gutterSize:"0.875rem",expanded:"absolute inset-y-0 inset-s-0 z-20 min-w-0",handle:"absolute bottom-2 inset-e-1 top-0 z-50 w-2 cursor-col-resize",sizeVariable:"--oc-context-panel-width"},bottom:{axis:"y",gutter:"mb-2 mt-2",gutterSize:"1rem",expanded:"absolute inset-x-0 bottom-0 z-20 min-h-0",handle:"absolute inset-x-0 top-1 z-50 h-2 cursor-row-resize",sizeVariable:"--oc-context-panel-height"}},Ed=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(fh,Math.round(t))):uh,Hj=t=>t===null?Number.POSITIVE_INFINITY:Math.max(fh,t-ph),ua=({zone:t="right"})=>{const e=Wj[t],s=ui(),r=e.axis==="y",{t:o,direction:i}=Et(),a=i==="rtl",d=Nn()??"",c=Qx(d||null),u=l.useCallback((se,Fe)=>o(pn(se,c),Fe),[c,o]),f=l.useMemo(()=>Dj(d),[d]),p=le(se=>f?se.contextPanelByDirectory[f]:void 0),h=le(se=>se.contextSurfaceZones),g=le(se=>se.closeContextZone),b=le(se=>se.closeContextPanelTab),x=le(se=>se.pinContextPanelTab),y=le(se=>se.toggleContextPanelExpanded),S=le(se=>se.setContextPanelWidth),m=le(se=>se.setContextPanelHeight),v=le(se=>se.setActiveContextPanelTab),w=le(se=>se.reorderContextPanelTabs),T=le(se=>se.contextEditorTreeVisible),k=le(se=>se.contextEditorTreeWidth),I=le(se=>se.setContextEditorTreeWidth),B=le(se=>se.toggleContextEditorTree),O=le(se=>se.contextEditorVisible),F=le(se=>se.toggleContextEditor),j=le(se=>se.fileTreeSide),P=le(se=>se.openNewContextBrowserTab),L=sh(se=>se.byOrigin),[z,H]=l.useState(null),R=l.useCallback(se=>{H(se),Ij(t,se)},[t]),G=l.useCallback(se=>{Cj(t,se)},[t]),_=l.useMemo(()=>p?.tabs??[],[p?.tabs]),$=p?Ro(p,h,t):null,E=p?oi(p,t):Pg,D=Oa(se=>se.workStatusReserved),C=Oa(se=>se.chatCovered),N=t==="bottom"&&C,A=!!(E.isOpen&&$)&&!N,q=l.useMemo(()=>_.some(se=>se.mode==="file"&&se.targetPath),[_]),ee=q&&(O||!T),Q=$?.mode??null,he=!r&&Q==="file"&&!ee,M=!!(A&&E.expanded&&!he),V=Q?r?p?.heightByMode?.[Q]:p?.widthByMode?.[Q]:void 0,ie=he?k:r?Ed(V??uh,Number.POSITIVE_INFINITY):Cd(V??(Q?Ca(Q):ch),Number.POSITIVE_INFINITY),ce=l.useCallback((se,Fe)=>r?Ed(se,Hj(Fe)):Cd(se,Rj(Fe)),[r]),ne=r?ph:dh,je=t==="right"?"left":t==="left"?"right":null,Ee=le(se=>{if(!je||!f)return 0;const Fe=se.contextPanelByDirectory[f],ot=Fe&&Dr(Fe,se.contextSurfaceZones,je)?Ro(Fe,se.contextSurfaceZones,je):null;if(!Fe||!ot)return 0;const $e=Fe.tabs.some(Ct=>Ct.mode==="file"&&Ct.targetPath)&&(se.contextEditorVisible||!se.contextEditorTreeVisible);return ot.mode==="file"&&!$e?se.contextEditorTreeWidth:Fe.widthByMode[ot.mode]??Ca(ot.mode)}),we=je==="right"&&D&&!C&&Ee===0?Xi:Ee,[Me,fe]=l.useState(null),be=l.useRef(null),ke=l.useRef(we);ke.current=we;const Ie=l.useRef(()=>!1);Ie.current=se=>M||!he&&se-ke.current-ne<ie;const Te=l.useCallback(()=>{const se=be.current;fe(se!==null&&Ie.current(se)?se:null)},[]),Y=Me!==null?Me-we:null,ue=t==="left"?Me:Y,me=he?ie:ce(ie,Y),re=A&&$?.mode==="chat",pe=l.useMemo(()=>{const se=[];if(!re)return se;for(const Fe of _){if(Fe.mode!=="chat")continue;const ot=Pi(Fe.dedupeKey);ot&&!se.includes(ot)&&se.push(ot)}return se},[re,_]),U=_j(pe),[ae,Re]=l.useState(!1),W=l.useRef(0),ye=l.useRef(me),de=l.useRef(null),Ne=l.useRef(null),Je=l.useRef(null),Ge=l.useRef(null),ge=l.useRef(!1);l.useLayoutEffect(()=>{const se=r?Je.current?.parentElement:Je.current?.closest("[data-workspace-row]");if(!se||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(ot=>{const $e=ot[ot.length-1]?.contentRect,Ct=r?$e?.height:$e?.width;be.current=Ct?Math.round(Ct):null,Rl(Te)});return Fe.observe(se),be.current=(r?se.clientHeight:se.clientWidth)||null,Te(),()=>{Fe.disconnect(),op(Te)}},[Te,r]),l.useLayoutEffect(()=>{Te()},[Te,ie,M,we]),l.useEffect(()=>{if(!A||ge.current){ge.current=A;return}const se=window.requestAnimationFrame(()=>{Ge.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(se)},[A]);const Ae=l.useRef(null),Ye=l.useRef(null),nt=l.useCallback(()=>{Ye.current=null;const se=Je.current,Fe=de.current;!se||Fe===null||se.style.setProperty(e.sizeVariable,`${Fe}px`)},[e.sizeVariable]);l.useEffect(()=>()=>{Ye.current!==null&&clearTimeout(Ye.current)},[]);const oe=l.useCallback(se=>{const Fe=Ae.current,ot=he?Ia(se):ce(se,Fe);return Fe===null?ot:Math.min(ot,Math.max(1,Fe))},[ce,he]),tt=l.useCallback(se=>{if(!A||M||!f)return;Ne.current=se.pointerId,Re(!0),W.current=r?se.clientY:se.clientX,ye.current=me,de.current=me;const Fe=r?Je.current?.parentElement?.clientHeight:(Je.current?.closest("[data-workspace-row]")?.clientWidth??0)-ke.current;Ae.current=Fe&&Fe>0?Fe:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",se.preventDefault()},[f,M,A,r,me]),Ue=l.useCallback(()=>{const se=oe(de.current??me);de.current=null,Ae.current=null,Ye.current!==null&&(clearTimeout(Ye.current),Ye.current=null),document.documentElement.style.cursor="",he?I(se):f&&Q&&(r?m(f,Q,se):S(f,Q,se)),Re(!1),Ne.current=null},[Q,oe,f,he,r,I,m,S,me]);l.useEffect(()=>{if(!ae)return;const se=$e=>{if(Ne.current!==$e.pointerId)return;const Ct=r?$e.clientY:$e.clientX,Yt=t==="left"?Ct-W.current:W.current-Ct,es=!r&&a?-Yt:Yt,Zt=oe(ye.current+es);de.current!==Zt&&(de.current=Zt,Ye.current===null&&(Ye.current=setTimeout(nt,Ej)))},Fe=$e=>{Ne.current===$e.pointerId&&Ue()},ot=()=>{Ue()};return window.addEventListener("pointermove",se),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",ot),()=>{window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",ot)}},[nt,oe,Ue,ae,a,r,t]),l.useEffect(()=>{ae||(de.current=null,document.documentElement.style.cursor="")},[ae]);const gt=l.useCallback(()=>{f&&g(f,t)},[g,f,t]),bt=l.useCallback(()=>{f&&y(f,t)},[f,y,t]),Ce=l.useCallback(se=>{nh(se,A,gt)},[gt,A]),_e=$?.mode==="file"||$?.mode==="chat"||$?.mode==="browser"||$?.mode==="pr",ze=l.useMemo(()=>{if(!$)return[];const se=_.filter(Fe=>Fe.mode===$.mode);return $.mode==="pr"?[...se.filter(Yi),...se.filter(Fe=>!Yi(Fe))]:se},[$,_]),Oe=hi($?.mode==="pr"&&f?f:null)?.current??null,it=l.useMemo(()=>{const se=Xx(ze.filter(Fe=>Fe.mode==="file").map(Fe=>Id(Fe.targetPath,d)));return ze.map(Fe=>{const ot=Yi(Fe),$e=ot?Oe||o("contextPanel.tracker.branchTab"):Mj(Fe,U,u),Ct=Lj($e,Tj),Yt=Id(Fe.targetPath,d);return{id:Fe.id,label:Ct,labelFolder:Fe.mode==="file"?se.get(Yt):void 0,icon:Pd(Fe,L),title:Yt?`${$e}: ${Yt}`:$e,closeLabel:o("contextPanel.tab.closeTabAria",{label:Ct}),closable:!ot,preview:Fe.preview}})},[ze,d,L,U,o,u,Oe]),X=$?.mode==="context"?n.jsx(rr,{value:z,children:n.jsx(ij,{})}):$?.mode==="git"?n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:z,children:n.jsx(Pj,{isActive:A})})}):$?.mode==="pr"?$.targetPath?n.jsx(D0,{url:$.targetPath,directory:$.targetDirectory??d,panelDirectory:d,tabId:$.id,foreign:!!$.targetDirectory,visible:A},$.id):n.jsx(S0,{}):$?.mode==="notes"?n.jsx(rr,{value:z,children:n.jsx(Kb,{visible:A})}):null,Be=$?.mode==="file",Le=le(se=>se.closeContextPanelTabs),at=l.useCallback(se=>{if(!f)return null;const{id:Fe,index:ot,allIds:$e,close:Ct}=se,Yt=()=>Le(f,$e.filter(cs=>cs!==Fe)),es=$e.slice(0,ot),Zt=$e.slice(ot+1),ss=()=>Le(f,a?Zt:es),bs=()=>Le(f,a?es:Zt),ls=()=>Le(f,$e),ms=$e.length>1,fs=a?ot===$e.length-1:ot===0,Es=a?ot===0:ot===$e.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs($n,{onClick:Ct,children:[n.jsx(Z,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(wo,{}),n.jsxs($n,{onClick:Yt,disabled:!ms,children:[n.jsx(Z,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs($n,{onClick:ss,disabled:fs,children:[n.jsx(Z,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs($n,{onClick:bs,disabled:Es,children:[n.jsx(Z,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(wo,{}),n.jsxs($n,{onClick:ls,disabled:!ms,children:[n.jsx(Z,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),$?n.jsxs(n.Fragment,{children:[n.jsx(wo,{}),n.jsx(bf,{mode:$.mode})]}):null]})},[$,Le,f,a,o]),qe=l.useCallback((se,Fe)=>{const ot=_.find(Ct=>Ct.id===se);if(!ot)return null;const $e=Ql({mode:ot.mode,label:Io(ot.mode,u),from:t},Fe);return{finish:()=>$e.finish(f),cancel:$e.cancel}},[f,u,_,t]),[ut,dt]=l.useState(null),ft=l.useCallback(se=>{if(!$||se.button!==0||se.pointerType==="touch"||se.target instanceof Element&&se.target.closest(zj))return;const Fe=$.mode,ot=Io(Fe,u),$e={x:se.clientX,y:se.clientY};let Ct=!1;const Yt=bs=>{const ls={x:bs.clientX,y:bs.clientY};!Ct&&(Math.hypot(ls.x-$e.x,ls.y-$e.y)<$j||(Ct=rh({mode:Fe,label:ot,from:t}),!Ct))||oh(ls)},es=()=>{window.removeEventListener("pointermove",Yt),window.removeEventListener("pointerup",Zt),window.removeEventListener("pointercancel",ss),window.removeEventListener("blur",ss)},Zt=()=>{es(),Ct&&ih(f)},ss=()=>{es(),Ct&&Ya()};window.addEventListener("pointermove",Yt),window.addEventListener("pointerup",Zt),window.addEventListener("pointercancel",ss),window.addEventListener("blur",ss)},[$,f,u,t]);l.useEffect(()=>{if(ut)return ut.addEventListener("pointerdown",ft),()=>ut.removeEventListener("pointerdown",ft)},[ft,ut]);const st=n.jsxs("header",{ref:dt,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[_e?n.jsx(Jx,{items:it,activeId:$?.id??null,onSelect:se=>{f&&v(f,se)},onClose:se=>{f&&b(f,se)},onReorder:(se,Fe)=>{f&&w(f,se,Fe)},onDoubleClickTab:se=>{f&&x(f,se)},layoutMode:"scrollable",variant:"default",tabContextMenu:at,onTabDragOut:qe}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 group-has-[[data-context-panel-toolbar]]/panel-header:hidden",children:[$?Pd($,L):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:$?Io($.mode,u):null})]}),n.jsx("div",{ref:R,className:"flex min-w-0 flex-1 items-stretch ps-1.5 empty:hidden"})]}),n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 self-start px-1.5",children:[$?.mode==="browser"?n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&P(f)},className:"h-7 w-7 p-0",title:o("contextPanel.browser.newTab"),"aria-label":o("contextPanel.browser.newTab"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,Be?["left","right"].map(se=>{const Fe=se===j;if(!Fe&&!q)return null;const ot=o(Fe?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:Fe?B:F,className:"h-7 w-7 p-0",title:ot,"aria-label":ot,"aria-pressed":Fe?T:ee,children:n.jsx(Z,{name:se==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},se)}):null,he?null:n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:bt,className:"h-7 w-7 p-0",title:o(M?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":o(M?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:M?n.jsx(Z,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx(Z,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:gt,className:"h-7 w-7 p-0",title:o("contextPanel.actions.closePanel"),"aria-label":o("contextPanel.actions.closePanel"),children:n.jsx(Z,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Rt=t==="right"&&D&&!C,Ke=ue!==null?`${ue}px`:"100%",jt=A?M?Ke:`min(var(${e.sizeVariable}), 100%)`:Rt?`${Xi}px`:"0px",Lt=t==="bottom"&&Dr(p,h,"left"),Mt=t==="bottom"&&(D&&!C||Dr(p,h,"right")),De=`${A}|${M}|${Rt}|${A?ie:""}`,Tt=l.useRef(De),At=l.useRef(C),kt=At.current!==C;l.useLayoutEffect(()=>{At.current=C},[C]),l.useLayoutEffect(()=>{Tt.current!==De&&(Tt.current=De,kt||Wf(s))},[De,kt,s]);const pt=!xo(A,Or(A),$?.mode),Dt=Co(M),Ve=A?`${me}px`:Rt?`${Xi}px`:"0px",rt={[e.sizeVariable]:A&&M?Ke:`${me}px`,...r?{height:jt,maxHeight:"100%"}:{width:jt,maxWidth:"100%"},transitionDuration:kt?"0ms":`${s}ms`,transitionTimingFunction:pr},wt=M?ue!==null?`calc(${ue}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs(n.Fragment,{children:[Dt?n.jsx("div",{"aria-hidden":"true",className:"flex-shrink-0",style:r?{height:Ve,maxHeight:"100%"}:{width:Ve,maxWidth:"100%"}}):null,n.jsxs("aside",{ref:Je,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":A?"true":"false",tabIndex:-1,className:Pe("flex min-h-0 flex-col overflow-clip bg-background","isolate",Dt?e.expanded:r?"relative w-full flex-shrink-0":"relative h-full flex-shrink-0",r?"transition-[height]":"transition-[width]","motion-reduce:transition-none"),onKeyDownCapture:Ce,style:rt,children:[n.jsx("div",{ref:Ge,tabIndex:-1,className:"absolute size-0 overflow-hidden outline-none"}),t==="right"?n.jsx("div",{ref:e1,className:Pe("absolute inset-y-0 inset-e-0 z-0 flex",C&&"invisible")}):null,A&&!M&&n.jsx("div",{className:e.handle,onPointerDown:tt,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{"data-zone-card":"",className:Pe("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Lt?"ms-0":"ms-2"),t==="bottom"&&(Mt?"me-0":"me-1.5"),r?null:"h-[calc(100%-0.5rem)]","oc-panel-edge overflow-hidden rounded-[10px] bg-background",r?"transition-[height,opacity]":"transition-[width,opacity]",!A&&"opacity-0",pt&&"pointer-events-none select-none"),style:{...r?{height:wt,width:`calc(100% - ${(Lt?0:.5)+(Mt?0:.375)}rem)`}:{width:wt},transitionDuration:`${s}ms`,transitionTimingFunction:pr},inert:pt||void 0,children:n.jsxs(ip.Provider,{value:!0,children:[st,n.jsx("div",{ref:G,className:Pe("relative min-h-0 flex-1 overflow-hidden",ae&&"pointer-events-none"),children:$&&Kj($.mode)?X:null})]})})]})]})},Uj=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"},Vj=async(t,e)=>{try{const s=await Ys("/api/dev-servers",{signal:t,directory:e});if(!s.ok)return{kind:"unavailable"};const r=await s.json();if(!r||typeof r!="object")return{kind:"unavailable"};const o=r.servers;return Array.isArray(o)?{kind:"ready",servers:o.filter(Uj)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},Gj=async t=>{try{const e=await Ys("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const s=await e.json();if(!s||typeof s!="object")return null;const r=s.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},qj=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:null}catch{return null}},Yj=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=qj(r);o!==null&&!s.has(o)&&s.set(o,r)}return e?e.map(r=>{const o=s.get(r.port);return{url:o??r.url,port:r.port,announced:o!==void 0}}).sort((r,o)=>r.announced!==o.announced?r.announced?-1:1:r.port-o.port):[...s.entries()].map(([r,o])=>({url:o,port:r,announced:!0})).sort((r,o)=>r.port-o.port)},Zj=t=>({sessionId:t.sessionId,directory:t.directory?Ds(t.directory):null}),Qj=2e3,Xj=50,Br=400,Bs=new Map,sn=new Map;let Za=null,Qa=null;const Ur=new Map;let un=null,jn=null,Fr=null;const fn=async t=>{try{const e=await Ys("/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}},Jj=async(t,e)=>{try{const s=await Ys("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});s.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${s.status}); the agent will see this action time out`)}catch(s){console.warn(`[browser-control] could not deliver the result for ${t}:`,s)}},hh=async(t,e=Qj)=>{const s=Date.now()+e;for(;!Bs.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,Xj));return Bs.get(t)??null},Vo=t=>Bs.has(t)||sn.has(t),mr=t=>Bs.get(t)??sn.get(t)??null,Xa=()=>[...Bs.values(),...[...sn.values()].filter(t=>!Bs.has(t.tabId))],Xl=t=>{const e=Qa?mr(Qa):null,s=e?.directory===Za?e:null;if(!t.sessionId){if(s)return s.tabId;const i=Xa().filter(c=>c.directory===Za),a=i.filter(c=>Bs.has(c.tabId)),d=a.length>0?a:i;return d.length>0?d[d.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=Ur.get(t.sessionId);if(r&&mr(r)?.ownerSessionId===t.sessionId)return r;const o=Xa().filter(i=>i.ownerSessionId===t.sessionId);return o.length>0?o[o.length-1].tabId:s&&s.ownerSessionId===null&&(!t.directory||s.directory===t.directory)?s.tabId:null},ek=t=>{const e=Xl(t);return e&&mr(e)?.ownerSessionId===t.sessionId?e:null},tk=(t,e)=>{t.sessionId&&mr(e)?.ownerSessionId===t.sessionId&&Ur.set(t.sessionId,e)},mh=async t=>{const e=Bs.get(t);if(e)return e;const s=sn.get(t);return s?(s.wake(),hh(t)):null},gh=t=>{const e=Xl(t);return Xa().filter(s=>!t.sessionId||!t.directory||s.ownerSessionId===t.sessionId||s.directory===t.directory).map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}const o=s.ownerSessionId===null?"user":s.ownerSessionId===t.sessionId?"you":"another session";return{id:s.tabId,title:r.title,url:r.url,owner:o,active:s.tabId===e}})},bh=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,yh=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use this session's own tab.`,sk=t=>{const e=gh(t);return"This session has no browser tab of its own, and the user is not looking at a tab of theirs in this session's project. Nothing was changed. Open the page with browser.open, or pass tabId to work in a tab the user points you to."+(e.length>0?` Open tabs:
3
3
  ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
4
- `)}`:"")},sk=()=>"This session has no browser tab of its own to close. Agent actions never close a tab the user opened. Open a page with browser.open first, or name a tab this session opened with tabId.",nk=t=>`The browser tab ${t} was not opened by this session, so it was not closed. Agent actions never close a tab the user or another session opened. Name a tab from browser.snapshot whose owner is you.`,rk=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",Is=(t,e)=>Xj(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:t1()})}:e),ok=async(t,e,s)=>{if(!e.sessionId){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:rk()});return}const r=s??Jj(e);if(r===null){if(await new Promise(a=>setTimeout(a,Br)),!await fn(t.requestId))return;await Is(t,{ok:!1,error:sk()});return}if(!Vo(r)){if(Bs.size===0&&sn.size===0&&!jn)return;if(await new Promise(a=>setTimeout(a,Br)),!Vo(r)){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:bh(r)});return}}const o=mr(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:nk(r)});return}if(!await fn(t.requestId))return;if(!(jn?jn(o.directory,r):!1)){await Is(t,{ok:!1,error:jn?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&Ur.get(e.sessionId)===r&&Ur.delete(e.sessionId),await Is(t,{ok:!0,data:{closed:!0,tabId:r}})},ik=async t=>{const e=t.action==="browser.open",s=t.action==="browser.close",r=Yj(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(s){await ok(t,r,a);return}if(a!==null){if(!Vo(a)){if(Bs.size===0&&sn.size===0&&!un)return;if(await new Promise(u=>setTimeout(u,Br)),Vo(a)){await Ed(t,r,a,i);return}if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:bh(a)});return}await Ed(t,r,a,i);return}const d=Xl(r);if(!d&&!(e&&un)){if(!r.sessionId||(await new Promise(u=>setTimeout(u,Br)),!await fn(t.requestId)))return;await Is(t,{ok:!1,error:tk(r)});return}if(!(e&&un!==null)&&r.sessionId&&mr(d)?.ownerSessionId!==r.sessionId&&await new Promise(u=>setTimeout(u,Br)),!!await fn(t.requestId))try{const u=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!u){await Is(t,{ok:!1,error:"url is required"});return}const f=e&&un?un(u,t.context):null;if(e&&!f&&!d){await Is(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(f){r.sessionId&&Ur.set(r.sessionId,f);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!h||h==="fill"){await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f}});return}const g=await ph(f);if(!g){await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f,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 b=await g.run("browser.resize",{viewport:h}),x=b&&typeof b=="object"?b.viewport??null:null;await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f,viewportApplied:!0,viewport:x}});return}const p=await hh(d);await Is(t,p?await yh(p,r,t.action,i):{ok:!1,error:gh(d)})}catch(u){await Is(t,{ok:!1,error:u instanceof Error?u.message:String(u)})}},Ed=async(t,e,s,r)=>{if(!await fn(t.requestId))return;ek(e,s);const o=await hh(s);await Is(t,o?await yh(o,e,t.action,r):{ok:!1,error:gh(s)})},yh=async(t,e,s,r)=>{try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:mh(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},Ei=()=>{Fr||(Fr=En(t=>{t.type==="browser-control-request"&&ik({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},Ti=()=>{Bs.size>0||sn.size>0||un||jn||!Fr||(Fr(),Fr=null)},ak=t=>(Bs.set(t.tabId,t),Ei(),()=>{Bs.get(t.tabId)===t&&Bs.delete(t.tabId),Ti()}),lk=t=>(sn.set(t.tabId,t),Ei(),()=>{sn.get(t.tabId)===t&&sn.delete(t.tabId),Ti()}),ck=(t,e)=>{Za=t,e&&(Qa=e)},dk=t=>(un=t,Ei(),()=>{un===t&&(un=null),Ti()}),uk=t=>(jn=t,Ei(),()=>{jn===t&&(jn=null),Ti()}),fk=50,pk=6,hk=2048,mk=200,xh=t=>{const e=nr(String(t??"").trim());if(!e||e.length>hk)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},gk=(t,e)=>{const s=xh(e.url);if(!s)return t;const r=t.find(a=>a.url===s),o=String(e.title??"").trim().slice(0,mk)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==s)].slice(0,fk)},bk=(t,e)=>{const s=xh(e);return t.filter(r=>r.url!==s)},yk=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Sh=(t,e,s=pk)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,d)=>d.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const d=yk(a);return a.url===r||d===i?!1:d.includes(i)}).slice(0,s)},Td=20,Po=t=>{const e=yt((t||"").trim());return e?JSON.stringify([Jt(),e]):""},xk=t=>{const e=Object.keys(t);if(e.length<=Td)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Td);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},ir=to()(Fw(t=>({byProject:{},recordVisit:(e,s)=>{const r=Po(e);r&&t(o=>{const i=o.byProject[r]??[],a=gk(i,{...s,at:Date.now()});return a===i?o:{byProject:xk({...o.byProject,[r]:a})}})},forget:(e,s)=>{const r=Po(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:bk(i,s)}}:o})},clear:e=>{const s=Po(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Eg(),partialize:t=>({byProject:t.byProject})})),Sk=[],wh=t=>e=>{const s=Po(t);return(s?e.byProject[s]:void 0)??Sk},Jl=t=>{const e=Ze.c(10),{t:s}=Et();let r;e[0]!==t?(r=$s(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=u=>o?u.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=Gs(i);if(o===null)return null;if(!a){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let d;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==s?(d=a.machine??(a.placeId==="docker"?s("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=s,e[9]=d):d=e[9];const c=d;return`${a.name} · ${c}`},Dd=6e3,wk=120,vk=80,jk=100,kk=`
5
- var MAX_ELEMENTS = ${wk};
6
- var MAX_LABEL_CHARS = ${vk};
4
+ `)}`:"")},nk=()=>"This session has no browser tab of its own to close. Agent actions never close a tab the user opened. Open a page with browser.open first, or name a tab this session opened with tabId.",rk=t=>`The browser tab ${t} was not opened by this session, so it was not closed. Agent actions never close a tab the user or another session opened. Name a tab from browser.snapshot whose owner is you.`,ok=()=>"This browser.close did not come from a session, so there is no tab it opened to close. Nothing was closed.",Is=(t,e)=>Jj(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:s1()})}:e),ik=async(t,e,s)=>{if(!e.sessionId){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:ok()});return}const r=s??ek(e);if(r===null){if(await new Promise(a=>setTimeout(a,Br)),!await fn(t.requestId))return;await Is(t,{ok:!1,error:nk()});return}if(!Vo(r)){if(Bs.size===0&&sn.size===0&&!jn)return;if(await new Promise(a=>setTimeout(a,Br)),!Vo(r)){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:yh(r)});return}}const o=mr(r);if(!o||o.ownerSessionId!==e.sessionId){if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:rk(r)});return}if(!await fn(t.requestId))return;if(!(jn?jn(o.directory,r):!1)){await Is(t,{ok:!1,error:jn?`The browser tab ${r} could not be closed.`:"There is no browser here to close a tab in."});return}e.sessionId&&Ur.get(e.sessionId)===r&&Ur.delete(e.sessionId),await Is(t,{ok:!0,data:{closed:!0,tabId:r}})},ak=async t=>{const e=t.action==="browser.open",s=t.action==="browser.close",r=Zj(t.context),{tabId:o,...i}=t.parameters,a=o===void 0?null:String(o);if(s){await ik(t,r,a);return}if(a!==null){if(!Vo(a)){if(Bs.size===0&&sn.size===0&&!un)return;if(await new Promise(u=>setTimeout(u,Br)),Vo(a)){await Td(t,r,a,i);return}if(!await fn(t.requestId))return;await Is(t,{ok:!1,error:yh(a)});return}await Td(t,r,a,i);return}const d=Xl(r);if(!d&&!(e&&un)){if(!r.sessionId||(await new Promise(u=>setTimeout(u,Br)),!await fn(t.requestId)))return;await Is(t,{ok:!1,error:sk(r)});return}if(!(e&&un!==null)&&r.sessionId&&mr(d)?.ownerSessionId!==r.sessionId&&await new Promise(u=>setTimeout(u,Br)),!!await fn(t.requestId))try{const u=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!u){await Is(t,{ok:!1,error:"url is required"});return}const f=e&&un?un(u,t.context):null;if(e&&!f&&!d){await Is(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(f){r.sessionId&&Ur.set(r.sessionId,f);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!h||h==="fill"){await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f}});return}const g=await hh(f);if(!g){await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f,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 b=await g.run("browser.resize",{viewport:h}),x=b&&typeof b=="object"?b.viewport??null:null;await Is(t,{ok:!0,data:{url:u,opened:!0,tabId:f,viewportApplied:!0,viewport:x}});return}const p=await mh(d);await Is(t,p?await xh(p,r,t.action,i):{ok:!1,error:bh(d)})}catch(u){await Is(t,{ok:!1,error:u instanceof Error?u.message:String(u)})}},Td=async(t,e,s,r)=>{if(!await fn(t.requestId))return;tk(e,s);const o=await mh(s);await Is(t,o?await xh(o,e,t.action,r):{ok:!1,error:bh(s)})},xh=async(t,e,s,r)=>{try{const o=await t.run(s,r);return s==="browser.snapshot"&&Object(o)===o?{ok:!0,data:{...Object(o),tabs:gh(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},Ei=()=>{Fr||(Fr=En(t=>{t.type==="browser-control-request"&&ak({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},Ti=()=>{Bs.size>0||sn.size>0||un||jn||!Fr||(Fr(),Fr=null)},lk=t=>(Bs.set(t.tabId,t),Ei(),()=>{Bs.get(t.tabId)===t&&Bs.delete(t.tabId),Ti()}),ck=t=>(sn.set(t.tabId,t),Ei(),()=>{sn.get(t.tabId)===t&&sn.delete(t.tabId),Ti()}),dk=(t,e)=>{Za=t,e&&(Qa=e)},uk=t=>(un=t,Ei(),()=>{un===t&&(un=null),Ti()}),fk=t=>(jn=t,Ei(),()=>{jn===t&&(jn=null),Ti()}),pk=50,hk=6,mk=2048,gk=200,Sh=t=>{const e=nr(String(t??"").trim());if(!e||e.length>mk)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},bk=(t,e)=>{const s=Sh(e.url);if(!s)return t;const r=t.find(a=>a.url===s),o=String(e.title??"").trim().slice(0,gk)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(a=>a.url!==s)].slice(0,pk)},yk=(t,e)=>{const s=Sh(e);return t.filter(r=>r.url!==s)},xk=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),wh=(t,e,s=hk)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((a,d)=>d.lastVisitedAt-a.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(a=>{const d=xk(a);return a.url===r||d===i?!1:d.includes(i)}).slice(0,s)},Dd=20,Po=t=>{const e=yt((t||"").trim());return e?JSON.stringify([Jt(),e]):""},Sk=t=>{const e=Object.keys(t);if(e.length<=Dd)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Dd);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},ir=to()(_w(t=>({byProject:{},recordVisit:(e,s)=>{const r=Po(e);r&&t(o=>{const i=o.byProject[r]??[],a=bk(i,{...s,at:Date.now()});return a===i?o:{byProject:Sk({...o.byProject,[r]:a})}})},forget:(e,s)=>{const r=Po(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:yk(i,s)}}:o})},clear:e=>{const s=Po(e);s&&t(r=>{if(!(s in r.byProject))return r;const o={...r.byProject};return delete o[s],{byProject:o}})}}),{name:"openchamber-browser-history",version:1,storage:Tg(),partialize:t=>({byProject:t.byProject})})),wk=[],vh=t=>e=>{const s=Po(t);return(s?e.byProject[s]:void 0)??wk},Jl=t=>{const e=Ze.c(10),{t:s}=Et();let r;e[0]!==t?(r=$s(t),e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o?(i=u=>o?u.journey?.get(o):void 0,e[2]=o,e[3]=i):i=e[3];const a=Gs(i);if(o===null)return null;if(!a){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let d;e[6]!==a.machine||e[7]!==a.placeId||e[8]!==s?(d=a.machine??(a.placeId==="docker"?s("spaces.create.place.localDocker"):a.placeId),e[6]=a.machine,e[7]=a.placeId,e[8]=s,e[9]=d):d=e[9];const c=d;return`${a.name} · ${c}`},Rd=6e3,vk=120,jk=80,kk=100,Ck=`
5
+ var MAX_ELEMENTS = ${vk};
6
+ var MAX_LABEL_CHARS = ${jk};
7
7
  var visible = function (element) {
8
8
  var rect = element.getBoundingClientRect();
9
9
  if (rect.width < 1 || rect.height < 1) return false;
@@ -117,9 +117,9 @@ ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(
117
117
  return exact || partial;
118
118
  };
119
119
  `,so=t=>`(() => {
120
- ${kk}
120
+ ${Ck}
121
121
  ${t}
122
- })()`,Ck=({selector:t}={})=>so(`
122
+ })()`,Ik=({selector:t}={})=>so(`
123
123
  var scopeSelector = ${JSON.stringify(t??"")};
124
124
  var root = document;
125
125
  if (scopeSelector) {
@@ -172,12 +172,12 @@ ${t}
172
172
  scope: scopeSelector || 'document',
173
173
  scrollY: Math.round(window.scrollY),
174
174
  maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
175
- text: text.slice(0, ${Dd}),
175
+ text: text.slice(0, ${Rd}),
176
176
  elements: elements
177
177
  };
178
178
  // State what was dropped. A capped list that reports only its own length
179
179
  // reads as the whole page, and the agent acts as if it had seen everything.
180
- if (text.length > ${Dd}) {
180
+ if (text.length > ${Rd}) {
181
181
  result.textTruncated = true;
182
182
  result.textTotalChars = text.length;
183
183
  }
@@ -186,7 +186,7 @@ ${t}
186
186
  result.interactiveElementsOnPage = visibleTotal;
187
187
  }
188
188
  return result;
189
- `),Ik=({selector:t,text:e})=>so(`
189
+ `),Pk=({selector:t,text:e})=>so(`
190
190
  var selector = ${JSON.stringify(t??"")};
191
191
  var text = ${JSON.stringify(e??"")};
192
192
  var target = null;
@@ -250,7 +250,7 @@ ${t}
250
250
  }
251
251
  fire(clicked || up, Mouse, 'click', {});
252
252
  return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
253
- `),Pk=({selector:t,value:e,submit:s})=>so(`
253
+ `),Ek=({selector:t,value:e,submit:s})=>so(`
254
254
  var selector = ${JSON.stringify(t)};
255
255
  var value = ${JSON.stringify(e)};
256
256
  var target = null;
@@ -285,7 +285,7 @@ ${t}
285
285
  if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
286
286
  }
287
287
  return { ok: true, selector: cssPath(target), url: String(location.href) };
288
- `),Ek=({selector:t,direction:e})=>so(`
288
+ `),Tk=({selector:t,direction:e})=>so(`
289
289
  var selector = ${JSON.stringify(t??"")};
290
290
  var direction = ${JSON.stringify(e??"")};
291
291
 
@@ -313,7 +313,7 @@ ${t}
313
313
  requestAnimationFrame(function () {
314
314
  requestAnimationFrame(finish);
315
315
  });
316
- setTimeout(finish, ${jk});
316
+ setTimeout(finish, ${kk});
317
317
  });
318
318
  };
319
319
 
@@ -337,7 +337,7 @@ ${t}
337
337
  else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
338
338
  else return { ok: false, error: 'Unknown scroll direction: ' + direction };
339
339
  return settle({ direction: direction });
340
- `),Tk=["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"],Dk=({selector:t})=>so(`
340
+ `),Dk=["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"],Rk=({selector:t})=>so(`
341
341
  var selector = ${JSON.stringify(t)};
342
342
  var target = null;
343
343
  try { target = document.querySelector(selector); }
@@ -346,7 +346,7 @@ ${t}
346
346
 
347
347
  var computed = window.getComputedStyle(target);
348
348
  var styles = {};
349
- var props = ${JSON.stringify(Tk)};
349
+ var props = ${JSON.stringify(Dk)};
350
350
  for (var i = 0; i < props.length; i += 1) {
351
351
  var value = computed.getPropertyValue(props[i]);
352
352
  if (value) styles[props[i]] = String(value).trim();
@@ -362,8 +362,8 @@ ${t}
362
362
  inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
363
363
  styles: styles
364
364
  };
365
- `),Rk=t=>{const e=Ze.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=Et();if(s.length===0)return null;let c;e[0]!==d?(c=d("contextPanel.browser.history.label"),e[0]=d,e[1]=c):c=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==d){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==d?(p=(h,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:Pe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(h.url)},onPointerEnter:()=>a(g),children:[n.jsx(Z,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:h.title||ii(h.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:h.url})]}),n.jsx("button",{type:"button",className:Pe("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":d("contextPanel.browser.history.forget"),title:d("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(h.url)},children:n.jsx(Z,{name:"close",className:"size-3","aria-hidden":"true"})})]},h.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=d,e[14]=p):p=e[14],u=s.map(p),e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=o,e[7]=d,e[8]=u}else u=e[8];let f;return e[15]!==c||e[16]!==u?(f=n.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":c,children:u}),e[15]=c,e[16]=u,e[17]=f):f=e[17],f},Hs=t=>{const e=Ze.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",c=a&&"text-foreground";let u;e[0]!==c?(u=Pe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=u):u=e[1];let f;e[2]!==s?(f=n.jsx(Z,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==d||e[9]!==u||e[10]!==f?(p=n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{type:"button",variant:d,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=d,e[9]=u,e[10]=f,e[11]=p):p=e[11];let h;e[12]!==r?(h=n.jsx(Kt,{sideOffset:6,children:r}),e[12]=r,e[13]=h):h=e[13];let g;return e[14]!==p||e[15]!==h?(g=n.jsxs(Ut,{children:[p,h]}),e[14]=p,e[15]=h,e[16]=g):g=e[16],g},vh=t=>{const e=Ze.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:d,onBack:c,onForward:u,onReload:f,onOpenExternal:p,canOpenExternal:h,canGoBack:g,canGoForward:b,isLoading:x,onAnnotate:y,onOpenDevTools:S,isAnnotating:m,onHardReload:v,onZoomIn:w,onZoomOut:T,onZoomReset:k,zoomPercent:I,onClearCookies:F,onClearCache:O,onToggleDeviceBar:B,isDeviceBarOpen:j}=t;let P;e[0]!==o?(P=o===void 0?[]:o,e[0]=o,e[1]=P):P=e[1];const L=P,z=h===void 0?!0:h,H=I===void 0?100:I,{t:R}=Et(),[G,_]=l.useState(!1),[$,E]=l.useState(-1);let D;e[2]!==G||e[3]!==L?(D=G?L:[],e[2]=G,e[3]=L,e[4]=D):D=e[4];const C=D;let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{E(-1)},e[5]=N):N=e[5];let A;e[6]!==s||e[7]!==G?(A=[s,G],e[6]=s,e[7]=G,e[8]=A):A=e[8],l.useEffect(N,A);let q;e[9]!==d?(q=oe=>{_(!1),E(-1),d(oe)},e[9]=d,e[10]=q):q=e[10];const ee=q;let Q;e[11]!==$||e[12]!==ee||e[13]!==C?(Q=oe=>{if(C.length!==0){if(oe.key==="ArrowDown"||oe.key==="ArrowUp"){oe.preventDefault();const tt=oe.key==="ArrowDown"?1:-1,Ue=C.length;E(gt=>{const bt=gt+tt;return bt<-1?Ue-1:bt>=Ue?-1:bt});return}if(oe.key==="Escape"&&$>=0){oe.preventDefault(),E(-1);return}if(oe.key==="Enter"&&$>=0){oe.preventDefault();const tt=C[$];tt&&ee(tt.url)}}},e[11]=$,e[12]=ee,e[13]=C,e[14]=Q):Q=e[14];const he=Q;let M;e[15]!==R?(M=R("contextPanel.browser.back"),e[15]=R,e[16]=M):M=e[16];const V=!g;let ie;e[17]!==c||e[18]!==M||e[19]!==V?(ie=n.jsx(Hs,{icon:"arrow-left",label:M,onClick:c,disabled:V}),e[17]=c,e[18]=M,e[19]=V,e[20]=ie):ie=e[20];let ce;e[21]!==R?(ce=R("contextPanel.browser.forward"),e[21]=R,e[22]=ce):ce=e[22];const ne=!b;let je;e[23]!==u||e[24]!==ce||e[25]!==ne?(je=n.jsx(Hs,{icon:"arrow-right",label:ce,onClick:u,disabled:ne}),e[23]=u,e[24]=ce,e[25]=ne,e[26]=je):je=e[26];let Ee;e[27]!==x||e[28]!==R?(Ee=R(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=R,e[29]=Ee):Ee=e[29];let we;e[30]!==f||e[31]!==Ee?(we=n.jsx(Hs,{icon:"refresh",label:Ee,onClick:f}),e[30]=f,e[31]=Ee,e[32]=we):we=e[32];let Me;e[33]!==v||e[34]!==R?(Me=v?n.jsx(Hs,{icon:"restart",label:R("contextPanel.browser.hardReload"),onClick:v}):null,e[33]=v,e[34]=R,e[35]=Me):Me=e[35];let fe;e[36]!==s||e[37]!==ee?(fe=oe=>{oe.preventDefault(),ee(s)},e[36]=s,e[37]=ee,e[38]=fe):fe=e[38];let be;e[39]!==r?(be=r?n.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:n.jsx(Z,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=be):be=e[40];let ke;e[41]!==a?(ke=oe=>a(oe.target.value),e[41]=a,e[42]=ke):ke=e[42];let Ie,Te;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>_(!0),Te=()=>_(!1),e[43]=Ie,e[44]=Te):(Ie=e[43],Te=e[44]);const Y=C.length>0,ue=r&&"ps-8";let me;e[45]!==ue?(me=Pe("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",ue,"typography-micro text-foreground outline-none"),e[45]=ue,e[46]=me):me=e[46];let re;e[47]!==R?(re=R("contextPanel.browser.addressAria"),e[47]=R,e[48]=re):re=e[48];let pe;e[49]!==s||e[50]!==he||e[51]!==ke||e[52]!==Y||e[53]!==me||e[54]!==re?(pe=n.jsx("input",{value:s,onChange:ke,onFocus:Ie,onBlur:Te,onKeyDown:he,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Y,"aria-controls":"openchamber-browser-address-suggestions",className:me,"aria-label":re}),e[49]=s,e[50]=he,e[51]=ke,e[52]=Y,e[53]=me,e[54]=re,e[55]=pe):pe=e[55];let U;e[56]!==i?(U=oe=>i?.(oe),e[56]=i,e[57]=U):U=e[57];let ae;e[58]!==$||e[59]!==ee||e[60]!==U||e[61]!==C?(ae=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(Rk,{entries:C,activeIndex:$,onSelect:ee,onForget:U,onHighlight:E})}),e[58]=$,e[59]=ee,e[60]=U,e[61]=C,e[62]=ae):ae=e[62];let Re;e[63]!==fe||e[64]!==be||e[65]!==pe||e[66]!==ae?(Re=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:fe,children:[be,pe,ae]}),e[63]=fe,e[64]=be,e[65]=pe,e[66]=ae,e[67]=Re):Re=e[67];let W;e[68]!==w||e[69]!==T||e[70]!==k||e[71]!==R||e[72]!==H?(W=T&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Hs,{icon:"subtract",label:R("contextPanel.browser.zoomOut"),onClick:T}),H!==100&&k?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsxs(Nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:k,"aria-label":R("contextPanel.browser.zoomReset"),children:[H,"%"]})}),n.jsx(Kt,{sideOffset:6,children:R("contextPanel.browser.zoomReset")})]}):null,n.jsx(Hs,{icon:"add",label:R("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=T,e[70]=k,e[71]=R,e[72]=H,e[73]=W):W=e[73];let ye;e[74]!==F||e[75]!==R?(ye=F?n.jsx(Hs,{icon:"delete-bin",label:R("contextPanel.browser.clearCookies"),onClick:F}):null,e[74]=F,e[75]=R,e[76]=ye):ye=e[76];let de;e[77]!==O||e[78]!==R?(de=O?n.jsx(Hs,{icon:"database-2",label:R("contextPanel.browser.clearCache"),onClick:O}):null,e[77]=O,e[78]=R,e[79]=de):de=e[79];let Ne;e[80]!==j||e[81]!==B||e[82]!==R?(Ne=B?n.jsx(Hs,{icon:"smartphone",label:R("contextPanel.browser.deviceToolbar"),onClick:B,pressed:j}):null,e[80]=j,e[81]=B,e[82]=R,e[83]=Ne):Ne=e[83];let Je;e[84]!==m||e[85]!==y||e[86]!==R?(Je=y?n.jsx(Hs,{icon:"markup",label:R("contextPanel.browser.annotate.toggle"),onClick:y,pressed:m}):null,e[84]=m,e[85]=y,e[86]=R,e[87]=Je):Je=e[87];let Ge;e[88]!==S||e[89]!==R?(Ge=S?n.jsx(Hs,{icon:"terminal-box",label:R("contextPanel.browser.devTools"),onClick:S}):null,e[88]=S,e[89]=R,e[90]=Ge):Ge=e[90];let ge;e[91]!==R?(ge=R("contextPanel.browser.openExternal"),e[91]=R,e[92]=ge):ge=e[92];const Ae=!z;let Ye;e[93]!==p||e[94]!==ge||e[95]!==Ae?(Ye=n.jsx(Hs,{icon:"external-link",label:ge,onClick:p,disabled:Ae}),e[93]=p,e[94]=ge,e[95]=Ae,e[96]=Ye):Ye=e[96];let nt;return e[97]!==ie||e[98]!==je||e[99]!==we||e[100]!==Me||e[101]!==Re||e[102]!==W||e[103]!==ye||e[104]!==de||e[105]!==Ne||e[106]!==Je||e[107]!==Ge||e[108]!==Ye?(nt=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ie,je,we,Me,Re,W,ye,de,Ne,Je,Ge,Ye]}),e[97]=ie,e[98]=je,e[99]=we,e[100]=Me,e[101]=Re,e[102]=W,e[103]=ye,e[104]=de,e[105]=Ne,e[106]=Je,e[107]=Ge,e[108]=Ye,e[109]=nt):nt=e[109],nt},Go={kind:"fill"},Rd=240,Nk=3840,jh=[{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}],Nd=t=>Number.isFinite(t)?Math.round(Math.min(Nk,Math.max(Rd,t))):Rd,qo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},kh=t=>{const e=jh.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Mk=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},Ak=(t,e)=>{const s=qo(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},Ok=["mobile","tablet","desktop","fill"],Bk={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Md=t=>typeof t=="string"&&Ok.includes(t),Ja=t=>t==="fill"?Go:kh(Bk[t])??Go,ao=t=>{const e=qo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=Ja(s),o=qo(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Fk=t=>{const e=Ze.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=Et();let c;e[0]!==s?(c=qo(s),e[0]=s,e[1]=c):c=e[1];const u=c,f=s.kind==="preset"?s.id:"";let p;e[2]!==r||e[3]!==u?(p=(Q,he)=>{const M=Number.parseInt(he,10);if(!Number.isFinite(M))return;const V=u??{width:1280,height:800};r({kind:"custom",width:Nd(Q==="width"?M:V.width),height:Nd(Q==="height"?M:V.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const h=p;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Pe("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=g):g=e[5];const b=g;let x;e[6]!==r?(x=Q=>{const he=kh(Q.target.value);r(he??Go)},e[6]=r,e[7]=x):x=e[7];let y;e[8]!==d?(y=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=y):y=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=Pe("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=S):S=e[10];let m;e[11]!==d?(m=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=m):m=e[12];let v;e[13]!==m?(v=n.jsx("option",{value:"",children:m}),e[13]=m,e[14]=v):v=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=jh.map(_k),e[15]=w):w=e[15];let T;e[16]!==f||e[17]!==x||e[18]!==y||e[19]!==v?(T=n.jsxs("select",{value:f,onChange:x,"aria-label":y,className:S,children:[v,w]}),e[16]=f,e[17]=x,e[18]=y,e[19]=v,e[20]=T):T=e[20];const k=u?String(u.width):"";let I;e[21]!==h?(I=Q=>h("width",Q.target.value),e[21]=h,e[22]=I):I=e[22];let F;e[23]!==d?(F=d("contextPanel.browser.device.width"),e[23]=d,e[24]=F):F=e[24];let O;e[25]!==k||e[26]!==I||e[27]!==F?(O=n.jsx("input",{value:k,onChange:I,placeholder:"—",inputMode:"numeric","aria-label":F,className:b}),e[25]=k,e[26]=I,e[27]=F,e[28]=O):O=e[28];let B;e[29]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=B):B=e[29];const j=u?String(u.height):"";let P;e[30]!==h?(P=Q=>h("height",Q.target.value),e[30]=h,e[31]=P):P=e[31];let L;e[32]!==d?(L=d("contextPanel.browser.device.height"),e[32]=d,e[33]=L):L=e[33];let z;e[34]!==j||e[35]!==P||e[36]!==L?(z=n.jsx("input",{value:j,onChange:P,placeholder:"—",inputMode:"numeric","aria-label":L,className:b}),e[34]=j,e[35]=P,e[36]=L,e[37]=z):z=e[37];let H;e[38]!==r||e[39]!==s?(H=()=>r(Mk(s)),e[38]=r,e[39]=s,e[40]=H):H=e[40];const R=!u;let G;e[41]!==d?(G=d("contextPanel.browser.device.rotate"),e[41]=d,e[42]=G):G=e[42];let _;e[43]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=_):_=e[43];let $;e[44]!==H||e[45]!==R||e[46]!==G?($=n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:H,disabled:R,"aria-label":G,children:_})}),e[44]=H,e[45]=R,e[46]=G,e[47]=$):$=e[47];let E;e[48]!==d?(E=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=E):E=e[49];let D;e[50]!==E?(D=n.jsx(Kt,{sideOffset:6,children:E}),e[50]=E,e[51]=D):D=e[51];let C;e[52]!==$||e[53]!==D?(C=n.jsxs(Ut,{children:[$,D]}),e[52]=$,e[53]=D,e[54]=C):C=e[54];let N;e[55]!==a||e[56]!==u?(N=u&&a<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=u,e[57]=N):N=e[57];let A;e[58]===Symbol.for("react.memo_cache_sentinel")?(A=["system","light","dark"],e[58]=A):A=e[58];let q;e[59]!==o||e[60]!==i||e[61]!==d?(q=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:A.map(Q=>n.jsx(Nt,{type:"button",variant:o===Q?"secondary":"ghost",size:"xs",className:Pe("shrink-0 rounded-full px-2.5 typography-micro",o===Q?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(Q),"aria-pressed":o===Q,children:d(Q==="system"?"contextPanel.browser.device.schemeSystem":Q==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},Q))}),e[59]=o,e[60]=i,e[61]=d,e[62]=q):q=e[62];let ee;return e[63]!==T||e[64]!==O||e[65]!==z||e[66]!==C||e[67]!==N||e[68]!==q?(ee=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[T,O,B,z,C,N,q]}),e[63]=T,e[64]=O,e[65]=z,e[66]=C,e[67]=N,e[68]=q,e[69]=ee):ee=e[69],ee};function _k(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Yo=new Map,el=new Set,Ch=()=>{for(const t of el)t()},fa=(t,e)=>{const s=t.trim();s&&(e.length===0?Yo.delete(s):Yo.set(s,[...e]),Ch())},Lk=t=>{Yo.delete(t.trim())&&Ch()},Ih=[],$k=t=>Yo.get(t.trim())??Ih,zk=t=>(el.add(t),()=>{el.delete(t)}),Kk=t=>{const e=Ze.c(2);let s;return e[0]!==t?(s=()=>$k(t),e[0]=t,e[1]=s):s=e[1],l.useSyncExternalStore(zk,s,Wk)};function Wk(){return Ih}const Ph="oc.browser.hiddenDevServerPorts.v1",Hk=Wr(zs(),Ci(Hp().int().positive())),tl=new Set,Eh=[];let lo=null;const ec=()=>{const t=ai().getItem(Ph);if(lo&&lo.raw===t)return lo.value;let e={};if(t!==null)try{const s=Hk.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return lo={raw:t,value:e},e},Th=t=>{ai().setItem(Ph,JSON.stringify(t));for(const e of tl)e()},Uk=(t=Jt())=>ec()[t]??Eh,Vk=t=>{const e=Jt(),s=ec(),r=s[e]??[];r.includes(t)||Th({...s,[e]:[...r,t].sort((o,i)=>o-i)})},Gk=()=>{const t=Jt(),e=ec();if(!e[t])return;const s={...e};delete s[t],Th(s)},qk=t=>(tl.add(t),()=>{tl.delete(t)}),Yk=()=>l.useSyncExternalStore(qk,Zk,Qk);function Zk(){return Uk()}function Qk(){return Eh}const Xk=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Jk=2e3,e2=t=>yf("http://localhost",t),Dh=t=>{const e=Ze.c(52),{onOpen:s,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=Et();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"loading"},e[0]=d):d=e[0];const[c,u]=l.useState(d),f=Kk(i);let p;e[1]!==i?(p=()=>e2(i),e[1]=i,e[2]=p):p=e[2];const[h]=l.useState(p);let g;e[3]!==i?(g=()=>Kb(i),e[3]=i,e[4]=g):g=e[4];const[b]=l.useState(g);let x;e[5]!==i?(x=qu(i),e[5]=i,e[6]=x):x=e[6];const y=x,S=Jl(i),m=Tg(i);let v,w;e[7]!==i||e[8]!==m||e[9]!==o?(v=()=>{if(m){u({kind:"ready",servers:[]});return}if(!o)return;let D=!0,C=null;const N=new AbortController,A=()=>{Uj(N.signal,i).then(q=>{D&&(u(q),C=setTimeout(A,Jk))})};return A(),()=>{D=!1,C&&clearTimeout(C),N.abort()}},w=[i,m,o],e[7]=i,e[8]=m,e[9]=o,e[10]=v,e[11]=w):(v=e[10],w=e[11]),l.useEffect(v,w);const T=c.kind==="ready"?c.servers:null;let k;e[12]!==f||e[13]!==T?(k=qj({announced:f,discovered:T}),e[12]=f,e[13]=T,e[14]=k):k=e[14];const I=k,F=Yk();let O;if(e[15]!==I||e[16]!==F){let D;e[18]!==F?(D=C=>C.announced||!F.includes(C.port),e[18]=F,e[19]=D):D=e[19],O=I.filter(D),e[15]=I,e[16]=F,e[17]=O}else O=e[17];const B=O,j=I.length-B.length;let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(s1,{width:110,height:110,className:"shrink-0 opacity-20"}),e[20]=P):P=e[20];let L;e[21]!==a?(L=a("contextPanel.browser.empty"),e[21]=a,e[22]=L):L=e[22];let z;e[23]!==L?(z=n.jsx("span",{className:"typography-ui-header text-foreground",children:L}),e[23]=L,e[24]=z):z=e[24];let H;e[25]!==a?(H=a("contextPanel.browser.emptyHint"),e[25]=a,e[26]=H):H=e[26];let R;e[27]!==H?(R=n.jsx("span",{className:"typography-micro text-muted-foreground",children:H}),e[27]=H,e[28]=R):R=e[28];let G;e[29]!==z||e[30]!==R?(G=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[z,R]}),e[29]=z,e[30]=R,e[31]=G):G=e[31];let _;e[32]!==f||e[33]!==I.length||e[34]!==i||e[35]!==j||e[36]!==y||e[37]!==s||e[38]!==h||e[39]!==S||e[40]!==b||e[41]!==a||e[42]!==B?(_=I.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),h&&!b?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pe-0.5",children:B.map(D=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(Nt,{type:"button",variant:"outline",size:"sm",className:Pe("min-w-0 flex-1 justify-start gap-2",h&&"cursor-default opacity-60"),"aria-disabled":h||void 0,onClick:()=>{h||(Lk(i),s(D.url))},children:[y?n.jsx("span",{className:"shrink-0",role:"img","aria-label":S??a("contextPanel.browser.spaceAddress"),title:S??a("contextPanel.browser.spaceAddress"),children:n.jsx(Z,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx(Z,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:ii(D.url)||D.url}),b?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(Z,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ms-auto truncate typography-micro text-muted-foreground",children:Xk(D.url)})]}),D.announced?null:n.jsx(Nt,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>Vk(D.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:D.port}),title:a("contextPanel.browser.devServers.hide",{port:D.port}),children:n.jsx(Z,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},D.port))}),j>0?n.jsx(Nt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:Gk,children:j===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:j}):a("contextPanel.browser.devServers.showHiddenPlural",{count:j})}):null]}):null,e[32]=f,e[33]=I.length,e[34]=i,e[35]=j,e[36]=y,e[37]=s,e[38]=h,e[39]=S,e[40]=b,e[41]=a,e[42]=B,e[43]=_):_=e[43];let $;e[44]!==I.length||e[45]!==c.kind||e[46]!==a?($=I.length===0&&c.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[44]=I.length,e[45]=c.kind,e[46]=a,e[47]=$):$=e[47];let E;return e[48]!==G||e[49]!==_||e[50]!==$?(E=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[P,G,_,$]}),e[48]=G,e[49]=_,e[50]=$,e[51]=E):E=e[51],E},t2=3e4,s2=3,n2=250,r2={attempts:0,windowStartedAt:null},o2=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=t2,r=s?0:t.attempts;return r>=s2?null:{delayMs:n2*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},i2=-3,co=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",tr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},a2=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:n1),[i,a]=l.useState(e),[d,c]=l.useState(""),[u,f]=l.useState(!1),[p,h]=l.useState(!1),g=l.useRef(s);g.current=s;const b=l.useRef(r2);return l.useEffect(()=>{if(!t)return;const x=()=>{try{const B=t.getURL();return co(B)?B:""}catch{return""}},y=()=>{try{f(t.canGoBack()),h(t.canGoForward())}catch{}},S=B=>{co(B)&&(a(B),g.current(B))},m=()=>{const B=x();o({kind:"loading",url:B})},v=()=>{const B=x();let j="";try{j=t.getTitle()||""}catch{j=""}c(j),S(B),y(),o(P=>P.kind==="failed"?P:{kind:"ready",url:B,title:j})},w=B=>{const j=tr(B);co(j.url)&&(S(j.url),y())},T=B=>{const j=tr(B),P=Array.isArray(j.favicons)?j.favicons.find(Boolean):"",L=x();if(!P||!L)return;let z=-1;try{z=t.getWebContentsId()}catch{return}!Number.isFinite(z)||z<0||th.getState().resolve(L,P,z)},k=B=>{const j=tr(B);typeof j.title=="string"&&c(j.title)},I=B=>{const j=tr(B);if(j.isMainFrame===!1)return;const P=typeof j.errorCode=="number"?j.errorCode:0;P!==i2&&o({kind:"failed",url:co(j.validatedURL)?j.validatedURL:x(),code:P,description:typeof j.errorDescription=="string"?j.errorDescription:""})};let F=null;const O=()=>{const B=x(),j=o2(b.current,Date.now());if(!j){o({kind:"failed",url:B,code:0,description:"",crashed:!0});return}b.current=j.state,o({kind:"loading",url:B}),F=setTimeout(()=>{F=null;try{t.reload()}catch{o({kind:"failed",url:B,code:0,description:"",crashed:!0})}},j.delayMs)};t.addEventListener("did-start-loading",m),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",w),t.addEventListener("did-navigate-in-page",w),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",T),t.addEventListener("did-fail-load",I),t.addEventListener("render-process-gone",O),t.addEventListener("crashed",O);try{!t.isLoading()&&x()&&v()}catch{}return()=>{F!==null&&clearTimeout(F),t.removeEventListener("render-process-gone",O),t.removeEventListener("crashed",O),t.removeEventListener("did-start-loading",m),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",w),t.removeEventListener("did-navigate-in-page",w),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",T),t.removeEventListener("did-fail-load",I)}},[t]),{status:r,url:i,title:d,canGoBack:u,canGoForward:p}},Ad=1e3,Rh=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},l2=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},c2=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},d2=(t,e)=>{const s=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const d=i.current;d&&d.isConnected&&d!==document.body?d.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=c2());const d=c=>{if(document.activeElement!==t){i.current=l2(c);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&Rh(u)&&!f||r.current>0||a()};return document.addEventListener("focusin",d,!0),()=>document.removeEventListener("focusin",d,!0)},[a,e,t]),l.useCallback(async d=>{const c=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,o.current=Date.now()+Ad,!c&&r.current===0&&a())},p=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await d(p)}finally{s.current-=1,o.current=Date.now()+Ad,f()}},[a,t])},u2=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),f2=()=>document.visibilityState==="visible",p2=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,uo=.5,h2=-3,m2=4,g2="persist:openchamber-browser",Nh=(t,e,s)=>$s(t)!==null&&Zu(e)?{icon:"box-3",label:s}:void 0,Od=t=>{const e=$s(t);return e?`openchamber-space-preview:${e}`:g2},Bd="openchamber:browser-panel-open-tab",b2=Ko({webContentsId:Hp(),url:zs().min(1),background:Ha()}),Fd=20,y2=600,x2=2e4,S2=15e3,w2=t=>{if(!t||Rh(t))return()=>{};const e=t.getBoundingClientRect(),s=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=s}},v2=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=Et(),{currentTheme:d}=br(),c=l.useRef(null),[u,f]=l.useState(null),p=l.useCallback(Ce=>{c.current=Ce,f(Ce)},[]),h=le(Ce=>Ce.setContextPanelTabTargetPath),g=l.useRef(nr(t)),b=g.current!==wn?g.current:"",[x,y]=l.useState(b?null:wn),S=Jl(s),[m,v]=l.useState(b),[w,T]=l.useState(!1),[k,I]=l.useState(!1),[F,O]=l.useState(0),B=l.useRef(0),[j,P]=l.useState(!1),[L,z]=l.useState(Go),H=l.useRef(L);H.current=L;const R=l.useRef([]),[G,_]=l.useState("system"),[$,E]=l.useState({width:0,height:0}),D=l.useRef(null),C=l.useRef(null),N=Ds(e),A=l.useRef(!!b&&!Dg(N,r)),q=l.useRef(null);l.useEffect(()=>{Yu(N,r)},[N,r]);const ee=l.useRef(!1),Q=l.useRef(Date.now()),he=l.useCallback(Ce=>{!Ce||Ce===wn||!e||!r||h(e,r,Ce)},[e,r,h]),M=a2(u,{initialUrl:b,onUrlChange:l.useCallback(Ce=>{const _e=Un(Ce);v(_e),he(_e)},[he])}),[V,ie]=l.useState(null),[ce,ne]=l.useState($s(s)===null);l.useEffect(()=>{const Ce=$s(s);if(Ce===null){ne(!0);return}let _e=!0;return ne(!1),Xn("desktop_space_preview_prepare",{spaceId:Ce}).then(()=>{_e&&ne(!0)}).catch(()=>{_e&&ie(b||"http://localhost/")}),()=>{_e=!1}},[s,b]);const je=r1(e),Ee=o1(),we=M.status.kind==="loading",Me=ir(wh(s)),fe=ir(Ce=>Ce.recordVisit),be=ir(Ce=>Ce.forget);l.useEffect(()=>{M.status.kind==="ready"&&fe(s,{url:Un(M.status.url),title:M.status.title})},[s,M.status,fe]);const ke=l.useMemo(()=>Sh(Me,m),[Me,m]),Ie=l.useCallback(Ce=>{const _e=nr(Ce);_e!==wn&&(A.current=!1,v(_e),ie(null),Ac(_e,s).then(ze=>{const Oe=c.current;if(!Oe){y(ze);return}try{Oe.loadURL(ze)}catch{y(ze)}}).catch(ze=>{ze instanceof Oc&&ie(_e)}))},[s]);l.useEffect(()=>{if(!b)return;let Ce=!0;return Ac(b,s).then(_e=>{Ce&&y(_e)}).catch(_e=>{if(Ce){if(_e instanceof Oc){ie(b),A.current=!1,y(wn);return}y(b)}}),()=>{Ce=!1}},[]);const Te=l.useMemo(()=>({executeJavaScript:async(Ce,_e)=>{const ze=c.current;if(!ze)throw new Error("Browser view is not available");return ze.executeJavaScript(Ce,_e)},capturePage:async()=>{const Ce=c.current;if(!Ce)return null;const _e=Ce.getWebContentsId();return Number.isFinite(_e)?await Xn("desktop_browser_capture_page",{webContentsId:_e}):null}}),[]),Y=l.useCallback(()=>{if(w){T(!1),Ji(Te);return}if(!M.url){He.error(a("contextPanel.browser.annotate.noPage"));return}const Ce=i1(d.metadata.variant==="light"?"light":"dark");T(!0),a1({host:Te,theme:Ce,labels:Ee}).then(async _e=>{T(!1),_e&&await je(_e)}).catch(()=>{T(!1),He.error(a("contextPanel.browser.annotate.failed"))})},[Te,je,d,w,M.url,Ee,a]);l.useEffect(()=>{if(!w)return;const Ce=_e=>{Nl(_e)||_e.key!=="Escape"||(_e.preventDefault(),_e.stopImmediatePropagation(),T(!1),Ji(Te))};return window.addEventListener("keydown",Ce,!0),()=>window.removeEventListener("keydown",Ce,!0)},[Te,w]);const ue=l.useRef(!1);l.useEffect(()=>{if(!u)return;const Ce=()=>{ue.current=!0};return u.addEventListener("dom-ready",Ce),u.addEventListener("did-fail-load",Ce),()=>{u.removeEventListener("dom-ready",Ce),u.removeEventListener("did-fail-load",Ce)}},[u]);const me=l.useCallback(async()=>{const Ce=Date.now()+S2;for(;!(c.current&&ue.current)&&Date.now()<Ce;)await new Promise(_e=>setTimeout(_e,100));return c.current},[]),re=l.useCallback(async(Ce=8e3)=>{const _e=Date.now();for(;;){const ze=c.current;if(!ze)return!1;let Oe=!1;try{Oe=ze.isLoading()}catch{return!1}if(!Oe)return!0;if(Date.now()-_e>Ce)return!1;await new Promise(it=>setTimeout(it,120))}},[]),pe=l.useCallback(async(Ce,_e,ze)=>{const Oe=await me();if(!Oe)throw new Error("The browser panel is not ready");const it=()=>{Md(_e.viewport)&&(z(Ja(_e.viewport)),P(!0))};if(Ce==="browser.back"||Ce==="browser.forward"){const dt=Ce==="browser.back";if(!(dt?Oe.canGoBack():Oe.canGoForward()))throw new Error(dt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");dt?Oe.goBack():Oe.goForward(),await new Promise(Rt=>setTimeout(Rt,150)),await re();let st="";try{st=Oe.getTitle()||""}catch{st=""}return{url:Un(Oe.getURL()),title:st}}if(Ce==="browser.capture"){const dt=w2(D.current);try{await new Promise(Rt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Rt()))}),await re();const ft=await Te.capturePage();if(!ft)throw new Error("The page could not be captured");let st="";try{st=Oe.getTitle()||""}catch{st=""}return{...ft,url:Un(Oe.getURL()),title:st,viewport:ao(H.current)}}finally{dt()}}if(Ce==="browser.resize"){if(!Md(_e.viewport))throw new Error("viewport is required");return it(),await new Promise(dt=>setTimeout(dt,200)),await re(),{viewport:ao(Ja(_e.viewport))}}if(Ce==="browser.open"){const dt=typeof _e.url=="string"?_e.url:"";if(!dt)throw new Error("url is required");it(),Ie(dt),await new Promise(Rt=>setTimeout(Rt,150));const ft=await re(25e3);let st="";try{st=Oe.getTitle()||""}catch{st=""}return{url:nr(dt),title:st,opened:!0,settled:ft,viewport:ao(H.current)}}await re();const X=dt=>typeof dt=="string"&&dt?dt:void 0,Le=(()=>{switch(Ce){case"browser.snapshot":return Ck({selector:X(_e.selector)});case"browser.click":return Ik({selector:X(_e.selector),text:X(_e.text)});case"browser.type":return Pk({selector:String(_e.selector??""),value:String(_e.value??""),submit:_e.submit===!0});case"browser.inspect":return Dk({selector:String(_e.selector??"")});case"browser.scroll":return Ek({selector:X(_e.selector),direction:X(_e.direction)});default:return null}})();if(!Le)throw new Error(`Unsupported browser action: ${Ce}`);let at=()=>{};(Ce==="browser.click"||Ce==="browser.type")&&(await Xn("desktop_browser_keep_page_focused",{webContentsId:Oe.getWebContentsId()}).then(ft=>ft.focused===!0).catch(()=>!1)||(at=ze(),Oe.focus({preventScroll:!0})));let qe;try{qe=await Oe.executeJavaScript(Le,!0)}finally{at()}if(!qe||typeof qe!="object")throw new Error("The page returned no result");const ut=qe;if(ut.ok!==!0)throw new Error(typeof ut.error=="string"&&ut.error?ut.error:"Browser action failed");if(Ce==="browser.snapshot"){const dt=R.current;return{...ut,viewport:ao(H.current),...dt.length>0?{consoleProblems:[...dt]}:{}}}return(Ce==="browser.click"||Ce==="browser.type"&&_e.submit===!0)&&(await new Promise(dt=>setTimeout(dt,150)),await re()),qe},[Te,Ie,re,me]),U=d2(u,D),[ae,Re]=l.useState(!1),W=l.useCallback((Ce,_e)=>(Re(!0),U(ze=>pe(Ce,_e,ze))),[U,pe]),ye=l.useCallback(()=>{const Ce=c.current;if(!Ce)return{title:"",url:""};let _e="",ze="";try{_e=Ce.getTitle()||""}catch{_e=""}try{ze=Un(Ce.getURL())}catch{ze=""}return{title:_e,url:ze}},[]);l.useEffect(()=>ak({tabId:r,directory:N,ownerSessionId:o,describe:ye,run:W}),[ye,o,W,N,r]),l.useEffect(()=>{const Ce=Te;return()=>{Ji(Ce)}},[Te]),l.useEffect(()=>{if(!u)return;const Ce=ze=>{const Oe=ze;if(typeof Oe.level!="number"||Oe.level<2)return;const it=Oe.sourceId?`${Oe.sourceId}${Oe.line?`:${Oe.line}`:""}`:"";R.current.push({level:Oe.level>=3?"error":"warning",message:String(Oe.message??"").slice(0,400),source:it}),R.current.length>Fd&&R.current.splice(0,R.current.length-Fd)},_e=()=>{R.current=[]};return u.addEventListener("console-message",Ce),u.addEventListener("did-start-loading",_e),()=>{u.removeEventListener("console-message",Ce),u.removeEventListener("did-start-loading",_e)}},[u]);const de=l.useRef(new Set),Ne=l.useCallback(Ce=>{de.current.clear(),Ie(Ce)},[Ie]),Je=l.useRef(M.status);Je.current=M.status;const Ge=l.useRef(!1);M.status.kind==="ready"&&M.status.url&&(Ge.current=!0),l.useEffect(()=>Rg(N,r,Ce=>{Mg(Je.current,Ge.current)&&Ne(Ce)}),[Ne,N,r]),l.useEffect(()=>{if(!u)return;const Ce=ze=>{const Oe=tr(ze),it=typeof Oe.url=="string"?Oe.url:"";!it||!Bc(it,s)||(ze.preventDefault(),Ie(it))},_e=ze=>{const Oe=tr(ze);if(Oe.isMainFrame===!1||Oe.errorCode===-3)return;const it=typeof Oe.validatedURL=="string"?Oe.validatedURL:"";!it||!Bc(it,s)||de.current.has(it)||(de.current.add(it),Ie(it))};return u.addEventListener("will-navigate",Ce),u.addEventListener("did-fail-load",_e),()=>{u.removeEventListener("will-navigate",Ce),u.removeEventListener("did-fail-load",_e)}},[s,Ie,u]),l.useEffect(()=>{if(!u)return;const Ce=_e=>{if(!(_e instanceof CustomEvent))return;const ze=b2.safeParse(_e.detail);if(!ze.success)return;let Oe=-1;try{Oe=u.getWebContentsId()}catch{return}ze.data.webContentsId===Oe&&le.getState().openContextBrowser(N,ze.data.url,{reveal:!ze.data.background})};return window.addEventListener(Bd,Ce),()=>window.removeEventListener(Bd,Ce)},[N,u]);const ge=l.useCallback(Ce=>{const _e=Math.min(m2,Math.max(h2,Ce));B.current=_e,O(_e);try{c.current?.setZoomLevel(_e)}catch{}},[]);l.useEffect(()=>{const Ce=_e=>{if(!(_e instanceof CustomEvent))return;const ze=_e.detail,Oe=c.current;!Oe||document.activeElement!==Oe||(ze==="zoom-in"?ge(B.current+uo):ze==="zoom-out"?ge(B.current-uo):ze==="zoom-reset"&&ge(0))};return window.addEventListener("openchamber:zoom",Ce),()=>window.removeEventListener("openchamber:zoom",Ce)},[ge]);const Ae=l.useCallback(Ce=>{Xn("desktop_browser_clear_data",{partition:Od(s),cookies:Ce==="cookies",cache:Ce==="cache"}).then(()=>{He.success(a(Ce==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>He.error(a("contextPanel.browser.clearFailed")))},[s,a]);l.useEffect(()=>{const Ce=D.current;if(!Ce||typeof ResizeObserver>"u")return;const _e=new ResizeObserver(ze=>{const Oe=ze[0]?.contentRect;Oe&&E({width:Oe.width,height:Oe.height})});return _e.observe(Ce),()=>_e.disconnect()},[]);const Ye=l.useCallback(Ce=>{_(Ce);const _e=c.current;if(!_e)return;let ze=-1;try{ze=_e.getWebContentsId()}catch{return}Xn("desktop_browser_set_color_scheme",{webContentsId:ze,scheme:Ce}).catch(Oe=>{_("system"),He.error(Oe instanceof Error?Oe.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),nt=l.useCallback(()=>{try{we?c.current?.stop():c.current?.reload()}catch{}},[we]),oe=M.status,tt=l.useSyncExternalStore(u2,f2),Ue=i&&tt||o!==null||ae;l.useEffect(()=>{const Ce=X=>{I(!0);const Be=setTimeout(()=>{try{c.current?.reload()}catch{}},X);return()=>clearTimeout(Be)};if(oe.kind==="loading")return;const _e=A.current||q.current===oe;if(A.current&&(oe.kind==="failed"||oe.kind==="ready"&&oe.url)&&(A.current=!1,q.current=oe),oe.kind==="failed"){const X=Ng(oe,{run:C.current,restored:_e,watched:Ue,now:Date.now()});if(C.current=X.run,X.next==="retry")return Ce(X.delayMs);I(X.next==="pause");return}if(C.current=null,oe.kind!=="ready"||!oe.url||!Zu(oe.url)){ee.current=!0,I(!1);return}if(_e||ee.current||Date.now()-Q.current>x2){ee.current=!0,I(!1);return}let ze=!1,Oe=null;return($s(s)?Promise.resolve(null):Vj(Un(oe.url))).then(X=>{if(!ze){if(X===null||X<500){ee.current=!0,I(!1);return}Oe=Ce(y2)}}),()=>{ze=!0,Oe?.()}},[s,oe,Ue]);const gt=M.status.kind==="failed"&&!k?M.status:null,bt=Ak(L,$);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(vh,{address:m,onAddressChange:v,onSubmit:Ne,suggestions:ke,onForgetSuggestion:Ce=>be(s,Ce),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:nt,onOpenExternal:()=>{xr(M.url||m)},addressMark:Nh(s,m,S??a("contextPanel.browser.spaceAddress")),canOpenExternal:$s(s)===null,canGoBack:M.canGoBack,canGoForward:M.canGoForward,isLoading:we,onAnnotate:Y,isAnnotating:w,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ge(F+uo),onZoomOut:()=>ge(F-uo),onZoomReset:()=>ge(0),zoomPercent:Math.round(Math.pow(1.2,F)*100),onClearCookies:()=>Ae("cookies"),onClearCache:()=>Ae("cache"),onToggleDeviceBar:()=>P(Ce=>!Ce),isDeviceBarOpen:j}),j?n.jsx(Fk,{viewport:L,onViewportChange:z,colorScheme:G,onColorSchemeChange:Ye,scale:bt?.scale??1}):null,n.jsxs("div",{ref:D,className:Pe("relative min-h-0 flex-1 bg-background",bt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null&&ce?n.jsx("webview",{ref:p,src:x,partition:Od(s),allowpopups:!0,style:bt?{width:`${bt.width}px`,height:`${bt.height}px`,transform:`scale(${bt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!b&&!M.url&&!we?n.jsx(Dh,{onOpen:Ne,directory:s,visible:i}):null,k?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,V?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[$s(s)!==null?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a($s(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:V})})]}):null,gt&&!V?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:gt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:gt.crashed?a("contextPanel.browser.crashedHint"):gt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,we?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},j2=t=>{const e=Ze.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=Et(),c=le(C2);let u;e[0]!==s?(u=nr(s),e[0]=s,e[1]=u):u=e[1];const f=u,p=f!==wn?f:"",[h,g]=l.useState(p);let b;e[2]!==o||e[3]!==p?(b=Qi(p,o),e[2]=o,e[3]=p,e[4]=b):b=e[4];const[x,y]=l.useState(b);let S;e[5]!==o||e[6]!==p?(S=yf(p,o)?p:"",e[5]=o,e[6]=p,e[7]=S):S=e[7];const[m,v]=l.useState(S);let w;e[8]!==o?(w=$s(o),e[8]=o,e[9]=w):w=e[9];const T=w!==null,k=Jl(o);let I;e[10]!==p?(I=p?[p]:[],e[10]=p,e[11]=I):I=e[11];const[F,O]=l.useState(I),[B,j]=l.useState(p?0:-1),[P,L]=l.useReducer(I2,0);let z,H;e[12]!==i||e[13]!==r?(z=()=>{Yu(Ds(r),i)},H=[r,i],e[12]=i,e[13]=r,e[14]=z,e[15]=H):(z=e[14],H=e[15]),l.useEffect(z,H);let R;e[16]!==c||e[17]!==i||e[18]!==r?(R=ke=>{!ke||ke===wn||!r||!i||c(r,i,ke)},e[16]=c,e[17]=i,e[18]=r,e[19]=R):R=e[19];const G=R;let _;e[20]!==o?(_=wh(o),e[20]=o,e[21]=_):_=e[21];const $=ir(_),E=ir(P2),D=ir(E2);let C;e[22]!==h||e[23]!==$?(C=Sh($,h),e[22]=h,e[23]=$,e[24]=C):C=e[24];const N=C;let A;e[25]!==o||e[26]!==B||e[27]!==G||e[28]!==E?(A=ke=>{const Ie=nr(ke);if(Ie===wn)return;g(Ie);const Te=Qi(Ie,o);y(Te),v(Te?"":Ie),G(Ie),E(o,{url:Ie}),O(Y=>{const ue=B>=0?Y.slice(0,B+1):[];return ue[ue.length-1]===Ie?(j(ue.length-1),ue):(j(ue.length),[...ue,Ie])})},e[25]=o,e[26]=B,e[27]=G,e[28]=E,e[29]=A):A=e[29];const q=A;let ee;e[30]!==o||e[31]!==F||e[32]!==G?(ee=ke=>{const Ie=F[ke];if(!Ie)return;j(ke),g(Ie);const Te=Qi(Ie,o);y(Te),v(Te?"":Ie),G(Ie)},e[30]=o,e[31]=F,e[32]=G,e[33]=ee):ee=e[33];const Q=ee;let he;e[34]!==o||e[35]!==D?(he=ke=>D(o,ke),e[34]=o,e[35]=D,e[36]=he):he=e[36];let M,V;e[37]!==Q||e[38]!==B?(M=()=>Q(B-1),V=()=>Q(B+1),e[37]=Q,e[38]=B,e[39]=M,e[40]=V):(M=e[39],V=e[40]);let ie;e[41]!==h||e[42]!==x?(ie=()=>{xr(x||h)},e[41]=h,e[42]=x,e[43]=ie):ie=e[43];let ce;e[44]!==k||e[45]!==d?(ce=k??d("contextPanel.browser.spaceAddress"),e[44]=k,e[45]=d,e[46]=ce):ce=e[46];let ne;e[47]!==h||e[48]!==o||e[49]!==ce?(ne=Nh(o,h,ce),e[47]=h,e[48]=o,e[49]=ce,e[50]=ne):ne=e[50];const je=!m,Ee=B>0,we=B>=0&&B<F.length-1;let Me;e[51]!==h||e[52]!==q||e[53]!==N||e[54]!==he||e[55]!==M||e[56]!==V||e[57]!==ie||e[58]!==ne||e[59]!==je||e[60]!==Ee||e[61]!==we?(Me=n.jsx(vh,{address:h,onAddressChange:g,onSubmit:q,suggestions:N,onForgetSuggestion:he,onBack:M,onForward:V,onReload:L,onOpenExternal:ie,addressMark:ne,canOpenExternal:je,canGoBack:Ee,canGoForward:we,isLoading:!1}),e[51]=h,e[52]=q,e[53]=N,e[54]=he,e[55]=M,e[56]=V,e[57]=ie,e[58]=ne,e[59]=je,e[60]=Ee,e[61]=we,e[62]=Me):Me=e[62];let fe;e[63]!==o||e[64]!==T||e[65]!==x||e[66]!==q||e[67]!==P||e[68]!==d||e[69]!==m||e[70]!==a?(fe=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:m?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[T?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:d(T?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:ii(m)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):x?n.jsx("iframe",{src:x,title:d("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${P}`):n.jsx(Dh,{onOpen:q,directory:o,visible:a})}),e[63]=o,e[64]=T,e[65]=x,e[66]=q,e[67]=P,e[68]=d,e[69]=m,e[70]=a,e[71]=fe):fe=e[71];let be;return e[72]!==Me||e[73]!==fe?(be=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,fe]}),e[72]=Me,e[73]=fe,e[74]=be):be=e[74],be},k2=t=>{const e=Ze.c(3),[s]=l.useState(p2);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(v2,{...t}):n.jsx(j2,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function C2(t){return t.setContextPanelTabTargetPath}function I2(t){return t+1}function P2(t){return t.recordVisit}function E2(t){return t.forget}const T2=t=>{const e=Ze.c(13),{zone:s,children:r}=t,[o]=l.useState(D2);let i;e[0]!==s?(i=h=>h.body[s],e[0]=s,e[1]=i):i=e[1];const a=Hr(i);let d,c;e[2]!==a||e[3]!==o||e[4]!==s?(d=()=>{const h=a??Hr.getState().body[s];if(!h){o.remove();return}if(o.parentElement===h)return;const g=document.activeElement;h.moveBefore&&o.isConnected?h.moveBefore(o,null):h.append(o),g instanceof HTMLElement&&o.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},c=[a,o,s],e[2]=a,e[3]=o,e[4]=s,e[5]=d,e[6]=c):(d=e[5],c=e[6]),l.useLayoutEffect(d,c);let u,f;e[7]!==o?(u=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=u,e[9]=f):(u=e[8],f=e[9]),l.useLayoutEffect(u,f);let p;return e[10]!==r||e[11]!==o?(p=gl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function D2(){const t=document.createElement("div");return t.style.display="contents",t}const R2=(t,e)=>{const s=[];let r=0;for(const[o,i]of e){const a=Math.min(Math.max(o,r),t.length),d=Math.min(Math.max(i,a),t.length);d!==a&&(a>r&&s.push({text:t.slice(r,a),matched:!1}),s.push({text:t.slice(a,d),matched:!0}),r=d)}return r<t.length&&s.push({text:t.slice(r),matched:!1}),s},N2=200,Mh=t=>`${t.path}:${t.line}:${t.column}`,_d={status:"idle"},M2=t=>{const e=Ze.c(9),{searchContents:s,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:d,active:c}=t,[u,f]=l.useState(_d);let p,h;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==d||e[6]!==s?(p=()=>{if(!c||!s||!r||!o.trim()){f(_d);return}const g=new AbortController;let b=!1;return f({status:"searching"}),s({directory:r,query:o,regex:i,limit:N2,includeHidden:a,respectGitignore:d,signal:g.signal}).then(x=>{b||f(x.status==="ok"?{status:"results",matches:x.matches,stopped:x.stopped}:x)}).catch(x=>{b||f({status:"failed",message:x instanceof Error?x.message:String(x)})}),()=>{b=!0,g.abort()}},h=[c,r,a,o,i,d,s],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=s,e[7]=p,e[8]=h):(p=e[7],h=e[8]),l.useEffect(p,h),u},On=t=>{const e=Ze.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Pe("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},A2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},O2=t=>{const e=Ze.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=Et();switch(s.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let h;e[1]!==d?(h=d("sidebarFilesTree.state.searching"),e[1]=d,e[2]=h):h=e[2];let g;return e[3]!==h?(g=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,h]}),e[3]=h,e[4]=g):g=e[4],g}case"unavailable":{let p;e[5]!==d?(p=d("sidebarFilesTree.contentSearch.unavailable"),e[5]=d,e[6]=p):p=e[6];let h;return e[7]!==p?(h=n.jsx(On,{children:p}),e[7]=p,e[8]=h):h=e[8],h}case"invalid-pattern":{let p;e[9]!==d?(p=d("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=d,e[10]=p):p=e[10];let h;e[11]!==p?(h=n.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=h):h=e[12];let g;e[13]!==s.message?(g=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=g):g=e[14];let b;return e[15]!==h||e[16]!==g?(b=n.jsxs(On,{className:"flex flex-col gap-0.5",children:[h,g]}),e[15]=h,e[16]=g,e[17]=b):b=e[17],b}case"failed":{let p;e[18]!==s.message||e[19]!==d?(p=d("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=d,e[20]=p):p=e[20];let h;return e[21]!==p?(h=n.jsx(On,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=h):h=e[22],h}}if(s.matches.length===0){let p;return e[23]!==s.stopped||e[24]!==d?(p=s.stopped==="deadline"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.deadline")}):n.jsx(On,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=d,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==s.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=h=>{const{name:g,directory:b}=A2(h.relativePath),x=Mh(h),y=r===x;return n.jsx("li",{"data-file-tree-path":h.path,children:n.jsxs("button",{type:"button",onClick:()=>o(h),onDoubleClick:()=>o(h,{pin:!0}),draggable:!!i,onDragStart:i?S=>i(S,h):void 0,onDragEnd:a?S=>a(S,h):void 0,className:Pe("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",_l(y)),title:`${h.relativePath}:${h.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(mi,{filePath:h.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:g}),b?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${b}‎`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:h.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[h.cutStart?"…":null,R2(h.text,h.ranges).map(B2)]})]})},x)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=s.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=s.matches,e[31]=c}else c=e[31];let u;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==d?(u=s.stopped==="limit"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=d,e[40]=u):u=e[40];let f;return e[41]!==c||e[42]!==u?(f=n.jsxs(n.Fragment,{children:[c,u]}),e[41]=c,e[42]=u,e[43]=f):f=e[43],f};function B2(t,e){return t.matched?n.jsx("mark",{className:"rounded-[2px] bg-primary/25 text-foreground",children:t.text},e):n.jsx(l.Fragment,{children:t.text},e)}const sl=2e4,F2=(t,e)=>{if(!t)return 1;let s=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(s+=1,s>e))return s;return s},fo=(t,e)=>Ag(Og.getState().dictionary,t,e),_2=t=>{const s=(t instanceof Error?t.message:String(t??"")).toLowerCase();return s.includes("file not found")||s.includes("not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")?"missing":"unreadable"},L2=async(t,e,s)=>{const r=!!(s?.directory&&!f1(e,s.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory,allowOutsideWorkspace:r})).content??"";const o=new URLSearchParams({path:e,optional:"true"});s?.directory&&o.set("directory",s.directory),r&&o.set("allowOutsideWorkspace","true");const i=await Ys(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const a=await i.json().catch(()=>({error:i.statusText}));throw new Error(a.error||"Failed to read file")}return i.text()},Ld=async(t,e,s)=>{if(l1(e)||c1(e)||d1(e))return{ok:!0};try{const r=await L2(t,e,s);return u1(r)?{ok:!1,reason:"binary"}:F2(r,sl)>sl?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:_2(r)}}},$d=t=>{if(t==="too-large"){const e=sl.toLocaleString(np());return fo("contextFileOpen.failure.tooLarge",{count:e})}return fo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},zd=8;let Vr=null;const Ah=(t,e)=>Math.abs(e.clientX-t.x)<=zd&&Math.abs(e.clientY-t.y)<=zd,nl=t=>{Vr={x:t.clientX,y:t.clientY}},rl=t=>{const e=Vr;return Vr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Ah(e,t)},Oh=t=>Vr!==null&&Ah(Vr,t);let Bh=null;const pa=t=>{Bh=t},Fh=()=>Bh,Kd=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},_h=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Kd(e.path);return!r||Kd(t.path)===r||t.type==="directory"&&Bg(r,t.path,t.path)!==null?null:r},$2=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},z2=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const c of e[a]??[]){const u=c.type==="directory"&&s.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:d,isExpanded:u}),!u)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:d+1,message:f}),i(c.path,d+1)}};return i(t,0),o},K2=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},W2=28,ar=t=>Array.from(t.types).includes("Files"),_r=t=>Array.from(t.types).includes($r)?Fh():null,Lh=(t,e,s)=>t.getData($r)===Di(e,s.path),H2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},U2=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),hs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Di=(t,e)=>{const s=hs(e),r=hs(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},jr=(t,e)=>{const s=Di(t,e);if(s!==".")return s;const r=hs(t);return r.split("/").filter(Boolean).pop()??r},Eo=t=>{const e=hs(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},V2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),G2=new Set(["node_modules"]),q2=t=>G2.has(t),Y2=t=>{const e=hs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Z2=8,tn=new Map,tc=t=>JSON.stringify([Jt(),t]),Q2=t=>{const e=tc(t),s=tn.get(e);return s?(s.touchedAt=Date.now(),tn.delete(e),tn.set(e,s),s):null},ha=t=>{const e=tc(t),s=tn.get(e);if(s)return s.touchedAt=Date.now(),s;if(tn.size>=Z2){const o=tn.keys().next().value;o!==void 0&&tn.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return tn.set(e,r),r},X2=t=>{const e=Ze.c(127),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:d,isOpen:c,status:u,badge:f,isDropTarget:p,isDragSource:h,canUpload:g,canMove:b,permissions:x,downloadFile:y,onSelect:S,onToggle:m,onRevealPath:v,onOpenDialog:w,onSetDropTarget:T,onDropFiles:k,onPickFiles:I,onMoveDragChange:F,onSetMoveDropTarget:O,onMoveDrop:B}=t,{t:j}=Et(),P=s.type==="directory";let L;e[0]!==P||e[1]!==s.path?(L=P?s.path:Eo(s.path),e[0]=P,e[1]=s.path,e[2]=L):L=e[2];const z=L,{canRename:H,canCreateFile:R,canCreateFolder:G,canDelete:_,canReveal:$}=x,E=!P&&!!y,D=$&&!a,C=P&&g,N=H||R||G||C||_||E||D,[A,q]=l.useState(!1),[ee,Q]=l.useState(!1);let he;e[3]!==N?(he=Oe=>{N&&(Oe?.preventDefault(),Q(!0))},e[3]=N,e[4]=he):he=e[4];const M=he;let V;e[5]!==P||e[6]!==s||e[7]!==S||e[8]!==m?(V=()=>{P?m(s.path):S(s)},e[5]=P,e[6]=s,e[7]=S,e[8]=m,e[9]=V):V=e[9];const ie=V;let ce;e[10]!==P||e[11]!==s||e[12]!==S?(ce=()=>{P||S(s,{pin:!0})},e[10]=P,e[11]=s,e[12]=S,e[13]=ce):ce=e[13];const ne=ce;let je;e[14]===Symbol.for("react.memo_cache_sentinel")?(je=Oe=>{Oe.stopPropagation(),Q(!1),q(!0)},e[14]=je):je=e[14];const Ee=je;let we;e[15]!==R||e[16]!==G||e[17]!==_||e[18]!==H||e[19]!==D||e[20]!==C||e[21]!==y||e[22]!==a||e[23]!==P||e[24]!==s||e[25]!==w||e[26]!==I||e[27]!==v||e[28]!==j?(we=Oe=>{const{Item:it,Separator:X}=Oe;return n.jsxs(n.Fragment,{children:[H&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("rename",s)},children:[n.jsx(Z,{name:"edit",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.rename")]}),n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),pi(s.path).then(Le=>{if(Le.ok){He.success(j("sidebarFilesTree.toast.pathCopied"));return}He.error(j("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Z,{name:"file-copy",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.copyPath")]}),!P&&y&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),y(s.path).catch(Le=>{console.error("Download failed:",Le),He.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"download",className:"me-2 h-4 w-4"})," ",j(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),D&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),v(s.path)},children:[n.jsx(Z,{name:"folder-received",className:"me-2 h-4 w-4"})," ",j(ip())]}),!P&&D&&li()&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),Fg(s.path).then(Le=>{Le||He.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"external-link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.openInDefaultApp")]}),P&&(R||G||C)&&n.jsxs(n.Fragment,{children:[n.jsx(X,{}),R&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("createFile",s)},children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFile")]}),G&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("createFolder",s)},children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFolder")]}),C&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),I(s.path)},children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.uploadFiles")]})]}),_&&n.jsxs(n.Fragment,{children:[n.jsx(X,{}),n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.delete")]})]})]})},e[15]=R,e[16]=G,e[17]=_,e[18]=H,e[19]=D,e[20]=C,e[21]=y,e[22]=a,e[23]=P,e[24]=s,e[25]=w,e[26]=I,e[27]=v,e[28]=j,e[29]=we):we=e[29];const Me=we;let fe;e[30]!==b||e[31]!==s.path||e[32]!==s.type||e[33]!==F||e[34]!==r?(fe=Oe=>{nl(Oe);const it=Di(r,s.path);!it||it==="."||(Oe.dataTransfer.setData($r,it),Oe.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&F({path:s.path,type:s.type}))},e[30]=b,e[31]=s.path,e[32]=s.type,e[33]=F,e[34]=r,e[35]=fe):fe=e[35];const be=fe;let ke;e[36]!==b||e[37]!==ie||e[38]!==F?(ke=Oe=>{b&&F(null),rl(Oe)&&ie()},e[36]=b,e[37]=ie,e[38]=F,e[39]=ke):ke=e[39];const Ie=ke;let Te;e[40]!==g||e[41]!==T||e[42]!==z?(Te=Oe=>{!g||!z||!ar(Oe.dataTransfer)||(Oe.preventDefault(),Oe.stopPropagation(),Oe.dataTransfer.dropEffect="copy",T(z))},e[40]=g,e[41]=T,e[42]=z,e[43]=Te):Te=e[43];const Y=Te;let ue;e[44]!==g||e[45]!==T||e[46]!==z?(ue=Oe=>{!g||!z||!ar(Oe.dataTransfer)||Oe.relatedTarget instanceof Node&&Oe.currentTarget.contains(Oe.relatedTarget)||(Oe.stopPropagation(),T(null))},e[44]=g,e[45]=T,e[46]=z,e[47]=ue):ue=e[47];const me=ue;let re;e[48]!==g||e[49]!==k||e[50]!==z?(re=Oe=>{!g||!z||!ar(Oe.dataTransfer)||(Oe.preventDefault(),Oe.stopPropagation(),k(z,Oe.dataTransfer))},e[48]=g,e[49]=k,e[50]=z,e[51]=re):re=e[51];const pe=re;let U;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(U=(Oe,it)=>Oh(Oe)?null:_h(it,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=U):U=e[55];const ae=U;let Re;e[56]!==b||e[57]!==ae||e[58]!==Y||e[59]!==O?(Re=Oe=>{const it=b?_r(Oe.dataTransfer):null;if(!it){Y(Oe);return}Oe.stopPropagation();const X=ae(Oe,it);O(X),X&&(Oe.preventDefault(),Oe.dataTransfer.dropEffect="move")},e[56]=b,e[57]=ae,e[58]=Y,e[59]=O,e[60]=Re):Re=e[60];const W=Re;let ye;e[61]!==b||e[62]!==ae||e[63]!==pe||e[64]!==B||e[65]!==O||e[66]!==r?(ye=Oe=>{const it=b?_r(Oe.dataTransfer):null;if(!it){pe(Oe);return}Oe.stopPropagation(),Oe.preventDefault(),O(null);const X=ae(Oe,it);X&&Lh(Oe.dataTransfer,r,it)&&B(it,X)},e[61]=b,e[62]=ae,e[63]=pe,e[64]=B,e[65]=O,e[66]=r,e[67]=ye):ye=e[67];const de=ye;let Ne;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ne={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ne):Ne=e[68];let Je;e[69]!==M||e[70]!==me||e[71]!==W||e[72]!==de?(Je=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ne,onContextMenu:M,onDragEnter:W,onDragOver:W,onDragLeave:me,onDrop:de}),e[69]=M,e[70]=me,e[71]=W,e[72]=de,e[73]=Je):Je=e[73];let Ge;e[74]!==d?(Ge=n.jsx(ap,{depth:d}),e[74]=d,e[75]=Ge):Ge=e[75];let ge;e[76]!==i||e[77]!==h||e[78]!==p?(ge=Pe("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":_l(i),h&&"opacity-50"),e[76]=i,e[77]=h,e[78]=p,e[79]=ge):ge=e[79];let Ae;e[80]!==d?(Ae=$l(d),e[80]=d,e[81]=Ae):Ae=e[81];let Ye;e[82]!==Ae?(Ye={paddingInlineStart:Ae},e[82]=Ae,e[83]=Ye):Ye=e[83];let nt;e[84]!==P||e[85]!==o||e[86]!==s.extension||e[87]!==s.path?(nt=P?n.jsx(eo,{expanded:o}):n.jsx(mi,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=P,e[85]=o,e[86]=s.extension,e[87]=s.path,e[88]=nt):nt=e[88];let oe;e[89]!==s.name||e[90]!==s.path?(oe=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[89]=s.name,e[90]=s.path,e[91]=oe):oe=e[91];let tt;e[92]!==P||e[93]!==c||e[94]!==u?(tt=!P&&n.jsx(p1,{isOpen:c,status:u}),e[92]=P,e[93]=c,e[94]=u,e[95]=tt):tt=e[95];let Ue;e[96]!==f||e[97]!==P?(Ue=P&&f&&n.jsx(h1,{badge:f}),e[96]=f,e[97]=P,e[98]=Ue):Ue=e[98];let gt;e[99]!==M||e[100]!==ne||e[101]!==Ie||e[102]!==be||e[103]!==ie||e[104]!==ge||e[105]!==Ye||e[106]!==nt||e[107]!==oe||e[108]!==tt||e[109]!==Ue?(gt=n.jsxs("button",{type:"button",onClick:ie,onDoubleClick:ne,onContextMenu:M,draggable:!0,onDragStart:be,onDragEnd:Ie,className:ge,style:Ye,children:[nt,oe,tt,Ue]}),e[99]=M,e[100]=ne,e[101]=Ie,e[102]=be,e[103]=ie,e[104]=ge,e[105]=Ye,e[106]=nt,e[107]=oe,e[108]=tt,e[109]=Ue,e[110]=gt):gt=e[110];let bt;e[111]!==A||e[112]!==N||e[113]!==Me||e[114]!==j?(bt=N&&n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(Rs,{open:A,onOpenChange:q,children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Ee,title:j("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":j("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Z,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:j("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Ms,{align:"end",side:"bottom",onCloseAutoFocus:()=>q(!1),children:Me({Item:rs,Separator:In})})]})}),e[111]=A,e[112]=N,e[113]=Me,e[114]=j,e[115]=bt):bt=e[115];let Ce;e[116]!==Je||e[117]!==Ge||e[118]!==gt||e[119]!==bt?(Ce=n.jsxs(zl,{render:Je,children:[Ge,gt,bt]}),e[116]=Je,e[117]=Ge,e[118]=gt,e[119]=bt,e[120]=Ce):Ce=e[120];let _e;e[121]!==Me?(_e=n.jsx(Ll,{className:"min-w-[180px]",children:Me({Item:$n,Separator:wo})}),e[121]=Me,e[122]=_e):_e=e[122];let ze;return e[123]!==ee||e[124]!==Ce||e[125]!==_e?(ze=n.jsxs(Zr,{open:ee,onOpenChange:Q,children:[Ce,_e]}),e[123]=ee,e[124]=Ce,e[125]=_e,e[126]=ze):ze=e[126],ze},J2=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,eC=l.memo(X2,J2),tC=t=>{const e=Ze.c(14),{visible:s}=t,r=s===void 0?!0:s,o=Cn(nC),i=Nn()??"",a=Yr();let d,c,u,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=fi(a,i)??"",a?.kind==="preparing"){let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(So,{}),e[7]=h):h=e[7],f=h;break e}d=sC,u=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=f}else d=e[3],c=e[4],u=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==d||e[9]!==c||e[10]!==i||e[11]!==u||e[12]!==r?(p=n.jsx(d,{visible:r,currentDirectory:c,panelDirectory:i},u),e[8]=d,e[9]=c,e[10]=i,e[11]=u,e[12]=r,e[13]=p):p=e[13],p},sC=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=l.useRef(t);r.current=t;const{t:o}=Et(),{files:i,runtime:a}=Ks(),d=_g(a.platform),c=hs(e.trim()),u=hs(s.trim()),f=tc(c),p=Lg(),h=$g(),g=zg(K=>K.searchFiles),b=le(K=>K.openContextFile),x=hi(t?e:null),[y,S]=l.useState(""),m=m1(y,200),v=l.useRef(null),[w,T]=l.useState([]),[k,I]=l.useState(!1),F=!!i.searchContents,[O,B]=l.useState("names"),[j,P]=l.useState(!1),L=F&&O==="contents",z=M2({searchContents:i.searchContents,directory:e,query:m,regex:j,includeHidden:p,respectGitignore:!h,active:t&&L}),H=le(K=>K.openContextFileAtLine),[R,G]=l.useState(null),[_,$]=l.useState(null),[E,D]=l.useState(null),[C,N]=l.useState(null),[A,q]=l.useState(null),{hasTouchOnlyPointer:ee}=Rn(),Q=!!(i.rename&&c)&&!ee,he=le(K=>K.confirmFileTreeMove),M=le(K=>K.setConfirmFileTreeMove),[V,ie]=l.useState({}),[ce,ne]=l.useState({}),je=l.useRef(new Set),Ee=l.useRef(new Map),we=l.useMemo(()=>new _w,[]);l.useEffect(()=>()=>we.clear(),[we]);const Me=l.useRef(null);l.useEffect(()=>{if($(null),N(null),q(null),!c){ie({}),ne({}),je.current=new Set;return}const K=Q2(c);K?(ie({...K.childrenByDir}),ne({...K.loadErrorsByDir}),je.current=new Set(K.loadedDirs)):(ie({}),ne({}),je.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.childrenByDir=V},[c,V]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.loadErrorsByDir=ce},[c,ce]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.loadedDirs=new Set(je.current)},[c,V,ce]),l.useEffect(()=>()=>{if(!c)return;const K=tn.get(f);K&&K.loadedDirs.size===0&&Object.keys(K.childrenByDir).length===0&&tn.delete(f)},[f,c]);const fe=l.useMemo(()=>[],[]),be=l.useMemo(()=>[],[]),ke=Vs(K=>c?K.byRoot[c]?.expandedPaths??fe:fe),Ie=l.useMemo(()=>new Set(ke),[ke]),Te=Vs(K=>c?K.byRoot[c]?.selectedPath??null:null),Y=Vs(K=>K.setSelectedPath),ue=l.useRef(null);l.useEffect(()=>{ue.current=Te},[Te]);const me=Vs(K=>K.addOpenPath),re=Vs(K=>K.removeOpenPathsByPrefix),pe=Vs(K=>K.toggleExpandedPath),U=Vs(K=>K.expandPath),ae=Vs(K=>K.collapseAllExpandedPaths),Re=le(K=>u?K.contextPanelByDirectory[u]?.tabs??be:be),W=l.useMemo(()=>new Set(Re.map(K=>K.mode==="file"?K.targetPath:null).filter(K=>typeof K=="string"&&K.length>0).map(K=>hs(K))),[Re]),[ye,de]=l.useState(null),[Ne,Je]=l.useState(null),[Ge,ge]=l.useState(""),[Ae,Ye]=l.useState(!1),nt=!!i.writeFile,oe=!!i.createDirectory,tt=!!i.rename,Ue=!!i.delete,gt=!!i.revealPath,bt=l.useMemo(()=>({canRename:tt,canCreateFile:nt,canCreateFolder:oe,canDelete:Ue,canReveal:gt}),[tt,nt,oe,Ue,gt]),Ce=l.useCallback(K=>{i.revealPath&&i.revealPath(K).catch(()=>{He.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),_e=l.useCallback((K,xe)=>{de(K),Je(xe),ge(K==="rename"&&xe.name||""),Ye(!1)},[]),ze=l.useCallback((K,xe)=>{const Xe=xe.filter(lt=>lt&&typeof lt.name=="string"&&lt.name.length>0).filter(lt=>p||!lt.name.startsWith(".")).filter(lt=>h||!q2(lt.name)).map(lt=>{const Bt=lt.name,Pt=hs(lt.path||""),Gt=Pt?V2(Pt)?Pt:hs(`${K}/${Pt}`):hs(`${K}/${Bt}`),Ft=lt.isDirectory?"directory":"file",Wt=Ft==="file"&&Bt.includes(".")?Bt.split(".").pop()?.toLowerCase():void 0;return{name:Bt,path:Gt,type:Ft,extension:Wt}});return U2(Xe)},[h,p]),Oe=l.useCallback(async(K,xe,Xe=!1)=>{if(!r.current||xe?.())return;const lt=hs(K.trim());if(!lt||!Xe&&je.current.has(lt))return;const Bt=Jt();return we.run(lt,async Pt=>{const Gt=()=>!Pt()||Jt()!==Bt;try{const Ft=!h,Wt=i.listDirectory?(await i.listDirectory(lt,{respectGitignore:Ft})).entries:await Mo.listLocalDirectory(lt,{respectGitignore:Ft});if(Gt())return;Ee.current.set(lt,Wt.length);const qt=ze(lt,Wt);je.current=new Set(je.current),je.current.add(lt),ne(vs=>{if(!vs[lt])return vs;const ds={...vs};return delete ds[lt],ds}),ie(vs=>vs[lt]&&Lw(vs[lt],qt)?vs:{...vs,[lt]:qt})}catch(Ft){if(Gt())return;const Wt=Ft instanceof Error?Ft.message:String(Ft??"");console.error("Failed to load sidebar directory:",Ft),ne(qt=>({...qt,[lt]:Wt}))}},Xe)},[we,i,ze,h]),it=l.useCallback(async()=>{if(!c)return;Me.current?.abort();const K=new AbortController;Me.current=K,we.clear();try{const Xe=(Vs.getState().byRoot[c]?.expandedPaths??[]).map(Pt=>hs(Pt)).filter(Pt=>!!Pt&&Pt!==c&&Pt.startsWith(`${c}/`)),lt=[c,...Xe];je.current=new Set(je.current);for(const Pt of lt)je.current.delete(Pt);ne(Pt=>{if(Object.keys(Pt).length===0)return Pt;const Gt={...Pt};let Ft=!1;for(const Wt of lt)Wt in Gt&&(delete Gt[Wt],Ft=!0);return Ft?Gt:Pt});const Bt=()=>K.signal.aborted;await Oe(c,Bt);for(let Pt=0;Pt<Xe.length&&!K.signal.aborted;Pt+=3){const Gt=Xe.slice(Pt,Pt+3);await Promise.all(Gt.map(Ft=>Oe(Ft,Bt)))}}catch(xe){if(K.signal.aborted)return;console.error("Failed to refresh sidebar tree:",xe)}finally{Me.current===K&&(Me.current=null)}},[we,Oe,c]),X=l.useCallback(async K=>{if(!K){await it();return}const xe=hs(K);je.current=new Set(je.current),je.current.delete(xe),await Oe(xe,void 0,!0)},[Oe,it]);l.useEffect(()=>{c&&(Me.current?.abort(),je.current=new Set,we.clear(),ne({}),ie(K=>Object.keys(K).length===0?K:{}),Oe(c))},[we,Oe,c,p,h]),l.useEffect(()=>{if(!t||!c||ke.length===0)return;const K=ke.map(lt=>hs(lt)).filter(lt=>!!lt&&lt!==c&&lt.startsWith(`${c}/`)&&!je.current.has(lt)&&!we.has(lt)).sort((lt,Bt)=>lt.split("/").length-Bt.split("/").length);if(K.length===0)return;let xe=!1;const Xe=()=>xe;return(async()=>{for(let lt=0;lt<K.length&&!xe;lt+=3){const Bt=K.slice(lt,lt+3);await Promise.all(Bt.map(Pt=>Oe(Pt,Xe)))}})(),()=>{xe=!0}},[we,ke,Oe,c,t]);const Be=l.useRef(t);l.useEffect(()=>{const K=t&&!Be.current;Be.current=t,K&&it()},[it,t]);const Le=l.useCallback(({directories:K})=>{if(!c)return;const xe=new Set((Vs.getState().byRoot[c]?.expandedPaths??[]).map(Wt=>hs(Wt))),Xe=c==="/"?"/":`${c}/`,lt=Wt=>{for(let qt=Wt;qt!==c;qt=Eo(qt))if(!qt.startsWith(Xe)||!xe.has(qt))return!1;return!0},Bt=Wt=>{for(let qt=Wt;qt===c||qt.startsWith(Xe);qt=Eo(qt)){if(je.current.has(qt))return qt;if(qt===c)break}return null},Pt=new Set,Gt=new Set;for(const Wt of K??je.current){const qt=Bt(hs(Wt));qt&&(lt(qt)?Pt:Gt).add(qt)}Gt.size>0&&(je.current=new Set([...je.current].filter(Wt=>!Gt.has(Wt))));const Ft=[...Pt].filter(Wt=>(Ee.current.get(Wt)??0)<=Wb);(async()=>{for(let Wt=0;Wt<Ft.length;Wt+=3)await Promise.all(Ft.slice(Wt,Wt+3).map(qt=>Oe(qt,void 0,!0)))})()},[Oe,c]);Hb({root:c,active:t,whileInactive:"drop",onChanges:Le}),l.useEffect(()=>{if(!t)return;if(!e||L){T([]),I(!1);return}const K=m.trim();if(!K){T([]),I(!1);return}let xe=!1;return I(!0),g(e,K,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(Xe=>{if(xe)return;const Bt=Xe.filter(Pt=>h||!Y2(Pt.path)).map(Pt=>({name:Pt.name,path:hs(Pt.path),type:"file",extension:Pt.extension,relativePath:Pt.relativePath}));T(Bt)}).catch(()=>{xe||T([])}).finally(()=>{xe||I(!1)}),()=>{xe=!0}},[L,e,m,g,p,h,t]);const at=l.useMemo(()=>{const K=new Map;if(!x?.files)return K;for(const xe of x.files)xe.index==="A"||xe.working_dir==="?"?K.set(xe.path,"git-added"):xe.index==="D"?K.set(xe.path,"git-deleted"):(xe.index==="M"||xe.working_dir==="M")&&K.set(xe.path,"git-modified");return K},[x]),qe=l.useMemo(()=>{const K=new Map;if(!x?.files||!c)return K;for(const xe of x.files){const Xe=xe.index==="M"||xe.working_dir==="M",lt=xe.index==="A"||xe.working_dir==="?";if(!Xe&&!lt)continue;const Bt=xe.path.split("/");if(Bt.length<=1)continue;let Pt=c;for(let Gt=0;Gt<Bt.length-1;Gt++){Pt=`${Pt}/${Bt[Gt]}`;let Ft=K.get(Pt);Ft||(Ft={modified:0,added:0},K.set(Pt,Ft)),Xe&&Ft.modified++,lt&&Ft.added++}}return K},[x,c]),ut=l.useCallback(K=>{if(at.size===0)return null;const xe=K.startsWith(c+"/")?K.slice(c.length+1):K;return at.get(xe)??null},[at,c]),dt=l.useCallback(K=>{if(qe.size===0)return null;const xe=qe.get(K);return xe&&xe.modified+xe.added>0?xe:null},[qe]),ft=l.useCallback(async(K,xe)=>{if(!c)return;const Xe=await Ld(i,K.path,{directory:c});if(!Xe.ok){He.error($d(Xe.reason));return}Y(c,K.path),me(c,K.path),b(u,K.path,{preview:!xe?.pin&&!le.getState().isMobile})},[me,i,b,u,c,Y]),st=l.useCallback(async(K,xe)=>{if(!c)return;const Xe=await Ld(i,K.path,{directory:c});if(!Xe.ok){He.error($d(Xe.reason));return}Y(c,K.path),me(c,K.path),G({path:K.path,key:Mh(K)}),H(u,K.path,K.line,K.column,{preview:!xe?.pin&&!le.getState().isMobile})},[me,i,H,u,c,Y]),Rt=l.useCallback((K,xe)=>{nl(K),pa(null),K.dataTransfer.setData($r,xe.relativePath),K.dataTransfer.effectAllowed="copy"},[]),Ke=l.useCallback((K,xe)=>{rl(K)&&st(xe)},[st]),jt=l.useCallback(async K=>{const xe=hs(K);c&&(pe(c,xe),je.current.has(xe)||await Oe(xe))},[Oe,c,pe]),{canUpload:Lt,uploadingDirectory:Mt,uploadFiles:De,pickFiles:Tt,uploadElements:At}=Ub({root:c,refreshDirectory:X}),kt=Mt!==null,pt=Mt??_,Dt=l.useCallback((K,xe)=>{const Xe=H2(xe);Xe.length!==0&&($(null),De(K,Xe))},[De]),Ve=l.useCallback(K=>{if(pa(K),!K){D(null),N(null);return}requestAnimationFrame(()=>{Fh()?.path===K.path&&D(K.path)})},[]),rt=l.useCallback(async(K,xe)=>{const Xe=$2(K,xe),lt=await id(i,{tabs:u,files:c},K.path,Xe);if(lt==="conflict"){He.error(o("sidebarFilesTree.toast.nameTaken",{name:Xe.slice(Xe.lastIndexOf("/")+1),folder:jr(c,xe)}));return}if(lt==="failed"){He.error(o("sidebarFilesTree.toast.operationFailed"));return}xe!==c&&U(c,xe),await Promise.all([X(Eo(K.path)),X(xe)]).catch(()=>{})},[U,i,u,X,c,o]),wt=l.useCallback((K,xe)=>{if(le.getState().confirmFileTreeMove){q({source:K,targetDirectory:xe});return}rt(K,xe)},[rt]),se=l.useCallback(()=>{A&&(q(null),rt(A.source,A.targetDirectory))},[rt,A]),Fe=l.useCallback((K,xe)=>!Q||Oh(K)?null:_h(xe,null,c),[Q,c]),ot=l.useCallback(K=>{const xe=_r(K.dataTransfer);if(xe){const Xe=Fe(K,xe);if(N(Xe),!Xe)return;K.preventDefault(),K.dataTransfer.dropEffect="move";return}!Lt||kt||!c||!ar(K.dataTransfer)||(K.preventDefault(),K.dataTransfer.dropEffect="copy",$(c))},[Lt,Fe,kt,c]),$e=l.useCallback(K=>{if(!(K.relatedTarget instanceof Node&&K.currentTarget.contains(K.relatedTarget))){if(_r(K.dataTransfer)){N(null);return}ar(K.dataTransfer)&&$(null)}},[]),Ct=l.useCallback(K=>{const xe=_r(K.dataTransfer);if(xe){K.preventDefault(),N(null);const Xe=Fe(K,xe);Xe&&Lh(K.dataTransfer,c,xe)&&wt(xe,Xe);return}!Lt||kt||!c||!ar(K.dataTransfer)||(K.preventDefault(),Dt(c,K.dataTransfer))},[Lt,Fe,Dt,wt,kt,c]),Yt=l.useCallback(async K=>{if(K?.preventDefault(),!Ne||!ye)return;Ye(!0);const xe=()=>Ye(!1),Xe=()=>de(null);if(ye==="createFile"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.filenameRequired")),xe();return}if(!i.writeFile){He.error(o("sidebarFilesTree.toast.writeNotSupported")),xe();return}const lt=Ne.path,Bt=lt?`${lt}/`:"",Pt=hs(`${Bt}${Ge.trim()}`);await i.writeFile(Pt,"").then(async Gt=>{Gt.success&&(He.success(o("sidebarFilesTree.toast.fileCreated")),await X(lt)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}if(ye==="createFolder"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.folderNameRequired")),xe();return}const lt=Ne.path,Bt=lt?`${lt}/`:"",Pt=hs(`${Bt}${Ge.trim()}`);await i.createDirectory(Pt).then(async Gt=>{Gt.success&&(He.success(o("sidebarFilesTree.toast.folderCreated")),await X(lt)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}if(ye==="rename"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.nameRequired")),xe();return}if(!i.rename){He.error(o("sidebarFilesTree.toast.renameNotSupported")),xe();return}const lt=Ne.path,Bt=lt.split("/").slice(0,-1).join("/"),Pt=Bt?`${Bt}/`:"",Gt=Ge.trim(),Ft=hs(`${Pt}${Gt}`);try{const Wt=await id(i,{tabs:u,files:c},lt,Ft);Wt==="moved"?(He.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await X(Bt),Xe()):Wt==="conflict"?He.error(o("sidebarFilesTree.toast.nameTaken",{name:Gt,folder:jr(c,Bt)})):He.error(o("sidebarFilesTree.toast.operationFailed"))}catch{He.error(o("sidebarFilesTree.toast.operationFailed"))}finally{xe()}return}if(ye==="delete"){if(!i.delete){He.error(o("sidebarFilesTree.toast.deleteNotSupported")),xe();return}const lt=Ne.path,Bt=lt.split("/").slice(0,-1).join("/");await i.delete(lt).then(async Pt=>{Pt.success&&(He.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await X(Bt),c&&re(c,lt),(Te===lt||Te&&Te.startsWith(lt+"/"))&&Y(c,null)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}xe()},[ye,Ne,Ge,i,u,X,re,c,Te,Y,o]),es=l.useMemo(()=>c?z2({root:c,childrenByDir:V,expandedPaths:Ie,loadErrorsByDir:ce}):[],[V,Ie,ce,c]),Zt=l.useMemo(()=>new Map(es.flatMap((K,xe)=>K.kind==="node"?[[K.node.path,xe]]:[])),[es]),[ss,bs]=l.useState(null),[ls,ms]=l.useState(null),[fs,Es]=l.useState(null),cs=l.useMemo(()=>[E,fs].flatMap(K=>K?[Zt.get(K)??-1]:[]),[fs,E,Zt]),Qe=l.useCallback(K=>K2(Vp(K),cs,es.length),[cs,es.length]),[vt,$t]=l.useState(0);l.useLayoutEffect(()=>{if(!ss||!ls)return;const K=ls.getBoundingClientRect().top-ss.getBoundingClientRect().top+ss.scrollTop;$t(Math.max(0,Math.round(K)))},[ls,ss]);const ve=Up({count:es.length,enabled:ss!==null,getScrollElement:()=>ss,estimateSize:()=>W2,getItemKey:K=>es[K]?.key??K,overscan:12,scrollMargin:vt,rangeExtractor:Qe}),ct=K=>{if(K.kind==="error")return n.jsxs("div",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:$l(K.depth)},children:[n.jsx(ap,{depth:K.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:K.message,children:K.message}),n.jsxs(Nt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{X(K.directory)},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:xe,depth:Xe,isExpanded:lt}=K,Bt=xe.type==="directory";return n.jsx(eC,{node:xe,root:c,isExpanded:lt,isActive:Te===xe.path,isBrowserClient:d,depth:Xe,isOpen:!Bt&&W.has(xe.path),status:Bt?void 0:ut(xe.path),badge:Bt?dt(xe.path):void 0,isDropTarget:Bt&&(pt===xe.path||C===xe.path),isDragSource:E===xe.path,canUpload:Lt&&!kt,canMove:Q,permissions:bt,downloadFile:i.downloadFile,onSelect:ft,onToggle:jt,onRevealPath:Ce,onOpenDialog:_e,onSetDropTarget:$,onDropFiles:Dt,onPickFiles:Tt,onMoveDragChange:Ve,onSetMoveDropTarget:N,onMoveDrop:wt})},ht=l.useCallback(K=>{const xe=K.target instanceof Element?K.target.closest("[data-tree-row-path]"):null;Es(xe?.dataset.treeRowPath??null)},[]),Ot=l.useCallback(K=>{K.relatedTarget instanceof Node&&K.currentTarget.contains(K.relatedTarget)||Es(null)},[]);l.useEffect(()=>{const K=ue.current;if(!K||!ss||!ls)return;const xe=Zt.get(K);xe===void 0||ss.offsetParent===null||(ue.current=null,ve.scrollToIndex(xe,{align:"auto"}))});const te=!!(c&&V[c]),et=c?ce[c]:null,xt=m.trim().length>0,It=!k&&!xt&&w.length===0&&!et&&te&&!!c,St=pt?jr(c,pt):"",Se=C?jr(c,C):"",We=A?A.source.path.slice(A.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col border-b border-border/40",children:[n.jsxs("div",{className:"flex h-8 shrink-0 items-center justify-end gap-1 border-t border-border/40 px-2",children:[nt||oe||Lt?n.jsxs(Rs,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":o("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Z,{name:kt?"loader-4":"add",className:Pe("h-4 w-4",kt&&"animate-spin")})})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Ms,{align:"end",className:"min-w-[180px]",children:[nt?n.jsxs(rs,{onClick:()=>_e("createFile",{path:e,type:"directory"}),children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,oe?n.jsxs(rs,{onClick:()=>_e("createFolder",{path:e,type:"directory"}),children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,Lt?n.jsxs(rs,{disabled:!c||kt,onClick:()=>Tt(c),children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx($w,{className:"size-6"}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>{it()},className:"size-6 p-0 flex-shrink-0",title:o("sidebarFilesTree.actions.refreshTitle"),"aria-label":o("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Z,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>{c&&ae(c)},className:"size-6 p-0 flex-shrink-0",title:o("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":o("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Z,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[F?n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsxs(Nt,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[n.jsx(Z,{name:L?"file-search":"search",className:"h-4 w-4"}),n.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),n.jsx(Ms,{align:"start",side:"bottom",children:n.jsxs(Jf,{value:O,onValueChange:K=>B(K==="contents"?"contents":"names"),children:[n.jsxs(Lo,{value:"names",closeOnClick:!0,className:"items-center",children:[n.jsx(Z,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(Lo,{value:"contents",closeOnClick:!0,className:"items-center",children:[n.jsx(Z,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(Z,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(_o,{ref:v,value:y,onChange:K=>S(K.target.value),placeholder:o(L?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Pe("h-8 ps-8 typography-meta",L?"pe-16":"pe-8")}),L?n.jsx(Nt,{variant:"chip",size:"xs","aria-pressed":j,onClick:()=>{P(K=>!K),v.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,y.trim().length>0?n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Pe("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",L?"inset-e-10":"inset-e-4"),onClick:()=>{S(""),v.current?.focus()},children:n.jsx(Z,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(Qr,{ref:bs,outerClassName:"h-full min-h-0",className:Pe("px-1.5 py-1.5 [overflow-anchor:none]",(pt===c||C===c)&&"bg-interactive-selection/10"),onDragEnter:ot,onDragOver:ot,onDragLeave:$e,onDrop:Ct,children:[n.jsx("ul",{className:"flex flex-col",children:L&&z.status!=="idle"?n.jsx(O2,{state:z,activeMatchKey:R&&R.path===Te?R.key:null,onOpen:st,onDragStart:Rt,onDragEnd:Ke}):k?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):xt&&w.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):w.length>0?w.map(K=>{const xe=Te===K.path;return n.jsx("li",{"data-file-tree-path":K.path,children:n.jsxs("button",{type:"button",onClick:()=>ft(K),onDoubleClick:()=>ft(K,{pin:!0}),draggable:!0,onDragStart:Xe=>{nl(Xe),pa(null);const lt=K.relativePath||Di(c??"",K.path);!lt||lt==="."||(Xe.dataTransfer.setData($r,lt),Xe.dataTransfer.effectAllowed="copy")},onDragEnd:Xe=>{rl(Xe)&&ft(K)},className:Pe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",_l(xe)),title:K.path,children:[n.jsx(mi,{filePath:K.path,extension:K.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${K.relativePath??K.path}‎`})]})},K.path)}):et?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:et}),n.jsxs(Nt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{it()},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):te&&c?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),It?n.jsx("ul",{ref:ms,className:"relative",style:{height:ve.getTotalSize()},onFocus:ht,onBlur:Ot,children:ve.getVirtualItems().map(K=>{const xe=es[K.index];if(!xe)return null;const Xe=xe.kind==="node"?xe.node.path:void 0;return n.jsx("li",{ref:ve.measureElement,"data-index":K.index,"data-tree-row-path":Xe,"data-file-tree-path":xe.kind==="node"&&xe.node.type==="file"?Xe:void 0,className:"absolute inset-x-0 top-0",style:{transform:`translateY(${K.start-vt}px)`},children:ct(xe)},K.key)})}):null]}),pt?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:kt?"loader-4":"folder-received",className:Pe("size-4 flex-shrink-0",kt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:St,children:o(kt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:St})})]}):C?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Se,children:o("sidebarFilesTree.drop.moveTarget",{path:Se})})]}):null]}),At,n.jsx(Qs,{open:!!ye,onOpenChange:K=>!K&&de(null),children:n.jsxs(Zs,{children:[n.jsxs(on,{children:[n.jsxs(nn,{children:[ye==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),ye==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),ye==="rename"&&o("sidebarFilesTree.dialog.rename.title"),ye==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(rn,{children:[ye==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ne?.path??o("sidebarFilesTree.dialog.rootFallback")}),ye==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ne?.path??o("sidebarFilesTree.dialog.rootFallback")}),ye==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ne?.name??""}),ye==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ne?.name??""})]})]}),ye!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(_o,{value:Ge,onChange:K=>ge(K.target.value),placeholder:o(ye==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:K=>{K.key==="Enter"&&Yt()},autoFocus:!0})}),n.jsxs(Pn,{children:[n.jsx(Nt,{variant:"outline",onClick:()=>de(null),disabled:Ae,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(Nt,{variant:ye==="delete"?"destructive":"default",onClick:()=>{Yt()},disabled:Ae||ye!=="delete"&&!Ge.trim(),children:Ae?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):o(ye==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(Qs,{open:A!==null,onOpenChange:K=>{K||q(null)},children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(rn,{children:A?o("sidebarFilesTree.dialog.move.description",{name:We,folder:jr(c,A.targetDirectory)}):null})]}),n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>M(!he),children:[n.jsx(g1,{checked:!he,onChange:K=>M(!K),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:()=>q(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(Nt,{onClick:se,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function nC(t){return t.runtimeKey}const rC=Xr(()=>as(()=>import("./WalkthroughView-CECS5lDs.js"),__vite__mapDeps([124,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,125,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,84,126,86,115,116,117,118,119,120,127,128,121])).then(t=>({default:t.WalkthroughView}))),oC=Xr(()=>as(()=>import("./DiffView-Be1Xoy_F.js"),__vite__mapDeps([129,1,2,4,5,6,7,8,9,125,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,83,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,84,130,86,115,116,117,118,119,120,126,122,123])).then(t=>({default:t.DiffView}))),iC=Xr(()=>as(()=>import("./FilesView-DONPk8-K.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,83,132,133,134,135,123,84,136,118,137,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,138,139,140,141,119,120,117,142,143])).then(t=>({default:t.FilesView}))),$h=l.lazy(()=>as(()=>import("./useAppFontEffects-d9vsRNKm.js").then(t=>t.oR),__vite__mapDeps([3,1,2,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])).then(t=>({default:t.PluginPane}))),Wd=l.lazy(()=>as(()=>import("./GuestSurfacePane-Cot0OO7x.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.GuestSurfacePane}))),zh={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-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},aC=t=>{const e=Ze.c(12),{mode:s,docking:r}=t,[o,i]=l.useState(null),a=zh[r.dock],d=Math.max(S1,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==a.page||e[1]!==c?(u=Pe("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=u):u=e[2];let f;e[3]!==a.vertical||e[4]!==d?(f=a.vertical?{height:d}:{width:d},e[3]=a.vertical,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==s?(p=n.jsx($h,{mode:s,onResize:i}),e[6]=s,e[7]=p):p=e[7];let h;return e[8]!==u||e[9]!==f||e[10]!==p?(h=n.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=h):h=e[11],h},Zn=(t,e)=>`${t}\0${e}`,lC=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=Et(),i=le(v=>v.contextEditorTreeWidth),a=le(v=>v.setContextEditorTreeWidth),[d,c]=l.useState(!1),u=l.useRef(0),f=l.useRef(i),p=l.useRef(null),h=l.useRef(null),g=l.useRef(null),b=l.useCallback(v=>{const w=g.current;w&&(w.style.width=`${v}px`,w.style.setProperty("--oc-editor-tree-width",`${v}px`))},[]),x=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}h.current=v.pointerId,c(!0),u.current=v.clientX,f.current=i,p.current=i,v.preventDefault()}},y=v=>{if(!d||h.current!==v.pointerId)return;const w=r==="left"?v.clientX-u.current:u.current-v.clientX,T=ni(v.currentTarget)?-w:w,k=Ia(f.current+T);p.current!==k&&(p.current=k,b(k))},S=v=>{if(h.current!==v.pointerId)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const w=Ia(p.current??i);h.current=null,p.current=null,c(!1),a(w)},m=t?i:0;return n.jsxs("div",{ref:g,className:Pe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?p.current??m:m}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${d?p.current??i:i}px`,overflowX:"clip",transitionProperty:d?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Pe("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Pe("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",d&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:y,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Pe("relative z-10 h-full shrink-0 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-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(tC,{visible:t&&e})})]})},Bn=t=>{const e=Ze.c(18),{zone:s,isOpen:r,interactive:o,hidden:i,directoryKey:a,className:d,children:c}=t,u=le(dC);let f;e[0]!==u||e[1]!==a||e[2]!==r||e[3]!==s?(f=S=>{sh(S,r,()=>{a&&u(a,s)},S.currentTarget.closest("[data-context-zone]"))},e[0]=u,e[1]=a,e[2]=r,e[3]=s,e[4]=f):f=e[4];const p=f,h=!r||i;let g;e[5]!==c||e[6]!==h?(g=n.jsx(lp,{paused:h,children:c}),e[5]=c,e[6]=h,e[7]=g):g=e[7];let b;e[8]!==o||e[9]!==g?(b=n.jsx(op.Provider,{value:!0,children:n.jsx(Yb.Provider,{value:o,children:g})}),e[8]=o,e[9]=g,e[10]=b):b=e[10];let x;e[11]!==d||e[12]!==p||e[13]!==b?(x=n.jsx("div",{className:d,onKeyDownCapture:p,children:b}),e[11]=d,e[12]=p,e[13]=b,e[14]=x):x=e[14];let y;return e[15]!==x||e[16]!==s?(y=n.jsx(T2,{zone:s,children:x}),e[15]=x,e[16]=s,e[17]=y):y=e[17],y},cC=()=>{const{t}=Et(),e=Nn()??"",s=l.useMemo(()=>e?Ds(e):"",[e]),r=le(U=>s?U.contextPanelByDirectory[s]:void 0),o=Yr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=fi(o,e)??"",c=le(U=>U.contextSurfaceZones),u=le(U=>U.contextPanelByDirectory),f=le(U=>U.closeContextPanelTab),p=le(U=>U.closeContextFile),h=le(U=>U.openContextPanelTab),g=le(U=>U.openAgentBrowserTab),b=le(U=>U.openContextFile),x=le(U=>U.contextEditorTreeVisible),y=le(U=>U.contextEditorVisible),S=le(U=>U.fileTreeSide),m=Vs(U=>U.setSelectedPath),v=Hr(U=>U.headerSlot),w=l.useMemo(()=>r?.tabs??[],[r?.tabs]),T=Oa(U=>U.chatCovered),k=l.useMemo(()=>{const U=ae=>{const Re=r?Ro(r,c,ae):null,W=ae==="bottom"&&T;return{activeTab:Re,isOpen:!!(r&&oi(r,ae).isOpen&&Re)&&!W}};return{left:U("left"),right:U("right"),bottom:U("bottom")}},[T,r,c]),I={left:Co(k.left.isOpen),right:Co(k.right.isOpen),bottom:Co(k.bottom.isOpen)},F=U=>!I[U],O={left:Or(k.left.isOpen),right:Or(k.right.isOpen),bottom:Or(k.bottom.isOpen)},B={left:xo(k.left.isOpen,O.left,k.left.activeTab?.mode),right:xo(k.right.isOpen,O.right,k.right.activeTab?.mode),bottom:xo(k.bottom.isOpen,O.bottom,k.bottom.activeTab?.mode)},j=U=>{const ae=Ao(c,U);return{zone:ae,...k[ae]}},P=j("file"),L=j("chat"),z=j("browser"),H=j("diff"),R=j("terminal"),G=j("walkthrough"),[_,$]=l.useState([]),E=l.useCallback((U,ae)=>{$(Re=>Kg(Re,Zn(U,ae)))},[]),D=le(U=>U.liveBrowserTabLimit);l.useEffect(()=>dk((U,ae)=>{const Re=ae.directory?Ds(ae.directory):s;if(!Re)return null;const W=g(Re,U,ae.sessionId);return W&&E(Re,W),W}),[s,g,E]),l.useEffect(()=>uk((U,ae)=>le.getState().contextPanelByDirectory[U]?.tabs?.some(W=>W.id===ae&&W.mode==="browser")?(f(U,ae),!0):!1),[f]),l.useEffect(()=>En(U=>{if(U.type!=="file-open-request")return;const ae=U.directory??e;ae&&b(ae,U.path)}),[e,b]),l.useEffect(()=>En(U=>{if(U.type!=="plan-open-request")return;const ae=U.directory??e,Re=Vb(ae,U.projectId);!ae||!Re||le.getState().openProjectKnowledgePlan(ae,b1(Re),U.planId)}),[e]);const C=z.activeTab?.mode==="browser"?z.activeTab.id:null;l.useEffect(()=>{ck(s,C)},[s,C]);const N=P.activeTab;l.useEffect(()=>{if(!d||N?.mode!=="file"||!N.targetPath)return;const U=$s(N.targetPath)===$s(d);m(Ds(d),N.targetPath,{allowOutsideRoot:!o&&U})},[d,o,N,m]);const A=l.useMemo(()=>w.some(U=>U.mode==="file"&&U.targetPath),[w]),q=l.useMemo(()=>w.some(U=>U.mode==="file"),[w]),ee=A&&(y||!x),Q=P.activeTab?.mode==="file",he=l.useCallback(U=>{s&&p(s,U)},[p,s]),M=L.isOpen&&L.activeTab?.mode==="chat"?L.activeTab:null,V=M?Pi(M.dedupeKey):null,ie=l.useMemo(()=>(M?.targetDirectory?Ds(M.targetDirectory):"")||s||null,[M?.targetDirectory,s]),ce=l.useMemo(()=>V?{sessionId:V,directory:ie}:null,[V,ie]);l.useEffect(()=>{if(!ie||!V||typeof window>"u")return;const U=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ea(ie,V,!1);return}cp(V),ea(ie,V,!0)};U();const ae=window.setInterval(U,1e4);return window.addEventListener("focus",U),window.addEventListener("blur",U),document.addEventListener("visibilitychange",U),()=>{window.clearInterval(ae),window.removeEventListener("focus",U),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",U),ea(ie,V,!1)}},[ie,V]);const ne=H.activeTab,je=l.useCallback(U=>{!s||ne?.mode!=="diff"||h(s,{mode:"diff",targetPath:ne.targetPath,targetDirectory:ne.targetDirectory,stagedDiff:U==="staged",diffScope:U})},[ne,s,h]),Ee=z.isOpen&&z.activeTab?.mode==="browser"?z.activeTab.id:null;l.useEffect(()=>{Ee&&s&&E(s,Ee)},[s,Ee,E]);const{loadedBrowserTabs:we,sleepingBrowserTabs:Me}=l.useMemo(()=>{const U=new Set(_),ae=new Set;for(const[de,Ne]of Object.entries(u))for(const Je of Ne.tabs)Je.mode==="browser"&&Je.ownerSessionId===null&&ae.add(Zn(de,Je.id));const Re=Wg(_,ae,D),W=[],ye=[];for(const[de,Ne]of Object.entries(u)){const Je=de===s;for(const Ge of Ne.tabs){if(Ge.mode!=="browser")continue;const ge=Zn(de,Ge.id),Ae=Ge.ownerSessionId===null,Ye=Je&&Ge.id===Ee||(Ae?Re.has(ge):U.has(ge));if(!Ye&&!Je&&Ae)continue;const nt={directory:de,id:Ge.id,targetPath:Ge.targetPath,ownerSessionId:Ge.ownerSessionId};(Ye?W:ye).push(nt)}}return W.sort((de,Ne)=>Zn(de.directory,de.id)<Zn(Ne.directory,Ne.id)?-1:1),{loadedBrowserTabs:W,sleepingBrowserTabs:ye}},[u,s,D,_,Ee]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const U=Me.map(ae=>lk({tabId:ae.id,directory:ae.directory,ownerSessionId:ae.ownerSessionId,describe:()=>({title:"",url:ae.targetPath??""}),wake:()=>E(ae.directory,ae.id)}));return()=>U.forEach(ae=>ae())},[Me,E]);const fe=l.useMemo(()=>w.filter(U=>U.mode==="diff"),[w]),be=l.useMemo(()=>w.find(U=>U.mode==="terminal")??null,[w]),ke=l.useMemo(()=>w.find(U=>U.mode==="walkthrough")??null,[w]),Ie=l.useMemo(()=>w.filter(U=>dr(U.mode)),[w]),Te=Dl(U=>U.guests),Y=l.useMemo(()=>new Set(Te.filter(y1).map(U=>U.id)),[Te]),ue=l.useMemo(()=>{const U=new Map;for(const ae of Te){const Re=x1(ae);Re&&U.set(ae.id,Re)}return U},[Te]),me=R.zone,re=l.useCallback(U=>{const ae=Ql({mode:"terminal",label:t("layout.mainTab.terminal"),from:me},U);return{finish:()=>ae.finish(s),cancel:ae.cancel}},[s,t,me]),pe=(U,ae)=>ae?v[U]:null;return n.jsxs(n.Fragment,{children:[q?n.jsxs(Bn,{zone:P.zone,interactive:B[P.zone],isOpen:P.isOpen,hidden:F(P.zone),directoryKey:s,className:Pe("absolute inset-0 flex",S==="left"&&"flex-row-reverse",Q?"flex":"hidden"),children:[i?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(So,{})}):A||!x?n.jsx("div",{className:Pe("h-full min-w-0 flex-1",A&&!ee&&"hidden"),children:A?n.jsx(l.Suspense,{fallback:null,children:n.jsx(iC,{mode:"editor-only",visible:!F(P.zone)&&Q&&ee,onCloseFile:he})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(Z,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:n.jsx(lC,{visible:x,active:P.isOpen&&Q,fill:!ee,side:S})]}):null,M&&V&&ce?n.jsx(Bn,{zone:L.zone,interactive:B[L.zone],isOpen:L.isOpen,hidden:F(L.zone),directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:V}),className:"h-full",children:n.jsx(xf,{pinnedSession:ce,readOnly:M.readOnly})})},M.id):null,we.map(U=>{const ae=U.directory===s&&z.activeTab?.id===U.id,Re=U.directory===s?a??U.directory:U.directory;return n.jsx(Bn,{zone:z.zone,interactive:B[z.zone],isOpen:z.isOpen,hidden:F(z.zone),directoryKey:s,className:Pe("absolute inset-0",!ae&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!ae||void 0,children:n.jsx(lp,{paused:!ae,children:U.directory===s&&i?n.jsx(So,{}):n.jsx(k2,{initialUrl:U.targetPath??"",directory:U.directory,siteDirectory:Re,tabID:U.id,ownerSessionId:U.ownerSessionId,visible:ae&&z.isOpen},Re)})})},Zn(U.directory,U.id))}),fe.map(U=>{const ae=H.activeTab?.id===U.id;return n.jsx(Bn,{zone:H.zone,interactive:B[H.zone],isOpen:H.isOpen,hidden:F(H.zone),directoryKey:s,className:Pe("absolute inset-0",!ae&&"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:pe(H.zone,ae),children:i&&!U.targetDirectory?n.jsx(So,{}):n.jsx(oC,{directory:U.targetDirectory??a,visible:H.isOpen&&ae,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:U.diffScope??(U.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:U.targetPath,flushContent:!0})})})},U.id)}),be?n.jsx(Bn,{zone:R.zone,interactive:B[R.zone],isOpen:R.isOpen,hidden:F(R.zone),directoryKey:s,className:Pe("absolute inset-0",R.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(rr,{value:pe(R.zone,R.activeTab?.mode==="terminal"),children:n.jsx(Gb.Provider,{value:re,children:n.jsx(qb,{visible:R.isOpen&&R.activeTab?.mode==="terminal",directory:be.targetDirectory,onLastTabClosed:()=>{s&&f(s,be.id)}})})})}):null,ke?n.jsx(Bn,{zone:G.zone,interactive:B[G.zone],isOpen:G.isOpen,hidden:F(G.zone),directoryKey:s,className:Pe("absolute inset-0",G.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:pe(G.zone,G.activeTab?.mode==="walkthrough"),children:n.jsx(rC,{directory:ke.targetDirectory??e,visible:G.isOpen&&G.activeTab?.mode==="walkthrough"})})})}):null,Ie.map(U=>{if(!dr(U.mode))return null;const ae=j(U.mode),Re=No(U.mode),W=Y.has(Re),ye=ue.get(Re),de=ae.activeTab?.id===U.id,Ne=de&&ae.isOpen;return W&&!ye&&!Ne?null:n.jsx(Bn,{zone:ae.zone,interactive:B[ae.zone],isOpen:ae.isOpen,hidden:F(ae.zone),directoryKey:s,className:Pe("absolute inset-0",de?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:W?ye?n.jsxs("div",{className:Pe("flex h-full",zh[ye.dock].container),children:[n.jsx(aC,{mode:U.mode,docking:ye}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ne?n.jsx(Wd,{mode:U.mode}):null})]}):n.jsx(Wd,{mode:U.mode}):n.jsx($h,{mode:U.mode})})},U.id)})]})};function dC(t){return t.closeContextZone}const uC={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},fC=()=>{const t=Ze.c(20),{t:e}=Et(),s=gn(pC),r=gn(hC),o=l.useRef(null),[i,a]=l.useState(!1);let d,c;t[0]!==s?(d=()=>{if(!s){a(!1);return}const S=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(S)},c=[s],t[0]=s,t[1]=d,t[2]=c):(d=t[1],c=t[2]),l.useEffect(d,c);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const S=m=>{const v=o.current;v&&(v.style.transform=`translate(${m.clientX+12}px, ${m.clientY+12}px)`)};return window.addEventListener("pointermove",S),()=>window.removeEventListener("pointermove",S)},f=[s],t[3]=s,t[4]=u,t[5]=f):(u=t[4],f=t[5]),l.useEffect(u,f),!s)return null;const p=i?"opacity-100":"opacity-0";let h;t[6]!==p?(h=Pe("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=h):h=t[7];let g;t[8]!==h?(g=n.jsx("div",{className:h}),t[8]=h,t[9]=g):g=t[9];let b;t[10]!==s.frames||t[11]!==r||t[12]!==e?(b=Qu.map(S=>{const m=s.frames[S];if(m.width<=0||m.height<=0)return null;const v=r===S;return n.jsx("div",{className:Pe("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",v?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:m.left,top:m.top,width:m.width,height:m.height},children:n.jsx("span",{className:"typography-ui-label",children:e(uC[S])})},S)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let x;t[14]!==s.label?(x=n.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:s.label}),t[14]=s.label,t[15]=x):x=t[15];let y;return t[16]!==g||t[17]!==b||t[18]!==x?(y=gl.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,b,x]}),document.body),t[16]=g,t[17]=b,t[18]=x,t[19]=y):y=t[19],y};function pC(t){return t.drag}function hC(t){return t.hovered}const Hd=400,mC=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=Hd)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Hd)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:s)>0?d:null}},gC=()=>{const t=Ze.c(5),e=Nn();let s;t[0]!==e?(s=e?Ds(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(!r)return;const d=y=>{const S=y.contextPanelByDirectory[r];return{left:Dr(S,y.contextSurfaceZones,"left"),right:Dr(S,y.contextSurfaceZones,"right")}},c=(y,S,m)=>{const v=y.contextPanelByDirectory[r],w=m&&v?Ro(v,y.contextSurfaceZones,S):null;return w?v?.widthByMode[w.mode]??Ca(w.mode):0};let u=null,f=!1,p=d(le.getState());const h=y=>{f=!0,le.getState().setSidebarOpen(y),f=!1},g=o.current;g&&!p[g]&&(o.current=null,le.getState().isSidebarOpen||h(!0));const b=(y,S,m)=>{const v=document.querySelector("[data-workspace-row]")?.clientWidth;if(!v)return;const w=mC({rowWidth:v,leftWidth:c(y,"left",m.left),rightWidth:c(y,"right",m.right),sidebarWidth:y.isSidebarOpen?y.sidebarWidth:null,opening:S});if(w.displace){const T=oi(y.contextPanelByDirectory[r],w.displace).activeTabId;T&&(u={side:w.displace,by:S,tabId:T})}w.collapseSidebar&&(o.current=S,h(!1)),w.displace&&y.closeContextZone(r,w.displace)},x=y=>{if(u?.side===y){o.current===y&&(o.current=u.by);return}const S=u?.by===y?u:null;S&&(u=null),o.current===y&&(S?o.current=S.side:(o.current=null,le.getState().isSidebarOpen||h(!0))),S&&le.getState().setActiveContextPanelTab(r,S.tabId)};return le.subscribe((y,S)=>{y.isSidebarOpen!==S.isSidebarOpen&&!f&&(o.current=null);const m=d(y),v=p;p=m;const w=["left","right"],T=w.filter(I=>m[I]&&!v[I]),k=w.filter(I=>!m[I]&&v[I]);for(const I of k){const F=I==="left"?"right":"left";T.includes(F)&&(o.current===I&&(o.current=F),u?.by===I&&(u=null))}for(const I of k)x(I);for(const I of T)b(y,I,m)})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null},bC=t=>{const e=Ze.c(53),{open:s,onOpenChange:r}=t,{t:o}=Et(),i=le(yC),a=le(xC),d=le(SC),c=le(wC),u=le(vC),f=Fl();let p;e[0]!==i||e[1]!==f?(p=Xu(i,f),e[0]=i,e[1]=f,e[2]=p):p=e[2];const h=p,g=d.length===0;let b;if(e[3]!==d||e[4]!==h){let _;e[6]!==d?(_=$=>d.includes($.id),e[6]=d,e[7]=_):_=e[7],b=h.every(_),e[3]=d,e[4]=h,e[5]=b}else b=e[5];const x=b,y=l.useRef(!1);let S;if(e[8]!==d||e[9]!==h||e[10]!==o){let _;e[12]!==d||e[13]!==o?(_=$=>({id:$.id,label:$.label??o($.labelKey),visible:!d.includes($.id)}),e[12]=d,e[13]=o,e[14]=_):_=e[14],S=h.map(_),e[8]=d,e[9]=h,e[10]=o,e[11]=S}else S=e[11];const m=S;let v;e[15]!==i||e[16]!==a?(v=_=>{const $=new Set(_);a([..._,...i.filter(E=>!$.has(E))])},e[15]=i,e[16]=a,e[17]=v):v=e[17];const w=v;let T;e[18]!==r?(T=(_,$)=>{if(!_&&$.reason==="escape-key"&&y.current){$.cancel(),$.allowPropagation();return}y.current=!1,r(_)},e[18]=r,e[19]=T):T=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=_=>{y.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(_.key)&&_.preventBaseUIHandler()},e[20]=k):k=e[20];let I;e[21]!==o?(I=o("contextRail.configure.dialogTitle"),e[21]=o,e[22]=I):I=e[22];let F;e[23]!==I?(F=n.jsx(nn,{children:I}),e[23]=I,e[24]=F):F=e[24];let O;e[25]!==o?(O=o("contextRail.configure.dialogDescription"),e[25]=o,e[26]=O):O=e[26];let B;e[27]!==O?(B=n.jsx(rn,{children:O}),e[27]=O,e[28]=B):B=e[28];let j;e[29]!==B||e[30]!==F?(j=n.jsxs(on,{children:[F,B]}),e[29]=B,e[30]=F,e[31]=j):j=e[31];let P;e[32]!==o?(P=o("contextRail.configure.dragInstructions"),e[32]=o,e[33]=P):P=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=_=>{y.current=_},e[34]=L):L=e[34];let z;e[35]!==w||e[36]!==m||e[37]!==c||e[38]!==P?(z=n.jsx(Zb,{items:m,onVisibleChange:c,onReorder:w,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:P,onDraggingChange:L}),e[35]=w,e[36]=m,e[37]=c,e[38]=P,e[39]=z):z=e[39];let H;e[40]!==g||e[41]!==x||e[42]!==u||e[43]!==o?(H=g?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(Nt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[40]=g,e[41]=x,e[42]=u,e[43]=o,e[44]=H):H=e[44];let R;e[45]!==j||e[46]!==z||e[47]!==H?(R=n.jsxs(Zs,{className:"max-w-md",onKeyDown:k,children:[j,z,H]}),e[45]=j,e[46]=z,e[47]=H,e[48]=R):R=e[48];let G;return e[49]!==s||e[50]!==R||e[51]!==T?(G=n.jsx(Qs,{open:s,onOpenChange:T,children:R}),e[49]=s,e[50]=R,e[51]=T,e[52]=G):G=e[52],G};function yC(t){return t.contextRailOrder}function xC(t){return t.setContextRailOrder}function SC(t){return t.contextRailHiddenSurfaces}function wC(t){return t.setContextRailSurfaceVisible}function vC(t){return t.setContextRailHiddenSurfaces}const jC=t=>{const e=sp(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},kC=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Kh=()=>{const t=Ze.c(4),e=mt(PC),s=mt(EC)??void 0,r=v1(e??"",s,jC,kC),{context:o}=j1(e,s),i=o>0?o:k1;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a},Ud=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),cn=18,ol=2,il=(cn-ol)/2,Vd=2*Math.PI*il,CC=t=>{const e=Ze.c(8),{className:s}=t,{fill:r,limit:o}=Kh(),i=r?.state==="measured"?Math.min(100,r.totalTokens/o*100):0;let a;e[0]!==s?(a=Pe("shrink-0",s),e[0]=s,e[1]=a):a=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("circle",{cx:cn/2,cy:cn/2,r:il,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ol}),e[2]=d):d=e[2];let c;e[3]!==i?(c=i>0?n.jsx("circle",{cx:cn/2,cy:cn/2,r:il,fill:"none",stroke:"currentColor",strokeWidth:ol,strokeLinecap:"round",strokeDasharray:Vd,strokeDashoffset:Vd*(1-i/100),transform:`rotate(-90 ${cn/2} ${cn/2})`}):null,e[3]=i,e[4]=c):c=e[4];let u;return e[5]!==a||e[6]!==c?(u=n.jsxs("svg",{viewBox:`0 0 ${cn} ${cn}`,className:a,"aria-hidden":"true",children:[d,c]}),e[5]=a,e[6]=c,e[7]=u):u=e[7],u},IC=()=>{const t=Ze.c(16),{t:e}=Et(),{sessionId:s,fill:r,limit:o}=Kh(),{totalCost:i}=w1(s);if(!s||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Ud(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let d;t[4]!==o||t[5]!==e?(d=e("contextUsage.tooltip.contextLimit",{tokens:Ud(o)}),t[4]=o,t[5]=e,t[6]=d):d=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:_p(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let u;t[10]!==a||t[11]!==d||t[12]!==c?(u=[a,d,...c],t[10]=a,t[11]=d,t[12]=c,t[13]=u):u=t[13];const f=u;let p;return t[14]!==f?(p=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(TC)}),t[14]=f,t[15]=p):p=t[15],p};function PC(t){return t.currentSessionId}function EC(t){return t.currentSessionDirectory}function TC(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const Wh=150,DC=500,RC=[],NC=t=>t>99?"99+":String(t),MC=t=>{const e=Ze.c(62),{surface:s,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:c,badgeDescription:u,orderNumber:f,showOrderNumber:p,onSelect:h}=t;let g;e[0]!==s.id?(g={id:s.id},e[0]=s.id,e[1]=g):g=e[1];const{attributes:b,listeners:x,setNodeRef:y,transform:S,transition:m,isDragging:v}=ji(g);let w;e[2]!==d?(w=d!=null&&d>0?NC(d):null,e[2]=d,e[3]=w):w=e[3];const T=w;let k;e[4]!==S?(k=ki.Translate.toString(S),e[4]=S,e[5]=k):k=e[5];let I;e[6]!==k||e[7]!==m?(I={transform:k,transition:m},e[6]=k,e[7]=m,e[8]=I):I=e[8];const F=v&&"z-10 opacity-70";let O;e[9]!==F?(O=Pe("relative",F),e[9]=F,e[10]=O):O=e[10];let B;e[11]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx("div",{}),e[11]=B):B=e[11];let j;e[12]!==h||e[13]!==s?(j=()=>h(s),e[12]=h,e[13]=s,e[14]=j):j=e[14];const P=c??i,L=s.id,z=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[15]!==z?(H=Pe("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",z),e[15]=z,e[16]=H):H=e[16];let R;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(R=s.id==="diff"?n.jsx(bf,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(CC,{className:"h-[18px] w-[18px]"}):n.jsx(yr,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[17]=s.icon,e[18]=s.iconSrc,e[19]=s.id,e[20]=R):R=e[20];let G;e[21]!==T||e[22]!==f||e[23]!==o||e[24]!==p?(G=p&&f!=null?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):T?n.jsx("span",{"aria-hidden":"true",className:"absolute -inset-e-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:T}):o?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[21]=T,e[22]=f,e[23]=o,e[24]=p,e[25]=G):G=e[25];let _;e[26]!==b||e[27]!==r||e[28]!==x||e[29]!==s.id||e[30]!==H||e[31]!==R||e[32]!==G||e[33]!==j||e[34]!==P?(_=n.jsx(Ht,{asChild:!0,children:n.jsxs("button",{type:"button",...b,...x,onClick:j,"aria-label":P,"aria-pressed":r,"data-context-surface":L,className:H,children:[R,G]})}),e[26]=b,e[27]=r,e[28]=x,e[29]=s.id,e[30]=H,e[31]=R,e[32]=G,e[33]=j,e[34]=P,e[35]=_):_=e[35];let $;e[36]!==i?($=n.jsx("span",{children:i}),e[36]=i,e[37]=$):$=e[37];let E;e[38]!==a?(E=n.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[38]=a,e[39]=E):E=e[39];let D;e[40]!==u?(D=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[40]=u,e[41]=D):D=e[41];let C;e[42]!==s.id?(C=s.id==="context"?n.jsx(IC,{}):null,e[42]=s.id,e[43]=C):C=e[43];let N;e[44]!==$||e[45]!==E||e[46]!==D||e[47]!==C?(N=n.jsx(Kt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,E,D,C]})}),e[44]=$,e[45]=E,e[46]=D,e[47]=C,e[48]=N):N=e[48];let A;e[49]!==_||e[50]!==N?(A=n.jsx(zl,{render:B,children:n.jsxs(Ut,{delayDuration:Wh,children:[_,N]})}),e[49]=_,e[50]=N,e[51]=A):A=e[51];let q;e[52]!==s.mode?(q=n.jsx(Ll,{children:n.jsx(gf,{mode:s.mode})}),e[52]=s.mode,e[53]=q):q=e[53];let ee;e[54]!==A||e[55]!==q?(ee=n.jsxs(Zr,{children:[A,q]}),e[54]=A,e[55]=q,e[56]=ee):ee=e[56];let Q;return e[57]!==y||e[58]!==ee||e[59]!==I||e[60]!==O?(Q=n.jsx("div",{ref:y,style:I,className:O,children:ee}),e[57]=y,e[58]=ee,e[59]=I,e[60]=O,e[61]=Q):Q=e[61],Q};function AC(t){return t==="gitlab"?"gitlab":t==="none"?"ticket-2":"github"}const OC=()=>{const t=Ze.c(104),{t:e}=Et(),s=Nn();let r;t[0]!==s?(r=s?Ds(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Ge=>o?Ge.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=le(i),d=le(BC),c=le(FC),u=le(_C),f=le(LC),p=le($C),h=le(zC),g=le(KC),b=le(WC),x=Uf(Vf)?.hasChecked??!1,y=kn(UC),S=C1(o||null),m=S==="none"?null:S,{screenWidth:v}=Rn(),w=Yr(),T=o||null;let k;t[4]!==w||t[5]!==T?(k=fi(w,T),t[4]=w,t[5]=T,t[6]=k):k=t[6];const I=hi(k);let F;t[7]!==b?(F=I1("switch_context_surface",b),t[7]=b,t[8]=F):F=t[8];const O=F,[B,j]=l.useState(!1);let P,L;t[9]!==O?(P=()=>{const Ge=new Set;let ge=null,Ae=!1;const Ye=VC,nt=()=>{Gc(O,Ge)?!Ae&&ge===null&&(ge=setTimeout(()=>j(!0),DC)):(Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),j(!1))},oe=gt=>{if(Ge.add(gt.key.toLowerCase()),Ye(gt.key)&&Gc(O,Ge)){Ae=!0,ge!==null&&(clearTimeout(ge),ge=null),j(!1);return}nt()},tt=gt=>{Ge.delete(gt.key.toLowerCase()),nt()},Ue=()=>{Ge.clear(),Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),j(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",tt,!0),window.addEventListener("blur",Ue),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",tt,!0),window.removeEventListener("blur",Ue),ge!==null&&clearTimeout(ge)}},L=[O],t[9]=O,t[10]=P,t[11]=L):(P=t[10],L=t[11]),l.useEffect(P,L);let z;t[12]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},t[12]=z):z=t[12];let H;t[13]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{delay:200,tolerance:6}},t[13]=H):H=t[13];const R=yi(mn(Si,z),mn(xi,H)),G=Fl(),_=Vc(GC),$=Vc(qC),E=a?.tabs??RC;let D;t[14]!==g||t[15]!==a?(D=bl(a,g),t[14]=g,t[15]=a,t[16]=D):D=t[16];const C=D,N=I?.files.length??0;let A;if(t[17]!==u||t[18]!==c||t[19]!==G||t[20]!==S||t[21]!==v||t[22]!==y||t[23]!==E){let Ge;t[25]!==S?(Ge=ge=>ge.id==="pr"?{...ge,icon:AC(S)}:ge,t[25]=S,t[26]=Ge):Ge=t[26],A=Hg({railOrder:c,hiddenSurfaces:u,isVSCode:Dn(),screenWidth:v,tabs:E,sourceControlConnected:y,extras:G}).map(Ge),t[17]=u,t[18]=c,t[19]=G,t[20]=S,t[21]=v,t[22]=y,t[23]=E,t[24]=A}else A=t[24];const q=A;let ee;t[27]!==E?(ee=E.some(YC),t[27]=E,t[28]=ee):ee=t[28];const Q=ee;let he,M;t[29]!==h||t[30]!==g||t[31]!==o||t[32]!==x||t[33]!==Q||t[34]!==C||t[35]!==y?(he=()=>{!o||!x||y||Q||!C.has("pr")||h(o,Ao(g,"pr"))},M=[h,g,o,x,Q,C,y],t[29]=h,t[30]=g,t[31]=o,t[32]=x,t[33]=Q,t[34]=C,t[35]=y,t[36]=he,t[37]=M):(he=t[36],M=t[37]),l.useEffect(he,M);const[V,ie]=l.useState(!1),ce=l.useRef(null),ne=l.useRef(null);let je;t[38]!==m||t[39]!==q||t[40]!==e?(je=Ge=>{const ge=q.find(Ye=>Ye.id===Ge.active.id),Ae=ce.current?.getBoundingClientRect().left;!ge||Ae===void 0||(ne.current?.cancel(),ne.current=Ql({mode:ge.mode,label:ge.label??e(pn(ge.labelKey,m)),from:Ao(le.getState().contextSurfaceZones,ge.mode)},Ye=>Ye.x<Ae-16))},t[38]=m,t[39]=q,t[40]=e,t[41]=je):je=t[41];const Ee=je;let we;t[42]===Symbol.for("react.memo_cache_sentinel")?(we=()=>{ne.current?.cancel(),ne.current=null},t[42]=we):we=t[42];const Me=we;let fe,be;t[43]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>()=>ne.current?.cancel(),be=[],t[43]=fe,t[44]=be):(fe=t[43],be=t[44]),l.useEffect(fe,be);let ke;t[45]!==o||t[46]!==G||t[47]!==f?(ke=Ge=>{const ge=ne.current;if(ne.current=null,ge?.finish(o))return;const{active:Ae,over:Ye}=Ge;if(!Ye||Ae.id===Ye.id)return;const nt=Xu(le.getState().contextRailOrder,G).map(ZC),oe=nt.indexOf(Ae.id),tt=nt.indexOf(Ye.id);oe===-1||tt===-1||f(Lp(nt,oe,tt))},t[45]=o,t[46]=G,t[47]=f,t[48]=ke):ke=t[48];const Ie=ke;if(!o)return null;let Te;t[49]!==e?(Te=e("contextRail.aria.rail"),t[49]=e,t[50]=Te):Te=t[50];let Y;t[51]!==q?(Y=q.map(QC),t[51]=q,t[52]=Y):Y=t[52];let ue;if(t[53]!==m||t[54]!==N||t[55]!==$||t[56]!==o||t[57]!==_||t[58]!==p||t[59]!==B||t[60]!==C||t[61]!==q||t[62]!==e||t[63]!==d){let Ge;t[65]!==m||t[66]!==N||t[67]!==$||t[68]!==o||t[69]!==_||t[70]!==p||t[71]!==B||t[72]!==C||t[73]!==e||t[74]!==d?(Ge=(ge,Ae)=>{const Ye=ge.label??e(pn(ge.labelKey,m)),nt=ge.id==="git"&&!d?N:0,oe=dr(ge.mode)&&!C.has(ge.mode)?_[No(ge.mode)]??0:0,tt=nt>0?nt:oe>0?oe:null,Ue=tt!==null&&nt===0;return n.jsx(MC,{surface:ge,isActive:C.has(ge.mode),showActivityDot:!1,label:Ye,description:e(pn(ge.descriptionKey,m)),badgeCount:tt,badgeAriaLabel:tt!==null?e(Ue?tt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":tt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Ye,count:tt}):null,badgeDescription:tt!==null?e(Ue?tt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":tt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:tt}):null,orderNumber:Ae+1,showOrderNumber:B,onSelect:gt=>{dr(gt.mode)&&$(No(gt.mode)),p(o,gt.mode)}},ge.id)},t[65]=m,t[66]=N,t[67]=$,t[68]=o,t[69]=_,t[70]=p,t[71]=B,t[72]=C,t[73]=e,t[74]=d,t[75]=Ge):Ge=t[75],ue=q.map(Ge),t[53]=m,t[54]=N,t[55]=$,t[56]=o,t[57]=_,t[58]=p,t[59]=B,t[60]=C,t[61]=q,t[62]=e,t[63]=d,t[64]=ue}else ue=t[64];let me;t[76]!==Y||t[77]!==ue?(me=n.jsx(Gl,{items:Y,strategy:$p,children:ue}),t[76]=Y,t[77]=ue,t[78]=me):me=t[78];let re;t[79]!==Ie||t[80]!==Ee||t[81]!==R||t[82]!==me?(re=n.jsx(wi,{sensors:R,collisionDetection:vi,onDragStart:Ee,onDragCancel:Me,onDragEnd:Ie,children:me}),t[79]=Ie,t[80]=Ee,t[81]=R,t[82]=me,t[83]=re):re=t[83];let pe;t[84]!==e?(pe=e("contextRail.configure.open"),t[84]=e,t[85]=pe):pe=t[85];let U;t[86]===Symbol.for("react.memo_cache_sentinel")?(U=()=>ie(!0),t[86]=U):U=t[86];let ae;t[87]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Z,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[87]=ae):ae=t[87];let Re;t[88]!==pe?(Re=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":pe,onClick:U,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ae})}),t[88]=pe,t[89]=Re):Re=t[89];let W;t[90]!==e?(W=e("contextRail.configure.open"),t[90]=e,t[91]=W):W=t[91];let ye;t[92]!==W?(ye=n.jsx(Kt,{side:"left",sideOffset:8,children:W}),t[92]=W,t[93]=ye):ye=t[93];let de;t[94]!==Re||t[95]!==ye?(de=n.jsxs(Ut,{delayDuration:Wh,children:[Re,ye]}),t[94]=Re,t[95]=ye,t[96]=de):de=t[96];let Ne;t[97]!==V?(Ne=n.jsx(bC,{open:V,onOpenChange:ie}),t[97]=V,t[98]=Ne):Ne=t[98];let Je;return t[99]!==Te||t[100]!==re||t[101]!==de||t[102]!==Ne?(Je=n.jsxs("nav",{ref:ce,"aria-label":Te,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[re,de,Ne]}),t[99]=Te,t[100]=re,t[101]=de,t[102]=Ne,t[103]=Je):Je=t[103],Je};function BC(t){return t.workStatusPanelVisible}function FC(t){return t.contextRailOrder}function _C(t){return t.contextRailHiddenSurfaces}function LC(t){return t.setContextRailOrder}function $C(t){return t.openContextSurface}function zC(t){return t.closeContextZone}function KC(t){return t.contextSurfaceZones}function WC(t){return t.shortcutOverrides}function HC(t){return t.status?.status==="connected"}function UC(t){return Object.values(t.entries).some(HC)}function VC(t){return t.length===1&&t>="0"&&t<="9"}function GC(t){return t.countByGuest}function qC(t){return t.clearBadge}function YC(t){return t.mode==="pr"&&t.targetPath}function ZC(t){return t.id}function QC(t){return t.id}const XC=t=>{const e=Ze.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:o,closeSessionSearch:i,sessionSearchInputRef:a,sessionSearchContainerRef:d}=t,c=s===void 0?!0:s;let u,f;e[0]!==c||e[1]!==r||e[2]!==a?(u=()=>{if(!c||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>window.cancelAnimationFrame(x)},f=[c,r,a],e[0]=c,e[1]=r,e[2]=a,e[3]=u,e[4]=f):(u=e[3],f=e[4]),l.useEffect(u,f);let p,h;e[5]!==c||e[6]!==o||e[7]!==a?(p=()=>{if(!c||typeof window>"u")return;const x=()=>{o(),a.current?.focus(),a.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},h=[c,o,a],e[5]=c,e[6]=o,e[7]=a,e[8]=p,e[9]=h):(p=e[8],h=e[9]),l.useEffect(p,h);let g,b;e[10]!==i||e[11]!==c||e[12]!==r||e[13]!==d?(g=()=>{if(!c||!r||typeof document>"u")return;const x=y=>{d.current&&(d.current.contains(y.target)||i())};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},b=[c,r,i,d],e[10]=i,e[11]=c,e[12]=r,e[13]=d,e[14]=g,e[15]=b):(g=e[14],b=e[15]),l.useEffect(g,b)},JC=t=>{const e=Ze.c(4);let s;e[0]!==t?(s=(i,a)=>{const d=t.get(i);if(!d||d.length===0)return a;const c=new Map(a.map(e3)),u=[];d.forEach(h=>{const g=c.get(h);g&&(u.push(g),c.delete(h))});const f=[],p=[];return a.forEach(h=>{c.has(h.id)&&(h.isArchivedBucket?p.push(h):f.push(h))}),[...f,...u,...p]},e[0]=t,e[1]=s):s=e[1];const r=s;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function e3(t){return[t.id,t]}const t3=(t,e)=>{const s=t.groups.find(i=>i.isMain&&i.sessions.length>0)??t.groups.find(i=>i.sessions.length>0)??t.groups.find(i=>i.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(i=>i.isArchivedBucket&&i.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(i=>i.isMain)?[t.groups.find(i=>i.isMain)]:[],...t.groups.filter(i=>!i.isMain)]).map(i=>({group:i,groupKey:`${t.project.id}:${i.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?i.id===s.id:i.isMain}))},Gd=(t,e,s)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const a of o.children)i=r(a)||i;return i&&s.add(o.session.id),i};for(const o of t)r(o)},gr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(gr(s,e))return!0;return!1},s3=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!yl(r),n3=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,al=(t,e,s)=>{const r=new Map,o=i=>{const a=ur(i.session)??yt(i.worktree?.path)??s;if(a){const d=r.get(a)??[];d.push(i.session.id),r.set(a,d)}if(!(i===t&&e))for(const d of i.children)o(d)};return o(t),[...r].map(([i,a])=>({directory:i,sessionIDs:a}))},ll=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(s.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},Hh=t=>{const e=new Map(t.map(a=>[a.id,a])),s=new Map;for(const a of t){if(!a.parentId||!e.has(a.parentId))continue;const d=s.get(a.parentId)??[];d.push(a),s.set(a.parentId,d)}const r=new Set,o=[],i=a=>{if(r.has(a.id))return;o.push(a);const d=[a.id];for(;d.length>0;){const c=d.pop();if(!(!c||r.has(c))){r.add(c);for(const u of s.get(c)??[])d.push(u.id)}}};return t.forEach(a=>{(!a.parentId||!e.has(a.parentId))&&i(a)}),t.forEach(i),o},Uh=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const h=o.get(u.parentId)??[];h.push(u.id),o.set(u.parentId,h)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){i.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const a=new Set,d=new Set,c=u=>{if(a.has(u))return!0;if(d.has(u))return!1;const f=r.get(u);if(!f)return!1;d.add(u);let p=i.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(o.get(u)??[]).some(c):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!s&&$o([f.name],e.searchQuery))&&(p=!0),p||(p=(o.get(u)??[]).some(c))),d.delete(u),p&&a.add(u),p};return t.forEach(u=>c(u.id)),new Set(t.filter(u=>a.has(u.id)).map(u=>u.id))},qd=new WeakMap;let Yd=1;const r3=t=>{const e=qd.get(t);if(e!==void 0)return e;const s=Yd;return Yd+=1,qd.set(t,s),s},Gr=t=>t.children.length===0?"":t.children.map(s=>{const r=r3(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Gr(s)}`}).join("|"),Vh=(t,e,s,r,o,i)=>{const a=Jt(),d=(c,u)=>{if(c.session.id!==u.session.id||c.children.length!==u.children.length)return!0;const f=c.session.directory??o,p=u.session.directory??i,h=qc(a,f??"",c.session.id),g=qc(a,p??"",u.session.id);return(h?s.has(h):!1)!==(g?r.has(g):!1)?!0:c.children.some((b,x)=>d(b,u.children[x]))};return d(t,e)},o3=(t,e)=>t?t.branchLabel??null:e??null,i3=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=yt(t?.path??null);return s&&r?{directory:r,branch:s}:null},Zo=(t,e,s,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const a=d=>{if(`${s}:${o}:${d.session.id}`===e)return i=d.session.id,!0;for(const u of d.children)if(a(u))return!0;return!1};return t.forEach(d=>a(d)),i},_n=(t,e)=>`${t}\0${e}`,lr=(t,e)=>t??xl(e)??yt(e??null),zn=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??yt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},sc=t=>t.startsWith("__archived__:"),Gh=6,Kn=t=>$l(t,Gh),Zd=t=>`calc(${Kn(t)} + 20px)`,a3=t=>{const e=new Array(t.length).fill(null);let s=[];for(let r=t.length-1;r>=0;r-=1){const o=t[r];if(o==null){s=[];continue}const i=[];for(let a=1;a<o;a+=1)s[a]&&i.push({level:a,end:!1});o>0&&i.push({level:o,end:!s[o]}),i.length>0&&(e[r]=Object.freeze(i)),s=s.slice(0,o),s[o]=!0}return e},Ri=(t,e)=>{const s=e.trim().toLowerCase();return s?s.startsWith("ses_")?t.id.toLowerCase()===s:(typeof t.title=="string"?t.title.toLowerCase():"").includes(e):!0},qh=(t,e)=>{if(Ri(t.session,e))return t;const s=t.children.flatMap(r=>{const o=qh(r,e);return o?[o]:[]});return s.length>0?{...t,children:s}:null},nc=(t,e)=>(Ri(t.session,e)?1:0)+t.children.reduce((s,r)=>s+nc(r,e),0),l3=(t,e,s,r)=>{const o=new Map;return s?{sessions:t.filter(a=>{const d=r==="tree"?nc(e(a),s):Number(Ri(a,s));return d>0&&o.set(a.id,d),d>0}),matchCountById:o}:{sessions:[...t],matchCountById:o}},Qd=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(o=>{if(!Ri(o,r))return[];const i=e(o.id);return[{node:s(o),projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:{projectLabel:i?.projectLabel??null,branchLabel:i?.branchLabel??null,inSpace:i?.inSpace??!1}}]}),Yh=["chats","pinned","work","timeline"],rc=t=>t==="project"||t==="mixed-compact"||t==="tree-chat",qr=t=>t==="timeline"||t==="timeline-mixed"||t==="timeline-by-time",c3=t=>qr(t)||t==="mixed-compact",po=t=>"run"in t,d3=(t,e)=>`${t}:active:run:${e}`,ma=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const a=e.runKeyBySessionId.get(i.session.id),d=a?e.runs.get(a):void 0;if(!d){r.push(i);continue}const c=o.get(d.key);if(c){c.lanes.push(i);continue}const u={run:d,lanes:[i]};o.set(d.key,u),r.push(u)}for(const i of o.values()){const a=new Map(i.run.memberIds.map((d,c)=>[d,c]));i.lanes.sort((d,c)=>(a.get(d.session.id)??0)-(a.get(c.session.id)??0))}return r},Zh=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),o=i=>i.reduce((a,d)=>a+(!r||d.session.id.toLowerCase()===s?1:0)+o(d.children),0);return o(t)},ga=[],u3=new Set,f3=32,Qh=52,p3=Qh+21,Xd=t=>t==="timeline-by-time"?p3:qr(t)?Qh:f3,h3=3,m3=7,Jd=7,eu=7,Xh=t=>`timeline-project:${t}`,Qn=32,Js=28,g3=t=>{switch(t.kind){case"group-header":return 0;case"folder-header":return t.depth;case"session":case"run":return rc(t.renderContext)?t.depth:null;default:return null}},tu=(t,e,s,r)=>{const o=r.get(t.session.id),i=r.get(e.session.id);if(o!==void 0||i!==void 0){if(o===void 0)return 1;if(i===void 0)return-1;if(o!==i)return o-i}return Kl(t.session,e.session,s,dp)},ba=t=>{const e=new Map,s=new Map,r=[],o=new WeakMap,i=t.map(a=>({node:a,visited:!1})).reverse();for(;i.length>0;){const a=i.pop();if(!a)continue;if(!a.visited){e.set(a.node.session.id,a.node),s.set(a.node.session.id,a.node.session);const c=r.length;r.push(a.node.session.id),o.set(a.node,[c,c+1]),i.push({node:a.node,visited:!0});for(let u=a.node.children.length-1;u>=0;u-=1){const f=a.node.children[u];f&&i.push({node:f,visited:!1})}continue}const d=o.get(a.node);d&&o.set(a.node,Object.freeze([d[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},b3=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,y3=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},x3=t=>{const e=[],s=[],r=[],o=[],i=[],a=new Map,d=new Map,c=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.zoneSessionIds??u3,p=E=>c&&f.has(E);let h=0;const b=[...[...t.authoritativeSections.flatMap(E=>E.groups.flatMap(D=>D.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const E=b.pop();E&&(a.set(E.session.id,E.session),b.push(...E.children))}const x=E=>{const D=d.get(E)??0;return d.set(E,D+1),D===0?E:`${E}:${D}`},y=E=>{e.push(Object.freeze(E))},S=t.runIndex??P1,m=(E,D)=>{const C=d3(D.renderContext,E.run.key),N=!c3(D.renderContext)&&(c||t.expandedParents.has(C)),A=E.lanes[0]?.session.id,q=A&&D.getSecondaryMeta?D.getSecondaryMeta(A):D.secondaryMeta,ee=Object.freeze([...new Set(E.lanes.flatMap(Q=>(D.getBlockingBadgeSessionScopes?.(Q.session.id)??[]).flatMap(he=>he.sessionIDs)))]);y({kind:"run",key:x(`${D.containerKey}:run:${E.run.key}`),estimateSize:Xd(D.renderContext),run:E.run,depth:D.baseDepth??0,laneNodes:Object.freeze([...E.lanes]),blockingSessionIds:ee,projectId:D.projectId,projectLabel:q?.projectLabel??null,groupDirectory:D.groupDirectory,renderContext:D.renderContext,expansionKey:C,expanded:N,forceExpanded:c}),N&&w(E.lanes,(D.baseDepth??0)+1,D)},v=E=>{for(const D of ma(E.nodes,S,E.archived))po(D)?m(D,E):w([D],E.baseDepth??0,E)},w=(E,D,C)=>{const N=[...E].reverse().map(A=>({node:A,depth:D,directory:C.groupDirectory}));for(;N.length>0;){const A=N.pop();if(!A)continue;const q=x(`${C.containerKey}:session:${A.node.session.id}`),ee=A.node.session.directory??A.directory;a.set(A.node.session.id,A.node.session),y({kind:"session",key:q,estimateSize:Xd(C.renderContext),node:A.node,blockingBadgeSessionScopes:A.depth===D?C.getBlockingBadgeSessionScopes?.(A.node.session.id)??C.blockingBadgeSessionScopes:void 0,depth:A.depth,projectId:C.projectId,groupDirectory:A.directory,ownerKey:C.ownerKey,selectionScopeKey:C.selectionScopeKey,archived:C.archived,renderContext:C.renderContext,secondaryMeta:C.getSecondaryMeta?C.getSecondaryMeta(A.node.session.id):C.secondaryMeta??null});const Q=C.indexedNodes?.subtreeRangeByNode.get(A.node),he=Q&&Q[1]>Q[0]+1?Object.freeze([(C.selectionPoolOffset??0)+Q[0]+1,(C.selectionPoolOffset??0)+Q[1]]):void 0;if(s.push(Object.freeze({id:A.node.session.id,rowKey:q,scopeKey:C.selectionScopeKey,archived:C.archived,descendantRange:he})),!(!c&&!t.expandedParents.has(b3(C.renderContext,C.archived,A.node.session.id))))for(let M=A.node.children.length-1;M>=0;M-=1){const V=A.node.children[M];V&&N.push({node:V,depth:A.depth+1,directory:ee})}}},T=E=>{const D=t.groupSearchDataByGroup.get(E);if(D?.hasMatch!==!0)return 0;const C=f.size>0?D.filteredNodes.filter(A=>p(A.session.id)):[];return Math.max(0,D.matchedSessionCount-Zh(C,t.normalizedQuery))+D.folderNameMatchCount+(D.groupMatches?1:0)},k=(E,D,C,N,A)=>{const q=t.groupSearchDataByGroup.get(E);if(c){const oe=T(E);if(oe===0)return;h+=oe}const ee=(c?q?.filteredNodes??[]:E.sessions).filter(oe=>!p(oe.session.id)).sort((oe,tt)=>tu(oe,tt,u,t.sessionOrderIndex)),Q=ba(ee),he=r.length;r.push(...Q.preorderIds);for(const[oe,tt]of Q.sessionsById)a.set(oe,tt);const M=lr(C,E.directory),V=!c&&t.collapsedGroups.has(D),ie=N?0:1,ce=A!==void 0&&!rc(A.renderContext),ne=t.groupStatusByKey.get(D),je=!ne||ne.state==="ready",Ee=ee.length===0&&je&&zn(E).every(({scopeKey:oe})=>(t.foldersMap[oe]??ga).length===0);if(!N){const oe=Q.preorderIds.flatMap(tt=>Q.sessionsById.get(tt)??[]);y({kind:"group-header",key:`${D}:header`,estimateSize:Qn,group:E,groupKey:D,projectId:C,collapsed:V&&!Ee,forceExpanded:c,empty:Ee,allSessions:Object.freeze(oe)})}if(V&&!Ee)return;const we=zn(E).flatMap(({scopeKey:oe,directory:tt})=>(t.foldersMap[oe]??ga).map(Ue=>({folder:Ue,scopeKey:oe,scopeDirectory:tt,ownerKey:M,nodes:ll(Ue.sessionIds,Q.byId).sort((gt,bt)=>tu(gt,bt,u,t.sessionOrderIndex))}))),Me=Uh(we.map(oe=>({id:oe.folder.id,name:oe.folder.name,parentId:oe.folder.parentId,nodeCount:oe.nodes.length})),{archivedBucket:E.isArchivedBucket===!0,searchQuery:c?t.normalizedQuery:""}),fe=we.filter(oe=>Me.has(oe.folder.id)),be=new Map(fe.map(oe=>[_n(oe.scopeKey,oe.folder.id),oe])),ke=new Map;for(const oe of fe){if(!oe.folder.parentId)continue;const tt=_n(oe.scopeKey,oe.folder.parentId),Ue=ke.get(tt)??[];Ue.push(oe),ke.set(tt,Ue)}const Ie=Hh(fe.map(oe=>({...oe.folder,scopeKey:oe.scopeKey}))).map(oe=>be.get(_n(oe.scopeKey??"",oe.id))).filter(oe=>!!oe),Te=new Set(fe.flatMap(oe=>oe.folder.sessionIds)),Y=ee.filter(oe=>!Te.has(oe.session.id)),ue=new Map,me=Ie.map(oe=>({folder:oe,visited:!1})),re=new Set;for(;me.length>0;){const oe=me.pop();if(!oe)continue;const tt=_n(oe.folder.scopeKey,oe.folder.folder.id);if(!oe.visited){if(re.has(tt))continue;re.add(tt),me.push({folder:oe.folder,visited:!0});for(const gt of ke.get(tt)??[])me.push({folder:gt,visited:!1});continue}const Ue=oe.folder.nodes.flatMap(gt=>{const bt=Q.subtreeRangeByNode.get(gt);return bt?Q.preorderIds.slice(bt[0],bt[1]).flatMap(Ce=>Q.sessionsById.get(Ce)??[]):[gt.session]});for(const gt of ke.get(tt)??[])Ue.push(...ue.get(_n(gt.scopeKey,gt.folder.id))??[]);ue.set(tt,Object.freeze(Ue))}const pe=new Set,U=(oe,tt)=>{const Ue=_n(oe.scopeKey,oe.folder.id);if(pe.has(Ue))return;pe.add(Ue);const gt=tt?`${tt} / ${oe.folder.name}`:oe.folder.name,bt=`${D}:folder:${Ue}`,Ce=je&&oe.nodes.length===0&&(ke.get(Ue)?.length??0)===0,_e=!c&&!Ce&&t.collapsedFolders.has(oe.folder.id),ze=ue.get(Ue)??[],Oe=_e&&!E.isArchivedBucket?ll([...new Set(ze.map(Be=>Be.id))],Q.byId):[],it=M?t.folderAuthorityByOwner.get(M):void 0,X=!!M&&!E.isArchivedBucket&&!sc(oe.scopeKey)&&it?.complete===!0&&it.scopeKeys.includes(oe.scopeKey);if(y({kind:"folder-header",key:bt,estimateSize:Qn,depth:ie,group:E,folder:oe.folder,displayName:gt,scopeKey:oe.scopeKey,scopeDirectory:oe.scopeDirectory,ownerKey:M,nodes:oe.nodes,activityNodes:Oe,projectId:C,archived:E.isArchivedBucket===!0,collapsed:_e,forceExpanded:c,empty:Ce,deleteSessions:ze,subFolderCount:ke.get(Ue)?.length??0,dropEnabled:X}),M&&i.push(Object.freeze({rowKey:bt,scopeKey:oe.scopeKey,folderId:oe.folder.id,ownerKey:M,enabled:X})),!_e){v({nodes:oe.nodes,containerKey:bt,projectId:C,groupDirectory:oe.scopeDirectory??E.directory,ownerKey:M,selectionScopeKey:M,archived:E.isArchivedBucket===!0,renderContext:"project",indexedNodes:Q,selectionPoolOffset:he,baseDepth:ie+1});for(const Be of ke.get(Ue)??[])U(Be,gt)}};for(const oe of Ie)U(oe,"");const ae=C?t.sessionBatchSize:void 0,Re=A?.initial??ae??(t.hideDirectoryControls?10:Jd),W=A?.increment??ae??eu,ye=Math.max(Re,t.visibleCountByContainer.get(D)??Re),de=oe=>!po(oe)&&A?.pinnedAlwaysVisible===!0&&gi(u,oe.session.directory??E.directory,oe.session.id),Ne=ma(Y,S,E.isArchivedBucket===!0),Je=Ne.filter(oe=>!de(oe));let Ge=ye;const ge=E.isArchivedBucket||c?Ne:Ne.filter(oe=>de(oe)?!0:Ge<=0?!1:(Ge-=1,!0)),Ae=ge.flatMap(oe=>po(oe)?oe.lanes:[oe]);v({nodes:Ae,containerKey:D,projectId:C,groupDirectory:E.directory,ownerKey:M,selectionScopeKey:M,archived:E.isArchivedBucket===!0,renderContext:A?.renderContext??"project",indexedNodes:Q,selectionPoolOffset:he,baseDepth:ie});const Ye=Ne.length-ge.length,nt=ye-Ge;!c&&!E.isArchivedBucket&&Ye>0?y({kind:"show-control",key:`${D}:more`,estimateSize:Js,control:"more",containerKey:D,currentCount:nt,increment:W,depth:ie,flat:ce}):!c&&!E.isArchivedBucket&&Je.length>Re&&Ye===0&&y({kind:"show-control",key:`${D}:fewer`,estimateSize:Js,control:"fewer",containerKey:D,currentCount:nt,increment:W,depth:ie,flat:ce}),ee.length===0&&fe.length===0?ne&&ne.state!=="ready"?y({kind:"status",key:`${D}:status`,estimateSize:Js,status:ne,group:E,groupKey:D,depth:ie,flat:ce}):E.isArchivedBucket&&y({kind:"empty",key:`${D}:empty`,estimateSize:Js,emptyKind:"archived",depth:ie}):ne&&ne.state!=="ready"&&ne.state!=="loading"&&y({kind:"status",key:`${D}:status`,estimateSize:Js,status:ne,group:E,groupKey:D,depth:ie,flat:ce})},I=E=>{const D=!c&&t.collapsedActivities.has(E),C=e.length;return y({kind:"activity-header",key:`activity:${E}:header`,estimateSize:Qn,activityKey:E,collapsed:D,forceExpanded:c}),o.push(Object.freeze({rowIndex:C,kind:"activity",id:E})),D},F=t.viewMode==="timeline",O=E=>"run"in E,B=E=>{const D=ma(E.map(N=>N.node),S,!1),C=new Map(E.map(N=>[N.node,N]));return D.flatMap(N=>{if(!po(N)){const A=C.get(N);return A?[A]:[]}return[{run:N.run,items:N.lanes.flatMap(A=>C.get(A)??[])}]})},j=(E,D,C)=>{const N=E.items[0];if(!N)return;const A=E.items.map(V=>V.node),q=ba(A),ee=r.length;r.push(...q.preorderIds);const Q=lr(N.projectId,N.groupDirectory),he=new Map(E.items.map(V=>[V.node.session.id,V.getSecondaryMeta?V.getSecondaryMeta(V.node.session.id):V.secondaryMeta])),M=new Map(E.items.map(V=>[V.node.session.id,V.blockingBadgeSessionScopes]));m({run:E.run,lanes:A},{nodes:A,containerKey:D,projectId:N.projectId,groupDirectory:N.groupDirectory,ownerKey:Q,selectionScopeKey:null,archived:!1,renderContext:C,getSecondaryMeta:V=>he.get(V)??null,getBlockingBadgeSessionScopes:V=>M.get(V),indexedNodes:q,selectionPoolOffset:ee})},P=(E,D,C,N=()=>1)=>{for(const A of B(E)){if(O(A)){j(A,D,C),c&&(h+=A.items.reduce((M,V)=>M+N(V),0));continue}const q=A,ee=ba([q.node]),Q=r.length;r.push(...ee.preorderIds);const he=lr(q.projectId,q.groupDirectory);v({nodes:[q.node],containerKey:D,projectId:q.projectId,groupDirectory:q.groupDirectory,ownerKey:he,selectionScopeKey:null,archived:!1,renderContext:C,blockingBadgeSessionScopes:q.blockingBadgeSessionScopes,secondaryMeta:q.secondaryMeta,getSecondaryMeta:q.getSecondaryMeta,indexedNodes:ee,selectionPoolOffset:Q}),c&&(h+=N(q))}};t.chatGroup&&(!c||T(t.chatGroup)>0)&&(I("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:h3,increment:m3,pinnedAlwaysVisible:!0,renderContext:F?"timeline-chat":"tree-chat"}));const L=F&&t.listGrouping==="time",z=L?"timeline-by-time":F||t.detailedZoneRows?"timeline-mixed":"mixed-compact",H=(E,D,C,N,A)=>{const q=Math.max(N,t.visibleCountByContainer.get(D)??N),ee=B(E),Q=c?ee:ee.slice(0,q);P(Q.flatMap(he=>O(he)?he.items:[he]),D,C),!c&&(ee.length>Q.length?y({kind:"show-control",key:`${D}:more`,estimateSize:Js,control:"more",containerKey:D,currentCount:Q.length,increment:A,flat:!0}):ee.length>N&&y({kind:"show-control",key:`${D}:fewer`,estimateSize:Js,control:"fewer",containerKey:D,currentCount:Q.length,increment:A,flat:!0}))},R=(E,D)=>{if(D.length===0)return;I(E)||P(D,`activity:${E}`,z,N=>N.searchMatchCount??nc(N.node,t.normalizedQuery))};if(R("pinned",t.pinnedItems??[]),R("work",t.workItems??[]),L){const E=(t.timelineItems??[]).filter(D=>D.projectId&&!f.has(D.node.session.id));if(E.length>0&&(I("timeline")||P(E,"activity:timeline","timeline-by-time")),!c&&!(E.length>0&&t.collapsedActivities.has("timeline"))){const D=new Set((t.timelineItems??[]).map(N=>N.projectId)),C=new Set;for(const N of t.sections){if(D.has(N.project.id))continue;const A=N.groups.find(he=>he.isMain);if(!A)continue;const q=`${N.project.id}:${A.id}`,ee=t.groupStatusByKey.get(q);if(!ee||ee.state==="ready")continue;const Q=ee.state==="loading"?"loading":`${ee.state}:${ee.directory??""}`;C.has(Q)||(C.add(Q),y({kind:"status",key:`activity:timeline:status:${q}`,estimateSize:Js,status:ee,group:A,groupKey:q,flat:!0}))}}}else if(F){const E=new Set((t.pinnedItems??[]).map(C=>C.node.session.id)),D=new Map;for(const C of t.timelineItems??[]){if(!C.projectId||p(C.node.session.id)||E.has(C.node.session.id))continue;const N=D.get(C.projectId);N?N.push(C):D.set(C.projectId,[C])}for(const C of t.sections){const N=C.project.id,A=D.get(N)??[];if(c&&A.length===0)continue;const q=!c&&t.collapsedProjects.has(N),ee=e.length;if(y({kind:"project-header",key:`project:${N}:header`,estimateSize:Qn,section:C,collapsed:q,forceExpanded:c}),o.push(Object.freeze({rowIndex:ee,kind:"project",id:N})),q)continue;if(!c)for(const V of C.groups){if(!V.space||V.sessions.length>0)continue;const ie=`${N}:${V.id}`,ce=t.groupStatusByKey.get(ie);if(ce?.state==="loading")continue;const ne=(!ce||ce.state==="ready")&&zn(V).every(({scopeKey:je})=>(t.foldersMap[je]??ga).length===0);y({kind:"group-header",key:`${ie}:header`,estimateSize:Qn,group:V,groupKey:ie,projectId:N,collapsed:!1,forceExpanded:!0,empty:ne,allSessions:Object.freeze([])}),ce&&ce.state!=="ready"&&y({kind:"status",key:`${ie}:status`,estimateSize:Js,status:ce,group:V,groupKey:ie,flat:!0})}if(A.length>0){H(A,Xh(N),"timeline",Jd,eu);continue}const Q=C.groups.find(V=>V.isMain);if(!Q)continue;const he=`${N}:${Q.id}`,M=t.groupStatusByKey.get(he);M&&M.state!=="ready"&&y({kind:"status",key:`${he}:status`,estimateSize:Js,status:M,group:Q,groupKey:he,flat:!0})}}let G=F?[]:t.singleProjectMode?t.sections.filter(E=>E.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const E=G.find(D=>D.project.id===t.activeProjectId)??G[0];G=E?[E]:[]}for(const E of G){const D=t3(E,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(c&&!D.some(N=>T(N.group)>0))continue;const C=!c&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(E.project.id);if(!t.showOnlyMainWorkspace){const N=e.length;y({kind:"project-header",key:`project:${E.project.id}:header`,estimateSize:Qn,section:E,collapsed:C,forceExpanded:c}),o.push(Object.freeze({rowIndex:N,kind:"project",id:E.project.id}))}if(!C)for(const N of D)k(N.group,N.groupKey,N.projectId,N.hideGroupLabel)}e.length===0&&y({kind:"empty",key:c?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:c?"search":"sidebar"}),a3(e.map(g3)).forEach((E,D)=>{const C=e[D];E&&C&&(e[D]=Object.freeze({...C,treeGuides:E}))});const $=new Map;return e.forEach((E,D)=>$.set(E.key,D)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:$,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:a,searchMatchCount:c?h:0})},ho="oc.sessions.projectCollapse",su="oc.sessions.groupOrder",nu="oc.sessions.groupCollapse",ru="oc.sessions.activityCollapse",ya=t=>{if(!t)return new Set;try{const e=Ci(zs()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},S3=t=>{if(!t)return new Map;try{const e=Wr(zs(),Ci(zs())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,o]of Object.entries(e.data))s.set(r,o);return s}catch{return new Map}},w3=t=>{const e=Ze.c(45),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Oo(),e[0]=o):o=e[0];const i=o;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>ya(i.getItem(ho)),e[1]=a):a=e[1];const[d,c]=l.useState(a);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>ya(i.getItem(nu)),e[2]=u):u=e[2];const[f,p]=l.useState(u);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>ya(i.getItem(ru)),e[3]=h):h=e[3];const[g,b]=l.useState(h);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=()=>S3(i.getItem(su)),e[4]=x):x=e[4];const[y,S]=l.useState(x),m=l.useRef(0),v=l.useRef(!1),w=l.useRef(!1),T=l.useRef(!1),k=l.useRef(null),I=l.useRef(null);let F;e[5]!==s?(F=()=>{if(s)return;const fe=I.current;if(I.current=null,k.current=null,!fe)return;const{projects:be}=ns.getState(),ke=be.map(Ie=>({...Ie,sidebarCollapsed:fe.has(Ie.id)}));en({projects:ke}).catch(v3)},e[5]=s,e[6]=F):F=e[6];const O=F;let B;e[7]!==O||e[8]!==s?(B=fe=>{!globalThis.window||s||(I.current=fe,k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{O()},700))},e[7]=O,e[8]=s,e[9]=B):B=e[9];const j=B;let P,L;e[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{globalThis.window&&k.current!==null&&window.clearTimeout(k.current),k.current=null,I.current=null},L=[],e[10]=P,e[11]=L):(P=e[10],L=e[11]),l.useEffect(P,L);let z,H;e[12]!==y?(z=()=>{if(T.current)try{i.setItem(su,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},H=[y,i],e[12]=y,e[13]=z,e[14]=H):(z=e[13],H=e[14]),l.useEffect(z,H);let R,G;e[15]!==f?(R=()=>{if(v.current)try{i.setItem(nu,JSON.stringify(Array.from(f)))}catch{}},G=[f,i],e[15]=f,e[16]=R,e[17]=G):(R=e[16],G=e[17]),l.useEffect(R,G);let _,$;e[18]!==g?(_=()=>{if(w.current)try{i.setItem(ru,JSON.stringify(Array.from(g)))}catch{}},$=[g,i],e[18]=g,e[19]=_,e[20]=$):(_=e[19],$=e[20]),l.useEffect(_,$);let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=fe=>{w.current=!0,b(fe)},e[21]=E):E=e[21];const D=E;let C;e[22]!==r||e[23]!==j?(C=()=>{m.current=Date.now()+150,v.current=!0,w.current=!0,p(new Set),b(j3),c(()=>{const fe=new Set(r.map(k3));try{i.setItem(ho,JSON.stringify(Array.from(fe)))}catch{}return j(fe),fe})},e[22]=r,e[23]=j,e[24]=C):C=e[24];const N=C;let A;e[25]!==j?(A=()=>{m.current=Date.now()+150,v.current=!0,w.current=!0,p(new Set),b(C3),c(()=>{const fe=new Set;try{i.setItem(ho,JSON.stringify([]))}catch{}return j(fe),fe})},e[25]=j,e[26]=A):A=e[26];const q=A;let ee;e[27]!==j?(ee=fe=>{m.current=Date.now()+150,c(be=>{const ke=new Set(be);ke.has(fe)?ke.delete(fe):ke.add(fe);try{i.setItem(ho,JSON.stringify(Array.from(ke)))}catch{}return j(ke),ke})},e[27]=j,e[28]=ee):ee=e[28];const Q=ee;let he;e[29]===Symbol.for("react.memo_cache_sentinel")?(he=fe=>{v.current=!0,p(be=>{const ke=new Set(be);return ke.has(fe)?ke.delete(fe):ke.add(fe),ke})},e[29]=he):he=e[29];const M=he;let V;e[30]===Symbol.for("react.memo_cache_sentinel")?(V=fe=>{T.current=!0,S(fe)},e[30]=V):V=e[30];const ie=V,{getOrderedGroups:ce}=JC(y);let ne;e[31]!==g||e[32]!==f||e[33]!==d||e[34]!==y?(ne={collapsedProjects:d,collapsedGroups:f,collapsedActivities:g,groupOrderByProject:y},e[31]=g,e[32]=f,e[33]=d,e[34]=y,e[35]=ne):ne=e[35];const je=ne;let Ee;e[36]!==N||e[37]!==q||e[38]!==ce||e[39]!==j||e[40]!==Q?(Ee={setCollapsedProjects:c,toggleProject:Q,collapseAll:N,expandAll:q,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:p,setCollapsedActivities:D,toggleGroup:M,setGroupOrderByProject:ie,getOrderedGroups:ce},e[36]=N,e[37]=q,e[38]=ce,e[39]=j,e[40]=Q,e[41]=Ee):Ee=e[41];const we=Ee;let Me;return e[42]!==we||e[43]!==je?(Me={state:je,actions:we},e[42]=we,e[43]=je,e[44]=Me):Me=e[44],Me};function v3(){}function j3(t){return new Set([...t,...Yh])}function k3(t){return t.id}function C3(t){const e=new Set(t);for(const s of Yh)e.delete(s);return e}const I3=5*6e4,P3=t=>{const e=Ze.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:a}=t,d=r===void 0?!0:r,{git:c}=Ks(),u=Cn(E3),f=Cn(T3),p=l.useRef(null),h=l.useRef(d);let g,b;e[0]!==d||e[1]!==u||e[2]!==c||e[3]!==f?(g=()=>{const j=d&&!h.current;h.current=d;const P=p.current;if(!(!j||!c||!P||P.git!==c||P.runtimeKey!==f))for(const L of P.paths)Nr(()=>u(L,c))},b=[d,u,c,f],e[0]=d,e[1]=u,e[2]=c,e[3]=f,e[4]=g,e[5]=b):(g=e[4],b=e[5]),l.useEffect(g,b);let x,y;e[6]!==d||e[7]!==u||e[8]!==c||e[9]!==f||e[10]!==s||e[11]!==i?(x=()=>{if(!d)return;if(!c||s.length===0){p.current=null,i(new Map);return}let j=p.current;(!j||j.runtimeKey!==f||j.git!==c)&&(j={runtimeKey:f,git:c,paths:new Set},p.current=j);const{paths:P}=j,L=new Set(s.map(D3));for(const R of P)L.has(R)||P.delete(R);const z=[...L].filter(R=>!P.has(R));if(z.length===0)return;for(const R of z)P.add(R);const H=R=>{const G=Cn.getState().directories.get(R);G?.isGitRepo!==!1&&!G?.status&&P.delete(R)};Nr(async()=>{await c.prefetchProjectStatuses?.(z),await Promise.all(z.map(R=>u(R,c).then(()=>H(R),()=>H(R))))})},y=[d,s,c,f,u,i],e[6]=d,e[7]=u,e[8]=c,e[9]=f,e[10]=s,e[11]=i,e[12]=x,e[13]=y):(x=e[12],y=e[13]),l.useEffect(x,y);let S,m;e[14]!==d||e[15]!==o||e[16]!==s||e[17]!==i?(S=()=>{if(!d)return;const j=new Map;s.forEach(P=>{j.set(P.id,o.get(P.normalizedPath)?.isGitRepo??null)}),i(j)},m=[d,s,o,i],e[14]=d,e[15]=o,e[16]=s,e[17]=i,e[18]=S,e[19]=m):(S=e[18],m=e[19]),l.useEffect(S,m);let v;if(e[20]!==o||e[21]!==s){let j;e[23]!==o?(j=P=>{const L=o.get(P.normalizedPath)?.branch??"";return`${P.id}:${L}`},e[23]=o,e[24]=j):j=e[24],v=s.map(j).join("|"),e[20]=o,e[21]=s,e[22]=v}else v=e[22];const w=v;let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=new Map,e[25]=T):T=e[25];const k=l.useRef(T);let I;e[26]===Symbol.for("react.memo_cache_sentinel")?(I=new Map,e[26]=I):I=e[26];const F=l.useRef(I);let O;e[27]!==d||e[28]!==o||e[29]!==s||e[30]!==a?(O=()=>{if(!d)return;let j=!1;const P=setTimeout(()=>{(async()=>{const z=new Set(s.map(R3));for(const E of k.current.keys())z.has(E)||(k.current.delete(E),F.current.delete(E));const H=Date.now(),R=s.filter(E=>{const D=o.get(E.normalizedPath);if(D?.isGitRepo===!1)return k.current.delete(E.id),F.current.delete(E.id),!1;if(D?.isGitRepo!==!0||D.branch===null)return!1;const C=D.branch.trim(),N=`${E.normalizedPath}\0${C}`,A=k.current.get(E.id);if(A===N){const q=F.current.get(E.id);return q&&(q.at=H),!1}return!(A!==void 0&&H-(F.current.get(E.id)?.at??0)<I3)});if(R.length===0)return;const G=await Nr(()=>Promise.all(R.map(async E=>{const D=o.get(E.normalizedPath)?.branch?.trim()??"",C=`${E.normalizedPath}\0${D}`,N=await ep(E.normalizedPath,D?{knownBranch:D}:void 0).catch(N3);return{id:E.id,inputKey:C,branch:N}})));if(j)return;const _=G.filter(M3);if(_.length===0)return;const $=Date.now();a(E=>{const D=new Map(E);return _.forEach(C=>{const{id:N,branch:A}=C;A&&D.set(N,A)}),D}),_.forEach(E=>{const{id:D,inputKey:C,branch:N}=E;k.current.set(D,C),N&&F.current.set(D,{branch:N,at:$})})})()},150);return()=>{j=!0,clearTimeout(P)}},e[27]=d,e[28]=o,e[29]=s,e[30]=a,e[31]=O):O=e[31];let B;e[32]!==d||e[33]!==o||e[34]!==s||e[35]!==w||e[36]!==a?(B=[d,s,w,o,a],e[32]=d,e[33]=o,e[34]=s,e[35]=w,e[36]=a,e[37]=B):B=e[37],l.useEffect(O,B)};function E3(t){return t.ensureStatus}function T3(t){return t.runtimeKey}function D3(t){return t.normalizedPath}function R3(t){return t.id}function N3(){return null}function M3(t){return t.branch}const A3=t=>{const e=Ze.c(19),{open:s,onOpenChange:r,project:o,onSave:i}=t,a=le(O3),[d,c]=l.useState("general");let u,f;e[0]!==s?(u=()=>{s&&c("general")},f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),l.useEffect(u,f);const p=o?.id??null;let h;e:{if(!p){h=void 0;break e}let S;e[3]!==r||e[4]!==p||e[5]!==a?(S=()=>{r(!1),a(p)},e[3]=r,e[4]=p,e[5]=a,e[6]=S):S=e[6],h=S}const g=h;let b;e[7]!==g||e[8]!==i||e[9]!==s||e[10]!==o||e[11]!==d?(b=s&&o?n.jsx(Qb,{frame:"dialog",project:o,onIdentitySave:i,tab:d,onTabChange:c,onOpenWorktrees:g}):null,e[7]=g,e[8]=i,e[9]=s,e[10]=o,e[11]=d,e[12]=b):b=e[12];let x;e[13]!==b?(x=n.jsx(Zs,{className:"flex h-[min(85vh,40rem)] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:b}),e[13]=b,e[14]=x):x=e[14];let y;return e[15]!==r||e[16]!==s||e[17]!==x?(y=n.jsx(Qs,{open:s,onOpenChange:r,children:x}),e[15]=r,e[16]=s,e[17]=x,e[18]=y):y=e[18],y};function O3(t){return t.setWorktreesPageProjectId}function B3(t,e,s,r){const o=Ze.c(6),[i,a]=l.useState(!0);let d,c;return o[0]!==e||o[1]!==r||o[2]!==s||o[3]!==t?(d=()=>{const u=t.current,f=e.current,p=s.current;if(!u||!f||!p||r===0)return;const h=()=>{const b=f.lastElementChild,x=b?b.getBoundingClientRect().width:0,y=Number.parseFloat(getComputedStyle(f).columnGap)||0,S=Number.parseFloat(getComputedStyle(u).columnGap)||0,m=f.getBoundingClientRect().width+r*(y+x),v=u.getBoundingClientRect().right-f.getBoundingClientRect().left-p.getBoundingClientRect().width-S;a(m<=v)};h();const g=new ResizeObserver(h);return g.observe(u),g.observe(f),g.observe(p),()=>g.disconnect()},c=[t,e,s,r],o[0]=e,o[1]=r,o[2]=s,o[3]=t,o[4]=d,o[5]=c):(d=o[4],c=o[5]),l.useLayoutEffect(d,c),i}const Jh="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",em="text-muted-foreground hover:text-foreground hover:bg-transparent";function kr(t){const e=Ze.c(14),{label:s,pressed:r,onClick:o,className:i,children:a}=t,d=r?Jh:em;let c;e[0]!==i||e[1]!==d?(c=Pe(i,d),e[0]=i,e[1]=d,e[2]=c):c=e[2];let u;e[3]!==a||e[4]!==s||e[5]!==o||e[6]!==r||e[7]!==c?(u=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:c,"aria-label":s,"aria-pressed":r,children:a})}),e[3]=a,e[4]=s,e[5]=o,e[6]=r,e[7]=c,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let p;return e[11]!==u||e[12]!==f?(p=n.jsxs(Ut,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13],p}function F3(t){const e=Ze.c(278),{t:s}=Et(),r=up(),{hideDirectoryControls:o,showProjectDisplayControls:i,showSectionControls:a,handleOpenDirectoryDialog:d,showSourceBoard:c,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:p,openSessionSearch:h,closeSessionSearch:g,sessionSearchInputRef:b,sessionSearchQuery:x,setSessionSearchQuery:y,hasSessionSearchQuery:S,searchMatchCount:m,collapseAll:v,expandAll:w}=t,T=l.useRef(null),k=l.useRef(null),I=l.useRef(null),F=B3(T,k,I,r.length),O=xs(u4),B=xs(d4),j=le(c4),P=le(l4),L=le(a4),z=le(i4),H=E1(),R=le(o4),G=ts(r4),_=ts(n4),$=ts(s4),E=ts(t4),D=ts(e4),C=ts(J3),N=ts(X3),A=ts(Q3),q=le(Z3),ee=ts(Y3),Q=ts(q3),he=ts(G3),M=ts(V3),V=ts(U3),ie=ts(H3),ce=ts(W3),ne=ts(K3),je=ts(z3),Ee=ts($3),we=i&&V==="timeline",Me=i&&!we&&je==="single";let fe;e[0]===Symbol.for("react.memo_cache_sentinel")?(fe=n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=fe):fe=e[0];const be=fe;let ke;e[1]!==s?(ke=(Ve,rt,wt,se)=>{const Fe=rt.find(ot=>{const[$e]=ot;return $e===wt})?.[1];return n.jsxs(hp,{children:[n.jsxs(mp,{children:[n.jsx("span",{className:"flex-1",children:s(Ve)}),Fe?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(Fe)}):null]}),n.jsx(gp,{className:"min-w-[160px]",children:rt.map(ot=>{const[$e,Ct]=ot;return n.jsxs(rs,{onClick:()=>se($e),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Ct)}),wt===$e?be:null]},$e)})})]})},e[1]=s,e[2]=ke):ke=e[2];const Ie=ke;let Te;e[3]!==s?(Te=(Ve,rt,wt)=>n.jsxs(rs,{onClick:wt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Ve)}),rt?be:null]}),e[3]=s,e[4]=Te):Te=e[4];const Y=Te;let ue;e[5]===Symbol.for("react.memo_cache_sentinel")?(ue=n.jsx(Z,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=ue):ue=e[5];let me;e[6]!==O||e[7]!==s?(me=s(O?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=O,e[7]=s,e[8]=me):me=e[8];let re;e[9]!==me?(re=n.jsx("span",{children:me}),e[9]=me,e[10]=re):re=e[10];let pe;e[11]!==re||e[12]!==B?(pe=n.jsxs(rs,{onClick:B,className:"flex items-center gap-2",children:[ue,re]},"select"),e[11]=re,e[12]=B,e[13]=pe):pe=e[13];let U;if(e[14]!==Ie||e[15]!==v||e[16]!==N||e[17]!==w||e[18]!==Me||e[19]!==ce||e[20]!==je||e[21]!==ee||e[22]!==q||e[23]!==A||e[24]!==ne||e[25]!==Ee||e[26]!==Q||e[27]!==_||e[28]!==C||e[29]!==E||e[30]!==ie||e[31]!==M||e[32]!==G||e[33]!==D||e[34]!==i||e[35]!==a||e[36]!==$||e[37]!==V||e[38]!==s||e[39]!==pe||e[40]!==we||e[41]!==Y||e[42]!==he){if(U=[pe],i){let Ve;e[44]!==s?(Ve=s("sessions.sidebar.header.viewMode.label"),e[44]=s,e[45]=Ve):Ve=e[45];let rt;e[46]!==Ve?(rt=n.jsx(Ma,{children:Ve}),e[46]=Ve,e[47]=rt):rt=e[47];let wt;e[48]!==ie||e[49]!==V||e[50]!==s?(wt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Fe=>{const[ot,$e]=Fe;return n.jsxs(rs,{onClick:()=>{ie(ot),en({sidebarViewMode:ot})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s($e)}),V===ot?be:null]},ot)}),e[48]=ie,e[49]=V,e[50]=s,e[51]=wt):wt=e[51];let se;e[52]!==rt||e[53]!==wt?(se=n.jsxs(n.Fragment,{children:[rt,wt]}),e[52]=rt,e[53]=wt,e[54]=se):se=e[54],U.push(se)}if(we){let Ve;if(e[55]!==Ie||e[56]!==ce||e[57]!==ne){let rt;e[59]!==ne?(rt=wt=>{ne(wt),en({sidebarListSessionGrouping:wt})},e[59]=ne,e[60]=rt):rt=e[60],Ve=Ie("sessions.sidebar.header.listGrouping.label",[["project","sessions.sidebar.header.listGrouping.project"],["time","sessions.sidebar.header.listGrouping.time"]],ce,rt),e[55]=Ie,e[56]=ce,e[57]=ne,e[58]=Ve}else Ve=e[58];U.push(Ve)}else{let Ve;if(e[61]!==Ie||e[62]!==ee||e[63]!==Q){let Fe;e[65]!==Q?(Fe=ot=>{Q(ot),en({sidebarProjectSortOrder:ot})},e[65]=Q,e[66]=Fe):Fe=e[66],Ve=Ie("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"]],ee,Fe),e[61]=Ie,e[62]=ee,e[63]=Q,e[64]=Ve}else Ve=e[64];let rt;e[67]!==Ie||e[68]!==M||e[69]!==i||e[70]!==he?(rt=i?Ie("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],he,Fe=>{M(Fe),en({sidebarWorktreeSortOrder:Fe})}):null,e[67]=Ie,e[68]=M,e[69]=i,e[70]=he,e[71]=rt):rt=e[71];let wt;e[72]!==Ie||e[73]!==je||e[74]!==Ee||e[75]!==i?(wt=i?Ie("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],je,Fe=>{Ee(Fe),en({sidebarProjectDisplayMode:Fe})}):null,e[72]=Ie,e[73]=je,e[74]=Ee,e[75]=i,e[76]=wt):wt=e[76];let se;e[77]!==Ve||e[78]!==rt||e[79]!==wt?(se=n.jsxs(n.Fragment,{children:[Ve,rt,wt]}),e[77]=Ve,e[78]=rt,e[79]=wt,e[80]=se):se=e[80],U.push(se)}if(a){let Ve;e[81]!==_||e[82]!==G?(Ve=()=>{_(!G),en({sidebarShowChatsSection:!G})},e[81]=_,e[82]=G,e[83]=Ve):Ve=e[83];let rt;e[84]!==G||e[85]!==Ve||e[86]!==Y?(rt=Y("sessions.sidebar.header.displayMode.showChats",G,Ve),e[84]=G,e[85]=Ve,e[86]=Y,e[87]=rt):rt=e[87];let wt;e[88]!==C||e[89]!==D?(wt=()=>{C(!D),en({sidebarShowPinnedSection:!D})},e[88]=C,e[89]=D,e[90]=wt):wt=e[90];let se;e[91]!==D||e[92]!==wt||e[93]!==Y?(se=Y("sessions.sidebar.header.displayMode.showPinned",D,wt),e[91]=D,e[92]=wt,e[93]=Y,e[94]=se):se=e[94];let Fe;e[95]!==q||e[96]!==E||e[97]!==$||e[98]!==Y?(Fe=q?Y("sessions.sidebar.header.displayMode.showWork",$,()=>{E(!$),en({sidebarShowWorkSection:!$})}):null,e[95]=q,e[96]=E,e[97]=$,e[98]=Y,e[99]=Fe):Fe=e[99];let ot;e[100]!==N||e[101]!==A||e[102]!==we||e[103]!==Y?(ot=we?null:Y("sessions.sidebar.header.displayMode.detailedZoneRows",N,()=>{A(!N),en({sidebarDetailedZoneRows:!N})}),e[100]=N,e[101]=A,e[102]=we,e[103]=Y,e[104]=ot):ot=e[104];let $e;e[105]!==se||e[106]!==Fe||e[107]!==ot||e[108]!==rt?($e=n.jsxs(n.Fragment,{children:[rt,se,Fe,ot]}),e[105]=se,e[106]=Fe,e[107]=ot,e[108]=rt,e[109]=$e):$e=e[109],U.push($e)}if(!Me){let Ve;e[110]===Symbol.for("react.memo_cache_sentinel")?(Ve=n.jsx(Z,{name:"contract-up-down",className:"h-4 w-4"}),e[110]=Ve):Ve=e[110];let rt;e[111]!==s?(rt=s("sessions.sidebar.header.displayMode.collapseAll"),e[111]=s,e[112]=rt):rt=e[112];let wt;e[113]!==rt?(wt=n.jsx("span",{children:rt}),e[113]=rt,e[114]=wt):wt=e[114];let se;e[115]!==v||e[116]!==wt?(se=n.jsxs(rs,{onClick:v,className:"flex items-center gap-2",children:[Ve,wt]}),e[115]=v,e[116]=wt,e[117]=se):se=e[117];let Fe;e[118]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(Z,{name:"expand-up-down",className:"h-4 w-4"}),e[118]=Fe):Fe=e[118];let ot;e[119]!==s?(ot=s("sessions.sidebar.header.displayMode.expandAll"),e[119]=s,e[120]=ot):ot=e[120];let $e;e[121]!==ot?($e=n.jsx("span",{children:ot}),e[121]=ot,e[122]=$e):$e=e[122];let Ct;e[123]!==w||e[124]!==$e?(Ct=n.jsxs(rs,{onClick:w,className:"flex items-center gap-2",children:[Fe,$e]}),e[123]=w,e[124]=$e,e[125]=Ct):Ct=e[125];let Yt;e[126]!==se||e[127]!==Ct?(Yt=n.jsxs(n.Fragment,{children:[se,Ct]}),e[126]=se,e[127]=Ct,e[128]=Yt):Yt=e[128],U.push(Yt)}e[14]=Ie,e[15]=v,e[16]=N,e[17]=w,e[18]=Me,e[19]=ce,e[20]=je,e[21]=ee,e[22]=q,e[23]=A,e[24]=ne,e[25]=Ee,e[26]=Q,e[27]=_,e[28]=C,e[29]=E,e[30]=ie,e[31]=M,e[32]=G,e[33]=D,e[34]=i,e[35]=a,e[36]=$,e[37]=V,e[38]=s,e[39]=pe,e[40]=we,e[41]=Y,e[42]=he,e[43]=U}else U=e[43];if(o){let Ve;e[129]!==s?(Ve=s("sessions.sidebar.header.search.placeholder"),e[129]=s,e[130]=Ve):Ve=e[130];let rt;e[131]!==s?(rt=s("sessions.sidebar.header.search.clear"),e[131]=s,e[132]=rt):rt=e[132];let wt;e[133]!==S||e[134]!==m||e[135]!==s?(wt=S?m===1?s("sessions.sidebar.header.search.matchCountSingle",{count:m}):s("sessions.sidebar.header.search.matchCountPlural",{count:m}):void 0,e[133]=S,e[134]=m,e[135]=s,e[136]=wt):wt=e[136];let se;e[137]!==s?(se=s("sessions.sidebar.header.search.escapeHint"),e[137]=s,e[138]=se):se=e[138];let Fe;return e[139]!==g||e[140]!==b||e[141]!==x||e[142]!==y||e[143]!==se||e[144]!==Ve||e[145]!==rt||e[146]!==wt?(Fe=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(Fc,{inputRef:b,value:x,onSearch:y,onClose:g,placeholder:Ve,clearLabel:rt,leadingHint:wt,trailingHint:se})}),e[139]=g,e[140]=b,e[141]=x,e[142]=y,e[143]=se,e[144]=Ve,e[145]=rt,e[146]=wt,e[147]=Fe):Fe=e[147],Fe}let ae;e[148]!==f||e[149]!==u||e[150]!==j||e[151]!==c||e[152]!==s?(ae=c?n.jsx(kr,{label:s("sourceBoard.title"),pressed:j,onClick:()=>le.getState().setSourceBoardOpen(!j),className:f,children:n.jsx(Z,{name:"git-pull-request",className:u})}):null,e[148]=f,e[149]=u,e[150]=j,e[151]=c,e[152]=s,e[153]=ae):ae=e[153];let Re;e[154]!==s?(Re=s("sessions.sidebar.header.actions.scheduledTasks"),e[154]=s,e[155]=Re):Re=e[155];let W;e[156]!==P?(W=()=>le.getState().setScheduledTasksDialogOpen(!P),e[156]=P,e[157]=W):W=e[157];let ye;e[158]!==u?(ye=n.jsx(Z,{name:"calendar-schedule",className:u}),e[158]=u,e[159]=ye):ye=e[159];let de;e[160]!==f||e[161]!==P||e[162]!==ye||e[163]!==Re||e[164]!==W?(de=n.jsx(kr,{label:Re,pressed:P,onClick:W,className:f,children:ye}),e[160]=f,e[161]=P,e[162]=ye,e[163]=Re,e[164]=W,e[165]=de):de=e[165];let Ne;e[166]!==s?(Ne=s("sessions.sidebar.nav.archive"),e[166]=s,e[167]=Ne):Ne=e[167];let Je;e[168]!==L?(Je=()=>le.getState().setArchivePageOpen(!L),e[168]=L,e[169]=Je):Je=e[169];let Ge;e[170]!==u?(Ge=n.jsx(Z,{name:"archive",className:u}),e[170]=u,e[171]=Ge):Ge=e[171];let ge;e[172]!==f||e[173]!==L||e[174]!==Ne||e[175]!==Je||e[176]!==Ge?(ge=n.jsx(kr,{label:Ne,pressed:L,onClick:Je,className:f,children:Ge}),e[172]=f,e[173]=L,e[174]=Ne,e[175]=Je,e[176]=Ge,e[177]=ge):ge=e[177];let Ae;e[178]!==H||e[179]!==f||e[180]!==u||e[181]!==z||e[182]!==s?(Ae=H?null:n.jsx(kr,{label:s("integrationsCatalog.sidebar.open"),pressed:z,onClick:()=>le.getState().setIntegrationsCatalogOpen(!z),className:f,children:n.jsx(Z,{name:"store-2",className:u})}),e[178]=H,e[179]=f,e[180]=u,e[181]=z,e[182]=s,e[183]=Ae):Ae=e[183];let Ye;e[184]!==de||e[185]!==ge||e[186]!==Ae||e[187]!==ae?(Ye=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[ae,de,ge,Ae]}),e[184]=de,e[185]=ge,e[186]=Ae,e[187]=ae,e[188]=Ye):Ye=e[188];let nt;e[189]!==r||e[190]!==F||e[191]!==f||e[192]!==u||e[193]!==R||e[194]!==s?(nt=F?r.map(Ve=>{const rt=R===Ve.id;return n.jsx(kr,{label:Ve.pageTitle??Ve.name,pressed:rt,onClick:()=>le.getState().setOpenGuestPage(rt?null:Ve.id),className:f,children:n.jsx(yr,{icon:pp(Ve.icon),iconSrc:fp(Ve.id,Ve.icon,Ju().authenticatedAsset),className:u})},Ve.id)}):r.length>0&&n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(Z,{name:"puzzle",className:u})})}),n.jsxs(Ms,{align:"start",children:[n.jsx(Ma,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(L3)]})]}),e[189]=r,e[190]=F,e[191]=f,e[192]=u,e[193]=R,e[194]=s,e[195]=nt):nt=e[195];let oe;e[196]!==Ye||e[197]!==nt?(oe=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[Ye,nt]}),e[196]=Ye,e[197]=nt,e[198]=oe):oe=e[198];const tt=p?g:h,Ue=p?Jh:em;let gt;e[199]!==f||e[200]!==Ue?(gt=Pe(f,Ue),e[199]=f,e[200]=Ue,e[201]=gt):gt=e[201];let bt;e[202]!==s?(bt=s("sessions.sidebar.header.actions.searchSessions"),e[202]=s,e[203]=bt):bt=e[203];let Ce;e[204]!==u?(Ce=n.jsx(Z,{name:"search",className:u}),e[204]=u,e[205]=Ce):Ce=e[205];let _e;e[206]!==p||e[207]!==tt||e[208]!==gt||e[209]!==bt||e[210]!==Ce?(_e=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:tt,className:gt,"aria-label":bt,"aria-expanded":p,children:Ce})}),e[206]=p,e[207]=tt,e[208]=gt,e[209]=bt,e[210]=Ce,e[211]=_e):_e=e[211];let ze;e[212]!==s?(ze=s("sessions.sidebar.header.actions.searchSessions"),e[212]=s,e[213]=ze):ze=e[213];let Oe;e[214]!==ze?(Oe=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:ze})}),e[214]=ze,e[215]=Oe):Oe=e[215];let it;e[216]!==_e||e[217]!==Oe?(it=n.jsxs(Ut,{children:[_e,Oe]}),e[216]=_e,e[217]=Oe,e[218]=it):it=e[218];let X;e[219]!==f?(X=Pe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[219]=f,e[220]=X):X=e[220];let Be;e[221]!==s?(Be=s("sessions.sidebar.header.actions.addProject"),e[221]=s,e[222]=Be):Be=e[222];let Le;e[223]!==u?(Le=n.jsx(Z,{name:"folder-add",className:u}),e[223]=u,e[224]=Le):Le=e[224];let at;e[225]!==d||e[226]!==X||e[227]!==Be||e[228]!==Le?(at=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:X,"aria-label":Be,children:Le})}),e[225]=d,e[226]=X,e[227]=Be,e[228]=Le,e[229]=at):at=e[229];let qe;e[230]!==s?(qe=s("sessions.sidebar.header.actions.addProject"),e[230]=s,e[231]=qe):qe=e[231];let ut;e[232]!==qe?(ut=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:qe})}),e[232]=qe,e[233]=ut):ut=e[233];let dt;e[234]!==at||e[235]!==ut?(dt=n.jsxs(Ut,{children:[at,ut]}),e[234]=at,e[235]=ut,e[236]=dt):dt=e[236];let ft;e[237]!==f?(ft=Pe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[237]=f,e[238]=ft):ft=e[238];let st;e[239]!==s?(st=s("sessions.sidebar.header.displayMode.label"),e[239]=s,e[240]=st):st=e[240];let Rt;e[241]!==u?(Rt=n.jsx(Z,{name:"equalizer-2",className:u}),e[241]=u,e[242]=Rt):Rt=e[242];let Ke;e[243]!==ft||e[244]!==st||e[245]!==Rt?(Ke=n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:ft,"aria-label":st,children:Rt})})}),e[243]=ft,e[244]=st,e[245]=Rt,e[246]=Ke):Ke=e[246];let jt;e[247]!==s?(jt=s("sessions.sidebar.header.displayMode.label"),e[247]=s,e[248]=jt):jt=e[248];let Lt;e[249]!==jt?(Lt=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:jt})}),e[249]=jt,e[250]=Lt):Lt=e[250];let Mt;e[251]!==Ke||e[252]!==Lt?(Mt=n.jsxs(Ut,{children:[Ke,Lt]}),e[251]=Ke,e[252]=Lt,e[253]=Mt):Mt=e[253];let De;e[254]!==U?(De=n.jsx(Ms,{align:"end",className:"min-w-[200px]",children:U.map(_3)}),e[254]=U,e[255]=De):De=e[255];let Tt;e[256]!==Mt||e[257]!==De?(Tt=n.jsxs(Rs,{children:[Mt,De]}),e[256]=Mt,e[257]=De,e[258]=Tt):Tt=e[258];let At;e[259]!==it||e[260]!==dt||e[261]!==Tt?(At=n.jsxs("div",{ref:I,className:"flex min-w-0 items-center gap-1.5",children:[it,dt,Tt]}),e[259]=it,e[260]=dt,e[261]=Tt,e[262]=At):At=e[262];let kt;e[263]!==oe||e[264]!==At?(kt=n.jsxs("div",{ref:T,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[oe,At]}),e[263]=oe,e[264]=At,e[265]=kt):kt=e[265];let pt;e[266]!==g||e[267]!==S||e[268]!==p||e[269]!==m||e[270]!==b||e[271]!==x||e[272]!==y||e[273]!==s?(pt=p?n.jsx("div",{className:"pb-1",children:n.jsx(Fc,{inputRef:b,value:x,onSearch:y,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:S?m===1?s("sessions.sidebar.header.search.matchCountSingle",{count:m}):s("sessions.sidebar.header.search.matchCountPlural",{count:m}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[266]=g,e[267]=S,e[268]=p,e[269]=m,e[270]=b,e[271]=x,e[272]=y,e[273]=s,e[274]=pt):pt=e[274];let Dt;return e[275]!==kt||e[276]!==pt?(Dt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:n.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[kt,pt]})}),e[275]=kt,e[276]=pt,e[277]=Dt):Dt=e[277],Dt}function _3(t,e){return n.jsxs(l.Fragment,{children:[e>0?n.jsx(In,{}):null,t]},e)}function L3(t){return n.jsxs(rs,{onSelect:()=>le.getState().setOpenGuestPage(t.id),children:[n.jsx(yr,{icon:pp(t.icon),iconSrc:fp(t.id,t.icon,Ju().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function $3(t){return t.setProjectDisplayMode}function z3(t){return t.projectDisplayMode}function K3(t){return t.setListSessionGrouping}function W3(t){return t.listSessionGrouping}function H3(t){return t.setSidebarViewMode}function U3(t){return t.sidebarViewMode}function V3(t){return t.setWorktreeSortOrder}function G3(t){return t.worktreeSortOrder}function q3(t){return t.setProjectSortOrder}function Y3(t){return t.projectSortOrder}function Z3(t){return t.sessionWorkEnabled}function Q3(t){return t.setDetailedZoneRows}function X3(t){return t.detailedZoneRows}function J3(t){return t.setShowPinnedSection}function e4(t){return t.showPinnedSection}function t4(t){return t.setShowWorkSection}function s4(t){return t.showWorkSection}function n4(t){return t.setShowChatsSection}function r4(t){return t.showChatsSection}function o4(t){return t.openGuestPageId}function i4(t){return t.isIntegrationsCatalogOpen}function a4(t){return t.isArchivePageOpen}function l4(t){return t.isScheduledTasksDialogOpen}function c4(t){return t.isSourceBoardOpen}function d4(t){return t.toggleMode}function u4(t){return t.enabled}function f4(t){const e=Ze.c(2),{className:s}=t,[r]=l.useState(p4);if(!r)return null;let o;return e[0]!==s?(o=n.jsx(h4,{className:s}),e[0]=s,e[1]=o):o=e[1],o}function p4(){return hn()}function h4({className:t}){const{t:e}=Et(),s=le(k=>k.shortcutOverrides),[r,o]=l.useState(!1),[i,a]=l.useState("Local"),[d,c]=l.useState(!0),[u,f]=l.useState(!1),[p,h]=l.useState(null),[g,b]=l.useState(!1),[x,y]=l.useState(null),S=l.useCallback(async()=>{try{if(li()){a("Local"),c(!0);return}c(!1);const k=await ci(),I=Ug(Vg(k.hosts,k.localOrigin));if(I.id===Gg){a("Local"),c(!0);return}a(ef(I.label.trim()||"Instance"))}catch{a("Local"),c(!0)}},[]);l.useEffect(()=>(S(),ri(()=>{S()})),[S]);const m=l.useCallback(async()=>{if(d){h(null),y(null);return}b(!0),y(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),I=await Ys(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!I.ok)throw new Error(`Server responded with ${I.status}`);h(Xb(await I.json()))}catch(k){h(null),y(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{b(!1)}},[d,e]);l.useEffect(()=>{h(null),y(null),f(!1)},[d,i]),l.useEffect(()=>{if(d)return;const k=3e3,I=3600*1e3;let F=!1,O=null;const B=j=>{O=window.setTimeout(()=>{if(F||typeof document<"u"&&document.visibilityState!=="visible"){B(I);return}m().finally(()=>{F||B(I)})},j)};return B(k),()=>{F=!0,O!==null&&window.clearTimeout(O)}},[m,d,i]);const v=l.useCallback(()=>{if(p?.available){f(!0);return}m()},[m,p?.available]),w=l.useCallback(k=>{o(k),k&&S()},[S]);zf({toggle_services_menu:()=>{if(r){o(!1);return}const k=le.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const T=Wf(Hf("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(Rs,{open:r,onOpenChange:w,children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":e("header.services.openWithCurrent",{current:i}),className:t,children:[n.jsx(Z,{name:"server",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate typography-ui-label",children:i})]})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:i,toggle:T})})})]}),n.jsxs(Ms,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[d?null:n.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:e("header.services.remoteUpdate.title")}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:p?.available?e("header.services.remoteUpdate.available",{version:p.version||""}):g?e("header.services.remoteUpdate.checking"):x||e("header.services.remoteUpdate.upToDate")})]}),p?.available?n.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:v,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(T1,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>o(!1)})]})]}),n.jsx(jl,{open:u,onOpenChange:f,info:p,downloading:!1,downloaded:!1,progress:null,error:x,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Cr="inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",m4="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function g4(t){const e=Ze.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:d}=t,c=a===void 0?!0:a,u=d===void 0?!0:d,{t:f}=Et(),p=Jb(),h=le(b4);if(!c&&!u)return null;let g;e[0]!==p||e[1]!==f?(g=f(p?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=p,e[1]=f,e[2]=g):g=e[2];const b=g;let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=Pe(Cr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=x):x=e[3];let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Z,{name:"download",className:"h-4 w-4"}),e[4]=y):y=e[4];let S;e[5]!==i||e[6]!==b?(S=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:x,"aria-label":b,children:y})}),e[5]=i,e[6]=b,e[7]=S):S=e[7];let m;e[8]!==b?(m=n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:b})}),e[8]=b,e[9]=m):m=e[9];let v;e[10]!==S||e[11]!==m?(v=n.jsxs(Ut,{children:[S,m]}),e[10]=S,e[11]=m,e[12]=v):v=e[12];const w=v;let T;e[13]!==h||e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==f||e[20]!==w?(T=c?n.jsxs(n.Fragment,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx(Z,{name:"settings-3",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>le.getState().setUsageStatsPageOpen(!h),className:Pe(Cr,h&&m4),"aria-label":f("usageStats.openAction"),"aria-pressed":h,children:n.jsx(Z,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(Z,{name:"command",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(Z,{name:"information",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=h,e[14]=o,e[15]=s,e[16]=r,e[17]=c,e[18]=u,e[19]=f,e[20]=w,e[21]=T):T=e[21];const k=!c&&u?w:null;let I;e[22]!==c?(I=c?n.jsx(f4,{className:"ms-auto inline-flex h-6 min-w-0 max-w-[12rem] items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}):null,e[22]=c,e[23]=I):I=e[23];let F;return e[24]!==k||e[25]!==I||e[26]!==T?(F=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[T,k,I]}),e[24]=k,e[25]=I,e[26]=T,e[27]=F):F=e[27],F}function b4(t){return t.isUsageStatsPageOpen}function y4(t){const e=Ze.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=Et();let a;e[0]!==s||e[1]!==o?(a=()=>{le.getState().setArchivePageOpen(!0,s),o()},e[0]=s,e[1]=o,e[2]=a):a=e[2];const d=a;let c;e[3]!==i?(c=i("sessions.sidebar.empty.noMatches.title"),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==c?(u=n.jsx("p",{className:"typography-ui-label font-semibold",children:c}),e[5]=c,e[6]=u):u=e[6];let f;e[7]!==i?(f=i("sessions.sidebar.empty.noMatches.description"),e[7]=i,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=p):p=e[10];let h;e[11]!==d||e[12]!==r||e[13]!==i?(h=r?n.jsx(Nt,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:d,children:i("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=d,e[12]=r,e[13]=i,e[14]=h):h=e[14];let g;return e[15]!==u||e[16]!==p||e[17]!==h?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,p,h]}),e[15]=u,e[16]=p,e[17]=h,e[18]=g):g=e[18],g}const x4=t=>{for(const e of t.sessions.values())if(e.tabs.some(tf))return!0;return!1},S4=()=>{const t=Ze.c(4),{terminal:e}=Ks(),s=zt(x4);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=w4,a=v4;if(s)return Ta(e,"",a,i);let d=j4;return d=Ta(e,"",a,c=>{i(c),d()}),()=>d()},o=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o),null};function w4(t){const e=zt.getState(),s=ey(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const o of r)e.reconcileServerSessions(o,s.get(o)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function v4(){return new Map(zt.getState().actionMutationRevisions)}function j4(){}const k4=50,C4=t=>{const e=new Map;for(const s of t){const r=yt(s.directory),o=s.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===k4))break}return[...e.values()]},ou=(t,e,s,r)=>{for(const[o,i]of t)i===e&&s.has(o)||(r(i,o),t.delete(o));for(const o of s)t.set(o,e)},I4=t=>{const e=Ze.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:a,isWorktreeTopologyLoading:d,unresolvedWorktreeProjectPaths:c,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,h=r===void 0?!0:r;let g,b;e[0]!==p||e[1]!==f||e[2]!==h||e[3]!==u||e[4]!==a||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==c?(g=()=>{!h||i||!a||d||s.forEach(x=>{if(c.has(x.normalizedPath))return;const y=bp(x.normalizedPath),S=o.archivedSessionsByProject.get(x.id)??[],m=u[y]??[],v=new Map(m.map(P4));S.forEach(w=>{const T=D1(w,x.normalizedPath),k=T.toLowerCase();let I=v.get(k);I||(I=f(y,T,null,`archived:${y}:${k}`),v.set(k,I)),I.sessionIds.includes(w.id)||p(y,I.id,w.id)})})},b=[s,h,o,i,a,d,c,u,f,p],e[0]=p,e[1]=f,e[2]=h,e[3]=u,e[4]=a,e[5]=i,e[6]=d,e[7]=s,e[8]=o,e[9]=c,e[10]=g,e[11]=b):(g=e[10],b=e[11]),l.useEffect(g,b)};function P4(t){return[t.name.toLowerCase(),t]}function E4({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:a}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(o.entries()).some(([f,p])=>f!==t&&p.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const c=(i&&r.has(i)?i:null)??a;return!c||c===e?{kind:"none"}:{kind:"select-session",sessionId:c}}const T4=t=>{const e=Ze.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:a,currentSessionOwnerProjectId:d,handleSessionSelect:c,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:h}=t;let g,b;if(e[0]!==s){b=new Map,g=new Map;const k=(I,F,O,B)=>{b.has(I)||b.set(I,new Map);const j=b.get(I);B.forEach(P=>{const L=yt(P.worktree?.path??P.session.directory??O??F);j.set(P.session.id,{directory:L}),g.has(I)||g.set(I,{id:P.session.id,directory:L}),P.children.length>0&&k(I,F,L,P.children)})};s.forEach(I=>{I.groups.forEach(F=>{k(I.project.id,I.project.normalizedPath,F.directory,F.sessions)})}),e[0]=s,e[1]=g,e[2]=b}else g=e[1],b=e[2];let x;e[3]!==g||e[4]!==b?(x={metaByProject:b,firstSessionByProject:g},e[3]=g,e[4]=b,e[5]=x):x=e[5];const y=x,S=l.useRef(null);let m,v;e[6]!==r||e[7]!==o||e[8]!==a||e[9]!==d||e[10]!==c||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==s||e[15]!==y||e[16]!==i||e[17]!==h?(m=()=>{if(!r||u||le.getState().isNewWorktreeDialogOpen||S.current===r)return;const k=s.find(B=>B.project.id===r);if(!k)return;if(S.current===null){S.current=r;return}const I=y.metaByProject.get(r);if(a&&I&&I.has(a)){S.current=r,i(B=>{if(B.get(r)===a)return B;const j=new Map(B);return j.set(r,a),j});return}const F=E4({activeProjectId:r,currentSessionId:a,currentSessionOwnerProjectId:d,projectMap:I,metaByProject:y.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(F.kind==="preserve-current"){d===r&&(S.current=r);return}if(S.current=r,F.kind==="open-draft"){f&&h(!1),p({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(F.kind!=="select-session")return;const O=I?.get(F.sessionId)?.directory??null;c(F.sessionId,O)},v=[r,o,a,d,c,u,f,p,s,y,h,i],e[6]=r,e[7]=o,e[8]=a,e[9]=d,e[10]=c,e[11]=f,e[12]=u,e[13]=p,e[14]=s,e[15]=y,e[16]=i,e[17]=h,e[18]=m,e[19]=v):(m=e[18],v=e[19]),l.useLayoutEffect(m,v);let w,T;e[20]!==r||e[21]!==a||e[22]!==y||e[23]!==i?(w=()=>{if(!r||!a)return;const k=y.metaByProject.get(r);!k||!k.has(a)||i(I=>{if(I.get(r)===a)return I;const F=new Map(I);return F.set(r,a),F})},T=[r,a,y,i],e[20]=r,e[21]=a,e[22]=y,e[23]=i,e[24]=w,e[25]=T):(w=e[24],T=e[25]),l.useEffect(w,T)},D4=t=>{const e=Ze.c(20);let s,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);const a=mt(R4),d=mt(N4);let c;e[5]!==a||e[6]!==i?(c=a?i?.get(a)?.projectId??null:null,e[5]=a,e[6]=i,e[7]=c):c=e[7];const u=c;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,h]=l.useState(f);let g;e[10]!==p||e[11]!==s||e[12]!==a||e[13]!==u||e[14]!==d?(g={...s,activeSessionByProject:p,setActiveSessionByProject:h,currentSessionId:a,currentSessionOwnerProjectId:u,newSessionDraftOpen:d},e[10]=p,e[11]=s,e[12]=a,e[13]=u,e[14]=d,e[15]=g):g=e[15],T4(g);let b,x;return e[16]!==p||e[17]!==o?(b=()=>{o(p)},x=[p,o],e[16]=p,e[17]=o,e[18]=b,e[19]=x):(b=e[18],x=e[19]),l.useEffect(b,x),null};function R4(t){return t.currentSessionId}function N4(t){return!!t.newSessionDraft?.open}const M4=t=>{const e=Ze.c(7),{ownership:s}=t;let r;e[0]!==s?(r=c=>s.sessionsByProject.get(c)??[],e[0]=s,e[1]=r):r=e[1];const o=r;let i;e[2]!==s?(i=c=>s.archivedSessionsByProject.get(c)??[],e[2]=s,e[3]=i):i=e[3];const a=i;let d;return e[4]!==a||e[5]!==o?(d={getSessionsForProject:o,getArchivedSessionsForProject:a},e[4]=a,e[5]=o,e[6]=d):d=e[6],d},A4=(t,e)=>t.map(s=>{const r=yt(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
366
- `),O4=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),B4=[],F4=new WeakMap,_4=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:a,gitBranches:d,sessionOrderRanks:c,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:x,standaloneGroups:y}=t,S=l.useRef(new Map),m=l.useMemo(()=>{const B=S.current,j=new Map;let P=0,L=0;const z=(R,G)=>R.length===G.length&&R.every((_,$)=>_===G[$]),H=e.map(R=>{const G=s(R.id),_=r(R.id),$=o.get(R.normalizedPath)??B4,E=i.has(R.id)?!!i.get(R.id):u,D=a.get(R.id)??null,C=A4($,d),N=O4(G,$,c),A=B.get(R.id);if(A&&A.project===R&&z(A.activeSessions,G)&&z(A.archivedSessions,_)&&A.availableWorktrees===$&&A.rootBranch===D&&A.worktreeBranchesKey===C&&A.worktreeRanksKey===N&&A.isRepo===E&&A.buildGroupedSessions===f)return P+=1,j.set(R.id,A),A.section;if(L+=1,A){const he=A.project!==R?"project":z(A.activeSessions,G)?z(A.archivedSessions,_)?A.availableWorktrees!==$?"worktrees":A.rootBranch!==D?"branch":A.worktreeBranchesKey!==C?"worktreeBranches":A.worktreeRanksKey!==N?"worktreeRanks":A.isRepo!==E?"repo":"builder":"archived":"sessions";As(`ui.sidebar.project_section.rebuilt_reason.${he}`)}const q=yp([...G,..._]),ee=f(q,R.normalizedPath,$,D,E),Q={project:R,groups:ee};return j.set(R.id,{project:R,activeSessions:G,archivedSessions:_,availableWorktrees:$,rootBranch:D,worktreeBranchesKey:C,worktreeRanksKey:N,isRepo:E,buildGroupedSessions:f,section:Q}),Q});return S.current=j,P>0&&As("ui.sidebar.project_section.reused",P),L>0&&As("ui.sidebar.project_section.rebuilt",L),H},[e,s,r,o,i,u,f,a,d,c]),v=l.useMemo(()=>m,[m]),w=l.useMemo(()=>{if(!p)return F4;const B=new WeakMap,P=h.trim().toLowerCase().startsWith("ses_"),L=z=>{const H=g(z.sessions,h),R=Zh(H,h),G=!P&&$o([b(z)],h),_=zn(z).flatMap(({scopeKey:E})=>x[E]??[]),$=P?0:_.filter(E=>$o([E.name],h)).length;B.set(z,{filteredNodes:H,matchedSessionCount:R,folderNameMatchCount:$,groupMatches:G,hasMatch:G||R>0||$>0})};return v.forEach(z=>{z.groups.forEach(L)}),y.forEach(L),B},[p,v,y,g,h,b,x]),T=l.useMemo(()=>p?v.map(B=>({...B,groups:B.groups.filter(j=>w.get(j)?.hasMatch===!0)})).filter(B=>B.groups.length>0):v,[p,v,w]),k=p?T:v,I=l.useRef(new WeakMap),F=l.useMemo(()=>{const B=I.current;return k.map(j=>{const P=B.get(j);if(P&&P.query===h)return P.section;const L=j.groups.filter(E=>!E.isArchivedBucket),z=j.groups.filter(E=>E.isArchivedBucket),H=L.flatMap(E=>p?w.get(E)?.filteredNodes??[]:E.sessions),R=L.map(E=>({scopeKey:E.folderScopeKey??yt(E.directory??null),directory:E.directory??null})).filter(E=>!!E.scopeKey),G=L.find(E=>E.isMain)??null,_={id:"flat",label:G?.label??"",branch:G?.branch??null,description:G?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:G?.directory??j.project.normalizedPath,folderScopeKey:G?.folderScopeKey??j.project.normalizedPath,folderScopes:R,sessions:H};if(p){const E=L.map(D=>w.get(D)).filter(D=>!!D);w.set(_,{filteredNodes:H,matchedSessionCount:E.reduce((D,C)=>D+C.matchedSessionCount,0),folderNameMatchCount:E.reduce((D,C)=>D+C.folderNameMatchCount,0),groupMatches:E.some(D=>D.groupMatches),hasMatch:E.some(D=>D.hasMatch)})}const $={project:j.project,groups:[_,...z]};return B.set(j,{query:h,section:$}),$})},[w,p,h,k]),O=l.useMemo(()=>{if(!p)return 0;const B=(P,L)=>{const z=w.get(L);if(!z)return P;const H=z.folderNameMatchCount+(z.groupMatches?1:0);return P+z.matchedSessionCount+H},j=k.reduce((P,L)=>L.groups.reduce(B,P),0);return y.reduce(B,j)},[p,k,y,w]);return{projectSections:m,visibleProjectSections:v,groupSearchDataByGroup:w,searchableProjectSections:T,sectionsForRender:k,flatSectionsForRender:F,searchMatchCount:O}},L4=180,iu=150,$4=2,z4=8,au=[-1,1],mo=t=>`${t.directory}
367
- ${t.sessionId}`,lu=t=>t?.directory?.trim()||null,tm=l.createContext(null),K4=()=>l.useContext(tm),W4=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),a=l.useRef(new Set),d=l.useRef([]),c=l.useRef(new Set),u=l.useRef(0),f=l.useMemo(()=>Dn(),[]),p=l.useCallback(()=>{u.current+=1,d.current=[],i.current.forEach(S=>window.clearTimeout(S)),i.current.clear(),a.current.clear()},[]),h=l.useCallback(()=>{if(!(!t||f))for(;c.current.size<$4&&d.current.length>0;){const S=d.current.shift();if(!S)break;if(S.generation!==u.current||mt.getState().currentSessionId===S.sessionId||Ba(S.sessionId,S.directory).renderable)continue;const v=mo(S);c.current.add(v),o({directory:S.directory,sessionID:S.sessionId}).catch(()=>{}).finally(()=>{c.current.delete(v),h()})}},[t,f,o]),g=l.useCallback((S,m="neighbor")=>{const v=S?.id,w=lu(S);if(!t||f||!v||!w||v===e)return;const T={sessionId:v,directory:w,generation:u.current},k=mo(T);if(Ba(v,w).renderable||c.current.has(k)||d.current.some(O=>mo(O)===k))return;const I=i.current.get(k);if(I!==void 0){if(m==="hover"&&!a.current.has(k))return;window.clearTimeout(I)}m==="hover"?a.current.add(k):a.current.delete(k);const F=window.setTimeout(()=>{if(i.current.delete(k),a.current.delete(k),T.generation!==u.current)return;const O=d.current;O.length>=z4&&O.shift(),O.push(T),h()},L4);i.current.set(k,F)},[e,t,f,h]),b=l.useCallback(S=>{const m=lu(S);if(!m)return;const v=mo({sessionId:S.id,directory:m}),w=i.current.get(v);w===void 0||!a.current.has(v)||(window.clearTimeout(w),i.current.delete(v),a.current.delete(v))},[]),x=l.useRef(g);x.current=g;const[y]=l.useState(()=>({schedule:S=>x.current(S,"hover"),cancel:b}));return l.useEffect(()=>{p()},[p,e,t,f]),l.useEffect(()=>{if(!t||f||!e||s.length===0)return;const S=window.setTimeout(()=>{const m=s.findIndex(v=>v.id===e);if(!(m<0))for(const v of au)g(s[m+v])},iu);return()=>window.clearTimeout(S)},[e,t,f,g,s]),l.useEffect(()=>{if(!t||f||!e||r.length===0)return;const S=window.setTimeout(()=>{const m=r.findIndex(v=>v.id===e);if(!(m<0))for(const v of au)g(r[m+v])},iu);return()=>window.clearTimeout(S)},[e,t,f,r,g]),l.useEffect(()=>p,[p]),y},H4=t=>{const e=Ze.c(11);let s,r;e[0]!==t?({children:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=mt(U4);let i;e[3]!==s||e[4]!==o?(i={...s,currentSessionId:o},e[3]=s,e[4]=o,e[5]=i):i=e[5];const a=W4(i);let d;if(e[6]!==r||e[7]!==a){let c;e[9]!==a?(c={value:a},e[9]=a,e[10]=c):c=e[10],d=l.createElement(tm.Provider,c,r),e[6]=r,e[7]=a,e[8]=d}else d=e[8];return d};function U4(t){return t.currentSessionId}const V4=t=>{const e=Ze.c(92),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:a,collapsedActivityState:d,onToggle:c,onRename:u,onDelete:f,children:p,renderBody:h,mobileVariant:g,alwaysShowActions:b,isRenaming:x,renameDraft:y,onRenameDraftChange:S,onRenameSave:m,onRenameCancel:v,droppableRef:w,isDropTarget:T,onNewSession:k,depth:I,canExpand:F,hideActions:O,archivedBucket:B}=t,j=d===void 0?null:d,P=h===void 0?!0:h,z=b===void 0?g===void 0?!1:g:b,H=x===void 0?!1:x,R=y===void 0?"":y,G=T===void 0?!1:T,_=I===void 0?0:I,$=F===void 0?!0:F,E=O===void 0?!1:O,D=B===void 0?!1:B,{t:C}=Et(),[N,A]=l.useState(!1),[q,ee]=l.useState(""),Q=l.useRef(null),he=H||N,M=H?R:q;let V;e[0]!==s.name?(V=()=>{ee(s.name),A(!0)},e[0]=s.name,e[1]=V):V=e[1];const ie=V;let ce;e[2]!==M||e[3]!==s.name||e[4]!==H||e[5]!==u||e[6]!==m?(ce=()=>{const Ue=M.trim();Ue&&Ue!==s.name&&u(Ue),H&&m&&m(),A(!1),ee("")},e[2]=M,e[3]=s.name,e[4]=H,e[5]=u,e[6]=m,e[7]=ce):ce=e[7];const ne=ce;let je;e[8]!==H||e[9]!==v?(je=()=>{H&&v&&v(),A(!1),ee("")},e[8]=H,e[9]=v,e[10]=je):je=e[10];const Ee=je;let we;e[11]!==H||e[12]!==S?(we=Ue=>{H&&S?S(Ue):ee(Ue)},e[11]=H,e[12]=S,e[13]=we):we=e[13];const Me=we;let fe,be;e[14]!==H?(fe=()=>{if(!H)return;const Ue=()=>{const Ce=Q.current;Ce&&(Ce.focus(),Ce.select())},gt=requestAnimationFrame(Ue),bt=window.setTimeout(Ue,0);return()=>{cancelAnimationFrame(gt),window.clearTimeout(bt)}},be=[H],e[14]=H,e[15]=fe,e[16]=be):(fe=e[15],be=e[16]),l.useEffect(fe,be);const ke=a?"folder":"folder-open",Ie=!he&&$;let Te;e[17]!==_?(Te=Kn(_),e[17]=_,e[18]=Te):Te=e[18];let Y;e[19]!==Te?(Y={paddingInlineStart:Te},e[19]=Te,e[20]=Y):Y=e[20];const ue=G&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let me;e[21]!==ue?(me=Pe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ue),e[21]=ue,e[22]=me):me=e[22];let re;e[23]!==c||e[24]!==Ie?(re=Ie?Ue=>{Ue.currentTarget.blur(),c()}:void 0,e[23]=c,e[24]=Ie,e[25]=re):re=e[25];const pe=Ie?"button":void 0,U=Ie?0:void 0;let ae;e[26]!==c||e[27]!==Ie?(ae=Ie?Ue=>{(Ue.key==="Enter"||Ue.key===" ")&&(Ue.preventDefault(),c())}:void 0,e[26]=c,e[27]=Ie,e[28]=ae):ae=e[28];let Re;e[29]!==s.name||e[30]!==a||e[31]!==C||e[32]!==Ie?(Re=Ie?a?C("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):C("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=a,e[31]=C,e[32]=Ie,e[33]=Re):Re=e[33];const W=D?z?"pe-7":"group-hover/folder:pe-7 group-has-[:focus-visible]/folder:pe-7":z?"pe-20":"group-hover/folder:pe-20 group-has-[:focus-visible]/folder:pe-20";let ye;e[34]!==W?(ye=Pe("min-w-0 flex items-center gap-0.5 flex-1",W),e[34]=W,e[35]=ye):ye=e[35];let de;e[36]!==$||e[37]!==a?(de=$?n.jsx(eo,{expanded:!a}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=$,e[37]=a,e[38]=de):de=e[38];const Ne=G?"text-primary":"text-muted-foreground";let Je;e[39]!==Ne?(Je=Pe("mx-px h-3 w-3 flex-shrink-0",Ne),e[39]=Ne,e[40]=Je):Je=e[40];let Ge;e[41]!==ke||e[42]!==Je?(Ge=n.jsx(Z,{name:ke,className:Je}),e[41]=ke,e[42]=Je,e[43]=Ge):Ge=e[43];let ge;e[44]!==j||e[45]!==r||e[46]!==M||e[47]!==s.name||e[48]!==Ee||e[49]!==Me||e[50]!==ne||e[51]!==G||e[52]!==he||e[53]!==o||e[54]!==C?(ge=he?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:G4,onMouseDown:q4,onSubmit:Ue=>{Ue.preventDefault(),ne()},children:[n.jsx("input",{ref:Q,value:M,onChange:Ue=>Me(Ue.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:C("sessions.sidebar.folderItem.namePlaceholder"),onClick:Y4,onPointerDown:Z4,onMouseDown:Q4,onKeyDown:Ue=>{if(Ue.key==="Escape"){Ue.stopPropagation(),Ee();return}(Ue.key===" "||Ue.key==="Enter")&&Ue.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:X4,onPointerDown:J4,onMouseDown:e5,children:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),Ee()},onPointerDown:t5,onMouseDown:s5,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:Pe("typography-ui-label font-medium truncate",G?"text-primary":"text-foreground/85"),children:r??s.name})}),n.jsx(Kt,{side:"top",sideOffset:6,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),j?n.jsx(ty,{state:j}):null]}),e[44]=j,e[45]=r,e[46]=M,e[47]=s.name,e[48]=Ee,e[49]=Me,e[50]=ne,e[51]=G,e[52]=he,e[53]=o,e[54]=C,e[55]=ge):ge=e[55];let Ae;e[56]!==ye||e[57]!==de||e[58]!==Ge||e[59]!==ge?(Ae=n.jsxs("div",{className:ye,children:[de,Ge,ge]}),e[56]=ye,e[57]=de,e[58]=Ge,e[59]=ge,e[60]=Ae):Ae=e[60];let Ye;e[61]!==z||e[62]!==D||e[63]!==s.name||e[64]!==ie||e[65]!==E||e[66]!==f||e[67]!==k||e[68]!==he||e[69]!==C?(Ye=!he&&(!E||D)?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",z?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-has-[:focus-visible]/folder:opacity-100 group-has-[:focus-visible]/folder:pointer-events-auto"),children:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!D&&k?n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),k()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":C("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:C("sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,D?null:n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),ie()},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":C("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(Z,{name:"pencil-ai",className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),f()},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":D?C("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):C("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Z,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=z,e[62]=D,e[63]=s.name,e[64]=ie,e[65]=E,e[66]=f,e[67]=k,e[68]=he,e[69]=C,e[70]=Ye):Ye=e[70];let nt;e[71]!==w||e[72]!==Y||e[73]!==me||e[74]!==re||e[75]!==pe||e[76]!==U||e[77]!==ae||e[78]!==Re||e[79]!==Ae||e[80]!==Ye?(nt=n.jsxs("div",{ref:w,style:Y,className:me,onClick:re,role:pe,tabIndex:U,onKeyDown:ae,"aria-label":Re,children:[Ae,Ye]}),e[71]=w,e[72]=Y,e[73]=me,e[74]=re,e[75]=pe,e[76]=U,e[77]=ae,e[78]=Re,e[79]=Ae,e[80]=Ye,e[81]=nt):nt=e[81];let oe;e[82]!==p||e[83]!==a||e[84]!==P||e[85]!==o||e[86]!==i||e[87]!==C?(oe=!a&&P?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?p:i?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:C("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=p,e[83]=a,e[84]=P,e[85]=o,e[86]=i,e[87]=C,e[88]=oe):oe=e[88];let tt;return e[89]!==nt||e[90]!==oe?(tt=n.jsxs("div",{className:"oc-folder",children:[nt,oe]}),e[89]=nt,e[90]=oe,e[91]=tt):tt=e[91],tt},sm=l.memo(V4);function G4(t){return t.stopPropagation()}function q4(t){return t.stopPropagation()}function Y4(t){return t.stopPropagation()}function Z4(t){return t.stopPropagation()}function Q4(t){return t.stopPropagation()}function X4(t){return t.stopPropagation()}function J4(t){return t.stopPropagation()}function e5(t){return t.stopPropagation()}function t5(t){return t.stopPropagation()}function s5(t){return t.stopPropagation()}function n5(t){const e=Ze.c(11);let s,r,o;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o):(s=e[1],r=e[2],o=e[3]);const i=o.isCollapsed&&!o.archivedBucket;let a;e[4]!==s||e[5]!==r||e[6]!==i?(a={nodes:s,includeUnreadSubtasks:r,enabled:i},e[4]=s,e[5]=r,e[6]=i,e[7]=a):a=e[7];const d=Sf(a);let c;return e[8]!==d||e[9]!==o?(c=n.jsx(sm,{...o,collapsedActivityState:d}),e[8]=d,e[9]=o,e[10]=c):c=e[10],c}const Qo=t=>{const e=Ze.c(16),{directory:s,className:r}=t,{t:o}=Et();let i;e[0]!==s?(i=qg(s),e[0]=s,e[1]=i):i=e[1];const a=i;let d;if(e[2]!==a?(d=y=>y.sessions.get(a),e[2]=a,e[3]=d):d=e[3],!zt(d)?.tabs.some(tf))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const p=f;let h;e[6]!==r?(h=Pe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=h):h=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Z,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let b;e[9]!==a||e[10]!==p||e[11]!==h?(b=n.jsx("span",{className:h,role:"img","aria-label":p,"data-action-directory":a,children:g}),e[9]=a,e[10]=p,e[11]=h,e[12]=b):b=e[12];let x;return e[13]!==p||e[14]!==b?(x=n.jsx(Ln,{label:p,children:b}),e[13]=p,e[14]=b,e[15]=x):x=e[15],x},r5=t=>{const e=Ze.c(19),{sessionId:s,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:a,archivedBucket:d,children:c}=t,u=o===void 0?null:o,f=d===void 0?!1:d,p=`session-drag:${r??s}`;let h;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==a?(h={type:"session",sessionId:s,ownerKey:u,sessionDirectory:i,sessionTitle:a,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=s,e[4]=a,e[5]=h):h=e[5];let g;e[6]!==f||e[7]!==p||e[8]!==h?(g={id:p,disabled:f,data:h},e[6]=f,e[7]=p,e[8]=h,e[9]=g):g=e[9];const{attributes:b,listeners:x,setNodeRef:y,isDragging:S}=Ew(g);let m;e[10]!==x?(m=k=>{k.stopPropagation(),x?.onPointerDown&&x.onPointerDown(k)},e[10]=x,e[11]=m):m=e[11];const v=m,w=`touch-pan-y select-none${S?" opacity-30":""}`;let T;return e[12]!==b||e[13]!==c||e[14]!==v||e[15]!==x||e[16]!==y||e[17]!==w?(T=n.jsx("div",{ref:y,...b,...x,onPointerDown:v,className:w,children:c}),e[12]=b,e[13]=c,e[14]=v,e[15]=x,e[16]=y,e[17]=w,e[18]=T):T=e[18],T},nm=t=>{const e=Ze.c(20),{folderId:s,scopeKey:r,ownerKey:o,disabled:i,children:a}=t,d=i===void 0?!1:i;let c;e[0]!==s||e[1]!==r?(c=_n(r,s),e[0]=s,e[1]=r,e[2]=c):c=e[2];const u=`folder-drop:${c}`;let f;e[3]!==d||e[4]!==r?(f=d||sc(r),e[3]=d,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==s||e[7]!==o||e[8]!==r?(p={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=p):p=e[9];let h;e[10]!==u||e[11]!==f||e[12]!==p?(h={id:u,disabled:f,data:p},e[10]=u,e[11]=f,e[12]=p,e[13]=h):h=e[13];const{setNodeRef:g,isOver:b}=Tw(h);let x;e[14]!==a||e[15]!==b||e[16]!==g?(x=a(g,b),e[14]=a,e[15]=b,e[16]=g,e[17]=x):x=e[17];let y;return e[18]!==x?(y=n.jsx(n.Fragment,{children:x}),e[18]=x,e[19]=y):y=e[19],y},o5=t=>{const e=Ze.c(22),{scopeKey:s,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:a}=t,d=r===void 0?null:r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activationConstraint:{distance:8}},e[0]=c):c=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 f=yi(mn(Si,c),mn(xi,u)),[p,h]=l.useState(null),[g,b]=l.useState("Session"),[x,y]=l.useState(null),[S,m]=l.useState(null);if(!s){let B;return e[2]!==a?(B=n.jsx(n.Fragment,{children:a}),e[2]=a,e[3]=B):B=e[3],B}let v;e[4]!==i||e[5]!==d?(v=B=>{h(null),y(null),m(null);const{active:j,over:P}=B;if(!P)return;const L=j.data.current,z=P.data.current;L?.type!=="session"||!L.sessionId||!L.ownerKey||L.archivedBucket===!0||d&&L.ownerKey!==d||z?.type!=="folder"||!z.folderId||!z.scopeKey||!z.ownerKey||sc(z.scopeKey)||z.ownerKey!==L.ownerKey||i(L.sessionId,{folderId:z.folderId,scopeKey:z.scopeKey,ownerKey:z.ownerKey},L.ownerKey)},e[4]=i,e[5]=d,e[6]=v):v=e[6];const w=v;let T,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=B=>{const j=B.active.data.current;if(j?.type==="session"&&j.sessionId){h(j.sessionId),b(j.sessionTitle??"Session");const P=B.active.rect.current.initial?.width,L=B.active.rect.current.initial?.height;y(P??null),m(L??null)}},k=()=>{h(null),y(null),m(null)},e[7]=T,e[8]=k):(T=e[7],k=e[8]);let I;e[9]!==S||e[10]!==p||e[11]!==g||e[12]!==x||e[13]!==o?(I=p&&o?n.jsxs("div",{style:{width:x?`${x}px`:"auto",height:S?`${S}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:[n.jsx(Z,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground me-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:g})]}):null,e[9]=S,e[10]=p,e[11]=g,e[12]=x,e[13]=o,e[14]=I):I=e[14];let F;e[15]!==I?(F=n.jsx(Dw,{children:I}),e[15]=I,e[16]=F):F=e[16];let O;return e[17]!==a||e[18]!==w||e[19]!==f||e[20]!==F?(O=n.jsxs(wi,{sensors:f,collisionDetection:vi,onDragStart:T,onDragCancel:k,onDragEnd:w,children:[a,F]}),e[17]=a,e[18]=w,e[19]=f,e[20]=F,e[21]=O):O=e[21],O},rm=l.createContext(null),i5=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const o=l.useRef(t),i=l.useRef(e),a=l.useRef(s);o.current=t,i.current=e,a.current=s;const d=l.useRef(null);return d.current===null&&(d.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>a.current}),n.jsx(rm.Provider,{value:d.current,children:r})},om=()=>l.useContext(rm),a5=(t,e,s)=>{const r=t[0];if(!r)return null;const o=s??r.scopeKey,i=[],a=new Set;for(const d of t){if(o&&d.scopeKey!==o)continue;const c=d.descendantRange,u=c?[d.id,...e.slice(c[0],c[1])]:[d.id];for(const f of u)a.has(f)||(a.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},im=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},l5=t=>{const e=Ze.c(24),{menuInstanceKey:s,contextMenuInstanceKey:r,openSidebarMenuKey:o,setOpenSidebarMenuKey:i,hasDeferredCloseWork:a,onCloseComplete:d}=t,[c,u]=l.useState(!1),[f,p]=l.useState(!1),h=o===s&&!f,g=r?o===r&&!f:c;let b;e[0]!==a||e[1]!==o||e[2]!==i?(b=I=>{if(o===I){if(a()){p(!0);return}i(null)}},e[0]=a,e[1]=o,e[2]=i,e[3]=b):b=e[3];const x=b;let y;e[4]!==s||e[5]!==x||e[6]!==i?(y=I=>{if(I){u(!1),p(!1),i(s);return}x(s)},e[4]=s,e[5]=x,e[6]=i,e[7]=y):y=e[7];const S=y;let m;e[8]!==r||e[9]!==x||e[10]!==i?(m=I=>{if(!r){u(I);return}if(I){p(!1),i(r);return}x(r)},e[8]=r,e[9]=x,e[10]=i,e[11]=m):m=e[11];const v=m;let w;e[12]!==r||e[13]!==s||e[14]!==d||e[15]!==o||e[16]!==i?(w=I=>{I||(d(),p(!1),(o===s||o===r)&&i(null))},e[12]=r,e[13]=s,e[14]=d,e[15]=o,e[16]=i,e[17]=w):w=e[17];const T=w;let k;return e[18]!==v||e[19]!==S||e[20]!==T||e[21]!==g||e[22]!==h?(k={isMenuOpen:h,isContextMenuOpen:g,handleMenuOpenChange:S,handleContextMenuOpenChange:v,handleMenuOpenChangeComplete:T},e[18]=v,e[19]=S,e[20]=T,e[21]=g,e[22]=h,e[23]=k):k=e[23],k},c5=t=>{const e=Ze.c(10),{project:s,fallback:r}=t,{currentTheme:o}=br(),i=s.iconImage??null;let a;e[0]!==s.id||e[1]!==i?(a={id:s.id,iconImage:i},e[0]=s.id,e[1]=i,e[2]=a):a=e[2];let d;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(d={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=d):d=e[5];let c;return e[6]!==r||e[7]!==a||e[8]!==d?(c=n.jsx(Il,{project:a,options:d,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=a,e[8]=d,e[9]=c):c=e[9],c},cu=t=>{const e=Ze.c(14),{project:s,label:r}=t,o=s.icon?kl[s.icon]:null;let i;e[0]!==s.color?(i=Cl(s.color),e[0]=s.color,e[1]=i):i=e[1];const a=i;let d;e[2]!==a||e[3]!==o?(d=o?n.jsx(Z,{name:o,className:Pe("h-3 w-3",!a&&"text-muted-foreground/75"),style:a?{color:a}:void 0}):n.jsx(Z,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:a?{color:a}:void 0}),e[2]=a,e[3]=o,e[4]=d):d=e[4];const c=d;let u;e[5]!==r?(u=r?{role:"img","aria-label":r}:{},e[5]=r,e[6]=u):u=e[6];const f=u;let p;e[7]!==c||e[8]!==f||e[9]!==s?(p=s.iconImage?n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:s.iconBackground?{backgroundColor:s.iconBackground}:void 0,...f,children:n.jsx(c5,{project:s,fallback:c})}):n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center",...f,children:c}),e[7]=c,e[8]=f,e[9]=s,e[10]=p):p=e[10];const h=p;let g;return e[11]!==r||e[12]!==h?(g=r?n.jsx(Ln,{label:r,children:h}):h,e[11]=r,e[12]=h,e[13]=g):g=e[13],g},cl=t=>{const e=Ze.c(59),{compact:s,project:r,projectLabel:o,projectLine:i,title:a,titleClassName:d,branchLabel:c,spaceMark:u,metaLineLead:f,statusDot:p,pinnedMarker:h,timeSlot:g,directoryIndicator:b,prBadge:x,zombieIndicator:y,goal:S,badges:m,doneHint:v,providerId:w,metaPaddingClass:T,hideMetaOnHoverClass:k,actionsReserveClass:I,actionsMaskClass:F}=t,O=s===void 0?!1:s,B=i===void 0?!1:i,j=u===void 0?null:u,P=f===void 0?null:f,L=S===void 0?null:S,z=v===void 0?null:v;let H;e[0]!==k||e[1]!==T?(H=Pe("ms-auto flex flex-shrink-0 items-center gap-1 transition-opacity",T,k),e[0]=k,e[1]=T,e[2]=H):H=e[2];const R=O?L:null,G=O?y??x:null,_=O?m:null;let $;e[3]!==g?($=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:g}),e[3]=g,e[4]=$):$=e[4];let E;e[5]!==b||e[6]!==z||e[7]!==h||e[8]!==p||e[9]!==_||e[10]!==$||e[11]!==H||e[12]!==R||e[13]!==G?(E=n.jsxs("span",{className:H,children:[R,G,_,b,h,z,p,$]}),e[5]=b,e[6]=z,e[7]=h,e[8]=p,e[9]=_,e[10]=$,e[11]=H,e[12]=R,e[13]=G,e[14]=E):E=e[14];const D=E;let C;e[15]!==F||e[16]!==d?(C=Pe("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",F,d),e[15]=F,e[16]=d,e[17]=C):C=e[17];let N;e[18]!==C||e[19]!==a?(N=n.jsx("div",{dir:"auto",className:C,children:a}),e[18]=C,e[19]=a,e[20]=N):N=e[20];const A=N;if(O){let ne;e[21]!==I?(ne=Pe("@container relative flex w-full min-w-0 items-center gap-1",I),e[21]=I,e[22]=ne):ne=e[22];let je;return e[23]!==D||e[24]!==ne||e[25]!==A?(je=n.jsxs("div",{className:ne,children:[A,D]}),e[23]=D,e[24]=ne,e[25]=A,e[26]=je):je=e[26],je}let q;e[27]!==F||e[28]!==I||e[29]!==D||e[30]!==r||e[31]!==o||e[32]!==B||e[33]!==a||e[34]!==d||e[35]!==A?(q=B?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:Pe("@container relative flex h-5 w-full min-w-0 items-center gap-1",I),children:[r?n.jsx(cu,{project:r,label:null}):null,n.jsx("span",{className:Pe("min-w-0 flex-1 truncate typography-micro text-muted-foreground/85",r&&"[--oc-actions-inset:16px]",F),children:o}),D]}),n.jsx("div",{className:"flex h-5 w-full min-w-0 items-center",children:n.jsx("div",{dir:"auto",className:Pe("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",d),children:a})})]}):n.jsxs("div",{className:Pe("@container relative flex h-5 w-full min-w-0 items-center gap-1",I),children:[A,D]}),e[27]=F,e[28]=I,e[29]=D,e[30]=r,e[31]=o,e[32]=B,e[33]=a,e[34]=d,e[35]=A,e[36]=q):q=e[36];let ee;e[37]!==r||e[38]!==o||e[39]!==B?(ee=r&&!B?n.jsx(cu,{project:r,label:o}):null,e[37]=r,e[38]=o,e[39]=B,e[40]=ee):ee=e[40];let Q;e[41]!==c||e[42]!==P||e[43]!==j?(Q=P??(c?n.jsxs(n.Fragment,{children:[j?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":j}):n.jsx(Z,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:c})]}):null),e[41]=c,e[42]=P,e[43]=j,e[44]=Q):Q=e[44];const he=y??x;let M;e[45]!==w?(M=w?n.jsx(xp,{providerId:w,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[45]=w,e[46]=M):M=e[46];let V;e[47]!==m||e[48]!==L||e[49]!==he||e[50]!==M?(V=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[L,he,m,M]}),e[47]=m,e[48]=L,e[49]=he,e[50]=M,e[51]=V):V=e[51];let ie;e[52]!==ee||e[53]!==Q||e[54]!==V?(ie=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[ee,Q,V]}),e[52]=ee,e[53]=Q,e[54]=V,e[55]=ie):ie=e[55];let ce;return e[56]!==q||e[57]!==ie?(ce=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[q,ie]}),e[56]=q,e[57]=ie,e[58]=ce):ce=e[58],ce},am=750,Xo=t=>{const e=Ze.c(9),{items:s,directory:r}=t,o=Wl();let i;if(e[0]!==r||e[1]!==s||e[2]!==o){let d;e[4]!==r||e[5]!==o?(d=c=>n.jsxs("button",{type:"button",className:Pe("group/ref flex min-w-0 flex-col rounded text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",!c.color&&"text-muted-foreground"),style:c.color?{color:c.color}:void 0,disabled:!c.url,onPointerDown:d5,onMouseDown:u5,onKeyDown:f5,onClick:u=>{u.stopPropagation(),c.url&&o(c.url,r,u)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/ref:underline group-disabled/ref:no-underline",children:[n.jsx(Z,{name:c.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:c.text})]}),c.title?n.jsx("span",{className:"min-w-0 truncate ps-[18px] text-muted-foreground",children:c.title}):null]},c.key),e[4]=r,e[5]=o,e[6]=d):d=e[6],i=s.map(d),e[0]=r,e[1]=s,e[2]=o,e[3]=i}else i=e[3];let a;return e[7]!==i?(a=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:i}),e[7]=i,e[8]=a):a=e[8],a};function d5(t){return t.stopPropagation()}function u5(t){return t.stopPropagation()}function f5(t){return t.stopPropagation()}const p5=150,xa={capture:!0,passive:!0};let To=null;const du=new WeakSet,h5=t=>{To={target:t.target,at:performance.now()}},uu=(t,e)=>t instanceof Node&&t.contains(e);function m5(){const t=Ze.c(4),e=l.useRef(null),s=l.useRef(null);let r,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(du.has(document)||(du.add(document),document.addEventListener("scroll",h5,xa)),()=>s.current?.()),o=[],t[0]=r,t[1]=o):(r=t[0],o=t[1]),l.useEffect(r,o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(c,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!c||!f)return;if(To&&performance.now()-To.at<p5&&uu(To.target,f)){u.cancel();return}const p=h=>{uu(h.target,f)&&e.current?.close()};document.addEventListener("scroll",p,xa),s.current=()=>document.removeEventListener("scroll",p,xa)},t[2]=i):i=t[2];const a=i;let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={actionsRef:e,onOpenChange:a},t[3]=d):d=t[3],d}let dl=!1;const ul=new Set;let fu=!1;function g5(){for(const t of ul)t()}function lm(t){dl!==t&&(dl=t,g5())}function go(t){lm(t.shiftKey)}function b5(){lm(!1)}function y5(){if(fu||typeof window>"u")return;fu=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",go,t),window.addEventListener("keyup",go,t),window.addEventListener("pointermove",go,t),window.addEventListener("pointerdown",go,t),window.addEventListener("blur",b5)}function x5(t){return y5(),ul.add(t),()=>{ul.delete(t)}}function S5(){return dl}function w5(){return!1}function cm(){return us.useSyncExternalStore(x5,S5,w5)}const dm=async(t,e,s)=>{const r=s.getRuntimeKey(),o=yt(t.path);if(!o)throw new Error("Unable to resolve worktree project");const i=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const a=s.getCurrentProjects(),d=a.find(b=>b.id===t.id)??null;if(!d||yt(d.path??null)!==o)throw new Error("Project removed during worktree refresh");const c=oc({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(b=>Jo(b));u.sort((b,x)=>um({metadata:b},{metadata:x}));const f=R1(c.worktreesByProject,o,u,e?.projectDirectory);v5(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=s.getPublishedWorktreesByProject(),h=N1(s.partitionWorktreesByRegisteredProject(a,f),p),g=[...h.values()].flat();return s.recordWorktreesSeen(g.map(b=>b.path),s.now()),s.worktreeMapsEqual(h,p)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:h}),u},v5=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),j5=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Jo(r))])),oc=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:j5(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),um=(t,e)=>{const s=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,o=s.localeCompare(r,void 0,{sensitivity:"base"});return o!==0?o:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},pu=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Jo=t=>({...t,path:yt(t.path)??t.path,projectDirectory:yt(t.projectDirectory)??t.projectDirectory,worktreeRoot:yt(t.worktreeRoot??t.path)??t.worktreeRoot}),hu=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:o}=t,a=yt(e?.path??null)===s,d=a?e?.branch??"":o??"",c={path:s,projectDirectory:r,branch:d,label:a?e?.label||e?.branch||e?.name||pu(s):o||pu(s),name:a?e?.name:void 0,worktreeRoot:a?yt(e?.worktreeRoot??s)??s:s,worktreeStatus:a?e?.worktreeStatus??"ready":"ready",worktreeSource:a?e?.worktreeSource??"existing":"existing",headState:a?e?.headState:o?"branch":void 0};return a&&e?{...e,...c}:c},mu=t=>{const e=yt(t.projectPath??null),s=yt(t.sourceDirectory??null)??yt(t.currentWorktree?.path??null),r=yt(t.discoveredWorktrees.find(f=>yt(f.projectDirectory??null))?.projectDirectory??null),o=yt(t.currentWorktree?.projectDirectory??null),i=r??o??e,a=new Map,d=f=>{const p=yt(f.metadata.path??null);!p||a.has(p)||e&&p!==s&&M1(p,e)||a.set(p,{...f,metadata:Jo({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=yt(f.path??null);p&&d({metadata:Jo({...f,path:p,projectDirectory:yt(f.projectDirectory??null)??i??e??p}),isPrimary:i===p,isCurrent:s===p})}i&&!a.has(i)&&d({metadata:hu({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!a.has(s)&&d({metadata:hu({path:s,projectDirectory:i??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===s,isCurrent:!0});const c=[],u=[];for(const f of a.values()){if(f.isPrimary){c.push(f);continue}u.push(f)}return c.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(um),[...c,...u]},fm=(t,e)=>{const s=t.projectId?e.projects.find(i=>i.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const o=t.currentWorktree?.projectDirectory??null;return o?e.resolveProject(o):null},k5=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=oc({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=fm(t,e),a=yt(i?.path??null);return{cachedTargets:mu({projectPath:a,discoveredWorktrees:a?o.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!a)throw new Error("Unable to resolve worktree project");const c=await dm(i,t.currentWorktree,e);return mu({projectPath:a,discoveredWorktrees:c,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},C5=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),s=[...e.values()].flat();return t.recordWorktreesSeen(s.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:s,availableWorktreesByProject:e}),!0},I5=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),P5=(t,e)=>yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,E5=[],T5=[],D5=[],gu=10,Sa=new WeakMap,R5=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Sa.get(s)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,a=null;const d=()=>{i=!0,a!==null&&window.cancelAnimationFrame(a),a=null,Sa.delete(s),s.removeEventListener("wheel",d),s.removeEventListener("touchstart",d)},c=()=>{if(i||!e.isConnected||!s.isConnected){d();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,As("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){d();return}a=window.requestAnimationFrame(c)};s.addEventListener("wheel",d,{passive:!0}),s.addEventListener("touchstart",d,{passive:!0}),Sa.set(s,d),a=window.requestAnimationFrame(c)},N5=l.memo(function(e){const s=Ze.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:a,onPointerDown:d,onMouseDown:c,onArchive:u,onDelete:f}=e,p=cm(),h=p?o:r;let g;s[0]!==u||s[1]!==f||s[2]!==p?(g=k=>{if(p||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=p,s[3]=g):g=s[3];const b=g,x=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;s[4]!==i||s[5]!==x?(y=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",x,i),s[4]=i,s[5]=x,s[6]=y):y=s[6];const S=p?"delete-bin":"archive";let m;s[7]!==a||s[8]!==S?(m=n.jsx(Z,{name:S,className:a}),s[7]=a,s[8]=S,s[9]=m):m=s[9];let v;s[10]!==b||s[11]!==h||s[12]!==c||s[13]!==d||s[14]!==y||s[15]!==m?(v=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:y,"aria-label":h,onPointerDown:d,onMouseDown:c,onClick:b,onKeyDown:z5,children:m})}),s[10]=b,s[11]=h,s[12]=c,s[13]=d,s[14]=y,s[15]=m,s[16]=v):v=s[16];let w;s[17]!==h?(w=n.jsx(Kt,{side:"top",sideOffset:6,children:h}),s[17]=h,s[18]=w):w=s[18];let T;return s[19]!==v||s[20]!==w?(T=n.jsxs(Ut,{children:[v,w]}),s[19]=v,s[20]=w,s[21]=T):T=s[21],T});function M5(t){As("ui.sidebar_session_node.render");const{t:e}=Et(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:c=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:b,editingRowKey:x,setEditingId:y,setEditingRowKey:S,editTitle:m,setEditTitle:v,handleSaveEdit:w,handleCancelEdit:T,toggleParent:k,handleSessionSelect:I,handleSessionDoubleClick:F,handleCopySessionId:O,openSidebarMenuKey:B,setOpenSidebarMenuKey:j,createFolderAndStartRename:P,handleDeleteSession:L,handleRestoreSession:z,startSessionWorktreeMenuLoad:H,mobileVariant:R,alwaysShowActions:G,secondaryMeta:_,renderContext:$="project",blockingBadgeSessionScopes:E,rowKey:D,dragKey:C,children:N}=t,A=is(J=>J.getFoldersForScope),q=is(J=>J.getSessionFolderId),ee=is(J=>J.removeSessionFromFolder),Q=is(J=>J.addSessionToFolder),he=le(J=>J.openContextPanelTab),M=l.useMemo(()=>Dn(),[]),V=l.useMemo(()=>Do(),[]),ie=l.useContext(A1),ce=M?"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",ne=M?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",je=M,Ee=!c&&!R,we=le(J=>J.sessionWorkEnabled),Me=le(J=>J.sessionRecapEnabled),fe=we&&!c&&!s.session.parentID&&!yl(s.session.directory),be=fe&&!G,ke=(be?1:0)+(Ee?1:0)+(je?1:0),Ie=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][ke],Te=Ee?"pe-13":"pe-7",Y=l.useRef(!1),[ue,me]=l.useState(!1),re=l.useRef(b);re.current=b;const pe=l.useRef(null),U=l.useRef(!1),ae=l.useRef(w);ae.current=w;const Re=m,W=l.useRef(Re);W.current=Re;const ye=l.useRef(null),de=l.useRef(!1),Ne=l.useRef(null),Je=l.useRef(null),Ge=m5(),ge=s.session,Ae=ge,Ye=ns(l.useCallback(J=>{if(_?.projectLabel||!i)return null;const _t=J.projects.find(Xt=>Xt.id===i);return _t?_t.label?.trim()||di(yt(_t.path)??_t.path,null)||_t.path:null},[i,_?.projectLabel])),nt=$==="timeline-chat"||$==="tree-chat"||$==="mixed-compact",oe=qr($)||nt,tt=$==="timeline-by-time",Ue=rc($),gt=$==="timeline-mixed"||$==="mixed-compact"||$==="timeline-by-time",bt=ts(J=>J.showPinnedSection),Ce=gt&&bt,_e=ns(l.useCallback(J=>$!=="timeline-mixed"&&$!=="timeline-by-time"||!i?null:J.projects.find(_t=>_t.id===i)??null,[$,i])),ze=_?.projectLabel??(Ye?Sp(Ye):null),Oe=o3(_,s.worktree?.branch??null),it=_?.inSpace===!0,X=l.useMemo(()=>i3(s.worktree,M),[M,s.worktree]),Be=wp(X?.directory??null,X?.branch??null),Le=l.useMemo(()=>M?E5:vp(ge),[M,ge]),at=l.useMemo(()=>Le.map(J=>({item:zr("pull",J),url:J.url,title:J.title})),[Le]),qe=Yc(at),ut=l.useMemo(()=>qe.filter(J=>J!==null),[qe]),dt=l.useMemo(()=>M?D5:O1(ge),[M,ge]),ft=l.useMemo(()=>dt.flatMap(J=>J.gitlab?[{item:Kr("pull",J.gitlab),url:J.url,title:J.title}]:[]),[dt]),st=Yc(ft),Rt=l.useMemo(()=>B1(Be,[...ut,...st.filter(J=>J!==null)]),[Be,st,ut]),Ke=l.useMemo(()=>{let J=0;return dt.filter(_t=>{if(!_t.gitlab)return!0;const Xt=st[J]!==null;return J+=1,!Xt})},[st,dt]),jt=l.useMemo(()=>F1(Le,Rt),[Le,Rt]),Lt=Be?`var(--pr-${Be.visualState})`:void 0,Mt=l.useMemo(()=>M?T5:Hl(ge),[M,ge]),De=l.useMemo(()=>Mt.flatMap(J=>J.source==="github"?[zr("issue",J)]:[]),[Mt]),Tt=zo(De),At=l.useMemo(()=>Mt.flatMap(J=>J.source==="gitlab"?[Kr("issue",J.ref)]:[]),[Mt]),kt=zo(At),pt=l.useMemo(()=>Mt.flatMap(J=>J.source==="linear"?[Ul(J.identifier)]:[]),[Mt]),Dt=jp(pt),Ve=l.useMemo(()=>{if(Rt.length>0||jt.length>0||Ke.length>0){const J=Rt.map(Vt=>{const gs=kp(Vt,e),Qt=Bl(Vt.provider,Vt.number);return{key:`${Vt.provider??""}:${Vt.repo?.owner??""}/${Vt.repo?.repo??""}#${Vt.number}`,icon:"git-pull-request",label:Qt,color:`var(--pr-${Vt.visualState})`,url:Vt.url,title:Vt.title,text:gs?`${Qt} · ${gs}`:Qt}}),_t=jt.map(Vt=>({key:`${Vt.owner}/${Vt.repo}#${Vt.number}`,icon:"git-pull-request",label:`#${Vt.number}`,url:Vt.url,title:Vt.title,text:`#${Vt.number}`})),Xt=Ke.map(Vt=>({key:Vt.key,icon:"git-pull-request",label:Vt.identifier,url:Vt.url,title:Vt.title,text:Vt.identifier}));return[...J,..._t,...Xt]}return Cp(Mt,Tt,Dt,kt).map(J=>({key:J.key,icon:J.icon,label:J.label,color:J.color??void 0,url:J.url,title:J.title,text:J.statusKey?`${J.label} · ${e(J.statusKey)}`:J.statusText?`${J.label} · ${J.statusText}`:J.label}))},[kt,Tt,Mt,Dt,jt,Rt,e,Ke]),rt=Ve[0]??null,wt=Math.max(0,Ve.length-1),se=Wl(),Fe=Ve.map(J=>J.text).join(", "),ot=mt(J=>J.currentSessionId===ge.id),$e=yt(ge.directory??null)??yt(o??null),Yt=ns(J=>i?J.projects.find(_t=>_t.id===i)?.path??null:null)??$e,es=d!==void 0?d:i??$e??null,Zt=Af(),ss=Ip(),bs=M,ls=K4(),ms=xs(J=>J.enabled),fs=xs(l.useCallback(J=>J.selectedIds.has(ge.id),[ge.id])),Es=xs(J=>J.toggleSelected),cs=xs(J=>J.setRange),Qe=om(),vt=D??ge.id,$t=b===ge.id&&x===vt,ve=l.useCallback(J=>{const _t=[],Xt=Vt=>{Vt.children.forEach(gs=>{_t.push(gs.session.id),Xt(gs)})};return Xt(J),_t},[]),ct=l.useCallback(J=>{const _t=[],Xt=Vt=>{Vt.children.forEach(gs=>{_t.push(gs.session),Xt(gs)})};return Xt(J),_t},[]),[ht,Ot]=l.useState(!1),[te,et]=l.useState(!0),[xt,It]=l.useState(null),St=`${$}:${c?"archived":"active"}:${ge.id}`,Se=D?`session-menu:${D}`:St,We=D?`session-context:${D}`:null,K=_1(l.useCallback(J=>!!J.sessionMemoryState.get(L1(ge.id))?.isZombie,[ge.id])),xe=Pl(ge.id),Xe=xe!==null,lt=$1(ge.id,Xe),Bt=Yp(ge.id),Pt=Sl(ge.id,$e),Gt=Bt||Pt,Ft=s.worktree??mt.getState().getWorktreeMetadata(ge.id)??null,[Wt,qt]=l.useState([]),[vs,ds]=l.useState(!1),bn=l.useRef(!1),Fs=l.useRef(0),Xs=z1(Ae),_s=fe&&Vl(Ae),Mm=_s&&!Xe&&K1(Ae),ic=e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),ac=async()=>{try{await tS(ge.id,$e,_s?"done":"open")}catch{He.error(e("sessions.sidebar.session.work.updateFailed"))}},Am=Zc(J=>J.enabled),no=W1(ge.id)!==void 0,Om=Am&&!c&&!s.session.parentID&&!!$e&&!qu($e),Bm=async()=>{if($e)try{await Zc.getState().setSessionWarm(ge.id,$e,!no)}catch{He.error(e("sessions.warming.toggleFailed"))}},lc=Xs?e(H1[Xs.status]):"",cc=Xs?n.jsx(Ln,{label:lc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":lc,children:n.jsx(Z,{name:"target",className:"h-3 w-3",style:{color:U1[Xs.status]}})})}):null,yn=Ae.title||e("sessions.sidebar.session.untitled"),Mi=Ue&&s.children.length>0,Sr=gi(u,$e,ge.id),Ai=St,Wn=p?!0:f.has(Ai),Fm=l.useMemo(()=>E??al(s,Wn,$e),[Wn,s,$e,E]),{hasPermission:Oi,hasForm:Bi}=V1(Fm),dc=!!Ae.parentID,_m=kf(ge.id)>0&&(!dc||g),uc=G1(Ae)||Date.now(),Lm=q1(uc),Fi=Pp(uc),{isMenuOpen:fc,isContextMenuOpen:pc,handleMenuOpenChange:$m,handleContextMenuOpenChange:zm,handleMenuOpenChangeComplete:hc}=l5({menuInstanceKey:Se,contextMenuInstanceKey:We,openSidebarMenuKey:B,setOpenSidebarMenuKey:j,hasDeferredCloseWork:()=>pe.current!==null,onCloseComplete:()=>{if(!pe.current)return;const{id:J,title:_t}=pe.current;pe.current=null,y(J),S(vt),v(_t)}}),wr=fc||pc,mc=l.useMemo(()=>Y1(Ae)?.key??null,[Ae]),_i=l.useMemo(()=>xt?ve(xt).length:0,[ve,xt]),Li=l.useCallback(async J=>{const _t=[];let Xt=0;for(const Vt of J)try{if(!$e)throw new Error("Session directory is required for export");const gs=await Zt({directory:$e,sessionID:Vt.session.id});if(!gs)throw new Error("Session runtime changed during export");const Qt=Vt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),qs=Vt.session.agent,Ws=await Li(Vt.children);Xt+=Ws.skipped,_t.push({title:Qt,agent:qs,records:gs,children:Ws.children})}catch{Xt+=ve(Vt).length+1}return{children:_t,skipped:Xt}},[ve,Zt,$e,e]),$i=l.useCallback(J=>{J<=0||He.warning(J===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:J}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:J}))},[e]),zi=l.useCallback(async(J,_t)=>{if(!$e){He.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Xt=await Zt({directory:$e,sessionID:ge.id}).catch(()=>null);if(!Xt){He.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Xt.length===0){He.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Vt,gs=0;if(J&&_t.children.length>0){const js=await Li(_t.children);Vt=js.children,gs=js.skipped}const Qt=Of(Xt,Ae.title??null,Vt),qs=Bf(Ae.title??null),Ws=await Ff(Qt,qs);if(Ws){He.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Q1()),onClick:()=>{Z1(Ws).then(js=>{js||He.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),$i(gs);return}_f(Qt,qs),He.success(e("sessions.sidebar.session.export.success")),$i(gs)},[Li,Zt,Ae.title,ge.id,$e,$i,e]),gc=Lf(),Km=l.useMemo(()=>$f(gc),[gc]),Wm=l.useCallback(J=>{Gp({entry:J,t:e,session:{id:ge.id,title:Ae.title,directory:$e},loadRecords:()=>$e?Zt({directory:$e,sessionID:ge.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>He.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Zt,Ae.title,ge.id,$e,e]),Hm=l.useCallback(async()=>{const J=s.children.length>0?s:sy(Ae);if(J.children.length>0){It(J),et(!0),Ot(!0);return}await zi(!1,J)},[zi,s,Ae]),Um=l.useCallback(()=>{$e&&vn("desktop_open_session_mini_chat_window",{sessionId:ge.id,directory:$e,...Tr()}).catch(J=>{console.warn("[session-sidebar] failed to open mini chat window",J)})},[ge.id,$e]),bc=()=>{if(!$e)return;const J=sS()??$e;he(J,{mode:"chat",dedupeKey:`session:${ge.id}`,label:yn,sessionTitleFallback:yn,targetDirectory:$e})};if(l.useEffect(()=>{if(!$t)return;const J=_t=>{const Vt=(_t.target instanceof HTMLElement?_t.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(vt)}"]`);Je.current&&!Vt&&ae.current(W.current)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[$t,vt]),l.useLayoutEffect(()=>{if(!$t){ye.current===vt&&(ye.current=null);return}ye.current!==vt&&(ye.current=vt,de.current=!0)},[m,$t,vt]),l.useLayoutEffect(()=>{if(!$t||!de.current)return;const J=Ne.current;!J||J.value!==m||(de.current=!1,J.focus(),J.select())},[m,$t,Re]),$t){const J=n.jsxs("form",{ref:Je,"data-session-rename-form":vt,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:_t=>{_t.preventDefault(),w(Re)},children:[n.jsx("input",{ref:Ne,value:Re,onChange:_t=>v(_t.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:_t=>Ea(_t,T)}),n.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:n.jsx(Z,{name:"check",className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:T,"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:n.jsx(Z,{name:"close",className:"size-3.5"})})]});return Ue?n.jsxs("div",{style:{paddingInlineStart:Kn(r)},className:Pe("group relative my-0.5 flex items-center gap-1.5 rounded-md pe-2.5",oe?"py-1":"py-[3px]"),children:[n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:J})]},ge.id):n.jsx("div",{style:{paddingInlineStart:gu},className:Pe("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",nt?"py-1":"py-1.5",ot&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(cl,{compact:nt,project:_e,projectLabel:ze,projectLine:tt,title:J,titleClassName:"text-foreground",branchLabel:Oe,spaceMark:it?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:Fi,directoryIndicator:null,prBadge:rt?n.jsxs("span",{className:Pe("inline-flex flex-shrink-0 items-center gap-1 typography-micro",rt.color?"oc-ref-tint":"text-muted-foreground"),style:rt.color?or(rt.color):void 0,children:[n.jsx(Z,{name:rt.icon,className:"h-3 w-3"}),nt?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:rt.label}),wt>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",wt]}):null]})]}):null,zombieIndicator:null,goal:cc,badges:null,hideMetaOnHoverClass:""})},ge.id)}const yc=e("sessions.sidebar.session.status.questionPending"),Ki=!Gt&&!Xe&&_m&&!ot,Vm=Xe||Ki,Gm=n.jsx(El,{state:xe??"unread",tooltip:!0}),qm=(Xe||Ki)&&lt,Ym=oe&&!nt?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][ke]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][ke],Zm=G?void 0:wr?"oc-actions-mask":M?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",Qm=wr?"opacity-0":ne,xc=e("sessions.sidebar.session.status.pinned"),Xm=n.jsx(Ln,{label:xc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":xc,children:n.jsx(Z,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),Jm=n.jsx(Z,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Pt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),ro=Gt?Jm:Vm?Gm:null,Wi=Ue&&ro!==null&&!(Mi&&G),Hi=Mi?n.jsx("span",{role:"button",tabIndex:0,onClick:J=>{J.stopPropagation(),J.currentTarget.blur(),k(Ai)},onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),k(Ai))},className:Pe("inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Wi&&"opacity-0 transition-opacity group-hover:opacity-100 group-has-[:focus-visible]:opacity-100"),"aria-label":e(Wn?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":Wn,children:n.jsx(eo,{expanded:Wn})}):null,eg=Ue?Wi?n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[Hi,Hi?n.jsx("span",{className:"pointer-events-none absolute inset-0 inline-flex items-center justify-center transition-opacity group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",children:ro}):ro]}):Hi??n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}):null,Ui=K?n.jsx(Z,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,tg=J=>{J.stopPropagation()},sg=J=>{J.stopPropagation()},ng=J=>{J.stopPropagation()},Vi=J=>{J.preventDefault(),J.stopPropagation()},Gi=J=>{J.preventDefault(),J.stopPropagation()},rg=J=>{J.preventDefault(),J.stopPropagation(),j(null),L(ge,{archivedBucket:c})},og=J=>{J.preventDefault(),J.stopPropagation(),j(null),L(ge,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},ig=J=>{J.preventDefault(),J.stopPropagation()},ag=J=>{J.preventDefault(),J.stopPropagation()},lg=J=>{J.preventDefault(),J.stopPropagation(),ie?.vscode?.executeCommand("openchamber.openSessionInEditor",ge.id,yn)},Sc=J=>{if(Y.current){Y.current=!1;return}if(ms){if(J?.preventDefault(),J?.stopPropagation(),J?.shiftKey){const _t=Qe?.getEntries(),Xt=_t??Array.from(document.querySelectorAll("[data-session-row]")).map(Qt=>Qt.getAttribute("data-session-row")).filter(Qt=>!!Qt).map(Qt=>({id:Qt,rowKey:Qt,scopeKey:es,archived:c})),Vt=_t?xs.getState().anchorRowKey:xs.getState().anchorId,gs=new Map;gs.set(ge.id,ve(s)),cs(Vt,vt,Xt,Qe?.getDescendantIds()??[],es,gs);return}Es(ge.id,es,ve(s),vt);return}if(J?.shiftKey&&!M&&$e){bc();return}J?.currentTarget&&R5(J.currentTarget),I(ge.id,$e)},cg=J=>{J.defaultPrevented||(J.target instanceof HTMLElement?J.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Sc(J)},dg=J=>{(J.button===2||J.button===0&&J.ctrlKey&&!ms)&&(Y.current=!0),J.button===0&&J.shiftKey&&!ms&&J.preventDefault()},ug=J=>{R&&J.pointerType==="touch"&&me(!0),J.button===0&&!ot&&!ms&&!bs&&$e&&!Ba(ge.id,$e).renderable&&ss({directory:$e,sessionID:ge.id}).catch(()=>{})},Hn=!ot&&!ms&&$e?{id:ge.id,directory:$e}:null,fg=J=>{J.pointerType!=="mouse"||!Hn||ls?.schedule(Hn)},pg=()=>{Hn&&ls?.schedule(Hn)},wc=()=>{Hn&&ls?.cancel(Hn)},vc=J=>{R&&J.pointerType==="touch"&&me(!1)},hg=J=>{bn.current=J,Fs.current+=1;const _t=Fs.current;if(!J){ds(!1);return}const Xt=H({projectId:i??null,sourceDirectory:$e,currentWorktree:Ft});qt(Xt.cachedTargets),ds(!1),Xt.refreshTargets.then(Vt=>{!bn.current||Fs.current!==_t||(qt(Vt),ds(!1))}).catch(()=>{!bn.current||Fs.current!==_t||ds(!0)})},jc=({Item:J,Separator:_t,Sub:Xt,SubTrigger:Vt,SubContent:gs})=>n.jsxs(n.Fragment,{children:[n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(J,{onClick:()=>{pe.current={id:ge.id,title:yn}},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:ge.id,directory:$e,open:wr,Item:J}),n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(J,{onClick:()=>O(ge.id),className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"file-copy",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(os,{hint:e(Sr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(J,{onClick:()=>{if(!$e)return;const Qt=Sr?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";ny({directory:$e,sessionId:ge.id}).catch(()=>He.error(e(Qt)))},className:"[&>svg]:me-1",children:[Sr?n.jsx(Z,{name:"unpin",className:"me-1 h-4 w-4"}):n.jsx(Z,{name:"pushpin",className:"me-1 h-4 w-4"}),e(Sr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),fe?n.jsx(os,{hint:e(_s?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(J,{onClick:()=>{ac()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:_s?"check":"eye",className:"me-1 h-4 w-4"}),e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,Om?n.jsx(os,{hint:e(no?"sessions.sidebar.session.menuHint.stopWarm":"sessions.sidebar.session.menuHint.keepWarm"),children:n.jsxs(J,{onClick:()=>{Bm()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:no?"fire-fill":"fire",className:"me-1 h-4 w-4"}),e(no?"sessions.sidebar.session.menu.stopWarm":"sessions.sidebar.session.menu.keepWarm")]})}):null,n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(J,{onClick:()=>{Hm()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),Km.map(Qt=>n.jsxs(J,{onClick:()=>Wm(Qt),className:"[&>svg]:me-1",children:[n.jsx(yr,{icon:Qt.icon,iconSrc:Qt.iconSrc,className:"me-1 size-4"}),Qt.action.label]},`${Qt.guest.id}:${Qt.action.id}`)),s3({isSubtaskSession:dc,archivedBucket:!!c,isVSCode:M,sessionDirectory:$e})?(()=>{const Qt=n3({sessionDirectory:$e,isStreaming:Xe,isMovingToWorktree:Bt}),qs=I5({targets:Wt,loadFailed:vs}),Ws=n.jsxs(Vt,{disabled:Qt,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":ge.id,children:[n.jsx(Z,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),js=Bt?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):Xe?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(Xt,{onOpenChange:hg,children:[js?n.jsx(os,{hint:js,children:Ws}):Ws,n.jsxs(gs,{className:"min-w-[220px]","data-session-worktree-submenu":ge.id,children:[Wt.map(ks=>{const Ss=yt(ks.metadata.path??null)??ks.metadata.path,ws=ks.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ks.metadata.label||ks.metadata.branch||ks.metadata.name||ks.metadata.path,an=ks.isCurrent||ks.metadata.worktreeStatus!=="ready";return n.jsxs(J,{disabled:an,title:ks.metadata.path,"data-session-worktree-target":Ss,onClick:()=>{an||!$e||Ho({kind:"existing",root:Ae,descendants:Bo(Ae,ct(s)),sourceDirectory:$e,destination:ks.metadata,messages:Wo(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[n.jsx("span",{className:"truncate",children:ws}),ks.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ks.isCurrent?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Ss)}),qs.refreshState==="error"?n.jsx(J,{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,n.jsx(_t,{}),n.jsxs(J,{disabled:Qt,"data-session-worktree-new-action":"true",onClick:()=>{Qt||!$e||Ho({kind:"quick",root:Ae,descendants:Bo(Ae,ct(s)),sourceDirectory:$e,messages:Wo(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,mc?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(J,{onClick:()=>le.getState().setRunOverviewKey(mc),className:"[&>svg]:me-1",children:[n.jsx(Fa,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,$e&&!c&&!oe?(()=>{const Qt=[],qs=Ss=>{const ws=yt(Ss??null);ws&&!Qt.includes(ws)&&Qt.push(ws)};if(i&&!M){const Ss=ns.getState().projects.find(an=>an.id===i),ws=yt(Ss?.path??null);qs(ws),ws&&(mt.getState().availableWorktreesByProject.get(ws)??[]).forEach(an=>qs(an.path))}qs(xl($e)),qs($e);const Ws=Qt.flatMap(Ss=>A(Ss).map(ws=>({scope:Ss,folder:ws}))),js=Ws.find(({scope:Ss,folder:ws})=>q(Ss,ge.id)===ws.id)??null,ks=Qt[0]??$e;return n.jsxs(n.Fragment,{children:[n.jsx(_t,{}),n.jsxs(Xt,{children:[n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(Vt,{className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(gs,{className:"min-w-[180px]",children:[Ws.length===0?n.jsx(J,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Ws.map(({scope:Ss,folder:ws})=>{const an=js?.folder.id===ws.id;return n.jsxs(J,{onClick:()=>{if(an){ee(Ss,ge.id);return}js&&js.scope!==Ss&&ee(js.scope,ge.id),Q(Ss,ws.id,ge.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ws.name}),an?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ws.id)}),n.jsx(_t,{}),n.jsxs(J,{onClick:()=>{const Ss=P(ks);Ss&&(U.current=!0,js&&js.scope!==ks&&ee(js.scope,ge.id),Q(ks,Ss.id,ge.id))},children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),js?n.jsxs(J,{onClick:()=>{ee(js.scope,ge.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,M?null:n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(J,{disabled:!$e,onClick:bc,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"chat-4",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")})]})}),V?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(J,{disabled:!$e,onClick:Um,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"window",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(_t,{}),c?null:n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>L(ge,{archivedBucket:c}),children:[n.jsx(Z,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),c?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>z(ge),children:[n.jsx(Z,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(J,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>L(ge,{archivedBucket:c,hardDelete:!0}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),mg=J=>{J.preventDefault(),J.stopPropagation(),ac()},qi=G?"h-6 w-6":oe&&!nt?"h-5 w-5":"h-4 w-4",oo=G?"h-3.5 w-3.5":oe&&!nt?"h-3 w-3":"h-2.5 w-2.5",gg=G?"h-4 w-4":oe&&!nt?"h-3.5 w-3.5":"h-3 w-3",kc=Me&&!Xe&&X1(Ae)?.recap||null,Cc=e("sessions.sidebar.session.work.doneSuggested"),bg=J=>Mm?n.jsx(Ln,{label:Cc,children:n.jsx("span",{className:Pe("inline-flex flex-shrink-0 items-center text-muted-foreground/75",J),"aria-label":Cc,children:n.jsx(Z,{name:"check",className:"h-3.5 w-3.5"})})}):null,Ic=e("sessions.sidebar.session.status.permissionRequired"),yg=Oi||Bi?n.jsxs(n.Fragment,{children:[Oi?n.jsx(Ln,{label:Ic,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":Ic,children:n.jsx(Z,{name:"shield",className:"h-3 w-3"})})}):null,Bi?n.jsx(Ln,{label:yc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":yc,children:n.jsx(Z,{name:"question",className:"h-3 w-3"})})}):null]}):null,xg=oe&&rt?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,closeDelay:am,children:n.jsxs("button",{type:"button",className:Pe("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",rt.color?"oc-ref-tint":"text-muted-foreground"),style:rt.color?or(rt.color):void 0,disabled:!rt.url,"aria-label":Fe,onPointerDown:Vi,onMouseDown:Gi,onClick:J=>{J.preventDefault(),J.stopPropagation(),!(J.target instanceof Element&&J.target.closest("[data-ref-more]"))&&rt.url&&se(rt.url,Yt,J)},onKeyDown:J=>J.stopPropagation(),children:[n.jsx(Z,{name:rt.icon,className:"h-3 w-3"}),nt?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:rt.label}),wt>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",wt]}):null]})]})}),n.jsx(Kt,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(Xo,{items:Ve,directory:Yt})})]}):null,Sg=n.jsx(cl,{compact:!qr($),project:_e,projectLabel:ze,projectLine:tt,title:vo(yn,h),titleClassName:ot||fs?"text-interactive-selection-foreground":Ki||Oi||Bi?"font-semibold text-foreground":Xe?"text-foreground":"text-muted-foreground",branchLabel:Oe,spaceMark:it?e("sessions.sidebar.group.space"):null,statusDot:Wi?null:ro,pinnedMarker:Sr&&!Gt&&!Ce?Xm:null,timeSlot:qm?n.jsx(J1,{sessionId:ge.id,running:Xe,className:"typography-micro"}):Fi,directoryIndicator:!c&&$e&&$!=="project"?n.jsx(Qo,{directory:$e}):null,prBadge:xg,zombieIndicator:oe?Ui:null,goal:cc,badges:yg,doneHint:bg(),providerId:oe?Ae.model?.providerID??null:null,metaPaddingClass:oe&&G?Ee?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:G&&!M?"":Qm,actionsReserveClass:Ym,actionsMaskClass:Zm}),wg=n.jsx(Ms,{align:"end",className:"min-w-[180px]",finalFocus:()=>U.current?(U.current=!1,!1):!re.current,children:jc({Item:rs,Separator:In,Sub:hp,SubTrigger:mp,SubContent:gp})}),vg=n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-content",finalFocus:()=>U.current?(U.current=!1,!1):!re.current,style:{color:"var(--surface-elevated-foreground)"},className:Pe(Da,"min-w-[180px]"),children:jc({Item:({className:J,..._t})=>n.jsx(Kp,{className:Pe(If,J),..._t}),Separator:({className:J,..._t})=>n.jsx(zp,{className:Pe(Cf,J),..._t}),Sub:Ow,SubTrigger:({className:J,children:_t,...Xt})=>n.jsxs(Bw,{className:Pe(eS,J),...Xt,children:[_t,n.jsx(Z,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:J,children:_t,...Xt})=>n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(Da,J),...Xt,children:_t})})})})})})});return n.jsxs(l.Fragment,{children:[n.jsx(r5,{sessionId:ge.id,dragKey:C??vt,ownerKey:a??es,sessionDirectory:$e??null,sessionTitle:yn,archivedBucket:c,children:n.jsxs(Zr,{open:pc,onOpenChange:zm,onOpenChangeComplete:hc,children:[n.jsxs(Wp,{render:n.jsx("div",{"data-session-row":ge.id,"data-session-scope":es??"","data-session-archived":c?"1":"0","aria-current":ot?"page":void 0,onClick:cg,style:{paddingInlineStart:Ue?Kn(r):gu},className:Pe("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",Ue&&"gap-1.5",oe?nt?"py-1":"py-1.5":"py-[3px]",!(ot||fs)&&"hover:bg-interactive-hover/60",(ot||fs)&&"bg-interactive-selection/70 text-interactive-selection-foreground",fs&&"ring-1 ring-inset ring-border")}),children:[eg,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Ut,{actionsRef:Ge.actionsRef,onOpenChange:Ge.onOpenChange,children:[n.jsx(Ht,{asChild:!0,closeDelay:0,disabled:M,children:n.jsx("div",{role:"button",tabIndex:0,"data-session-row-main":"",onKeyDown:J=>{J.target!==J.currentTarget||J.key!=="Enter"&&J.key!==" "||(J.preventDefault(),J.currentTarget.click())},"aria-pressed":ms?fs:void 0,onPointerDown:ug,onPointerUp:vc,onPointerCancel:vc,onPointerEnter:fg,onPointerLeave:wc,onFocus:pg,onBlur:wc,onMouseDown:dg,onClick:J=>Sc(J),onDoubleClick:J=>{J.stopPropagation(),F(ge.id,yn)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none",ue&&"bg-interactive-hover/70",oe||!G?void 0:M?Ie:Te),children:Sg})}),M?null:n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs text-start",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-start text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{dir:"auto",className:"oc-ui-start-align min-w-0 truncate font-medium text-foreground",children:yn}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:Lm,children:Fi})]}),ze?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(Z,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:ze})]}):null,Oe?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[it?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0","aria-hidden":!1,role:"img","aria-label":e("sessions.sidebar.group.space")}):n.jsx(Z,{name:"git-branch",className:Pe("h-3 w-3 flex-shrink-0",Lt&&"oc-ref-tint"),style:Lt?or(Lt):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:Oe})]}):null,Ve.length>0?n.jsx(Xo,{items:Ve,directory:Yt}):null,kc?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:kc}):null]})})]})}),Ui&&!R&&!oe?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:Ui}):null,n.jsx("div",{className:Pe("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",oe&&!nt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",wr||G&&!M?"opacity-100":Pe("opacity-0",ce)),children:n.jsxs(bi,{delayDuration:400,children:[be?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",qi,_s?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":ic,onPointerDown:Vi,onMouseDown:Gi,onClick:mg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:_s?"check":"eye",className:_s?gg:oo})})}),n.jsx(Kt,{side:"top",sideOffset:6,children:ic})]}):null,Ee?n.jsx(N5,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:qi,iconSizeClass:oo,onPointerDown:Vi,onMouseDown:Gi,onArchive:rg,onDelete:og}):null,je?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",qi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:ig,onMouseDown:ag,onClick:lg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"external-link",className:oo})})}),n.jsx(Kt,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Rs,{open:fc,onOpenChange:$m,onOpenChangeComplete:hc,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",G?"h-6 w-6 opacity-100":wr?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:sg,onMouseDown:ng,onClick:tg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"more-2",className:oo})})}),wg]})]})})]}),vg]})}),Mi&&Wn?N:null,n.jsx(Qs,{open:ht,onOpenChange:Ot,children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(rn,{children:_i===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:_i}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:_i})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:te,onChange:J=>et(J.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(Pn,{children:[n.jsx(Nt,{type:"button",onClick:()=>Ot(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{type:"button",onClick:()=>{Ot(!1),zi(te,xt??s)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},ge.id)}const bu=t=>yt(t.session.directory??null),A5=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),O5=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",s=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(s)?t.openSidebarMenuKey.slice(s.length):null},yu=t=>t.menuOpenSessionId??O5(t),bo=(t,e,s)=>e?s.has(t.node.session.id)?!0:gr(t.node,e):!1,fl=(t,e,s,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(s.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let a=0;a<t.children.length;a+=1)if(fl(t.children[a],e.children[a],s,r,o))return!0;return!1},B5=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return fl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||fl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},F5=(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&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&Ep(t,e),_5=(t,e)=>{if(t.node.session.id!==e.node.session.id||!F5(t.node.session,e.node.session)||!P5(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(bu(t.node)!==bu(e.node))return"nodeDirectory";if(!A5(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Vh(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&B5(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(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&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=yu(t),o=yu(e);if(gr(t.node,r)||gr(e.node,o))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.children===e.children?null:"callbacks"},L5=(t,e)=>{const s=_5(t,e);return s===null?!0:(As(`ui.sidebar_session_node.props_changed.${s}`),!1)},$5=l.memo(M5,L5);function z5(t){return t.stopPropagation()}const K5=t=>{const{t:e}=Et(),s=l.useRef(t.editingId),r=l.useRef(t.editTitle),o=l.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,o.current=t.deleteSessionConfirm;const i=le(_=>_.setSessionSwitcherOpen),a=mt(_=>_.setCurrentSession),d=mt(_=>_.updateSessionTitle),c=mt(_=>_.deleteSession),u=mt(_=>_.deleteSessions),f=mt(_=>_.archiveSession),p=mt(_=>_.archiveSessions),h=mt(_=>_.unarchiveSession),{mobileVariant:g,allowReselect:b,onSessionSelected:x,resetSessionSearch:y,descendantIds:S,showDeletionDialog:m,setDeleteSessionConfirm:v,setEditingId:w,setEditingRowKey:T,editingSessionId:k,editingOccurrenceKey:I,setEditTitle:F}=t,O=l.useCallback((_,$)=>{if(Pa("navigation.session_select"),le.getState().closeMainSurfaces(),g&&i(!1),_===mt.getState().currentSessionId){b&&x?.(_),y();return}Pa("navigation.session_state_set"),a(_,$??null),x?.(_),y()},[b,g,x,y,a,i]),B=l.useCallback((_,$)=>{w(_),T(I),F($)},[I,F,w,T]),j=l.useCallback(async _=>{if(!s.current)return;const E=(_??r.current).trim();if(E)try{await d(k,E)}catch(D){console.error("[session-actions] rename failed",D),He.error(e("sessions.sidebar.session.rename.error",{detail:wf(D instanceof Error?D:new Error(String(D)),e)}))}w(null),T(null),F("")},[k,F,w,T,e,d]),P=l.useCallback(()=>{w(null),T(null),F("")},[F,w,T]),L=l.useCallback(_=>{pi(_).then($=>{if($.ok){He.success(e("sessions.sidebar.session.copyId.success"));return}He.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>He.error(e("sessions.sidebar.session.copyId.error")))},[e]),z=l.useCallback(async(_,$,E)=>{const D=$?.archivedBucket===!0||$?.hardDelete===!0,C=E?.descendantIds??S;await ry(D?"delete":"archive",_,C,{archiveSession:f,archiveSessions:p,deleteSession:c,deleteSessions:u},e)},[f,p,c,u,S,e]),H=l.useCallback((_,$)=>{const E=$?.archivedBucket===!0||$?.hardDelete===!0,D=wl(_.id,S,E);if(!m||$?.skipConfirm===!0){z(_,$,{descendantIds:D});return}v({session:_,descendantCount:D.length,descendantIds:D,archivedBucket:E})},[S,z,v,m]),R=l.useCallback(async()=>{const _=o.current;if(!_)return;const{session:$,archivedBucket:E,descendantIds:D}=_;v(null),await z($,{archivedBucket:E},{descendantIds:D})},[z,v]),G=l.useCallback(async _=>{await h(_.id)?He.success(e("sessions.sidebar.session.restore.success")):He.error(e("sessions.sidebar.session.restore.error"))},[e,h]);return l.useMemo(()=>({handleSessionSelect:O,handleSessionDoubleClick:B,handleSaveEdit:j,handleCancelEdit:P,handleCopySessionId:L,handleDeleteSession:H,handleRestoreSession:G,confirmDeleteSession:R}),[P,L,H,G,j,B,O,R])};function W5(t){const e=Ze.c(71),{t:s}=Et(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:d}=t;let c,u,f,p,h,g,b,x,y,S;if(e[0]!==o||e[1]!==s||e[2]!==r){const $=s("sessions.sidebar.session.untitled");p=Qs,y=!!r,e[13]!==o?(S=D=>{D||o(null)},e[13]=o,e[14]=S):S=e[14],f=Zs,b=!1,x="max-w-sm gap-5",u=on;let E;e[15]!==s||e[16]!==r?.archivedBucket?(E=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=E):E=e[17],e[18]!==E?(g=n.jsx(nn,{children:E}),e[18]=E,e[19]=g):g=e[19],c=rn,h=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||$,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||$,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||$,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||$,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||$}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||$}),e[0]=o,e[1]=s,e[2]=r,e[3]=c,e[4]=u,e[5]=f,e[6]=p,e[7]=h,e[8]=g,e[9]=b,e[10]=x,e[11]=y,e[12]=S}else c=e[3],u=e[4],f=e[5],p=e[6],h=e[7],g=e[8],b=e[9],x=e[10],y=e[11],S=e[12];let m;e[20]!==c||e[21]!==h?(m=n.jsx(c,{children:h}),e[20]=c,e[21]=h,e[22]=m):m=e[22];let v;e[23]!==u||e[24]!==g||e[25]!==m?(v=n.jsxs(u,{children:[g,m]}),e[23]=u,e[24]=g,e[25]=m,e[26]=v):v=e[26];let w;e[27]!==a||e[28]!==i?(w=()=>a(!i),e[27]=a,e[28]=i,e[29]=w):w=e[29];const T=!i;let k;e[30]!==i?(k=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=k):k=e[31];let I;e[32]!==s?(I=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=I):I=e[33];let F;e[34]!==k||e[35]!==I||e[36]!==w||e[37]!==T?(F=n.jsxs("button",{type:"button",onClick:w,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":T,children:[k,I]}),e[34]=k,e[35]=I,e[36]=w,e[37]=T,e[38]=F):F=e[38];let O;e[39]!==o?(O=()=>o(null),e[39]=o,e[40]=O):O=e[40];let B;e[41]!==s?(B=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=B):B=e[42];let j;e[43]!==O||e[44]!==B?(j=n.jsx("button",{type:"button",onClick:O,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:B}),e[43]=O,e[44]=B,e[45]=j):j=e[45];let P;e[46]!==d?(P=()=>{d()},e[46]=d,e[47]=P):P=e[47];let L;e[48]!==s||e[49]!==r?.archivedBucket?(L=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=L):L=e[50];let z;e[51]!==P||e[52]!==L?(z=n.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:L}),e[51]=P,e[52]=L,e[53]=z):z=e[53];let H;e[54]!==j||e[55]!==z?(H=n.jsxs("div",{className:"flex items-center gap-2",children:[j,z]}),e[54]=j,e[55]=z,e[56]=H):H=e[56];let R;e[57]!==F||e[58]!==H?(R=n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[F,H]}),e[57]=F,e[58]=H,e[59]=R):R=e[59];let G;e[60]!==f||e[61]!==b||e[62]!==R||e[63]!==x||e[64]!==v?(G=n.jsxs(f,{showCloseButton:b,className:x,children:[v,R]}),e[60]=f,e[61]=b,e[62]=R,e[63]=x,e[64]=v,e[65]=G):G=e[65];let _;return e[66]!==p||e[67]!==G||e[68]!==y||e[69]!==S?(_=n.jsx(p,{open:y,onOpenChange:S,children:G}),e[66]=p,e[67]=G,e[68]=y,e[69]=S,e[70]=_):_=e[70],_}function H5(t){const e=Ze.c(57),{t:s}=Et(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:d}=t,c=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==c||e[1]!==u||e[2]!==s?(f=s(c?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]=c,e[1]=u,e[2]=s,e[3]=f):f=e[3];const p=f;let h;e[4]!==c||e[5]!==u||e[6]!==s?(h=c?u===1?s("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?s("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=c,e[5]=u,e[6]=s,e[7]=h):h=e[7];const g=h,b=!!r;let x;e[8]!==o?(x=_=>{_||o(null)},e[8]=o,e[9]=x):x=e[9];let y;e[10]!==p?(y=n.jsx(nn,{children:p}),e[10]=p,e[11]=y):y=e[11];let S;e[12]!==g?(S=n.jsx(rn,{children:g}),e[12]=g,e[13]=S):S=e[13];let m;e[14]!==y||e[15]!==S?(m=n.jsxs(on,{children:[y,S]}),e[14]=y,e[15]=S,e[16]=m):m=e[16];let v;e[17]!==a||e[18]!==i?(v=()=>a(!i),e[17]=a,e[18]=i,e[19]=v):v=e[19];const w=!i;let T;e[20]!==i?(T=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=T):T=e[21];let k;e[22]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=k):k=e[23];let I;e[24]!==k||e[25]!==v||e[26]!==w||e[27]!==T?(I=n.jsxs("button",{type:"button",onClick:v,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":w,children:[T,k]}),e[24]=k,e[25]=v,e[26]=w,e[27]=T,e[28]=I):I=e[28];let F;e[29]!==o?(F=()=>o(null),e[29]=o,e[30]=F):F=e[30];let O;e[31]!==s?(O=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=O):O=e[32];let B;e[33]!==F||e[34]!==O?(B=n.jsx("button",{type:"button",onClick:F,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:O}),e[33]=F,e[34]=O,e[35]=B):B=e[35];let j;e[36]!==d?(j=()=>{d()},e[36]=d,e[37]=j):j=e[37];let P;e[38]!==c||e[39]!==s?(P=s(c?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=c,e[39]=s,e[40]=P):P=e[40];let L;e[41]!==j||e[42]!==P?(L=n.jsx("button",{type:"button",onClick:j,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:P}),e[41]=j,e[42]=P,e[43]=L):L=e[43];let z;e[44]!==B||e[45]!==L?(z=n.jsxs("div",{className:"flex items-center gap-2",children:[B,L]}),e[44]=B,e[45]=L,e[46]=z):z=e[46];let H;e[47]!==I||e[48]!==z?(H=n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[I,z]}),e[47]=I,e[48]=z,e[49]=H):H=e[49];let R;e[50]!==H||e[51]!==m?(R=n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,H]}),e[50]=H,e[51]=m,e[52]=R):R=e[52];let G;return e[53]!==b||e[54]!==R||e[55]!==x?(G=n.jsx(Qs,{open:b,onOpenChange:x,children:R}),e[53]=b,e[54]=R,e[55]=x,e[56]=G):G=e[56],G}function pm(t){const e=Ze.c(36),{t:s}=Et(),{value:r,setValue:o,onConfirm:i}=t,a=!!r;let d;e[0]!==o?(d=T=>{T||o(null)},e[0]=o,e[1]=d):d=e[1];let c;e[2]!==s?(c=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==c?(u=n.jsx(nn,{children:c}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==s||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?s("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):s("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=s,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx(rn,{children:f}),e[9]=f,e[10]=p):p=e[10];let h;e[11]!==u||e[12]!==p?(h=n.jsxs(on,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=h):h=e[13];let g;e[14]!==o?(g=()=>o(null),e[14]=o,e[15]=g):g=e[15];let b;e[16]!==s?(b=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=b):b=e[17];let x;e[18]!==g||e[19]!==b?(x=n.jsx("button",{type:"button",onClick:g,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:b}),e[18]=g,e[19]=b,e[20]=x):x=e[20];let y;e[21]!==s?(y=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=y):y=e[22];let S;e[23]!==i||e[24]!==y?(S=n.jsx("button",{type:"button",onClick:i,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=i,e[24]=y,e[25]=S):S=e[25];let m;e[26]!==S||e[27]!==x?(m=n.jsxs(Pn,{children:[x,S]}),e[26]=S,e[27]=x,e[28]=m):m=e[28];let v;e[29]!==m||e[30]!==h?(v=n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,m]}),e[29]=m,e[30]=h,e[31]=v):v=e[31];let w;return e[32]!==a||e[33]!==d||e[34]!==v?(w=n.jsx(Qs,{open:a,onOpenChange:d,children:v}),e[32]=a,e[33]=d,e[34]=v,e[35]=w):w=e[35],w}const U5=new Set;function V5(t){const e=Ze.c(113),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:c,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:h,renderExtras:g,pinnedSessionIds:b,expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:F,toggleParent:O,openSidebarMenuKey:B,setOpenSidebarMenuKey:j,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:R,startFolderRename:G,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,renderChildren:D}=t,C=r===void 0?0:r,N=c===void 0?!1:c,A=f===void 0?"project":f,q=D===void 0?!0:D;As("ui.sidebar_tree_item.render");const ee=p??`${A}:${N?"archived":"active"}:${s.session.id}`,Q=is(Z5),he=is(Y5),M=le(q5),V=le(G5);let ie;if(e[0]!==s){ie=[];const de=Ne=>Ne.children.forEach(Je=>{ie.push(Je.session.id),de(Je)});de(s),e[0]=s,e[1]=ie}else ie=e[1];const ce=ie.join(`
365
+ `),Nk=t=>{const e=Ze.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:a}=t,{t:d}=Et();if(s.length===0)return null;let c;e[0]!==d?(c=d("contextPanel.browser.history.label"),e[0]=d,e[1]=c):c=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==a||e[6]!==o||e[7]!==d){let p;e[9]!==r||e[10]!==i||e[11]!==a||e[12]!==o||e[13]!==d?(p=(h,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:Pe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",g===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),o(h.url)},onPointerEnter:()=>a(g),children:[n.jsx(Z,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:h.title||ii(h.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:h.url})]}),n.jsx("button",{type:"button",className:Pe("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":d("contextPanel.browser.history.forget"),title:d("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(h.url)},children:n.jsx(Z,{name:"close",className:"size-3","aria-hidden":"true"})})]},h.url),e[9]=r,e[10]=i,e[11]=a,e[12]=o,e[13]=d,e[14]=p):p=e[14],u=s.map(p),e[2]=r,e[3]=s,e[4]=i,e[5]=a,e[6]=o,e[7]=d,e[8]=u}else u=e[8];let f;return e[15]!==c||e[16]!==u?(f=n.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":c,children:u}),e[15]=c,e[16]=u,e[17]=f):f=e[17],f},Hs=t=>{const e=Ze.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:a}=t,d=a?"secondary":"ghost",c=a&&"text-foreground";let u;e[0]!==c?(u=Pe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",c),e[0]=c,e[1]=u):u=e[1];let f;e[2]!==s?(f=n.jsx(Z,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==a||e[8]!==d||e[9]!==u||e[10]!==f?(p=n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{type:"button",variant:d,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":a,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=a,e[8]=d,e[9]=u,e[10]=f,e[11]=p):p=e[11];let h;e[12]!==r?(h=n.jsx(Kt,{sideOffset:6,children:r}),e[12]=r,e[13]=h):h=e[13];let g;return e[14]!==p||e[15]!==h?(g=n.jsxs(Ut,{children:[p,h]}),e[14]=p,e[15]=h,e[16]=g):g=e[16],g},jh=t=>{const e=Ze.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:a,onSubmit:d,onBack:c,onForward:u,onReload:f,onOpenExternal:p,canOpenExternal:h,canGoBack:g,canGoForward:b,isLoading:x,onAnnotate:y,onOpenDevTools:S,isAnnotating:m,onHardReload:v,onZoomIn:w,onZoomOut:T,onZoomReset:k,zoomPercent:I,onClearCookies:B,onClearCache:O,onToggleDeviceBar:F,isDeviceBarOpen:j}=t;let P;e[0]!==o?(P=o===void 0?[]:o,e[0]=o,e[1]=P):P=e[1];const L=P,z=h===void 0?!0:h,H=I===void 0?100:I,{t:R}=Et(),[G,_]=l.useState(!1),[$,E]=l.useState(-1);let D;e[2]!==G||e[3]!==L?(D=G?L:[],e[2]=G,e[3]=L,e[4]=D):D=e[4];const C=D;let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{E(-1)},e[5]=N):N=e[5];let A;e[6]!==s||e[7]!==G?(A=[s,G],e[6]=s,e[7]=G,e[8]=A):A=e[8],l.useEffect(N,A);let q;e[9]!==d?(q=oe=>{_(!1),E(-1),d(oe)},e[9]=d,e[10]=q):q=e[10];const ee=q;let Q;e[11]!==$||e[12]!==ee||e[13]!==C?(Q=oe=>{if(C.length!==0){if(oe.key==="ArrowDown"||oe.key==="ArrowUp"){oe.preventDefault();const tt=oe.key==="ArrowDown"?1:-1,Ue=C.length;E(gt=>{const bt=gt+tt;return bt<-1?Ue-1:bt>=Ue?-1:bt});return}if(oe.key==="Escape"&&$>=0){oe.preventDefault(),E(-1);return}if(oe.key==="Enter"&&$>=0){oe.preventDefault();const tt=C[$];tt&&ee(tt.url)}}},e[11]=$,e[12]=ee,e[13]=C,e[14]=Q):Q=e[14];const he=Q;let M;e[15]!==R?(M=R("contextPanel.browser.back"),e[15]=R,e[16]=M):M=e[16];const V=!g;let ie;e[17]!==c||e[18]!==M||e[19]!==V?(ie=n.jsx(Hs,{icon:"arrow-left",label:M,onClick:c,disabled:V}),e[17]=c,e[18]=M,e[19]=V,e[20]=ie):ie=e[20];let ce;e[21]!==R?(ce=R("contextPanel.browser.forward"),e[21]=R,e[22]=ce):ce=e[22];const ne=!b;let je;e[23]!==u||e[24]!==ce||e[25]!==ne?(je=n.jsx(Hs,{icon:"arrow-right",label:ce,onClick:u,disabled:ne}),e[23]=u,e[24]=ce,e[25]=ne,e[26]=je):je=e[26];let Ee;e[27]!==x||e[28]!==R?(Ee=R(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=R,e[29]=Ee):Ee=e[29];let we;e[30]!==f||e[31]!==Ee?(we=n.jsx(Hs,{icon:"refresh",label:Ee,onClick:f}),e[30]=f,e[31]=Ee,e[32]=we):we=e[32];let Me;e[33]!==v||e[34]!==R?(Me=v?n.jsx(Hs,{icon:"restart",label:R("contextPanel.browser.hardReload"),onClick:v}):null,e[33]=v,e[34]=R,e[35]=Me):Me=e[35];let fe;e[36]!==s||e[37]!==ee?(fe=oe=>{oe.preventDefault(),ee(s)},e[36]=s,e[37]=ee,e[38]=fe):fe=e[38];let be;e[39]!==r?(be=r?n.jsx("span",{className:"pointer-events-none absolute inset-s-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:n.jsx(Z,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=be):be=e[40];let ke;e[41]!==a?(ke=oe=>a(oe.target.value),e[41]=a,e[42]=ke):ke=e[42];let Ie,Te;e[43]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>_(!0),Te=()=>_(!1),e[43]=Ie,e[44]=Te):(Ie=e[43],Te=e[44]);const Y=C.length>0,ue=r&&"ps-8";let me;e[45]!==ue?(me=Pe("oc-raised oc-field h-6 w-full rounded-full bg-[var(--surface-elevated)] px-3",ue,"typography-micro text-foreground outline-none"),e[45]=ue,e[46]=me):me=e[46];let re;e[47]!==R?(re=R("contextPanel.browser.addressAria"),e[47]=R,e[48]=re):re=e[48];let pe;e[49]!==s||e[50]!==he||e[51]!==ke||e[52]!==Y||e[53]!==me||e[54]!==re?(pe=n.jsx("input",{value:s,onChange:ke,onFocus:Ie,onBlur:Te,onKeyDown:he,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Y,"aria-controls":"openchamber-browser-address-suggestions",className:me,"aria-label":re}),e[49]=s,e[50]=he,e[51]=ke,e[52]=Y,e[53]=me,e[54]=re,e[55]=pe):pe=e[55];let U;e[56]!==i?(U=oe=>i?.(oe),e[56]=i,e[57]=U):U=e[57];let ae;e[58]!==$||e[59]!==ee||e[60]!==U||e[61]!==C?(ae=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(Nk,{entries:C,activeIndex:$,onSelect:ee,onForget:U,onHighlight:E})}),e[58]=$,e[59]=ee,e[60]=U,e[61]=C,e[62]=ae):ae=e[62];let Re;e[63]!==fe||e[64]!==be||e[65]!==pe||e[66]!==ae?(Re=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:fe,children:[be,pe,ae]}),e[63]=fe,e[64]=be,e[65]=pe,e[66]=ae,e[67]=Re):Re=e[67];let W;e[68]!==w||e[69]!==T||e[70]!==k||e[71]!==R||e[72]!==H?(W=T&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Hs,{icon:"subtract",label:R("contextPanel.browser.zoomOut"),onClick:T}),H!==100&&k?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsxs(Nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:k,"aria-label":R("contextPanel.browser.zoomReset"),children:[H,"%"]})}),n.jsx(Kt,{sideOffset:6,children:R("contextPanel.browser.zoomReset")})]}):null,n.jsx(Hs,{icon:"add",label:R("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=T,e[70]=k,e[71]=R,e[72]=H,e[73]=W):W=e[73];let ye;e[74]!==B||e[75]!==R?(ye=B?n.jsx(Hs,{icon:"delete-bin",label:R("contextPanel.browser.clearCookies"),onClick:B}):null,e[74]=B,e[75]=R,e[76]=ye):ye=e[76];let de;e[77]!==O||e[78]!==R?(de=O?n.jsx(Hs,{icon:"database-2",label:R("contextPanel.browser.clearCache"),onClick:O}):null,e[77]=O,e[78]=R,e[79]=de):de=e[79];let Ne;e[80]!==j||e[81]!==F||e[82]!==R?(Ne=F?n.jsx(Hs,{icon:"smartphone",label:R("contextPanel.browser.deviceToolbar"),onClick:F,pressed:j}):null,e[80]=j,e[81]=F,e[82]=R,e[83]=Ne):Ne=e[83];let Je;e[84]!==m||e[85]!==y||e[86]!==R?(Je=y?n.jsx(Hs,{icon:"markup",label:R("contextPanel.browser.annotate.toggle"),onClick:y,pressed:m}):null,e[84]=m,e[85]=y,e[86]=R,e[87]=Je):Je=e[87];let Ge;e[88]!==S||e[89]!==R?(Ge=S?n.jsx(Hs,{icon:"terminal-box",label:R("contextPanel.browser.devTools"),onClick:S}):null,e[88]=S,e[89]=R,e[90]=Ge):Ge=e[90];let ge;e[91]!==R?(ge=R("contextPanel.browser.openExternal"),e[91]=R,e[92]=ge):ge=e[92];const Ae=!z;let Ye;e[93]!==p||e[94]!==ge||e[95]!==Ae?(Ye=n.jsx(Hs,{icon:"external-link",label:ge,onClick:p,disabled:Ae}),e[93]=p,e[94]=ge,e[95]=Ae,e[96]=Ye):Ye=e[96];let nt;return e[97]!==ie||e[98]!==je||e[99]!==we||e[100]!==Me||e[101]!==Re||e[102]!==W||e[103]!==ye||e[104]!==de||e[105]!==Ne||e[106]!==Je||e[107]!==Ge||e[108]!==Ye?(nt=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[ie,je,we,Me,Re,W,ye,de,Ne,Je,Ge,Ye]}),e[97]=ie,e[98]=je,e[99]=we,e[100]=Me,e[101]=Re,e[102]=W,e[103]=ye,e[104]=de,e[105]=Ne,e[106]=Je,e[107]=Ge,e[108]=Ye,e[109]=nt):nt=e[109],nt},Go={kind:"fill"},Nd=240,Mk=3840,kh=[{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}],Md=t=>Number.isFinite(t)?Math.round(Math.min(Mk,Math.max(Nd,t))):Nd,qo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Ch=t=>{const e=kh.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Ak=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},Ok=(t,e)=>{const s=qo(t);if(!s)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/s.width,o/s.height);return{width:s.width,height:s.height,scale:i}},Bk=["mobile","tablet","desktop","fill"],Fk={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ad=t=>typeof t=="string"&&Bk.includes(t),Ja=t=>t==="fill"?Go:Ch(Fk[t])??Go,ao=t=>{const e=qo(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=Ja(s),o=qo(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:s,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},_k=t=>{const e=Ze.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:a}=t,{t:d}=Et();let c;e[0]!==s?(c=qo(s),e[0]=s,e[1]=c):c=e[1];const u=c,f=s.kind==="preset"?s.id:"";let p;e[2]!==r||e[3]!==u?(p=(Q,he)=>{const M=Number.parseInt(he,10);if(!Number.isFinite(M))return;const V=u??{width:1280,height:800};r({kind:"custom",width:Md(Q==="width"?M:V.width),height:Md(Q==="height"?M:V.height)})},e[2]=r,e[3]=u,e[4]=p):p=e[4];const h=p;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=Pe("oc-raised oc-field h-6 w-14 rounded-full bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none"),e[5]=g):g=e[5];const b=g;let x;e[6]!==r?(x=Q=>{const he=Ch(Q.target.value);r(he??Go)},e[6]=r,e[7]=x):x=e[7];let y;e[8]!==d?(y=d("contextPanel.browser.device.preset"),e[8]=d,e[9]=y):y=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=Pe("oc-raised oc-field h-6 shrink-0 rounded-full bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none"),e[10]=S):S=e[10];let m;e[11]!==d?(m=d("contextPanel.browser.device.responsive"),e[11]=d,e[12]=m):m=e[12];let v;e[13]!==m?(v=n.jsx("option",{value:"",children:m}),e[13]=m,e[14]=v):v=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=kh.map(Lk),e[15]=w):w=e[15];let T;e[16]!==f||e[17]!==x||e[18]!==y||e[19]!==v?(T=n.jsxs("select",{value:f,onChange:x,"aria-label":y,className:S,children:[v,w]}),e[16]=f,e[17]=x,e[18]=y,e[19]=v,e[20]=T):T=e[20];const k=u?String(u.width):"";let I;e[21]!==h?(I=Q=>h("width",Q.target.value),e[21]=h,e[22]=I):I=e[22];let B;e[23]!==d?(B=d("contextPanel.browser.device.width"),e[23]=d,e[24]=B):B=e[24];let O;e[25]!==k||e[26]!==I||e[27]!==B?(O=n.jsx("input",{value:k,onChange:I,placeholder:"—",inputMode:"numeric","aria-label":B,className:b}),e[25]=k,e[26]=I,e[27]=B,e[28]=O):O=e[28];let F;e[29]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=F):F=e[29];const j=u?String(u.height):"";let P;e[30]!==h?(P=Q=>h("height",Q.target.value),e[30]=h,e[31]=P):P=e[31];let L;e[32]!==d?(L=d("contextPanel.browser.device.height"),e[32]=d,e[33]=L):L=e[33];let z;e[34]!==j||e[35]!==P||e[36]!==L?(z=n.jsx("input",{value:j,onChange:P,placeholder:"—",inputMode:"numeric","aria-label":L,className:b}),e[34]=j,e[35]=P,e[36]=L,e[37]=z):z=e[37];let H;e[38]!==r||e[39]!==s?(H=()=>r(Ak(s)),e[38]=r,e[39]=s,e[40]=H):H=e[40];const R=!u;let G;e[41]!==d?(G=d("contextPanel.browser.device.rotate"),e[41]=d,e[42]=G):G=e[42];let _;e[43]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(Z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=_):_=e[43];let $;e[44]!==H||e[45]!==R||e[46]!==G?($=n.jsx(Ht,{asChild:!0,children:n.jsx(Nt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:H,disabled:R,"aria-label":G,children:_})}),e[44]=H,e[45]=R,e[46]=G,e[47]=$):$=e[47];let E;e[48]!==d?(E=d("contextPanel.browser.device.rotate"),e[48]=d,e[49]=E):E=e[49];let D;e[50]!==E?(D=n.jsx(Kt,{sideOffset:6,children:E}),e[50]=E,e[51]=D):D=e[51];let C;e[52]!==$||e[53]!==D?(C=n.jsxs(Ut,{children:[$,D]}),e[52]=$,e[53]=D,e[54]=C):C=e[54];let N;e[55]!==a||e[56]!==u?(N=u&&a<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(a*100),"%"]}):null,e[55]=a,e[56]=u,e[57]=N):N=e[57];let A;e[58]===Symbol.for("react.memo_cache_sentinel")?(A=["system","light","dark"],e[58]=A):A=e[58];let q;e[59]!==o||e[60]!==i||e[61]!==d?(q=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:A.map(Q=>n.jsx(Nt,{type:"button",variant:o===Q?"secondary":"ghost",size:"xs",className:Pe("shrink-0 rounded-full px-2.5 typography-micro",o===Q?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(Q),"aria-pressed":o===Q,children:d(Q==="system"?"contextPanel.browser.device.schemeSystem":Q==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},Q))}),e[59]=o,e[60]=i,e[61]=d,e[62]=q):q=e[62];let ee;return e[63]!==T||e[64]!==O||e[65]!==z||e[66]!==C||e[67]!==N||e[68]!==q?(ee=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[T,O,F,z,C,N,q]}),e[63]=T,e[64]=O,e[65]=z,e[66]=C,e[67]=N,e[68]=q,e[69]=ee):ee=e[69],ee};function Lk(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const Yo=new Map,el=new Set,Ih=()=>{for(const t of el)t()},fa=(t,e)=>{const s=t.trim();s&&(e.length===0?Yo.delete(s):Yo.set(s,[...e]),Ih())},$k=t=>{Yo.delete(t.trim())&&Ih()},Ph=[],zk=t=>Yo.get(t.trim())??Ph,Kk=t=>(el.add(t),()=>{el.delete(t)}),Wk=t=>{const e=Ze.c(2);let s;return e[0]!==t?(s=()=>zk(t),e[0]=t,e[1]=s):s=e[1],l.useSyncExternalStore(Kk,s,Hk)};function Hk(){return Ph}const Eh="oc.browser.hiddenDevServerPorts.v1",Uk=Wr(zs(),Ci(Up().int().positive())),tl=new Set,Th=[];let lo=null;const ec=()=>{const t=ai().getItem(Eh);if(lo&&lo.raw===t)return lo.value;let e={};if(t!==null)try{const s=Uk.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return lo={raw:t,value:e},e},Dh=t=>{ai().setItem(Eh,JSON.stringify(t));for(const e of tl)e()},Vk=(t=Jt())=>ec()[t]??Th,Gk=t=>{const e=Jt(),s=ec(),r=s[e]??[];r.includes(t)||Dh({...s,[e]:[...r,t].sort((o,i)=>o-i)})},qk=()=>{const t=Jt(),e=ec();if(!e[t])return;const s={...e};delete s[t],Dh(s)},Yk=t=>(tl.add(t),()=>{tl.delete(t)}),Zk=()=>l.useSyncExternalStore(Yk,Qk,Xk);function Qk(){return Vk()}function Xk(){return Th}const Jk=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},e2=2e3,t2=t=>xf("http://localhost",t),Rh=t=>{const e=Ze.c(52),{onOpen:s,directory:r,visible:o}=t,i=r===void 0?"":r,{t:a}=Et();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"loading"},e[0]=d):d=e[0];const[c,u]=l.useState(d),f=Wk(i);let p;e[1]!==i?(p=()=>t2(i),e[1]=i,e[2]=p):p=e[2];const[h]=l.useState(p);let g;e[3]!==i?(g=()=>Wb(i),e[3]=i,e[4]=g):g=e[4];const[b]=l.useState(g);let x;e[5]!==i?(x=Yu(i),e[5]=i,e[6]=x):x=e[6];const y=x,S=Jl(i),m=Dg(i);let v,w;e[7]!==i||e[8]!==m||e[9]!==o?(v=()=>{if(m){u({kind:"ready",servers:[]});return}if(!o)return;let D=!0,C=null;const N=new AbortController,A=()=>{Vj(N.signal,i).then(q=>{D&&(u(q),C=setTimeout(A,e2))})};return A(),()=>{D=!1,C&&clearTimeout(C),N.abort()}},w=[i,m,o],e[7]=i,e[8]=m,e[9]=o,e[10]=v,e[11]=w):(v=e[10],w=e[11]),l.useEffect(v,w);const T=c.kind==="ready"?c.servers:null;let k;e[12]!==f||e[13]!==T?(k=Yj({announced:f,discovered:T}),e[12]=f,e[13]=T,e[14]=k):k=e[14];const I=k,B=Zk();let O;if(e[15]!==I||e[16]!==B){let D;e[18]!==B?(D=C=>C.announced||!B.includes(C.port),e[18]=B,e[19]=D):D=e[19],O=I.filter(D),e[15]=I,e[16]=B,e[17]=O}else O=e[17];const F=O,j=I.length-F.length;let P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(n1,{width:110,height:110,className:"shrink-0 opacity-20"}),e[20]=P):P=e[20];let L;e[21]!==a?(L=a("contextPanel.browser.empty"),e[21]=a,e[22]=L):L=e[22];let z;e[23]!==L?(z=n.jsx("span",{className:"typography-ui-header text-foreground",children:L}),e[23]=L,e[24]=z):z=e[24];let H;e[25]!==a?(H=a("contextPanel.browser.emptyHint"),e[25]=a,e[26]=H):H=e[26];let R;e[27]!==H?(R=n.jsx("span",{className:"typography-micro text-muted-foreground",children:H}),e[27]=H,e[28]=R):R=e[28];let G;e[29]!==z||e[30]!==R?(G=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[z,R]}),e[29]=z,e[30]=R,e[31]=G):G=e[31];let _;e[32]!==f||e[33]!==I.length||e[34]!==i||e[35]!==j||e[36]!==y||e[37]!==s||e[38]!==h||e[39]!==S||e[40]!==b||e[41]!==a||e[42]!==F?(_=I.length>0?n.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[n.jsx("span",{className:"shrink-0 typography-micro text-start text-muted-foreground",children:f.length>0?a("contextPanel.browser.devServers.justStarted"):a("contextPanel.browser.devServers.title")}),h&&!b?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.remoteOnly")}):null,n.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pe-0.5",children:F.map(D=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(Nt,{type:"button",variant:"outline",size:"sm",className:Pe("min-w-0 flex-1 justify-start gap-2",h&&"cursor-default opacity-60"),"aria-disabled":h||void 0,onClick:()=>{h||($k(i),s(D.url))},children:[y?n.jsx("span",{className:"shrink-0",role:"img","aria-label":S??a("contextPanel.browser.spaceAddress"),title:S??a("contextPanel.browser.spaceAddress"),children:n.jsx(Z,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx(Z,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:ii(D.url)||D.url}),b?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":a("contextPanel.browser.devServers.spaceOnlyDesktop"),title:a("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx(Z,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ms-auto truncate typography-micro text-muted-foreground",children:Jk(D.url)})]}),D.announced?null:n.jsx(Nt,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground opacity-0 group-hover/server:opacity-100 focus-visible:opacity-100",onClick:()=>Gk(D.port),"aria-label":a("contextPanel.browser.devServers.hide",{port:D.port}),title:a("contextPanel.browser.devServers.hide",{port:D.port}),children:n.jsx(Z,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},D.port))}),j>0?n.jsx(Nt,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:qk,children:j===1?a("contextPanel.browser.devServers.showHiddenSingle",{count:j}):a("contextPanel.browser.devServers.showHiddenPlural",{count:j})}):null]}):null,e[32]=f,e[33]=I.length,e[34]=i,e[35]=j,e[36]=y,e[37]=s,e[38]=h,e[39]=S,e[40]=b,e[41]=a,e[42]=F,e[43]=_):_=e[43];let $;e[44]!==I.length||e[45]!==c.kind||e[46]!==a?($=I.length===0&&c.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.devServers.unavailable")}):null,e[44]=I.length,e[45]=c.kind,e[46]=a,e[47]=$):$=e[47];let E;return e[48]!==G||e[49]!==_||e[50]!==$?(E=n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[P,G,_,$]}),e[48]=G,e[49]=_,e[50]=$,e[51]=E):E=e[51],E},s2=3e4,n2=3,r2=250,o2={attempts:0,windowStartedAt:null},i2=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=s2,r=s?0:t.attempts;return r>=n2?null:{delayMs:r2*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},a2=-3,co=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",tr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},l2=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:r1),[i,a]=l.useState(e),[d,c]=l.useState(""),[u,f]=l.useState(!1),[p,h]=l.useState(!1),g=l.useRef(s);g.current=s;const b=l.useRef(o2);return l.useEffect(()=>{if(!t)return;const x=()=>{try{const F=t.getURL();return co(F)?F:""}catch{return""}},y=()=>{try{f(t.canGoBack()),h(t.canGoForward())}catch{}},S=F=>{co(F)&&(a(F),g.current(F))},m=()=>{const F=x();o({kind:"loading",url:F})},v=()=>{const F=x();let j="";try{j=t.getTitle()||""}catch{j=""}c(j),S(F),y(),o(P=>P.kind==="failed"?P:{kind:"ready",url:F,title:j})},w=F=>{const j=tr(F);co(j.url)&&(S(j.url),y())},T=F=>{const j=tr(F),P=Array.isArray(j.favicons)?j.favicons.find(Boolean):"",L=x();if(!P||!L)return;let z=-1;try{z=t.getWebContentsId()}catch{return}!Number.isFinite(z)||z<0||sh.getState().resolve(L,P,z)},k=F=>{const j=tr(F);typeof j.title=="string"&&c(j.title)},I=F=>{const j=tr(F);if(j.isMainFrame===!1)return;const P=typeof j.errorCode=="number"?j.errorCode:0;P!==a2&&o({kind:"failed",url:co(j.validatedURL)?j.validatedURL:x(),code:P,description:typeof j.errorDescription=="string"?j.errorDescription:""})};let B=null;const O=()=>{const F=x(),j=i2(b.current,Date.now());if(!j){o({kind:"failed",url:F,code:0,description:"",crashed:!0});return}b.current=j.state,o({kind:"loading",url:F}),B=setTimeout(()=>{B=null;try{t.reload()}catch{o({kind:"failed",url:F,code:0,description:"",crashed:!0})}},j.delayMs)};t.addEventListener("did-start-loading",m),t.addEventListener("did-stop-loading",v),t.addEventListener("did-navigate",w),t.addEventListener("did-navigate-in-page",w),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",T),t.addEventListener("did-fail-load",I),t.addEventListener("render-process-gone",O),t.addEventListener("crashed",O);try{!t.isLoading()&&x()&&v()}catch{}return()=>{B!==null&&clearTimeout(B),t.removeEventListener("render-process-gone",O),t.removeEventListener("crashed",O),t.removeEventListener("did-start-loading",m),t.removeEventListener("did-stop-loading",v),t.removeEventListener("did-navigate",w),t.removeEventListener("did-navigate-in-page",w),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",T),t.removeEventListener("did-fail-load",I)}},[t]),{status:r,url:i,title:d,canGoBack:u,canGoForward:p}},Od=1e3,Nh=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},c2=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},d2=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},u2=(t,e)=>{const s=l.useRef(0),r=l.useRef(0),o=l.useRef(0),i=l.useRef(null),a=l.useCallback(()=>{if(!t||document.activeElement!==t)return;const d=i.current;d&&d.isConnected&&d!==document.body?d.focus({preventScroll:!0}):t.blur()},[t]);return l.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=d2());const d=c=>{if(document.activeElement!==t){i.current=c2(c);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&Nh(u)&&!f||r.current>0||a()};return document.addEventListener("focusin",d,!0),()=>document.removeEventListener("focusin",d,!0)},[a,e,t]),l.useCallback(async d=>{const c=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,o.current=Date.now()+Od,!c&&r.current===0&&a())},p=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await d(p)}finally{s.current-=1,o.current=Date.now()+Od,f()}},[a,t])},f2=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),p2=()=>document.visibilityState==="visible",h2=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,uo=.5,m2=-3,g2=4,b2="persist:openchamber-browser",Mh=(t,e,s)=>$s(t)!==null&&Qu(e)?{icon:"box-3",label:s}:void 0,Bd=t=>{const e=$s(t);return e?`openchamber-space-preview:${e}`:b2},Fd="openchamber:browser-panel-open-tab",y2=Ko({webContentsId:Up(),url:zs().min(1),background:Ha()}),_d=20,x2=600,S2=2e4,w2=15e3,v2=t=>{if(!t||Nh(t))return()=>{};const e=t.getBoundingClientRect(),s=t.style.cssText;return Object.assign(t.style,{position:"fixed",top:`${e.top}px`,left:`${Math.max(0,Math.min(e.left,window.innerWidth-e.width))}px`,width:`${e.width}px`,height:`${e.height}px`,visibility:"visible",opacity:"0",pointerEvents:"none"}),()=>{t.style.cssText=s}},j2=({initialUrl:t,directory:e,siteDirectory:s,tabID:r,ownerSessionId:o,visible:i})=>{const{t:a}=Et(),{currentTheme:d}=br(),c=l.useRef(null),[u,f]=l.useState(null),p=l.useCallback(Ce=>{c.current=Ce,f(Ce)},[]),h=le(Ce=>Ce.setContextPanelTabTargetPath),g=l.useRef(nr(t)),b=g.current!==wn?g.current:"",[x,y]=l.useState(b?null:wn),S=Jl(s),[m,v]=l.useState(b),[w,T]=l.useState(!1),[k,I]=l.useState(!1),[B,O]=l.useState(0),F=l.useRef(0),[j,P]=l.useState(!1),[L,z]=l.useState(Go),H=l.useRef(L);H.current=L;const R=l.useRef([]),[G,_]=l.useState("system"),[$,E]=l.useState({width:0,height:0}),D=l.useRef(null),C=l.useRef(null),N=Ds(e),A=l.useRef(!!b&&!Rg(N,r)),q=l.useRef(null);l.useEffect(()=>{Zu(N,r)},[N,r]);const ee=l.useRef(!1),Q=l.useRef(Date.now()),he=l.useCallback(Ce=>{!Ce||Ce===wn||!e||!r||h(e,r,Ce)},[e,r,h]),M=l2(u,{initialUrl:b,onUrlChange:l.useCallback(Ce=>{const _e=Un(Ce);v(_e),he(_e)},[he])}),[V,ie]=l.useState(null),[ce,ne]=l.useState($s(s)===null);l.useEffect(()=>{const Ce=$s(s);if(Ce===null){ne(!0);return}let _e=!0;return ne(!1),Xn("desktop_space_preview_prepare",{spaceId:Ce}).then(()=>{_e&&ne(!0)}).catch(()=>{_e&&ie(b||"http://localhost/")}),()=>{_e=!1}},[s,b]);const je=o1(e),Ee=i1(),we=M.status.kind==="loading",Me=ir(vh(s)),fe=ir(Ce=>Ce.recordVisit),be=ir(Ce=>Ce.forget);l.useEffect(()=>{M.status.kind==="ready"&&fe(s,{url:Un(M.status.url),title:M.status.title})},[s,M.status,fe]);const ke=l.useMemo(()=>wh(Me,m),[Me,m]),Ie=l.useCallback(Ce=>{const _e=nr(Ce);_e!==wn&&(A.current=!1,v(_e),ie(null),Oc(_e,s).then(ze=>{const Oe=c.current;if(!Oe){y(ze);return}try{Oe.loadURL(ze)}catch{y(ze)}}).catch(ze=>{ze instanceof Bc&&ie(_e)}))},[s]);l.useEffect(()=>{if(!b)return;let Ce=!0;return Oc(b,s).then(_e=>{Ce&&y(_e)}).catch(_e=>{if(Ce){if(_e instanceof Bc){ie(b),A.current=!1,y(wn);return}y(b)}}),()=>{Ce=!1}},[]);const Te=l.useMemo(()=>({executeJavaScript:async(Ce,_e)=>{const ze=c.current;if(!ze)throw new Error("Browser view is not available");return ze.executeJavaScript(Ce,_e)},capturePage:async()=>{const Ce=c.current;if(!Ce)return null;const _e=Ce.getWebContentsId();return Number.isFinite(_e)?await Xn("desktop_browser_capture_page",{webContentsId:_e}):null}}),[]),Y=l.useCallback(()=>{if(w){T(!1),Ji(Te);return}if(!M.url){He.error(a("contextPanel.browser.annotate.noPage"));return}const Ce=a1(d.metadata.variant==="light"?"light":"dark");T(!0),l1({host:Te,theme:Ce,labels:Ee}).then(async _e=>{T(!1),_e&&await je(_e)}).catch(()=>{T(!1),He.error(a("contextPanel.browser.annotate.failed"))})},[Te,je,d,w,M.url,Ee,a]);l.useEffect(()=>{if(!w)return;const Ce=_e=>{Nl(_e)||_e.key!=="Escape"||(_e.preventDefault(),_e.stopImmediatePropagation(),T(!1),Ji(Te))};return window.addEventListener("keydown",Ce,!0),()=>window.removeEventListener("keydown",Ce,!0)},[Te,w]);const ue=l.useRef(!1);l.useEffect(()=>{if(!u)return;const Ce=()=>{ue.current=!0};return u.addEventListener("dom-ready",Ce),u.addEventListener("did-fail-load",Ce),()=>{u.removeEventListener("dom-ready",Ce),u.removeEventListener("did-fail-load",Ce)}},[u]);const me=l.useCallback(async()=>{const Ce=Date.now()+w2;for(;!(c.current&&ue.current)&&Date.now()<Ce;)await new Promise(_e=>setTimeout(_e,100));return c.current},[]),re=l.useCallback(async(Ce=8e3)=>{const _e=Date.now();for(;;){const ze=c.current;if(!ze)return!1;let Oe=!1;try{Oe=ze.isLoading()}catch{return!1}if(!Oe)return!0;if(Date.now()-_e>Ce)return!1;await new Promise(it=>setTimeout(it,120))}},[]),pe=l.useCallback(async(Ce,_e,ze)=>{const Oe=await me();if(!Oe)throw new Error("The browser panel is not ready");const it=()=>{Ad(_e.viewport)&&(z(Ja(_e.viewport)),P(!0))};if(Ce==="browser.back"||Ce==="browser.forward"){const dt=Ce==="browser.back";if(!(dt?Oe.canGoBack():Oe.canGoForward()))throw new Error(dt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");dt?Oe.goBack():Oe.goForward(),await new Promise(Rt=>setTimeout(Rt,150)),await re();let st="";try{st=Oe.getTitle()||""}catch{st=""}return{url:Un(Oe.getURL()),title:st}}if(Ce==="browser.capture"){const dt=v2(D.current);try{await new Promise(Rt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Rt()))}),await re();const ft=await Te.capturePage();if(!ft)throw new Error("The page could not be captured");let st="";try{st=Oe.getTitle()||""}catch{st=""}return{...ft,url:Un(Oe.getURL()),title:st,viewport:ao(H.current)}}finally{dt()}}if(Ce==="browser.resize"){if(!Ad(_e.viewport))throw new Error("viewport is required");return it(),await new Promise(dt=>setTimeout(dt,200)),await re(),{viewport:ao(Ja(_e.viewport))}}if(Ce==="browser.open"){const dt=typeof _e.url=="string"?_e.url:"";if(!dt)throw new Error("url is required");it(),Ie(dt),await new Promise(Rt=>setTimeout(Rt,150));const ft=await re(25e3);let st="";try{st=Oe.getTitle()||""}catch{st=""}return{url:nr(dt),title:st,opened:!0,settled:ft,viewport:ao(H.current)}}await re();const X=dt=>typeof dt=="string"&&dt?dt:void 0,Le=(()=>{switch(Ce){case"browser.snapshot":return Ik({selector:X(_e.selector)});case"browser.click":return Pk({selector:X(_e.selector),text:X(_e.text)});case"browser.type":return Ek({selector:String(_e.selector??""),value:String(_e.value??""),submit:_e.submit===!0});case"browser.inspect":return Rk({selector:String(_e.selector??"")});case"browser.scroll":return Tk({selector:X(_e.selector),direction:X(_e.direction)});default:return null}})();if(!Le)throw new Error(`Unsupported browser action: ${Ce}`);let at=()=>{};(Ce==="browser.click"||Ce==="browser.type")&&(await Xn("desktop_browser_keep_page_focused",{webContentsId:Oe.getWebContentsId()}).then(ft=>ft.focused===!0).catch(()=>!1)||(at=ze(),Oe.focus({preventScroll:!0})));let qe;try{qe=await Oe.executeJavaScript(Le,!0)}finally{at()}if(!qe||typeof qe!="object")throw new Error("The page returned no result");const ut=qe;if(ut.ok!==!0)throw new Error(typeof ut.error=="string"&&ut.error?ut.error:"Browser action failed");if(Ce==="browser.snapshot"){const dt=R.current;return{...ut,viewport:ao(H.current),...dt.length>0?{consoleProblems:[...dt]}:{}}}return(Ce==="browser.click"||Ce==="browser.type"&&_e.submit===!0)&&(await new Promise(dt=>setTimeout(dt,150)),await re()),qe},[Te,Ie,re,me]),U=u2(u,D),[ae,Re]=l.useState(!1),W=l.useCallback((Ce,_e)=>(Re(!0),U(ze=>pe(Ce,_e,ze))),[U,pe]),ye=l.useCallback(()=>{const Ce=c.current;if(!Ce)return{title:"",url:""};let _e="",ze="";try{_e=Ce.getTitle()||""}catch{_e=""}try{ze=Un(Ce.getURL())}catch{ze=""}return{title:_e,url:ze}},[]);l.useEffect(()=>lk({tabId:r,directory:N,ownerSessionId:o,describe:ye,run:W}),[ye,o,W,N,r]),l.useEffect(()=>{const Ce=Te;return()=>{Ji(Ce)}},[Te]),l.useEffect(()=>{if(!u)return;const Ce=ze=>{const Oe=ze;if(typeof Oe.level!="number"||Oe.level<2)return;const it=Oe.sourceId?`${Oe.sourceId}${Oe.line?`:${Oe.line}`:""}`:"";R.current.push({level:Oe.level>=3?"error":"warning",message:String(Oe.message??"").slice(0,400),source:it}),R.current.length>_d&&R.current.splice(0,R.current.length-_d)},_e=()=>{R.current=[]};return u.addEventListener("console-message",Ce),u.addEventListener("did-start-loading",_e),()=>{u.removeEventListener("console-message",Ce),u.removeEventListener("did-start-loading",_e)}},[u]);const de=l.useRef(new Set),Ne=l.useCallback(Ce=>{de.current.clear(),Ie(Ce)},[Ie]),Je=l.useRef(M.status);Je.current=M.status;const Ge=l.useRef(!1);M.status.kind==="ready"&&M.status.url&&(Ge.current=!0),l.useEffect(()=>Ng(N,r,Ce=>{Ag(Je.current,Ge.current)&&Ne(Ce)}),[Ne,N,r]),l.useEffect(()=>{if(!u)return;const Ce=ze=>{const Oe=tr(ze),it=typeof Oe.url=="string"?Oe.url:"";!it||!Fc(it,s)||(ze.preventDefault(),Ie(it))},_e=ze=>{const Oe=tr(ze);if(Oe.isMainFrame===!1||Oe.errorCode===-3)return;const it=typeof Oe.validatedURL=="string"?Oe.validatedURL:"";!it||!Fc(it,s)||de.current.has(it)||(de.current.add(it),Ie(it))};return u.addEventListener("will-navigate",Ce),u.addEventListener("did-fail-load",_e),()=>{u.removeEventListener("will-navigate",Ce),u.removeEventListener("did-fail-load",_e)}},[s,Ie,u]),l.useEffect(()=>{if(!u)return;const Ce=_e=>{if(!(_e instanceof CustomEvent))return;const ze=y2.safeParse(_e.detail);if(!ze.success)return;let Oe=-1;try{Oe=u.getWebContentsId()}catch{return}ze.data.webContentsId===Oe&&le.getState().openContextBrowser(N,ze.data.url,{reveal:!ze.data.background})};return window.addEventListener(Fd,Ce),()=>window.removeEventListener(Fd,Ce)},[N,u]);const ge=l.useCallback(Ce=>{const _e=Math.min(g2,Math.max(m2,Ce));F.current=_e,O(_e);try{c.current?.setZoomLevel(_e)}catch{}},[]);l.useEffect(()=>{const Ce=_e=>{if(!(_e instanceof CustomEvent))return;const ze=_e.detail,Oe=c.current;!Oe||document.activeElement!==Oe||(ze==="zoom-in"?ge(F.current+uo):ze==="zoom-out"?ge(F.current-uo):ze==="zoom-reset"&&ge(0))};return window.addEventListener("openchamber:zoom",Ce),()=>window.removeEventListener("openchamber:zoom",Ce)},[ge]);const Ae=l.useCallback(Ce=>{Xn("desktop_browser_clear_data",{partition:Bd(s),cookies:Ce==="cookies",cache:Ce==="cache"}).then(()=>{He.success(a(Ce==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{c.current?.reloadIgnoringCache()}catch{}}).catch(()=>He.error(a("contextPanel.browser.clearFailed")))},[s,a]);l.useEffect(()=>{const Ce=D.current;if(!Ce||typeof ResizeObserver>"u")return;const _e=new ResizeObserver(ze=>{const Oe=ze[0]?.contentRect;Oe&&E({width:Oe.width,height:Oe.height})});return _e.observe(Ce),()=>_e.disconnect()},[]);const Ye=l.useCallback(Ce=>{_(Ce);const _e=c.current;if(!_e)return;let ze=-1;try{ze=_e.getWebContentsId()}catch{return}Xn("desktop_browser_set_color_scheme",{webContentsId:ze,scheme:Ce}).catch(Oe=>{_("system"),He.error(Oe instanceof Error?Oe.message:a("contextPanel.browser.device.schemeFailed"))})},[a]),nt=l.useCallback(()=>{try{we?c.current?.stop():c.current?.reload()}catch{}},[we]),oe=M.status,tt=l.useSyncExternalStore(f2,p2),Ue=i&&tt||o!==null||ae;l.useEffect(()=>{const Ce=X=>{I(!0);const Be=setTimeout(()=>{try{c.current?.reload()}catch{}},X);return()=>clearTimeout(Be)};if(oe.kind==="loading")return;const _e=A.current||q.current===oe;if(A.current&&(oe.kind==="failed"||oe.kind==="ready"&&oe.url)&&(A.current=!1,q.current=oe),oe.kind==="failed"){const X=Mg(oe,{run:C.current,restored:_e,watched:Ue,now:Date.now()});if(C.current=X.run,X.next==="retry")return Ce(X.delayMs);I(X.next==="pause");return}if(C.current=null,oe.kind!=="ready"||!oe.url||!Qu(oe.url)){ee.current=!0,I(!1);return}if(_e||ee.current||Date.now()-Q.current>S2){ee.current=!0,I(!1);return}let ze=!1,Oe=null;return($s(s)?Promise.resolve(null):Gj(Un(oe.url))).then(X=>{if(!ze){if(X===null||X<500){ee.current=!0,I(!1);return}Oe=Ce(x2)}}),()=>{ze=!0,Oe?.()}},[s,oe,Ue]);const gt=M.status.kind==="failed"&&!k?M.status:null,bt=Ok(L,$);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(jh,{address:m,onAddressChange:v,onSubmit:Ne,suggestions:ke,onForgetSuggestion:Ce=>be(s,Ce),onBack:()=>{try{c.current?.goBack()}catch{}},onForward:()=>{try{c.current?.goForward()}catch{}},onReload:nt,onOpenExternal:()=>{xr(M.url||m)},addressMark:Mh(s,m,S??a("contextPanel.browser.spaceAddress")),canOpenExternal:$s(s)===null,canGoBack:M.canGoBack,canGoForward:M.canGoForward,isLoading:we,onAnnotate:Y,isAnnotating:w,onOpenDevTools:()=>{try{c.current?.openDevTools()}catch{}},onHardReload:()=>{try{c.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ge(B+uo),onZoomOut:()=>ge(B-uo),onZoomReset:()=>ge(0),zoomPercent:Math.round(Math.pow(1.2,B)*100),onClearCookies:()=>Ae("cookies"),onClearCache:()=>Ae("cache"),onToggleDeviceBar:()=>P(Ce=>!Ce),isDeviceBarOpen:j}),j?n.jsx(_k,{viewport:L,onViewportChange:z,colorScheme:G,onColorSchemeChange:Ye,scale:bt?.scale??1}):null,n.jsxs("div",{ref:D,className:Pe("relative min-h-0 flex-1 bg-background",bt&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null&&ce?n.jsx("webview",{ref:p,src:x,partition:Bd(s),allowpopups:!0,style:bt?{width:`${bt.width}px`,height:`${bt.height}px`,transform:`scale(${bt.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!b&&!M.url&&!we?n.jsx(Rh,{onOpen:Ne,directory:s,visible:i}):null,k?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a("contextPanel.browser.waitingForServerHint")})]}):null,V?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[$s(s)!==null?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:a("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:a($s(s)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:V})})]}):null,gt&&!V?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[n.jsx("span",{className:"typography-ui-header text-foreground",children:gt.crashed?a("contextPanel.browser.crashed"):a("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:gt.crashed?a("contextPanel.browser.crashedHint"):gt.description||a("contextPanel.browser.loadFailedUnknown")})]}):null,we?n.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:n.jsx("div",{className:"h-full w-1/3 bg-[var(--primary)]"})}):null]})]})},k2=t=>{const e=Ze.c(75),{initialUrl:s,directory:r,siteDirectory:o,tabID:i,visible:a}=t,{t:d}=Et(),c=le(I2);let u;e[0]!==s?(u=nr(s),e[0]=s,e[1]=u):u=e[1];const f=u,p=f!==wn?f:"",[h,g]=l.useState(p);let b;e[2]!==o||e[3]!==p?(b=Qi(p,o),e[2]=o,e[3]=p,e[4]=b):b=e[4];const[x,y]=l.useState(b);let S;e[5]!==o||e[6]!==p?(S=xf(p,o)?p:"",e[5]=o,e[6]=p,e[7]=S):S=e[7];const[m,v]=l.useState(S);let w;e[8]!==o?(w=$s(o),e[8]=o,e[9]=w):w=e[9];const T=w!==null,k=Jl(o);let I;e[10]!==p?(I=p?[p]:[],e[10]=p,e[11]=I):I=e[11];const[B,O]=l.useState(I),[F,j]=l.useState(p?0:-1),[P,L]=l.useReducer(P2,0);let z,H;e[12]!==i||e[13]!==r?(z=()=>{Zu(Ds(r),i)},H=[r,i],e[12]=i,e[13]=r,e[14]=z,e[15]=H):(z=e[14],H=e[15]),l.useEffect(z,H);let R;e[16]!==c||e[17]!==i||e[18]!==r?(R=ke=>{!ke||ke===wn||!r||!i||c(r,i,ke)},e[16]=c,e[17]=i,e[18]=r,e[19]=R):R=e[19];const G=R;let _;e[20]!==o?(_=vh(o),e[20]=o,e[21]=_):_=e[21];const $=ir(_),E=ir(E2),D=ir(T2);let C;e[22]!==h||e[23]!==$?(C=wh($,h),e[22]=h,e[23]=$,e[24]=C):C=e[24];const N=C;let A;e[25]!==o||e[26]!==F||e[27]!==G||e[28]!==E?(A=ke=>{const Ie=nr(ke);if(Ie===wn)return;g(Ie);const Te=Qi(Ie,o);y(Te),v(Te?"":Ie),G(Ie),E(o,{url:Ie}),O(Y=>{const ue=F>=0?Y.slice(0,F+1):[];return ue[ue.length-1]===Ie?(j(ue.length-1),ue):(j(ue.length),[...ue,Ie])})},e[25]=o,e[26]=F,e[27]=G,e[28]=E,e[29]=A):A=e[29];const q=A;let ee;e[30]!==o||e[31]!==B||e[32]!==G?(ee=ke=>{const Ie=B[ke];if(!Ie)return;j(ke),g(Ie);const Te=Qi(Ie,o);y(Te),v(Te?"":Ie),G(Ie)},e[30]=o,e[31]=B,e[32]=G,e[33]=ee):ee=e[33];const Q=ee;let he;e[34]!==o||e[35]!==D?(he=ke=>D(o,ke),e[34]=o,e[35]=D,e[36]=he):he=e[36];let M,V;e[37]!==Q||e[38]!==F?(M=()=>Q(F-1),V=()=>Q(F+1),e[37]=Q,e[38]=F,e[39]=M,e[40]=V):(M=e[39],V=e[40]);let ie;e[41]!==h||e[42]!==x?(ie=()=>{xr(x||h)},e[41]=h,e[42]=x,e[43]=ie):ie=e[43];let ce;e[44]!==k||e[45]!==d?(ce=k??d("contextPanel.browser.spaceAddress"),e[44]=k,e[45]=d,e[46]=ce):ce=e[46];let ne;e[47]!==h||e[48]!==o||e[49]!==ce?(ne=Mh(o,h,ce),e[47]=h,e[48]=o,e[49]=ce,e[50]=ne):ne=e[50];const je=!m,Ee=F>0,we=F>=0&&F<B.length-1;let Me;e[51]!==h||e[52]!==q||e[53]!==N||e[54]!==he||e[55]!==M||e[56]!==V||e[57]!==ie||e[58]!==ne||e[59]!==je||e[60]!==Ee||e[61]!==we?(Me=n.jsx(jh,{address:h,onAddressChange:g,onSubmit:q,suggestions:N,onForgetSuggestion:he,onBack:M,onForward:V,onReload:L,onOpenExternal:ie,addressMark:ne,canOpenExternal:je,canGoBack:Ee,canGoForward:we,isLoading:!1}),e[51]=h,e[52]=q,e[53]=N,e[54]=he,e[55]=M,e[56]=V,e[57]=ie,e[58]=ne,e[59]=je,e[60]=Ee,e[61]=we,e[62]=Me):Me=e[62];let fe;e[63]!==o||e[64]!==T||e[65]!==x||e[66]!==q||e[67]!==P||e[68]!==d||e[69]!==m||e[70]!==a?(fe=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:m?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[T?n.jsx(Z,{name:"box-3",className:"size-8 text-muted-foreground opacity-70","aria-hidden":"true"}):null,n.jsx("span",{className:"typography-ui-header text-foreground",children:d(T?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:ii(m)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:d("contextPanel.browser.remoteLoopback.hint")})]}):x?n.jsx("iframe",{src:x,title:d("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${P}`):n.jsx(Rh,{onOpen:q,directory:o,visible:a})}),e[63]=o,e[64]=T,e[65]=x,e[66]=q,e[67]=P,e[68]=d,e[69]=m,e[70]=a,e[71]=fe):fe=e[71];let be;return e[72]!==Me||e[73]!==fe?(be=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[Me,fe]}),e[72]=Me,e[73]=fe,e[74]=be):be=e[74],be},C2=t=>{const e=Ze.c(3),[s]=l.useState(h2);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(j2,{...t}):n.jsx(k2,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function I2(t){return t.setContextPanelTabTargetPath}function P2(t){return t+1}function E2(t){return t.recordVisit}function T2(t){return t.forget}const D2=t=>{const e=Ze.c(13),{zone:s,children:r}=t,[o]=l.useState(R2);let i;e[0]!==s?(i=h=>h.body[s],e[0]=s,e[1]=i):i=e[1];const a=Hr(i);let d,c;e[2]!==a||e[3]!==o||e[4]!==s?(d=()=>{const h=a??Hr.getState().body[s];if(!h){o.remove();return}if(o.parentElement===h)return;const g=document.activeElement;h.moveBefore&&o.isConnected?h.moveBefore(o,null):h.append(o),g instanceof HTMLElement&&o.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},c=[a,o,s],e[2]=a,e[3]=o,e[4]=s,e[5]=d,e[6]=c):(d=e[5],c=e[6]),l.useLayoutEffect(d,c);let u,f;e[7]!==o?(u=()=>()=>o.remove(),f=[o],e[7]=o,e[8]=u,e[9]=f):(u=e[8],f=e[9]),l.useLayoutEffect(u,f);let p;return e[10]!==r||e[11]!==o?(p=gl.createPortal(r,o),e[10]=r,e[11]=o,e[12]=p):p=e[12],p};function R2(){const t=document.createElement("div");return t.style.display="contents",t}const N2=(t,e)=>{const s=[];let r=0;for(const[o,i]of e){const a=Math.min(Math.max(o,r),t.length),d=Math.min(Math.max(i,a),t.length);d!==a&&(a>r&&s.push({text:t.slice(r,a),matched:!1}),s.push({text:t.slice(a,d),matched:!0}),r=d)}return r<t.length&&s.push({text:t.slice(r),matched:!1}),s},M2=200,Ah=t=>`${t.path}:${t.line}:${t.column}`,Ld={status:"idle"},A2=t=>{const e=Ze.c(9),{searchContents:s,directory:r,query:o,regex:i,includeHidden:a,respectGitignore:d,active:c}=t,[u,f]=l.useState(Ld);let p,h;return e[0]!==c||e[1]!==r||e[2]!==a||e[3]!==o||e[4]!==i||e[5]!==d||e[6]!==s?(p=()=>{if(!c||!s||!r||!o.trim()){f(Ld);return}const g=new AbortController;let b=!1;return f({status:"searching"}),s({directory:r,query:o,regex:i,limit:M2,includeHidden:a,respectGitignore:d,signal:g.signal}).then(x=>{b||f(x.status==="ok"?{status:"results",matches:x.matches,stopped:x.stopped}:x)}).catch(x=>{b||f({status:"failed",message:x instanceof Error?x.message:String(x)})}),()=>{b=!0,g.abort()}},h=[c,r,a,o,i,d,s],e[0]=c,e[1]=r,e[2]=a,e[3]=o,e[4]=i,e[5]=d,e[6]=s,e[7]=p,e[8]=h):(p=e[7],h=e[8]),l.useEffect(p,h),u},On=t=>{const e=Ze.c(5),{className:s,children:r}=t;let o;e[0]!==s?(o=Pe("px-2 py-1 typography-meta text-muted-foreground",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==r||e[3]!==o?(i=n.jsx("li",{className:o,children:r}),e[2]=r,e[3]=o,e[4]=i):i=e[4],i},O2=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},B2=t=>{const e=Ze.c(44),{state:s,activeMatchKey:r,onOpen:o,onDragStart:i,onDragEnd:a}=t,{t:d}=Et();switch(s.status){case"idle":return null;case"searching":{let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),e[0]=p):p=e[0];let h;e[1]!==d?(h=d("sidebarFilesTree.state.searching"),e[1]=d,e[2]=h):h=e[2];let g;return e[3]!==h?(g=n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[p,h]}),e[3]=h,e[4]=g):g=e[4],g}case"unavailable":{let p;e[5]!==d?(p=d("sidebarFilesTree.contentSearch.unavailable"),e[5]=d,e[6]=p):p=e[6];let h;return e[7]!==p?(h=n.jsx(On,{children:p}),e[7]=p,e[8]=h):h=e[8],h}case"invalid-pattern":{let p;e[9]!==d?(p=d("sidebarFilesTree.contentSearch.invalidPattern"),e[9]=d,e[10]=p):p=e[10];let h;e[11]!==p?(h=n.jsx("span",{className:"text-[var(--status-error)]",children:p}),e[11]=p,e[12]=h):h=e[12];let g;e[13]!==s.message?(g=n.jsx("span",{className:"font-mono typography-micro",dir:"ltr",children:s.message}),e[13]=s.message,e[14]=g):g=e[14];let b;return e[15]!==h||e[16]!==g?(b=n.jsxs(On,{className:"flex flex-col gap-0.5",children:[h,g]}),e[15]=h,e[16]=g,e[17]=b):b=e[17],b}case"failed":{let p;e[18]!==s.message||e[19]!==d?(p=d("sidebarFilesTree.contentSearch.failed",{message:s.message}),e[18]=s.message,e[19]=d,e[20]=p):p=e[20];let h;return e[21]!==p?(h=n.jsx(On,{className:"text-[var(--status-error)]",children:p}),e[21]=p,e[22]=h):h=e[22],h}}if(s.matches.length===0){let p;return e[23]!==s.stopped||e[24]!==d?(p=s.stopped==="deadline"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.deadline")}):n.jsx(On,{children:d("sidebarFilesTree.contentSearch.empty")}),e[23]=s.stopped,e[24]=d,e[25]=p):p=e[25],p}let c;if(e[26]!==r||e[27]!==a||e[28]!==i||e[29]!==o||e[30]!==s.matches){let p;e[32]!==r||e[33]!==a||e[34]!==i||e[35]!==o?(p=h=>{const{name:g,directory:b}=O2(h.relativePath),x=Ah(h),y=r===x;return n.jsx("li",{"data-file-tree-path":h.path,children:n.jsxs("button",{type:"button",onClick:()=>o(h),onDoubleClick:()=>o(h,{pin:!0}),draggable:!!i,onDragStart:i?S=>i(S,h):void 0,onDragEnd:a?S=>a(S,h):void 0,className:Pe("flex w-full flex-col gap-0.5 rounded-md px-2 py-1 text-start transition-colors",_l(y)),title:`${h.relativePath}:${h.line}`,children:[n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[n.jsx(mi,{filePath:h.path,className:"size-3.5 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 flex-shrink truncate typography-meta",dir:"auto",children:g}),b?n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-micro text-muted-foreground",style:{direction:"rtl"},children:`‎${b}‎`}):n.jsx("span",{className:"flex-1"}),n.jsx("span",{className:"flex-shrink-0 typography-micro tabular-nums text-muted-foreground",children:h.line})]}),n.jsxs("span",{className:"block w-full min-w-0 truncate font-mono typography-micro text-muted-foreground",dir:"ltr",children:[h.cutStart?"…":null,N2(h.text,h.ranges).map(F2)]})]})},x)},e[32]=r,e[33]=a,e[34]=i,e[35]=o,e[36]=p):p=e[36],c=s.matches.map(p),e[26]=r,e[27]=a,e[28]=i,e[29]=o,e[30]=s.matches,e[31]=c}else c=e[31];let u;e[37]!==s.matches.length||e[38]!==s.stopped||e[39]!==d?(u=s.stopped==="limit"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.limit",{count:s.matches.length})}):s.stopped==="deadline"?n.jsx(On,{children:d("sidebarFilesTree.contentSearch.deadline")}):null,e[37]=s.matches.length,e[38]=s.stopped,e[39]=d,e[40]=u):u=e[40];let f;return e[41]!==c||e[42]!==u?(f=n.jsxs(n.Fragment,{children:[c,u]}),e[41]=c,e[42]=u,e[43]=f):f=e[43],f};function F2(t,e){return t.matched?n.jsx("mark",{className:"rounded-[2px] bg-primary/25 text-foreground",children:t.text},e):n.jsx(l.Fragment,{children:t.text},e)}const sl=2e4,_2=(t,e)=>{if(!t)return 1;let s=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(s+=1,s>e))return s;return s},fo=(t,e)=>Og(Bg.getState().dictionary,t,e),L2=t=>{const s=(t instanceof Error?t.message:String(t??"")).toLowerCase();return s.includes("file not found")||s.includes("not found")||s.includes("enoent")||s.includes("no such file")||s.includes("does not exist")?"missing":"unreadable"},$2=async(t,e,s)=>{const r=!!(s?.directory&&!p1(e,s.directory));if(t.readFile)return(await t.readFile(e,{optional:!0,directory:s?.directory,allowOutsideWorkspace:r})).content??"";const o=new URLSearchParams({path:e,optional:"true"});s?.directory&&o.set("directory",s.directory),r&&o.set("allowOutsideWorkspace","true");const i=await Ys(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const a=await i.json().catch(()=>({error:i.statusText}));throw new Error(a.error||"Failed to read file")}return i.text()},$d=async(t,e,s)=>{if(c1(e)||d1(e)||u1(e))return{ok:!0};try{const r=await $2(t,e,s);return f1(r)?{ok:!1,reason:"binary"}:_2(r,sl)>sl?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:L2(r)}}},zd=t=>{if(t==="too-large"){const e=sl.toLocaleString(rp());return fo("contextFileOpen.failure.tooLarge",{count:e})}return fo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Kd=8;let Vr=null;const Oh=(t,e)=>Math.abs(e.clientX-t.x)<=Kd&&Math.abs(e.clientY-t.y)<=Kd,nl=t=>{Vr={x:t.clientX,y:t.clientY}},rl=t=>{const e=Vr;return Vr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Oh(e,t)},Bh=t=>Vr!==null&&Oh(Vr,t);let Fh=null;const pa=t=>{Fh=t},_h=()=>Fh,Wd=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},Lh=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Wd(e.path);return!r||Wd(t.path)===r||t.type==="directory"&&Fg(r,t.path,t.path)!==null?null:r},z2=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},K2=({root:t,childrenByDir:e,expandedPaths:s,loadErrorsByDir:r})=>{const o=[],i=(a,d)=>{for(const c of e[a]??[]){const u=c.type==="directory"&&s.has(c.path);if(o.push({kind:"node",key:c.path,node:c,depth:d,isExpanded:u}),!u)continue;const f=r[c.path];f&&o.push({kind:"error",key:`error:${c.path}`,directory:c.path,depth:d+1,message:f}),i(c.path,d+1)}};return i(t,0),o},W2=(t,e,s)=>{const r=e.filter(o=>o>=0&&o<s&&!t.includes(o));return r.length===0?[...t]:[...t,...r].sort((o,i)=>o-i)},H2=28,ar=t=>Array.from(t.types).includes("Files"),_r=t=>Array.from(t.types).includes($r)?_h():null,$h=(t,e,s)=>t.getData($r)===Di(e,s.path),U2=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(s=>{if(s.kind!=="file"||s.webkitGetAsEntry()?.isDirectory)return[];const r=s.getAsFile();return r?[r]:[]})},V2=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),hs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),s&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Di=(t,e)=>{const s=hs(e),r=hs(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},jr=(t,e)=>{const s=Di(t,e);if(s!==".")return s;const r=hs(t);return r.split("/").filter(Boolean).pop()??r},Eo=t=>{const e=hs(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},G2=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),q2=new Set(["node_modules"]),Y2=t=>q2.has(t),Z2=t=>{const e=hs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Q2=8,tn=new Map,tc=t=>JSON.stringify([Jt(),t]),X2=t=>{const e=tc(t),s=tn.get(e);return s?(s.touchedAt=Date.now(),tn.delete(e),tn.set(e,s),s):null},ha=t=>{const e=tc(t),s=tn.get(e);if(s)return s.touchedAt=Date.now(),s;if(tn.size>=Q2){const o=tn.keys().next().value;o!==void 0&&tn.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return tn.set(e,r),r},J2=t=>{const e=Ze.c(127),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:a,depth:d,isOpen:c,status:u,badge:f,isDropTarget:p,isDragSource:h,canUpload:g,canMove:b,permissions:x,downloadFile:y,onSelect:S,onToggle:m,onRevealPath:v,onOpenDialog:w,onSetDropTarget:T,onDropFiles:k,onPickFiles:I,onMoveDragChange:B,onSetMoveDropTarget:O,onMoveDrop:F}=t,{t:j}=Et(),P=s.type==="directory";let L;e[0]!==P||e[1]!==s.path?(L=P?s.path:Eo(s.path),e[0]=P,e[1]=s.path,e[2]=L):L=e[2];const z=L,{canRename:H,canCreateFile:R,canCreateFolder:G,canDelete:_,canReveal:$}=x,E=!P&&!!y,D=$&&!a,C=P&&g,N=H||R||G||C||_||E||D,[A,q]=l.useState(!1),[ee,Q]=l.useState(!1);let he;e[3]!==N?(he=Oe=>{N&&(Oe?.preventDefault(),Q(!0))},e[3]=N,e[4]=he):he=e[4];const M=he;let V;e[5]!==P||e[6]!==s||e[7]!==S||e[8]!==m?(V=()=>{P?m(s.path):S(s)},e[5]=P,e[6]=s,e[7]=S,e[8]=m,e[9]=V):V=e[9];const ie=V;let ce;e[10]!==P||e[11]!==s||e[12]!==S?(ce=()=>{P||S(s,{pin:!0})},e[10]=P,e[11]=s,e[12]=S,e[13]=ce):ce=e[13];const ne=ce;let je;e[14]===Symbol.for("react.memo_cache_sentinel")?(je=Oe=>{Oe.stopPropagation(),Q(!1),q(!0)},e[14]=je):je=e[14];const Ee=je;let we;e[15]!==R||e[16]!==G||e[17]!==_||e[18]!==H||e[19]!==D||e[20]!==C||e[21]!==y||e[22]!==a||e[23]!==P||e[24]!==s||e[25]!==w||e[26]!==I||e[27]!==v||e[28]!==j?(we=Oe=>{const{Item:it,Separator:X}=Oe;return n.jsxs(n.Fragment,{children:[H&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("rename",s)},children:[n.jsx(Z,{name:"edit",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.rename")]}),n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),pi(s.path).then(Le=>{if(Le.ok){He.success(j("sidebarFilesTree.toast.pathCopied"));return}He.error(j("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Z,{name:"file-copy",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.copyPath")]}),!P&&y&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),y(s.path).catch(Le=>{console.error("Download failed:",Le),He.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"download",className:"me-2 h-4 w-4"})," ",j(a?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),D&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),v(s.path)},children:[n.jsx(Z,{name:"folder-received",className:"me-2 h-4 w-4"})," ",j(ap())]}),!P&&D&&li()&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),_g(s.path).then(Le=>{Le||He.error(j("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"external-link",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.openInDefaultApp")]}),P&&(R||G||C)&&n.jsxs(n.Fragment,{children:[n.jsx(X,{}),R&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("createFile",s)},children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFile")]}),G&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("createFolder",s)},children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.newFolder")]}),C&&n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),I(s.path)},children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.uploadFiles")]})]}),_&&n.jsxs(n.Fragment,{children:[n.jsx(X,{}),n.jsxs(it,{onClick:Be=>{Be.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",j("sidebarFilesTree.menu.delete")]})]})]})},e[15]=R,e[16]=G,e[17]=_,e[18]=H,e[19]=D,e[20]=C,e[21]=y,e[22]=a,e[23]=P,e[24]=s,e[25]=w,e[26]=I,e[27]=v,e[28]=j,e[29]=we):we=e[29];const Me=we;let fe;e[30]!==b||e[31]!==s.path||e[32]!==s.type||e[33]!==B||e[34]!==r?(fe=Oe=>{nl(Oe);const it=Di(r,s.path);!it||it==="."||(Oe.dataTransfer.setData($r,it),Oe.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&B({path:s.path,type:s.type}))},e[30]=b,e[31]=s.path,e[32]=s.type,e[33]=B,e[34]=r,e[35]=fe):fe=e[35];const be=fe;let ke;e[36]!==b||e[37]!==ie||e[38]!==B?(ke=Oe=>{b&&B(null),rl(Oe)&&ie()},e[36]=b,e[37]=ie,e[38]=B,e[39]=ke):ke=e[39];const Ie=ke;let Te;e[40]!==g||e[41]!==T||e[42]!==z?(Te=Oe=>{!g||!z||!ar(Oe.dataTransfer)||(Oe.preventDefault(),Oe.stopPropagation(),Oe.dataTransfer.dropEffect="copy",T(z))},e[40]=g,e[41]=T,e[42]=z,e[43]=Te):Te=e[43];const Y=Te;let ue;e[44]!==g||e[45]!==T||e[46]!==z?(ue=Oe=>{!g||!z||!ar(Oe.dataTransfer)||Oe.relatedTarget instanceof Node&&Oe.currentTarget.contains(Oe.relatedTarget)||(Oe.stopPropagation(),T(null))},e[44]=g,e[45]=T,e[46]=z,e[47]=ue):ue=e[47];const me=ue;let re;e[48]!==g||e[49]!==k||e[50]!==z?(re=Oe=>{!g||!z||!ar(Oe.dataTransfer)||(Oe.preventDefault(),Oe.stopPropagation(),k(z,Oe.dataTransfer))},e[48]=g,e[49]=k,e[50]=z,e[51]=re):re=e[51];const pe=re;let U;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(U=(Oe,it)=>Bh(Oe)?null:Lh(it,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=U):U=e[55];const ae=U;let Re;e[56]!==b||e[57]!==ae||e[58]!==Y||e[59]!==O?(Re=Oe=>{const it=b?_r(Oe.dataTransfer):null;if(!it){Y(Oe);return}Oe.stopPropagation();const X=ae(Oe,it);O(X),X&&(Oe.preventDefault(),Oe.dataTransfer.dropEffect="move")},e[56]=b,e[57]=ae,e[58]=Y,e[59]=O,e[60]=Re):Re=e[60];const W=Re;let ye;e[61]!==b||e[62]!==ae||e[63]!==pe||e[64]!==F||e[65]!==O||e[66]!==r?(ye=Oe=>{const it=b?_r(Oe.dataTransfer):null;if(!it){pe(Oe);return}Oe.stopPropagation(),Oe.preventDefault(),O(null);const X=ae(Oe,it);X&&$h(Oe.dataTransfer,r,it)&&F(it,X)},e[61]=b,e[62]=ae,e[63]=pe,e[64]=F,e[65]=O,e[66]=r,e[67]=ye):ye=e[67];const de=ye;let Ne;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ne={blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ne):Ne=e[68];let Je;e[69]!==M||e[70]!==me||e[71]!==W||e[72]!==de?(Je=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ne,onContextMenu:M,onDragEnter:W,onDragOver:W,onDragLeave:me,onDrop:de}),e[69]=M,e[70]=me,e[71]=W,e[72]=de,e[73]=Je):Je=e[73];let Ge;e[74]!==d?(Ge=n.jsx(lp,{depth:d}),e[74]=d,e[75]=Ge):Ge=e[75];let ge;e[76]!==i||e[77]!==h||e[78]!==p?(ge=Pe("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",p?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":_l(i),h&&"opacity-50"),e[76]=i,e[77]=h,e[78]=p,e[79]=ge):ge=e[79];let Ae;e[80]!==d?(Ae=$l(d),e[80]=d,e[81]=Ae):Ae=e[81];let Ye;e[82]!==Ae?(Ye={paddingInlineStart:Ae},e[82]=Ae,e[83]=Ye):Ye=e[83];let nt;e[84]!==P||e[85]!==o||e[86]!==s.extension||e[87]!==s.path?(nt=P?n.jsx(eo,{expanded:o}):n.jsx(mi,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=P,e[85]=o,e[86]=s.extension,e[87]=s.path,e[88]=nt):nt=e[88];let oe;e[89]!==s.name||e[90]!==s.path?(oe=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[89]=s.name,e[90]=s.path,e[91]=oe):oe=e[91];let tt;e[92]!==P||e[93]!==c||e[94]!==u?(tt=!P&&n.jsx(h1,{isOpen:c,status:u}),e[92]=P,e[93]=c,e[94]=u,e[95]=tt):tt=e[95];let Ue;e[96]!==f||e[97]!==P?(Ue=P&&f&&n.jsx(m1,{badge:f}),e[96]=f,e[97]=P,e[98]=Ue):Ue=e[98];let gt;e[99]!==M||e[100]!==ne||e[101]!==Ie||e[102]!==be||e[103]!==ie||e[104]!==ge||e[105]!==Ye||e[106]!==nt||e[107]!==oe||e[108]!==tt||e[109]!==Ue?(gt=n.jsxs("button",{type:"button",onClick:ie,onDoubleClick:ne,onContextMenu:M,draggable:!0,onDragStart:be,onDragEnd:Ie,className:ge,style:Ye,children:[nt,oe,tt,Ue]}),e[99]=M,e[100]=ne,e[101]=Ie,e[102]=be,e[103]=ie,e[104]=ge,e[105]=Ye,e[106]=nt,e[107]=oe,e[108]=tt,e[109]=Ue,e[110]=gt):gt=e[110];let bt;e[111]!==A||e[112]!==N||e[113]!==Me||e[114]!==j?(bt=N&&n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(Rs,{open:A,onOpenChange:q,children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Ee,title:j("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":j("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Z,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:j("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Ms,{align:"end",side:"bottom",onCloseAutoFocus:()=>q(!1),children:Me({Item:rs,Separator:In})})]})}),e[111]=A,e[112]=N,e[113]=Me,e[114]=j,e[115]=bt):bt=e[115];let Ce;e[116]!==Je||e[117]!==Ge||e[118]!==gt||e[119]!==bt?(Ce=n.jsxs(zl,{render:Je,children:[Ge,gt,bt]}),e[116]=Je,e[117]=Ge,e[118]=gt,e[119]=bt,e[120]=Ce):Ce=e[120];let _e;e[121]!==Me?(_e=n.jsx(Ll,{className:"min-w-[180px]",children:Me({Item:$n,Separator:wo})}),e[121]=Me,e[122]=_e):_e=e[122];let ze;return e[123]!==ee||e[124]!==Ce||e[125]!==_e?(ze=n.jsxs(Zr,{open:ee,onOpenChange:Q,children:[Ce,_e]}),e[123]=ee,e[124]=Ce,e[125]=_e,e[126]=ze):ze=e[126],ze},eC=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.depth===e.depth&&t.isOpen===e.isOpen&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.isDragSource===e.isDragSource&&t.canUpload===e.canUpload&&t.canMove===e.canMove&&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&&t.onMoveDragChange===e.onMoveDragChange&&t.onSetMoveDropTarget===e.onSetMoveDropTarget&&t.onMoveDrop===e.onMoveDrop,tC=l.memo(J2,eC),sC=t=>{const e=Ze.c(14),{visible:s}=t,r=s===void 0?!0:s,o=Cn(rC),i=Nn()??"",a=Yr();let d,c,u,f;if(e[0]!==a||e[1]!==i||e[2]!==o){f=Symbol.for("react.early_return_sentinel");e:{if(c=fi(a,i)??"",a?.kind==="preparing"){let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(So,{}),e[7]=h):h=e[7],f=h;break e}d=nC,u=JSON.stringify([o,c])}e[0]=a,e[1]=i,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=f}else d=e[3],c=e[4],u=e[5],f=e[6];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return e[8]!==d||e[9]!==c||e[10]!==i||e[11]!==u||e[12]!==r?(p=n.jsx(d,{visible:r,currentDirectory:c,panelDirectory:i},u),e[8]=d,e[9]=c,e[10]=i,e[11]=u,e[12]=r,e[13]=p):p=e[13],p},nC=({visible:t,currentDirectory:e,panelDirectory:s})=>{const r=l.useRef(t);r.current=t;const{t:o}=Et(),{files:i,runtime:a}=Ks(),d=Lg(a.platform),c=hs(e.trim()),u=hs(s.trim()),f=tc(c),p=$g(),h=zg(),g=Kg(K=>K.searchFiles),b=le(K=>K.openContextFile),x=hi(t?e:null),[y,S]=l.useState(""),m=g1(y,200),v=l.useRef(null),[w,T]=l.useState([]),[k,I]=l.useState(!1),B=!!i.searchContents,[O,F]=l.useState("names"),[j,P]=l.useState(!1),L=B&&O==="contents",z=A2({searchContents:i.searchContents,directory:e,query:m,regex:j,includeHidden:p,respectGitignore:!h,active:t&&L}),H=le(K=>K.openContextFileAtLine),[R,G]=l.useState(null),[_,$]=l.useState(null),[E,D]=l.useState(null),[C,N]=l.useState(null),[A,q]=l.useState(null),{hasTouchOnlyPointer:ee}=Rn(),Q=!!(i.rename&&c)&&!ee,he=le(K=>K.confirmFileTreeMove),M=le(K=>K.setConfirmFileTreeMove),[V,ie]=l.useState({}),[ce,ne]=l.useState({}),je=l.useRef(new Set),Ee=l.useRef(new Map),we=l.useMemo(()=>new Lw,[]);l.useEffect(()=>()=>we.clear(),[we]);const Me=l.useRef(null);l.useEffect(()=>{if($(null),N(null),q(null),!c){ie({}),ne({}),je.current=new Set;return}const K=X2(c);K?(ie({...K.childrenByDir}),ne({...K.loadErrorsByDir}),je.current=new Set(K.loadedDirs)):(ie({}),ne({}),je.current=new Set)},[c]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.childrenByDir=V},[c,V]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.loadErrorsByDir=ce},[c,ce]),l.useEffect(()=>{if(!c)return;const K=ha(c);K.loadedDirs=new Set(je.current)},[c,V,ce]),l.useEffect(()=>()=>{if(!c)return;const K=tn.get(f);K&&K.loadedDirs.size===0&&Object.keys(K.childrenByDir).length===0&&tn.delete(f)},[f,c]);const fe=l.useMemo(()=>[],[]),be=l.useMemo(()=>[],[]),ke=Vs(K=>c?K.byRoot[c]?.expandedPaths??fe:fe),Ie=l.useMemo(()=>new Set(ke),[ke]),Te=Vs(K=>c?K.byRoot[c]?.selectedPath??null:null),Y=Vs(K=>K.setSelectedPath),ue=l.useRef(null);l.useEffect(()=>{ue.current=Te},[Te]);const me=Vs(K=>K.addOpenPath),re=Vs(K=>K.removeOpenPathsByPrefix),pe=Vs(K=>K.toggleExpandedPath),U=Vs(K=>K.expandPath),ae=Vs(K=>K.collapseAllExpandedPaths),Re=le(K=>u?K.contextPanelByDirectory[u]?.tabs??be:be),W=l.useMemo(()=>new Set(Re.map(K=>K.mode==="file"?K.targetPath:null).filter(K=>typeof K=="string"&&K.length>0).map(K=>hs(K))),[Re]),[ye,de]=l.useState(null),[Ne,Je]=l.useState(null),[Ge,ge]=l.useState(""),[Ae,Ye]=l.useState(!1),nt=!!i.writeFile,oe=!!i.createDirectory,tt=!!i.rename,Ue=!!i.delete,gt=!!i.revealPath,bt=l.useMemo(()=>({canRename:tt,canCreateFile:nt,canCreateFolder:oe,canDelete:Ue,canReveal:gt}),[tt,nt,oe,Ue,gt]),Ce=l.useCallback(K=>{i.revealPath&&i.revealPath(K).catch(()=>{He.error(o("sidebarFilesTree.toast.revealFailed"))})},[i,o]),_e=l.useCallback((K,xe)=>{de(K),Je(xe),ge(K==="rename"&&xe.name||""),Ye(!1)},[]),ze=l.useCallback((K,xe)=>{const Xe=xe.filter(lt=>lt&&typeof lt.name=="string"&&lt.name.length>0).filter(lt=>p||!lt.name.startsWith(".")).filter(lt=>h||!Y2(lt.name)).map(lt=>{const Bt=lt.name,Pt=hs(lt.path||""),Gt=Pt?G2(Pt)?Pt:hs(`${K}/${Pt}`):hs(`${K}/${Bt}`),Ft=lt.isDirectory?"directory":"file",Wt=Ft==="file"&&Bt.includes(".")?Bt.split(".").pop()?.toLowerCase():void 0;return{name:Bt,path:Gt,type:Ft,extension:Wt}});return V2(Xe)},[h,p]),Oe=l.useCallback(async(K,xe,Xe=!1)=>{if(!r.current||xe?.())return;const lt=hs(K.trim());if(!lt||!Xe&&je.current.has(lt))return;const Bt=Jt();return we.run(lt,async Pt=>{const Gt=()=>!Pt()||Jt()!==Bt;try{const Ft=!h,Wt=i.listDirectory?(await i.listDirectory(lt,{respectGitignore:Ft})).entries:await Mo.listLocalDirectory(lt,{respectGitignore:Ft});if(Gt())return;Ee.current.set(lt,Wt.length);const qt=ze(lt,Wt);je.current=new Set(je.current),je.current.add(lt),ne(vs=>{if(!vs[lt])return vs;const ds={...vs};return delete ds[lt],ds}),ie(vs=>vs[lt]&&$w(vs[lt],qt)?vs:{...vs,[lt]:qt})}catch(Ft){if(Gt())return;const Wt=Ft instanceof Error?Ft.message:String(Ft??"");console.error("Failed to load sidebar directory:",Ft),ne(qt=>({...qt,[lt]:Wt}))}},Xe)},[we,i,ze,h]),it=l.useCallback(async()=>{if(!c)return;Me.current?.abort();const K=new AbortController;Me.current=K,we.clear();try{const Xe=(Vs.getState().byRoot[c]?.expandedPaths??[]).map(Pt=>hs(Pt)).filter(Pt=>!!Pt&&Pt!==c&&Pt.startsWith(`${c}/`)),lt=[c,...Xe];je.current=new Set(je.current);for(const Pt of lt)je.current.delete(Pt);ne(Pt=>{if(Object.keys(Pt).length===0)return Pt;const Gt={...Pt};let Ft=!1;for(const Wt of lt)Wt in Gt&&(delete Gt[Wt],Ft=!0);return Ft?Gt:Pt});const Bt=()=>K.signal.aborted;await Oe(c,Bt);for(let Pt=0;Pt<Xe.length&&!K.signal.aborted;Pt+=3){const Gt=Xe.slice(Pt,Pt+3);await Promise.all(Gt.map(Ft=>Oe(Ft,Bt)))}}catch(xe){if(K.signal.aborted)return;console.error("Failed to refresh sidebar tree:",xe)}finally{Me.current===K&&(Me.current=null)}},[we,Oe,c]),X=l.useCallback(async K=>{if(!K){await it();return}const xe=hs(K);je.current=new Set(je.current),je.current.delete(xe),await Oe(xe,void 0,!0)},[Oe,it]);l.useEffect(()=>{c&&(Me.current?.abort(),je.current=new Set,we.clear(),ne({}),ie(K=>Object.keys(K).length===0?K:{}),Oe(c))},[we,Oe,c,p,h]),l.useEffect(()=>{if(!t||!c||ke.length===0)return;const K=ke.map(lt=>hs(lt)).filter(lt=>!!lt&&lt!==c&&lt.startsWith(`${c}/`)&&!je.current.has(lt)&&!we.has(lt)).sort((lt,Bt)=>lt.split("/").length-Bt.split("/").length);if(K.length===0)return;let xe=!1;const Xe=()=>xe;return(async()=>{for(let lt=0;lt<K.length&&!xe;lt+=3){const Bt=K.slice(lt,lt+3);await Promise.all(Bt.map(Pt=>Oe(Pt,Xe)))}})(),()=>{xe=!0}},[we,ke,Oe,c,t]);const Be=l.useRef(t);l.useEffect(()=>{const K=t&&!Be.current;Be.current=t,K&&it()},[it,t]);const Le=l.useCallback(({directories:K})=>{if(!c)return;const xe=new Set((Vs.getState().byRoot[c]?.expandedPaths??[]).map(Wt=>hs(Wt))),Xe=c==="/"?"/":`${c}/`,lt=Wt=>{for(let qt=Wt;qt!==c;qt=Eo(qt))if(!qt.startsWith(Xe)||!xe.has(qt))return!1;return!0},Bt=Wt=>{for(let qt=Wt;qt===c||qt.startsWith(Xe);qt=Eo(qt)){if(je.current.has(qt))return qt;if(qt===c)break}return null},Pt=new Set,Gt=new Set;for(const Wt of K??je.current){const qt=Bt(hs(Wt));qt&&(lt(qt)?Pt:Gt).add(qt)}Gt.size>0&&(je.current=new Set([...je.current].filter(Wt=>!Gt.has(Wt))));const Ft=[...Pt].filter(Wt=>(Ee.current.get(Wt)??0)<=Hb);(async()=>{for(let Wt=0;Wt<Ft.length;Wt+=3)await Promise.all(Ft.slice(Wt,Wt+3).map(qt=>Oe(qt,void 0,!0)))})()},[Oe,c]);Ub({root:c,active:t,whileInactive:"drop",onChanges:Le}),l.useEffect(()=>{if(!t)return;if(!e||L){T([]),I(!1);return}const K=m.trim();if(!K){T([]),I(!1);return}let xe=!1;return I(!0),g(e,K,150,{includeHidden:p,respectGitignore:!h,type:"file"}).then(Xe=>{if(xe)return;const Bt=Xe.filter(Pt=>h||!Z2(Pt.path)).map(Pt=>({name:Pt.name,path:hs(Pt.path),type:"file",extension:Pt.extension,relativePath:Pt.relativePath}));T(Bt)}).catch(()=>{xe||T([])}).finally(()=>{xe||I(!1)}),()=>{xe=!0}},[L,e,m,g,p,h,t]);const at=l.useMemo(()=>{const K=new Map;if(!x?.files)return K;for(const xe of x.files)xe.index==="A"||xe.working_dir==="?"?K.set(xe.path,"git-added"):xe.index==="D"?K.set(xe.path,"git-deleted"):(xe.index==="M"||xe.working_dir==="M")&&K.set(xe.path,"git-modified");return K},[x]),qe=l.useMemo(()=>{const K=new Map;if(!x?.files||!c)return K;for(const xe of x.files){const Xe=xe.index==="M"||xe.working_dir==="M",lt=xe.index==="A"||xe.working_dir==="?";if(!Xe&&!lt)continue;const Bt=xe.path.split("/");if(Bt.length<=1)continue;let Pt=c;for(let Gt=0;Gt<Bt.length-1;Gt++){Pt=`${Pt}/${Bt[Gt]}`;let Ft=K.get(Pt);Ft||(Ft={modified:0,added:0},K.set(Pt,Ft)),Xe&&Ft.modified++,lt&&Ft.added++}}return K},[x,c]),ut=l.useCallback(K=>{if(at.size===0)return null;const xe=K.startsWith(c+"/")?K.slice(c.length+1):K;return at.get(xe)??null},[at,c]),dt=l.useCallback(K=>{if(qe.size===0)return null;const xe=qe.get(K);return xe&&xe.modified+xe.added>0?xe:null},[qe]),ft=l.useCallback(async(K,xe)=>{if(!c)return;const Xe=await $d(i,K.path,{directory:c});if(!Xe.ok){He.error(zd(Xe.reason));return}Y(c,K.path),me(c,K.path),b(u,K.path,{preview:!xe?.pin&&!le.getState().isMobile})},[me,i,b,u,c,Y]),st=l.useCallback(async(K,xe)=>{if(!c)return;const Xe=await $d(i,K.path,{directory:c});if(!Xe.ok){He.error(zd(Xe.reason));return}Y(c,K.path),me(c,K.path),G({path:K.path,key:Ah(K)}),H(u,K.path,K.line,K.column,{preview:!xe?.pin&&!le.getState().isMobile})},[me,i,H,u,c,Y]),Rt=l.useCallback((K,xe)=>{nl(K),pa(null),K.dataTransfer.setData($r,xe.relativePath),K.dataTransfer.effectAllowed="copy"},[]),Ke=l.useCallback((K,xe)=>{rl(K)&&st(xe)},[st]),jt=l.useCallback(async K=>{const xe=hs(K);c&&(pe(c,xe),je.current.has(xe)||await Oe(xe))},[Oe,c,pe]),{canUpload:Lt,uploadingDirectory:Mt,uploadFiles:De,pickFiles:Tt,uploadElements:At}=Vb({root:c,refreshDirectory:X}),kt=Mt!==null,pt=Mt??_,Dt=l.useCallback((K,xe)=>{const Xe=U2(xe);Xe.length!==0&&($(null),De(K,Xe))},[De]),Ve=l.useCallback(K=>{if(pa(K),!K){D(null),N(null);return}requestAnimationFrame(()=>{_h()?.path===K.path&&D(K.path)})},[]),rt=l.useCallback(async(K,xe)=>{const Xe=z2(K,xe),lt=await ad(i,{tabs:u,files:c},K.path,Xe);if(lt==="conflict"){He.error(o("sidebarFilesTree.toast.nameTaken",{name:Xe.slice(Xe.lastIndexOf("/")+1),folder:jr(c,xe)}));return}if(lt==="failed"){He.error(o("sidebarFilesTree.toast.operationFailed"));return}xe!==c&&U(c,xe),await Promise.all([X(Eo(K.path)),X(xe)]).catch(()=>{})},[U,i,u,X,c,o]),wt=l.useCallback((K,xe)=>{if(le.getState().confirmFileTreeMove){q({source:K,targetDirectory:xe});return}rt(K,xe)},[rt]),se=l.useCallback(()=>{A&&(q(null),rt(A.source,A.targetDirectory))},[rt,A]),Fe=l.useCallback((K,xe)=>!Q||Bh(K)?null:Lh(xe,null,c),[Q,c]),ot=l.useCallback(K=>{const xe=_r(K.dataTransfer);if(xe){const Xe=Fe(K,xe);if(N(Xe),!Xe)return;K.preventDefault(),K.dataTransfer.dropEffect="move";return}!Lt||kt||!c||!ar(K.dataTransfer)||(K.preventDefault(),K.dataTransfer.dropEffect="copy",$(c))},[Lt,Fe,kt,c]),$e=l.useCallback(K=>{if(!(K.relatedTarget instanceof Node&&K.currentTarget.contains(K.relatedTarget))){if(_r(K.dataTransfer)){N(null);return}ar(K.dataTransfer)&&$(null)}},[]),Ct=l.useCallback(K=>{const xe=_r(K.dataTransfer);if(xe){K.preventDefault(),N(null);const Xe=Fe(K,xe);Xe&&$h(K.dataTransfer,c,xe)&&wt(xe,Xe);return}!Lt||kt||!c||!ar(K.dataTransfer)||(K.preventDefault(),Dt(c,K.dataTransfer))},[Lt,Fe,Dt,wt,kt,c]),Yt=l.useCallback(async K=>{if(K?.preventDefault(),!Ne||!ye)return;Ye(!0);const xe=()=>Ye(!1),Xe=()=>de(null);if(ye==="createFile"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.filenameRequired")),xe();return}if(!i.writeFile){He.error(o("sidebarFilesTree.toast.writeNotSupported")),xe();return}const lt=Ne.path,Bt=lt?`${lt}/`:"",Pt=hs(`${Bt}${Ge.trim()}`);await i.writeFile(Pt,"").then(async Gt=>{Gt.success&&(He.success(o("sidebarFilesTree.toast.fileCreated")),await X(lt)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}if(ye==="createFolder"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.folderNameRequired")),xe();return}const lt=Ne.path,Bt=lt?`${lt}/`:"",Pt=hs(`${Bt}${Ge.trim()}`);await i.createDirectory(Pt).then(async Gt=>{Gt.success&&(He.success(o("sidebarFilesTree.toast.folderCreated")),await X(lt)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}if(ye==="rename"){if(!Ge.trim()){He.error(o("sidebarFilesTree.toast.nameRequired")),xe();return}if(!i.rename){He.error(o("sidebarFilesTree.toast.renameNotSupported")),xe();return}const lt=Ne.path,Bt=lt.split("/").slice(0,-1).join("/"),Pt=Bt?`${Bt}/`:"",Gt=Ge.trim(),Ft=hs(`${Pt}${Gt}`);try{const Wt=await ad(i,{tabs:u,files:c},lt,Ft);Wt==="moved"?(He.success(o("sidebarFilesTree.toast.renamedSuccessfully")),await X(Bt),Xe()):Wt==="conflict"?He.error(o("sidebarFilesTree.toast.nameTaken",{name:Gt,folder:jr(c,Bt)})):He.error(o("sidebarFilesTree.toast.operationFailed"))}catch{He.error(o("sidebarFilesTree.toast.operationFailed"))}finally{xe()}return}if(ye==="delete"){if(!i.delete){He.error(o("sidebarFilesTree.toast.deleteNotSupported")),xe();return}const lt=Ne.path,Bt=lt.split("/").slice(0,-1).join("/");await i.delete(lt).then(async Pt=>{Pt.success&&(He.success(o("sidebarFilesTree.toast.deletedSuccessfully")),await X(Bt),c&&re(c,lt),(Te===lt||Te&&Te.startsWith(lt+"/"))&&Y(c,null)),Xe()}).catch(()=>He.error(o("sidebarFilesTree.toast.operationFailed"))).finally(xe);return}xe()},[ye,Ne,Ge,i,u,X,re,c,Te,Y,o]),es=l.useMemo(()=>c?K2({root:c,childrenByDir:V,expandedPaths:Ie,loadErrorsByDir:ce}):[],[V,Ie,ce,c]),Zt=l.useMemo(()=>new Map(es.flatMap((K,xe)=>K.kind==="node"?[[K.node.path,xe]]:[])),[es]),[ss,bs]=l.useState(null),[ls,ms]=l.useState(null),[fs,Es]=l.useState(null),cs=l.useMemo(()=>[E,fs].flatMap(K=>K?[Zt.get(K)??-1]:[]),[fs,E,Zt]),Qe=l.useCallback(K=>W2(Gp(K),cs,es.length),[cs,es.length]),[vt,$t]=l.useState(0);l.useLayoutEffect(()=>{if(!ss||!ls)return;const K=ls.getBoundingClientRect().top-ss.getBoundingClientRect().top+ss.scrollTop;$t(Math.max(0,Math.round(K)))},[ls,ss]);const ve=Vp({count:es.length,enabled:ss!==null,getScrollElement:()=>ss,estimateSize:()=>H2,getItemKey:K=>es[K]?.key??K,overscan:12,scrollMargin:vt,rangeExtractor:Qe}),ct=K=>{if(K.kind==="error")return n.jsxs("div",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:$l(K.depth)},children:[n.jsx(lp,{depth:K.depth}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:K.message,children:K.message}),n.jsxs(Nt,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{X(K.directory)},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]});const{node:xe,depth:Xe,isExpanded:lt}=K,Bt=xe.type==="directory";return n.jsx(tC,{node:xe,root:c,isExpanded:lt,isActive:Te===xe.path,isBrowserClient:d,depth:Xe,isOpen:!Bt&&W.has(xe.path),status:Bt?void 0:ut(xe.path),badge:Bt?dt(xe.path):void 0,isDropTarget:Bt&&(pt===xe.path||C===xe.path),isDragSource:E===xe.path,canUpload:Lt&&!kt,canMove:Q,permissions:bt,downloadFile:i.downloadFile,onSelect:ft,onToggle:jt,onRevealPath:Ce,onOpenDialog:_e,onSetDropTarget:$,onDropFiles:Dt,onPickFiles:Tt,onMoveDragChange:Ve,onSetMoveDropTarget:N,onMoveDrop:wt})},ht=l.useCallback(K=>{const xe=K.target instanceof Element?K.target.closest("[data-tree-row-path]"):null;Es(xe?.dataset.treeRowPath??null)},[]),Ot=l.useCallback(K=>{K.relatedTarget instanceof Node&&K.currentTarget.contains(K.relatedTarget)||Es(null)},[]);l.useEffect(()=>{const K=ue.current;if(!K||!ss||!ls)return;const xe=Zt.get(K);xe===void 0||ss.offsetParent===null||(ue.current=null,ve.scrollToIndex(xe,{align:"auto"}))});const te=!!(c&&V[c]),et=c?ce[c]:null,xt=m.trim().length>0,It=!k&&!xt&&w.length===0&&!et&&te&&!!c,St=pt?jr(c,pt):"",Se=C?jr(c,C):"",We=A?A.source.path.slice(A.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col border-b border-border/40",children:[n.jsxs("div",{className:"flex h-8 shrink-0 items-center justify-end gap-1 border-t border-border/40 px-2",children:[nt||oe||Lt?n.jsxs(Rs,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":o("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Z,{name:kt?"loader-4":"add",className:Pe("h-4 w-4",kt&&"animate-spin")})})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Ms,{align:"end",className:"min-w-[180px]",children:[nt?n.jsxs(rs,{onClick:()=>_e("createFile",{path:e,type:"directory"}),children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFile")]}):null,oe?n.jsxs(rs,{onClick:()=>_e("createFolder",{path:e,type:"directory"}),children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.newFolder")]}):null,Lt?n.jsxs(rs,{disabled:!c||kt,onClick:()=>Tt(c),children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",o("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx(zw,{className:"size-6"}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>{it()},className:"size-6 p-0 flex-shrink-0",title:o("sidebarFilesTree.actions.refreshTitle"),"aria-label":o("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Z,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>{c&&ae(c)},className:"size-6 p-0 flex-shrink-0",title:o("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":o("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Z,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:6,children:o("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[B?n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsxs(Nt,{variant:"ghost",size:"sm",className:"absolute inset-s-3 top-3 size-6 p-0 text-muted-foreground hover:text-foreground",title:o("sidebarFilesTree.search.mode.aria"),"aria-label":o("sidebarFilesTree.search.mode.aria"),children:[n.jsx(Z,{name:L?"file-search":"search",className:"h-4 w-4"}),n.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0.5 end-0.5 size-0 border-[3px] border-b-current border-e-current border-s-transparent border-t-transparent opacity-70"})]})}),n.jsx(Ms,{align:"start",side:"bottom",children:n.jsxs(ep,{value:O,onValueChange:K=>F(K==="contents"?"contents":"names"),children:[n.jsxs(Lo,{value:"names",closeOnClick:!0,className:"items-center",children:[n.jsx(Z,{name:"search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.names")]}),n.jsxs(Lo,{value:"contents",closeOnClick:!0,className:"items-center",children:[n.jsx(Z,{name:"file-search",className:"size-3.5"}),o("sidebarFilesTree.search.mode.contents")]})]})})]}):n.jsx(Z,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(_o,{ref:v,value:y,onChange:K=>S(K.target.value),placeholder:o(L?"sidebarFilesTree.search.contentsPlaceholder":"sidebarFilesTree.search.placeholder"),className:Pe("h-8 ps-8 typography-meta",L?"pe-16":"pe-8")}),L?n.jsx(Nt,{variant:"chip",size:"xs","aria-pressed":j,onClick:()=>{P(K=>!K),v.current?.focus()},title:o("sidebarFilesTree.search.regexTitle"),"aria-label":o("sidebarFilesTree.search.regexTitle"),className:"absolute inset-e-3 top-3.5 h-5 min-w-0 px-1 font-mono typography-micro",children:".*"}):null,y.trim().length>0?n.jsx("button",{type:"button","aria-label":o("sidebarFilesTree.search.clearAria"),className:Pe("absolute top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",L?"inset-e-10":"inset-e-4"),onClick:()=>{S(""),v.current?.focus()},children:n.jsx(Z,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsxs(Qr,{ref:bs,outerClassName:"h-full min-h-0",className:Pe("px-1.5 py-1.5 [overflow-anchor:none]",(pt===c||C===c)&&"bg-interactive-selection/10"),onDragEnter:ot,onDragOver:ot,onDragLeave:$e,onDrop:Ct,children:[n.jsx("ul",{className:"flex flex-col",children:L&&z.status!=="idle"?n.jsx(B2,{state:z,activeMatchKey:R&&R.path===Te?R.key:null,onOpen:st,onDragStart:Rt,onDragEnd:Ke}):k?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"h-4 w-4 animate-spin"}),o("sidebarFilesTree.state.searching")]}):xt&&w.length===0?n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("mobile.files.search.empty")}):w.length>0?w.map(K=>{const xe=Te===K.path;return n.jsx("li",{"data-file-tree-path":K.path,children:n.jsxs("button",{type:"button",onClick:()=>ft(K),onDoubleClick:()=>ft(K,{pin:!0}),draggable:!0,onDragStart:Xe=>{nl(Xe),pa(null);const lt=K.relativePath||Di(c??"",K.path);!lt||lt==="."||(Xe.dataTransfer.setData($r,lt),Xe.dataTransfer.effectAllowed="copy")},onDragEnd:Xe=>{rl(Xe)&&ft(K)},className:Pe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",_l(xe)),title:K.path,children:[n.jsx(mi,{filePath:K.path,extension:K.extension,className:"size-3.5"}),n.jsx("span",{className:"oc-ui-start-align min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl"},children:`‎${K.relativePath??K.path}‎`})]})},K.path)}):et?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:et}),n.jsxs(Nt,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{it()},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),o("sidebarFilesTree.actions.refreshTitle")]})]}):te&&c?null:n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:o("sidebarFilesTree.state.loading")})}),It?n.jsx("ul",{ref:ms,className:"relative",style:{height:ve.getTotalSize()},onFocus:ht,onBlur:Ot,children:ve.getVirtualItems().map(K=>{const xe=es[K.index];if(!xe)return null;const Xe=xe.kind==="node"?xe.node.path:void 0;return n.jsx("li",{ref:ve.measureElement,"data-index":K.index,"data-tree-row-path":Xe,"data-file-tree-path":xe.kind==="node"&&xe.node.type==="file"?Xe:void 0,className:"absolute inset-x-0 top-0",style:{transform:`translateY(${K.start-vt}px)`},children:ct(xe)},K.key)})}):null]}),pt?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:kt?"loader-4":"folder-received",className:Pe("size-4 flex-shrink-0",kt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:St,children:o(kt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:St})})]}):C?n.jsxs("div",{className:"pointer-events-none absolute inset-s-2 inset-e-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:[n.jsx(Z,{name:"folder-received",className:"size-4 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Se,children:o("sidebarFilesTree.drop.moveTarget",{path:Se})})]}):null]}),At,n.jsx(Qs,{open:!!ye,onOpenChange:K=>!K&&de(null),children:n.jsxs(Zs,{children:[n.jsxs(on,{children:[n.jsxs(nn,{children:[ye==="createFile"&&o("sidebarFilesTree.dialog.createFile.title"),ye==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.title"),ye==="rename"&&o("sidebarFilesTree.dialog.rename.title"),ye==="delete"&&o("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(rn,{children:[ye==="createFile"&&o("sidebarFilesTree.dialog.createFile.description",{path:Ne?.path??o("sidebarFilesTree.dialog.rootFallback")}),ye==="createFolder"&&o("sidebarFilesTree.dialog.createFolder.description",{path:Ne?.path??o("sidebarFilesTree.dialog.rootFallback")}),ye==="rename"&&o("sidebarFilesTree.dialog.rename.description",{name:Ne?.name??""}),ye==="delete"&&o("sidebarFilesTree.dialog.delete.description",{name:Ne?.name??""})]})]}),ye!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(_o,{value:Ge,onChange:K=>ge(K.target.value),placeholder:o(ye==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:K=>{K.key==="Enter"&&Yt()},autoFocus:!0})}),n.jsxs(Pn,{children:[n.jsx(Nt,{variant:"outline",onClick:()=>de(null),disabled:Ae,children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(Nt,{variant:ye==="delete"?"destructive":"default",onClick:()=>{Yt()},disabled:Ae||ye!=="delete"&&!Ge.trim(),children:Ae?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):o(ye==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(Qs,{open:A!==null,onOpenChange:K=>{K||q(null)},children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:o("sidebarFilesTree.dialog.move.title")}),n.jsx(rn,{children:A?o("sidebarFilesTree.dialog.move.description",{name:We,folder:jr(c,A.targetDirectory)}):null})]}),n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[n.jsxs("div",{className:"flex cursor-pointer items-center gap-2 typography-meta text-muted-foreground",onClick:()=>M(!he),children:[n.jsx(b1,{checked:!he,onChange:K=>M(!K),ariaLabel:o("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:o("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:()=>q(null),children:o("sidebarFilesTree.dialog.cancel")}),n.jsx(Nt,{onClick:se,children:o("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function rC(t){return t.runtimeKey}const oC=Xr(()=>as(()=>import("./WalkthroughView-CdIYpttA.js"),__vite__mapDeps([124,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,125,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,84,126,86,115,116,117,118,119,120,127,128,121])).then(t=>({default:t.WalkthroughView}))),iC=Xr(()=>as(()=>import("./DiffView-CaDZ4gTk.js"),__vite__mapDeps([129,1,2,4,5,6,7,8,9,125,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,83,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,84,130,86,115,116,117,118,119,120,126,122,123])).then(t=>({default:t.DiffView}))),aC=Xr(()=>as(()=>import("./FilesView-Csrs_BGv.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,83,132,133,134,135,123,84,136,118,137,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,138,139,140,141,119,120,117,142,143])).then(t=>({default:t.FilesView}))),zh=l.lazy(()=>as(()=>import("./useAppFontEffects-Dm6zEvrf.js").then(t=>t.oS),__vite__mapDeps([3,1,2,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])).then(t=>({default:t.PluginPane}))),Hd=l.lazy(()=>as(()=>import("./GuestSurfacePane-DNg0xBTD.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83])).then(t=>({default:t.GuestSurfacePane}))),Kh={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-e border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-s border-border",vertical:!1}},lC=t=>{const e=Ze.c(12),{mode:s,docking:r}=t,[o,i]=l.useState(null),a=Kh[r.dock],d=Math.max(w1,o??r.size),c=a.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==a.page||e[1]!==c?(u=Pe("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c,a.page),e[0]=a.page,e[1]=c,e[2]=u):u=e[2];let f;e[3]!==a.vertical||e[4]!==d?(f=a.vertical?{height:d}:{width:d},e[3]=a.vertical,e[4]=d,e[5]=f):f=e[5];let p;e[6]!==s?(p=n.jsx(zh,{mode:s,onResize:i}),e[6]=s,e[7]=p):p=e[7];let h;return e[8]!==u||e[9]!==f||e[10]!==p?(h=n.jsx("div",{className:u,style:f,children:p}),e[8]=u,e[9]=f,e[10]=p,e[11]=h):h=e[11],h},Zn=(t,e)=>`${t}\0${e}`,cC=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=Et(),i=le(v=>v.contextEditorTreeWidth),a=le(v=>v.setContextEditorTreeWidth),[d,c]=l.useState(!1),u=l.useRef(0),f=l.useRef(i),p=l.useRef(null),h=l.useRef(null),g=l.useRef(null),b=l.useCallback(v=>{const w=g.current;w&&(w.style.width=`${v}px`,w.style.setProperty("--oc-editor-tree-width",`${v}px`))},[]),x=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}h.current=v.pointerId,c(!0),u.current=v.clientX,f.current=i,p.current=i,v.preventDefault()}},y=v=>{if(!d||h.current!==v.pointerId)return;const w=r==="left"?v.clientX-u.current:u.current-v.clientX,T=ni(v.currentTarget)?-w:w,k=Ia(f.current+T);p.current!==k&&(p.current=k,b(k))},S=v=>{if(h.current!==v.pointerId)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const w=Ia(p.current??i);h.current=null,p.current=null,c(!1),a(w)},m=t?i:0;return n.jsxs("div",{ref:g,className:Pe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&(r==="left"?"me-auto":"ms-auto")),style:{width:`${d?p.current??m:m}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${d?p.current??i:i}px`,overflowX:"clip",transitionProperty:d?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!s&&n.jsx("div",{"aria-hidden":"true",className:Pe("pointer-events-none absolute inset-y-0 z-20 w-px bg-border",r==="left"?"inset-e-0":"inset-s-0")}),t&&!s&&n.jsx("div",{className:Pe("absolute top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",r==="left"?"inset-e-0":"inset-s-0",d&&"bg-[var(--interactive-border)]"),onPointerDown:x,onPointerMove:y,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:Pe("relative z-10 h-full shrink-0 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-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(sC,{visible:t&&e})})]})},Bn=t=>{const e=Ze.c(18),{zone:s,isOpen:r,interactive:o,hidden:i,directoryKey:a,className:d,children:c}=t,u=le(uC);let f;e[0]!==u||e[1]!==a||e[2]!==r||e[3]!==s?(f=S=>{nh(S,r,()=>{a&&u(a,s)},S.currentTarget.closest("[data-context-zone]"))},e[0]=u,e[1]=a,e[2]=r,e[3]=s,e[4]=f):f=e[4];const p=f,h=!r||i;let g;e[5]!==c||e[6]!==h?(g=n.jsx(cp,{paused:h,children:c}),e[5]=c,e[6]=h,e[7]=g):g=e[7];let b;e[8]!==o||e[9]!==g?(b=n.jsx(ip.Provider,{value:!0,children:n.jsx(Zb.Provider,{value:o,children:g})}),e[8]=o,e[9]=g,e[10]=b):b=e[10];let x;e[11]!==d||e[12]!==p||e[13]!==b?(x=n.jsx("div",{className:d,onKeyDownCapture:p,children:b}),e[11]=d,e[12]=p,e[13]=b,e[14]=x):x=e[14];let y;return e[15]!==x||e[16]!==s?(y=n.jsx(D2,{zone:s,children:x}),e[15]=x,e[16]=s,e[17]=y):y=e[17],y},dC=()=>{const{t}=Et(),e=Nn()??"",s=l.useMemo(()=>e?Ds(e):"",[e]),r=le(U=>s?U.contextPanelByDirectory[s]:void 0),o=Yr(),i=o?.kind==="preparing",a=o?.kind==="ready"?o.directory:null,d=fi(o,e)??"",c=le(U=>U.contextSurfaceZones),u=le(U=>U.contextPanelByDirectory),f=le(U=>U.closeContextPanelTab),p=le(U=>U.closeContextFile),h=le(U=>U.openContextPanelTab),g=le(U=>U.openAgentBrowserTab),b=le(U=>U.openContextFile),x=le(U=>U.contextEditorTreeVisible),y=le(U=>U.contextEditorVisible),S=le(U=>U.fileTreeSide),m=Vs(U=>U.setSelectedPath),v=Hr(U=>U.headerSlot),w=l.useMemo(()=>r?.tabs??[],[r?.tabs]),T=Oa(U=>U.chatCovered),k=l.useMemo(()=>{const U=ae=>{const Re=r?Ro(r,c,ae):null,W=ae==="bottom"&&T;return{activeTab:Re,isOpen:!!(r&&oi(r,ae).isOpen&&Re)&&!W}};return{left:U("left"),right:U("right"),bottom:U("bottom")}},[T,r,c]),I={left:Co(k.left.isOpen),right:Co(k.right.isOpen),bottom:Co(k.bottom.isOpen)},B=U=>!I[U],O={left:Or(k.left.isOpen),right:Or(k.right.isOpen),bottom:Or(k.bottom.isOpen)},F={left:xo(k.left.isOpen,O.left,k.left.activeTab?.mode),right:xo(k.right.isOpen,O.right,k.right.activeTab?.mode),bottom:xo(k.bottom.isOpen,O.bottom,k.bottom.activeTab?.mode)},j=U=>{const ae=Ao(c,U);return{zone:ae,...k[ae]}},P=j("file"),L=j("chat"),z=j("browser"),H=j("diff"),R=j("terminal"),G=j("walkthrough"),[_,$]=l.useState([]),E=l.useCallback((U,ae)=>{$(Re=>Wg(Re,Zn(U,ae)))},[]),D=le(U=>U.liveBrowserTabLimit);l.useEffect(()=>uk((U,ae)=>{const Re=ae.directory?Ds(ae.directory):s;if(!Re)return null;const W=g(Re,U,ae.sessionId);return W&&E(Re,W),W}),[s,g,E]),l.useEffect(()=>fk((U,ae)=>le.getState().contextPanelByDirectory[U]?.tabs?.some(W=>W.id===ae&&W.mode==="browser")?(f(U,ae),!0):!1),[f]),l.useEffect(()=>En(U=>{if(U.type!=="file-open-request")return;const ae=U.directory??e;ae&&b(ae,U.path)}),[e,b]),l.useEffect(()=>En(U=>{if(U.type!=="plan-open-request")return;const ae=U.directory??e,Re=Gb(ae,U.projectId);!ae||!Re||le.getState().openProjectKnowledgePlan(ae,y1(Re),U.planId)}),[e]);const C=z.activeTab?.mode==="browser"?z.activeTab.id:null;l.useEffect(()=>{dk(s,C)},[s,C]);const N=P.activeTab;l.useEffect(()=>{if(!d||N?.mode!=="file"||!N.targetPath)return;const U=$s(N.targetPath)===$s(d);m(Ds(d),N.targetPath,{allowOutsideRoot:!o&&U})},[d,o,N,m]);const A=l.useMemo(()=>w.some(U=>U.mode==="file"&&U.targetPath),[w]),q=l.useMemo(()=>w.some(U=>U.mode==="file"),[w]),ee=A&&(y||!x),Q=P.activeTab?.mode==="file",he=l.useCallback(U=>{s&&p(s,U)},[p,s]),M=L.isOpen&&L.activeTab?.mode==="chat"?L.activeTab:null,V=M?Pi(M.dedupeKey):null,ie=l.useMemo(()=>(M?.targetDirectory?Ds(M.targetDirectory):"")||s||null,[M?.targetDirectory,s]),ce=l.useMemo(()=>V?{sessionId:V,directory:ie}:null,[V,ie]);l.useEffect(()=>{if(!ie||!V||typeof window>"u")return;const U=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ea(ie,V,!1);return}dp(V),ea(ie,V,!0)};U();const ae=window.setInterval(U,1e4);return window.addEventListener("focus",U),window.addEventListener("blur",U),document.addEventListener("visibilitychange",U),()=>{window.clearInterval(ae),window.removeEventListener("focus",U),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",U),ea(ie,V,!1)}},[ie,V]);const ne=H.activeTab,je=l.useCallback(U=>{!s||ne?.mode!=="diff"||h(s,{mode:"diff",targetPath:ne.targetPath,targetDirectory:ne.targetDirectory,stagedDiff:U==="staged",diffScope:U})},[ne,s,h]),Ee=z.isOpen&&z.activeTab?.mode==="browser"?z.activeTab.id:null;l.useEffect(()=>{Ee&&s&&E(s,Ee)},[s,Ee,E]);const{loadedBrowserTabs:we,sleepingBrowserTabs:Me}=l.useMemo(()=>{const U=new Set(_),ae=new Set;for(const[de,Ne]of Object.entries(u))for(const Je of Ne.tabs)Je.mode==="browser"&&Je.ownerSessionId===null&&ae.add(Zn(de,Je.id));const Re=Hg(_,ae,D),W=[],ye=[];for(const[de,Ne]of Object.entries(u)){const Je=de===s;for(const Ge of Ne.tabs){if(Ge.mode!=="browser")continue;const ge=Zn(de,Ge.id),Ae=Ge.ownerSessionId===null,Ye=Je&&Ge.id===Ee||(Ae?Re.has(ge):U.has(ge));if(!Ye&&!Je&&Ae)continue;const nt={directory:de,id:Ge.id,targetPath:Ge.targetPath,ownerSessionId:Ge.ownerSessionId};(Ye?W:ye).push(nt)}}return W.sort((de,Ne)=>Zn(de.directory,de.id)<Zn(Ne.directory,Ne.id)?-1:1),{loadedBrowserTabs:W,sleepingBrowserTabs:ye}},[u,s,D,_,Ee]);l.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const U=Me.map(ae=>ck({tabId:ae.id,directory:ae.directory,ownerSessionId:ae.ownerSessionId,describe:()=>({title:"",url:ae.targetPath??""}),wake:()=>E(ae.directory,ae.id)}));return()=>U.forEach(ae=>ae())},[Me,E]);const fe=l.useMemo(()=>w.filter(U=>U.mode==="diff"),[w]),be=l.useMemo(()=>w.find(U=>U.mode==="terminal")??null,[w]),ke=l.useMemo(()=>w.find(U=>U.mode==="walkthrough")??null,[w]),Ie=l.useMemo(()=>w.filter(U=>dr(U.mode)),[w]),Te=Dl(U=>U.guests),Y=l.useMemo(()=>new Set(Te.filter(x1).map(U=>U.id)),[Te]),ue=l.useMemo(()=>{const U=new Map;for(const ae of Te){const Re=S1(ae);Re&&U.set(ae.id,Re)}return U},[Te]),me=R.zone,re=l.useCallback(U=>{const ae=Ql({mode:"terminal",label:t("layout.mainTab.terminal"),from:me},U);return{finish:()=>ae.finish(s),cancel:ae.cancel}},[s,t,me]),pe=(U,ae)=>ae?v[U]:null;return n.jsxs(n.Fragment,{children:[q?n.jsxs(Bn,{zone:P.zone,interactive:F[P.zone],isOpen:P.isOpen,hidden:B(P.zone),directoryKey:s,className:Pe("absolute inset-0 flex",S==="left"&&"flex-row-reverse",Q?"flex":"hidden"),children:[i?n.jsx("div",{className:"h-full min-w-0 flex-1",children:n.jsx(So,{})}):A||!x?n.jsx("div",{className:Pe("h-full min-w-0 flex-1",A&&!ee&&"hidden"),children:A?n.jsx(l.Suspense,{fallback:null,children:n.jsx(aC,{mode:"editor-only",visible:!B(P.zone)&&Q&&ee,onCloseFile:he})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx(Z,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),n.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,i?null:n.jsx(cC,{visible:x,active:P.isOpen&&Q,fill:!ee,side:S})]}):null,M&&V&&ce?n.jsx(Bn,{zone:L.zone,interactive:F[L.zone],isOpen:L.isOpen,hidden:B(L.zone),directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:V}),className:"h-full",children:n.jsx(Sf,{pinnedSession:ce,readOnly:M.readOnly})})},M.id):null,we.map(U=>{const ae=U.directory===s&&z.activeTab?.id===U.id,Re=U.directory===s?a??U.directory:U.directory;return n.jsx(Bn,{zone:z.zone,interactive:F[z.zone],isOpen:z.isOpen,hidden:B(z.zone),directoryKey:s,className:Pe("absolute inset-0",!ae&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!ae||void 0,children:n.jsx(cp,{paused:!ae,children:U.directory===s&&i?n.jsx(So,{}):n.jsx(C2,{initialUrl:U.targetPath??"",directory:U.directory,siteDirectory:Re,tabID:U.id,ownerSessionId:U.ownerSessionId,visible:ae&&z.isOpen},Re)})})},Zn(U.directory,U.id))}),fe.map(U=>{const ae=H.activeTab?.id===U.id;return n.jsx(Bn,{zone:H.zone,interactive:F[H.zone],isOpen:H.isOpen,hidden:B(H.zone),directoryKey:s,className:Pe("absolute inset-0",!ae&&"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:pe(H.zone,ae),children:i&&!U.targetDirectory?n.jsx(So,{}):n.jsx(iC,{directory:U.targetDirectory??a,visible:H.isOpen&&ae,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:U.diffScope??(U.stagedDiff?"staged":null),onDiffScopeChange:je,targetFilePath:U.targetPath,flushContent:!0})})})},U.id)}),be?n.jsx(Bn,{zone:R.zone,interactive:F[R.zone],isOpen:R.isOpen,hidden:B(R.zone),directoryKey:s,className:Pe("absolute inset-0",R.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(rr,{value:pe(R.zone,R.activeTab?.mode==="terminal"),children:n.jsx(qb.Provider,{value:re,children:n.jsx(Yb,{visible:R.isOpen&&R.activeTab?.mode==="terminal",directory:be.targetDirectory,onLastTabClosed:()=>{s&&f(s,be.id)}})})})}):null,ke?n.jsx(Bn,{zone:G.zone,interactive:F[G.zone],isOpen:G.isOpen,hidden:B(G.zone),directoryKey:s,className:Pe("absolute inset-0",G.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(rr,{value:pe(G.zone,G.activeTab?.mode==="walkthrough"),children:n.jsx(oC,{directory:ke.targetDirectory??e,visible:G.isOpen&&G.activeTab?.mode==="walkthrough"})})})}):null,Ie.map(U=>{if(!dr(U.mode))return null;const ae=j(U.mode),Re=No(U.mode),W=Y.has(Re),ye=ue.get(Re),de=ae.activeTab?.id===U.id,Ne=de&&ae.isOpen;return W&&!ye&&!Ne?null:n.jsx(Bn,{zone:ae.zone,interactive:F[ae.zone],isOpen:ae.isOpen,hidden:B(ae.zone),directoryKey:s,className:Pe("absolute inset-0",de?"block":"hidden"),children:n.jsx(l.Suspense,{fallback:null,children:W?ye?n.jsxs("div",{className:Pe("flex h-full",Kh[ye.dock].container),children:[n.jsx(lC,{mode:U.mode,docking:ye}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ne?n.jsx(Hd,{mode:U.mode}):null})]}):n.jsx(Hd,{mode:U.mode}):n.jsx(zh,{mode:U.mode})})},U.id)})]})};function uC(t){return t.closeContextZone}const fC={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},pC=()=>{const t=Ze.c(20),{t:e}=Et(),s=gn(hC),r=gn(mC),o=l.useRef(null),[i,a]=l.useState(!1);let d,c;t[0]!==s?(d=()=>{if(!s){a(!1);return}const S=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(S)},c=[s],t[0]=s,t[1]=d,t[2]=c):(d=t[1],c=t[2]),l.useEffect(d,c);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const S=m=>{const v=o.current;v&&(v.style.transform=`translate(${m.clientX+12}px, ${m.clientY+12}px)`)};return window.addEventListener("pointermove",S),()=>window.removeEventListener("pointermove",S)},f=[s],t[3]=s,t[4]=u,t[5]=f):(u=t[4],f=t[5]),l.useEffect(u,f),!s)return null;const p=i?"opacity-100":"opacity-0";let h;t[6]!==p?(h=Pe("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",p),t[6]=p,t[7]=h):h=t[7];let g;t[8]!==h?(g=n.jsx("div",{className:h}),t[8]=h,t[9]=g):g=t[9];let b;t[10]!==s.frames||t[11]!==r||t[12]!==e?(b=Xu.map(S=>{const m=s.frames[S];if(m.width<=0||m.height<=0)return null;const v=r===S;return n.jsx("div",{className:Pe("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",v?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:m.left,top:m.top,width:m.width,height:m.height},children:n.jsx("span",{className:"typography-ui-label",children:e(fC[S])})},S)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let x;t[14]!==s.label?(x=n.jsx("div",{ref:o,className:"absolute left-0 top-0 rounded-md border border-border bg-background px-2 py-1 typography-meta text-foreground shadow-sm",children:s.label}),t[14]=s.label,t[15]=x):x=t[15];let y;return t[16]!==g||t[17]!==b||t[18]!==x?(y=gl.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,b,x]}),document.body),t[16]=g,t[17]=b,t[18]=x,t[19]=y):y=t[19],y};function hC(t){return t.drag}function mC(t){return t.hovered}const Ud=400,gC=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=Ud)return{collapseSidebar:!1,displace:null};const a=r!==null;if(a&&(i+=r),i>=Ud)return{collapseSidebar:a,displace:null};const d=o==="left"?"right":"left";return{collapseSidebar:a,displace:(d==="left"?e:s)>0?d:null}},bC=()=>{const t=Ze.c(5),e=Nn();let s;t[0]!==e?(s=e?Ds(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=l.useRef(null);let i,a;return t[2]!==r?(i=()=>{if(!r)return;const d=y=>{const S=y.contextPanelByDirectory[r];return{left:Dr(S,y.contextSurfaceZones,"left"),right:Dr(S,y.contextSurfaceZones,"right")}},c=(y,S,m)=>{const v=y.contextPanelByDirectory[r],w=m&&v?Ro(v,y.contextSurfaceZones,S):null;return w?v?.widthByMode[w.mode]??Ca(w.mode):0};let u=null,f=!1,p=d(le.getState());const h=y=>{f=!0,le.getState().setSidebarOpen(y),f=!1},g=o.current;g&&!p[g]&&(o.current=null,le.getState().isSidebarOpen||h(!0));const b=(y,S,m)=>{const v=document.querySelector("[data-workspace-row]")?.clientWidth;if(!v)return;const w=gC({rowWidth:v,leftWidth:c(y,"left",m.left),rightWidth:c(y,"right",m.right),sidebarWidth:y.isSidebarOpen?y.sidebarWidth:null,opening:S});if(w.displace){const T=oi(y.contextPanelByDirectory[r],w.displace).activeTabId;T&&(u={side:w.displace,by:S,tabId:T})}w.collapseSidebar&&(o.current=S,h(!1)),w.displace&&y.closeContextZone(r,w.displace)},x=y=>{if(u?.side===y){o.current===y&&(o.current=u.by);return}const S=u?.by===y?u:null;S&&(u=null),o.current===y&&(S?o.current=S.side:(o.current=null,le.getState().isSidebarOpen||h(!0))),S&&le.getState().setActiveContextPanelTab(r,S.tabId)};return le.subscribe((y,S)=>{y.isSidebarOpen!==S.isSidebarOpen&&!f&&(o.current=null);const m=d(y),v=p;p=m;const w=["left","right"],T=w.filter(I=>m[I]&&!v[I]),k=w.filter(I=>!m[I]&&v[I]);for(const I of k){const B=I==="left"?"right":"left";T.includes(B)&&(o.current===I&&(o.current=B),u?.by===I&&(u=null))}for(const I of k)x(I);for(const I of T)b(y,I,m)})},a=[r],t[2]=r,t[3]=i,t[4]=a):(i=t[3],a=t[4]),l.useEffect(i,a),null},yC=t=>{const e=Ze.c(53),{open:s,onOpenChange:r}=t,{t:o}=Et(),i=le(xC),a=le(SC),d=le(wC),c=le(vC),u=le(jC),f=Fl();let p;e[0]!==i||e[1]!==f?(p=Ju(i,f),e[0]=i,e[1]=f,e[2]=p):p=e[2];const h=p,g=d.length===0;let b;if(e[3]!==d||e[4]!==h){let _;e[6]!==d?(_=$=>d.includes($.id),e[6]=d,e[7]=_):_=e[7],b=h.every(_),e[3]=d,e[4]=h,e[5]=b}else b=e[5];const x=b,y=l.useRef(!1);let S;if(e[8]!==d||e[9]!==h||e[10]!==o){let _;e[12]!==d||e[13]!==o?(_=$=>({id:$.id,label:$.label??o($.labelKey),visible:!d.includes($.id)}),e[12]=d,e[13]=o,e[14]=_):_=e[14],S=h.map(_),e[8]=d,e[9]=h,e[10]=o,e[11]=S}else S=e[11];const m=S;let v;e[15]!==i||e[16]!==a?(v=_=>{const $=new Set(_);a([..._,...i.filter(E=>!$.has(E))])},e[15]=i,e[16]=a,e[17]=v):v=e[17];const w=v;let T;e[18]!==r?(T=(_,$)=>{if(!_&&$.reason==="escape-key"&&y.current){$.cancel(),$.allowPropagation();return}y.current=!1,r(_)},e[18]=r,e[19]=T):T=e[19];let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=_=>{y.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(_.key)&&_.preventBaseUIHandler()},e[20]=k):k=e[20];let I;e[21]!==o?(I=o("contextRail.configure.dialogTitle"),e[21]=o,e[22]=I):I=e[22];let B;e[23]!==I?(B=n.jsx(nn,{children:I}),e[23]=I,e[24]=B):B=e[24];let O;e[25]!==o?(O=o("contextRail.configure.dialogDescription"),e[25]=o,e[26]=O):O=e[26];let F;e[27]!==O?(F=n.jsx(rn,{children:O}),e[27]=O,e[28]=F):F=e[28];let j;e[29]!==F||e[30]!==B?(j=n.jsxs(on,{children:[B,F]}),e[29]=F,e[30]=B,e[31]=j):j=e[31];let P;e[32]!==o?(P=o("contextRail.configure.dragInstructions"),e[32]=o,e[33]=P):P=e[33];let L;e[34]===Symbol.for("react.memo_cache_sentinel")?(L=_=>{y.current=_},e[34]=L):L=e[34];let z;e[35]!==w||e[36]!==m||e[37]!==c||e[38]!==P?(z=n.jsx(Qb,{items:m,onVisibleChange:c,onReorder:w,settingsItemPrefix:"layout.context-rail.surface.",dragInstructions:P,onDraggingChange:L}),e[35]=w,e[36]=m,e[37]=c,e[38]=P,e[39]=z):z=e[39];let H;e[40]!==g||e[41]!==x||e[42]!==u||e[43]!==o?(H=g?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[x?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(Nt,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[40]=g,e[41]=x,e[42]=u,e[43]=o,e[44]=H):H=e[44];let R;e[45]!==j||e[46]!==z||e[47]!==H?(R=n.jsxs(Zs,{className:"max-w-md",onKeyDown:k,children:[j,z,H]}),e[45]=j,e[46]=z,e[47]=H,e[48]=R):R=e[48];let G;return e[49]!==s||e[50]!==R||e[51]!==T?(G=n.jsx(Qs,{open:s,onOpenChange:T,children:R}),e[49]=s,e[50]=R,e[51]=T,e[52]=G):G=e[52],G};function xC(t){return t.contextRailOrder}function SC(t){return t.setContextRailOrder}function wC(t){return t.contextRailHiddenSurfaces}function vC(t){return t.setContextRailSurfaceVisible}function jC(t){return t.setContextRailHiddenSurfaces}const kC=t=>{const e=np(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},CC=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Wh=()=>{const t=Ze.c(4),e=mt(EC),s=mt(TC)??void 0,r=j1(e??"",s,kC,CC),{context:o}=k1(e,s),i=o>0?o:C1;let a;return t[0]!==r||t[1]!==i||t[2]!==e?(a={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=a):a=t[3],a},Vd=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),cn=18,ol=2,il=(cn-ol)/2,Gd=2*Math.PI*il,IC=t=>{const e=Ze.c(8),{className:s}=t,{fill:r,limit:o}=Wh(),i=r?.state==="measured"?Math.min(100,r.totalTokens/o*100):0;let a;e[0]!==s?(a=Pe("shrink-0",s),e[0]=s,e[1]=a):a=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("circle",{cx:cn/2,cy:cn/2,r:il,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:ol}),e[2]=d):d=e[2];let c;e[3]!==i?(c=i>0?n.jsx("circle",{cx:cn/2,cy:cn/2,r:il,fill:"none",stroke:"currentColor",strokeWidth:ol,strokeLinecap:"round",strokeDasharray:Gd,strokeDashoffset:Gd*(1-i/100),transform:`rotate(-90 ${cn/2} ${cn/2})`}):null,e[3]=i,e[4]=c):c=e[4];let u;return e[5]!==a||e[6]!==c?(u=n.jsxs("svg",{viewBox:`0 0 ${cn} ${cn}`,className:a,"aria-hidden":"true",children:[d,c]}),e[5]=a,e[6]=c,e[7]=u):u=e[7],u},PC=()=>{const t=Ze.c(16),{t:e}=Et(),{sessionId:s,fill:r,limit:o}=Wh(),{totalCost:i}=v1(s);if(!s||!r)return null;let a;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(a=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Vd(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=a):a=t[3];let d;t[4]!==o||t[5]!==e?(d=e("contextUsage.tooltip.contextLimit",{tokens:Vd(o)}),t[4]=o,t[5]=e,t[6]=d):d=t[6];let c;t[7]!==e||t[8]!==i?(c=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:Lp(i)})]:[],t[7]=e,t[8]=i,t[9]=c):c=t[9];let u;t[10]!==a||t[11]!==d||t[12]!==c?(u=[a,d,...c],t[10]=a,t[11]=d,t[12]=c,t[13]=u):u=t[13];const f=u;let p;return t[14]!==f?(p=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(DC)}),t[14]=f,t[15]=p):p=t[15],p};function EC(t){return t.currentSessionId}function TC(t){return t.currentSessionDirectory}function DC(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const Hh=150,RC=500,NC=[],MC=t=>t>99?"99+":String(t),AC=t=>{const e=Ze.c(62),{surface:s,isActive:r,showActivityDot:o,label:i,description:a,badgeCount:d,badgeAriaLabel:c,badgeDescription:u,orderNumber:f,showOrderNumber:p,onSelect:h}=t;let g;e[0]!==s.id?(g={id:s.id},e[0]=s.id,e[1]=g):g=e[1];const{attributes:b,listeners:x,setNodeRef:y,transform:S,transition:m,isDragging:v}=ji(g);let w;e[2]!==d?(w=d!=null&&d>0?MC(d):null,e[2]=d,e[3]=w):w=e[3];const T=w;let k;e[4]!==S?(k=ki.Translate.toString(S),e[4]=S,e[5]=k):k=e[5];let I;e[6]!==k||e[7]!==m?(I={transform:k,transition:m},e[6]=k,e[7]=m,e[8]=I):I=e[8];const B=v&&"z-10 opacity-70";let O;e[9]!==B?(O=Pe("relative",B),e[9]=B,e[10]=O):O=e[10];let F;e[11]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx("div",{}),e[11]=F):F=e[11];let j;e[12]!==h||e[13]!==s?(j=()=>h(s),e[12]=h,e[13]=s,e[14]=j):j=e[14];const P=c??i,L=s.id,z=r?"text-primary":"text-muted-foreground hover:text-foreground";let H;e[15]!==z?(H=Pe("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",z),e[15]=z,e[16]=H):H=e[16];let R;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(R=s.id==="diff"?n.jsx(yf,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(IC,{className:"h-[18px] w-[18px]"}):n.jsx(yr,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[17]=s.icon,e[18]=s.iconSrc,e[19]=s.id,e[20]=R):R=e[20];let G;e[21]!==T||e[22]!==f||e[23]!==o||e[24]!==p?(G=p&&f!=null?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-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:f===10?"0":f}):T?n.jsx("span",{"aria-hidden":"true",className:"absolute -inset-e-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:T}):o?n.jsx("span",{"aria-hidden":"true",className:"absolute inset-e-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[21]=T,e[22]=f,e[23]=o,e[24]=p,e[25]=G):G=e[25];let _;e[26]!==b||e[27]!==r||e[28]!==x||e[29]!==s.id||e[30]!==H||e[31]!==R||e[32]!==G||e[33]!==j||e[34]!==P?(_=n.jsx(Ht,{asChild:!0,children:n.jsxs("button",{type:"button",...b,...x,onClick:j,"aria-label":P,"aria-pressed":r,"data-context-surface":L,className:H,children:[R,G]})}),e[26]=b,e[27]=r,e[28]=x,e[29]=s.id,e[30]=H,e[31]=R,e[32]=G,e[33]=j,e[34]=P,e[35]=_):_=e[35];let $;e[36]!==i?($=n.jsx("span",{children:i}),e[36]=i,e[37]=$):$=e[37];let E;e[38]!==a?(E=n.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),e[38]=a,e[39]=E):E=e[39];let D;e[40]!==u?(D=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[40]=u,e[41]=D):D=e[41];let C;e[42]!==s.id?(C=s.id==="context"?n.jsx(PC,{}):null,e[42]=s.id,e[43]=C):C=e[43];let N;e[44]!==$||e[45]!==E||e[46]!==D||e[47]!==C?(N=n.jsx(Kt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[$,E,D,C]})}),e[44]=$,e[45]=E,e[46]=D,e[47]=C,e[48]=N):N=e[48];let A;e[49]!==_||e[50]!==N?(A=n.jsx(zl,{render:F,children:n.jsxs(Ut,{delayDuration:Hh,children:[_,N]})}),e[49]=_,e[50]=N,e[51]=A):A=e[51];let q;e[52]!==s.mode?(q=n.jsx(Ll,{children:n.jsx(bf,{mode:s.mode})}),e[52]=s.mode,e[53]=q):q=e[53];let ee;e[54]!==A||e[55]!==q?(ee=n.jsxs(Zr,{children:[A,q]}),e[54]=A,e[55]=q,e[56]=ee):ee=e[56];let Q;return e[57]!==y||e[58]!==ee||e[59]!==I||e[60]!==O?(Q=n.jsx("div",{ref:y,style:I,className:O,children:ee}),e[57]=y,e[58]=ee,e[59]=I,e[60]=O,e[61]=Q):Q=e[61],Q};function OC(t){return t==="gitlab"?"gitlab":t==="none"?"ticket-2":"github"}const BC=()=>{const t=Ze.c(104),{t:e}=Et(),s=Nn();let r;t[0]!==s?(r=s?Ds(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Ge=>o?Ge.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const a=le(i),d=le(FC),c=le(_C),u=le(LC),f=le($C),p=le(zC),h=le(KC),g=le(WC),b=le(HC),x=Vf(Gf)?.hasChecked??!1,y=kn(VC),S=I1(o||null),m=S==="none"?null:S,{screenWidth:v}=Rn(),w=Yr(),T=o||null;let k;t[4]!==w||t[5]!==T?(k=fi(w,T),t[4]=w,t[5]=T,t[6]=k):k=t[6];const I=hi(k);let B;t[7]!==b?(B=P1("switch_context_surface",b),t[7]=b,t[8]=B):B=t[8];const O=B,[F,j]=l.useState(!1);let P,L;t[9]!==O?(P=()=>{const Ge=new Set;let ge=null,Ae=!1;const Ye=GC,nt=()=>{qc(O,Ge)?!Ae&&ge===null&&(ge=setTimeout(()=>j(!0),RC)):(Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),j(!1))},oe=gt=>{if(Ge.add(gt.key.toLowerCase()),Ye(gt.key)&&qc(O,Ge)){Ae=!0,ge!==null&&(clearTimeout(ge),ge=null),j(!1);return}nt()},tt=gt=>{Ge.delete(gt.key.toLowerCase()),nt()},Ue=()=>{Ge.clear(),Ae=!1,ge!==null&&(clearTimeout(ge),ge=null),j(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",tt,!0),window.addEventListener("blur",Ue),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",tt,!0),window.removeEventListener("blur",Ue),ge!==null&&clearTimeout(ge)}},L=[O],t[9]=O,t[10]=P,t[11]=L):(P=t[10],L=t[11]),l.useEffect(P,L);let z;t[12]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},t[12]=z):z=t[12];let H;t[13]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{delay:200,tolerance:6}},t[13]=H):H=t[13];const R=yi(mn(Si,z),mn(xi,H)),G=Fl(),_=Gc(qC),$=Gc(YC),E=a?.tabs??NC;let D;t[14]!==g||t[15]!==a?(D=bl(a,g),t[14]=g,t[15]=a,t[16]=D):D=t[16];const C=D,N=I?.files.length??0;let A;if(t[17]!==u||t[18]!==c||t[19]!==G||t[20]!==S||t[21]!==v||t[22]!==y||t[23]!==E){let Ge;t[25]!==S?(Ge=ge=>ge.id==="pr"?{...ge,icon:OC(S)}:ge,t[25]=S,t[26]=Ge):Ge=t[26],A=Ug({railOrder:c,hiddenSurfaces:u,isVSCode:Dn(),screenWidth:v,tabs:E,sourceControlConnected:y,extras:G}).map(Ge),t[17]=u,t[18]=c,t[19]=G,t[20]=S,t[21]=v,t[22]=y,t[23]=E,t[24]=A}else A=t[24];const q=A;let ee;t[27]!==E?(ee=E.some(ZC),t[27]=E,t[28]=ee):ee=t[28];const Q=ee;let he,M;t[29]!==h||t[30]!==g||t[31]!==o||t[32]!==x||t[33]!==Q||t[34]!==C||t[35]!==y?(he=()=>{!o||!x||y||Q||!C.has("pr")||h(o,Ao(g,"pr"))},M=[h,g,o,x,Q,C,y],t[29]=h,t[30]=g,t[31]=o,t[32]=x,t[33]=Q,t[34]=C,t[35]=y,t[36]=he,t[37]=M):(he=t[36],M=t[37]),l.useEffect(he,M);const[V,ie]=l.useState(!1),ce=l.useRef(null),ne=l.useRef(null);let je;t[38]!==m||t[39]!==q||t[40]!==e?(je=Ge=>{const ge=q.find(Ye=>Ye.id===Ge.active.id),Ae=ce.current?.getBoundingClientRect().left;!ge||Ae===void 0||(ne.current?.cancel(),ne.current=Ql({mode:ge.mode,label:ge.label??e(pn(ge.labelKey,m)),from:Ao(le.getState().contextSurfaceZones,ge.mode)},Ye=>Ye.x<Ae-16))},t[38]=m,t[39]=q,t[40]=e,t[41]=je):je=t[41];const Ee=je;let we;t[42]===Symbol.for("react.memo_cache_sentinel")?(we=()=>{ne.current?.cancel(),ne.current=null},t[42]=we):we=t[42];const Me=we;let fe,be;t[43]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>()=>ne.current?.cancel(),be=[],t[43]=fe,t[44]=be):(fe=t[43],be=t[44]),l.useEffect(fe,be);let ke;t[45]!==o||t[46]!==G||t[47]!==f?(ke=Ge=>{const ge=ne.current;if(ne.current=null,ge?.finish(o))return;const{active:Ae,over:Ye}=Ge;if(!Ye||Ae.id===Ye.id)return;const nt=Ju(le.getState().contextRailOrder,G).map(QC),oe=nt.indexOf(Ae.id),tt=nt.indexOf(Ye.id);oe===-1||tt===-1||f($p(nt,oe,tt))},t[45]=o,t[46]=G,t[47]=f,t[48]=ke):ke=t[48];const Ie=ke;if(!o)return null;let Te;t[49]!==e?(Te=e("contextRail.aria.rail"),t[49]=e,t[50]=Te):Te=t[50];let Y;t[51]!==q?(Y=q.map(XC),t[51]=q,t[52]=Y):Y=t[52];let ue;if(t[53]!==m||t[54]!==N||t[55]!==$||t[56]!==o||t[57]!==_||t[58]!==p||t[59]!==F||t[60]!==C||t[61]!==q||t[62]!==e||t[63]!==d){let Ge;t[65]!==m||t[66]!==N||t[67]!==$||t[68]!==o||t[69]!==_||t[70]!==p||t[71]!==F||t[72]!==C||t[73]!==e||t[74]!==d?(Ge=(ge,Ae)=>{const Ye=ge.label??e(pn(ge.labelKey,m)),nt=ge.id==="git"&&!d?N:0,oe=dr(ge.mode)&&!C.has(ge.mode)?_[No(ge.mode)]??0:0,tt=nt>0?nt:oe>0?oe:null,Ue=tt!==null&&nt===0;return n.jsx(AC,{surface:ge,isActive:C.has(ge.mode),showActivityDot:!1,label:Ye,description:e(pn(ge.descriptionKey,m)),badgeCount:tt,badgeAriaLabel:tt!==null?e(Ue?tt===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":tt===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Ye,count:tt}):null,badgeDescription:tt!==null?e(Ue?tt===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":tt===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:tt}):null,orderNumber:Ae+1,showOrderNumber:F,onSelect:gt=>{dr(gt.mode)&&$(No(gt.mode)),p(o,gt.mode)}},ge.id)},t[65]=m,t[66]=N,t[67]=$,t[68]=o,t[69]=_,t[70]=p,t[71]=F,t[72]=C,t[73]=e,t[74]=d,t[75]=Ge):Ge=t[75],ue=q.map(Ge),t[53]=m,t[54]=N,t[55]=$,t[56]=o,t[57]=_,t[58]=p,t[59]=F,t[60]=C,t[61]=q,t[62]=e,t[63]=d,t[64]=ue}else ue=t[64];let me;t[76]!==Y||t[77]!==ue?(me=n.jsx(Gl,{items:Y,strategy:zp,children:ue}),t[76]=Y,t[77]=ue,t[78]=me):me=t[78];let re;t[79]!==Ie||t[80]!==Ee||t[81]!==R||t[82]!==me?(re=n.jsx(wi,{sensors:R,collisionDetection:vi,onDragStart:Ee,onDragCancel:Me,onDragEnd:Ie,children:me}),t[79]=Ie,t[80]=Ee,t[81]=R,t[82]=me,t[83]=re):re=t[83];let pe;t[84]!==e?(pe=e("contextRail.configure.open"),t[84]=e,t[85]=pe):pe=t[85];let U;t[86]===Symbol.for("react.memo_cache_sentinel")?(U=()=>ie(!0),t[86]=U):U=t[86];let ae;t[87]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Z,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[87]=ae):ae=t[87];let Re;t[88]!==pe?(Re=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":pe,onClick:U,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ae})}),t[88]=pe,t[89]=Re):Re=t[89];let W;t[90]!==e?(W=e("contextRail.configure.open"),t[90]=e,t[91]=W):W=t[91];let ye;t[92]!==W?(ye=n.jsx(Kt,{side:"left",sideOffset:8,children:W}),t[92]=W,t[93]=ye):ye=t[93];let de;t[94]!==Re||t[95]!==ye?(de=n.jsxs(Ut,{delayDuration:Hh,children:[Re,ye]}),t[94]=Re,t[95]=ye,t[96]=de):de=t[96];let Ne;t[97]!==V?(Ne=n.jsx(yC,{open:V,onOpenChange:ie}),t[97]=V,t[98]=Ne):Ne=t[98];let Je;return t[99]!==Te||t[100]!==re||t[101]!==de||t[102]!==Ne?(Je=n.jsxs("nav",{ref:ce,"aria-label":Te,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[re,de,Ne]}),t[99]=Te,t[100]=re,t[101]=de,t[102]=Ne,t[103]=Je):Je=t[103],Je};function FC(t){return t.workStatusPanelVisible}function _C(t){return t.contextRailOrder}function LC(t){return t.contextRailHiddenSurfaces}function $C(t){return t.setContextRailOrder}function zC(t){return t.openContextSurface}function KC(t){return t.closeContextZone}function WC(t){return t.contextSurfaceZones}function HC(t){return t.shortcutOverrides}function UC(t){return t.status?.status==="connected"}function VC(t){return Object.values(t.entries).some(UC)}function GC(t){return t.length===1&&t>="0"&&t<="9"}function qC(t){return t.countByGuest}function YC(t){return t.clearBadge}function ZC(t){return t.mode==="pr"&&t.targetPath}function QC(t){return t.id}function XC(t){return t.id}const JC=t=>{const e=Ze.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:o,closeSessionSearch:i,sessionSearchInputRef:a,sessionSearchContainerRef:d}=t,c=s===void 0?!0:s;let u,f;e[0]!==c||e[1]!==r||e[2]!==a?(u=()=>{if(!c||!r||typeof window>"u")return;const x=window.requestAnimationFrame(()=>{a.current?.focus(),a.current?.select()});return()=>window.cancelAnimationFrame(x)},f=[c,r,a],e[0]=c,e[1]=r,e[2]=a,e[3]=u,e[4]=f):(u=e[3],f=e[4]),l.useEffect(u,f);let p,h;e[5]!==c||e[6]!==o||e[7]!==a?(p=()=>{if(!c||typeof window>"u")return;const x=()=>{o(),a.current?.focus(),a.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",x),()=>window.removeEventListener("openchamber:sidebar-session-search",x)},h=[c,o,a],e[5]=c,e[6]=o,e[7]=a,e[8]=p,e[9]=h):(p=e[8],h=e[9]),l.useEffect(p,h);let g,b;e[10]!==i||e[11]!==c||e[12]!==r||e[13]!==d?(g=()=>{if(!c||!r||typeof document>"u")return;const x=y=>{d.current&&(d.current.contains(y.target)||i())};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},b=[c,r,i,d],e[10]=i,e[11]=c,e[12]=r,e[13]=d,e[14]=g,e[15]=b):(g=e[14],b=e[15]),l.useEffect(g,b)},e3=t=>{const e=Ze.c(4);let s;e[0]!==t?(s=(i,a)=>{const d=t.get(i);if(!d||d.length===0)return a;const c=new Map(a.map(t3)),u=[];d.forEach(h=>{const g=c.get(h);g&&(u.push(g),c.delete(h))});const f=[],p=[];return a.forEach(h=>{c.has(h.id)&&(h.isArchivedBucket?p.push(h):f.push(h))}),[...f,...u,...p]},e[0]=t,e[1]=s):s=e[1];const r=s;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function t3(t){return[t.id,t]}const s3=(t,e)=>{const s=t.groups.find(i=>i.isMain&&i.sessions.length>0)??t.groups.find(i=>i.sessions.length>0)??t.groups.find(i=>i.isMain)??t.groups[0];if(!s)return[];const r=t.groups.find(i=>i.isArchivedBucket&&i.id!==s.id);return(e.mainWorkspaceOnly?[s,...r?[r]:[]]:[...t.groups.find(i=>i.isMain)?[t.groups.find(i=>i.isMain)]:[],...t.groups.filter(i=>!i.isMain)]).map(i=>({group:i,groupKey:`${t.project.id}:${i.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?i.id===s.id:i.isMain}))},qd=(t,e,s)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const a of o.children)i=r(a)||i;return i&&s.add(o.session.id),i};for(const o of t)r(o)},gr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(gr(s,e))return!0;return!1},n3=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!yl(r),r3=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,al=(t,e,s)=>{const r=new Map,o=i=>{const a=ur(i.session)??yt(i.worktree?.path)??s;if(a){const d=r.get(a)??[];d.push(i.session.id),r.set(a,d)}if(!(i===t&&e))for(const d of i.children)o(d)};return o(t),[...r].map(([i,a])=>({directory:i,sessionIDs:a}))},ll=(t,e)=>{const s=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(s.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},Uh=t=>{const e=new Map(t.map(a=>[a.id,a])),s=new Map;for(const a of t){if(!a.parentId||!e.has(a.parentId))continue;const d=s.get(a.parentId)??[];d.push(a),s.set(a.parentId,d)}const r=new Set,o=[],i=a=>{if(r.has(a.id))return;o.push(a);const d=[a.id];for(;d.length>0;){const c=d.pop();if(!(!c||r.has(c))){r.add(c);for(const u of s.get(c)??[])d.push(u.id)}}};return t.forEach(a=>{(!a.parentId||!e.has(a.parentId))&&i(a)}),t.forEach(i),o},Vh=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const h=o.get(u.parentId)??[];h.push(u.id),o.set(u.parentId,h)}const f=new Set;let p=u.id;for(;p;){if(f.has(p)){i.add(u.id);break}f.add(p),p=r.get(p)?.parentId}}const a=new Set,d=new Set,c=u=>{if(a.has(u))return!0;if(d.has(u))return!1;const f=r.get(u);if(!f)return!1;d.add(u);let p=i.has(u);return!p&&e.archivedBucket&&f.nodeCount===0?p=(o.get(u)??[]).some(c):(!p&&!e.searchQuery&&(p=!0),!p&&(f.nodeCount>0||!s&&$o([f.name],e.searchQuery))&&(p=!0),p||(p=(o.get(u)??[]).some(c))),d.delete(u),p&&a.add(u),p};return t.forEach(u=>c(u.id)),new Set(t.filter(u=>a.has(u.id)).map(u=>u.id))},Yd=new WeakMap;let Zd=1;const o3=t=>{const e=Yd.get(t);if(e!==void 0)return e;const s=Zd;return Zd+=1,Yd.set(t,s),s},Gr=t=>t.children.length===0?"":t.children.map(s=>{const r=o3(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Gr(s)}`}).join("|"),Gh=(t,e,s,r,o,i)=>{const a=Jt(),d=(c,u)=>{if(c.session.id!==u.session.id||c.children.length!==u.children.length)return!0;const f=c.session.directory??o,p=u.session.directory??i,h=Yc(a,f??"",c.session.id),g=Yc(a,p??"",u.session.id);return(h?s.has(h):!1)!==(g?r.has(g):!1)?!0:c.children.some((b,x)=>d(b,u.children[x]))};return d(t,e)},i3=(t,e)=>t?t.branchLabel??null:e??null,a3=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=yt(t?.path??null);return s&&r?{directory:r,branch:s}:null},Zo=(t,e,s,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const a=d=>{if(`${s}:${o}:${d.session.id}`===e)return i=d.session.id,!0;for(const u of d.children)if(a(u))return!0;return!1};return t.forEach(d=>a(d)),i},_n=(t,e)=>`${t}\0${e}`,lr=(t,e)=>t??xl(e)??yt(e??null),zn=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??yt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},sc=t=>t.startsWith("__archived__:"),qh=6,Kn=t=>$l(t,qh),Qd=t=>`calc(${Kn(t)} + 20px)`,l3=t=>{const e=new Array(t.length).fill(null);let s=[];for(let r=t.length-1;r>=0;r-=1){const o=t[r];if(o==null){s=[];continue}const i=[];for(let a=1;a<o;a+=1)s[a]&&i.push({level:a,end:!1});o>0&&i.push({level:o,end:!s[o]}),i.length>0&&(e[r]=Object.freeze(i)),s=s.slice(0,o),s[o]=!0}return e},Ri=(t,e)=>{const s=e.trim().toLowerCase();return s?s.startsWith("ses_")?t.id.toLowerCase()===s:(typeof t.title=="string"?t.title.toLowerCase():"").includes(e):!0},Yh=(t,e)=>{if(Ri(t.session,e))return t;const s=t.children.flatMap(r=>{const o=Yh(r,e);return o?[o]:[]});return s.length>0?{...t,children:s}:null},nc=(t,e)=>(Ri(t.session,e)?1:0)+t.children.reduce((s,r)=>s+nc(r,e),0),c3=(t,e,s,r)=>{const o=new Map;return s?{sessions:t.filter(a=>{const d=r==="tree"?nc(e(a),s):Number(Ri(a,s));return d>0&&o.set(a.id,d),d>0}),matchCountById:o}:{sessions:[...t],matchCountById:o}},Xd=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(o=>{if(!Ri(o,r))return[];const i=e(o.id);return[{node:s(o),projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:{projectLabel:i?.projectLabel??null,branchLabel:i?.branchLabel??null,inSpace:i?.inSpace??!1}}]}),Zh=["chats","pinned","work","timeline"],rc=t=>t==="project"||t==="mixed-compact"||t==="tree-chat",qr=t=>t==="timeline"||t==="timeline-mixed"||t==="timeline-by-time",d3=t=>qr(t)||t==="mixed-compact",po=t=>"run"in t,u3=(t,e)=>`${t}:active:run:${e}`,ma=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const a=e.runKeyBySessionId.get(i.session.id),d=a?e.runs.get(a):void 0;if(!d){r.push(i);continue}const c=o.get(d.key);if(c){c.lanes.push(i);continue}const u={run:d,lanes:[i]};o.set(d.key,u),r.push(u)}for(const i of o.values()){const a=new Map(i.run.memberIds.map((d,c)=>[d,c]));i.lanes.sort((d,c)=>(a.get(d.session.id)??0)-(a.get(c.session.id)??0))}return r},Qh=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),o=i=>i.reduce((a,d)=>a+(!r||d.session.id.toLowerCase()===s?1:0)+o(d.children),0);return o(t)},ga=[],f3=new Set,p3=32,Xh=52,h3=Xh+21,Jd=t=>t==="timeline-by-time"?h3:qr(t)?Xh:p3,m3=3,g3=7,eu=7,tu=7,Jh=t=>`timeline-project:${t}`,Qn=32,Js=28,b3=t=>{switch(t.kind){case"group-header":return 0;case"folder-header":return t.depth;case"session":case"run":return rc(t.renderContext)?t.depth:null;default:return null}},su=(t,e,s,r)=>{const o=r.get(t.session.id),i=r.get(e.session.id);if(o!==void 0||i!==void 0){if(o===void 0)return 1;if(i===void 0)return-1;if(o!==i)return o-i}return Kl(t.session,e.session,s,up)},ba=t=>{const e=new Map,s=new Map,r=[],o=new WeakMap,i=t.map(a=>({node:a,visited:!1})).reverse();for(;i.length>0;){const a=i.pop();if(!a)continue;if(!a.visited){e.set(a.node.session.id,a.node),s.set(a.node.session.id,a.node.session);const c=r.length;r.push(a.node.session.id),o.set(a.node,[c,c+1]),i.push({node:a.node,visited:!0});for(let u=a.node.children.length-1;u>=0;u-=1){const f=a.node.children[u];f&&i.push({node:f,visited:!1})}continue}const d=o.get(a.node);d&&o.set(a.node,Object.freeze([d[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},y3=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,x3=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},S3=t=>{const e=[],s=[],r=[],o=[],i=[],a=new Map,d=new Map,c=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.zoneSessionIds??f3,p=E=>c&&f.has(E);let h=0;const b=[...[...t.authoritativeSections.flatMap(E=>E.groups.flatMap(D=>D.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const E=b.pop();E&&(a.set(E.session.id,E.session),b.push(...E.children))}const x=E=>{const D=d.get(E)??0;return d.set(E,D+1),D===0?E:`${E}:${D}`},y=E=>{e.push(Object.freeze(E))},S=t.runIndex??E1,m=(E,D)=>{const C=u3(D.renderContext,E.run.key),N=!d3(D.renderContext)&&(c||t.expandedParents.has(C)),A=E.lanes[0]?.session.id,q=A&&D.getSecondaryMeta?D.getSecondaryMeta(A):D.secondaryMeta,ee=Object.freeze([...new Set(E.lanes.flatMap(Q=>(D.getBlockingBadgeSessionScopes?.(Q.session.id)??[]).flatMap(he=>he.sessionIDs)))]);y({kind:"run",key:x(`${D.containerKey}:run:${E.run.key}`),estimateSize:Jd(D.renderContext),run:E.run,depth:D.baseDepth??0,laneNodes:Object.freeze([...E.lanes]),blockingSessionIds:ee,projectId:D.projectId,projectLabel:q?.projectLabel??null,groupDirectory:D.groupDirectory,renderContext:D.renderContext,expansionKey:C,expanded:N,forceExpanded:c}),N&&w(E.lanes,(D.baseDepth??0)+1,D)},v=E=>{for(const D of ma(E.nodes,S,E.archived))po(D)?m(D,E):w([D],E.baseDepth??0,E)},w=(E,D,C)=>{const N=[...E].reverse().map(A=>({node:A,depth:D,directory:C.groupDirectory}));for(;N.length>0;){const A=N.pop();if(!A)continue;const q=x(`${C.containerKey}:session:${A.node.session.id}`),ee=A.node.session.directory??A.directory;a.set(A.node.session.id,A.node.session),y({kind:"session",key:q,estimateSize:Jd(C.renderContext),node:A.node,blockingBadgeSessionScopes:A.depth===D?C.getBlockingBadgeSessionScopes?.(A.node.session.id)??C.blockingBadgeSessionScopes:void 0,depth:A.depth,projectId:C.projectId,groupDirectory:A.directory,ownerKey:C.ownerKey,selectionScopeKey:C.selectionScopeKey,archived:C.archived,renderContext:C.renderContext,secondaryMeta:C.getSecondaryMeta?C.getSecondaryMeta(A.node.session.id):C.secondaryMeta??null});const Q=C.indexedNodes?.subtreeRangeByNode.get(A.node),he=Q&&Q[1]>Q[0]+1?Object.freeze([(C.selectionPoolOffset??0)+Q[0]+1,(C.selectionPoolOffset??0)+Q[1]]):void 0;if(s.push(Object.freeze({id:A.node.session.id,rowKey:q,scopeKey:C.selectionScopeKey,archived:C.archived,descendantRange:he})),!(!c&&!t.expandedParents.has(y3(C.renderContext,C.archived,A.node.session.id))))for(let M=A.node.children.length-1;M>=0;M-=1){const V=A.node.children[M];V&&N.push({node:V,depth:A.depth+1,directory:ee})}}},T=E=>{const D=t.groupSearchDataByGroup.get(E);if(D?.hasMatch!==!0)return 0;const C=f.size>0?D.filteredNodes.filter(A=>p(A.session.id)):[];return Math.max(0,D.matchedSessionCount-Qh(C,t.normalizedQuery))+D.folderNameMatchCount+(D.groupMatches?1:0)},k=(E,D,C,N,A)=>{const q=t.groupSearchDataByGroup.get(E);if(c){const oe=T(E);if(oe===0)return;h+=oe}const ee=(c?q?.filteredNodes??[]:E.sessions).filter(oe=>!p(oe.session.id)).sort((oe,tt)=>su(oe,tt,u,t.sessionOrderIndex)),Q=ba(ee),he=r.length;r.push(...Q.preorderIds);for(const[oe,tt]of Q.sessionsById)a.set(oe,tt);const M=lr(C,E.directory),V=!c&&t.collapsedGroups.has(D),ie=N?0:1,ce=A!==void 0&&!rc(A.renderContext),ne=t.groupStatusByKey.get(D),je=!ne||ne.state==="ready",Ee=ee.length===0&&je&&zn(E).every(({scopeKey:oe})=>(t.foldersMap[oe]??ga).length===0);if(!N){const oe=Q.preorderIds.flatMap(tt=>Q.sessionsById.get(tt)??[]);y({kind:"group-header",key:`${D}:header`,estimateSize:Qn,group:E,groupKey:D,projectId:C,collapsed:V&&!Ee,forceExpanded:c,empty:Ee,allSessions:Object.freeze(oe)})}if(V&&!Ee)return;const we=zn(E).flatMap(({scopeKey:oe,directory:tt})=>(t.foldersMap[oe]??ga).map(Ue=>({folder:Ue,scopeKey:oe,scopeDirectory:tt,ownerKey:M,nodes:ll(Ue.sessionIds,Q.byId).sort((gt,bt)=>su(gt,bt,u,t.sessionOrderIndex))}))),Me=Vh(we.map(oe=>({id:oe.folder.id,name:oe.folder.name,parentId:oe.folder.parentId,nodeCount:oe.nodes.length})),{archivedBucket:E.isArchivedBucket===!0,searchQuery:c?t.normalizedQuery:""}),fe=we.filter(oe=>Me.has(oe.folder.id)),be=new Map(fe.map(oe=>[_n(oe.scopeKey,oe.folder.id),oe])),ke=new Map;for(const oe of fe){if(!oe.folder.parentId)continue;const tt=_n(oe.scopeKey,oe.folder.parentId),Ue=ke.get(tt)??[];Ue.push(oe),ke.set(tt,Ue)}const Ie=Uh(fe.map(oe=>({...oe.folder,scopeKey:oe.scopeKey}))).map(oe=>be.get(_n(oe.scopeKey??"",oe.id))).filter(oe=>!!oe),Te=new Set(fe.flatMap(oe=>oe.folder.sessionIds)),Y=ee.filter(oe=>!Te.has(oe.session.id)),ue=new Map,me=Ie.map(oe=>({folder:oe,visited:!1})),re=new Set;for(;me.length>0;){const oe=me.pop();if(!oe)continue;const tt=_n(oe.folder.scopeKey,oe.folder.folder.id);if(!oe.visited){if(re.has(tt))continue;re.add(tt),me.push({folder:oe.folder,visited:!0});for(const gt of ke.get(tt)??[])me.push({folder:gt,visited:!1});continue}const Ue=oe.folder.nodes.flatMap(gt=>{const bt=Q.subtreeRangeByNode.get(gt);return bt?Q.preorderIds.slice(bt[0],bt[1]).flatMap(Ce=>Q.sessionsById.get(Ce)??[]):[gt.session]});for(const gt of ke.get(tt)??[])Ue.push(...ue.get(_n(gt.scopeKey,gt.folder.id))??[]);ue.set(tt,Object.freeze(Ue))}const pe=new Set,U=(oe,tt)=>{const Ue=_n(oe.scopeKey,oe.folder.id);if(pe.has(Ue))return;pe.add(Ue);const gt=tt?`${tt} / ${oe.folder.name}`:oe.folder.name,bt=`${D}:folder:${Ue}`,Ce=je&&oe.nodes.length===0&&(ke.get(Ue)?.length??0)===0,_e=!c&&!Ce&&t.collapsedFolders.has(oe.folder.id),ze=ue.get(Ue)??[],Oe=_e&&!E.isArchivedBucket?ll([...new Set(ze.map(Be=>Be.id))],Q.byId):[],it=M?t.folderAuthorityByOwner.get(M):void 0,X=!!M&&!E.isArchivedBucket&&!sc(oe.scopeKey)&&it?.complete===!0&&it.scopeKeys.includes(oe.scopeKey);if(y({kind:"folder-header",key:bt,estimateSize:Qn,depth:ie,group:E,folder:oe.folder,displayName:gt,scopeKey:oe.scopeKey,scopeDirectory:oe.scopeDirectory,ownerKey:M,nodes:oe.nodes,activityNodes:Oe,projectId:C,archived:E.isArchivedBucket===!0,collapsed:_e,forceExpanded:c,empty:Ce,deleteSessions:ze,subFolderCount:ke.get(Ue)?.length??0,dropEnabled:X}),M&&i.push(Object.freeze({rowKey:bt,scopeKey:oe.scopeKey,folderId:oe.folder.id,ownerKey:M,enabled:X})),!_e){v({nodes:oe.nodes,containerKey:bt,projectId:C,groupDirectory:oe.scopeDirectory??E.directory,ownerKey:M,selectionScopeKey:M,archived:E.isArchivedBucket===!0,renderContext:"project",indexedNodes:Q,selectionPoolOffset:he,baseDepth:ie+1});for(const Be of ke.get(Ue)??[])U(Be,gt)}};for(const oe of Ie)U(oe,"");const ae=C?t.sessionBatchSize:void 0,Re=A?.initial??ae??(t.hideDirectoryControls?10:eu),W=A?.increment??ae??tu,ye=Math.max(Re,t.visibleCountByContainer.get(D)??Re),de=oe=>!po(oe)&&A?.pinnedAlwaysVisible===!0&&gi(u,oe.session.directory??E.directory,oe.session.id),Ne=ma(Y,S,E.isArchivedBucket===!0),Je=Ne.filter(oe=>!de(oe));let Ge=ye;const ge=E.isArchivedBucket||c?Ne:Ne.filter(oe=>de(oe)?!0:Ge<=0?!1:(Ge-=1,!0)),Ae=ge.flatMap(oe=>po(oe)?oe.lanes:[oe]);v({nodes:Ae,containerKey:D,projectId:C,groupDirectory:E.directory,ownerKey:M,selectionScopeKey:M,archived:E.isArchivedBucket===!0,renderContext:A?.renderContext??"project",indexedNodes:Q,selectionPoolOffset:he,baseDepth:ie});const Ye=Ne.length-ge.length,nt=ye-Ge;!c&&!E.isArchivedBucket&&Ye>0?y({kind:"show-control",key:`${D}:more`,estimateSize:Js,control:"more",containerKey:D,currentCount:nt,increment:W,depth:ie,flat:ce}):!c&&!E.isArchivedBucket&&Je.length>Re&&Ye===0&&y({kind:"show-control",key:`${D}:fewer`,estimateSize:Js,control:"fewer",containerKey:D,currentCount:nt,increment:W,depth:ie,flat:ce}),ee.length===0&&fe.length===0?ne&&ne.state!=="ready"?y({kind:"status",key:`${D}:status`,estimateSize:Js,status:ne,group:E,groupKey:D,depth:ie,flat:ce}):E.isArchivedBucket&&y({kind:"empty",key:`${D}:empty`,estimateSize:Js,emptyKind:"archived",depth:ie}):ne&&ne.state!=="ready"&&ne.state!=="loading"&&y({kind:"status",key:`${D}:status`,estimateSize:Js,status:ne,group:E,groupKey:D,depth:ie,flat:ce})},I=E=>{const D=!c&&t.collapsedActivities.has(E),C=e.length;return y({kind:"activity-header",key:`activity:${E}:header`,estimateSize:Qn,activityKey:E,collapsed:D,forceExpanded:c}),o.push(Object.freeze({rowIndex:C,kind:"activity",id:E})),D},B=t.viewMode==="timeline",O=E=>"run"in E,F=E=>{const D=ma(E.map(N=>N.node),S,!1),C=new Map(E.map(N=>[N.node,N]));return D.flatMap(N=>{if(!po(N)){const A=C.get(N);return A?[A]:[]}return[{run:N.run,items:N.lanes.flatMap(A=>C.get(A)??[])}]})},j=(E,D,C)=>{const N=E.items[0];if(!N)return;const A=E.items.map(V=>V.node),q=ba(A),ee=r.length;r.push(...q.preorderIds);const Q=lr(N.projectId,N.groupDirectory),he=new Map(E.items.map(V=>[V.node.session.id,V.getSecondaryMeta?V.getSecondaryMeta(V.node.session.id):V.secondaryMeta])),M=new Map(E.items.map(V=>[V.node.session.id,V.blockingBadgeSessionScopes]));m({run:E.run,lanes:A},{nodes:A,containerKey:D,projectId:N.projectId,groupDirectory:N.groupDirectory,ownerKey:Q,selectionScopeKey:null,archived:!1,renderContext:C,getSecondaryMeta:V=>he.get(V)??null,getBlockingBadgeSessionScopes:V=>M.get(V),indexedNodes:q,selectionPoolOffset:ee})},P=(E,D,C,N=()=>1)=>{for(const A of F(E)){if(O(A)){j(A,D,C),c&&(h+=A.items.reduce((M,V)=>M+N(V),0));continue}const q=A,ee=ba([q.node]),Q=r.length;r.push(...ee.preorderIds);const he=lr(q.projectId,q.groupDirectory);v({nodes:[q.node],containerKey:D,projectId:q.projectId,groupDirectory:q.groupDirectory,ownerKey:he,selectionScopeKey:null,archived:!1,renderContext:C,blockingBadgeSessionScopes:q.blockingBadgeSessionScopes,secondaryMeta:q.secondaryMeta,getSecondaryMeta:q.getSecondaryMeta,indexedNodes:ee,selectionPoolOffset:Q}),c&&(h+=N(q))}};t.chatGroup&&(!c||T(t.chatGroup)>0)&&(I("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:m3,increment:g3,pinnedAlwaysVisible:!0,renderContext:B?"timeline-chat":"tree-chat"}));const L=B&&t.listGrouping==="time",z=L?"timeline-by-time":B||t.detailedZoneRows?"timeline-mixed":"mixed-compact",H=(E,D,C,N,A)=>{const q=Math.max(N,t.visibleCountByContainer.get(D)??N),ee=F(E),Q=c?ee:ee.slice(0,q);P(Q.flatMap(he=>O(he)?he.items:[he]),D,C),!c&&(ee.length>Q.length?y({kind:"show-control",key:`${D}:more`,estimateSize:Js,control:"more",containerKey:D,currentCount:Q.length,increment:A,flat:!0}):ee.length>N&&y({kind:"show-control",key:`${D}:fewer`,estimateSize:Js,control:"fewer",containerKey:D,currentCount:Q.length,increment:A,flat:!0}))},R=(E,D)=>{if(D.length===0)return;I(E)||P(D,`activity:${E}`,z,N=>N.searchMatchCount??nc(N.node,t.normalizedQuery))};if(R("pinned",t.pinnedItems??[]),R("work",t.workItems??[]),L){const E=(t.timelineItems??[]).filter(D=>D.projectId&&!f.has(D.node.session.id));if(E.length>0&&(I("timeline")||P(E,"activity:timeline","timeline-by-time")),!c&&!(E.length>0&&t.collapsedActivities.has("timeline"))){const D=new Set((t.timelineItems??[]).map(N=>N.projectId)),C=new Set;for(const N of t.sections){if(D.has(N.project.id))continue;const A=N.groups.find(he=>he.isMain);if(!A)continue;const q=`${N.project.id}:${A.id}`,ee=t.groupStatusByKey.get(q);if(!ee||ee.state==="ready")continue;const Q=ee.state==="loading"?"loading":`${ee.state}:${ee.directory??""}`;C.has(Q)||(C.add(Q),y({kind:"status",key:`activity:timeline:status:${q}`,estimateSize:Js,status:ee,group:A,groupKey:q,flat:!0}))}}}else if(B){const E=new Set((t.pinnedItems??[]).map(C=>C.node.session.id)),D=new Map;for(const C of t.timelineItems??[]){if(!C.projectId||p(C.node.session.id)||E.has(C.node.session.id))continue;const N=D.get(C.projectId);N?N.push(C):D.set(C.projectId,[C])}for(const C of t.sections){const N=C.project.id,A=D.get(N)??[];if(c&&A.length===0)continue;const q=!c&&t.collapsedProjects.has(N),ee=e.length;if(y({kind:"project-header",key:`project:${N}:header`,estimateSize:Qn,section:C,collapsed:q,forceExpanded:c}),o.push(Object.freeze({rowIndex:ee,kind:"project",id:N})),q)continue;if(!c)for(const V of C.groups){if(!V.space||V.sessions.length>0)continue;const ie=`${N}:${V.id}`,ce=t.groupStatusByKey.get(ie);if(ce?.state==="loading")continue;const ne=(!ce||ce.state==="ready")&&zn(V).every(({scopeKey:je})=>(t.foldersMap[je]??ga).length===0);y({kind:"group-header",key:`${ie}:header`,estimateSize:Qn,group:V,groupKey:ie,projectId:N,collapsed:!1,forceExpanded:!0,empty:ne,allSessions:Object.freeze([])}),ce&&ce.state!=="ready"&&y({kind:"status",key:`${ie}:status`,estimateSize:Js,status:ce,group:V,groupKey:ie,flat:!0})}if(A.length>0){H(A,Jh(N),"timeline",eu,tu);continue}const Q=C.groups.find(V=>V.isMain);if(!Q)continue;const he=`${N}:${Q.id}`,M=t.groupStatusByKey.get(he);M&&M.state!=="ready"&&y({kind:"status",key:`${he}:status`,estimateSize:Js,status:M,group:Q,groupKey:he,flat:!0})}}let G=B?[]:t.singleProjectMode?t.sections.filter(E=>E.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const E=G.find(D=>D.project.id===t.activeProjectId)??G[0];G=E?[E]:[]}for(const E of G){const D=s3(E,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(c&&!D.some(N=>T(N.group)>0))continue;const C=!c&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(E.project.id);if(!t.showOnlyMainWorkspace){const N=e.length;y({kind:"project-header",key:`project:${E.project.id}:header`,estimateSize:Qn,section:E,collapsed:C,forceExpanded:c}),o.push(Object.freeze({rowIndex:N,kind:"project",id:E.project.id}))}if(!C)for(const N of D)k(N.group,N.groupKey,N.projectId,N.hideGroupLabel)}e.length===0&&y({kind:"empty",key:c?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:c?"search":"sidebar"}),l3(e.map(b3)).forEach((E,D)=>{const C=e[D];E&&C&&(e[D]=Object.freeze({...C,treeGuides:E}))});const $=new Map;return e.forEach((E,D)=>$.set(E.key,D)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:$,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:a,searchMatchCount:c?h:0})},ho="oc.sessions.projectCollapse",nu="oc.sessions.groupOrder",ru="oc.sessions.groupCollapse",ou="oc.sessions.activityCollapse",ya=t=>{if(!t)return new Set;try{const e=Ci(zs()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},w3=t=>{if(!t)return new Map;try{const e=Wr(zs(),Ci(zs())).safeParse(JSON.parse(t));if(!e.success)return new Map;const s=new Map;for(const[r,o]of Object.entries(e.data))s.set(r,o);return s}catch{return new Map}},v3=t=>{const e=Ze.c(45),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Oo(),e[0]=o):o=e[0];const i=o;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>ya(i.getItem(ho)),e[1]=a):a=e[1];const[d,c]=l.useState(a);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>ya(i.getItem(ru)),e[2]=u):u=e[2];const[f,p]=l.useState(u);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>ya(i.getItem(ou)),e[3]=h):h=e[3];const[g,b]=l.useState(h);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=()=>w3(i.getItem(nu)),e[4]=x):x=e[4];const[y,S]=l.useState(x),m=l.useRef(0),v=l.useRef(!1),w=l.useRef(!1),T=l.useRef(!1),k=l.useRef(null),I=l.useRef(null);let B;e[5]!==s?(B=()=>{if(s)return;const fe=I.current;if(I.current=null,k.current=null,!fe)return;const{projects:be}=ns.getState(),ke=be.map(Ie=>({...Ie,sidebarCollapsed:fe.has(Ie.id)}));en({projects:ke}).catch(j3)},e[5]=s,e[6]=B):B=e[6];const O=B;let F;e[7]!==O||e[8]!==s?(F=fe=>{!globalThis.window||s||(I.current=fe,k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{O()},700))},e[7]=O,e[8]=s,e[9]=F):F=e[9];const j=F;let P,L;e[10]===Symbol.for("react.memo_cache_sentinel")?(P=()=>()=>{globalThis.window&&k.current!==null&&window.clearTimeout(k.current),k.current=null,I.current=null},L=[],e[10]=P,e[11]=L):(P=e[10],L=e[11]),l.useEffect(P,L);let z,H;e[12]!==y?(z=()=>{if(T.current)try{i.setItem(nu,JSON.stringify(Object.fromEntries(y.entries())))}catch{}},H=[y,i],e[12]=y,e[13]=z,e[14]=H):(z=e[13],H=e[14]),l.useEffect(z,H);let R,G;e[15]!==f?(R=()=>{if(v.current)try{i.setItem(ru,JSON.stringify(Array.from(f)))}catch{}},G=[f,i],e[15]=f,e[16]=R,e[17]=G):(R=e[16],G=e[17]),l.useEffect(R,G);let _,$;e[18]!==g?(_=()=>{if(w.current)try{i.setItem(ou,JSON.stringify(Array.from(g)))}catch{}},$=[g,i],e[18]=g,e[19]=_,e[20]=$):(_=e[19],$=e[20]),l.useEffect(_,$);let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=fe=>{w.current=!0,b(fe)},e[21]=E):E=e[21];const D=E;let C;e[22]!==r||e[23]!==j?(C=()=>{m.current=Date.now()+150,v.current=!0,w.current=!0,p(new Set),b(k3),c(()=>{const fe=new Set(r.map(C3));try{i.setItem(ho,JSON.stringify(Array.from(fe)))}catch{}return j(fe),fe})},e[22]=r,e[23]=j,e[24]=C):C=e[24];const N=C;let A;e[25]!==j?(A=()=>{m.current=Date.now()+150,v.current=!0,w.current=!0,p(new Set),b(I3),c(()=>{const fe=new Set;try{i.setItem(ho,JSON.stringify([]))}catch{}return j(fe),fe})},e[25]=j,e[26]=A):A=e[26];const q=A;let ee;e[27]!==j?(ee=fe=>{m.current=Date.now()+150,c(be=>{const ke=new Set(be);ke.has(fe)?ke.delete(fe):ke.add(fe);try{i.setItem(ho,JSON.stringify(Array.from(ke)))}catch{}return j(ke),ke})},e[27]=j,e[28]=ee):ee=e[28];const Q=ee;let he;e[29]===Symbol.for("react.memo_cache_sentinel")?(he=fe=>{v.current=!0,p(be=>{const ke=new Set(be);return ke.has(fe)?ke.delete(fe):ke.add(fe),ke})},e[29]=he):he=e[29];const M=he;let V;e[30]===Symbol.for("react.memo_cache_sentinel")?(V=fe=>{T.current=!0,S(fe)},e[30]=V):V=e[30];const ie=V,{getOrderedGroups:ce}=e3(y);let ne;e[31]!==g||e[32]!==f||e[33]!==d||e[34]!==y?(ne={collapsedProjects:d,collapsedGroups:f,collapsedActivities:g,groupOrderByProject:y},e[31]=g,e[32]=f,e[33]=d,e[34]=y,e[35]=ne):ne=e[35];const je=ne;let Ee;e[36]!==N||e[37]!==q||e[38]!==ce||e[39]!==j||e[40]!==Q?(Ee={setCollapsedProjects:c,toggleProject:Q,collapseAll:N,expandAll:q,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:p,setCollapsedActivities:D,toggleGroup:M,setGroupOrderByProject:ie,getOrderedGroups:ce},e[36]=N,e[37]=q,e[38]=ce,e[39]=j,e[40]=Q,e[41]=Ee):Ee=e[41];const we=Ee;let Me;return e[42]!==we||e[43]!==je?(Me={state:je,actions:we},e[42]=we,e[43]=je,e[44]=Me):Me=e[44],Me};function j3(){}function k3(t){return new Set([...t,...Zh])}function C3(t){return t.id}function I3(t){const e=new Set(t);for(const s of Zh)e.delete(s);return e}const P3=5*6e4,E3=t=>{const e=Ze.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:a}=t,d=r===void 0?!0:r,{git:c}=Ks(),u=Cn(T3),f=Cn(D3),p=l.useRef(null),h=l.useRef(d);let g,b;e[0]!==d||e[1]!==u||e[2]!==c||e[3]!==f?(g=()=>{const j=d&&!h.current;h.current=d;const P=p.current;if(!(!j||!c||!P||P.git!==c||P.runtimeKey!==f))for(const L of P.paths)Nr(()=>u(L,c))},b=[d,u,c,f],e[0]=d,e[1]=u,e[2]=c,e[3]=f,e[4]=g,e[5]=b):(g=e[4],b=e[5]),l.useEffect(g,b);let x,y;e[6]!==d||e[7]!==u||e[8]!==c||e[9]!==f||e[10]!==s||e[11]!==i?(x=()=>{if(!d)return;if(!c||s.length===0){p.current=null,i(new Map);return}let j=p.current;(!j||j.runtimeKey!==f||j.git!==c)&&(j={runtimeKey:f,git:c,paths:new Set},p.current=j);const{paths:P}=j,L=new Set(s.map(R3));for(const R of P)L.has(R)||P.delete(R);const z=[...L].filter(R=>!P.has(R));if(z.length===0)return;for(const R of z)P.add(R);const H=R=>{const G=Cn.getState().directories.get(R);G?.isGitRepo!==!1&&!G?.status&&P.delete(R)};Nr(async()=>{await c.prefetchProjectStatuses?.(z),await Promise.all(z.map(R=>u(R,c).then(()=>H(R),()=>H(R))))})},y=[d,s,c,f,u,i],e[6]=d,e[7]=u,e[8]=c,e[9]=f,e[10]=s,e[11]=i,e[12]=x,e[13]=y):(x=e[12],y=e[13]),l.useEffect(x,y);let S,m;e[14]!==d||e[15]!==o||e[16]!==s||e[17]!==i?(S=()=>{if(!d)return;const j=new Map;s.forEach(P=>{j.set(P.id,o.get(P.normalizedPath)?.isGitRepo??null)}),i(j)},m=[d,s,o,i],e[14]=d,e[15]=o,e[16]=s,e[17]=i,e[18]=S,e[19]=m):(S=e[18],m=e[19]),l.useEffect(S,m);let v;if(e[20]!==o||e[21]!==s){let j;e[23]!==o?(j=P=>{const L=o.get(P.normalizedPath)?.branch??"";return`${P.id}:${L}`},e[23]=o,e[24]=j):j=e[24],v=s.map(j).join("|"),e[20]=o,e[21]=s,e[22]=v}else v=e[22];const w=v;let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=new Map,e[25]=T):T=e[25];const k=l.useRef(T);let I;e[26]===Symbol.for("react.memo_cache_sentinel")?(I=new Map,e[26]=I):I=e[26];const B=l.useRef(I);let O;e[27]!==d||e[28]!==o||e[29]!==s||e[30]!==a?(O=()=>{if(!d)return;let j=!1;const P=setTimeout(()=>{(async()=>{const z=new Set(s.map(N3));for(const E of k.current.keys())z.has(E)||(k.current.delete(E),B.current.delete(E));const H=Date.now(),R=s.filter(E=>{const D=o.get(E.normalizedPath);if(D?.isGitRepo===!1)return k.current.delete(E.id),B.current.delete(E.id),!1;if(D?.isGitRepo!==!0||D.branch===null)return!1;const C=D.branch.trim(),N=`${E.normalizedPath}\0${C}`,A=k.current.get(E.id);if(A===N){const q=B.current.get(E.id);return q&&(q.at=H),!1}return!(A!==void 0&&H-(B.current.get(E.id)?.at??0)<P3)});if(R.length===0)return;const G=await Nr(()=>Promise.all(R.map(async E=>{const D=o.get(E.normalizedPath)?.branch?.trim()??"",C=`${E.normalizedPath}\0${D}`,N=await tp(E.normalizedPath,D?{knownBranch:D}:void 0).catch(M3);return{id:E.id,inputKey:C,branch:N}})));if(j)return;const _=G.filter(A3);if(_.length===0)return;const $=Date.now();a(E=>{const D=new Map(E);return _.forEach(C=>{const{id:N,branch:A}=C;A&&D.set(N,A)}),D}),_.forEach(E=>{const{id:D,inputKey:C,branch:N}=E;k.current.set(D,C),N&&B.current.set(D,{branch:N,at:$})})})()},150);return()=>{j=!0,clearTimeout(P)}},e[27]=d,e[28]=o,e[29]=s,e[30]=a,e[31]=O):O=e[31];let F;e[32]!==d||e[33]!==o||e[34]!==s||e[35]!==w||e[36]!==a?(F=[d,s,w,o,a],e[32]=d,e[33]=o,e[34]=s,e[35]=w,e[36]=a,e[37]=F):F=e[37],l.useEffect(O,F)};function T3(t){return t.ensureStatus}function D3(t){return t.runtimeKey}function R3(t){return t.normalizedPath}function N3(t){return t.id}function M3(){return null}function A3(t){return t.branch}const O3=t=>{const e=Ze.c(19),{open:s,onOpenChange:r,project:o,onSave:i}=t,a=le(B3),[d,c]=l.useState("general");let u,f;e[0]!==s?(u=()=>{s&&c("general")},f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),l.useEffect(u,f);const p=o?.id??null;let h;e:{if(!p){h=void 0;break e}let S;e[3]!==r||e[4]!==p||e[5]!==a?(S=()=>{r(!1),a(p)},e[3]=r,e[4]=p,e[5]=a,e[6]=S):S=e[6],h=S}const g=h;let b;e[7]!==g||e[8]!==i||e[9]!==s||e[10]!==o||e[11]!==d?(b=s&&o?n.jsx(Xb,{frame:"dialog",project:o,onIdentitySave:i,tab:d,onTabChange:c,onOpenWorktrees:g}):null,e[7]=g,e[8]=i,e[9]=s,e[10]=o,e[11]=d,e[12]=b):b=e[12];let x;e[13]!==b?(x=n.jsx(Zs,{className:"flex h-[min(85vh,40rem)] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:b}),e[13]=b,e[14]=x):x=e[14];let y;return e[15]!==r||e[16]!==s||e[17]!==x?(y=n.jsx(Qs,{open:s,onOpenChange:r,children:x}),e[15]=r,e[16]=s,e[17]=x,e[18]=y):y=e[18],y};function B3(t){return t.setWorktreesPageProjectId}function F3(t,e,s,r){const o=Ze.c(6),[i,a]=l.useState(!0);let d,c;return o[0]!==e||o[1]!==r||o[2]!==s||o[3]!==t?(d=()=>{const u=t.current,f=e.current,p=s.current;if(!u||!f||!p||r===0)return;const h=()=>{const b=f.lastElementChild,x=b?b.getBoundingClientRect().width:0,y=Number.parseFloat(getComputedStyle(f).columnGap)||0,S=Number.parseFloat(getComputedStyle(u).columnGap)||0,m=f.getBoundingClientRect().width+r*(y+x),v=u.getBoundingClientRect().right-f.getBoundingClientRect().left-p.getBoundingClientRect().width-S;a(m<=v)};h();const g=new ResizeObserver(h);return g.observe(u),g.observe(f),g.observe(p),()=>g.disconnect()},c=[t,e,s,r],o[0]=e,o[1]=r,o[2]=s,o[3]=t,o[4]=d,o[5]=c):(d=o[4],c=o[5]),l.useLayoutEffect(d,c),i}const em="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",tm="text-muted-foreground hover:text-foreground hover:bg-transparent";function kr(t){const e=Ze.c(14),{label:s,pressed:r,onClick:o,className:i,children:a}=t,d=r?em:tm;let c;e[0]!==i||e[1]!==d?(c=Pe(i,d),e[0]=i,e[1]=d,e[2]=c):c=e[2];let u;e[3]!==a||e[4]!==s||e[5]!==o||e[6]!==r||e[7]!==c?(u=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:c,"aria-label":s,"aria-pressed":r,children:a})}),e[3]=a,e[4]=s,e[5]=o,e[6]=r,e[7]=c,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let p;return e[11]!==u||e[12]!==f?(p=n.jsxs(Ut,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13],p}function _3(t){const e=Ze.c(278),{t:s}=Et(),r=fp(),{hideDirectoryControls:o,showProjectDisplayControls:i,showSectionControls:a,handleOpenDirectoryDialog:d,showSourceBoard:c,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:p,openSessionSearch:h,closeSessionSearch:g,sessionSearchInputRef:b,sessionSearchQuery:x,setSessionSearchQuery:y,hasSessionSearchQuery:S,searchMatchCount:m,collapseAll:v,expandAll:w}=t,T=l.useRef(null),k=l.useRef(null),I=l.useRef(null),B=F3(T,k,I,r.length),O=xs(f4),F=xs(u4),j=le(d4),P=le(c4),L=le(l4),z=le(a4),H=T1(),R=le(i4),G=ts(o4),_=ts(r4),$=ts(n4),E=ts(s4),D=ts(t4),C=ts(e4),N=ts(J3),A=ts(X3),q=le(Q3),ee=ts(Z3),Q=ts(Y3),he=ts(q3),M=ts(G3),V=ts(V3),ie=ts(U3),ce=ts(H3),ne=ts(W3),je=ts(K3),Ee=ts(z3),we=i&&V==="timeline",Me=i&&!we&&je==="single";let fe;e[0]===Symbol.for("react.memo_cache_sentinel")?(fe=n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=fe):fe=e[0];const be=fe;let ke;e[1]!==s?(ke=(Ve,rt,wt,se)=>{const Fe=rt.find(ot=>{const[$e]=ot;return $e===wt})?.[1];return n.jsxs(mp,{children:[n.jsxs(gp,{children:[n.jsx("span",{className:"flex-1",children:s(Ve)}),Fe?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(Fe)}):null]}),n.jsx(bp,{className:"min-w-[160px]",children:rt.map(ot=>{const[$e,Ct]=ot;return n.jsxs(rs,{onClick:()=>se($e),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Ct)}),wt===$e?be:null]},$e)})})]})},e[1]=s,e[2]=ke):ke=e[2];const Ie=ke;let Te;e[3]!==s?(Te=(Ve,rt,wt)=>n.jsxs(rs,{onClick:wt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Ve)}),rt?be:null]}),e[3]=s,e[4]=Te):Te=e[4];const Y=Te;let ue;e[5]===Symbol.for("react.memo_cache_sentinel")?(ue=n.jsx(Z,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=ue):ue=e[5];let me;e[6]!==O||e[7]!==s?(me=s(O?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=O,e[7]=s,e[8]=me):me=e[8];let re;e[9]!==me?(re=n.jsx("span",{children:me}),e[9]=me,e[10]=re):re=e[10];let pe;e[11]!==re||e[12]!==F?(pe=n.jsxs(rs,{onClick:F,className:"flex items-center gap-2",children:[ue,re]},"select"),e[11]=re,e[12]=F,e[13]=pe):pe=e[13];let U;if(e[14]!==Ie||e[15]!==v||e[16]!==N||e[17]!==w||e[18]!==Me||e[19]!==ce||e[20]!==je||e[21]!==ee||e[22]!==q||e[23]!==A||e[24]!==ne||e[25]!==Ee||e[26]!==Q||e[27]!==_||e[28]!==C||e[29]!==E||e[30]!==ie||e[31]!==M||e[32]!==G||e[33]!==D||e[34]!==i||e[35]!==a||e[36]!==$||e[37]!==V||e[38]!==s||e[39]!==pe||e[40]!==we||e[41]!==Y||e[42]!==he){if(U=[pe],i){let Ve;e[44]!==s?(Ve=s("sessions.sidebar.header.viewMode.label"),e[44]=s,e[45]=Ve):Ve=e[45];let rt;e[46]!==Ve?(rt=n.jsx(Ma,{children:Ve}),e[46]=Ve,e[47]=rt):rt=e[47];let wt;e[48]!==ie||e[49]!==V||e[50]!==s?(wt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Fe=>{const[ot,$e]=Fe;return n.jsxs(rs,{onClick:()=>{ie(ot),en({sidebarViewMode:ot})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s($e)}),V===ot?be:null]},ot)}),e[48]=ie,e[49]=V,e[50]=s,e[51]=wt):wt=e[51];let se;e[52]!==rt||e[53]!==wt?(se=n.jsxs(n.Fragment,{children:[rt,wt]}),e[52]=rt,e[53]=wt,e[54]=se):se=e[54],U.push(se)}if(we){let Ve;if(e[55]!==Ie||e[56]!==ce||e[57]!==ne){let rt;e[59]!==ne?(rt=wt=>{ne(wt),en({sidebarListSessionGrouping:wt})},e[59]=ne,e[60]=rt):rt=e[60],Ve=Ie("sessions.sidebar.header.listGrouping.label",[["project","sessions.sidebar.header.listGrouping.project"],["time","sessions.sidebar.header.listGrouping.time"]],ce,rt),e[55]=Ie,e[56]=ce,e[57]=ne,e[58]=Ve}else Ve=e[58];U.push(Ve)}else{let Ve;if(e[61]!==Ie||e[62]!==ee||e[63]!==Q){let Fe;e[65]!==Q?(Fe=ot=>{Q(ot),en({sidebarProjectSortOrder:ot})},e[65]=Q,e[66]=Fe):Fe=e[66],Ve=Ie("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"]],ee,Fe),e[61]=Ie,e[62]=ee,e[63]=Q,e[64]=Ve}else Ve=e[64];let rt;e[67]!==Ie||e[68]!==M||e[69]!==i||e[70]!==he?(rt=i?Ie("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],he,Fe=>{M(Fe),en({sidebarWorktreeSortOrder:Fe})}):null,e[67]=Ie,e[68]=M,e[69]=i,e[70]=he,e[71]=rt):rt=e[71];let wt;e[72]!==Ie||e[73]!==je||e[74]!==Ee||e[75]!==i?(wt=i?Ie("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],je,Fe=>{Ee(Fe),en({sidebarProjectDisplayMode:Fe})}):null,e[72]=Ie,e[73]=je,e[74]=Ee,e[75]=i,e[76]=wt):wt=e[76];let se;e[77]!==Ve||e[78]!==rt||e[79]!==wt?(se=n.jsxs(n.Fragment,{children:[Ve,rt,wt]}),e[77]=Ve,e[78]=rt,e[79]=wt,e[80]=se):se=e[80],U.push(se)}if(a){let Ve;e[81]!==_||e[82]!==G?(Ve=()=>{_(!G),en({sidebarShowChatsSection:!G})},e[81]=_,e[82]=G,e[83]=Ve):Ve=e[83];let rt;e[84]!==G||e[85]!==Ve||e[86]!==Y?(rt=Y("sessions.sidebar.header.displayMode.showChats",G,Ve),e[84]=G,e[85]=Ve,e[86]=Y,e[87]=rt):rt=e[87];let wt;e[88]!==C||e[89]!==D?(wt=()=>{C(!D),en({sidebarShowPinnedSection:!D})},e[88]=C,e[89]=D,e[90]=wt):wt=e[90];let se;e[91]!==D||e[92]!==wt||e[93]!==Y?(se=Y("sessions.sidebar.header.displayMode.showPinned",D,wt),e[91]=D,e[92]=wt,e[93]=Y,e[94]=se):se=e[94];let Fe;e[95]!==q||e[96]!==E||e[97]!==$||e[98]!==Y?(Fe=q?Y("sessions.sidebar.header.displayMode.showWork",$,()=>{E(!$),en({sidebarShowWorkSection:!$})}):null,e[95]=q,e[96]=E,e[97]=$,e[98]=Y,e[99]=Fe):Fe=e[99];let ot;e[100]!==N||e[101]!==A||e[102]!==we||e[103]!==Y?(ot=we?null:Y("sessions.sidebar.header.displayMode.detailedZoneRows",N,()=>{A(!N),en({sidebarDetailedZoneRows:!N})}),e[100]=N,e[101]=A,e[102]=we,e[103]=Y,e[104]=ot):ot=e[104];let $e;e[105]!==se||e[106]!==Fe||e[107]!==ot||e[108]!==rt?($e=n.jsxs(n.Fragment,{children:[rt,se,Fe,ot]}),e[105]=se,e[106]=Fe,e[107]=ot,e[108]=rt,e[109]=$e):$e=e[109],U.push($e)}if(!Me){let Ve;e[110]===Symbol.for("react.memo_cache_sentinel")?(Ve=n.jsx(Z,{name:"contract-up-down",className:"h-4 w-4"}),e[110]=Ve):Ve=e[110];let rt;e[111]!==s?(rt=s("sessions.sidebar.header.displayMode.collapseAll"),e[111]=s,e[112]=rt):rt=e[112];let wt;e[113]!==rt?(wt=n.jsx("span",{children:rt}),e[113]=rt,e[114]=wt):wt=e[114];let se;e[115]!==v||e[116]!==wt?(se=n.jsxs(rs,{onClick:v,className:"flex items-center gap-2",children:[Ve,wt]}),e[115]=v,e[116]=wt,e[117]=se):se=e[117];let Fe;e[118]===Symbol.for("react.memo_cache_sentinel")?(Fe=n.jsx(Z,{name:"expand-up-down",className:"h-4 w-4"}),e[118]=Fe):Fe=e[118];let ot;e[119]!==s?(ot=s("sessions.sidebar.header.displayMode.expandAll"),e[119]=s,e[120]=ot):ot=e[120];let $e;e[121]!==ot?($e=n.jsx("span",{children:ot}),e[121]=ot,e[122]=$e):$e=e[122];let Ct;e[123]!==w||e[124]!==$e?(Ct=n.jsxs(rs,{onClick:w,className:"flex items-center gap-2",children:[Fe,$e]}),e[123]=w,e[124]=$e,e[125]=Ct):Ct=e[125];let Yt;e[126]!==se||e[127]!==Ct?(Yt=n.jsxs(n.Fragment,{children:[se,Ct]}),e[126]=se,e[127]=Ct,e[128]=Yt):Yt=e[128],U.push(Yt)}e[14]=Ie,e[15]=v,e[16]=N,e[17]=w,e[18]=Me,e[19]=ce,e[20]=je,e[21]=ee,e[22]=q,e[23]=A,e[24]=ne,e[25]=Ee,e[26]=Q,e[27]=_,e[28]=C,e[29]=E,e[30]=ie,e[31]=M,e[32]=G,e[33]=D,e[34]=i,e[35]=a,e[36]=$,e[37]=V,e[38]=s,e[39]=pe,e[40]=we,e[41]=Y,e[42]=he,e[43]=U}else U=e[43];if(o){let Ve;e[129]!==s?(Ve=s("sessions.sidebar.header.search.placeholder"),e[129]=s,e[130]=Ve):Ve=e[130];let rt;e[131]!==s?(rt=s("sessions.sidebar.header.search.clear"),e[131]=s,e[132]=rt):rt=e[132];let wt;e[133]!==S||e[134]!==m||e[135]!==s?(wt=S?m===1?s("sessions.sidebar.header.search.matchCountSingle",{count:m}):s("sessions.sidebar.header.search.matchCountPlural",{count:m}):void 0,e[133]=S,e[134]=m,e[135]=s,e[136]=wt):wt=e[136];let se;e[137]!==s?(se=s("sessions.sidebar.header.search.escapeHint"),e[137]=s,e[138]=se):se=e[138];let Fe;return e[139]!==g||e[140]!==b||e[141]!==x||e[142]!==y||e[143]!==se||e[144]!==Ve||e[145]!==rt||e[146]!==wt?(Fe=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(_c,{inputRef:b,value:x,onSearch:y,onClose:g,placeholder:Ve,clearLabel:rt,leadingHint:wt,trailingHint:se})}),e[139]=g,e[140]=b,e[141]=x,e[142]=y,e[143]=se,e[144]=Ve,e[145]=rt,e[146]=wt,e[147]=Fe):Fe=e[147],Fe}let ae;e[148]!==f||e[149]!==u||e[150]!==j||e[151]!==c||e[152]!==s?(ae=c?n.jsx(kr,{label:s("sourceBoard.title"),pressed:j,onClick:()=>le.getState().setSourceBoardOpen(!j),className:f,children:n.jsx(Z,{name:"git-pull-request",className:u})}):null,e[148]=f,e[149]=u,e[150]=j,e[151]=c,e[152]=s,e[153]=ae):ae=e[153];let Re;e[154]!==s?(Re=s("sessions.sidebar.header.actions.scheduledTasks"),e[154]=s,e[155]=Re):Re=e[155];let W;e[156]!==P?(W=()=>le.getState().setScheduledTasksDialogOpen(!P),e[156]=P,e[157]=W):W=e[157];let ye;e[158]!==u?(ye=n.jsx(Z,{name:"calendar-schedule",className:u}),e[158]=u,e[159]=ye):ye=e[159];let de;e[160]!==f||e[161]!==P||e[162]!==ye||e[163]!==Re||e[164]!==W?(de=n.jsx(kr,{label:Re,pressed:P,onClick:W,className:f,children:ye}),e[160]=f,e[161]=P,e[162]=ye,e[163]=Re,e[164]=W,e[165]=de):de=e[165];let Ne;e[166]!==s?(Ne=s("sessions.sidebar.nav.archive"),e[166]=s,e[167]=Ne):Ne=e[167];let Je;e[168]!==L?(Je=()=>le.getState().setArchivePageOpen(!L),e[168]=L,e[169]=Je):Je=e[169];let Ge;e[170]!==u?(Ge=n.jsx(Z,{name:"archive",className:u}),e[170]=u,e[171]=Ge):Ge=e[171];let ge;e[172]!==f||e[173]!==L||e[174]!==Ne||e[175]!==Je||e[176]!==Ge?(ge=n.jsx(kr,{label:Ne,pressed:L,onClick:Je,className:f,children:Ge}),e[172]=f,e[173]=L,e[174]=Ne,e[175]=Je,e[176]=Ge,e[177]=ge):ge=e[177];let Ae;e[178]!==H||e[179]!==f||e[180]!==u||e[181]!==z||e[182]!==s?(Ae=H?null:n.jsx(kr,{label:s("integrationsCatalog.sidebar.open"),pressed:z,onClick:()=>le.getState().setIntegrationsCatalogOpen(!z),className:f,children:n.jsx(Z,{name:"store-2",className:u})}),e[178]=H,e[179]=f,e[180]=u,e[181]=z,e[182]=s,e[183]=Ae):Ae=e[183];let Ye;e[184]!==de||e[185]!==ge||e[186]!==Ae||e[187]!==ae?(Ye=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[ae,de,ge,Ae]}),e[184]=de,e[185]=ge,e[186]=Ae,e[187]=ae,e[188]=Ye):Ye=e[188];let nt;e[189]!==r||e[190]!==B||e[191]!==f||e[192]!==u||e[193]!==R||e[194]!==s?(nt=B?r.map(Ve=>{const rt=R===Ve.id;return n.jsx(kr,{label:Ve.pageTitle??Ve.name,pressed:rt,onClick:()=>le.getState().setOpenGuestPage(rt?null:Ve.id),className:f,children:n.jsx(yr,{icon:hp(Ve.icon),iconSrc:pp(Ve.id,Ve.icon,ef().authenticatedAsset),className:u})},Ve.id)}):r.length>0&&n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(Nt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx(Z,{name:"puzzle",className:u})})}),n.jsxs(Ms,{align:"start",children:[n.jsx(Ma,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map($3)]})]}),e[189]=r,e[190]=B,e[191]=f,e[192]=u,e[193]=R,e[194]=s,e[195]=nt):nt=e[195];let oe;e[196]!==Ye||e[197]!==nt?(oe=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[Ye,nt]}),e[196]=Ye,e[197]=nt,e[198]=oe):oe=e[198];const tt=p?g:h,Ue=p?em:tm;let gt;e[199]!==f||e[200]!==Ue?(gt=Pe(f,Ue),e[199]=f,e[200]=Ue,e[201]=gt):gt=e[201];let bt;e[202]!==s?(bt=s("sessions.sidebar.header.actions.searchSessions"),e[202]=s,e[203]=bt):bt=e[203];let Ce;e[204]!==u?(Ce=n.jsx(Z,{name:"search",className:u}),e[204]=u,e[205]=Ce):Ce=e[205];let _e;e[206]!==p||e[207]!==tt||e[208]!==gt||e[209]!==bt||e[210]!==Ce?(_e=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:tt,className:gt,"aria-label":bt,"aria-expanded":p,children:Ce})}),e[206]=p,e[207]=tt,e[208]=gt,e[209]=bt,e[210]=Ce,e[211]=_e):_e=e[211];let ze;e[212]!==s?(ze=s("sessions.sidebar.header.actions.searchSessions"),e[212]=s,e[213]=ze):ze=e[213];let Oe;e[214]!==ze?(Oe=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:ze})}),e[214]=ze,e[215]=Oe):Oe=e[215];let it;e[216]!==_e||e[217]!==Oe?(it=n.jsxs(Ut,{children:[_e,Oe]}),e[216]=_e,e[217]=Oe,e[218]=it):it=e[218];let X;e[219]!==f?(X=Pe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[219]=f,e[220]=X):X=e[220];let Be;e[221]!==s?(Be=s("sessions.sidebar.header.actions.addProject"),e[221]=s,e[222]=Be):Be=e[222];let Le;e[223]!==u?(Le=n.jsx(Z,{name:"folder-add",className:u}),e[223]=u,e[224]=Le):Le=e[224];let at;e[225]!==d||e[226]!==X||e[227]!==Be||e[228]!==Le?(at=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:X,"aria-label":Be,children:Le})}),e[225]=d,e[226]=X,e[227]=Be,e[228]=Le,e[229]=at):at=e[229];let qe;e[230]!==s?(qe=s("sessions.sidebar.header.actions.addProject"),e[230]=s,e[231]=qe):qe=e[231];let ut;e[232]!==qe?(ut=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:qe})}),e[232]=qe,e[233]=ut):ut=e[233];let dt;e[234]!==at||e[235]!==ut?(dt=n.jsxs(Ut,{children:[at,ut]}),e[234]=at,e[235]=ut,e[236]=dt):dt=e[236];let ft;e[237]!==f?(ft=Pe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[237]=f,e[238]=ft):ft=e[238];let st;e[239]!==s?(st=s("sessions.sidebar.header.displayMode.label"),e[239]=s,e[240]=st):st=e[240];let Rt;e[241]!==u?(Rt=n.jsx(Z,{name:"equalizer-2",className:u}),e[241]=u,e[242]=Rt):Rt=e[242];let Ke;e[243]!==ft||e[244]!==st||e[245]!==Rt?(Ke=n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:ft,"aria-label":st,children:Rt})})}),e[243]=ft,e[244]=st,e[245]=Rt,e[246]=Ke):Ke=e[246];let jt;e[247]!==s?(jt=s("sessions.sidebar.header.displayMode.label"),e[247]=s,e[248]=jt):jt=e[248];let Lt;e[249]!==jt?(Lt=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:jt})}),e[249]=jt,e[250]=Lt):Lt=e[250];let Mt;e[251]!==Ke||e[252]!==Lt?(Mt=n.jsxs(Ut,{children:[Ke,Lt]}),e[251]=Ke,e[252]=Lt,e[253]=Mt):Mt=e[253];let De;e[254]!==U?(De=n.jsx(Ms,{align:"end",className:"min-w-[200px]",children:U.map(L3)}),e[254]=U,e[255]=De):De=e[255];let Tt;e[256]!==Mt||e[257]!==De?(Tt=n.jsxs(Rs,{children:[Mt,De]}),e[256]=Mt,e[257]=De,e[258]=Tt):Tt=e[258];let At;e[259]!==it||e[260]!==dt||e[261]!==Tt?(At=n.jsxs("div",{ref:I,className:"flex min-w-0 items-center gap-1.5",children:[it,dt,Tt]}),e[259]=it,e[260]=dt,e[261]=Tt,e[262]=At):At=e[262];let kt;e[263]!==oe||e[264]!==At?(kt=n.jsxs("div",{ref:T,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[oe,At]}),e[263]=oe,e[264]=At,e[265]=kt):kt=e[265];let pt;e[266]!==g||e[267]!==S||e[268]!==p||e[269]!==m||e[270]!==b||e[271]!==x||e[272]!==y||e[273]!==s?(pt=p?n.jsx("div",{className:"pb-1",children:n.jsx(_c,{inputRef:b,value:x,onSearch:y,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:S?m===1?s("sessions.sidebar.header.search.matchCountSingle",{count:m}):s("sessions.sidebar.header.search.matchCountPlural",{count:m}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[266]=g,e[267]=S,e[268]=p,e[269]=m,e[270]=b,e[271]=x,e[272]=y,e[273]=s,e[274]=pt):pt=e[274];let Dt;return e[275]!==kt||e[276]!==pt?(Dt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:n.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[kt,pt]})}),e[275]=kt,e[276]=pt,e[277]=Dt):Dt=e[277],Dt}function L3(t,e){return n.jsxs(l.Fragment,{children:[e>0?n.jsx(In,{}):null,t]},e)}function $3(t){return n.jsxs(rs,{onSelect:()=>le.getState().setOpenGuestPage(t.id),children:[n.jsx(yr,{icon:hp(t.icon),iconSrc:pp(t.id,t.icon,ef().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function z3(t){return t.setProjectDisplayMode}function K3(t){return t.projectDisplayMode}function W3(t){return t.setListSessionGrouping}function H3(t){return t.listSessionGrouping}function U3(t){return t.setSidebarViewMode}function V3(t){return t.sidebarViewMode}function G3(t){return t.setWorktreeSortOrder}function q3(t){return t.worktreeSortOrder}function Y3(t){return t.setProjectSortOrder}function Z3(t){return t.projectSortOrder}function Q3(t){return t.sessionWorkEnabled}function X3(t){return t.setDetailedZoneRows}function J3(t){return t.detailedZoneRows}function e4(t){return t.setShowPinnedSection}function t4(t){return t.showPinnedSection}function s4(t){return t.setShowWorkSection}function n4(t){return t.showWorkSection}function r4(t){return t.setShowChatsSection}function o4(t){return t.showChatsSection}function i4(t){return t.openGuestPageId}function a4(t){return t.isIntegrationsCatalogOpen}function l4(t){return t.isArchivePageOpen}function c4(t){return t.isScheduledTasksDialogOpen}function d4(t){return t.isSourceBoardOpen}function u4(t){return t.toggleMode}function f4(t){return t.enabled}function p4(t){const e=Ze.c(2),{className:s}=t,[r]=l.useState(h4);if(!r)return null;let o;return e[0]!==s?(o=n.jsx(m4,{className:s}),e[0]=s,e[1]=o):o=e[1],o}function h4(){return hn()}function m4({className:t}){const{t:e}=Et(),s=le(k=>k.shortcutOverrides),[r,o]=l.useState(!1),[i,a]=l.useState("Local"),[d,c]=l.useState(!0),[u,f]=l.useState(!1),[p,h]=l.useState(null),[g,b]=l.useState(!1),[x,y]=l.useState(null),S=l.useCallback(async()=>{if(li()){a("Local"),c(!0);return}const k=await ci().then(B=>Pc(B.hosts,B.localOrigin)).catch(()=>Pc([],Vg())),I=Gg(k);if(I.id===qg){a("Local"),c(!0);return}c(!1),a(tf(I.label.trim()||"Instance"))},[]);l.useEffect(()=>(S(),ri(()=>{S()})),[S]);const m=l.useCallback(async()=>{if(d){h(null),y(null);return}b(!0),y(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),I=await Ys(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!I.ok)throw new Error(`Server responded with ${I.status}`);h(Jb(await I.json()))}catch(k){h(null),y(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{b(!1)}},[d,e]);l.useEffect(()=>{h(null),y(null),f(!1)},[d,i]),l.useEffect(()=>{if(d)return;const k=3e3,I=3600*1e3;let B=!1,O=null;const F=j=>{O=window.setTimeout(()=>{if(B||typeof document<"u"&&document.visibilityState!=="visible"){F(I);return}m().finally(()=>{B||F(I)})},j)};return F(k),()=>{B=!0,O!==null&&window.clearTimeout(O)}},[m,d,i]);const v=l.useCallback(()=>{if(p?.available){f(!0);return}m()},[m,p?.available]),w=l.useCallback(k=>{o(k),k&&S()},[S]);Kf({toggle_services_menu:()=>{if(r){o(!1);return}const k=le.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const T=Hf(Uf("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(Rs,{open:r,onOpenChange:w,children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":e("header.services.openWithCurrent",{current:i}),className:t,children:[n.jsx(Z,{name:"server",className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate typography-ui-label",children:i})]})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:i,toggle:T})})})]}),n.jsxs(Ms,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[d?null:n.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:e("header.services.remoteUpdate.title")}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:p?.available?e("header.services.remoteUpdate.available",{version:p.version||""}):g?e("header.services.remoteUpdate.checking"):x||e("header.services.remoteUpdate.upToDate")})]}),p?.available?n.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:v,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(D1,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>o(!1)})]})]}),n.jsx(jl,{open:u,onOpenChange:f,info:p,downloading:!1,downloaded:!1,progress:null,error:x,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Cr="inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",g4="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function b4(t){const e=Ze.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:d}=t,c=a===void 0?!0:a,u=d===void 0?!0:d,{t:f}=Et(),p=ey(),h=le(y4);if(!c&&!u)return null;let g;e[0]!==p||e[1]!==f?(g=f(p?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=p,e[1]=f,e[2]=g):g=e[2];const b=g;let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=Pe(Cr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=x):x=e[3];let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(Z,{name:"download",className:"h-4 w-4"}),e[4]=y):y=e[4];let S;e[5]!==i||e[6]!==b?(S=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:x,"aria-label":b,children:y})}),e[5]=i,e[6]=b,e[7]=S):S=e[7];let m;e[8]!==b?(m=n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:b})}),e[8]=b,e[9]=m):m=e[9];let v;e[10]!==S||e[11]!==m?(v=n.jsxs(Ut,{children:[S,m]}),e[10]=S,e[11]=m,e[12]=v):v=e[12];const w=v;let T;e[13]!==h||e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==f||e[20]!==w?(T=c?n.jsxs(n.Fragment,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx(Z,{name:"settings-3",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>le.getState().setUsageStatsPageOpen(!h),className:Pe(Cr,h&&g4),"aria-label":f("usageStats.openAction"),"aria-pressed":h,children:n.jsx(Z,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx(Z,{name:"command",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:Cr,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx(Z,{name:"information",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=h,e[14]=o,e[15]=s,e[16]=r,e[17]=c,e[18]=u,e[19]=f,e[20]=w,e[21]=T):T=e[21];const k=!c&&u?w:null;let I;e[22]!==c?(I=c?n.jsx(p4,{className:"ms-auto inline-flex h-6 min-w-0 max-w-[12rem] items-center gap-1.5 rounded-md px-2 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}):null,e[22]=c,e[23]=I):I=e[23];let B;return e[24]!==k||e[25]!==I||e[26]!==T?(B=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[T,k,I]}),e[24]=k,e[25]=I,e[26]=T,e[27]=B):B=e[27],B}function y4(t){return t.isUsageStatsPageOpen}function x4(t){const e=Ze.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=Et();let a;e[0]!==s||e[1]!==o?(a=()=>{le.getState().setArchivePageOpen(!0,s),o()},e[0]=s,e[1]=o,e[2]=a):a=e[2];const d=a;let c;e[3]!==i?(c=i("sessions.sidebar.empty.noMatches.title"),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==c?(u=n.jsx("p",{className:"typography-ui-label font-semibold",children:c}),e[5]=c,e[6]=u):u=e[6];let f;e[7]!==i?(f=i("sessions.sidebar.empty.noMatches.description"),e[7]=i,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=p):p=e[10];let h;e[11]!==d||e[12]!==r||e[13]!==i?(h=r?n.jsx(Nt,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:d,children:i("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=d,e[12]=r,e[13]=i,e[14]=h):h=e[14];let g;return e[15]!==u||e[16]!==p||e[17]!==h?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,p,h]}),e[15]=u,e[16]=p,e[17]=h,e[18]=g):g=e[18],g}const S4=t=>{for(const e of t.sessions.values())if(e.tabs.some(sf))return!0;return!1},w4=()=>{const t=Ze.c(4),{terminal:e}=Ks(),s=zt(S4);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=v4,a=j4;if(s)return Ta(e,"",a,i);let d=k4;return d=Ta(e,"",a,c=>{i(c),d()}),()=>d()},o=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o),null};function v4(t){const e=zt.getState(),s=ty(t.sessions),r=new Set([...e.sessions.keys(),...s.keys()]);for(const o of r)e.reconcileServerSessions(o,s.get(o)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function j4(){return new Map(zt.getState().actionMutationRevisions)}function k4(){}const C4=50,I4=t=>{const e=new Map;for(const s of t){const r=yt(s.directory),o=s.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===C4))break}return[...e.values()]},iu=(t,e,s,r)=>{for(const[o,i]of t)i===e&&s.has(o)||(r(i,o),t.delete(o));for(const o of s)t.set(o,e)},P4=t=>{const e=Ze.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:a,isWorktreeTopologyLoading:d,unresolvedWorktreeProjectPaths:c,foldersMap:u,createFolder:f,addSessionToFolder:p}=t,h=r===void 0?!0:r;let g,b;e[0]!==p||e[1]!==f||e[2]!==h||e[3]!==u||e[4]!==a||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==c?(g=()=>{!h||i||!a||d||s.forEach(x=>{if(c.has(x.normalizedPath))return;const y=yp(x.normalizedPath),S=o.archivedSessionsByProject.get(x.id)??[],m=u[y]??[],v=new Map(m.map(E4));S.forEach(w=>{const T=R1(w,x.normalizedPath),k=T.toLowerCase();let I=v.get(k);I||(I=f(y,T,null,`archived:${y}:${k}`),v.set(k,I)),I.sessionIds.includes(w.id)||p(y,I.id,w.id)})})},b=[s,h,o,i,a,d,c,u,f,p],e[0]=p,e[1]=f,e[2]=h,e[3]=u,e[4]=a,e[5]=i,e[6]=d,e[7]=s,e[8]=o,e[9]=c,e[10]=g,e[11]=b):(g=e[10],b=e[11]),l.useEffect(g,b)};function E4(t){return[t.name.toLowerCase(),t]}function T4({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:a}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(o.entries()).some(([f,p])=>f!==t&&p.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const c=(i&&r.has(i)?i:null)??a;return!c||c===e?{kind:"none"}:{kind:"select-session",sessionId:c}}const D4=t=>{const e=Ze.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:a,currentSessionOwnerProjectId:d,handleSessionSelect:c,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:p,setSessionSwitcherOpen:h}=t;let g,b;if(e[0]!==s){b=new Map,g=new Map;const k=(I,B,O,F)=>{b.has(I)||b.set(I,new Map);const j=b.get(I);F.forEach(P=>{const L=yt(P.worktree?.path??P.session.directory??O??B);j.set(P.session.id,{directory:L}),g.has(I)||g.set(I,{id:P.session.id,directory:L}),P.children.length>0&&k(I,B,L,P.children)})};s.forEach(I=>{I.groups.forEach(B=>{k(I.project.id,I.project.normalizedPath,B.directory,B.sessions)})}),e[0]=s,e[1]=g,e[2]=b}else g=e[1],b=e[2];let x;e[3]!==g||e[4]!==b?(x={metaByProject:b,firstSessionByProject:g},e[3]=g,e[4]=b,e[5]=x):x=e[5];const y=x,S=l.useRef(null);let m,v;e[6]!==r||e[7]!==o||e[8]!==a||e[9]!==d||e[10]!==c||e[11]!==f||e[12]!==u||e[13]!==p||e[14]!==s||e[15]!==y||e[16]!==i||e[17]!==h?(m=()=>{if(!r||u||le.getState().isNewWorktreeDialogOpen||S.current===r)return;const k=s.find(F=>F.project.id===r);if(!k)return;if(S.current===null){S.current=r;return}const I=y.metaByProject.get(r);if(a&&I&&I.has(a)){S.current=r,i(F=>{if(F.get(r)===a)return F;const j=new Map(F);return j.set(r,a),j});return}const B=T4({activeProjectId:r,currentSessionId:a,currentSessionOwnerProjectId:d,projectMap:I,metaByProject:y.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(B.kind==="preserve-current"){d===r&&(S.current=r);return}if(S.current=r,B.kind==="open-draft"){f&&h(!1),p({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(B.kind!=="select-session")return;const O=I?.get(B.sessionId)?.directory??null;c(B.sessionId,O)},v=[r,o,a,d,c,u,f,p,s,y,h,i],e[6]=r,e[7]=o,e[8]=a,e[9]=d,e[10]=c,e[11]=f,e[12]=u,e[13]=p,e[14]=s,e[15]=y,e[16]=i,e[17]=h,e[18]=m,e[19]=v):(m=e[18],v=e[19]),l.useLayoutEffect(m,v);let w,T;e[20]!==r||e[21]!==a||e[22]!==y||e[23]!==i?(w=()=>{if(!r||!a)return;const k=y.metaByProject.get(r);!k||!k.has(a)||i(I=>{if(I.get(r)===a)return I;const B=new Map(I);return B.set(r,a),B})},T=[r,a,y,i],e[20]=r,e[21]=a,e[22]=y,e[23]=i,e[24]=w,e[25]=T):(w=e[24],T=e[25]),l.useEffect(w,T)},R4=t=>{const e=Ze.c(20);let s,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...s}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);const a=mt(N4),d=mt(M4);let c;e[5]!==a||e[6]!==i?(c=a?i?.get(a)?.projectId??null:null,e[5]=a,e[6]=i,e[7]=c):c=e[7];const u=c;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[p,h]=l.useState(f);let g;e[10]!==p||e[11]!==s||e[12]!==a||e[13]!==u||e[14]!==d?(g={...s,activeSessionByProject:p,setActiveSessionByProject:h,currentSessionId:a,currentSessionOwnerProjectId:u,newSessionDraftOpen:d},e[10]=p,e[11]=s,e[12]=a,e[13]=u,e[14]=d,e[15]=g):g=e[15],D4(g);let b,x;return e[16]!==p||e[17]!==o?(b=()=>{o(p)},x=[p,o],e[16]=p,e[17]=o,e[18]=b,e[19]=x):(b=e[18],x=e[19]),l.useEffect(b,x),null};function N4(t){return t.currentSessionId}function M4(t){return!!t.newSessionDraft?.open}const A4=t=>{const e=Ze.c(7),{ownership:s}=t;let r;e[0]!==s?(r=c=>s.sessionsByProject.get(c)??[],e[0]=s,e[1]=r):r=e[1];const o=r;let i;e[2]!==s?(i=c=>s.archivedSessionsByProject.get(c)??[],e[2]=s,e[3]=i):i=e[3];const a=i;let d;return e[4]!==a||e[5]!==o?(d={getSessionsForProject:o,getArchivedSessionsForProject:a},e[4]=a,e[5]=o,e[6]=d):d=e[6],d},O4=(t,e)=>t.map(s=>{const r=yt(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
366
+ `),B4=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),F4=[],_4=new WeakMap,L4=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:a,gitBranches:d,sessionOrderRanks:c,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:x,standaloneGroups:y}=t,S=l.useRef(new Map),m=l.useMemo(()=>{const F=S.current,j=new Map;let P=0,L=0;const z=(R,G)=>R.length===G.length&&R.every((_,$)=>_===G[$]),H=e.map(R=>{const G=s(R.id),_=r(R.id),$=o.get(R.normalizedPath)??F4,E=i.has(R.id)?!!i.get(R.id):u,D=a.get(R.id)??null,C=O4($,d),N=B4(G,$,c),A=F.get(R.id);if(A&&A.project===R&&z(A.activeSessions,G)&&z(A.archivedSessions,_)&&A.availableWorktrees===$&&A.rootBranch===D&&A.worktreeBranchesKey===C&&A.worktreeRanksKey===N&&A.isRepo===E&&A.buildGroupedSessions===f)return P+=1,j.set(R.id,A),A.section;if(L+=1,A){const he=A.project!==R?"project":z(A.activeSessions,G)?z(A.archivedSessions,_)?A.availableWorktrees!==$?"worktrees":A.rootBranch!==D?"branch":A.worktreeBranchesKey!==C?"worktreeBranches":A.worktreeRanksKey!==N?"worktreeRanks":A.isRepo!==E?"repo":"builder":"archived":"sessions";As(`ui.sidebar.project_section.rebuilt_reason.${he}`)}const q=xp([...G,..._]),ee=f(q,R.normalizedPath,$,D,E),Q={project:R,groups:ee};return j.set(R.id,{project:R,activeSessions:G,archivedSessions:_,availableWorktrees:$,rootBranch:D,worktreeBranchesKey:C,worktreeRanksKey:N,isRepo:E,buildGroupedSessions:f,section:Q}),Q});return S.current=j,P>0&&As("ui.sidebar.project_section.reused",P),L>0&&As("ui.sidebar.project_section.rebuilt",L),H},[e,s,r,o,i,u,f,a,d,c]),v=l.useMemo(()=>m,[m]),w=l.useMemo(()=>{if(!p)return _4;const F=new WeakMap,P=h.trim().toLowerCase().startsWith("ses_"),L=z=>{const H=g(z.sessions,h),R=Qh(H,h),G=!P&&$o([b(z)],h),_=zn(z).flatMap(({scopeKey:E})=>x[E]??[]),$=P?0:_.filter(E=>$o([E.name],h)).length;F.set(z,{filteredNodes:H,matchedSessionCount:R,folderNameMatchCount:$,groupMatches:G,hasMatch:G||R>0||$>0})};return v.forEach(z=>{z.groups.forEach(L)}),y.forEach(L),F},[p,v,y,g,h,b,x]),T=l.useMemo(()=>p?v.map(F=>({...F,groups:F.groups.filter(j=>w.get(j)?.hasMatch===!0)})).filter(F=>F.groups.length>0):v,[p,v,w]),k=p?T:v,I=l.useRef(new WeakMap),B=l.useMemo(()=>{const F=I.current;return k.map(j=>{const P=F.get(j);if(P&&P.query===h)return P.section;const L=j.groups.filter(E=>!E.isArchivedBucket),z=j.groups.filter(E=>E.isArchivedBucket),H=L.flatMap(E=>p?w.get(E)?.filteredNodes??[]:E.sessions),R=L.map(E=>({scopeKey:E.folderScopeKey??yt(E.directory??null),directory:E.directory??null})).filter(E=>!!E.scopeKey),G=L.find(E=>E.isMain)??null,_={id:"flat",label:G?.label??"",branch:G?.branch??null,description:G?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:G?.directory??j.project.normalizedPath,folderScopeKey:G?.folderScopeKey??j.project.normalizedPath,folderScopes:R,sessions:H};if(p){const E=L.map(D=>w.get(D)).filter(D=>!!D);w.set(_,{filteredNodes:H,matchedSessionCount:E.reduce((D,C)=>D+C.matchedSessionCount,0),folderNameMatchCount:E.reduce((D,C)=>D+C.folderNameMatchCount,0),groupMatches:E.some(D=>D.groupMatches),hasMatch:E.some(D=>D.hasMatch)})}const $={project:j.project,groups:[_,...z]};return F.set(j,{query:h,section:$}),$})},[w,p,h,k]),O=l.useMemo(()=>{if(!p)return 0;const F=(P,L)=>{const z=w.get(L);if(!z)return P;const H=z.folderNameMatchCount+(z.groupMatches?1:0);return P+z.matchedSessionCount+H},j=k.reduce((P,L)=>L.groups.reduce(F,P),0);return y.reduce(F,j)},[p,k,y,w]);return{projectSections:m,visibleProjectSections:v,groupSearchDataByGroup:w,searchableProjectSections:T,sectionsForRender:k,flatSectionsForRender:B,searchMatchCount:O}},$4=180,au=150,z4=2,K4=8,lu=[-1,1],mo=t=>`${t.directory}
367
+ ${t.sessionId}`,cu=t=>t?.directory?.trim()||null,sm=l.createContext(null),W4=()=>l.useContext(sm),H4=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),a=l.useRef(new Set),d=l.useRef([]),c=l.useRef(new Set),u=l.useRef(0),f=l.useMemo(()=>Dn(),[]),p=l.useCallback(()=>{u.current+=1,d.current=[],i.current.forEach(S=>window.clearTimeout(S)),i.current.clear(),a.current.clear()},[]),h=l.useCallback(()=>{if(!(!t||f))for(;c.current.size<z4&&d.current.length>0;){const S=d.current.shift();if(!S)break;if(S.generation!==u.current||mt.getState().currentSessionId===S.sessionId||Ba(S.sessionId,S.directory).renderable)continue;const v=mo(S);c.current.add(v),o({directory:S.directory,sessionID:S.sessionId}).catch(()=>{}).finally(()=>{c.current.delete(v),h()})}},[t,f,o]),g=l.useCallback((S,m="neighbor")=>{const v=S?.id,w=cu(S);if(!t||f||!v||!w||v===e)return;const T={sessionId:v,directory:w,generation:u.current},k=mo(T);if(Ba(v,w).renderable||c.current.has(k)||d.current.some(O=>mo(O)===k))return;const I=i.current.get(k);if(I!==void 0){if(m==="hover"&&!a.current.has(k))return;window.clearTimeout(I)}m==="hover"?a.current.add(k):a.current.delete(k);const B=window.setTimeout(()=>{if(i.current.delete(k),a.current.delete(k),T.generation!==u.current)return;const O=d.current;O.length>=K4&&O.shift(),O.push(T),h()},$4);i.current.set(k,B)},[e,t,f,h]),b=l.useCallback(S=>{const m=cu(S);if(!m)return;const v=mo({sessionId:S.id,directory:m}),w=i.current.get(v);w===void 0||!a.current.has(v)||(window.clearTimeout(w),i.current.delete(v),a.current.delete(v))},[]),x=l.useRef(g);x.current=g;const[y]=l.useState(()=>({schedule:S=>x.current(S,"hover"),cancel:b}));return l.useEffect(()=>{p()},[p,e,t,f]),l.useEffect(()=>{if(!t||f||!e||s.length===0)return;const S=window.setTimeout(()=>{const m=s.findIndex(v=>v.id===e);if(!(m<0))for(const v of lu)g(s[m+v])},au);return()=>window.clearTimeout(S)},[e,t,f,g,s]),l.useEffect(()=>{if(!t||f||!e||r.length===0)return;const S=window.setTimeout(()=>{const m=r.findIndex(v=>v.id===e);if(!(m<0))for(const v of lu)g(r[m+v])},au);return()=>window.clearTimeout(S)},[e,t,f,r,g]),l.useEffect(()=>p,[p]),y},U4=t=>{const e=Ze.c(11);let s,r;e[0]!==t?({children:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=mt(V4);let i;e[3]!==s||e[4]!==o?(i={...s,currentSessionId:o},e[3]=s,e[4]=o,e[5]=i):i=e[5];const a=H4(i);let d;if(e[6]!==r||e[7]!==a){let c;e[9]!==a?(c={value:a},e[9]=a,e[10]=c):c=e[10],d=l.createElement(sm.Provider,c,r),e[6]=r,e[7]=a,e[8]=d}else d=e[8];return d};function V4(t){return t.currentSessionId}const G4=t=>{const e=Ze.c(92),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:a,collapsedActivityState:d,onToggle:c,onRename:u,onDelete:f,children:p,renderBody:h,mobileVariant:g,alwaysShowActions:b,isRenaming:x,renameDraft:y,onRenameDraftChange:S,onRenameSave:m,onRenameCancel:v,droppableRef:w,isDropTarget:T,onNewSession:k,depth:I,canExpand:B,hideActions:O,archivedBucket:F}=t,j=d===void 0?null:d,P=h===void 0?!0:h,z=b===void 0?g===void 0?!1:g:b,H=x===void 0?!1:x,R=y===void 0?"":y,G=T===void 0?!1:T,_=I===void 0?0:I,$=B===void 0?!0:B,E=O===void 0?!1:O,D=F===void 0?!1:F,{t:C}=Et(),[N,A]=l.useState(!1),[q,ee]=l.useState(""),Q=l.useRef(null),he=H||N,M=H?R:q;let V;e[0]!==s.name?(V=()=>{ee(s.name),A(!0)},e[0]=s.name,e[1]=V):V=e[1];const ie=V;let ce;e[2]!==M||e[3]!==s.name||e[4]!==H||e[5]!==u||e[6]!==m?(ce=()=>{const Ue=M.trim();Ue&&Ue!==s.name&&u(Ue),H&&m&&m(),A(!1),ee("")},e[2]=M,e[3]=s.name,e[4]=H,e[5]=u,e[6]=m,e[7]=ce):ce=e[7];const ne=ce;let je;e[8]!==H||e[9]!==v?(je=()=>{H&&v&&v(),A(!1),ee("")},e[8]=H,e[9]=v,e[10]=je):je=e[10];const Ee=je;let we;e[11]!==H||e[12]!==S?(we=Ue=>{H&&S?S(Ue):ee(Ue)},e[11]=H,e[12]=S,e[13]=we):we=e[13];const Me=we;let fe,be;e[14]!==H?(fe=()=>{if(!H)return;const Ue=()=>{const Ce=Q.current;Ce&&(Ce.focus(),Ce.select())},gt=requestAnimationFrame(Ue),bt=window.setTimeout(Ue,0);return()=>{cancelAnimationFrame(gt),window.clearTimeout(bt)}},be=[H],e[14]=H,e[15]=fe,e[16]=be):(fe=e[15],be=e[16]),l.useEffect(fe,be);const ke=a?"folder":"folder-open",Ie=!he&&$;let Te;e[17]!==_?(Te=Kn(_),e[17]=_,e[18]=Te):Te=e[18];let Y;e[19]!==Te?(Y={paddingInlineStart:Te},e[19]=Te,e[20]=Y):Y=e[20];const ue=G&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let me;e[21]!==ue?(me=Pe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ue),e[21]=ue,e[22]=me):me=e[22];let re;e[23]!==c||e[24]!==Ie?(re=Ie?Ue=>{Ue.currentTarget.blur(),c()}:void 0,e[23]=c,e[24]=Ie,e[25]=re):re=e[25];const pe=Ie?"button":void 0,U=Ie?0:void 0;let ae;e[26]!==c||e[27]!==Ie?(ae=Ie?Ue=>{(Ue.key==="Enter"||Ue.key===" ")&&(Ue.preventDefault(),c())}:void 0,e[26]=c,e[27]=Ie,e[28]=ae):ae=e[28];let Re;e[29]!==s.name||e[30]!==a||e[31]!==C||e[32]!==Ie?(Re=Ie?a?C("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):C("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=a,e[31]=C,e[32]=Ie,e[33]=Re):Re=e[33];const W=D?z?"pe-7":"group-hover/folder:pe-7 group-has-[:focus-visible]/folder:pe-7":z?"pe-20":"group-hover/folder:pe-20 group-has-[:focus-visible]/folder:pe-20";let ye;e[34]!==W?(ye=Pe("min-w-0 flex items-center gap-0.5 flex-1",W),e[34]=W,e[35]=ye):ye=e[35];let de;e[36]!==$||e[37]!==a?(de=$?n.jsx(eo,{expanded:!a}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=$,e[37]=a,e[38]=de):de=e[38];const Ne=G?"text-primary":"text-muted-foreground";let Je;e[39]!==Ne?(Je=Pe("mx-px h-3 w-3 flex-shrink-0",Ne),e[39]=Ne,e[40]=Je):Je=e[40];let Ge;e[41]!==ke||e[42]!==Je?(Ge=n.jsx(Z,{name:ke,className:Je}),e[41]=ke,e[42]=Je,e[43]=Ge):Ge=e[43];let ge;e[44]!==j||e[45]!==r||e[46]!==M||e[47]!==s.name||e[48]!==Ee||e[49]!==Me||e[50]!==ne||e[51]!==G||e[52]!==he||e[53]!==o||e[54]!==C?(ge=he?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:q4,onMouseDown:Y4,onSubmit:Ue=>{Ue.preventDefault(),ne()},children:[n.jsx("input",{ref:Q,value:M,onChange:Ue=>Me(Ue.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:C("sessions.sidebar.folderItem.namePlaceholder"),onClick:Z4,onPointerDown:Q4,onMouseDown:X4,onKeyDown:Ue=>{if(Ue.key==="Escape"){Ue.stopPropagation(),Ee();return}(Ue.key===" "||Ue.key==="Enter")&&Ue.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:J4,onPointerDown:e5,onMouseDown:t5,children:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),Ee()},onPointerDown:s5,onMouseDown:n5,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx(Z,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("span",{className:Pe("typography-ui-label font-medium truncate",G?"text-primary":"text-foreground/85"),children:r??s.name})}),n.jsx(Kt,{side:"top",sideOffset:6,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),j?n.jsx(sy,{state:j}):null]}),e[44]=j,e[45]=r,e[46]=M,e[47]=s.name,e[48]=Ee,e[49]=Me,e[50]=ne,e[51]=G,e[52]=he,e[53]=o,e[54]=C,e[55]=ge):ge=e[55];let Ae;e[56]!==ye||e[57]!==de||e[58]!==Ge||e[59]!==ge?(Ae=n.jsxs("div",{className:ye,children:[de,Ge,ge]}),e[56]=ye,e[57]=de,e[58]=Ge,e[59]=ge,e[60]=Ae):Ae=e[60];let Ye;e[61]!==z||e[62]!==D||e[63]!==s.name||e[64]!==ie||e[65]!==E||e[66]!==f||e[67]!==k||e[68]!==he||e[69]!==C?(Ye=!he&&(!E||D)?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",z?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-has-[:focus-visible]/folder:opacity-100 group-has-[:focus-visible]/folder:pointer-events-auto"),children:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!D&&k?n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),k()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":C("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:C("sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,D?null:n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),ie()},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":C("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx(Z,{name:"pencil-ai",className:"h-3 w-3"})}),n.jsx("button",{type:"button",onClick:Ue=>{Ue.stopPropagation(),f()},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":D?C("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):C("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Z,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=z,e[62]=D,e[63]=s.name,e[64]=ie,e[65]=E,e[66]=f,e[67]=k,e[68]=he,e[69]=C,e[70]=Ye):Ye=e[70];let nt;e[71]!==w||e[72]!==Y||e[73]!==me||e[74]!==re||e[75]!==pe||e[76]!==U||e[77]!==ae||e[78]!==Re||e[79]!==Ae||e[80]!==Ye?(nt=n.jsxs("div",{ref:w,style:Y,className:me,onClick:re,role:pe,tabIndex:U,onKeyDown:ae,"aria-label":Re,children:[Ae,Ye]}),e[71]=w,e[72]=Y,e[73]=me,e[74]=re,e[75]=pe,e[76]=U,e[77]=ae,e[78]=Re,e[79]=Ae,e[80]=Ye,e[81]=nt):nt=e[81];let oe;e[82]!==p||e[83]!==a||e[84]!==P||e[85]!==o||e[86]!==i||e[87]!==C?(oe=!a&&P?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?p:i?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:C("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=p,e[83]=a,e[84]=P,e[85]=o,e[86]=i,e[87]=C,e[88]=oe):oe=e[88];let tt;return e[89]!==nt||e[90]!==oe?(tt=n.jsxs("div",{className:"oc-folder",children:[nt,oe]}),e[89]=nt,e[90]=oe,e[91]=tt):tt=e[91],tt},nm=l.memo(G4);function q4(t){return t.stopPropagation()}function Y4(t){return t.stopPropagation()}function Z4(t){return t.stopPropagation()}function Q4(t){return t.stopPropagation()}function X4(t){return t.stopPropagation()}function J4(t){return t.stopPropagation()}function e5(t){return t.stopPropagation()}function t5(t){return t.stopPropagation()}function s5(t){return t.stopPropagation()}function n5(t){return t.stopPropagation()}function r5(t){const e=Ze.c(11);let s,r,o;e[0]!==t?({notifyOnSubtasks:r,activityNodes:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o):(s=e[1],r=e[2],o=e[3]);const i=o.isCollapsed&&!o.archivedBucket;let a;e[4]!==s||e[5]!==r||e[6]!==i?(a={nodes:s,includeUnreadSubtasks:r,enabled:i},e[4]=s,e[5]=r,e[6]=i,e[7]=a):a=e[7];const d=wf(a);let c;return e[8]!==d||e[9]!==o?(c=n.jsx(nm,{...o,collapsedActivityState:d}),e[8]=d,e[9]=o,e[10]=c):c=e[10],c}const Qo=t=>{const e=Ze.c(16),{directory:s,className:r}=t,{t:o}=Et();let i;e[0]!==s?(i=Yg(s),e[0]=s,e[1]=i):i=e[1];const a=i;let d;if(e[2]!==a?(d=y=>y.sessions.get(a),e[2]=a,e[3]=d):d=e[3],!zt(d)?.tabs.some(sf))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const p=f;let h;e[6]!==r?(h=Pe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=h):h=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(Z,{name:"pulse",className:"size-3.5"}),e[8]=g):g=e[8];let b;e[9]!==a||e[10]!==p||e[11]!==h?(b=n.jsx("span",{className:h,role:"img","aria-label":p,"data-action-directory":a,children:g}),e[9]=a,e[10]=p,e[11]=h,e[12]=b):b=e[12];let x;return e[13]!==p||e[14]!==b?(x=n.jsx(Ln,{label:p,children:b}),e[13]=p,e[14]=b,e[15]=x):x=e[15],x},o5=t=>{const e=Ze.c(19),{sessionId:s,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:a,archivedBucket:d,children:c}=t,u=o===void 0?null:o,f=d===void 0?!1:d,p=`session-drag:${r??s}`;let h;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==a?(h={type:"session",sessionId:s,ownerKey:u,sessionDirectory:i,sessionTitle:a,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=s,e[4]=a,e[5]=h):h=e[5];let g;e[6]!==f||e[7]!==p||e[8]!==h?(g={id:p,disabled:f,data:h},e[6]=f,e[7]=p,e[8]=h,e[9]=g):g=e[9];const{attributes:b,listeners:x,setNodeRef:y,isDragging:S}=Tw(g);let m;e[10]!==x?(m=k=>{k.stopPropagation(),x?.onPointerDown&&x.onPointerDown(k)},e[10]=x,e[11]=m):m=e[11];const v=m,w=`touch-pan-y select-none${S?" opacity-30":""}`;let T;return e[12]!==b||e[13]!==c||e[14]!==v||e[15]!==x||e[16]!==y||e[17]!==w?(T=n.jsx("div",{ref:y,...b,...x,onPointerDown:v,className:w,children:c}),e[12]=b,e[13]=c,e[14]=v,e[15]=x,e[16]=y,e[17]=w,e[18]=T):T=e[18],T},rm=t=>{const e=Ze.c(20),{folderId:s,scopeKey:r,ownerKey:o,disabled:i,children:a}=t,d=i===void 0?!1:i;let c;e[0]!==s||e[1]!==r?(c=_n(r,s),e[0]=s,e[1]=r,e[2]=c):c=e[2];const u=`folder-drop:${c}`;let f;e[3]!==d||e[4]!==r?(f=d||sc(r),e[3]=d,e[4]=r,e[5]=f):f=e[5];let p;e[6]!==s||e[7]!==o||e[8]!==r?(p={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=p):p=e[9];let h;e[10]!==u||e[11]!==f||e[12]!==p?(h={id:u,disabled:f,data:p},e[10]=u,e[11]=f,e[12]=p,e[13]=h):h=e[13];const{setNodeRef:g,isOver:b}=Dw(h);let x;e[14]!==a||e[15]!==b||e[16]!==g?(x=a(g,b),e[14]=a,e[15]=b,e[16]=g,e[17]=x):x=e[17];let y;return e[18]!==x?(y=n.jsx(n.Fragment,{children:x}),e[18]=x,e[19]=y):y=e[19],y},i5=t=>{const e=Ze.c(22),{scopeKey:s,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:a}=t,d=r===void 0?null:r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activationConstraint:{distance:8}},e[0]=c):c=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 f=yi(mn(Si,c),mn(xi,u)),[p,h]=l.useState(null),[g,b]=l.useState("Session"),[x,y]=l.useState(null),[S,m]=l.useState(null);if(!s){let F;return e[2]!==a?(F=n.jsx(n.Fragment,{children:a}),e[2]=a,e[3]=F):F=e[3],F}let v;e[4]!==i||e[5]!==d?(v=F=>{h(null),y(null),m(null);const{active:j,over:P}=F;if(!P)return;const L=j.data.current,z=P.data.current;L?.type!=="session"||!L.sessionId||!L.ownerKey||L.archivedBucket===!0||d&&L.ownerKey!==d||z?.type!=="folder"||!z.folderId||!z.scopeKey||!z.ownerKey||sc(z.scopeKey)||z.ownerKey!==L.ownerKey||i(L.sessionId,{folderId:z.folderId,scopeKey:z.scopeKey,ownerKey:z.ownerKey},L.ownerKey)},e[4]=i,e[5]=d,e[6]=v):v=e[6];const w=v;let T,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=F=>{const j=F.active.data.current;if(j?.type==="session"&&j.sessionId){h(j.sessionId),b(j.sessionTitle??"Session");const P=F.active.rect.current.initial?.width,L=F.active.rect.current.initial?.height;y(P??null),m(L??null)}},k=()=>{h(null),y(null),m(null)},e[7]=T,e[8]=k):(T=e[7],k=e[8]);let I;e[9]!==S||e[10]!==p||e[11]!==g||e[12]!==x||e[13]!==o?(I=p&&o?n.jsxs("div",{style:{width:x?`${x}px`:"auto",height:S?`${S}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:[n.jsx(Z,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground me-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:g})]}):null,e[9]=S,e[10]=p,e[11]=g,e[12]=x,e[13]=o,e[14]=I):I=e[14];let B;e[15]!==I?(B=n.jsx(Rw,{children:I}),e[15]=I,e[16]=B):B=e[16];let O;return e[17]!==a||e[18]!==w||e[19]!==f||e[20]!==B?(O=n.jsxs(wi,{sensors:f,collisionDetection:vi,onDragStart:T,onDragCancel:k,onDragEnd:w,children:[a,B]}),e[17]=a,e[18]=w,e[19]=f,e[20]=B,e[21]=O):O=e[21],O},om=l.createContext(null),a5=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const o=l.useRef(t),i=l.useRef(e),a=l.useRef(s);o.current=t,i.current=e,a.current=s;const d=l.useRef(null);return d.current===null&&(d.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>a.current}),n.jsx(om.Provider,{value:d.current,children:r})},im=()=>l.useContext(om),l5=(t,e,s)=>{const r=t[0];if(!r)return null;const o=s??r.scopeKey,i=[],a=new Set;for(const d of t){if(o&&d.scopeKey!==o)continue;const c=d.descendantRange,u=c?[d.id,...e.slice(c[0],c[1])]:[d.id];for(const f of u)a.has(f)||(a.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},am=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},c5=t=>{const e=Ze.c(24),{menuInstanceKey:s,contextMenuInstanceKey:r,openSidebarMenuKey:o,setOpenSidebarMenuKey:i,hasDeferredCloseWork:a,onCloseComplete:d}=t,[c,u]=l.useState(!1),[f,p]=l.useState(!1),h=o===s&&!f,g=r?o===r&&!f:c;let b;e[0]!==a||e[1]!==o||e[2]!==i?(b=I=>{if(o===I){if(a()){p(!0);return}i(null)}},e[0]=a,e[1]=o,e[2]=i,e[3]=b):b=e[3];const x=b;let y;e[4]!==s||e[5]!==x||e[6]!==i?(y=I=>{if(I){u(!1),p(!1),i(s);return}x(s)},e[4]=s,e[5]=x,e[6]=i,e[7]=y):y=e[7];const S=y;let m;e[8]!==r||e[9]!==x||e[10]!==i?(m=I=>{if(!r){u(I);return}if(I){p(!1),i(r);return}x(r)},e[8]=r,e[9]=x,e[10]=i,e[11]=m):m=e[11];const v=m;let w;e[12]!==r||e[13]!==s||e[14]!==d||e[15]!==o||e[16]!==i?(w=I=>{I||(d(),p(!1),(o===s||o===r)&&i(null))},e[12]=r,e[13]=s,e[14]=d,e[15]=o,e[16]=i,e[17]=w):w=e[17];const T=w;let k;return e[18]!==v||e[19]!==S||e[20]!==T||e[21]!==g||e[22]!==h?(k={isMenuOpen:h,isContextMenuOpen:g,handleMenuOpenChange:S,handleContextMenuOpenChange:v,handleMenuOpenChangeComplete:T},e[18]=v,e[19]=S,e[20]=T,e[21]=g,e[22]=h,e[23]=k):k=e[23],k},d5=t=>{const e=Ze.c(10),{project:s,fallback:r}=t,{currentTheme:o}=br(),i=s.iconImage??null;let a;e[0]!==s.id||e[1]!==i?(a={id:s.id,iconImage:i},e[0]=s.id,e[1]=i,e[2]=a):a=e[2];let d;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(d={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=d):d=e[5];let c;return e[6]!==r||e[7]!==a||e[8]!==d?(c=n.jsx(Il,{project:a,options:d,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=a,e[8]=d,e[9]=c):c=e[9],c},du=t=>{const e=Ze.c(14),{project:s,label:r}=t,o=s.icon?kl[s.icon]:null;let i;e[0]!==s.color?(i=Cl(s.color),e[0]=s.color,e[1]=i):i=e[1];const a=i;let d;e[2]!==a||e[3]!==o?(d=o?n.jsx(Z,{name:o,className:Pe("h-3 w-3",!a&&"text-muted-foreground/75"),style:a?{color:a}:void 0}):n.jsx(Z,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:a?{color:a}:void 0}),e[2]=a,e[3]=o,e[4]=d):d=e[4];const c=d;let u;e[5]!==r?(u=r?{role:"img","aria-label":r}:{},e[5]=r,e[6]=u):u=e[6];const f=u;let p;e[7]!==c||e[8]!==f||e[9]!==s?(p=s.iconImage?n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:s.iconBackground?{backgroundColor:s.iconBackground}:void 0,...f,children:n.jsx(d5,{project:s,fallback:c})}):n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center",...f,children:c}),e[7]=c,e[8]=f,e[9]=s,e[10]=p):p=e[10];const h=p;let g;return e[11]!==r||e[12]!==h?(g=r?n.jsx(Ln,{label:r,children:h}):h,e[11]=r,e[12]=h,e[13]=g):g=e[13],g},cl=t=>{const e=Ze.c(59),{compact:s,project:r,projectLabel:o,projectLine:i,title:a,titleClassName:d,branchLabel:c,spaceMark:u,metaLineLead:f,statusDot:p,pinnedMarker:h,timeSlot:g,directoryIndicator:b,prBadge:x,zombieIndicator:y,goal:S,badges:m,doneHint:v,providerId:w,metaPaddingClass:T,hideMetaOnHoverClass:k,actionsReserveClass:I,actionsMaskClass:B}=t,O=s===void 0?!1:s,F=i===void 0?!1:i,j=u===void 0?null:u,P=f===void 0?null:f,L=S===void 0?null:S,z=v===void 0?null:v;let H;e[0]!==k||e[1]!==T?(H=Pe("ms-auto flex flex-shrink-0 items-center gap-1 transition-opacity",T,k),e[0]=k,e[1]=T,e[2]=H):H=e[2];const R=O?L:null,G=O?y??x:null,_=O?m:null;let $;e[3]!==g?($=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:g}),e[3]=g,e[4]=$):$=e[4];let E;e[5]!==b||e[6]!==z||e[7]!==h||e[8]!==p||e[9]!==_||e[10]!==$||e[11]!==H||e[12]!==R||e[13]!==G?(E=n.jsxs("span",{className:H,children:[R,G,_,b,h,z,p,$]}),e[5]=b,e[6]=z,e[7]=h,e[8]=p,e[9]=_,e[10]=$,e[11]=H,e[12]=R,e[13]=G,e[14]=E):E=e[14];const D=E;let C;e[15]!==B||e[16]!==d?(C=Pe("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",B,d),e[15]=B,e[16]=d,e[17]=C):C=e[17];let N;e[18]!==C||e[19]!==a?(N=n.jsx("div",{dir:"auto",className:C,children:a}),e[18]=C,e[19]=a,e[20]=N):N=e[20];const A=N;if(O){let ne;e[21]!==I?(ne=Pe("@container relative flex w-full min-w-0 items-center gap-1",I),e[21]=I,e[22]=ne):ne=e[22];let je;return e[23]!==D||e[24]!==ne||e[25]!==A?(je=n.jsxs("div",{className:ne,children:[A,D]}),e[23]=D,e[24]=ne,e[25]=A,e[26]=je):je=e[26],je}let q;e[27]!==B||e[28]!==I||e[29]!==D||e[30]!==r||e[31]!==o||e[32]!==F||e[33]!==a||e[34]!==d||e[35]!==A?(q=F?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:Pe("@container relative flex h-5 w-full min-w-0 items-center gap-1",I),children:[r?n.jsx(du,{project:r,label:null}):null,n.jsx("span",{className:Pe("min-w-0 flex-1 truncate typography-micro text-muted-foreground/85",r&&"[--oc-actions-inset:16px]",B),children:o}),D]}),n.jsx("div",{className:"flex h-5 w-full min-w-0 items-center",children:n.jsx("div",{dir:"auto",className:Pe("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",d),children:a})})]}):n.jsxs("div",{className:Pe("@container relative flex h-5 w-full min-w-0 items-center gap-1",I),children:[A,D]}),e[27]=B,e[28]=I,e[29]=D,e[30]=r,e[31]=o,e[32]=F,e[33]=a,e[34]=d,e[35]=A,e[36]=q):q=e[36];let ee;e[37]!==r||e[38]!==o||e[39]!==F?(ee=r&&!F?n.jsx(du,{project:r,label:o}):null,e[37]=r,e[38]=o,e[39]=F,e[40]=ee):ee=e[40];let Q;e[41]!==c||e[42]!==P||e[43]!==j?(Q=P??(c?n.jsxs(n.Fragment,{children:[j?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":j}):n.jsx(Z,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:c})]}):null),e[41]=c,e[42]=P,e[43]=j,e[44]=Q):Q=e[44];const he=y??x;let M;e[45]!==w?(M=w?n.jsx(Sp,{providerId:w,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[45]=w,e[46]=M):M=e[46];let V;e[47]!==m||e[48]!==L||e[49]!==he||e[50]!==M?(V=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[L,he,m,M]}),e[47]=m,e[48]=L,e[49]=he,e[50]=M,e[51]=V):V=e[51];let ie;e[52]!==ee||e[53]!==Q||e[54]!==V?(ie=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[ee,Q,V]}),e[52]=ee,e[53]=Q,e[54]=V,e[55]=ie):ie=e[55];let ce;return e[56]!==q||e[57]!==ie?(ce=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[q,ie]}),e[56]=q,e[57]=ie,e[58]=ce):ce=e[58],ce},lm=750,Xo=t=>{const e=Ze.c(9),{items:s,directory:r}=t,o=Wl();let i;if(e[0]!==r||e[1]!==s||e[2]!==o){let d;e[4]!==r||e[5]!==o?(d=c=>n.jsxs("button",{type:"button",className:Pe("group/ref flex min-w-0 flex-col rounded text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",!c.color&&"text-muted-foreground"),style:c.color?{color:c.color}:void 0,disabled:!c.url,onPointerDown:u5,onMouseDown:f5,onKeyDown:p5,onClick:u=>{u.stopPropagation(),c.url&&o(c.url,r,u)},children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 group-hover/ref:underline group-disabled/ref:no-underline",children:[n.jsx(Z,{name:c.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:c.text})]}),c.title?n.jsx("span",{className:"min-w-0 truncate ps-[18px] text-muted-foreground",children:c.title}):null]},c.key),e[4]=r,e[5]=o,e[6]=d):d=e[6],i=s.map(d),e[0]=r,e[1]=s,e[2]=o,e[3]=i}else i=e[3];let a;return e[7]!==i?(a=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:i}),e[7]=i,e[8]=a):a=e[8],a};function u5(t){return t.stopPropagation()}function f5(t){return t.stopPropagation()}function p5(t){return t.stopPropagation()}const h5=150,xa={capture:!0,passive:!0};let To=null;const uu=new WeakSet,m5=t=>{To={target:t.target,at:performance.now()}},fu=(t,e)=>t instanceof Node&&t.contains(e);function g5(){const t=Ze.c(4),e=l.useRef(null),s=l.useRef(null);let r,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(uu.has(document)||(uu.add(document),document.addEventListener("scroll",m5,xa)),()=>s.current?.()),o=[],t[0]=r,t[1]=o):(r=t[0],o=t[1]),l.useEffect(r,o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(c,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!c||!f)return;if(To&&performance.now()-To.at<h5&&fu(To.target,f)){u.cancel();return}const p=h=>{fu(h.target,f)&&e.current?.close()};document.addEventListener("scroll",p,xa),s.current=()=>document.removeEventListener("scroll",p,xa)},t[2]=i):i=t[2];const a=i;let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={actionsRef:e,onOpenChange:a},t[3]=d):d=t[3],d}let dl=!1;const ul=new Set;let pu=!1;function b5(){for(const t of ul)t()}function cm(t){dl!==t&&(dl=t,b5())}function go(t){cm(t.shiftKey)}function y5(){cm(!1)}function x5(){if(pu||typeof window>"u")return;pu=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",go,t),window.addEventListener("keyup",go,t),window.addEventListener("pointermove",go,t),window.addEventListener("pointerdown",go,t),window.addEventListener("blur",y5)}function S5(t){return x5(),ul.add(t),()=>{ul.delete(t)}}function w5(){return dl}function v5(){return!1}function dm(){return us.useSyncExternalStore(S5,w5,v5)}const um=async(t,e,s)=>{const r=s.getRuntimeKey(),o=yt(t.path);if(!o)throw new Error("Unable to resolve worktree project");const i=await s.listProjectWorktrees(t,{force:!0});if(s.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const a=s.getCurrentProjects(),d=a.find(b=>b.id===t.id)??null;if(!d||yt(d.path??null)!==o)throw new Error("Project removed during worktree refresh");const c=oc({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(b=>Jo(b));u.sort((b,x)=>fm({metadata:b},{metadata:x}));const f=N1(c.worktreesByProject,o,u,e?.projectDirectory);j5(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const p=s.getPublishedWorktreesByProject(),h=M1(s.partitionWorktreesByRegisteredProject(a,f),p),g=[...h.values()].flat();return s.recordWorktreesSeen(g.map(b=>b.path),s.now()),s.worktreeMapsEqual(h,p)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:h}),u},j5=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),k5=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Jo(r))])),oc=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:k5(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),fm=(t,e)=>{const s=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,o=s.localeCompare(r,void 0,{sensitivity:"base"});return o!==0?o:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},hu=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Jo=t=>({...t,path:yt(t.path)??t.path,projectDirectory:yt(t.projectDirectory)??t.projectDirectory,worktreeRoot:yt(t.worktreeRoot??t.path)??t.worktreeRoot}),mu=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:o}=t,a=yt(e?.path??null)===s,d=a?e?.branch??"":o??"",c={path:s,projectDirectory:r,branch:d,label:a?e?.label||e?.branch||e?.name||hu(s):o||hu(s),name:a?e?.name:void 0,worktreeRoot:a?yt(e?.worktreeRoot??s)??s:s,worktreeStatus:a?e?.worktreeStatus??"ready":"ready",worktreeSource:a?e?.worktreeSource??"existing":"existing",headState:a?e?.headState:o?"branch":void 0};return a&&e?{...e,...c}:c},gu=t=>{const e=yt(t.projectPath??null),s=yt(t.sourceDirectory??null)??yt(t.currentWorktree?.path??null),r=yt(t.discoveredWorktrees.find(f=>yt(f.projectDirectory??null))?.projectDirectory??null),o=yt(t.currentWorktree?.projectDirectory??null),i=r??o??e,a=new Map,d=f=>{const p=yt(f.metadata.path??null);!p||a.has(p)||e&&p!==s&&A1(p,e)||a.set(p,{...f,metadata:Jo({...f.metadata,path:p})})};for(const f of t.discoveredWorktrees){const p=yt(f.path??null);p&&d({metadata:Jo({...f,path:p,projectDirectory:yt(f.projectDirectory??null)??i??e??p}),isPrimary:i===p,isCurrent:s===p})}i&&!a.has(i)&&d({metadata:mu({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!a.has(s)&&d({metadata:mu({path:s,projectDirectory:i??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===s,isCurrent:!0});const c=[],u=[];for(const f of a.values()){if(f.isPrimary){c.push(f);continue}u.push(f)}return c.sort((f,p)=>f.metadata.path.localeCompare(p.metadata.path,void 0,{sensitivity:"base"})),u.sort(fm),[...c,...u]},pm=(t,e)=>{const s=t.projectId?e.projects.find(i=>i.id===t.projectId)??null:null;if(s)return s;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const o=t.currentWorktree?.projectDirectory??null;return o?e.resolveProject(o):null},C5=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=oc({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=pm(t,e),a=yt(i?.path??null);return{cachedTargets:gu({projectPath:a,discoveredWorktrees:a?o.worktreesByProject.get(a)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!a)throw new Error("Unable to resolve worktree project");const c=await um(i,t.currentWorktree,e);return gu({projectPath:a,discoveredWorktrees:c,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},I5=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),s=[...e.values()].flat();return t.recordWorktreesSeen(s.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:s,availableWorktreesByProject:e}),!0},P5=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),E5=(t,e)=>yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,T5=[],D5=[],R5=[],bu=10,Sa=new WeakMap,N5=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Sa.get(s)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,a=null;const d=()=>{i=!0,a!==null&&window.cancelAnimationFrame(a),a=null,Sa.delete(s),s.removeEventListener("wheel",d),s.removeEventListener("touchstart",d)},c=()=>{if(i||!e.isConnected||!s.isConnected){d();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,As("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){d();return}a=window.requestAnimationFrame(c)};s.addEventListener("wheel",d,{passive:!0}),s.addEventListener("touchstart",d,{passive:!0}),Sa.set(s,d),a=window.requestAnimationFrame(c)},M5=l.memo(function(e){const s=Ze.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:a,onPointerDown:d,onMouseDown:c,onArchive:u,onDelete:f}=e,p=dm(),h=p?o:r;let g;s[0]!==u||s[1]!==f||s[2]!==p?(g=k=>{if(p||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=p,s[3]=g):g=s[3];const b=g,x=p?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;s[4]!==i||s[5]!==x?(y=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",x,i),s[4]=i,s[5]=x,s[6]=y):y=s[6];const S=p?"delete-bin":"archive";let m;s[7]!==a||s[8]!==S?(m=n.jsx(Z,{name:S,className:a}),s[7]=a,s[8]=S,s[9]=m):m=s[9];let v;s[10]!==b||s[11]!==h||s[12]!==c||s[13]!==d||s[14]!==y||s[15]!==m?(v=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:y,"aria-label":h,onPointerDown:d,onMouseDown:c,onClick:b,onKeyDown:K5,children:m})}),s[10]=b,s[11]=h,s[12]=c,s[13]=d,s[14]=y,s[15]=m,s[16]=v):v=s[16];let w;s[17]!==h?(w=n.jsx(Kt,{side:"top",sideOffset:6,children:h}),s[17]=h,s[18]=w):w=s[18];let T;return s[19]!==v||s[20]!==w?(T=n.jsxs(Ut,{children:[v,w]}),s[19]=v,s[20]=w,s[21]=T):T=s[21],T});function A5(t){As("ui.sidebar_session_node.render");const{t:e}=Et(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:c=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:g,editingId:b,editingRowKey:x,setEditingId:y,setEditingRowKey:S,editTitle:m,setEditTitle:v,handleSaveEdit:w,handleCancelEdit:T,toggleParent:k,handleSessionSelect:I,handleSessionDoubleClick:B,handleCopySessionId:O,openSidebarMenuKey:F,setOpenSidebarMenuKey:j,createFolderAndStartRename:P,handleDeleteSession:L,handleRestoreSession:z,startSessionWorktreeMenuLoad:H,mobileVariant:R,alwaysShowActions:G,secondaryMeta:_,renderContext:$="project",blockingBadgeSessionScopes:E,rowKey:D,dragKey:C,children:N}=t,A=is(J=>J.getFoldersForScope),q=is(J=>J.getSessionFolderId),ee=is(J=>J.removeSessionFromFolder),Q=is(J=>J.addSessionToFolder),he=le(J=>J.openContextPanelTab),M=l.useMemo(()=>Dn(),[]),V=l.useMemo(()=>Do(),[]),ie=l.useContext(O1),ce=M?"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",ne=M?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",je=M,Ee=!c&&!R,we=le(J=>J.sessionWorkEnabled),Me=le(J=>J.sessionRecapEnabled),fe=we&&!c&&!s.session.parentID&&!yl(s.session.directory),be=fe&&!G,ke=(be?1:0)+(Ee?1:0)+(je?1:0),Ie=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][ke],Te=Ee?"pe-13":"pe-7",Y=l.useRef(!1),[ue,me]=l.useState(!1),re=l.useRef(b);re.current=b;const pe=l.useRef(null),U=l.useRef(!1),ae=l.useRef(w);ae.current=w;const Re=m,W=l.useRef(Re);W.current=Re;const ye=l.useRef(null),de=l.useRef(!1),Ne=l.useRef(null),Je=l.useRef(null),Ge=g5(),ge=s.session,Ae=ge,Ye=ns(l.useCallback(J=>{if(_?.projectLabel||!i)return null;const _t=J.projects.find(Xt=>Xt.id===i);return _t?_t.label?.trim()||di(yt(_t.path)??_t.path,null)||_t.path:null},[i,_?.projectLabel])),nt=$==="timeline-chat"||$==="tree-chat"||$==="mixed-compact",oe=qr($)||nt,tt=$==="timeline-by-time",Ue=rc($),gt=$==="timeline-mixed"||$==="mixed-compact"||$==="timeline-by-time",bt=ts(J=>J.showPinnedSection),Ce=gt&&bt,_e=ns(l.useCallback(J=>$!=="timeline-mixed"&&$!=="timeline-by-time"||!i?null:J.projects.find(_t=>_t.id===i)??null,[$,i])),ze=_?.projectLabel??(Ye?wp(Ye):null),Oe=i3(_,s.worktree?.branch??null),it=_?.inSpace===!0,X=l.useMemo(()=>a3(s.worktree,M),[M,s.worktree]),Be=vp(X?.directory??null,X?.branch??null),Le=l.useMemo(()=>M?T5:jp(ge),[M,ge]),at=l.useMemo(()=>Le.map(J=>({item:zr("pull",J),url:J.url,title:J.title})),[Le]),qe=Zc(at),ut=l.useMemo(()=>qe.filter(J=>J!==null),[qe]),dt=l.useMemo(()=>M?R5:B1(ge),[M,ge]),ft=l.useMemo(()=>dt.flatMap(J=>J.gitlab?[{item:Kr("pull",J.gitlab),url:J.url,title:J.title}]:[]),[dt]),st=Zc(ft),Rt=l.useMemo(()=>F1(Be,[...ut,...st.filter(J=>J!==null)]),[Be,st,ut]),Ke=l.useMemo(()=>{let J=0;return dt.filter(_t=>{if(!_t.gitlab)return!0;const Xt=st[J]!==null;return J+=1,!Xt})},[st,dt]),jt=l.useMemo(()=>_1(Le,Rt),[Le,Rt]),Lt=Be?`var(--pr-${Be.visualState})`:void 0,Mt=l.useMemo(()=>M?D5:Hl(ge),[M,ge]),De=l.useMemo(()=>Mt.flatMap(J=>J.source==="github"?[zr("issue",J)]:[]),[Mt]),Tt=zo(De),At=l.useMemo(()=>Mt.flatMap(J=>J.source==="gitlab"?[Kr("issue",J.ref)]:[]),[Mt]),kt=zo(At),pt=l.useMemo(()=>Mt.flatMap(J=>J.source==="linear"?[Ul(J.identifier)]:[]),[Mt]),Dt=kp(pt),Ve=l.useMemo(()=>{if(Rt.length>0||jt.length>0||Ke.length>0){const J=Rt.map(Vt=>{const gs=Cp(Vt,e),Qt=Bl(Vt.provider,Vt.number);return{key:`${Vt.provider??""}:${Vt.repo?.owner??""}/${Vt.repo?.repo??""}#${Vt.number}`,icon:"git-pull-request",label:Qt,color:`var(--pr-${Vt.visualState})`,url:Vt.url,title:Vt.title,text:gs?`${Qt} · ${gs}`:Qt}}),_t=jt.map(Vt=>({key:`${Vt.owner}/${Vt.repo}#${Vt.number}`,icon:"git-pull-request",label:`#${Vt.number}`,url:Vt.url,title:Vt.title,text:`#${Vt.number}`})),Xt=Ke.map(Vt=>({key:Vt.key,icon:"git-pull-request",label:Vt.identifier,url:Vt.url,title:Vt.title,text:Vt.identifier}));return[...J,..._t,...Xt]}return Ip(Mt,Tt,Dt,kt).map(J=>({key:J.key,icon:J.icon,label:J.label,color:J.color??void 0,url:J.url,title:J.title,text:J.statusKey?`${J.label} · ${e(J.statusKey)}`:J.statusText?`${J.label} · ${J.statusText}`:J.label}))},[kt,Tt,Mt,Dt,jt,Rt,e,Ke]),rt=Ve[0]??null,wt=Math.max(0,Ve.length-1),se=Wl(),Fe=Ve.map(J=>J.text).join(", "),ot=mt(J=>J.currentSessionId===ge.id),$e=yt(ge.directory??null)??yt(o??null),Yt=ns(J=>i?J.projects.find(_t=>_t.id===i)?.path??null:null)??$e,es=d!==void 0?d:i??$e??null,Zt=Of(),ss=Pp(),bs=M,ls=W4(),ms=xs(J=>J.enabled),fs=xs(l.useCallback(J=>J.selectedIds.has(ge.id),[ge.id])),Es=xs(J=>J.toggleSelected),cs=xs(J=>J.setRange),Qe=im(),vt=D??ge.id,$t=b===ge.id&&x===vt,ve=l.useCallback(J=>{const _t=[],Xt=Vt=>{Vt.children.forEach(gs=>{_t.push(gs.session.id),Xt(gs)})};return Xt(J),_t},[]),ct=l.useCallback(J=>{const _t=[],Xt=Vt=>{Vt.children.forEach(gs=>{_t.push(gs.session),Xt(gs)})};return Xt(J),_t},[]),[ht,Ot]=l.useState(!1),[te,et]=l.useState(!0),[xt,It]=l.useState(null),St=`${$}:${c?"archived":"active"}:${ge.id}`,Se=D?`session-menu:${D}`:St,We=D?`session-context:${D}`:null,K=L1(l.useCallback(J=>!!J.sessionMemoryState.get($1(ge.id))?.isZombie,[ge.id])),xe=Pl(ge.id),Xe=xe!==null,lt=z1(ge.id,Xe),Bt=Zp(ge.id),Pt=Sl(ge.id,$e),Gt=Bt||Pt,Ft=s.worktree??mt.getState().getWorktreeMetadata(ge.id)??null,[Wt,qt]=l.useState([]),[vs,ds]=l.useState(!1),bn=l.useRef(!1),Fs=l.useRef(0),Xs=K1(Ae),_s=fe&&Vl(Ae),Am=_s&&!Xe&&W1(Ae),ic=e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),ac=async()=>{try{await sS(ge.id,$e,_s?"done":"open")}catch{He.error(e("sessions.sidebar.session.work.updateFailed"))}},Om=Qc(J=>J.enabled),no=H1(ge.id)!==void 0,Bm=Om&&!c&&!s.session.parentID&&!!$e&&!Yu($e),Fm=async()=>{if($e)try{await Qc.getState().setSessionWarm(ge.id,$e,!no)}catch{He.error(e("sessions.warming.toggleFailed"))}},lc=Xs?e(U1[Xs.status]):"",cc=Xs?n.jsx(Ln,{label:lc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":lc,children:n.jsx(Z,{name:"target",className:"h-3 w-3",style:{color:V1[Xs.status]}})})}):null,yn=Ae.title||e("sessions.sidebar.session.untitled"),Mi=Ue&&s.children.length>0,Sr=gi(u,$e,ge.id),Ai=St,Wn=p?!0:f.has(Ai),_m=l.useMemo(()=>E??al(s,Wn,$e),[Wn,s,$e,E]),{hasPermission:Oi,hasForm:Bi}=G1(_m),dc=!!Ae.parentID,Lm=Cf(ge.id)>0&&(!dc||g),uc=q1(Ae)||Date.now(),$m=Y1(uc),Fi=Ep(uc),{isMenuOpen:fc,isContextMenuOpen:pc,handleMenuOpenChange:zm,handleContextMenuOpenChange:Km,handleMenuOpenChangeComplete:hc}=c5({menuInstanceKey:Se,contextMenuInstanceKey:We,openSidebarMenuKey:F,setOpenSidebarMenuKey:j,hasDeferredCloseWork:()=>pe.current!==null,onCloseComplete:()=>{if(!pe.current)return;const{id:J,title:_t}=pe.current;pe.current=null,y(J),S(vt),v(_t)}}),wr=fc||pc,mc=l.useMemo(()=>Z1(Ae)?.key??null,[Ae]),_i=l.useMemo(()=>xt?ve(xt).length:0,[ve,xt]),Li=l.useCallback(async J=>{const _t=[];let Xt=0;for(const Vt of J)try{if(!$e)throw new Error("Session directory is required for export");const gs=await Zt({directory:$e,sessionID:Vt.session.id});if(!gs)throw new Error("Session runtime changed during export");const Qt=Vt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),qs=Vt.session.agent,Ws=await Li(Vt.children);Xt+=Ws.skipped,_t.push({title:Qt,agent:qs,records:gs,children:Ws.children})}catch{Xt+=ve(Vt).length+1}return{children:_t,skipped:Xt}},[ve,Zt,$e,e]),$i=l.useCallback(J=>{J<=0||He.warning(J===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:J}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:J}))},[e]),zi=l.useCallback(async(J,_t)=>{if(!$e){He.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Xt=await Zt({directory:$e,sessionID:ge.id}).catch(()=>null);if(!Xt){He.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Xt.length===0){He.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Vt,gs=0;if(J&&_t.children.length>0){const js=await Li(_t.children);Vt=js.children,gs=js.skipped}const Qt=Bf(Xt,Ae.title??null,Vt),qs=Ff(Ae.title??null),Ws=await _f(Qt,qs);if(Ws){He.success(e("sessions.sidebar.session.export.success"),{action:{label:e(X1()),onClick:()=>{Q1(Ws).then(js=>{js||He.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),$i(gs);return}Lf(Qt,qs),He.success(e("sessions.sidebar.session.export.success")),$i(gs)},[Li,Zt,Ae.title,ge.id,$e,$i,e]),gc=$f(),Wm=l.useMemo(()=>zf(gc),[gc]),Hm=l.useCallback(J=>{qp({entry:J,t:e,session:{id:ge.id,title:Ae.title,directory:$e},loadRecords:()=>$e?Zt({directory:$e,sessionID:ge.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>He.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Zt,Ae.title,ge.id,$e,e]),Um=l.useCallback(async()=>{const J=s.children.length>0?s:ny(Ae);if(J.children.length>0){It(J),et(!0),Ot(!0);return}await zi(!1,J)},[zi,s,Ae]),Vm=l.useCallback(()=>{$e&&vn("desktop_open_session_mini_chat_window",{sessionId:ge.id,directory:$e,...Tr()}).catch(J=>{console.warn("[session-sidebar] failed to open mini chat window",J)})},[ge.id,$e]),bc=()=>{if(!$e)return;const J=nS()??$e;he(J,{mode:"chat",dedupeKey:`session:${ge.id}`,label:yn,sessionTitleFallback:yn,targetDirectory:$e})};if(l.useEffect(()=>{if(!$t)return;const J=_t=>{const Vt=(_t.target instanceof HTMLElement?_t.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(vt)}"]`);Je.current&&!Vt&&ae.current(W.current)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[$t,vt]),l.useLayoutEffect(()=>{if(!$t){ye.current===vt&&(ye.current=null);return}ye.current!==vt&&(ye.current=vt,de.current=!0)},[m,$t,vt]),l.useLayoutEffect(()=>{if(!$t||!de.current)return;const J=Ne.current;!J||J.value!==m||(de.current=!1,J.focus(),J.select())},[m,$t,Re]),$t){const J=n.jsxs("form",{ref:Je,"data-session-rename-form":vt,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:_t=>{_t.preventDefault(),w(Re)},children:[n.jsx("input",{ref:Ne,value:Re,onChange:_t=>v(_t.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:_t=>Ea(_t,T)}),n.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:n.jsx(Z,{name:"check",className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:T,"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:n.jsx(Z,{name:"close",className:"size-3.5"})})]});return Ue?n.jsxs("div",{style:{paddingInlineStart:Kn(r)},className:Pe("group relative my-0.5 flex items-center gap-1.5 rounded-md pe-2.5",oe?"py-1":"py-[3px]"),children:[n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:J})]},ge.id):n.jsx("div",{style:{paddingInlineStart:bu},className:Pe("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",nt?"py-1":"py-1.5",ot&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(cl,{compact:nt,project:_e,projectLabel:ze,projectLine:tt,title:J,titleClassName:"text-foreground",branchLabel:Oe,spaceMark:it?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:Fi,directoryIndicator:null,prBadge:rt?n.jsxs("span",{className:Pe("inline-flex flex-shrink-0 items-center gap-1 typography-micro",rt.color?"oc-ref-tint":"text-muted-foreground"),style:rt.color?or(rt.color):void 0,children:[n.jsx(Z,{name:rt.icon,className:"h-3 w-3"}),nt?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:rt.label}),wt>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",wt]}):null]})]}):null,zombieIndicator:null,goal:cc,badges:null,hideMetaOnHoverClass:""})},ge.id)}const yc=e("sessions.sidebar.session.status.questionPending"),Ki=!Gt&&!Xe&&Lm&&!ot,Gm=Xe||Ki,qm=n.jsx(El,{state:xe??"unread",tooltip:!0}),Ym=(Xe||Ki)&&lt,Zm=oe&&!nt?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][ke]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][ke],Qm=G?void 0:wr?"oc-actions-mask":M?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",Xm=wr?"opacity-0":ne,xc=e("sessions.sidebar.session.status.pinned"),Jm=n.jsx(Ln,{label:xc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":xc,children:n.jsx(Z,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),eg=n.jsx(Z,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Pt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),ro=Gt?eg:Gm?qm:null,Wi=Ue&&ro!==null&&!(Mi&&G),Hi=Mi?n.jsx("span",{role:"button",tabIndex:0,onClick:J=>{J.stopPropagation(),J.currentTarget.blur(),k(Ai)},onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),k(Ai))},className:Pe("inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Wi&&"opacity-0 transition-opacity group-hover:opacity-100 group-has-[:focus-visible]:opacity-100"),"aria-label":e(Wn?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":Wn,children:n.jsx(eo,{expanded:Wn})}):null,tg=Ue?Wi?n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[Hi,Hi?n.jsx("span",{className:"pointer-events-none absolute inset-0 inline-flex items-center justify-center transition-opacity group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",children:ro}):ro]}):Hi??n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}):null,Ui=K?n.jsx(Z,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,sg=J=>{J.stopPropagation()},ng=J=>{J.stopPropagation()},rg=J=>{J.stopPropagation()},Vi=J=>{J.preventDefault(),J.stopPropagation()},Gi=J=>{J.preventDefault(),J.stopPropagation()},og=J=>{J.preventDefault(),J.stopPropagation(),j(null),L(ge,{archivedBucket:c})},ig=J=>{J.preventDefault(),J.stopPropagation(),j(null),L(ge,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},ag=J=>{J.preventDefault(),J.stopPropagation()},lg=J=>{J.preventDefault(),J.stopPropagation()},cg=J=>{J.preventDefault(),J.stopPropagation(),ie?.vscode?.executeCommand("openchamber.openSessionInEditor",ge.id,yn)},Sc=J=>{if(Y.current){Y.current=!1;return}if(ms){if(J?.preventDefault(),J?.stopPropagation(),J?.shiftKey){const _t=Qe?.getEntries(),Xt=_t??Array.from(document.querySelectorAll("[data-session-row]")).map(Qt=>Qt.getAttribute("data-session-row")).filter(Qt=>!!Qt).map(Qt=>({id:Qt,rowKey:Qt,scopeKey:es,archived:c})),Vt=_t?xs.getState().anchorRowKey:xs.getState().anchorId,gs=new Map;gs.set(ge.id,ve(s)),cs(Vt,vt,Xt,Qe?.getDescendantIds()??[],es,gs);return}Es(ge.id,es,ve(s),vt);return}if(J?.shiftKey&&!M&&$e){bc();return}J?.currentTarget&&N5(J.currentTarget),I(ge.id,$e)},dg=J=>{J.defaultPrevented||(J.target instanceof HTMLElement?J.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Sc(J)},ug=J=>{(J.button===2||J.button===0&&J.ctrlKey&&!ms)&&(Y.current=!0),J.button===0&&J.shiftKey&&!ms&&J.preventDefault()},fg=J=>{R&&J.pointerType==="touch"&&me(!0),J.button===0&&!ot&&!ms&&!bs&&$e&&!Ba(ge.id,$e).renderable&&ss({directory:$e,sessionID:ge.id}).catch(()=>{})},Hn=!ot&&!ms&&$e?{id:ge.id,directory:$e}:null,pg=J=>{J.pointerType!=="mouse"||!Hn||ls?.schedule(Hn)},hg=()=>{Hn&&ls?.schedule(Hn)},wc=()=>{Hn&&ls?.cancel(Hn)},vc=J=>{R&&J.pointerType==="touch"&&me(!1)},mg=J=>{bn.current=J,Fs.current+=1;const _t=Fs.current;if(!J){ds(!1);return}const Xt=H({projectId:i??null,sourceDirectory:$e,currentWorktree:Ft});qt(Xt.cachedTargets),ds(!1),Xt.refreshTargets.then(Vt=>{!bn.current||Fs.current!==_t||(qt(Vt),ds(!1))}).catch(()=>{!bn.current||Fs.current!==_t||ds(!0)})},jc=({Item:J,Separator:_t,Sub:Xt,SubTrigger:Vt,SubContent:gs})=>n.jsxs(n.Fragment,{children:[n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(J,{onClick:()=>{pe.current={id:ge.id,title:yn}},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(Ua,{sessionID:ge.id,directory:$e,open:wr,Item:J}),n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(J,{onClick:()=>O(ge.id),className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"file-copy",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(os,{hint:e(Sr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(J,{onClick:()=>{if(!$e)return;const Qt=Sr?"sessions.sidebar.session.pin.unpinFailed":"sessions.sidebar.session.pin.pinFailed";ry({directory:$e,sessionId:ge.id}).catch(()=>He.error(e(Qt)))},className:"[&>svg]:me-1",children:[Sr?n.jsx(Z,{name:"unpin",className:"me-1 h-4 w-4"}):n.jsx(Z,{name:"pushpin",className:"me-1 h-4 w-4"}),e(Sr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),fe?n.jsx(os,{hint:e(_s?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(J,{onClick:()=>{ac()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:_s?"check":"eye",className:"me-1 h-4 w-4"}),e(_s?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,Bm?n.jsx(os,{hint:e(no?"sessions.sidebar.session.menuHint.stopWarm":"sessions.sidebar.session.menuHint.keepWarm"),children:n.jsxs(J,{onClick:()=>{Fm()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:no?"fire-fill":"fire",className:"me-1 h-4 w-4"}),e(no?"sessions.sidebar.session.menu.stopWarm":"sessions.sidebar.session.menu.keepWarm")]})}):null,n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(J,{onClick:()=>{Um()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),Wm.map(Qt=>n.jsxs(J,{onClick:()=>Hm(Qt),className:"[&>svg]:me-1",children:[n.jsx(yr,{icon:Qt.icon,iconSrc:Qt.iconSrc,className:"me-1 size-4"}),Qt.action.label]},`${Qt.guest.id}:${Qt.action.id}`)),n3({isSubtaskSession:dc,archivedBucket:!!c,isVSCode:M,sessionDirectory:$e})?(()=>{const Qt=r3({sessionDirectory:$e,isStreaming:Xe,isMovingToWorktree:Bt}),qs=P5({targets:Wt,loadFailed:vs}),Ws=n.jsxs(Vt,{disabled:Qt,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":ge.id,children:[n.jsx(Z,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),js=Bt?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):Xe?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(Xt,{onOpenChange:mg,children:[js?n.jsx(os,{hint:js,children:Ws}):Ws,n.jsxs(gs,{className:"min-w-[220px]","data-session-worktree-submenu":ge.id,children:[Wt.map(ks=>{const Ss=yt(ks.metadata.path??null)??ks.metadata.path,ws=ks.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ks.metadata.label||ks.metadata.branch||ks.metadata.name||ks.metadata.path,an=ks.isCurrent||ks.metadata.worktreeStatus!=="ready";return n.jsxs(J,{disabled:an,title:ks.metadata.path,"data-session-worktree-target":Ss,onClick:()=>{an||!$e||Ho({kind:"existing",root:Ae,descendants:Bo(Ae,ct(s)),sourceDirectory:$e,destination:ks.metadata,messages:Wo(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[n.jsx("span",{className:"truncate",children:ws}),ks.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ks.isCurrent?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Ss)}),qs.refreshState==="error"?n.jsx(J,{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,n.jsx(_t,{}),n.jsxs(J,{disabled:Qt,"data-session-worktree-new-action":"true",onClick:()=>{Qt||!$e||Ho({kind:"quick",root:Ae,descendants:Bo(Ae,ct(s)),sourceDirectory:$e,messages:Wo(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,mc?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(J,{onClick:()=>le.getState().setRunOverviewKey(mc),className:"[&>svg]:me-1",children:[n.jsx(Fa,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,$e&&!c&&!oe?(()=>{const Qt=[],qs=Ss=>{const ws=yt(Ss??null);ws&&!Qt.includes(ws)&&Qt.push(ws)};if(i&&!M){const Ss=ns.getState().projects.find(an=>an.id===i),ws=yt(Ss?.path??null);qs(ws),ws&&(mt.getState().availableWorktreesByProject.get(ws)??[]).forEach(an=>qs(an.path))}qs(xl($e)),qs($e);const Ws=Qt.flatMap(Ss=>A(Ss).map(ws=>({scope:Ss,folder:ws}))),js=Ws.find(({scope:Ss,folder:ws})=>q(Ss,ge.id)===ws.id)??null,ks=Qt[0]??$e;return n.jsxs(n.Fragment,{children:[n.jsx(_t,{}),n.jsxs(Xt,{children:[n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(Vt,{className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(gs,{className:"min-w-[180px]",children:[Ws.length===0?n.jsx(J,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Ws.map(({scope:Ss,folder:ws})=>{const an=js?.folder.id===ws.id;return n.jsxs(J,{onClick:()=>{if(an){ee(Ss,ge.id);return}js&&js.scope!==Ss&&ee(js.scope,ge.id),Q(Ss,ws.id,ge.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ws.name}),an?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ws.id)}),n.jsx(_t,{}),n.jsxs(J,{onClick:()=>{const Ss=P(ks);Ss&&(U.current=!0,js&&js.scope!==ks&&ee(js.scope,ge.id),Q(ks,Ss.id,ge.id))},children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),js?n.jsxs(J,{onClick:()=>{ee(js.scope,ge.id)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,M?null:n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(J,{disabled:!$e,onClick:bc,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"chat-4",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")})]})}),V?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(J,{disabled:!$e,onClick:Vm,className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"window",className:"me-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(_t,{}),c?null:n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>L(ge,{archivedBucket:c}),children:[n.jsx(Z,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),c?n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>z(ge),children:[n.jsx(Z,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(os,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(J,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>L(ge,{archivedBucket:c,hardDelete:!0}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),gg=J=>{J.preventDefault(),J.stopPropagation(),ac()},qi=G?"h-6 w-6":oe&&!nt?"h-5 w-5":"h-4 w-4",oo=G?"h-3.5 w-3.5":oe&&!nt?"h-3 w-3":"h-2.5 w-2.5",bg=G?"h-4 w-4":oe&&!nt?"h-3.5 w-3.5":"h-3 w-3",kc=Me&&!Xe&&J1(Ae)?.recap||null,Cc=e("sessions.sidebar.session.work.doneSuggested"),yg=J=>Am?n.jsx(Ln,{label:Cc,children:n.jsx("span",{className:Pe("inline-flex flex-shrink-0 items-center text-muted-foreground/75",J),"aria-label":Cc,children:n.jsx(Z,{name:"check",className:"h-3.5 w-3.5"})})}):null,Ic=e("sessions.sidebar.session.status.permissionRequired"),xg=Oi||Bi?n.jsxs(n.Fragment,{children:[Oi?n.jsx(Ln,{label:Ic,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-destructive/10 px-1 py-0.5 text-destructive","aria-label":Ic,children:n.jsx(Z,{name:"shield",className:"h-3 w-3"})})}):null,Bi?n.jsx(Ln,{label:yc,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-status-info/10 px-1 py-0.5 text-status-info","aria-label":yc,children:n.jsx(Z,{name:"question",className:"h-3 w-3"})})}):null]}):null,Sg=oe&&rt?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,closeDelay:lm,children:n.jsxs("button",{type:"button",className:Pe("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",rt.color?"oc-ref-tint":"text-muted-foreground"),style:rt.color?or(rt.color):void 0,disabled:!rt.url,"aria-label":Fe,onPointerDown:Vi,onMouseDown:Gi,onClick:J=>{J.preventDefault(),J.stopPropagation(),!(J.target instanceof Element&&J.target.closest("[data-ref-more]"))&&rt.url&&se(rt.url,Yt,J)},onKeyDown:J=>J.stopPropagation(),children:[n.jsx(Z,{name:rt.icon,className:"h-3 w-3"}),nt?null:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"leading-none tabular-nums",children:rt.label}),wt>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",wt]}):null]})]})}),n.jsx(Kt,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(Xo,{items:Ve,directory:Yt})})]}):null,wg=n.jsx(cl,{compact:!qr($),project:_e,projectLabel:ze,projectLine:tt,title:vo(yn,h),titleClassName:ot||fs?"text-interactive-selection-foreground":Ki||Oi||Bi?"font-semibold text-foreground":Xe?"text-foreground":"text-muted-foreground",branchLabel:Oe,spaceMark:it?e("sessions.sidebar.group.space"):null,statusDot:Wi?null:ro,pinnedMarker:Sr&&!Gt&&!Ce?Jm:null,timeSlot:Ym?n.jsx(eS,{sessionId:ge.id,running:Xe,className:"typography-micro"}):Fi,directoryIndicator:!c&&$e&&$!=="project"?n.jsx(Qo,{directory:$e}):null,prBadge:Sg,zombieIndicator:oe?Ui:null,goal:cc,badges:xg,doneHint:yg(),providerId:oe?Ae.model?.providerID??null:null,metaPaddingClass:oe&&G?Ee?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:G&&!M?"":Xm,actionsReserveClass:Zm,actionsMaskClass:Qm}),vg=n.jsx(Ms,{align:"end",className:"min-w-[180px]",finalFocus:()=>U.current?(U.current=!1,!1):!re.current,children:jc({Item:rs,Separator:In,Sub:mp,SubTrigger:gp,SubContent:bp})}),jg=n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-content",finalFocus:()=>U.current?(U.current=!1,!1):!re.current,style:{color:"var(--surface-elevated-foreground)"},className:Pe(Da,"min-w-[180px]"),children:jc({Item:({className:J,..._t})=>n.jsx(Wp,{className:Pe(Pf,J),..._t}),Separator:({className:J,..._t})=>n.jsx(Kp,{className:Pe(If,J),..._t}),Sub:Bw,SubTrigger:({className:J,children:_t,...Xt})=>n.jsxs(Fw,{className:Pe(tS,J),...Xt,children:[_t,n.jsx(Z,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:J,children:_t,...Xt})=>n.jsx(za,{children:n.jsx(Ka,{className:"app-region-no-drag z-50",children:n.jsx(Wa,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe(Da,J),...Xt,children:_t})})})})})})});return n.jsxs(l.Fragment,{children:[n.jsx(o5,{sessionId:ge.id,dragKey:C??vt,ownerKey:a??es,sessionDirectory:$e??null,sessionTitle:yn,archivedBucket:c,children:n.jsxs(Zr,{open:pc,onOpenChange:Km,onOpenChangeComplete:hc,children:[n.jsxs(Hp,{render:n.jsx("div",{"data-session-row":ge.id,"data-session-scope":es??"","data-session-archived":c?"1":"0","aria-current":ot?"page":void 0,onClick:dg,style:{paddingInlineStart:Ue?Kn(r):bu},className:Pe("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",Ue&&"gap-1.5",oe?nt?"py-1":"py-1.5":"py-[3px]",!(ot||fs)&&"hover:bg-interactive-hover/60",(ot||fs)&&"bg-interactive-selection/70 text-interactive-selection-foreground",fs&&"ring-1 ring-inset ring-border")}),children:[tg,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Ut,{actionsRef:Ge.actionsRef,onOpenChange:Ge.onOpenChange,children:[n.jsx(Ht,{asChild:!0,closeDelay:0,disabled:M,children:n.jsx("div",{role:"button",tabIndex:0,"data-session-row-main":"",onKeyDown:J=>{J.target!==J.currentTarget||J.key!=="Enter"&&J.key!==" "||(J.preventDefault(),J.currentTarget.click())},"aria-pressed":ms?fs:void 0,onPointerDown:fg,onPointerUp:vc,onPointerCancel:vc,onPointerEnter:pg,onPointerLeave:wc,onFocus:hg,onBlur:wc,onMouseDown:ug,onClick:J=>Sc(J),onDoubleClick:J=>{J.stopPropagation(),B(ge.id,yn)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none",ue&&"bg-interactive-hover/70",oe||!G?void 0:M?Ie:Te),children:wg})}),M?null:n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs text-start",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-start text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{dir:"auto",className:"oc-ui-start-align min-w-0 truncate font-medium text-foreground",children:yn}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:$m,children:Fi})]}),ze?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx(Z,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:ze})]}):null,Oe?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[it?n.jsx(Z,{name:"box-3",className:"h-3 w-3 flex-shrink-0","aria-hidden":!1,role:"img","aria-label":e("sessions.sidebar.group.space")}):n.jsx(Z,{name:"git-branch",className:Pe("h-3 w-3 flex-shrink-0",Lt&&"oc-ref-tint"),style:Lt?or(Lt):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:Oe})]}):null,Ve.length>0?n.jsx(Xo,{items:Ve,directory:Yt}):null,kc?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:kc}):null]})})]})}),Ui&&!R&&!oe?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:Ui}):null,n.jsx("div",{className:Pe("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",oe&&!nt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",wr||G&&!M?"opacity-100":Pe("opacity-0",ce)),children:n.jsxs(bi,{delayDuration:400,children:[be?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",qi,_s?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":ic,onPointerDown:Vi,onMouseDown:Gi,onClick:gg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:_s?"check":"eye",className:_s?bg:oo})})}),n.jsx(Kt,{side:"top",sideOffset:6,children:ic})]}):null,Ee?n.jsx(M5,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:qi,iconSizeClass:oo,onPointerDown:Vi,onMouseDown:Gi,onArchive:og,onDelete:ig}):null,je?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",qi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:ag,onMouseDown:lg,onClick:cg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"external-link",className:oo})})}),n.jsx(Kt,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Rs,{open:fc,onOpenChange:zm,onOpenChangeComplete:hc,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",G?"h-6 w-6 opacity-100":wr?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:ng,onMouseDown:rg,onClick:sg,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"more-2",className:oo})})}),vg]})]})})]}),jg]})}),Mi&&Wn?N:null,n.jsx(Qs,{open:ht,onOpenChange:Ot,children:n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(on,{children:[n.jsx(nn,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(rn,{children:_i===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:_i}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:_i})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:te,onChange:J=>et(J.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(Pn,{children:[n.jsx(Nt,{type:"button",onClick:()=>Ot(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{type:"button",onClick:()=>{Ot(!1),zi(te,xt??s)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},ge.id)}const yu=t=>yt(t.session.directory??null),O5=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),B5=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",s=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(s)?t.openSidebarMenuKey.slice(s.length):null},xu=t=>t.menuOpenSessionId??B5(t),bo=(t,e,s)=>e?s.has(t.node.session.id)?!0:gr(t.node,e):!1,fl=(t,e,s,r,o)=>{if(t.session.id!==e.session.id)return!0;const i=o(t);if(s.has(i)!==r.has(i)||t.children.length!==e.children.length)return!0;for(let a=0;a<t.children.length;a+=1)if(fl(t.children[a],e.children[a],s,r,o))return!0;return!1},F5=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return fl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||fl(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},_5=(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&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&Tp(t,e),L5=(t,e)=>{if(t.node.session.id!==e.node.session.id||!_5(t.node.session,e.node.session)||!E5(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(yu(t.node)!==yu(e.node))return"nodeDirectory";if(!O5(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Gh(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&F5(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(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&&(bo(t,t.editingId,t.subtreeContainsEditing)||bo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=xu(t),o=xu(e);if(gr(t.node,r)||gr(e.node,o))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.children===e.children?null:"callbacks"},$5=(t,e)=>{const s=L5(t,e);return s===null?!0:(As(`ui.sidebar_session_node.props_changed.${s}`),!1)},z5=l.memo(A5,$5);function K5(t){return t.stopPropagation()}const W5=t=>{const{t:e}=Et(),s=l.useRef(t.editingId),r=l.useRef(t.editTitle),o=l.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,o.current=t.deleteSessionConfirm;const i=le(_=>_.setSessionSwitcherOpen),a=mt(_=>_.setCurrentSession),d=mt(_=>_.updateSessionTitle),c=mt(_=>_.deleteSession),u=mt(_=>_.deleteSessions),f=mt(_=>_.archiveSession),p=mt(_=>_.archiveSessions),h=mt(_=>_.unarchiveSession),{mobileVariant:g,allowReselect:b,onSessionSelected:x,resetSessionSearch:y,descendantIds:S,showDeletionDialog:m,setDeleteSessionConfirm:v,setEditingId:w,setEditingRowKey:T,editingSessionId:k,editingOccurrenceKey:I,setEditTitle:B}=t,O=l.useCallback((_,$)=>{if(Pa("navigation.session_select"),le.getState().closeMainSurfaces(),g&&i(!1),_===mt.getState().currentSessionId){b&&x?.(_),y();return}Pa("navigation.session_state_set"),a(_,$??null),x?.(_),y()},[b,g,x,y,a,i]),F=l.useCallback((_,$)=>{w(_),T(I),B($)},[I,B,w,T]),j=l.useCallback(async _=>{if(!s.current)return;const E=(_??r.current).trim();if(E)try{await d(k,E)}catch(D){console.error("[session-actions] rename failed",D),He.error(e("sessions.sidebar.session.rename.error",{detail:vf(D instanceof Error?D:new Error(String(D)),e)}))}w(null),T(null),B("")},[k,B,w,T,e,d]),P=l.useCallback(()=>{w(null),T(null),B("")},[B,w,T]),L=l.useCallback(_=>{pi(_).then($=>{if($.ok){He.success(e("sessions.sidebar.session.copyId.success"));return}He.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>He.error(e("sessions.sidebar.session.copyId.error")))},[e]),z=l.useCallback(async(_,$,E)=>{const D=$?.archivedBucket===!0||$?.hardDelete===!0,C=E?.descendantIds??S;await oy(D?"delete":"archive",_,C,{archiveSession:f,archiveSessions:p,deleteSession:c,deleteSessions:u},e)},[f,p,c,u,S,e]),H=l.useCallback((_,$)=>{const E=$?.archivedBucket===!0||$?.hardDelete===!0,D=wl(_.id,S,E);if(!m||$?.skipConfirm===!0){z(_,$,{descendantIds:D});return}v({session:_,descendantCount:D.length,descendantIds:D,archivedBucket:E})},[S,z,v,m]),R=l.useCallback(async()=>{const _=o.current;if(!_)return;const{session:$,archivedBucket:E,descendantIds:D}=_;v(null),await z($,{archivedBucket:E},{descendantIds:D})},[z,v]),G=l.useCallback(async _=>{await h(_.id)?He.success(e("sessions.sidebar.session.restore.success")):He.error(e("sessions.sidebar.session.restore.error"))},[e,h]);return l.useMemo(()=>({handleSessionSelect:O,handleSessionDoubleClick:F,handleSaveEdit:j,handleCancelEdit:P,handleCopySessionId:L,handleDeleteSession:H,handleRestoreSession:G,confirmDeleteSession:R}),[P,L,H,G,j,F,O,R])};function H5(t){const e=Ze.c(71),{t:s}=Et(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:d}=t;let c,u,f,p,h,g,b,x,y,S;if(e[0]!==o||e[1]!==s||e[2]!==r){const $=s("sessions.sidebar.session.untitled");p=Qs,y=!!r,e[13]!==o?(S=D=>{D||o(null)},e[13]=o,e[14]=S):S=e[14],f=Zs,b=!1,x="max-w-sm gap-5",u=on;let E;e[15]!==s||e[16]!==r?.archivedBucket?(E=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=E):E=e[17],e[18]!==E?(g=n.jsx(nn,{children:E}),e[18]=E,e[19]=g):g=e[19],c=rn,h=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||$,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||$,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||$,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||$,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||$}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||$}),e[0]=o,e[1]=s,e[2]=r,e[3]=c,e[4]=u,e[5]=f,e[6]=p,e[7]=h,e[8]=g,e[9]=b,e[10]=x,e[11]=y,e[12]=S}else c=e[3],u=e[4],f=e[5],p=e[6],h=e[7],g=e[8],b=e[9],x=e[10],y=e[11],S=e[12];let m;e[20]!==c||e[21]!==h?(m=n.jsx(c,{children:h}),e[20]=c,e[21]=h,e[22]=m):m=e[22];let v;e[23]!==u||e[24]!==g||e[25]!==m?(v=n.jsxs(u,{children:[g,m]}),e[23]=u,e[24]=g,e[25]=m,e[26]=v):v=e[26];let w;e[27]!==a||e[28]!==i?(w=()=>a(!i),e[27]=a,e[28]=i,e[29]=w):w=e[29];const T=!i;let k;e[30]!==i?(k=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=k):k=e[31];let I;e[32]!==s?(I=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=I):I=e[33];let B;e[34]!==k||e[35]!==I||e[36]!==w||e[37]!==T?(B=n.jsxs("button",{type:"button",onClick:w,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":T,children:[k,I]}),e[34]=k,e[35]=I,e[36]=w,e[37]=T,e[38]=B):B=e[38];let O;e[39]!==o?(O=()=>o(null),e[39]=o,e[40]=O):O=e[40];let F;e[41]!==s?(F=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=F):F=e[42];let j;e[43]!==O||e[44]!==F?(j=n.jsx("button",{type:"button",onClick:O,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:F}),e[43]=O,e[44]=F,e[45]=j):j=e[45];let P;e[46]!==d?(P=()=>{d()},e[46]=d,e[47]=P):P=e[47];let L;e[48]!==s||e[49]!==r?.archivedBucket?(L=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=L):L=e[50];let z;e[51]!==P||e[52]!==L?(z=n.jsx("button",{type:"button",onClick:P,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:L}),e[51]=P,e[52]=L,e[53]=z):z=e[53];let H;e[54]!==j||e[55]!==z?(H=n.jsxs("div",{className:"flex items-center gap-2",children:[j,z]}),e[54]=j,e[55]=z,e[56]=H):H=e[56];let R;e[57]!==B||e[58]!==H?(R=n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[B,H]}),e[57]=B,e[58]=H,e[59]=R):R=e[59];let G;e[60]!==f||e[61]!==b||e[62]!==R||e[63]!==x||e[64]!==v?(G=n.jsxs(f,{showCloseButton:b,className:x,children:[v,R]}),e[60]=f,e[61]=b,e[62]=R,e[63]=x,e[64]=v,e[65]=G):G=e[65];let _;return e[66]!==p||e[67]!==G||e[68]!==y||e[69]!==S?(_=n.jsx(p,{open:y,onOpenChange:S,children:G}),e[66]=p,e[67]=G,e[68]=y,e[69]=S,e[70]=_):_=e[70],_}function U5(t){const e=Ze.c(57),{t:s}=Et(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:a,onConfirm:d}=t,c=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==c||e[1]!==u||e[2]!==s?(f=s(c?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]=c,e[1]=u,e[2]=s,e[3]=f):f=e[3];const p=f;let h;e[4]!==c||e[5]!==u||e[6]!==s?(h=c?u===1?s("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?s("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):s("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=c,e[5]=u,e[6]=s,e[7]=h):h=e[7];const g=h,b=!!r;let x;e[8]!==o?(x=_=>{_||o(null)},e[8]=o,e[9]=x):x=e[9];let y;e[10]!==p?(y=n.jsx(nn,{children:p}),e[10]=p,e[11]=y):y=e[11];let S;e[12]!==g?(S=n.jsx(rn,{children:g}),e[12]=g,e[13]=S):S=e[13];let m;e[14]!==y||e[15]!==S?(m=n.jsxs(on,{children:[y,S]}),e[14]=y,e[15]=S,e[16]=m):m=e[16];let v;e[17]!==a||e[18]!==i?(v=()=>a(!i),e[17]=a,e[18]=i,e[19]=v):v=e[19];const w=!i;let T;e[20]!==i?(T=i?n.jsx(Z,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx(Z,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=T):T=e[21];let k;e[22]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=k):k=e[23];let I;e[24]!==k||e[25]!==v||e[26]!==w||e[27]!==T?(I=n.jsxs("button",{type:"button",onClick:v,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":w,children:[T,k]}),e[24]=k,e[25]=v,e[26]=w,e[27]=T,e[28]=I):I=e[28];let B;e[29]!==o?(B=()=>o(null),e[29]=o,e[30]=B):B=e[30];let O;e[31]!==s?(O=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=O):O=e[32];let F;e[33]!==B||e[34]!==O?(F=n.jsx("button",{type:"button",onClick:B,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:O}),e[33]=B,e[34]=O,e[35]=F):F=e[35];let j;e[36]!==d?(j=()=>{d()},e[36]=d,e[37]=j):j=e[37];let P;e[38]!==c||e[39]!==s?(P=s(c?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=c,e[39]=s,e[40]=P):P=e[40];let L;e[41]!==j||e[42]!==P?(L=n.jsx("button",{type:"button",onClick:j,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:P}),e[41]=j,e[42]=P,e[43]=L):L=e[43];let z;e[44]!==F||e[45]!==L?(z=n.jsxs("div",{className:"flex items-center gap-2",children:[F,L]}),e[44]=F,e[45]=L,e[46]=z):z=e[46];let H;e[47]!==I||e[48]!==z?(H=n.jsxs(Pn,{className:"w-full sm:items-center sm:justify-between",children:[I,z]}),e[47]=I,e[48]=z,e[49]=H):H=e[49];let R;e[50]!==H||e[51]!==m?(R=n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,H]}),e[50]=H,e[51]=m,e[52]=R):R=e[52];let G;return e[53]!==b||e[54]!==R||e[55]!==x?(G=n.jsx(Qs,{open:b,onOpenChange:x,children:R}),e[53]=b,e[54]=R,e[55]=x,e[56]=G):G=e[56],G}function hm(t){const e=Ze.c(36),{t:s}=Et(),{value:r,setValue:o,onConfirm:i}=t,a=!!r;let d;e[0]!==o?(d=T=>{T||o(null)},e[0]=o,e[1]=d):d=e[1];let c;e[2]!==s?(c=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==c?(u=n.jsx(nn,{children:c}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==s||e[7]!==r?(f=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?s("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):s("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):s("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=s,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==f?(p=n.jsx(rn,{children:f}),e[9]=f,e[10]=p):p=e[10];let h;e[11]!==u||e[12]!==p?(h=n.jsxs(on,{children:[u,p]}),e[11]=u,e[12]=p,e[13]=h):h=e[13];let g;e[14]!==o?(g=()=>o(null),e[14]=o,e[15]=g):g=e[15];let b;e[16]!==s?(b=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=b):b=e[17];let x;e[18]!==g||e[19]!==b?(x=n.jsx("button",{type:"button",onClick:g,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:b}),e[18]=g,e[19]=b,e[20]=x):x=e[20];let y;e[21]!==s?(y=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=y):y=e[22];let S;e[23]!==i||e[24]!==y?(S=n.jsx("button",{type:"button",onClick:i,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=i,e[24]=y,e[25]=S):S=e[25];let m;e[26]!==S||e[27]!==x?(m=n.jsxs(Pn,{children:[x,S]}),e[26]=S,e[27]=x,e[28]=m):m=e[28];let v;e[29]!==m||e[30]!==h?(v=n.jsxs(Zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,m]}),e[29]=m,e[30]=h,e[31]=v):v=e[31];let w;return e[32]!==a||e[33]!==d||e[34]!==v?(w=n.jsx(Qs,{open:a,onOpenChange:d,children:v}),e[32]=a,e[33]=d,e[34]=v,e[35]=w):w=e[35],w}const V5=new Set;function G5(t){const e=Ze.c(113),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:c,secondaryMeta:u,renderContext:f,rowKey:p,dragKey:h,renderExtras:g,pinnedSessionIds:b,expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:B,toggleParent:O,openSidebarMenuKey:F,setOpenSidebarMenuKey:j,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:R,startFolderRename:G,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,renderChildren:D}=t,C=r===void 0?0:r,N=c===void 0?!1:c,A=f===void 0?"project":f,q=D===void 0?!0:D;As("ui.sidebar_tree_item.render");const ee=p??`${A}:${N?"archived":"active"}:${s.session.id}`,Q=is(Q5),he=is(Z5),M=le(Y5),V=le(q5);let ie;if(e[0]!==s){ie=[];const de=Ne=>Ne.children.forEach(Je=>{ie.push(Je.session.id),de(Je)});de(s),e[0]=s,e[1]=ie}else ie=e[1];const ce=ie.join(`
368
368
  `);let ne;e[2]!==ce?(ne=ce?ce.split(`
369
- `):[],e[2]=ce,e[3]=ne):ne=e[3];const je=ne;let Ee;e[4]!==Q||e[5]!==G||e[6]!==he?(Ee=(de,Ne)=>{if(!de)return null;Ne&&is.getState().collapsedFolderIds.has(Ne)&&he(Ne);const Je=Q(de,"New folder",Ne);return G(de,Je),Je},e[4]=Q,e[5]=G,e[6]=he,e[7]=Ee):Ee=e[7];const we=Ee;let Me;e[8]!==P||e[9]!==H||e[10]!==je||e[11]!==I||e[12]!==v||e[13]!==ee||e[14]!==$||e[15]!==s.session.id||e[16]!==L||e[17]!==z||e[18]!==R||e[19]!==F||e[20]!==T||e[21]!==k||e[22]!==M?(Me={mobileVariant:$,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,descendantIds:je,showDeletionDialog:M,setDeleteSessionConfirm:R,deleteSessionConfirm:H,editingId:v,setEditingId:T,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:ee,editTitle:I,setEditTitle:F},e[8]=P,e[9]=H,e[10]=je,e[11]=I,e[12]=v,e[13]=ee,e[14]=$,e[15]=s.session.id,e[16]=L,e[17]=z,e[18]=R,e[19]=F,e[20]=T,e[21]=k,e[22]=M,e[23]=Me):Me=e[23];const fe=K5(Me),be=g?.childRenderExtrasFor,ke=s.session.directory??o;let Ie;e[24]!==N||e[25]!==i||e[26]!==A||e[27]!==ke?(Ie={groupDirectory:ke,projectId:i,archivedBucket:N,renderContext:A},e[24]=N,e[25]=i,e[26]=A,e[27]=ke,e[28]=Ie):Ie=e[28];const Te=Ie,Y=h??p??s.session.id,ue=g?.subtreeContainsEditing??U5,me=g?.menuOpenSessionId??null,re=g?.nodeStructureKey??"",pe=g?.blockingBadgeSessionScopes,U=g?.relativeTimeTick;let ae;e[29]!==P||e[30]!==E||e[31]!==Te||e[32]!==be||e[33]!==H||e[34]!==C||e[35]!==I||e[36]!==v||e[37]!==w||e[38]!==x||e[39]!==a||e[40]!==y||e[41]!==$||e[42]!==s.children||e[43]!==S||e[44]!==m||e[45]!==L||e[46]!==B||e[47]!==b||e[48]!==q||e[49]!==z||e[50]!==d||e[51]!==R||e[52]!==F||e[53]!==T||e[54]!==k||e[55]!==j||e[56]!==G||e[57]!==_||e[58]!==O?(ae=q?s.children.map(de=>n.jsx(ei,{node:de,pinnedSessionIds:b,expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:F,toggleParent:O,openSidebarMenuKey:B,setOpenSidebarMenuKey:j,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:R,startFolderRename:G,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,depth:C+1,folderOwnerKey:a,selectionScopeKey:d,...Te,renderExtras:be?.(de)},de.session.id)):null,e[29]=P,e[30]=E,e[31]=Te,e[32]=be,e[33]=H,e[34]=C,e[35]=I,e[36]=v,e[37]=w,e[38]=x,e[39]=a,e[40]=y,e[41]=$,e[42]=s.children,e[43]=S,e[44]=m,e[45]=L,e[46]=B,e[47]=b,e[48]=q,e[49]=z,e[50]=d,e[51]=R,e[52]=F,e[53]=T,e[54]=k,e[55]=j,e[56]=G,e[57]=_,e[58]=O,e[59]=ae):ae=e[59];let Re;e[60]!==E||e[61]!==N||e[62]!==we||e[63]!==C||e[64]!==I||e[65]!==v||e[66]!==w||e[67]!==ee||e[68]!==x||e[69]!==a||e[70]!==o||e[71]!==y||e[72]!==$||e[73]!==s||e[74]!==S||e[75]!==m||e[76]!==B||e[77]!==b||e[78]!==i||e[79]!==A||e[80]!==u||e[81]!==d||e[82]!==fe.handleCancelEdit||e[83]!==fe.handleCopySessionId||e[84]!==fe.handleDeleteSession||e[85]!==fe.handleRestoreSession||e[86]!==fe.handleSaveEdit||e[87]!==fe.handleSessionDoubleClick||e[88]!==fe.handleSessionSelect||e[89]!==F||e[90]!==T||e[91]!==k||e[92]!==j||e[93]!==_||e[94]!==Y||e[95]!==ue||e[96]!==me||e[97]!==re||e[98]!==pe||e[99]!==U||e[100]!==ae||e[101]!==O?(Re=n.jsx($5,{expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:F,handleSaveEdit:fe.handleSaveEdit,handleCancelEdit:fe.handleCancelEdit,toggleParent:O,handleSessionSelect:fe.handleSessionSelect,handleSessionDoubleClick:fe.handleSessionDoubleClick,handleCopySessionId:fe.handleCopySessionId,openSidebarMenuKey:B,setOpenSidebarMenuKey:j,createFolderAndStartRename:we,handleDeleteSession:fe.handleDeleteSession,handleRestoreSession:fe.handleRestoreSession,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,pinnedSessionIds:b,node:s,depth:C,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:N,secondaryMeta:u,renderContext:A,rowKey:ee,dragKey:Y,subtreeContainsEditing:ue,menuOpenSessionId:me,nodeStructureKey:re,blockingBadgeSessionScopes:pe,relativeTimeTick:U,children:ae}),e[60]=E,e[61]=N,e[62]=we,e[63]=C,e[64]=I,e[65]=v,e[66]=w,e[67]=ee,e[68]=x,e[69]=a,e[70]=o,e[71]=y,e[72]=$,e[73]=s,e[74]=S,e[75]=m,e[76]=B,e[77]=b,e[78]=i,e[79]=A,e[80]=u,e[81]=d,e[82]=fe.handleCancelEdit,e[83]=fe.handleCopySessionId,e[84]=fe.handleDeleteSession,e[85]=fe.handleRestoreSession,e[86]=fe.handleSaveEdit,e[87]=fe.handleSessionDoubleClick,e[88]=fe.handleSessionSelect,e[89]=F,e[90]=T,e[91]=k,e[92]=j,e[93]=_,e[94]=Y,e[95]=ue,e[96]=me,e[97]=re,e[98]=pe,e[99]=U,e[100]=ae,e[101]=O,e[102]=Re):Re=e[102];let W;e[103]!==H||e[104]!==s.session.id||e[105]!==fe.confirmDeleteSession||e[106]!==R||e[107]!==V||e[108]!==M?(W=H?.session.id===s.session.id?n.jsx(W5,{value:H,setValue:R,showDeletionDialog:M,setShowDeletionDialog:V,onConfirm:fe.confirmDeleteSession}):null,e[103]=H,e[104]=s.session.id,e[105]=fe.confirmDeleteSession,e[106]=R,e[107]=V,e[108]=M,e[109]=W):W=e[109];let ye;return e[110]!==Re||e[111]!==W?(ye=n.jsxs(n.Fragment,{children:[Re,W]}),e[110]=Re,e[111]=W,e[112]=ye):ye=e[112],ye}function G5(t){return t.setShowDeletionDialog}function q5(t){return t.showDeletionDialog}function Y5(t){return t.toggleFolderCollapse}function Z5(t){return t.createFolder}const Q5=(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&&Ep(t.session,e.session)&&yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,X5=(t,e)=>{if(t.node!==e.node&&!Q5(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 s=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(s)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(s)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null)||(t.secondaryMeta?.inSpace??!1)!==(e.secondaryMeta?.inSpace??!1))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","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},ei=l.memo(V5,X5),J5=10,eI=4;function xu(t){const e=Ze.c(7),{providerIDs:s,ringClass:r}=t;let o;if(e[0]!==s||e[1]!==r){let a;e[3]!==r?(a=d=>n.jsx("span",{className:Pe("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(xp,{providerId:d,className:"h-3 w-3"})},d),e[3]=r,e[4]=a):a=e[4],o=s.slice(0,eI).map(a),e[0]=s,e[1]=r,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:o}),e[5]=o,e[6]=i):i=e[6],i}function tI(t){const e=Ze.c(108),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:a,projectId:d,projectLabel:c,expansionKey:u,expanded:f,forceExpanded:p,notifyOnSubtasks:h,toggleParent:g}=t,{t:b}=Et();let x;e[0]!==s.key?(x=we=>we.runOverviewKey===s.key,e[0]=s.key,e[1]=x):x=e[1];const y=le(x),S=a==="mixed-compact",m=qr(a)||S,v=a==="timeline-by-time";let w;e[2]!==v||e[3]!==d||e[4]!==a?(w=we=>(a==="timeline-mixed"||v)&&d?we.projects.find(Me=>Me.id===d)??null:null,e[2]=v,e[3]=d,e[4]=a,e[5]=w):w=e[5];const T=ns(w),k=s.lanes.length;let I;e[6]!==k||e[7]!==b?(I=k===1?b("sessions.sidebar.run.laneCountSingle",{count:k}):b("sessions.sidebar.run.laneCountPlural",{count:k}),e[6]=k,e[7]=b,e[8]=I):I=e[8];const F=I;let O;e[9]!==o?(O=[...o],e[9]=o,e[10]=O):O=e[10];const B=O;let j;e[11]!==B||e[12]!==i||e[13]!==h?(j=n.jsx(vf,{nodes:B,blockingSessionIds:i,includeUnreadSubtasks:h}),e[11]=B,e[12]=i,e[13]=h,e[14]=j):j=e[14];const P=j,L=y?"text-interactive-selection-foreground":"text-muted-foreground";let z;e[15]!==s.key?(z=()=>le.getState().setRunOverviewKey(s.key),e[15]=s.key,e[16]=z):z=e[16];const H=z;if(m){const we=s.key,Me=y?"page":void 0;let fe;e[17]!==s.title||e[18]!==b?(fe=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[17]=s.title,e[18]=b,e[19]=fe):fe=e[19];let be;e[20]!==r||e[21]!==S?(be=S?Kn(r):J5,e[20]=r,e[21]=S,e[22]=be):be=e[22];let ke;e[23]!==be?(ke={paddingInlineStart:be},e[23]=be,e[24]=ke):ke=e[24];const Ie=S?"gap-1.5 py-1":"py-1.5",Te=y?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Y;e[25]!==Ie||e[26]!==Te?(Y=Pe("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ie,Te),e[25]=Ie,e[26]=Te,e[27]=Y):Y=e[27];let ue;e[28]!==P||e[29]!==S?(ue=S?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:P}):null,e[28]=P,e[29]=S,e[30]=ue):ue=e[30];const me=s.title;let re;e[31]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(Fa,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[31]=re):re=e[31];let pe;e[32]!==F?(pe=n.jsxs(n.Fragment,{children:[re,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:F})]}),e[32]=F,e[33]=pe):pe=e[33];const U=S?null:P;let ae;e[34]!==s.lastActivity?(ae=Pp(s.lastActivity),e[34]=s.lastActivity,e[35]=ae):ae=e[35];let Re;e[36]!==s.providerIDs?(Re=n.jsx(xu,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[36]=s.providerIDs,e[37]=Re):Re=e[37];let W;e[38]!==v||e[39]!==S||e[40]!==c||e[41]!==s.title||e[42]!==pe||e[43]!==U||e[44]!==ae||e[45]!==Re||e[46]!==T||e[47]!==L?(W=n.jsx(cl,{compact:S,project:T,projectLabel:c,projectLine:v,title:me,titleClassName:L,branchLabel:null,metaLineLead:pe,statusDot:U,pinnedMarker:null,timeSlot:ae,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:Re,hideMetaOnHoverClass:""}),e[38]=v,e[39]=S,e[40]=c,e[41]=s.title,e[42]=pe,e[43]=U,e[44]=ae,e[45]=Re,e[46]=T,e[47]=L,e[48]=W):W=e[48];let ye;return e[49]!==H||e[50]!==s.key||e[51]!==ke||e[52]!==Y||e[53]!==ue||e[54]!==W||e[55]!==Me||e[56]!==fe?(ye=n.jsxs("button",{type:"button","data-run-row":we,"aria-current":Me,"aria-label":fe,onClick:H,style:ke,className:Y,children:[ue,W]}),e[49]=H,e[50]=s.key,e[51]=ke,e[52]=Y,e[53]=ue,e[54]=W,e[55]=Me,e[56]=fe,e[57]=ye):ye=e[57],ye}let R;e[58]!==u||e[59]!==p||e[60]!==g?(R=we=>{we.stopPropagation(),p||g(u)},e[58]=u,e[59]=p,e[60]=g,e[61]=R):R=e[61];const G=R,_=s.key,$=y?"page":void 0;let E;e[62]!==r?(E=Kn(r),e[62]=r,e[63]=E):E=e[63];let D;e[64]!==E?(D={paddingInlineStart:E},e[64]=E,e[65]=D):D=e[65];const C=y?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let N;e[66]!==C?(N=Pe("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",C),e[66]=C,e[67]=N):N=e[67];let A;e[68]!==G?(A=we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),G(we))},e[68]=G,e[69]=A):A=e[69];let q;e[70]!==f||e[71]!==b?(q=b(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[70]=f,e[71]=b,e[72]=q):q=e[72];let ee;e[73]!==f?(ee=n.jsx(eo,{expanded:f}),e[73]=f,e[74]=ee):ee=e[74];let Q;e[75]!==f||e[76]!==A||e[77]!==q||e[78]!==ee||e[79]!==G?(Q=n.jsx("button",{type:"button",onClick:G,onKeyDown:A,className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":f,"aria-label":q,children:ee}),e[75]=f,e[76]=A,e[77]=q,e[78]=ee,e[79]=G,e[80]=Q):Q=e[80];let he;e[81]!==H?(he=we=>{we.stopPropagation(),H()},e[81]=H,e[82]=he):he=e[82];let M;e[83]!==s.title||e[84]!==b?(M=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[83]=s.title,e[84]=b,e[85]=M):M=e[85];let V;e[86]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Fa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[86]=V):V=e[86];let ie;e[87]!==L?(ie=Pe("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",L),e[87]=L,e[88]=ie):ie=e[88];let ce;e[89]!==s.title||e[90]!==ie?(ce=n.jsx("span",{dir:"auto",className:ie,children:s.title}),e[89]=s.title,e[90]=ie,e[91]=ce):ce=e[91];let ne;e[92]!==s.providerIDs?(ne=n.jsx(xu,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[92]=s.providerIDs,e[93]=ne):ne=e[93];let je;e[94]!==P||e[95]!==he||e[96]!==M||e[97]!==ce||e[98]!==ne?(je=n.jsxs("button",{type:"button",onClick:he,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":M,children:[V,ce,ne,P]}),e[94]=P,e[95]=he,e[96]=M,e[97]=ce,e[98]=ne,e[99]=je):je=e[99];let Ee;return e[100]!==H||e[101]!==s.key||e[102]!==D||e[103]!==N||e[104]!==Q||e[105]!==je||e[106]!==$?(Ee=n.jsxs("div",{"data-run-row":_,"aria-current":$,onClick:H,style:D,className:N,children:[Q,je]}),e[100]=H,e[101]=s.key,e[102]=D,e[103]=N,e[104]=Q,e[105]=je,e[106]=$,e[107]=Ee):Ee=e[107],Ee}const sI=l.memo(tI),nI=24,rI=t=>Array.from({length:Math.min(t,nI)},(e,s)=>s),oI=(t,e,s)=>{const r=new Set(t);for(const o of e)o>=0&&o<s&&r.add(o);return[...r].sort((o,i)=>o-i)},iI=(t,e)=>t.find(s=>s.end>e)?.index??0,aI={"pb-2":8,"pb-1.5":6},Su=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,lI=(t,e)=>`${t.key}|${sr(t,e)??""}`,cI=(t,e,s={})=>{const r=sr(t,e),o=r?s.gapBySpacing?.get(r)??aI[r]:0;return(s.height??t.estimateSize)+o},sr=(t,e)=>e?.kind==="activity-header"||e?.kind==="project-header"?"pb-2":e?.kind==="group-header"&&t.kind!=="project-header"?"pb-1.5":void 0,dI=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function uI({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,a=l.useCallback(()=>e,[e]),d=l.useRef(new Map),c=l.useRef(new Map),u=l.useCallback(j=>{const P=i[j];if(!P)return 32;const L=i[j+1];return cI(P,L,{height:d.current.get(Su(P)),gapBySpacing:c.current})},[i]),f=l.useCallback((j,P,L)=>{const z=zw(j,P,L),H=L.indexFromElement(j),R=i[H];if(R){const G=sr(R,i[H+1]),_=G&&Number.parseFloat(getComputedStyle(j).paddingBottom)||0;G&&c.current.set(G,_),d.current.set(Su(R),z-_)}return z},[i]),p=l.useCallback(j=>{const P=i[j];return P?lI(P,i[j+1]):j},[i]),h=l.useRef(0),[g,b]=l.useState(null),x=g?.slidingIndexes,y=l.useCallback(j=>{const P=Vp(j),L=x?.length?new Set([...s,...x]):s;return oI(P,L,i.length)},[s,i.length,x]),S=Up({count:i.length,enabled:e!==null,getScrollElement:a,estimateSize:u,measureElement:f,getItemKey:p,overscan:8,rangeExtractor:y}),m=S.getVirtualItems(),v=e?S.getTotalSize():0,w=e?Math.max(v-e.clientHeight,0):0,T=e?Math.min(e.scrollTop,w):0,k=iI(m,T);l.useLayoutEffect(()=>{o(k)},[k,o]);const I=l.useRef(null),F=l.useRef(null);l.useLayoutEffect(()=>{const j=F.current;if(!j||j.rows===i||!e||dI())return;const P=oy(j.rows,i);if(!P)return;const L=j.measurements,z=S.measurementsCache,H=L[P.previousHeaderIndex],R=z[P.nextHeaderIndex];if(!H||!R)return;const G=R.start-H.start,_=P.opened?L[P.previousHeaderIndex+1]:L[P.blockEnd],$=P.opened?P.blockEnd:P.nextHeaderIndex+1,E=z[$],D=(_?.start??H.end)+G,C=E?.start??R.end,N=e.scrollTop-e.clientHeight,A=e.scrollTop+e.clientHeight*2,q=new Set,ee=[],Q=[];if(P.opened){for(let he=P.blockStart;he<P.blockEnd;he+=1)q.add(i[he].key);for(let he=$;he<z.length&&z[he].start+D-C<A;he+=1)Q.push(he)}else for(let he=P.blockStart;he<P.blockEnd;he+=1){const M=L[he];!M||M.end+G<N||M.start+G>A||ee.push({row:j.rows[he],nextRow:j.rows[he+1],start:M.start+G,end:M.end+G})}h.current+=1,b({id:h.current,revealKeys:q,ghosts:ee,followingIndex:$,from:D,to:C,slidingIndexes:Q})},[i,e,S]),l.useLayoutEffect(()=>{F.current={rows:i,measurements:S.measurementsCache}}),l.useLayoutEffect(()=>{const j=I.current;if(!g||!j)return;const P={duration:ay,easing:iy},L=g.from-g.to,z=[];for(const R of j.children){if(!(R instanceof HTMLElement))continue;const G=R.dataset.sidebarRowKey??"",_=Number(R.dataset.sidebarVirtualStart);R.dataset.sidebarGhost==="true"?z.push(R.animate(_c(_,R.offsetHeight,g.from,g.to),{...P,fill:"forwards"})):g.revealKeys.has(G)?z.push(R.animate(_c(_,R.offsetHeight,g.from,g.to),P)):Number(R.dataset.index)>=g.followingIndex&&L!==0&&z.push(R.animate([{transform:`translateY(${_+L}px)`},{transform:`translateY(${_}px)`}],P))}let H=!1;return Promise.all(z.map(R=>R.finished)).then(()=>{H||b(R=>R?.id===g.id?null:R)},()=>{}),()=>{H=!0;for(const R of z)R.cancel()}},[g]);const O=(j,P)=>j.treeGuides?n.jsxs("div",{className:"relative flow-root",children:[r(j,P),n.jsx(ly,{guides:j.treeGuides,slotStartPx:Gh})]}):r(j,P);if(!e){const j=rI(i.length),P=j.reduce((z,H)=>z+(i[H]?.estimateSize??0),0),L=i.reduce((z,H)=>z+H.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[j.map(z=>{const H=i[z];return H?n.jsx("div",{className:sr(H,i[z+1]),children:O(H,z)},H.key):null}),L>P?n.jsx("div",{"aria-hidden":"true",style:{height:L-P}}):null]})}const B=g?.ghosts.reduce((j,P)=>Math.max(j,P.end),0)??0;return n.jsxs("div",{ref:I,"data-sidebar-virtual-ready":"true",style:{height:Math.max(v,B),position:"relative"},children:[g?.ghosts.map(j=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${sr(j.row,j.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":j.row.key,"data-sidebar-virtual-start":j.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${j.start}px)`},children:O(j.row,-1)},j.row.key)),m.map(j=>{const P=i[j.index];return P?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${sr(P,i[j.index+1])??""}`,"data-index":j.index,"data-sidebar-row-key":P.key,"data-sidebar-virtual-start":j.start,ref:S.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${j.start}px)`},children:O(P,j.index)},P.key):null})]})}const fI={pinned:"pushpin",work:"eye",chats:"chat-4",timeline:"history"},pI={pinned:"sessions.sidebar.activity.pinnedTitle",work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle",timeline:"sessions.sidebar.activity.projectsTitle"},hI=t=>{const e=Ze.c(33),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:a,onNewChat:d}=t,{t:c}=Et(),u=s==="chats",f=o?void 0:a,p=u?"pe-10":"pe-3.5";let h;e[0]!==p?(h=Pe("group flex w-full items-center gap-1.5 py-1 ps-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",p),e[0]=p,e[1]=h):h=e[1];const g=!r,b=fI[s],x=!o&&"group-hover:hidden";let y;e[2]!==x?(y=Pe("h-3.5 w-3.5 text-muted-foreground/80",x),e[2]=x,e[3]=y):y=e[3];let S;e[4]!==b||e[5]!==y?(S=n.jsx(Z,{name:b,className:y}),e[4]=b,e[5]=y,e[6]=S):S=e[6];let m;e[7]!==r||e[8]!==o?(m=o?null:n.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:n.jsx(Z,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=o,e[9]=m):m=e[9];let v;e[10]!==S||e[11]!==m?(v=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[S,m]}),e[10]=S,e[11]=m,e[12]=v):v=e[12];const w=pI[s];let T;e[13]!==c||e[14]!==w?(T=c(w),e[13]=c,e[14]=w,e[15]=T):T=e[15];let k;e[16]!==T?(k=n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:T}),e[16]=T,e[17]=k):k=e[17];let I;e[18]!==o||e[19]!==f||e[20]!==v||e[21]!==k||e[22]!==h||e[23]!==g?(I=n.jsxs("button",{type:"button",onClick:f,disabled:o,className:h,"aria-expanded":g,children:[v,k]}),e[18]=o,e[19]=f,e[20]=v,e[21]=k,e[22]=h,e[23]=g,e[24]=I):I=e[24];let F;e[25]!==i||e[26]!==u||e[27]!==d||e[28]!==c?(F=u?n.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),d()},className:Pe("absolute inset-e-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",i?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-has-[:focus-visible]/chats:opacity-100 group-has-[:focus-visible]/chats:pointer-events-auto"),"aria-label":c("sessions.sidebar.header.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})}):null,e[25]=i,e[26]=u,e[27]=d,e[28]=c,e[29]=F):F=e[29];let O;return e[30]!==I||e[31]!==F?(O=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[I,F]}),e[30]=I,e[31]=F,e[32]=O):O=e[32],O},hm=l.createContext(null);function wu(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const i=s.offsetParent;s=i instanceof HTMLElement?i:null}const r=t.closest("[data-sidebar-virtual-start]"),o=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(o)?o:0)}function mI(t){const e=Ze.c(11),{suspended:s,layoutKey:r,scrollRef:o,children:i}=t,a=s===void 0?!1:s,d=r===void 0?"":r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const u=l.useRef(c),f=l.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=y=>(u.current.add(y),f.current?.(),()=>{u.current.delete(y),f.current?.()}),e[1]=p):p=e[1];const h=p;let g;e[2]!==o||e[3]!==a?(g=()=>{const y=o.current;if(a||!y)return;const S=document.createElement("div");S.dataset.sidebarCrossfadeLayer="true",S.className="pointer-events-none sticky top-0 z-30 h-0",S.style.marginBlock="0px",y.prepend(S);let m=null,v=null,w=null,T=0;const k=new Set;let I=[];const F=window.matchMedia("(prefers-reduced-motion: reduce)"),O=(R,G)=>{const _=document.activeElement,$=_ instanceof HTMLElement&&R.host.contains(_),E=$?y.scrollTop:null;G.moveBefore&&G.isConnected&&R.host.isConnected?G.moveBefore(R.host,null):G.append(R.host),$&&_.focus({preventScroll:!0}),E!==null&&y.scrollTop!==E&&(y.scrollTop=E)},B=()=>{w?.cancel(),w=null,v?.remove(),v=null},j=()=>{let R=null,G=-1/0;for(const{entry:_,top:$}of I)$<=y.scrollTop&&$>=G&&(G=$,R=_);if(m!==R){if(B(),m&&R&&!F.matches){const _=m.host.cloneNode(!0);_ instanceof HTMLElement&&(_.inert=!0,_.setAttribute("aria-hidden","true"),_.querySelectorAll("[id]").forEach(gI),_.className="pointer-events-none absolute inset-x-0 top-0 z-30",v=_)}m&&(O(m,m.slot),m.slot.style.removeProperty("height")),m=R,S.hidden=!R,R&&(R.slot.style.height=`${R.host.getBoundingClientRect().height}px`,O(R,S),v&&(S.append(v),w=v.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=B))}},P=()=>{m&&(m.slot.style.height=`${m.host.getBoundingClientRect().height}px`);const R=wu(y)+y.clientTop;I=Array.from(u.current,G=>({entry:G,top:wu(G.slot)-R})),j()},L=new ResizeObserver(P),z=new MutationObserver(()=>{cancelAnimationFrame(T),T=requestAnimationFrame(P)});L.observe(y);const H=()=>{z.disconnect();for(const R of k)u.current.has(R)||(L.unobserve(R.host),R.slot.parentElement&&L.unobserve(R.slot.parentElement),k.delete(R));for(const R of u.current){const G=R.slot.closest("[data-sidebar-virtual-start]");G&&z.observe(G,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(R)||(L.observe(R.host),R.slot.parentElement&&L.observe(R.slot.parentElement),k.add(R))}cancelAnimationFrame(T),T=requestAnimationFrame(P)};return f.current=H,y.addEventListener("scroll",j,{passive:!0}),H(),P(),()=>{f.current=null,cancelAnimationFrame(T),y.removeEventListener("scroll",j),L.disconnect(),z.disconnect(),B(),S.hidden=!0,m&&(O(m,m.slot),m.slot.style.removeProperty("height")),S.remove()}},e[2]=o,e[3]=a,e[4]=g):g=e[4];let b;e[5]!==d||e[6]!==o||e[7]!==a?(b=[a,d,o],e[5]=d,e[6]=o,e[7]=a,e[8]=b):b=e[8],l.useLayoutEffect(g,b);let x;return e[9]!==i?(x=n.jsx(hm.Provider,{value:h,children:i}),e[9]=i,e[10]=x):x=e[10],x}function gI(t){return t.removeAttribute("id")}function bI(t){const e=Ze.c(15);let s,r;e[0]!==t?({register:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=l.useRef(null),[i]=l.useState(yI);let a,d;e[3]!==i||e[4]!==r?(a=()=>{const h=o.current;if(!h)return;h.append(i);const g=r({slot:h,host:i});return()=>{g(),i.remove()}},d=[i,r],e[3]=i,e[4]=r,e[5]=a,e[6]=d):(a=e[5],d=e[6]),l.useLayoutEffect(a,d);let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{ref:o}),e[7]=c):c=e[7];let u;e[8]!==s?(u=n.jsx("div",{...s}),e[8]=s,e[9]=u):u=e[9];let f;e[10]!==i||e[11]!==u?(f=gl.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=n.jsxs(n.Fragment,{children:[c,f]}),e[13]=f,e[14]=p):p=e[14],p}function yI(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function mm(t){const e=Ze.c(3),s=l.useContext(hm);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(bI,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const xI=t=>{const e=Ze.c(3),[s,r]=l.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let a=!0;const d=()=>{Mo.getDirectoryAvailability(t).then(c=>{a&&c!=="unknown"&&r(c==="missing")})};return d(),window.addEventListener("focus",d),()=>{a=!1,window.removeEventListener("focus",d)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),l.useEffect(o,i),s},wa=t=>{const e=Ze.c(27),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:a,projectIconBackground:d,isCollapsed:c,alwaysShowActions:u,labelClassName:f}=t,p=u===void 0?!1:u,{currentTheme:h}=br(),g=o?kl[o]:null;let b;e[0]!==i?(b=Cl(i),e[0]=i,e[1]=b):b=e[1];const x=b,y=c!==void 0,S=y?p?"hidden":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0":void 0;let m;e[2]!==p||e[3]!==y||e[4]!==c?(m=y?n.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",p?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-has-[:focus-visible]/project:opacity-100"),children:n.jsx(Z,{name:c?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=p,e[3]=y,e[4]=c,e[5]=m):m=e[5];let v;e[6]!==p||e[7]!==h||e[8]!==y||e[9]!==x||e[10]!==S||e[11]!==s||e[12]!==d||e[13]!==a||e[14]!==g?(v=a?n.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",y&&p?"hidden":"inline-flex",S),style:d?{backgroundColor:d}:void 0,children:n.jsx(Il,{project:{id:s,iconImage:a},options:{themeVariant:h.metadata.variant,iconColor:h.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?n.jsx(Z,{name:g,className:"h-3.5 w-3.5",style:x?{color:x}:void 0}):n.jsx(Z,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:x?{color:x}:void 0})})}):g?n.jsx(Z,{name:g,className:Pe("h-3.5 w-3.5",S),style:x?{color:x}:void 0}):n.jsx(Z,{name:"folder",className:Pe("h-3.5 w-3.5 text-muted-foreground/80",S),style:x?{color:x}:void 0}),e[6]=p,e[7]=h,e[8]=y,e[9]=x,e[10]=S,e[11]=s,e[12]=d,e[13]=a,e[14]=g,e[15]=v):v=e[15];let w;e[16]!==m||e[17]!==v?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[m,v]}),e[16]=m,e[17]=v,e[18]=w):w=e[18];let T;e[19]!==f?(T=Pe("truncate typography-ui-header font-semibold text-foreground",f),e[19]=f,e[20]=T):T=e[20];let k;e[21]!==r||e[22]!==T?(k=n.jsx("span",{className:T,children:r}),e[21]=r,e[22]=T,e[23]=k):k=e[23];let I;return e[24]!==w||e[25]!==k?(I=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=I):I=e[26],I},SI=t=>{const e=Ze.c(68),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:a,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:h,hideDirectoryControls:g,alwaysShowActions:b,onToggle:x,onNewSession:y,onNewWorktreeSession:S,onManageWorktrees:m,onManageSpaces:v,onOpenSourceBoard:w,onOpenFolder:T,onRenameStart:k,onArchiveAll:I,onClose:F,children:O,showCreateButtons:B,hideHeader:j,statusIndicator:P,openSidebarMenuKey:L,setOpenSidebarMenuKey:z,projectPickerOptions:H,onProjectSelect:R}=t,G=r===void 0?!1:r,_=B===void 0?!0:B,$=j===void 0?!1:j,E=P===void 0?null:P,{t:D}=Et(),C=xI(a);let N;e[0]!==G||e[1]!==s?(N={id:s,disabled:G},e[0]=G,e[1]=s,e[2]=N):N=e[2];const{attributes:A,listeners:q,setNodeRef:ee,transform:Q,transition:he,isDragging:M}=ji(N),V=l.useRef(!1),ie=`project:${s}`,ce=L===ie,[ne,je]=l.useState(!1),Ee=!!(H&&R);let we;e[3]!==ie||e[4]!==z?(we=Ae=>{Ae&&je(!1),z(Ae?ie:null)},e[3]=ie,e[4]=z,e[5]=we):we=e[5];const Me=we;let fe;e[6]!==g||e[7]!==h||e[8]!==I||e[9]!==F||e[10]!==v||e[11]!==m||e[12]!==y||e[13]!==T||e[14]!==w||e[15]!==k||e[16]!==_||e[17]!==D?(fe=Ae=>n.jsxs(n.Fragment,{children:[_&&!h&&!g&&y&&n.jsxs(Ae,{onClick:y,children:[n.jsx(Z,{name:"add",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.newSession")]}),h&&!g&&m&&n.jsxs(Ae,{onClick:m,children:[n.jsx(Z,{name:"node-tree",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.manageWorktrees")]}),h&&!g&&v&&n.jsxs(Ae,{onClick:v,children:[n.jsx(Z,{name:"box-3",className:"me-1.5 h-4 w-4"}),D("spaces.page.menuItem")]}),h&&!g&&w&&n.jsxs(Ae,{onClick:w,children:[n.jsx(Z,{name:"git-pull-request",className:"me-1.5 h-4 w-4"}),D("sourceBoard.title")]}),T&&n.jsxs(Ae,{onClick:T,children:[n.jsx(Z,{name:"folder-received",className:"me-1.5 h-4 w-4"}),D(ip())]}),n.jsxs(Ae,{onClick:k,children:[n.jsx(Z,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.edit")]}),I&&n.jsxs(Ae,{onClick:I,children:[n.jsx(Z,{name:"archive",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Ae,{onClick:F,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=g,e[7]=h,e[8]=I,e[9]=F,e[10]=v,e[11]=m,e[12]=y,e[13]=T,e[14]=w,e[15]=k,e[16]=_,e[17]=D,e[18]=fe):fe=e[18];const be=fe,ke=jI,Ie=kI,Te=CI;let Y;e[19]===Symbol.for("react.memo_cache_sentinel")?(Y=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey)&&(V.current=!0)},e[19]=Y):Y=e[19];const ue=Y;let me;e[20]!==x?(me=()=>{if(V.current){V.current=!1;return}x()},e[20]=x,e[21]=me):me=e[21];const re=me,U=(_&&h&&!g&&!!S?1:0)+(g?0:1),ae=U===2?"[--oc-actions-reserve:66px]":U===1&&_?"[--oc-actions-reserve:38px]":_||U===1?"[--oc-actions-reserve:12px]":void 0,Re=b?void 0:ce?"oc-actions-mask":"group-hover/project:oc-actions-mask group-has-[:focus-visible]/project:oc-actions-mask",W=b?void 0:ce?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0";let ye;e[22]!==Q?(ye=ki.Transform.toString(Q),e[22]=Q,e[23]=ye):ye=e[23];let de;e[24]!==ye||e[25]!==he?(de={transform:ye,transition:he},e[24]=ye,e[25]=he,e[26]=de):de=e[26];const Ne=M&&"opacity-30";let Je;e[27]!==Ne?(Je=Pe("relative",Ne),e[27]=Ne,e[28]=Je):Je=e[28];let Ge;e[29]!==b||e[30]!==A||e[31]!==C||e[32]!==Me||e[33]!==re||e[34]!==ae||e[35]!==W||e[36]!==Re||e[37]!==g||e[38]!==$||e[39]!==s||e[40]!==p||e[41]!==ne||e[42]!==ce||e[43]!==Ee||e[44]!==h||e[45]!==q||e[46]!==y||e[47]!==S||e[48]!==R||e[49]!==c||e[50]!==i||e[51]!==a||e[52]!==d||e[53]!==f||e[54]!==u||e[55]!==o||e[56]!==H||e[57]!==be||e[58]!==_||e[59]!==E||e[60]!==D?(Ge=$?null:n.jsx(n.Fragment,{children:n.jsxs(Zr,{open:ne,onOpenChange:je,children:[n.jsx(zl,{render:n.jsx(mm,{className:Pe("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Ae=>{g||(Ae.preventDefault(),je(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",...A,children:[Ee?n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button",className:Pe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",h&&!g?b||ce?"pe-20":"pe-0 group-hover/project:pe-20 group-has-[:focus-visible]/project:pe-20":b||ce?"pe-14":"pe-0 group-hover/project:pe-14 group-has-[:focus-visible]/project:pe-14"),"aria-label":D("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(wa,{id:s,projectLabel:o,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f}),n.jsx(Z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),a?n.jsx(Qo,{directory:a,className:"ms-auto"}):null]})}),n.jsx(Ms,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:H?.map(Ae=>n.jsxs(rs,{onClick:()=>R?.(Ae.id),className:"flex items-center justify-between gap-3",title:Ae.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(wa,{...Ae})}),Ae.id===s?n.jsx(Z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Ae.id))})]}):n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:ue,onClick:re,...q,className:Pe("@container flex-1 min-w-0 flex items-center gap-1.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",b?h&&!g?"pe-20":"pe-14":ae),children:[n.jsx(wa,{id:s,projectLabel:o,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:b,labelClassName:Pe("[--oc-actions-inset:20px]",Re)}),C?n.jsx("span",{className:Pe("inline-flex flex-shrink-0 items-center text-status-warning",W),title:D("sessions.sidebar.project.folderMissing"),"aria-label":D("sessions.sidebar.project.folderMissing"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,E?n.jsx("span",{className:Pe("ms-1 inline-flex flex-shrink-0 items-center",W),children:E}):null,a?n.jsx(Qo,{directory:a,className:Pe("ms-auto",W)}):null]})}),n.jsx(Kt,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:Pe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",_?"inset-e-7":"inset-e-0.5"),children:[_&&h&&!g&&S?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),S()},className:Pe("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",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Z,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(Rs,{open:ce,onOpenChange:Me,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",ce?"opacity-100 pointer-events-auto":b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Ie,onMouseDown:Te,onClick:ke,children:n.jsx(Z,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Ms,{align:"end",className:"min-w-[180px]",children:be(rs)})]})]}),_&&y?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),y()},className:Pe("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",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Ll,{className:"min-w-[180px]",children:be($n)})]})}),e[29]=b,e[30]=A,e[31]=C,e[32]=Me,e[33]=re,e[34]=ae,e[35]=W,e[36]=Re,e[37]=g,e[38]=$,e[39]=s,e[40]=p,e[41]=ne,e[42]=ce,e[43]=Ee,e[44]=h,e[45]=q,e[46]=y,e[47]=S,e[48]=R,e[49]=c,e[50]=i,e[51]=a,e[52]=d,e[53]=f,e[54]=u,e[55]=o,e[56]=H,e[57]=be,e[58]=_,e[59]=E,e[60]=D,e[61]=Ge):Ge=e[61];let ge;return e[62]!==O||e[63]!==ee||e[64]!==de||e[65]!==Je||e[66]!==Ge?(ge=n.jsxs("div",{ref:ee,style:de,className:Je,children:[Ge,O]}),e[62]=O,e[63]=ee,e[64]=de,e[65]=Je,e[66]=Ge,e[67]=ge):ge=e[67],ge},wI=t=>{const e=Ze.c(21),{id:s,disabled:r,children:o}=t,i=r===void 0?!1:r;let a;e[0]!==i||e[1]!==s?(a={id:s,disabled:i},e[0]=i,e[1]=s,e[2]=a):a=e[2];const{listeners:d,setNodeRef:c,setActivatorNodeRef:u,transform:f,transition:p,isDragging:h}=ji(a);let g;e[3]!==d||e[4]!==u?(g={listeners:d,setActivatorNodeRef:u},e[3]=d,e[4]=u,e[5]=g):g=e[5];const b=g;let x;e[6]!==f?(x=ki.Transform.toString(f),e[6]=f,e[7]=x):x=e[7];let y;e[8]!==x||e[9]!==p?(y={transform:x,transition:p},e[8]=x,e[9]=p,e[10]=y):y=e[10];const S=h&&"opacity-50";let m;e[11]!==S?(m=Pe("space-y-0.5 rounded-md",S),e[11]=S,e[12]=m):m=e[12];let v;e[13]!==o||e[14]!==b?(v=o(b),e[13]=o,e[14]=b,e[15]=v):v=e[15];let w;return e[16]!==c||e[17]!==y||e[18]!==m||e[19]!==v?(w=n.jsx("div",{ref:c,style:y,className:m,children:v}),e[16]=c,e[17]=y,e[18]=m,e[19]=v,e[20]=w):w=e[20],w},vI=l.memo(wI);function jI(t){t.stopPropagation()}function kI(t){t.stopPropagation()}function CI(t){t.stopPropagation()}const vu=[],II=t=>{const e=Ze.c(6),{nodes:s,includeUnreadSubtasks:r,children:o}=t;let i;e[0]!==r||e[1]!==s?(i={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=i):i=e[2];const a=Sf(i);let d;return e[3]!==o||e[4]!==a?(d=o(a),e[3]=o,e[4]=a,e[5]=d):d=e[5],d},va=(t,e)=>e?t.sessions.some(s=>gr(s,e)):!1,PI=(t,e,s)=>t.sessions.some(r=>Vh(r,r,e,s,t.directory,t.directory)),EI=(t,e,s)=>{const r=o=>{const i=o.session.id;return e.get(i)!==s.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},TI=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const a=`project:${r}:${i.session.id}`;return e.has(a)!==s.has(a)?!0:i.children.some(o)};return t.sessions.some(o)},DI=(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&&PI(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&EI(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&TI(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(va(e.group,t.editingId)||va(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&va(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=Zo(e.group.sessions,t.openSidebarMenuKey,"project",s),o=Zo(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||o)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??yt(e.group.directory??null)];if(s.includes(t.folderRename?.scopeKey??null)||s.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},RI=l.memo(function(e){const s=Ze.c(23),{label:r,sessions:o,worktree:i}=e,{t:a}=Et(),d=cm();let c;s[0]!==o||s[1]!==d||s[2]!==i?(c=S=>{S.stopPropagation(),Tn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:d||S.shiftKey})},s[0]=o,s[1]=d,s[2]=i,s[3]=c):c=s[3];const u=d?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=Pe("inline-flex h-6 w-6 items-center justify-center rounded-md hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u),s[4]=u,s[5]=f):f=s[5];let p;s[6]!==r||s[7]!==d||s[8]!==a?(p=d?a("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):a("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=d,s[8]=a,s[9]=p):p=s[9];let h;s[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"}),s[10]=h):h=s[10];let g;s[11]!==c||s[12]!==f||s[13]!==p?(g=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:c,className:f,"aria-label":p,children:h})}),s[11]=c,s[12]=f,s[13]=p,s[14]=g):g=s[14];let b;s[15]!==d||s[16]!==a?(b=a(d?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=d,s[16]=a,s[17]=b):b=s[17];let x;s[18]!==b?(x=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b})}),s[18]=b,s[19]=x):x=s[19];let y;return s[20]!==g||s[21]!==x?(y=n.jsxs(Ut,{children:[g,x]}),s[20]=g,s[21]=x,s[22]=y):y=s[22],y}),ju=[];function NI(t){const{t:e}=Et(),s=Wl(),r=Yg(t.group.space?.id),o=Gs(Se=>{const We=t.group.space?.id;return We!=null&&nS(Se.journey?.get(We),Se.spaces.get(We),Se.actions.get(We))}),{group:i,groupKey:a,projectId:d,hideGroupLabel:c,renderBody:u=!0,isEmpty:f=!1,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,groupSearchDataByGroup:g,visibleSessionCount:b,sessionBatchSize:x,collapsedGroups:y,hideDirectoryControls:S,showMoreGroupSessions:m,resetGroupSessionLimit:v,mobileVariant:w,alwaysShowActions:T,activeProjectId:k,setActiveProjectIdOnly:I,setSessionSwitcherOpen:F,openNewSessionDraft:O,pinnedSessionIds:B,sessionOrderIndex:j,notifyOnSubtasks:P,onToggleCollapsedGroup:L,dragHandleProps:z,compactBodyPadding:H=!1,expandedParents:R,editingId:G,editingRowKey:_,openSidebarMenuKey:$,editTitle:E,folderRename:D,setFolderRenameDraft:C,clearFolderRename:N}=t,q=ns(Se=>d?Se.projects.find(We=>We.id===d)?.path??null:null)??i.directory??null,ee=is(Se=>Se.toggleFolderCollapse),Q=is(Se=>Se.renameFolder),he=is(Se=>Se.deleteFolder),M=is(Se=>Se.addSessionToFolder),V=le(Se=>Se.showDeletionDialog),[ie,ce]=l.useState(null),ne=l.useCallback((Se,We)=>{const K=j.get(Se.session.id),xe=j.get(We.session.id);if(K!==void 0||xe!==void 0){if(K===void 0)return 1;if(xe===void 0)return-1;if(K!==xe)return K-xe}return Kl(Se.session,We.session,B,dp)},[B,j]),je=p?g.get(i):null,Ee=p?!1:y.has(a),we=rS(!i.isMain&&i.worktree?i.worktree.path:null),Me=i.isMain||i.isArchivedBucket||c?null:yt(i.directory??null),fe=i.isMain||i.isArchivedBucket||c?null:i.branch?.trim()||null,be=wp(Me,fe),ke=be?`var(--pr-${be.visualState})`:void 0,Ie=kp(be,e),Te=be?Bl(be.provider,be.number):"",Y=be?Ie?`${Te} · ${Ie}`:Te:void 0,ue=Jr(),me=l.useMemo(()=>{const Se=i.folderScopes?.map(We=>yt(We.directory))??[yt(i.directory??null)];return[...new Set(Se.filter(We=>!!We))]},[i.directory,i.folderScopes]);l.useSyncExternalStore(l.useCallback(Se=>me.length>0?ue.subscribeBootstrap(Se):()=>{},[me.length,ue]),l.useCallback(()=>me.map(Se=>`${Se}\0${ue.getBootstrapState(Se)??""}\0${ue.getBootstrapFailure(Se)??""}\0${ue.getInitializationState(Se)??""}\0${ue.getInitializationFailure(Se)??""}`).join(""),[me,ue]),l.useCallback(()=>"",[]));const re=me.some(Se=>{const We=ue.getBootstrapState(Se);return We==="queued"||We==="running"}),pe=me.find(Se=>ue.getBootstrapState(Se)==="failed"||ue.getInitializationState(Se)==="failed")??null,U=pe!==null&&ue.getBootstrapState(pe)==="failed",ae=pe?U?ue.getBootstrapFailure(pe):ue.getInitializationFailure(pe):void 0,Re=ae==="os-permission"&&sf(),[W,ye]=l.useState(!1),de=l.useCallback(()=>{pe&&ue.requestBootstrap({directory:pe,priority:Ee?"visible":"expanded",reason:i.isMain?"project-expanded":"worktree-expanded",force:!0})},[ue,pe,i.isMain,Ee]),Ne=l.useCallback(async()=>{if(!(!pe||!Re||W)){ye(!0);try{(await nf(pe)).success&&de()}finally{ye(!1)}}},[Re,pe,W,de]),Je=x??(S?10:7),Ge=Math.max(Je,b??Je),ge=p?je?.groupMatches===!0:!1,Ae=p,Ye=l.useMemo(()=>[...Ae?je?.filteredNodes??[]:i.sessions].sort(ne),[ne,i.sessions,je?.filteredNodes,Ae]),nt=i.folderScopeKey??yt(i.directory??null),oe=lr(d,i.directory),tt=l.useMemo(()=>i.folderScopes&&i.folderScopes.length>0?i.folderScopes:nt?[{scopeKey:nt,directory:i.directory??null}]:[],[nt,i.directory,i.folderScopes]),Ue=is(hr(l.useCallback(Se=>tt.map(({scopeKey:We})=>Se.foldersMap[We]??vu),[tt]))),gt=l.useMemo(()=>tt.flatMap(({scopeKey:Se,directory:We},K)=>(Ue[K]??vu).map(Xe=>({folder:Xe,scopeKey:Se,scopeDirectory:We}))),[Ue,tt]),bt=is(hr(l.useCallback(Se=>new Set(Ue.flatMap(We=>We.filter(K=>Se.collapsedFolderIds.has(K.id)).map(K=>K.id))),[Ue]))),Ce=l.useMemo(()=>{const Se=new Map,We=K=>{K.forEach(xe=>{Se.set(xe.session.id,xe),xe.children.length>0&&We(xe.children)})};return We(Ye),Se},[Ye]),_e=l.useMemo(()=>gt.map(({folder:Se,scopeKey:We,scopeDirectory:K})=>{const xe=ll(Se.sessionIds,Ce).sort(ne);return{folder:Se,scopeKey:We,scopeDirectory:K,nodes:xe}}),[gt,Ce,ne]),ze=l.useMemo(()=>{const Se=Uh(_e.map(({folder:We,nodes:K})=>({id:We.id,name:We.name,parentId:We.parentId,nodeCount:K.length})),{archivedBucket:i.isArchivedBucket===!0,searchQuery:p?h:""});return _e.filter(({folder:We})=>Se.has(We.id))},[_e,i.isArchivedBucket,p,h]),Oe=G,it=$,X=l.useMemo(()=>new Set(ze.flatMap(Se=>Se.folder.sessionIds)),[ze]),Be=l.useMemo(()=>Ye.filter(Se=>!X.has(Se.session.id)),[Ye,X]),Le=l.useMemo(()=>{const Se=new Map(ze.map(We=>[We.folder.id,We]));return Hh(ze.map(We=>We.folder)).map(We=>Se.get(We.id)).filter(We=>!!We)},[ze]),at=l.useMemo(()=>{const Se=new Map;return ze.forEach(We=>{if(!We.folder.parentId)return;const K=Se.get(We.folder.parentId)??[];K.push(We),Se.set(We.folder.parentId,K)}),Se},[ze]),qe=l.useMemo(()=>{const Se=new Map(ze.map(xe=>[xe.folder.id,xe])),We=new Map,K=(xe,Xe)=>{const lt=We.get(xe);if(lt!==void 0)return lt;if(Xe.has(xe))return[];Xe.add(xe);const Bt=Se.get(xe),Pt=Bt?[...Bt.nodes]:[];for(const Gt of at.get(xe)??[])Pt.push(...K(Gt.folder.id,Xe));return We.set(xe,Pt),Pt};return ze.forEach(({folder:xe})=>K(xe.id,new Set)),We},[ze,at]),ut="project",dt=l.useMemo(()=>{const Se=new Set;return Gd(Ye,Oe,Se),ze.forEach(({nodes:We})=>{Gd(We,Oe,Se)}),Se},[Ye,ze,Oe]),ft=l.useMemo(()=>{if(!it)return null;const Se=Zo(Ye,it,ut,!!i.isArchivedBucket);if(Se)return Se;for(const{nodes:We}of ze){const K=Zo(We,it,ut,!!i.isArchivedBucket);if(K)return K}return null},[it,Ye,ze,i.isArchivedBucket]),st=l.useCallback(Se=>{const We=new WeakMap,K=xe=>{We.set(xe,Gr(xe));for(const Xe of xe.children)K(Xe)};return Se.forEach(K),We},[]),Rt=l.useMemo(()=>st(Ye),[st,Ye]),Ke=l.useMemo(()=>{const Se=new WeakMap;return ze.forEach(({nodes:We})=>{We.forEach(K=>Se.set(K,Gr(K)))}),Se},[ze]),jt=l.useCallback(Se=>Rt.get(Se)??Ke.get(Se)??"",[Rt,Ke]),Lt=l.useCallback(Se=>({subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(Se)}),[dt,ft,jt]),Mt=Be.length,De=i.isArchivedBucket||p?Be:Be.slice(0,Ge),Tt=Mt-De.length,At=!i.isArchivedBucket&&!p&&Mt>Je&&Tt===0,kt=l.useCallback(Se=>{const We=[],K=xe=>{xe.forEach(Xe=>{We.push(Xe.session),Xe.children.length>0&&K(Xe.children)})};return K(Se),We},[]),pt=l.useMemo(()=>kt(Ye),[kt,Ye]),Dt=l.useMemo(()=>{if(be||i.isMain||i.isArchivedBucket||c)return ju;const Se=new Map;for(const We of pt)for(const K of Hl(We))Se.has(K.key)||Se.set(K.key,K);return Se.size>0?[...Se.values()]:ju},[pt,i.isArchivedBucket,i.isMain,be,c]),Ve=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="github"?[zr("issue",Se)]:[]),[Dt]),rt=zo(Ve),wt=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="linear"?[Ul(Se.identifier)]:[]),[Dt]),se=jp(wt),Fe=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="gitlab"?[Kr("issue",Se.ref)]:[]),[Dt]),ot=zo(Fe),$e=l.useMemo(()=>Cp(Dt,rt,se,ot).map(Se=>({...Se,text:Se.statusKey?`${Se.label} · ${e(Se.statusKey)}`:Se.statusText?`${Se.label} · ${Se.statusText}`:Se.label})),[ot,rt,Dt,se,e]),Ct=$e[0]??null,Yt=l.useMemo(()=>{if(!i.isArchivedBucket)return new Map;const Se=new Map,We=new Map;for(const{folder:xe}of ze){if(!xe.parentId)continue;const Xe=We.get(xe.parentId)??[];Xe.push(xe.id),We.set(xe.parentId,Xe)}const K=(xe,Xe)=>{if(Xe.has(xe))return[];Xe.add(xe);const lt=ze.find(({folder:Gt})=>Gt.id===xe),Bt=lt?kt(lt.nodes):[],Pt=We.get(xe)??[];for(const Gt of Pt)Bt.push(...K(Gt,Xe));return Bt};for(const{folder:xe}of ze)Se.set(xe.id,K(xe.id,new Set));return Se},[ze,kt,i.isArchivedBucket]);if(p&&!ge&&Le.length===0&&Be.length===0)return null;const es=!i.isMain&&!!i.branch,Zt=i.branch&&oS(i.branch,i.label)?{label:i.branch}:null,ss=Ee?n.jsx(vf,{nodes:Ye,includeUnreadSubtasks:P}):null,bs=(Se,We)=>{const{folder:K,scopeKey:xe,scopeDirectory:Xe,nodes:lt}=Se,Bt=Yt.get(K.id)??[],Pt=D?.folderId===K.id&&D?.scopeKey===xe,Gt=p?!1:bt.has(K.id),Ft=Wt=>n.jsx(nm,{folderId:K.id,scopeKey:xe,ownerKey:oe,children:(qt,vs)=>n.jsx(sm,{folder:K,displayName:We,sessions:lt,isCollapsed:Gt,collapsedActivityState:Wt,onToggle:()=>ee(K.id),onRename:ds=>{Q(xe,K.id,ds)},onDelete:()=>{if(i.isArchivedBucket){Tn.requestDelete({sessions:Bt,mode:"session"});return}if(!V){he(xe,K.id);return}const ds=ze.filter(({folder:Fs})=>Fs.parentId===K.id).length,bn=lt.length;ce({scopeKey:xe,folderId:K.id,folderName:K.name,subFolderCount:ds,sessionCount:bn})},groupDirectory:Xe??i.directory,projectId:d,mobileVariant:w,alwaysShowActions:T,isRenaming:Pt,renameDraft:Pt?D?.draft:void 0,onRenameDraftChange:C,onRenameSave:()=>{const ds=D?.draft.trim()??"";ds&&Q(xe,K.id,ds),N()},onRenameCancel:N,droppableRef:qt,isDropTarget:vs,depth:0,onNewSession:()=>{d&&d!==k&&I(d),w&&F(!1),O({selectedProjectId:d,directoryOverride:Xe??i.directory,targetFolderId:K.id,target:i.draftTarget})},hideActions:!1,archivedBucket:i.isArchivedBucket===!0,children:lt.map(ds=>n.jsx(ei,{node:ds,pinnedSessionIds:B,expandedParents:R,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:P,editingId:G,editingRowKey:_,editTitle:E,openSidebarMenuKey:$,mobileVariant:w,alwaysShowActions:T,groupDirectory:Xe??i.directory,projectId:d,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:i.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(ds),childRenderExtrasFor:Lt},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},ds.session.id))})},K.id);return Gt?n.jsx(II,{nodes:qe.get(K.id)??lt,includeUnreadSubtasks:P,children:Ft},K.id):Ft(null)},ls=()=>{const Se=new Map;for(const Xe of ze){const lt=Xe.folder.parentId;if(!lt)continue;const Bt=Se.get(lt);Bt?Bt.push(Xe):Se.set(lt,[Xe])}const We=[],K=new Set,xe=(Xe,lt)=>{if(K.has(Xe.folder.id))return;K.add(Xe.folder.id);const Bt=lt?`${lt} / ${Xe.folder.name}`:Xe.folder.name;We.push(bs(Xe,Bt)),!(!p&&bt.has(Xe.folder.id))&&(Se.get(Xe.folder.id)??[]).forEach(Gt=>xe(Gt,Bt))};return Le.forEach(Xe=>xe(Xe,"")),We},ms=!!(!i.isMain&&i.worktree&&!we),fs=i.worktree?.worktreeStatus==="missing"?n.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:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,Es=i.space&&i.space.state!=="complete"&&!o?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.spaceStale"),"aria-label":e("sessions.sidebar.group.spaceStale"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,cs=ms||!!i.space,Qe=!!i.space,vt=T?Qe?"pe-20":cs?"pe-14":"pe-7":Pe("pe-2",Qe?"[--oc-actions-reserve:68px]":cs?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),$t=T?void 0:"group-hover/gh:oc-actions-mask group-has-[:focus-visible]/gh:oc-actions-mask",ve=T?void 0:"transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",ct=f?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(eo,{expanded:!Ee}),ht=Se=>n.jsx("span",{className:"relative me-1 inline-flex size-3.5 flex-shrink-0 items-center justify-center",children:f||T?Se:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex items-center justify-center transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",children:Se}),n.jsx("span",{className:"absolute inset-0 inline-flex items-center justify-center text-muted-foreground opacity-0 transition-opacity group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100",children:ct})]})}),Ot=be&&Ie?[{key:`pr:${be.number}`,icon:"git-pull-request",text:`${Te} · ${Ie}`,title:be.title,color:ke,url:be.url}]:[],te=pe?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ae==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":U?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),Re?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:W,onClick:()=>{Ne()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:de,children:e("sessions.sidebar.group.empty.retry")})]}):null,et=Se=>n.jsx(ei,{node:Se,pinnedSessionIds:B,expandedParents:R,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:P,editingId:G,editingRowKey:_,editTitle:E,openSidebarMenuKey:$,mobileVariant:w,alwaysShowActions:T,groupDirectory:i.directory,projectId:d,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:i.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(Se),childRenderExtrasFor:Lt},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},Se.session.id),xt=n.jsxs(o5,{scopeKey:tt[0]?.scopeKey??nt,ownerKey:oe,hasFolders:ze.length>0,onSessionDroppedOnFolder:(Se,We)=>{const K=ze.find(({folder:Xe,scopeKey:lt})=>Xe.id===We.folderId&&lt===We.scopeKey);if(!K)return;const xe=is.getState();for(const{scopeKey:Xe}of tt)Xe!==K.scopeKey&&xe.getSessionFolderId(Xe,Se)&&xe.removeSessionFromFolder(Xe,Se);M(K.scopeKey,We.folderId,Se)},children:[ls(),De.map(et),Mt===0&&ze.length===0&&!r?!i.isArchivedBucket&&!re&&!te&&i.directory&&!i.emptyMessage?n.jsx(Nt,{variant:"link",size:"xs",className:"w-full justify-start ps-[26px] text-start font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{d&&d!==k&&I(d),w&&F(!1),O({selectedProjectId:d,directoryOverride:i.directory,target:i.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-muted-foreground",children:i.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):re?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Fo,{className:"size-3"}),e("sessions.sidebar.group.empty.loadingSessions")]}):te||(i.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Mt>0&&te?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:te}):null,Tt>0?n.jsx("button",{type:"button",onClick:()=>m(a,De.length,x??7),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,At?n.jsx("button",{type:"button",onClick:()=>v(a),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),It="pb-2",St=n.jsx(pm,{value:ie,setValue:ce,onConfirm:()=>{const Se=ie;Se&&(he(Se.scopeKey,Se.folderId),ce(null))}});return c?u?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:Pe("oc-group-body",It),children:xt})}),St]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:Pe("oc-group",we&&"opacity-60"),"aria-busy":we||void 0,children:[n.jsxs("div",{className:Pe("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[n.jsxs(Ut,{disabled:be?!Ie:!Ct,children:[n.jsx(Ht,{asChild:!0,closeDelay:am,children:n.jsx("div",{className:"min-w-0 flex-1",...f?{}:{onClick:()=>L(a),role:"button",tabIndex:0,onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),L(a))},"aria-label":Ee?e("sessions.sidebar.group.expandAria",{label:i.label}):e("sessions.sidebar.group.collapseAria",{label:i.label}),"aria-expanded":!Ee},children:n.jsxs("div",{ref:z?.setActivatorNodeRef,style:{paddingInlineStart:Kn(0)},className:Pe("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",vt),...z?.listeners??{},children:[n.jsxs("div",{className:Pe("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",$t),children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:i.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-0.5",children:[ht(n.jsx(Z,{name:"archive",className:"h-3 w-3 shrink-0 text-muted-foreground"})),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:vo(i.label,h)}),fs,ss]}):!i.isMain||i.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[ht(we?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",title:e("sessions.sidebar.group.worktreeRemoving"),role:"status","aria-label":e("sessions.sidebar.group.worktreeRemoving"),children:n.jsx(Fo,{className:"h-3.5 w-3.5"})}):n.jsx(Z,{name:i.space?"box-3":"git-branch",className:Pe("h-3 w-3 shrink-0",ke?"oc-ref-tint":"text-muted-foreground"),style:ke?or(ke):void 0,"aria-label":i.space?e("sessions.sidebar.group.space"):void 0})),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-medium text-foreground/85",children:vo(i.label,h)}),fs,Es,ss,be?n.jsx("button",{type:"button",className:Pe("ms-auto flex-shrink-0 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",ke&&"oc-ref-tint",ve),style:ke?or(ke):void 0,disabled:!be.url,"aria-label":Y,onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),be.url&&s(be.url,q,Se)},children:Te}):Ct?n.jsxs("button",{type:"button",className:Pe("ms-auto inline-flex flex-shrink-0 items-center gap-1 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ct.color?"oc-ref-tint":"text-muted-foreground",ve),style:Ct.color?or(Ct.color):void 0,"aria-label":$e.map(Se=>Se.text).join(", "),onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),!(Se.target instanceof Element&&Se.target.closest("[data-ref-more]"))&&s(Ct.url,q,Se)},children:[n.jsx(Z,{name:Ct.icon,className:"h-3 w-3"}),Ct.label,$e.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",$e.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[ct,n.jsx("span",{className:"min-w-0 truncate",children:vo(i.label,h)}),ss]})}),es&&Zt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[i.isArchivedBucket?n.jsx(Z,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Zt.label})]}):null]}),!i.isArchivedBucket&&i.directory?n.jsx(Qo,{directory:i.directory,className:Pe("self-center",ve)}):null]})})}),Ot.length>0?n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Xo,{items:Ot,directory:q})}):!be&&Ct?n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Xo,{items:$e,directory:q})}):null]}),n.jsxs(bi,{delayDuration:400,children:[i.isArchivedBucket&&pt.length>0?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),Tn.requestDelete({sessions:pt,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:i.label}),children:n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,i.directory&&!i.isMain&&i.worktree&&!we?n.jsx("div",{className:Pe("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsx(RI,{label:i.label,sessions:pt,worktree:i.worktree})}):null,i.space?n.jsx("div",{className:Pe("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),i.space&&Gs.getState().openAccessDialog(i.space.id)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("spaces.group.access.giveAria",{label:i.label}),children:n.jsx(Z,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,i.space?n.jsx("div",{className:Pe("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(cy,{spaceId:i.space.id,label:i.label})}):null,i.directory?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),d&&d!==k&&I(d),w&&F(!1),O({selectedProjectId:d,directoryOverride:i.directory,preserveDirectoryOverride:!!i.space})},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:i.label}),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),i.space?n.jsx(dy,{spaceId:i.space.id,className:"pb-1 ps-2"}):null,!Ee&&u?n.jsx("div",{className:Pe("oc-group-body",It),children:xt}):null]}),St]})}const MI=l.memo(NI,DI),ja=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},AI=(t,e)=>{const s=new Set;for(const r of t)if(!r.isArchivedBucket)for(const o of r.sessions){const{session:i}=o;i.time?.archived||e(i)||s.add(i.id)}return[...s]},OI=(t,e,s)=>t.flatMap(r=>{const o=e(r);return o.some(s)?[]:[{id:r,descendantIds:o}]}),BI=(t,e)=>{const s=new Set(e),r=t.filter(({id:o,descendantIds:i})=>s.has(o)||i.some(a=>s.has(a))).length;return{archived:t.length-r,failed:r}},ku=10,Cu=(t,e)=>Sp(t.label?.trim()||di(t.normalizedPath,e)||t.normalizedPath);function FI(t){const e=Ze.c(104),{model:s,view:r,actions:o}=t;As("ui.sidebar_projects_list.render");const{t:i}=Et(),a=Jr(),{files:d}=Ks(),c=is(ZI),u=is(YI),f=is(qI),p=is(GI),h=le(VI),g=le(UI)&&!Dn(),b=iS(),[x,y]=l.useState(null),[S,m]=l.useState(null),[v,w]=l.useState(null),[T,k]=l.useState(null),[I,F]=l.useState(null),O=I?.kind==="project",B=l.useRef(null);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[0]=j):j=e[0];let P;e[1]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[1]=P):P=e[1];let L;e[2]===Symbol.for("react.memo_cache_sentinel")?(L={coordinateGetter:Aw},e[2]=L):L=e[2];const z=yi(mn(Si,j),mn(xi,P),mn(Rw,L));let H;e[3]===Symbol.for("react.memo_cache_sentinel")?(H=W=>{B.current=W,k(W)},e[3]=H):H=e[3];const R=H;let G;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let W;e[7]!==r.homeDirectory?(W=ye=>({id:ye.project.id,projectLabel:Cu(ye.project,r.homeDirectory),projectDescription:fr(ye.project.normalizedPath,r.homeDirectory),projectIcon:ye.project.icon,projectColor:ye.project.color,projectIconImage:ye.project.iconImage,projectIconBackground:ye.project.iconBackground}),e[7]=r.homeDirectory,e[8]=W):W=e[8],G=s.projectSections.map(W),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=G}else G=e[6];const _=G,$=aS(),{confirm:E}=$;let D;e[9]!==E||e[10]!==i?(D=async(W,ye)=>{const de=lS.getState().ids,Ne=OI(AI(ye,Ae=>gi(de,Ae.directory,Ae.id)||Ra(Ae.id)||Vl(Ae)),HI,Ra);if(Ne.length===0){He.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await E({title:i("sessions.sidebar.project.archiveAll.title",{project:W}),message:Ne.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ne.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ne.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{failedIds:Ge}=await mt.getState().archiveSessions(Ne.flatMap(WI)),ge=BI(Ne,Ge);ge.archived>0&&He.success(ge.archived===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:ge.archived}):i("sessions.sidebar.bulkActions.archivedPlural",{count:ge.archived})),ge.failed>0&&He.error(ge.failed===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ge.failed}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:ge.failed}))},e[9]=E,e[10]=i,e[11]=D):D=e[11];const C=D;let N;e[12]!==d||e[13]!==i?(N=W=>{d.revealPath&&d.revealPath(W).catch(()=>{He.error(i("sidebarFilesTree.toast.revealFailed"))})},e[12]=d,e[13]=i,e[14]=N):N=e[14];const A=N;let q;e[15]!==S?(q=W=>`${W.kind}:${W.id}`===S,e[15]=S,e[16]=q):q=e[16];const ee=s.rowModel.stickyHeaders.findIndex(q);let Q;if(e[17]!==v||e[18]!==s.groupProps.editingRowKey||e[19]!==s.rowModel.rowIndexByKey||e[20]!==s.rowModel.rows||e[21]!==s.rowModel.stickyHeaders||e[22]!==s.state.openSidebarMenuKey||e[23]!==ee){if(Q=new Set,v){let W;e[25]!==v||e[26]!==s.rowModel.rowIndexByKey?(W=s.rowModel.rowIndexByKey.get(v),e[25]=v,e[26]=s.rowModel.rowIndexByKey,e[27]=W):W=e[27];const ye=W;ye!==void 0&&Q.add(ye)}for(let W=0;W<s.rowModel.rows.length;W=W+1,W){const ye=s.rowModel.rows[W];ye?.kind==="session"&&(s.groupProps.editingRowKey===ye.key||s.state.openSidebarMenuKey===`session-menu:${ye.key}`||s.state.openSidebarMenuKey===`session-context:${ye.key}`)&&Q.add(W)}if(ee>=0){const W=Math.max(0,ee-1),ye=Math.min(s.rowModel.stickyHeaders.length-1,ee+1);for(let de=W;de<=ye;de=de+1,de){const Ne=s.rowModel.stickyHeaders[de];Ne&&Q.add(Ne.rowIndex)}}e[17]=v,e[18]=s.groupProps.editingRowKey,e[19]=s.rowModel.rowIndexByKey,e[20]=s.rowModel.rows,e[21]=s.rowModel.stickyHeaders,e[22]=s.state.openSidebarMenuKey,e[23]=ee,e[24]=Q}else Q=e[24];const he=Q;let M;e[28]!==s.rowModel.stickyHeaders?(M=W=>{const ye=y3(s.rowModel.stickyHeaders,W),de=ye?`${ye.kind}:${ye.id}`:null;m(Ne=>Ne===de?Ne:de)},e[28]=s.rowModel.stickyHeaders,e[29]=M):M=e[29];const V=M;let ie;e[30]!==a||e[31]!==i?(ie=W=>{const ye=()=>{if(!W.status.directory){Tp();return}a.requestBootstrap({directory:W.status.directory,priority:"expanded",reason:W.group.isMain?"project-expanded":"worktree-expanded",force:!0})},de=async()=>{if(!W.status.directory)return;(await nf(W.status.directory)).success&&ye()};let Ne;e:switch(W.status.state){case"permission-denied":{Ne=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ne=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ne=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ne=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:W.flat?ku:Zd(W.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[W.status.state==="loading"?n.jsx(Fo,{className:"size-3"}):null,Ne,W.status.canGrantAccess?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{de()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,W.status.state!=="loading"?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ye,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=a,e[31]=i,e[32]=ie):ie=e[32];const ce=ie;let ne;e[33]!==o||e[34]!==f||e[35]!==d||e[36]!==s.emptyState||e[37]!==s.groupProps||e[38]!==s.projectRepoStatus||e[39]!==s.searchEmptyState||e[40]!==s.singleProjectMode||e[41]!==s.state||e[42]!==A||e[43]!==b||e[44]!==_||e[45]!==u||e[46]!==ce||e[47]!==C||e[48]!==h||e[49]!==g||e[50]!==i||e[51]!==c||e[52]!==r?(ne=W=>{if(W.kind==="activity-header")return n.jsx(mm,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(hI,{activityKey:W.activityKey,collapsed:W.collapsed,forceExpanded:W.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!W.collapsed){const de=`activity:${W.activityKey}`;o.group.resetGroupSessionLimit(de),s.state.setVisibleActivityCountByKey(Ne=>{if(!Ne.has(de))return Ne;const Je=new Map(Ne);return Je.delete(de),Je})}s.state.setCollapsedActivityKeys(de=>{const Ne=new Set(de);return Ne.has(W.activityKey)?Ne.delete(W.activityKey):Ne.add(W.activityKey),Ne})},onNewChat:()=>{le.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Zg,directoryOverride:null})}})});if(W.kind==="project-header"){const de=W.section.project,Ne=Cu(de,r.homeDirectory);return n.jsx(SI,{id:de.id,disabled:s.singleProjectMode||W.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Ne,projectDescription:fr(de.normalizedPath,r.homeDirectory),projectDirectory:de.normalizedPath,projectIcon:de.icon,projectColor:de.color,projectIconImage:de.iconImage,projectIconBackground:de.iconBackground,isCollapsed:W.collapsed,isRepo:!!s.projectRepoStatus.get(de.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:W.collapsed?o.renderProjectStatusIndicator?.(de.id,W.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?_:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!W.forceExpanded&&!s.singleProjectMode&&o.toggleProject(de.id)},onNewSession:()=>{ja({projectId:de.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:de.id,directoryOverride:de.normalizedPath})},onNewWorktreeSession:()=>{ja({projectId:de.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(de.id),onManageSpaces:g?()=>le.getState().setSpacesPageProjectId(de.id):void 0,onOpenSourceBoard:b?()=>b(de.id):void 0,onOpenFolder:de.normalizedPath&&d.revealPath?()=>A(de.normalizedPath):void 0,onRenameStart:()=>o.openProjectEditDialog(de.id),onArchiveAll:()=>{C(Ne,W.section.groups)},onClose:()=>o.removeProject(de.id),showCreateButtons:!0})}if(W.kind==="group-header")return n.jsx(vI,{id:W.groupKey,disabled:W.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:de=>n.jsx(MI,{...s.groupProps,...o.group,group:W.group,groupKey:W.groupKey,projectId:W.projectId,isEmpty:W.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get(W.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:de,renderBody:!1})});if(W.kind==="folder-header"){const de=s.groupProps.folderRename?.folderId===W.folder.id&&s.groupProps.folderRename.scopeKey===W.scopeKey;return n.jsx(nm,{folderId:W.folder.id,scopeKey:W.scopeKey,ownerKey:W.ownerKey,disabled:!W.dropEnabled,children:(Ne,Je)=>n.jsx(n5,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:W.activityNodes,folder:W.folder,displayName:W.displayName,sessions:W.nodes,depth:W.depth,canExpand:!W.empty,isCollapsed:W.collapsed,onToggle:W.forceExpanded?KI:()=>c(W.folder.id),onRename:Ge=>u(W.scopeKey,W.folder.id,Ge),onDelete:()=>{W.archived?Tn.requestDelete({sessions:[...W.deleteSessions],mode:"session"}):h?y({scopeKey:W.scopeKey,folderId:W.folder.id,folderName:W.folder.name,subFolderCount:W.subFolderCount,sessionCount:W.nodes.length}):f(W.scopeKey,W.folder.id)},renderBody:!1,groupDirectory:W.scopeDirectory??W.group.directory,projectId:W.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:de,renameDraft:de?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const Ge=s.groupProps.folderRename?.draft.trim();Ge&&u(W.scopeKey,W.folder.id,Ge),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Ne,isDropTarget:Je,onNewSession:()=>{ja({projectId:W.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:W.projectId,directoryOverride:W.scopeDirectory??W.group.directory,targetFolderId:W.folder.id,target:W.group.draftTarget})},archivedBucket:W.archived})})}if(W.kind==="session"){const de=new Set;return gr(W.node,s.state.editingId)&&de.add(W.node.session.id),n.jsx("div",{onFocusCapture:()=>w(W.key),onBlurCapture:()=>w(Ne=>Ne===W.key?null:Ne),children:n.jsx(ei,{...s.groupProps,node:W.node,depth:W.depth,groupDirectory:W.groupDirectory,projectId:W.projectId,folderOwnerKey:W.ownerKey,selectionScopeKey:W.selectionScopeKey,archivedBucket:W.archived,renderContext:W.renderContext,rowKey:W.key,dragKey:W.key,secondaryMeta:W.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:de,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${W.key}`||s.state.openSidebarMenuKey===`session-context:${W.key}`?W.node.session.id:null,nodeStructureKey:W.blockingBadgeSessionScopes?`${Gr(W.node)}:${JSON.stringify(W.blockingBadgeSessionScopes)}`:Gr(W.node),blockingBadgeSessionScopes:W.blockingBadgeSessionScopes}})})}if(W.kind==="run")return n.jsx(sI,{run:W.run,depth:W.depth,laneNodes:W.laneNodes,blockingSessionIds:W.blockingSessionIds,renderContext:W.renderContext,projectId:W.projectId,projectLabel:W.projectLabel,expansionKey:W.expansionKey,expanded:W.expanded,forceExpanded:W.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const ye=W.kind==="show-control"&&W.flat===!0?ku:Zd(W.kind==="show-control"||W.kind==="empty"?W.depth??0:0);return W.kind==="show-control"?n.jsx("div",{children:n.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",style:{paddingInlineStart:ye},onClick:()=>{W.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(de=>{const Ne=new Map(de);return W.control==="more"?Ne.set(W.containerKey,W.currentCount+W.increment):Ne.delete(W.containerKey),Ne}):W.control==="more"?o.group.showMoreGroupSessions(W.containerKey,W.currentCount,W.increment):o.group.resetGroupSessionLimit(W.containerKey)},children:i(W.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):W.kind==="status"?ce(W):W.emptyKind==="sidebar"?s.emptyState:W.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:ye},children:i("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=o,e[34]=f,e[35]=d,e[36]=s.emptyState,e[37]=s.groupProps,e[38]=s.projectRepoStatus,e[39]=s.searchEmptyState,e[40]=s.singleProjectMode,e[41]=s.state,e[42]=A,e[43]=b,e[44]=_,e[45]=u,e[46]=ce,e[47]=C,e[48]=h,e[49]=g,e[50]=i,e[51]=c,e[52]=r,e[53]=ne):ne=e[53];const je=ne;let Ee;if(e[54]!==I||e[55]!==s.rowModel.rows){let W;e[57]!==I?(W=ye=>ye.kind==="project-header"?I?.kind==="group"?[]:[ye.section.project.id]:ye.kind!=="group-header"?[]:I?.kind==="project"?[]:I?.kind==="group"&&ye.projectId!==I.projectId?[]:[ye.groupKey],e[57]=I,e[58]=W):W=e[58],Ee=s.rowModel.rows.flatMap(W),e[54]=I,e[55]=s.rowModel.rows,e[56]=Ee}else Ee=e[56];const we=Ee;let Me;e[59]!==s.sectionsForRender?(Me=new Set(s.sectionsForRender.map(zI)),e[59]=s.sectionsForRender,e[60]=Me):Me=e[60];const fe=Me;let be;e[61]!==s.rowModel.stickyHeaders?(be=s.rowModel.stickyHeaders.map($I).join(""),e[61]=s.rowModel.stickyHeaders,e[62]=be):be=e[62];const ke=be;let Ie;e[63]!==s.rowModel.rows||e[64]!==fe?(Ie=W=>{const ye=String(W.active.id);if(fe.has(ye)){F({kind:"project"});return}const de=s.rowModel.rows.find(Ne=>Ne.kind==="group-header"&&Ne.groupKey===ye);F(de?{kind:"group",projectId:de.projectId}:null)},e[63]=s.rowModel.rows,e[64]=fe,e[65]=Ie):Ie=e[65];let Te;e[66]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>F(null),e[66]=Te):Te=e[66];let Y;e[67]!==o||e[68]!==p||e[69]!==s.rowModel.folderAuthorityByOwner||e[70]!==s.rowModel.folderDropTargets||e[71]!==s.rowModel.rows||e[72]!==s.sectionsForRender||e[73]!==s.state||e[74]!==r?(Y=W=>{if(F(null),!W.over)return;const ye=W.active.data.current,de=W.over.data.current;if(ye?.type==="session"&&ye.sessionId&&ye.ownerKey&&ye.archivedBucket!==!0&&de?.type==="folder"&&de.folderId&&de.scopeKey&&de.ownerKey===ye.ownerKey){const bt=s.rowModel.folderDropTargets.find(ze=>ze.folderId===de.folderId&&ze.scopeKey===de.scopeKey&&ze.ownerKey===ye.ownerKey),Ce=s.rowModel.folderAuthorityByOwner.get(ye.ownerKey);if(!bt?.enabled||Ce?.complete!==!0)return;const _e=is.getState();for(const ze of Ce.scopeKeys)ze!==de.scopeKey&&_e.removeSessionFromFolder(ze,ye.sessionId);p(de.scopeKey,de.folderId,ye.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||W.active.id===W.over.id)return;const Ne=String(W.active.id),Je=String(W.over.id),Ge=s.sectionsForRender.map(LI),ge=Ge.indexOf(Ne),Ae=Ge.indexOf(Je);if(ge>=0&&Ae>=0&&r.projectSortOrder==="manual"){o.reorderProjects(ge,Ae);return}const Ye=s.rowModel.rows.find(bt=>bt.kind==="group-header"&&bt.groupKey===Ne),nt=s.rowModel.rows.find(bt=>bt.kind==="group-header"&&bt.groupKey===Je);if(!Ye||!nt||Ye.projectId!==nt.projectId||!Ye.projectId)return;const oe=Ye.projectId,tt=s.sectionsForRender.find(bt=>bt.project.id===oe);if(!tt)return;const Ue=tt.groups.findIndex(bt=>bt.id===Ye.group.id),gt=tt.groups.findIndex(bt=>bt.id===nt.group.id);Ue<0||gt<0||o.setGroupOrderByProject(bt=>new Map(bt).set(oe,Lp(tt.groups,Ue,gt).map(_I)))},e[67]=o,e[68]=p,e[69]=s.rowModel.folderAuthorityByOwner,e[70]=s.rowModel.folderDropTargets,e[71]=s.rowModel.rows,e[72]=s.sectionsForRender,e[73]=s.state,e[74]=r,e[75]=Y):Y=e[75];let ue;e[76]!==V||e[77]!==s.rowModel||e[78]!==he||e[79]!==je||e[80]!==T?(ue=n.jsx(uI,{model:s.rowModel,scrollElement:T,pinnedRowIndexes:he,renderRow:je,onFirstVisibleIndexChange:V}),e[76]=V,e[77]=s.rowModel,e[78]=he,e[79]=je,e[80]=T,e[81]=ue):ue=e[81];let me;e[82]!==we||e[83]!==ue?(me=n.jsx(Gl,{items:we,strategy:$p,children:ue}),e[82]=we,e[83]=ue,e[84]=me):me=e[84];let re;e[85]!==z||e[86]!==Ie||e[87]!==Y||e[88]!==me?(re=n.jsx(Qr,{ref:R,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 ps-2.5 pe-2 [overflow-anchor:none]",children:n.jsx(wi,{sensors:z,collisionDetection:vi,onDragStart:Ie,onDragCancel:Te,onDragEnd:Y,children:me})}),e[85]=z,e[86]=Ie,e[87]=Y,e[88]=me,e[89]=re):re=e[89];let pe;e[90]!==O||e[91]!==re||e[92]!==ke?(pe=n.jsx(mI,{suspended:O,layoutKey:ke,scrollRef:B,children:re}),e[90]=O,e[91]=re,e[92]=ke,e[93]=pe):pe=e[93];let U;e[94]!==f||e[95]!==x?(U=()=>{x&&(f(x.scopeKey,x.folderId),y(null))},e[94]=f,e[95]=x,e[96]=U):U=e[96];let ae;e[97]!==x||e[98]!==U?(ae=n.jsx(pm,{value:x,setValue:y,onConfirm:U}),e[97]=x,e[98]=U,e[99]=ae):ae=e[99];let Re;return e[100]!==$.dialog||e[101]!==pe||e[102]!==ae?(Re=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[pe,ae,$.dialog]}),e[100]=$.dialog,e[101]=pe,e[102]=ae,e[103]=Re):Re=e[103],Re}function _I(t){return t.id}function LI(t){return t.project.id}function $I(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function zI(t){return t.project.id}function KI(){}function WI(t){const{id:e,descendantIds:s}=t;return[e,...s]}function HI(t){return wl(t,[],!1)}function UI(t){return t.isolatedSpacesEnabled}function VI(t){return t.showDeletionDialog}function GI(t){return t.addSessionToFolder}function qI(t){return t.deleteFolder}function YI(t){return t.renameFolder}function ZI(t){return t.toggleFolderCollapse}const QI=l.memo(FI),pl=new Map,Iu=(t,e)=>{for(const s of t){const r=yt(s??null);r&&!pl.has(r)&&pl.set(r,e)}},Pu=t=>{const e=yt(t??null);return e?pl.get(e)??0:0},Ir=t=>!!t.time?.archived,XI=(t,e)=>{if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const[s,r]of e)if(t.get(s)?.scopeDirectory!==r.scopeDirectory)return!1;return!0},JI=t=>{const{t:e}=Et(),s=l.useRef(t.gitBranches);s.current=t.gitBranches;const r=l.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const o=l.useRef(t.sessionOwners),i=l.useMemo(()=>(XI(o.current,t.sessionOwners)||(o.current=t.sessionOwners),o.current),[t.sessionOwners]),a=l.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),d=l.useCallback(f=>{const p=yt(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${p}`.toLowerCase()},[e]),c=l.useCallback((f,p)=>{if(!p)return f;const h=p.trim().toLowerCase(),g=h.startsWith("ses_");return f.flatMap(b=>{if(g&&Ir(b.session))return[];if(g?b.session.id.toLowerCase()===h:$o([d(b.session)],p))return[b];const y=c(b.children,p);return y.length===0?[]:[{...b,children:y}]})},[d]),u=l.useCallback((f,p,h,g,b)=>{const x=yt(p??null),y=yp(f),S=new Map(y.map(N=>[N.id,N])),m=new Map;y.forEach(N=>{const A=N.parentID;if(!A)return;const q=S.get(A);if(!q||Ir(q)||Ir(N))return;const ee=m.get(A)??[];ee.push(N),m.set(A,ee)});const v=cS(h,x),w=(x&&!t.isVSCode?t.spacesByProject?.get(x):void 0)??[],T=new Map;for(const N of w){const A=yt(N.directory);A&&T.set(A,N)}const k=N=>{const A=yt(N.directory??null),q=t.worktreeMetadata.get(N.id)??null;if(q)return q;if(A){const ee=ta(A,v);if(ee&&A!==x)return ee}return null},I=new Set,F=N=>{I.add(N.id);const A=m.get(N.id)??[],q=[];for(const ee of A)I.has(ee.id)||q.push(F(ee));return{session:N,children:q,worktree:k(N)}},O=N=>{const A=N.parentID;if(!A)return!1;if(Ir(N))return!0;const q=S.get(A);return!!(q&&Ir(q))},B=y.filter(N=>{const A=N.parentID;return A?!S.has(A)&&!O(N):!0}),j=[],P=N=>{I.has(N.id)||j.push(F(N))};B.forEach(P),y.forEach(N=>{O(N)||P(N)});const L=new Map,z="__archived__",H=N=>{if(N.time?.archived)return z;if(t.isVSCode||t.runKeyBySessionId?.has(N.id))return x??"__project_root__";const A=i?.get(N.id)?.scopeDirectory;if(A){if(A===x)return x??"__project_root__";if(T.has(A))return A;const he=ta(A,v);if(he)return yt(he.path)??he.path}const ee=yt(t.worktreeMetadata.get(N.id)?.path??null)??ur(N);if(!ee||ee===x)return x??"__project_root__";const Q=ta(ee,v);return Q?yt(Q.path)??Q.path:x??"__project_root__"};j.forEach(N=>{const A=H(N.session);L.has(A)||L.set(A,[]),L.get(A)?.push(N)});const R=x??"__project_root__",G=[{id:"root",label:b&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:x?fr(x,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:x,folderScopeKey:x,sessions:L.get(R)??[]}],_=new Map;h.forEach(N=>{const A=yt(N.path)??N.path,q=L.get(A)??[],ee=q.length>0,Q=q.reduce((he,M)=>{const V=dS(M.session,r.current);return Number.isFinite(V)?Math.max(he,V):he},0);_.set(A,{hasActiveSession:ee,lastUpdatedAt:Q})});const $=(N,A)=>{const q=(N.label||N.branch||N.name||N.path||"").toLowerCase(),ee=(A.label||A.branch||A.name||A.path||"").toLowerCase();return q.localeCompare(ee)},E=t.worktreeSortOrder!=="recent"?[...h].sort($):[...h].sort((N,A)=>{const q=yt(N.path)??N.path,ee=yt(A.path)??A.path,Q=_.get(q)??{hasActiveSession:!1,lastUpdatedAt:0},he=_.get(ee)??{hasActiveSession:!1,lastUpdatedAt:0};if(Q.hasActiveSession!==he.hasActiveSession)return Q.hasActiveSession?-1:1;if(Q.hasActiveSession&&he.hasActiveSession)return he.lastUpdatedAt-Q.lastUpdatedAt;const M=Pu(N.path),V=Pu(A.path);return M!==V?V-M:$(N,A)});(t.isVSCode?[]:E).forEach(N=>{const A=yt(N.path)??N.path,q=s.current.get(A)?.trim()||null,ee=N.branch?.trim()||null,Q=uS(N,q,di(A,t.homeDirectory)||A);G.push({id:`worktree:${A}`,label:Q,branch:q||ee,description:fr(A,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:N,directory:A,folderScopeKey:A,sessions:L.get(A)??[]})});for(const[N,A]of T)G.push({id:`space:${A.id}`,label:A.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:A,directory:N,folderScopeKey:N,sessions:L.get(N)??[]});const C=L.get(z)??[];return C.length>0&&G.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&x?bp(x):null,sessions:C}),G},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,i,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:a,buildSessionSearchText:d,filterSessionNodesForSearch:c,buildGroupedSessions:u}},eP=t=>{const e=Ze.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:a,onCreateFolderAndMove:d,onRemoveFromFolder:c,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:h,onDone:g}=t,{t:b}=Et(),x=s>0,y=x&&!!r&&!i;let S;e[0]!==s||e[1]!==b?(S=b("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=b,e[2]=S):S=e[2];let m;e[3]!==S?(m=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:S}),e[3]=S,e[4]=m):m=e[4];let v;e[5]!==y||e[6]!==u||e[7]!==d||e[8]!==a||e[9]!==c||e[10]!==o||e[11]!==b?(v=y?n.jsxs(Rs,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.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":b("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx(Z,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Ms,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(rs,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(C=>n.jsx(rs,{onClick:()=>a(C.id),children:n.jsx("span",{className:"flex-1 truncate",children:C.name})},C.id)),n.jsx(In,{}),n.jsxs(rs,{onClick:d,children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(rs,{onClick:c,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=y,e[6]=u,e[7]=d,e[8]=a,e[9]=c,e[10]=o,e[11]=b,e[12]=v):v=e[12];let w;e[13]!==i||e[14]!==x||e[15]!==f||e[16]!==b?(w=i?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.restore"),children:n.jsx(Z,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=x,e[15]=f,e[16]=b,e[17]=w):w=e[17];let T;e[18]!==i||e[19]!==x||e[20]!==p||e[21]!==b?(T=i?null:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,disabled:!x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.archive"),children:n.jsx(Z,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=x,e[20]=p,e[21]=b,e[22]=T):T=e[22];const k=!x;let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=Pe("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]=I):I=e[23];let F;e[24]!==b?(F=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=F):F=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Z,{name:"delete-bin",className:"h-4 w-4"}),e[26]=O):O=e[26];let B;e[27]!==h||e[28]!==k||e[29]!==F?(B=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,disabled:k,className:I,"aria-label":F,children:O})}),e[27]=h,e[28]=k,e[29]=F,e[30]=B):B=e[30];let j;e[31]!==b?(j=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=j):j=e[32];let P;e[33]!==j?(P=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:j})}),e[33]=j,e[34]=P):P=e[34];let L;e[35]!==B||e[36]!==P?(L=n.jsxs(Ut,{children:[B,P]}),e[35]=B,e[36]=P,e[37]=L):L=e[37];let z;e[38]!==b?(z=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=z):z=e[39];let H;e[40]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Z,{name:"close",className:"h-4 w-4"}),e[40]=H):H=e[40];let R;e[41]!==g||e[42]!==z?(R=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":z,children:H})}),e[41]=g,e[42]=z,e[43]=R):R=e[43];let G;e[44]!==b?(G=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=G):G=e[45];let _;e[46]!==G?(_=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:G})}),e[46]=G,e[47]=_):_=e[47];let $;e[48]!==R||e[49]!==_?($=n.jsxs(Ut,{children:[R,_]}),e[48]=R,e[49]=_,e[50]=$):$=e[50];let E;e[51]!==L||e[52]!==$||e[53]!==v||e[54]!==w||e[55]!==T?(E=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[v,w,T,L,$]}),e[51]=L,e[52]=$,e[53]=v,e[54]=w,e[55]=T,e[56]=E):E=e[56];let D;return e[57]!==m||e[58]!==E?(D=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[m,E]}),e[57]=m,e[58]=E,e[59]=D):D=e[59],D},Eu=new Map,tP=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},sP=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||im(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},nP=t=>{const e=Ze.c(89),{t:s}=Et();let r;e[0]!==s?(r=re=>{const pe=fS(re);return pe?{description:wf(pe,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:c,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:h,unarchiveSessions:g,deleteSessions:b,bulkDeleteConfirm:x,setBulkDeleteConfirm:y}=t,S=xs(rP),m=xs(oP),v=m>0,w=xs(iP),T=xs(aP),k=om(),I=lP,F=cP;let O;e[2]!==v||e[3]!==k||e[4]!==w?(O=v&&im(w,k?.getSessionsById()??Eu),e[2]=v,e[3]=k,e[4]=w,e[5]=O):O=e[5];const B=O;let j;e:{if(T){j=T;break e}j=null}const P=j;let L;e[6]!==P||e[7]!==c?(L=tP(P,c),e[6]=P,e[7]=c,e[8]=L):L=e[8];const z=L;let H;if(e[9]!==d||e[10]!==z){let re;e[12]!==d?(re=pe=>d[pe]??[],e[12]=d,e[13]=re):re=e[13],H=z.flatMap(re),e[9]=d,e[10]=z,e[11]=H}else H=e[11];const R=H;let G;e[14]!==d||e[15]!==z?(G=re=>{for(const pe of z)if((d[pe]??[]).some(U=>U.id===re))return pe;return null},e[14]=d,e[15]=z,e[16]=G):G=e[16];const _=G;let $;e:{if(!v){$=!1;break e}for(const re of z)for(const pe of d[re]??[])for(const U of pe.sessionIds)if(w.has(U)){$=!0;break e}$=!1}const E=$;let D;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==z?(D=(re,pe)=>{const U=Array.from(w);for(const ae of z)ae!==re&&f(ae,U);u(re,pe,U)},e[17]=u,e[18]=f,e[19]=w,e[20]=z,e[21]=D):D=e[21];const C=D;let N;e[22]!==v||e[23]!==C||e[24]!==_?(N=re=>{if(!v)return;const pe=_(re);pe&&C(pe,re)},e[22]=v,e[23]=C,e[24]=_,e[25]=N):N=e[25];const A=N;let q;e[26]!==p||e[27]!==v||e[28]!==C||e[29]!==z?(q=()=>{const re=z[0];if(!re||!v)return;const pe=p(re);pe&&C(re,pe.id)},e[26]=p,e[27]=v,e[28]=C,e[29]=z,e[30]=q):q=e[30];const ee=q;let Q;e[31]!==v||e[32]!==f||e[33]!==w||e[34]!==z?(Q=()=>{if(!v)return;const re=Array.from(w);for(const pe of z)f(pe,re)},e[31]=v,e[32]=f,e[33]=w,e[34]=z,e[35]=Q):Q=e[35];const he=Q;let M;e[36]!==h||e[37]!==b||e[38]!==o||e[39]!==s?(M=async(re,pe)=>{if(re.length!==0)if(pe){const{deletedIds:U,failedIds:ae}=await b(re);U.length>0&&He.success(U.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:U.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:U.length})),ae.length>0&&He.error(ae.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ae.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:ae.length}),o(ae)),xs.getState().removeMany(U)}else{const{archivedIds:U,failedIds:ae}=await h(re);U.length>0&&He.success(U.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:U.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:U.length})),ae.length>0&&He.error(ae.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ae.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:ae.length}),o(ae)),xs.getState().removeMany(U)}},e[36]=h,e[37]=b,e[38]=o,e[39]=s,e[40]=M):M=e[40];const V=M;let ie;e[41]!==V||e[42]!==v||e[43]!==w||e[44]!==y||e[45]!==a?(ie=re=>{if(!v)return;const pe=Array.from(w);if(!a){V(pe,re);return}y({sessionIds:pe,sessionCount:pe.length,archivedBucket:re})},e[41]=V,e[42]=v,e[43]=w,e[44]=y,e[45]=a,e[46]=ie):ie=e[46];const ce=ie;let ne;e[47]!==B||e[48]!==ce?(ne=()=>ce(B),e[47]=B,e[48]=ce,e[49]=ne):ne=e[49];const je=ne;let Ee;e[50]!==ce?(Ee=()=>ce(!1),e[50]=ce,e[51]=Ee):Ee=e[51];const we=Ee;let Me;e[52]!==ce?(Me=()=>ce(!0),e[52]=ce,e[53]=Me):Me=e[53];const fe=Me;let be;e[54]!==B||e[55]!==o||e[56]!==v||e[57]!==w||e[58]!==s||e[59]!==g?(be=async()=>{if(!v||!B)return;const re=Array.from(w),{restoredIds:pe,failedIds:U}=await g(re);pe.length>0&&He.success(pe.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:pe.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:pe.length})),U.length>0&&He.error(U.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:U.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:U.length}),o(U)),xs.getState().removeMany(pe)},e[54]=B,e[55]=o,e[56]=v,e[57]=w,e[58]=s,e[59]=g,e[60]=be):be=e[60];const ke=be;let Ie;e[61]!==x||e[62]!==V||e[63]!==k||e[64]!==y?(Ie=async()=>{if(!x)return;const re=k?.getSessionsById()??Eu,pe=sP(x,re);if(!pe.ready){y(pe.value);return}y(null),await V(pe.value.sessionIds,pe.value.archivedBucket)},e[61]=x,e[62]=V,e[63]=k,e[64]=y,e[65]=Ie):Ie=e[65];const Te=Ie;let Y,ue;e[66]!==x||e[67]!==je||e[68]!==i||e[69]!==k||e[70]!==S?(Y=()=>{if(!S)return;const re=/Macintosh|Mac OS X/.test(navigator.userAgent||""),pe=U=>{if(x||i)return;const ae=U.target instanceof HTMLElement?U.target:null;if(ae&&(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable))return;const Re=re?U.metaKey:U.ctrlKey;if(U.key==="Escape"){U.preventDefault(),xs.getState().disable();return}if(Re&&U.key==="Backspace"){U.preventDefault(),je();return}if(Re&&(U.key==="a"||U.key==="A")){const W=a5(k?.getEntries()??[],k?.getDescendantIds()??[],xs.getState().scopeKey);if(!W)return;U.preventDefault(),xs.getState().replaceAll(W.ids,W.scopeKey)}};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},ue=[x,je,i,k,S],e[66]=x,e[67]=je,e[68]=i,e[69]=k,e[70]=S,e[71]=Y,e[72]=ue):(Y=e[71],ue=e[72]),l.useEffect(Y,ue);let me;return e[73]!==E||e[74]!==R||e[75]!==B||e[76]!==Te||e[77]!==P||e[78]!==we||e[79]!==ee||e[80]!==je||e[81]!==fe||e[82]!==A||e[83]!==he||e[84]!==ke||e[85]!==v||e[86]!==m||e[87]!==S?(me={selectionModeEnabled:S,hasSelection:v,selectedIdsSize:m,bulkScopeIsArchived:B,derivedSelectionScope:P,bulkScopeFolders:R,bulkCanRemoveFromFolder:E,handleToggleSelectionMode:I,handleExitSelectionMode:F,handleBulkMoveToFolder:A,handleBulkCreateFolderAndMove:ee,handleBulkRemoveFromFolder:he,handleBulkDelete:je,handleBulkArchive:we,handleBulkHardDelete:fe,handleBulkRestore:ke,confirmBulkDelete:Te},e[73]=E,e[74]=R,e[75]=B,e[76]=Te,e[77]=P,e[78]=we,e[79]=ee,e[80]=je,e[81]=fe,e[82]=A,e[83]=he,e[84]=ke,e[85]=v,e[86]=m,e[87]=S,e[88]=me):me=e[88],me};function rP(t){return t.enabled}function oP(t){return t.selectedIds.size}function iP(t){return t.selectedIds}function aP(t){return t.scopeKey}function lP(){xs.getState().toggleMode()}function cP(){xs.getState().disable()}function dP(t){const e=Ze.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,a]=l.useState(null),d=le(xP),c=le(yP),u=is(bP),f=is(gP),p=is(mP),h=is(hP),g=mt(pP),b=mt(fP),x=mt(uP);let y;e[0]!==f||e[1]!==o?(y=k=>{const I=f(k,"New folder");return o(k,I),I},e[0]=f,e[1]=o,e[2]=y):y=e[2];let S;e[3]!==p||e[4]!==g||e[5]!==i||e[6]!==x||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==h||e[11]!==d||e[12]!==y||e[13]!==b?(S={isInlineEditing:r,showDeletionDialog:d,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:p,removeSessionsFromFolders:h,createFolderAndStartRename:y,archiveSessions:g,unarchiveSessions:b,deleteSessions:x,bulkDeleteConfirm:i,setBulkDeleteConfirm:a},e[3]=p,e[4]=g,e[5]=i,e[6]=x,e[7]=u,e[8]=s,e[9]=r,e[10]=h,e[11]=d,e[12]=y,e[13]=b,e[14]=S):S=e[14];const m=nP(S);let v;e[15]!==m.bulkCanRemoveFromFolder||e[16]!==m.bulkScopeFolders||e[17]!==m.bulkScopeIsArchived||e[18]!==m.derivedSelectionScope||e[19]!==m.handleBulkArchive||e[20]!==m.handleBulkCreateFolderAndMove||e[21]!==m.handleBulkHardDelete||e[22]!==m.handleBulkMoveToFolder||e[23]!==m.handleBulkRemoveFromFolder||e[24]!==m.handleBulkRestore||e[25]!==m.handleExitSelectionMode||e[26]!==m.selectedIdsSize||e[27]!==m.selectionModeEnabled?(v=m.selectionModeEnabled?n.jsx(eP,{selectedCount:m.selectedIdsSize,scopeKey:m.derivedSelectionScope,scopeFolders:m.bulkScopeFolders,archivedBucket:m.bulkScopeIsArchived,onMoveToFolder:m.handleBulkMoveToFolder,onCreateFolderAndMove:m.handleBulkCreateFolderAndMove,onRemoveFromFolder:m.handleBulkRemoveFromFolder,canRemoveFromFolder:m.bulkCanRemoveFromFolder,onRestore:m.handleBulkRestore,onArchive:m.handleBulkArchive,onDelete:m.handleBulkHardDelete,onDone:m.handleExitSelectionMode}):null,e[15]=m.bulkCanRemoveFromFolder,e[16]=m.bulkScopeFolders,e[17]=m.bulkScopeIsArchived,e[18]=m.derivedSelectionScope,e[19]=m.handleBulkArchive,e[20]=m.handleBulkCreateFolderAndMove,e[21]=m.handleBulkHardDelete,e[22]=m.handleBulkMoveToFolder,e[23]=m.handleBulkRemoveFromFolder,e[24]=m.handleBulkRestore,e[25]=m.handleExitSelectionMode,e[26]=m.selectedIdsSize,e[27]=m.selectionModeEnabled,e[28]=v):v=e[28];let w;e[29]!==m.confirmBulkDelete||e[30]!==i||e[31]!==c||e[32]!==d?(w=n.jsx(H5,{value:i,setValue:a,showDeletionDialog:d,setShowDeletionDialog:c,onConfirm:m.confirmBulkDelete}),e[29]=m.confirmBulkDelete,e[30]=i,e[31]=c,e[32]=d,e[33]=w):w=e[33];let T;return e[34]!==v||e[35]!==w?(T=n.jsxs(n.Fragment,{children:[v,w]}),e[34]=v,e[35]=w,e[36]=T):T=e[36],T}function uP(t){return t.deleteSessions}function fP(t){return t.unarchiveSessions}function pP(t){return t.archiveSessions}function hP(t){return t.removeSessionsFromFolders}function mP(t){return t.addSessionsToFolder}function gP(t){return t.createFolder}function bP(t){return t.foldersMap}function yP(t){return t.setShowDeletionDialog}function xP(t){return t.showDeletionDialog}const gm="oc.sessions.expandedParents.v3",SP=Ci(zs()),wP=()=>{try{const t=globalThis.localStorage.getItem(gm);if(t===null)return new Set;const e=SP.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},vP=()=>{const[t,e]=l.useState(wP),s=l.useRef(t);s.current=t;const r=l.useCallback(o=>{const i=pS(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(gm,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},jP=t=>{const e=Ze.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,a=Os(kP),d=Os(CP);let c;e[0]!==o||e[1]!==r?(c=[...r.flatMap(IP),...o?[{key:"activity:chats",group:o}]:[]].map(TP),e[0]=o,e[1]=r,e[2]=c):c=e[2];const u=c;let f;e[3]!==u?(f=new Set(u.flatMap(DP)),e[3]=u,e[4]=f):f=e[4];let p;e[5]!==f?(p=[...f],e[5]=f,e[6]=p):p=e[6];const h=p;let g;e[7]!==s||e[8]!==h.length?(g=v=>h.length>0?s.subscribeBootstrap(v):RP,e[7]=s,e[8]=h.length,e[9]=g):g=e[9];let b;e[10]!==s||e[11]!==h?(b=()=>h.map(v=>`${v}\0${s.getBootstrapState(v)??""}\0${s.getBootstrapFailure(v)??""}\0${s.getInitializationState(v)??""}\0${s.getInitializationFailure(v)??""}`).join(""),e[10]=s,e[11]=h,e[12]=b):b=e[12];const x=l.useSyncExternalStore(g,b,NP);let y;if(e[13]!==i||e[14]!==s||e[15]!==a||e[16]!==u||e[17]!==d){y=new Map;for(const{key:v,archived:w,directories:T}of u){const k=T.find(I=>s.getBootstrapState(I)==="failed"||s.getInitializationState(I)==="failed");if(k){const I=s.getBootstrapState(k)==="failed",F=I?s.getBootstrapFailure(k):s.getInitializationFailure(k);y.set(v,{state:F==="os-permission"?"permission-denied":I?"load-failed":"initialization-failed",directory:k,canGrantAccess:F==="os-permission"&&i})}else{const I=d||!w&&T.length>0&&T.every(F=>s.getBootstrapState(F)==="complete");y.set(v,{state:I?"ready":a==="error"?"load-failed":"loading",directory:I?T[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=a,e[16]=u,e[17]=d,e[18]=y}else y=e[18];const S=y;let m;return e[19]!==x||e[20]!==S?(m={groupStatusByKey:S,bootstrapSnapshot:x},e[19]=x,e[20]=S,e[21]=m):m=e[21],m};function kP(t){return t.status}function CP(t){return t.hasLoaded}function IP(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function PP(t){return yt(t.directory)}function EP(t){return!!t}function TP(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:zn(s).map(PP).filter(EP)}}function DP(t){return t.directories}function RP(){}function NP(){return""}const MP=6e4,AP=[],Tu=[],Du={pinned:[],work:[]},OP=t=>!t.parentID,BP=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:a,...d}=s,c=is(ve=>ve.foldersMap),u=is(ve=>ve.collapsedFolderIds),f=is(ve=>ve.createFolder),p=is(ve=>ve.addSessionToFolder),h=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:b,toggleGroup:x,toggleProject:y,setCollapsedActivities:S}=i,m=hS({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),v=mS(ve=>ve.projects),w=Qg(),T=l.useMemo(()=>new Map(w.map(ve=>[ve.id,ve.name])),[w]),k=l.useMemo(()=>{const ve=new Map;for(const ct of w){const ht=yt(ct.projectDirectory);if(!ht)continue;const Ot=ve.get(ht);Ot?Ot.push(ct):ve.set(ht,[ct])}return ve},[w]),I=l.useMemo(()=>gS(m.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,m.archivedSessions,v,w),[v,m.archivedSessions,m.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[F,O]=l.useState(new Map),[B,j]=l.useState(new Map),P=l.useCallback((ve,ct,ht=7)=>{O(Ot=>new Map(Ot).set(ve,ct+ht))},[]),L=l.useCallback(ve=>{O(ct=>{if(!ct.has(ve))return ct;const ht=new Map(ct);return ht.delete(ve),ht})},[]);l.useEffect(()=>{O(ve=>{if(ve.size===0)return ve;const ct=te=>h.collapsedGroups.has(te)||[...h.collapsedProjects].some(et=>te===Xh(et)||te.startsWith(`${et}:`)),ht=[...ve.keys()].filter(ct);if(ht.length===0)return ve;const Ot=new Map(ve);for(const te of ht)Ot.delete(te);return Ot})},[h.collapsedGroups,h.collapsedProjects]);const z=ts(ve=>ve.showChatsSection),H=ts(ve=>ve.projectDisplayMode),R=ts(ve=>ve.singleProjectId),G=ts(ve=>ve.setSingleProjectId),$=!t.isVSCode&&!Xg()&&H==="single",E=e.sidebarViewMode==="timeline"&&!t.isVSCode,D=ts(ve=>ve.listSessionGrouping),C=E&&D==="time",N=l.useMemo(()=>bS(m.rootSessions,ve=>yt(t.worktreeMetadata.get(ve.id)?.projectDirectory??ve.directory??null)),[m.rootSessions,t.worktreeMetadata]),A=l.useRef(null),q=l.useMemo(()=>{const ve=Array.from(N.runKeyBySessionId,([ct,ht])=>`${ct}\0${ht}`).sort().join("");return A.current?.signature!==ve&&(A.current={signature:ve,map:N.runKeyBySessionId}),A.current.map},[N]),[ee,Q]=l.useState(null),[he,M]=l.useState(null),[V,ie]=l.useState(""),[ce,ne]=l.useState(null),[je,Ee]=l.useState(null),[we,Me]=l.useState(null),fe=l.useCallback((ve,ct)=>{Me({scopeKey:ve,folderId:ct.id,draft:ct.name})},[]),be=l.useCallback(ve=>{Me(ct=>ct?{...ct,draft:ve}:null)},[]),ke=l.useCallback(()=>Me(null),[]),{expandedParents:Ie,toggleParent:Te}=vP(),Y=mt(ve=>ve.setCurrentSession),ue=l.useCallback((ve,ct)=>{ve!==mt.getState().currentSessionId&&Y(ve,ct)},[Y]),me=Ip(),re=ts(ve=>ve.worktreeSortOrder),{buildGroupedSessions:pe,filterSessionNodesForSearch:U,buildGroupSearchText:ae}=JI({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:m.pinnedSessionIds,sessionOrderRanks:m.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:re,sessionOwners:I.bySessionId,spacesByProject:k,runKeyBySessionId:q}),{getSessionsForProject:Re,getArchivedSessionsForProject:W}=M4({ownership:I}),ye=yS(),de=l.useMemo(()=>{if(t.isVSCode)return null;const ve=ye??m.chatSessions.map(ht=>xl(ht.directory)).find(Boolean)??null;if(!ve)return null;const ct=Array.from(new Set([ve,...m.chatSessions.map(ht=>yt(ht.directory??null)).filter(Boolean)])).filter(ht=>!!ht).map(ht=>({scopeKey:ht,directory:ht}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:ve,folderScopeKey:ve,folderScopes:ct,draftTarget:"chat",sessions:m.chatSessions.filter(ht=>!ht.time?.archived&&OP(ht)).map(ht=>Gn(m.childrenMap,ht))}},[m.chatSessions,m.childrenMap,ye,t.isVSCode]),Ne=l.useMemo(()=>de?[de]:AP,[de]),{projectSections:Je,groupSearchDataByGroup:Ge,sectionsForRender:ge,flatSectionsForRender:Ae}=_4({normalizedProjects:t.projects,getSessionsForProject:Re,getArchivedSessionsForProject:W,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:m.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:pe,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:U,buildGroupSearchText:ae,foldersMap:c,standaloneGroups:Ne}),Ye=e.onSearchMatchCountChange;l.useEffect(()=>()=>Ye(0),[Ye]);const nt=Jr(),oe=e.useGroupedSections?ge:Ae,tt=l.useMemo(()=>e.showInlineArchived?oe:oe.map(ve=>ve.groups.some(ct=>ct.isArchivedBucket)?{...ve,groups:ve.groups.filter(ct=>!ct.isArchivedBucket)}:ve),[oe,e.showInlineArchived]),Ue=l.useCallback(ve=>Ae.find(ht=>ht.project.id===ve)?.groups.find(ht=>!ht.isArchivedBucket)?.folderScopes??[],[Ae]);I4({enabled:!0,normalizedProjects:t.projects,ownership:I,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:m.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:c,createFolder:f,addSessionToFolder:p});const{sourceControl:gt}=Ks(),bt=ys(ve=>ve.ensureEntry),Ce=ys(ve=>ve.setParams),_e=ys(ve=>ve.refreshTargets),ze=ys(ve=>ve.clearDirectoryStatus),Oe=ys(ve=>ve.beginActiveContextsLoad),it=ys(ve=>ve.commitActiveContexts),X=ys(ve=>ve.releaseActiveContexts),Be=ys(ve=>ve.activeContextRegistrations),Le=l.useId(),at=l.useRef(new Set),qe=l.useRef(new Map),ut=l.useMemo(()=>new Map(m.orderedSessions.map((ve,ct)=>[ve.id,ct])),[m.orderedSessions]),[dt,ft]=l.useState(null),st=l.useRef([]),Rt=e.projectSortOrder==="recent";l.useEffect(()=>{Rt||ft(null)},[Rt]);const Ke=l.useMemo(()=>{const ve=re!=="manual"?tt:tt.map(ht=>{const Ot=g(ht.project.id,ht.groups);return Ot===ht.groups?ht:{...ht,groups:Ot}}),ct=xS(ve,e.projectSortOrder,ht=>ht.project.id,I.sessionsByProject);return[...dt&&Rt?SS(ct,dt,ht=>ht.project.id):ct]},[g,dt,Rt,I.sessionsByProject,tt,e.projectSortOrder,re]);l.useEffect(()=>{st.current=Ke.map(ve=>ve.project.id)},[Ke]);const jt=l.useMemo(()=>{if(!E)return Tu;const ve=new Set(m.rootSessions.map(et=>et.id)),ct=m.orderedSessions.filter(et=>ve.has(et.id)&&!et.time?.archived),ht=new Map,Ot=Lc({sessions:ct,projects:t.projects,ownerBySessionId:I.bySessionId,spaceLabelById:T,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return Qd({sessions:ct,getSessionLocation:et=>Ot.get(et)??null,getSessionNode:et=>{const xt=Gn(m.childrenMap,et),It=Ot.get(et.id);return ht.set(et.id,al(xt,!1,It?.groupDirectory??et.directory??null)),{...xt,children:[],worktree:It?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(et=>({...et,blockingBadgeSessionScopes:ht.get(et.node.session.id)}))},[m.childrenMap,m.orderedSessions,m.rootSessions,I.bySessionId,T,E,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Lt=le(ve=>ve.sessionWorkEnabled),Mt=ts(ve=>ve.showWorkSection),De=ts(ve=>ve.showPinnedSection),Tt=ts(ve=>ve.detailedZoneRows),At=!E&&!Tt,kt=l.useMemo(()=>{const ve=Lt&&Mt;if(!ve&&!De)return Du;const ct=[],ht=[];for(const Ot of m.orderedSessions)Ot.parentID||Ot.time?.archived||yl(Ot.directory)||(De&&gi(m.pinnedSessionIds,Ot.directory,Ot.id)?ct.push(Ot):ve&&Vl(Ot)&&ht.push(Ot));return ct.length===0&&ht.length===0?Du:{pinned:ct,work:ht}},[m.orderedSessions,m.pinnedSessionIds,Lt,De,Mt]),pt=kt.work,Dt=l.useMemo(()=>new Set([...kt.pinned,...kt.work].map(ve=>ve.id)),[kt]),Ve=l.useCallback(ve=>{if(ve.length===0)return Tu;const ct=Lc({sessions:[...ve],projects:t.projects,ownerBySessionId:I.bySessionId,spaceLabelById:T,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),ht=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ot=new Map,te=new Map(ve.map(St=>[St.id,Gn(m.childrenMap,St)])),et=new Map(ve.map(St=>{const Se=te.get(St.id)??Gn(m.childrenMap,St),We=ct.get(St.id)?.worktree??null;if(At){const xe=ht?qh(Se,ht)??Se:Se;return[St.id,{...xe,worktree:We}]}Ot.set(St.id,al(Se,!1,ct.get(St.id)?.groupDirectory??St.directory??null));const K={...Se,children:[],worktree:We};return[St.id,K]})),xt=l3(ve,St=>te.get(St.id)??Gn(m.childrenMap,St),ht,E?"session":"tree");return Qd({sessions:xt.sessions,getSessionLocation:St=>ct.get(St)??null,getSessionNode:St=>et.get(St.id)??Gn(m.childrenMap,St),query:""}).map(St=>({...St,blockingBadgeSessionScopes:Ot.get(St.node.session.id),searchMatchCount:xt.matchCountById.get(St.node.session.id)}))},[E,At,m.childrenMap,I.bySessionId,T,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),rt=l.useMemo(()=>Ve(kt.pinned),[Ve,kt.pinned]),wt=l.useMemo(()=>Ve(kt.work),[Ve,kt.work]),se=l.useMemo(()=>{const ve=new Map,ct=new Map,ht=new Map,Ot=new Map,te=new Set,et=(It,St)=>{const Se=St?.trim();It&&Se&&ve.set(jS(It,Se),{directory:It,branch:Se})},xt=It=>{if(et(yt(It.worktree?.path??null),It.worktree?.branch),!t.isVSCode){for(const St of vp(It.session))ct.set(`${St.owner.toLowerCase()}/${St.repo.toLowerCase()}#${St.number}`,{owner:St.owner,repo:St.repo,number:St.number});for(const St of Hl(It.session))St.source==="github"?ht.set(`${St.owner.toLowerCase()}/${St.repo.toLowerCase()}#${St.number}`,{owner:St.owner,repo:St.repo,number:St.number}):St.source==="linear"&&te.add(St.identifier.toUpperCase());for(const St of vS(It.session))Ot.set(St.key,St)}It.children.forEach(xt)};return rt.forEach(It=>xt(It.node)),wt.forEach(It=>xt(It.node)),C?(h.collapsedActivities.has("timeline")||jt.forEach(It=>xt(It.node)),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]}):E?(jt.forEach(It=>{(!It.projectId||!h.collapsedProjects.has(It.projectId))&&xt(It.node)}),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]}):(Je.forEach(It=>{h.collapsedProjects.has(It.project.id)||It.groups.forEach(St=>{if(St.isArchivedBucket||(St.sessions.forEach(xt),St.isMain))return;const Se=yt(St.directory??null);et(Se,St.branch?.trim()||t.gitBranches.get(Se||""))})}),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]})},[rt,Je,h.collapsedActivities,h.collapsedProjects,C,jt,E,t.gitBranches,t.isVSCode,wt]),Fe=se.targets,ot=l.useRef(null),$e=l.useMemo(()=>{const ve=C4(Fe.values()),ct=JSON.stringify(ve);return ot.current?.signature!==ct&&(ot.current={signature:ct,candidates:ve}),ot.current.candidates},[Fe]);l.useEffect(()=>{const ve=$e,ct=Jt(),ht=new Set(ve.map(We=>We.directory));if(ou(qe.current,ct,ht,(We,K)=>X(We,K,Le)),ve.length===0)return;let Ot=!1;const te=async(We,K=MP)=>{const xe=Date.now(),Xe=new Map,lt=Ft=>{const Wt=Xe.get(Ft);if(Wt)return Wt;const qt=Oe(ct,Ft,Le),vs=Mn.scope(Ft),ds=Nr(()=>Mn.read(vs,gt)).then(bn=>{if(Ot||ct!==Jt())return null;const Fs=bn.contexts[0],Xs=Fs&&Aa(kn.getState().entries[er(Fs)],Fs).connected?[Fs]:[];return it(ct,Ft,Le,qt,Xs)?(Xs.length===0&&ze(Ft),Xs):null});return Xe.set(Ft,ds),ds},Bt=await Promise.all(ve.filter(Ft=>!We||Ft.directory===We).map(async Ft=>(await lt(Ft.directory)??[]).map(qt=>({...Ft,context:qt}))));if(Ot||ct!==Jt())return;const Pt=new Map,Gt=new Map;for(const Ft of Bt.flat()){const Wt=Zf(Ft.context,Ft.branch);Gt.set(Wt,{context:Ft.context,branch:Ft.branch});const qt=ys.getState().entries[Wt],vs=qt?.status?.changeRequest??qt?.status?.pr,ds=vs?.state,Fs=!!vs&&!(ds==="closed"||ds==="merged"),Xs=Math.max(qt?.lastRefreshAt??0,qt?.lastDiscoveryPollAt??0),_s=!!(qt?.isInitialStatusResolved&&!Fs&&(!at.current.has(Wt)||xe-Xs>=K));(!qt||!qt.isInitialStatusResolved||_s)&&(_s&&at.current.add(Wt),Pt.has(Wt)||Pt.set(Wt,{context:Ft.context,branch:Ft.branch}))}Gt.forEach((Ft,Wt)=>{bt(Wt),Ce(Wt,{directory:Ft.context.directory,branch:Ft.branch,remoteName:Ft.context.primaryRemote,canShow:!0,identity:Ft.context,readContext:Ft.context,sourceControl:gt,authChecked:!0,connected:!0})}),Pt.size!==0&&await _e([...Pt.values()],{silent:!0,markInitialResolved:!0})},et=[...new Set(ve.map(We=>We.directory))].map(We=>Mn.scope(We)),xt=et.map(We=>{let K=Mn.snapshot(We);return Mn.subscribe(We,()=>{const xe=Mn.snapshot(We),Xe=K.read!==null&&K!==xe;K=xe,Xe&&!Ot&&te(We.directory)})}),It=kn.subscribe((We,K)=>{if(!(Ot||ct!==Jt()||We.entries===K.entries))for(const xe of et){const Xe=Mn.snapshot(xe).contexts[0];if(!Xe)continue;const lt=er(Xe);We.entries[lt]!==K.entries[lt]&&te(xe.directory)}});te();const St=En(We=>{!Ot&&We.type==="source-control-activity"&&ht.has(We.directory)&&te(We.directory,0)}),Se=()=>{!Ot&&document.visibilityState==="visible"&&te()};return document.addEventListener("visibilitychange",Se),()=>{Ot=!0,It(),xt.forEach(We=>We()),St(),document.removeEventListener("visibilitychange",Se)}},[Oe,ze,it,$e,bt,_e,X,Ce,gt,Le]),l.useEffect(()=>()=>ou(qe.current,Jt(),new Set,(ve,ct)=>X(ve,ct,Le)),[X,Le]);const Ct=l.useMemo(()=>wS(Be,Fe.values()),[Be,Fe]),Yt=Xf(Ct),es=l.useMemo(()=>[...Yt,...se.linkedRefs.map(ve=>zr("pull",ve)),...se.linkedIssueRefs.map(ve=>zr("issue",ve)),...se.gitlabRefs.map(ve=>ve.thread==="pull"?Kr("pull",ve):Kr("issue",ve)),...se.linearIdentifiers.map(Ul)],[Yt,se]);Qf(es);const{groupStatusByKey:Zt,bootstrapSnapshot:ss}=jP({childStores:nt,sections:Ke,chatGroup:de,canGrantAccess:sf()});let bs=null;$&&(Je.some(ve=>ve.project.id===R)?bs=R:Je.some(ve=>ve.project.id===e.activeProjectId)?bs=e.activeProjectId:bs=Je[0]?.project.id??null);const ls=l.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ge,collapsedGroups:h.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:ut,expandedParents:Ie,editingId:ee,editingRowKey:he,editTitle:V,sessionBatchSize:$&&!e.useGroupedSections?20:void 0,setEditingId:Q,setEditingRowKey:M,setEditTitle:ie,toggleParent:Te,allowReselect:a.allowReselect,onSessionSelected:a.onSessionSelected,resetSessionSearch:a.resetSessionSearch,deleteSessionConfirm:je,setDeleteSessionConfirm:Ee,startFolderRename:fe,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:we,setFolderRenameDraft:be,clearFolderRename:ke}),[m.pinnedSessionIds,r,o,h.collapsedGroups,Ge,ut,V,ee,he,Ie,we,be,ke,fe,je,s.startSessionWorktreeMenuLoad,a,Te,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,$]),ms=l.useMemo(()=>({showMoreGroupSessions:P,resetGroupSessionLimit:L,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x}),[L,P,x,d.openNewSessionDraft,d.setActiveProjectIdOnly,d.setSessionSwitcherOpen]),fs=l.useMemo(()=>{const ve=new Map;for(const ct of Ke)for(const ht of ct.groups){const Ot=lr(ct.project.id,ht.directory);if(!Ot)continue;const te=zn(ht),et=ve.get(Ot),xt=[...new Set([...et?.scopeKeys??[],...te.map(St=>St.scopeKey)])],It=m.hasAuthoritativeGlobalSessions&&te.every(St=>{const Se=yt(St.directory);return!Se||nt.getBootstrapState(Se)==="complete"});ve.set(Ot,{scopeKeys:xt,complete:(et?.complete??!0)&&It})}if(de){const ct=lr(null,de.directory);ct&&ve.set(ct,{scopeKeys:zn(de).map(ht=>ht.scopeKey),complete:m.hasAuthoritativeGlobalSessions})}return ve},[ss,de,nt,m.hasAuthoritativeGlobalSessions,Ke]),Es=l.useMemo(()=>new Map([...F,...B]),[B,F]),cs=l.useMemo(()=>x3({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:E?"timeline":"projects",listGrouping:D,sections:Ke,authoritativeSections:Je,chatGroup:z?de:null,timelineItems:jt,pinnedItems:rt,workItems:wt,zoneSessionIds:Dt,detailedZoneRows:Tt,foldersMap:c,groupSearchDataByGroup:Ge,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:h.collapsedProjects,collapsedGroups:h.collapsedGroups,collapsedFolders:u,collapsedActivities:h.collapsedActivities,expandedParents:Ie,visibleCountByContainer:Es,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:ut,groupStatusByKey:Zt,folderAuthorityByOwner:fs,activeProjectId:e.activeProjectId,singleProjectMode:$&&!E,singleProjectId:bs,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:$&&!e.useGroupedSections?20:void 0,runIndex:N}),[N,de,z,h.collapsedActivities,jt,E,D,rt,wt,Dt,Tt,u,m.pinnedSessionIds,Ie,fs,c,Ge,Zt,Ke,Je,h.collapsedGroups,h.collapsedProjects,bs,ut,$,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Es]);l.useEffect(()=>{Ye(cs.searchMatchCount)},[Ye,cs.searchMatchCount]),l.useEffect(()=>{if(e.hasSessionSearchQuery)return;const ve=is.getState().toggleFolderCollapse;for(const ct of cs.rows)ct.kind==="group-header"&&ct.empty&&h.collapsedGroups.has(ct.groupKey)?x(ct.groupKey):ct.kind==="folder-header"&&ct.empty&&u.has(ct.folder.id)&&ve(ct.folder.id)},[u,h.collapsedGroups,cs.rows,x,e.hasSessionSearchQuery]);const Qe=l.useMemo(()=>({rowModel:cs,sectionsForRender:Ke,projectSections:Je,singleProjectMode:$,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ee,openSidebarMenuKey:ce,setOpenSidebarMenuKey:ne,visibleSessionCountByGroup:F,collapsedActivityKeys:h.collapsedActivities,setCollapsedActivityKeys:S,visibleActivityCountByKey:B,setVisibleActivityCountByKey:j},groupProps:ls}),[ls,ee,ce,Je,Ke,cs,t.projectRepoStatus,e.emptyState,e.searchEmptyState,F,B,h.collapsedActivities,S,$]),vt=l.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:re}),[re,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),$t=l.useMemo(()=>({group:ms,toggleProject:y,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:G}),[ms,d.openNewSessionDraft,d.openNewWorktreeDialog,d.openProjectEditDialog,d.openWorktreesPage,d.removeProject,d.reorderProjects,d.setActiveProjectIdOnly,d.setSessionSwitcherOpen,b,y,d.renderProjectStatusIndicator,G]);return n.jsxs(n.Fragment,{children:[n.jsx(S4,{}),n.jsx(D4,{projectSections:Je,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:I.bySessionId,handleSessionSelect:ue}),n.jsx(H4,{sortedSessions:m.orderedSessions,workSessions:pt,prefetchSession:me,children:n.jsxs(i5,{entries:cs.selectionEntries,descendantIds:cs.selectionDescendantIds,sessionsById:cs.sessionById,children:[n.jsx(dP,{getFolderScopesForProject:Ue,isInlineEditing:ee!==null,startFolderRename:fe}),n.jsx("div",{className:"contents",onPointerEnter:ve=>{Rt&&ve.pointerType==="mouse"&&ft(st.current)},onPointerLeave:()=>ft(null),children:n.jsx(QI,{model:Qe,view:vt,actions:$t})})]})})]})},FP=t=>{const e=Ze.c(3),[s,r]=l.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let o;return e[0]!==t||e[1]!==s?(o=s?n.jsx(BP,{...t}):null,e[0]=t,e[1]=s,e[2]=o):o=e[2],o},bm=(t,e,s)=>{const r=new Set;for(const o of t){const i=yt(o.path);i&&r.add(i)}if(s?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const a=yt(i.path);a&&r.add(a)}return r},Ru="oc.sessions.activeSessionByProject",_P=Wr(zs(),zs().min(1).catch("")),LP=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{Pa("react.session_sidebar_render"),As("ui.session_sidebar.render"),As(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),As(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:a}=Et(),[d,c]=l.useState(!1),[u,f]=l.useState(""),p=l.useCallback(()=>c(!0),[]),h=l.useCallback(()=>{f(""),c(!1)},[]),[g,b]=l.useState(0),x=l.useRef(null),y=l.useRef(null),[S,m]=l.useState(null),v=l.useMemo(()=>Oo(),[]),[w,T]=l.useState(new Map),k=le(De=>De.isNewWorktreeDialogOpen),I=le(De=>De.setNewWorktreeDialogOpen),[F,O]=l.useState(!1),B=l.useMemo(()=>{try{const De=v.getItem(Ru);if(!De)return new Map;const Tt=_P.safeParse(JSON.parse(De));if(!Tt.success)return new Map;const At=new Map;return Object.entries(Tt.data).forEach(([kt,pt])=>{pt&&At.set(kt,pt)}),At}catch{return new Map}},[v]),j=l.useCallback(De=>{try{v.setItem(Ru,JSON.stringify(Object.fromEntries(De.entries())))}catch{}},[v]),[P,L]=l.useState(new Map),z=Ps(De=>De.homeDirectory),H=ns(De=>De.projects),R=ns(De=>De.activeProjectId),G=ns(De=>De.removeProject),_=ns(De=>De.setActiveProjectIdOnly),$=ns(De=>De.updateProjectMeta),E=ns(De=>De.reorderProjects),D=le(De=>De.setSettingsDialogOpen),C=le(De=>De.toggleHelpDialog),N=le(De=>De.setAboutDialogOpen),A=le(De=>De.setSessionSwitcherOpen),q=le(De=>De.setWorktreesPageProjectId),ee=le(De=>De.notifyOnSubtasks),Q=l.useMemo(()=>u.trim().toLowerCase(),[u]),he=Q.length>0;XC({enabled:t,isSessionSearchOpen:d,openSessionSearch:p,closeSessionSearch:h,sessionSearchInputRef:y,sessionSearchContainerRef:x});const M=kS(t),V=l.useMemo(()=>Dn(),[]),ie=mt(De=>De.worktreeMetadata),ce=mt(De=>De.availableWorktreesByProject),ne=mt(De=>De.openNewSessionDraft),je=l.useMemo(()=>bm(H,ce,{includeWorktrees:!V}),[ce,V,H]),Ee=l.useCallback(De=>{le.getState().closeMainSurfaces(),ne(De),V&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[V,ne]),we=Rr(hr(De=>({checkForUpdates:De.checkForUpdates,available:De.available,runtimeType:De.runtimeType,info:De.info,downloading:De.downloading,downloaded:De.downloaded,installing:De.installing,progress:De.progress,error:De.error,downloadUpdate:De.downloadUpdate,restartToUpdate:De.restartToUpdate}))),Me=Jt(),fe=l.useMemo(()=>`${Me}|${H.map(De=>`${De.id}:${yt(De.path)??""}`).join("|")}`,[H,Me]),[be,ke]=l.useState(V?fe:null),[Ie,Te]=l.useReducer(De=>De+1,0),Y=!V&&be!==fe,[ue,me]=l.useState(new Set),re=l.useRef(ue);re.current=ue;const pe=ps(De=>De.isConnected),U=l.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});l.useEffect(()=>{let De=!1;return(async()=>{const At=Me,kt=ps.getState().isConnected,pt=ns.getState().projects;if(mt.setState({worktreeDiscoveryByProject:new Map(pt.map($e=>[yt($e.path)??$e.path,"loading"]))}),pt.length===0||V){De||(U.current={runtimeKey:null,revision:0,worktreesByProject:new Map},me(new Set),ke(fe));return}const Dt=mt.getState().availableWorktreesByProject,Ve=oc({rawWorktreesByProjectRef:U,publishedWorktreesByProject:Dt,runtimeKey:At}),rt=Ve.revision,wt=new Map(Ve.worktreesByProject),se=new Set;if(await Nr(()=>Promise.all(pt.map(async $e=>{const Ct=yt($e.path);if(Ct)try{if(!(Cn.getState().directories.get(Ct)?.isGitRepo??await Rf(Ct))){wt.delete(Ct);return}const Zt=await Jc({id:$e.id,path:Ct});if(De)return;Zt.length===0?wt.delete(Ct):wt.set(Ct,Zt)}catch{se.add(Ct)}}))),De||Jt()!==At)return;const Fe=new Set(pt.map($e=>yt($e.path)).filter(Boolean));for(const $e of wt.keys())Fe.has($e)||wt.delete($e);C5({rawWorktreesByProjectRef:U,runtimeKey:At,capturedRevision:rt,nextRawWorktreesByProject:wt,publishedWorktreesByProject:Dt,partitionWorktreesByRegisteredProject:Xc,projects:pt,worktreeMapsEqual:Qc,recordWorktreesSeen:Iu,publishTopology:$e=>{mt.setState($e)},requestRediscovery:()=>{Te()},now:()=>Date.now()})&&(me(se),mt.setState({worktreeDiscoveryByProject:new Map(pt.map($e=>{const Ct=yt($e.path)??$e.path;return[Ct,se.has(Ct)?"error":"ready"]}))}),ke(fe),se.size>0&&!kt&&ps.getState().isConnected&&Te())})(),()=>{De=!0}},[V,fe,Me,Ie]),l.useEffect(()=>{pe&&re.current.size>0&&Te()},[pe]);const ae=l.useMemo(()=>hn(),[]),{isTablet:Re}=Rn(),W=e||Re,ye=l.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noSessions.description")})]}),[a]),de=l.useMemo(()=>H.find(De=>De.id===S)??null,[H,S]),Ne=l.useCallback(De=>{S&&$(S,{label:De.label,icon:De.icon,color:De.color,iconBackground:De.iconBackground,defaultAgent:De.defaultAgent??null,defaultModel:De.defaultModel??null,defaultVariant:De.defaultVariant??null})},[S,$]),Je=l.useCallback(()=>{I(!0)},[I]),Ge=l.useCallback(()=>{const De=Rr.getState();if(De.available&&De.info){O(!0);return}we.checkForUpdates().then(()=>{const{available:Tt,error:At}=Rr.getState();if(At){He.error(a("sessions.sidebar.updateCheck.errorTitle"),{description:At});return}if(!Tt){He.success(a("sessions.sidebar.updateCheck.latestVersion"));return}O(!0)})},[a,we]),ge=l.useCallback(()=>{e&&A(!1),D(!0)},[e,A,D]),Ae=we.available&&(we.runtimeType==="desktop"||we.runtimeType==="web"),Ye=l.useCallback(()=>{Tn.requestDirectoryDialog()},[]),nt=l.useMemo(()=>H.flatMap(De=>{const Tt=yt(De.path);return Tt?[{id:De.id,path:De.path,label:De.label,normalizedPath:Tt,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}]:[]}),[H]),oe=l.useMemo(()=>nt.map(De=>De.normalizedPath),[nt]),tt=CS(oe,t);P3({enabled:t,normalizedProjects:nt,gitRepoStatus:tt,setProjectRepoStatus:T,setProjectRootBranches:L});const Ue=mt(De=>De.isLoading),gt=l.useRef(!1);R&&w.has(R)&&(gt.current=!!w.get(R));const bt=ts(De=>De.showArchivedSessions),Ce=ts(De=>De.projectSortOrder),_e=ts(De=>De.sidebarViewMode),ze=V?"projects":_e,Oe=ze==="timeline"?"manual":Ce,it=ns(De=>De.manualProjectOrder),X={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:a,isTablet:Re,projects:H,activeProjectId:R,manualProjectOrder:it,worktreeMetadata:ie,availableWorktreesByProject:ce,gitBranches:M,gitRepoStatus:tt,updateStore:we,showArchivedSessions:bt,projectSortOrder:Oe,projectRepoStatus:w,projectRootBranches:P,resolvedWorktreeTopologyKey:be,unresolvedWorktreeProjectPaths:ue,isSessionSearchOpen:d,sessionSearchQuery:u,editingProjectDialogId:S,updateDialogOpen:F},Be=l.useRef(null),Le=Be.current;if(Le){let De=!1;for(const Tt of Object.keys(X))Object.is(Le[Tt],X[Tt])||(As(`ui.session_sidebar.source.${Tt}`),De=!0);De||As("ui.session_sidebar.source.parent_or_context")}Be.current=X;const at=l.useMemo(()=>IS(nt,Oe,it),[nt,Oe,it]),qe=w3({isVSCode:V,projects:at}),ut=l.useMemo(()=>n.jsx(y4,{query:u,showArchive:!V,resetSessionSearch:h}),[V,h,u]),dt=V&&bt,ft=!V,Ke=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 w-4",Lt=l.useMemo(()=>({projects:H,getCurrentProjects:()=>ns.getState().projects,rawWorktreesByProjectRef:U,getPublishedWorktreesByProject:()=>mt.getState().availableWorktreesByProject,resolveProject:De=>Na(De),listProjectWorktrees:Jc,partitionWorktreesByRegisteredProject:Xc,worktreeMapsEqual:Qc,recordWorktreesSeen:Iu,publishTopology:De=>{mt.setState(De)},getRuntimeKey:Jt,now:()=>Date.now()}),[H]),Mt=l.useCallback(De=>{const Tt=fm(De,{projects:H,resolveProject:Na});return k5(De,{...Lt,projectRootBranch:Tt?P.get(Tt.id)??null:null})},[P,H,Lt]);return l.useEffect(()=>{if(V)return;const De=Tt=>{for(const At of Tt){const kt=yt(At.path),pt=Jt(),Dt=Ve=>{!kt||Jt()!==pt||mt.setState(rt=>({worktreeDiscoveryByProject:new Map(rt.worktreeDiscoveryByProject).set(kt,Ve)}))};Dt("loading"),dm(At,null,Lt).then(()=>{!kt||Jt()!==pt||(Dt("ready"),me(Ve=>{if(!Ve.has(kt))return Ve;const rt=new Set(Ve);return rt.delete(kt),rt}))}).catch(()=>{!kt||Jt()!==pt||(Dt("error"),me(Ve=>new Set(Ve).add(kt)))})}};return En(Tt=>{if(Tt.type==="session-created"){const At=PS(Tt.directory,ns.getState().projects);if(!At){Te();return}De([At]);return}Tt.type==="worktree-changed"&&De(ES(Tt.directories))})},[V,Lt]),n.jsx(bi,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:x,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(F3,{hideDirectoryControls:o,showProjectDisplayControls:!V,showSectionControls:!V,handleOpenDirectoryDialog:Ye,showSourceBoard:!e&&!V,headerActionIconClass:jt,headerActionButtonClass:Ke,isSessionSearchOpen:d,openSessionSearch:p,closeSessionSearch:h,sessionSearchInputRef:y,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:he,searchMatchCount:g,collapseAll:qe.actions.collapseAll,expandAll:qe.actions.expandAll}),n.jsx(FP,{topology:{projects:at,availableWorktreesByProject:ce,knownDirectories:je,isVSCode:V,worktreeMetadata:ie,gitBranches:M,projectRepoStatus:w,projectRootBranches:P,lastRepoStatus:gt.current},view:{isVisible:t,hasSessionSearchQuery:he,normalizedSessionSearchQuery:Q,activeProjectId:R,showInlineArchived:dt,useGroupedSections:ft,homeDirectory:z,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:ae,projectSortOrder:Oe,sidebarViewMode:ze,emptyState:ye,searchEmptyState:ut,isSessionsLoading:Ue,isWorktreeTopologyLoading:Y,unresolvedWorktreeProjectPaths:ue,projectView:qe.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:h},alwaysShowActions:W,notifyOnSubtasks:ee,setActiveProjectIdOnly:_,setSessionSwitcherOpen:A,openNewSessionDraft:Ee,openNewWorktreeDialog:Je,openWorktreesPage:De=>{e&&A(!1),q(De)},openProjectEditDialog:m,removeProject:G,reorderProjects:E,startSessionWorktreeMenuLoad:Mt,initialActiveSessionByProject:B,persistActiveSessionByProject:j,projectViewActions:qe.actions}}),n.jsx(g4,{onOpenSettings:ge,onOpenShortcuts:C,onOpenAbout:()=>N(!0),onOpenUpdate:Ge,showRuntimeButtons:!V,showUpdateButton:Ae}),n.jsx(jl,{open:F,onOpenChange:O,info:we.info,downloading:we.downloading,downloaded:we.downloaded,installing:we.installing,progress:we.progress,error:we.error,onDownload:we.downloadUpdate,onRestart:we.restartToUpdate,runtimeType:we.runtimeType}),n.jsx(A3,{open:!!de,onOpenChange:De=>{De||m(null)},project:de,onSave:Ne}),n.jsx(TS,{open:k,onOpenChange:I,onWorktreeCreated:De=>{le.getState().closeMainSurfaces(),e&&A(!1),ne({directoryOverride:De,preserveDirectoryOverride:!0})}})]})})},$P=l.memo(LP),ln=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Us=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},zP=()=>{const{t}=Et(),{git:e,sourceControl:s}=Ks(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[d,c]=l.useState([]),[u,f]=l.useState(!1),[p,h]=l.useState(!1),[g,b]=l.useState(!1),[x,y]=l.useState(!1),[S,m]=l.useState(new Set),v=mt(Y=>Y.getWorktreeMetadata),w=mt(Y=>Y.newSessionDraft),T=mt(Y=>Y.setNewSessionDraftTarget),k=mt(Y=>Y.setDraftBootstrapPendingDirectory),I=DS,F=NS,O=mt(Y=>Y.deleteSessions),B=mt(Y=>Y.archiveSessions),j=le(Y=>Y.showDeletionDialog),P=le(Y=>Y.setShowDeletionDialog),L=Ps(Y=>Y.currentDirectory),z=Ps(Y=>Y.homeDirectory),H=ns(Y=>Y.projects),R=ns(Y=>Y.activeProjectId),{isMobile:G,isTablet:_,hasTouchInput:$}=Rn(),E=G||_||$,D=l.useMemo(()=>{const ue=(R?H.find(me=>me.id===R)??null:null)?.path??L;return Us(ue)},[R,L,H]),C=l.useCallback(Y=>{const me=Us(Y.projectDirectory)||D;return{id:(H.find(pe=>Us(pe.path)===me)??null)?.id??`path:${me}`,path:me}},[D,H]),N=x&&S.size>0,A=l.useMemo(()=>{const Y=i?.worktree;return Y&&typeof Y.branch=="string"&&Y.branch.trim().length>0?!!Y.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:ue})=>typeof ue.branch=="string"&&ue.branch.trim().length>0&&!!ue.status?.upstream?.split("/")[0]?.trim())},[i?.worktree,d]),q=i?.mode==="worktree",ee=g||!q||!A,Q=g||!q,he=l.useCallback(Y=>{a({sessions:Y.sessions,dateLabel:Y.dateLabel,mode:Y.mode??"session",worktree:Y.worktree??null})},[]),M=l.useCallback(()=>{a(null),c([]),f(!1),h(!1),b(!1),y(!1),m(new Set)},[]),V=l.useCallback(async Y=>{if(Y.sessions.length===0)return;if(Y.sessions.length===1){const pe=Y.sessions[0];await I(pe.id)?He.success(t("sessions.sidebar.session.delete.success")):He.error(t("sessions.sidebar.session.delete.error"));return}const ue=Y.sessions.map(pe=>pe.id),{deletedIds:me,failedIds:re}=await O(ue);if(me.length>0){const pe=re.length>0?re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:re.length}):Y.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Y.dateLabel}):void 0;He.success(me.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:me.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:me.length}),{description:ln(pe)})}re.length>0&&He.error(re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:re.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[I,O,t]);l.useEffect(()=>Tn.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),h(!1),y(!1),m(new Set);return}const Y=i.sessions.map(re=>{const pe=v(re.id);return pe?{session:re,metadata:pe}:null}).filter(re=>!!re);c(Y),f(!1),y(!1),m(new Set);const ue=new Map;if(i.worktree?.path&&ue.set(Us(i.worktree.path),i.worktree),Y.forEach(({metadata:re})=>{re.path&&ue.set(Us(re.path),re)}),ue.size===0){y(!0);return}let me=!1;return(async()=>{const re=new Map,pe=new Set;await Promise.all(Array.from(ue.entries()).map(async([U,ae])=>{try{const Re=await ed(ae.path);re.set(U,Re),Re?.isDirty&&pe.add(U)}catch{ae.status&&(re.set(U,ae.status),ae.status.isDirty&&pe.add(U))}})).catch(U=>{console.warn("Failed to inspect worktree status before deletion:",U)}),!me&&(m(pe),y(!0),a(U=>{if(!U?.worktree?.path)return U;const ae=Us(U.worktree.path),Re=re.get(ae);if(!Re)return U;const W=U.worktree.status;return W?.isDirty===Re.isDirty&&W?.ahead===Re.ahead&&W?.behind===Re.behind&&W?.upstream===Re.upstream?U:{...U,worktree:{...U.worktree,status:Re}}}),c(U=>U.map(ae=>{const Re=Us(ae.metadata.path),W=re.get(Re);return W?{session:ae.session,metadata:{...ae.metadata,status:W}}:ae})))})(),()=>{me=!0}},[i,v]),l.useEffect(()=>{A||f(!1)},[A]);const ie=l.useCallback(async(Y,ue,me)=>{const re=u&&A,pe=C(Y),U=Us(Y.path),ae=Us(pe.path);try{await Nf(pe,Y,{deleteRemoteBranch:re,deleteLocalBranch:ue,remoteName:Y.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const Re=ye=>!!(U&&ye&&Pf(U,ye)),W=Us(w?.directoryOverride);return w?.open&&Re(W)&&ae&&(k(null),T({projectId:pe.id,directoryOverride:ae},{force:!0})),Re(Us(L))&&ae&&Ps.getState().setDirectory(ae,{showOverlay:!1}),!0}catch(Re){return He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:sa(Y)}),{id:me,description:ln(Re instanceof Error?Re.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[A,L,u,C,e,w?.directoryOverride,w?.open,k,T,s,t]),ce=l.useCallback((Y,ue,me)=>{const re=u&&A,pe=He.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:sa(Y)}));return RS(Y.path),(async()=>{try{const U=await uy({sessionIds:ue,removeWorktree:()=>ie(Y,me,pe),archiveSessions:async W=>W.length===1?await F(W[0])?{archivedIds:W,failedIds:[]}:{archivedIds:[],failedIds:W}:B(W)});if(!U.removed)return;const ae=t(re?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");He.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:sa(Y)}),{id:pe,description:ln(ae)});const{failedIds:Re}=U.archive;Re.length>0&&He.error(Re.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:Re.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(U){He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:pe,description:ln(U instanceof Error?U.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{MS(Y.path)}})()},[F,B,A,u,ie,t]),ne=l.useRef(new Set),je=l.useCallback(async(Y,ue)=>{const me=Us(Y.path);if(!ne.current.has(me)){ne.current.add(me);try{const re=await ed(Y.path).catch(()=>{});if(!AS(re)){he({sessions:ue,mode:"worktree",worktree:Y});return}await ce(Y,ue.map(pe=>pe.id),!0)}finally{ne.current.delete(me)}}},[he,ce]);l.useEffect(()=>Tn.onDeleteRequest(Y=>{if(!j&&(Y.mode??"session")==="session"){V(Y);return}if(Y.mode==="worktree"&&Y.skipDialogIfSafe&&Y.worktree){je(Y.worktree,Y.sessions);return}he(Y)}),[he,j,V,je]);const Ee=l.useCallback(async()=>{if(i){b(!0);try{if(q){const Y=i.worktree??d[0]?.metadata;if(!Y){He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}ce(Y,i.sessions.map(ue=>ue.id),p),M();return}if(i.sessions.length===1){const Y=i.sessions[0];if(!await I(Y.id)){He.error(t("sessions.sidebar.session.delete.error")),b(!1);return}He.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Y=i.sessions.map(re=>re.id),{deletedIds:ue,failedIds:me}=await O(Y);if(ue.length>0){const re=me.length>0?me.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:me.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:me.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;He.success(ue.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ue.length}),{description:ln(re),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(me.length>0&&(He.error(me.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:me.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:me.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ue.length===0)){b(!1);return}}M()}finally{b(!1)}}},[i,d,p,I,O,M,q,ce,t]),we=i?.worktree??d[0]?.metadata??null;let Me="";if(i?.mode==="worktree"){const Y=i.sessions.length;Y===0?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):Y===1?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:Y}):Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:Y})}else if(i){const Y=i.sessions.length;Y===1?Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:Y,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:Y})}const fe=i?n.jsxs("div",{className:Pe(q?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:Pe(q?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[q&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:i.sessions.length})]}),n.jsxs("ul",{className:Pe(q?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(Y=>n.jsxs("li",{className:Pe(q?"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:[n.jsx("span",{className:Pe(!q&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:Y.title||t("sessions.sidebar.session.untitled")})]},Y.id)),i.sessions.length>5&&n.jsx("li",{className:Pe(q?"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:i.sessions.length-5})})]})]}),q?n.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Z,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),we?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:we.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:we?fr(we.path,z):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),N&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,be=q?A?n.jsxs("button",{type:"button",onClick:()=>{ee||f(Y=>!Y)},disabled:ee,"aria-pressed":u,className:Pe("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:[u?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,ke=q?n.jsxs("button",{type:"button",onClick:()=>{Q||h(Y=>!Y)},disabled:Q,"aria-pressed":p,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Q?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ie=q?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[ke,be]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:M,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",onClick:Ee,disabled:g,children:t(g?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>P(!j),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":!j,children:[j?n.jsx(Z,{name:"checkbox-blank",className:"size-4"}):n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:M,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",onClick:Ee,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Te=q?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[E?n.jsx(OS,{open:!!i,onClose:()=>{g||M()},title:Te,footer:n.jsx("div",{className:"flex justify-end gap-2",children:Ie}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Me&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Me}),fe]})}):n.jsx(Qs,{open:!!i,onOpenChange:Y=>{if(!Y){if(g)return;M()}},children:n.jsxs(Zs,{className:Pe(q?"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:[n.jsxs(on,{children:[n.jsxs(nn,{className:Pe(q&&"flex items-center gap-2"),children:[q&&n.jsx(Z,{name:"delete-bin",className:"h-5 w-5"}),Te]}),Me&&n.jsx(rn,{children:Me})]}),n.jsx("div",{className:Pe(q&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:fe}),n.jsx(Pn,{className:"mt-2 gap-2 pt-1 pb-1",children:Ie})]})}),n.jsx(fy,{open:r,onOpenChange:o})]})},KP=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],WP=["dev","start","preview","serve"];async function HP(t,e,s){if(!t)return null;const r=GP(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=qP(s);if(o){const i=await YP(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await UP(t)){const o=await VP(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function UP(t){const e=`${t}/index.html`,s=await ti(e,t);return typeof s=="string"&&s.trim().length>0}async function VP(){try{const t=await Ys("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function GP(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(WP.some(o=>s.includes(o)))return e}return null}function qP(t){for(const{pattern:e}of KP)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function YP(t){const e=await ti(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await ti(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function ti(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Ys(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=rf()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Ys(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function ZP(t){try{const e=await ti(`${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 QP=/\{(worktree|branch)\}/g,ka=63,XP=new Set(["main","master"]),ym=t=>/\{(worktree|branch)\}/.test(t??""),JP=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},xm=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=ka)return e;const s=await JP(e);return s?`${e.slice(0,ka-7).replace(/-+$/,"")}-${s}`:e.slice(0,ka).replace(/-+$/,"")},eE=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},tE=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:eE(i.current),linkedWorktree:o}},sE=async t=>!t.linkedWorktree||!t.branch||XP.has(t.branch)?"":xm(t.branch.split("/").pop()??""),nE=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",d=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${d.join(".")}${a}`},rE=async(t,e)=>{const s={worktree:await sE(e),branch:e.branch?await xm(e.branch):""},r=t.replace(QP,(c,u)=>s[u]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${nE(a)}${d}`},oE=async(t,e,s)=>ym(e)?rE(e,await tE(t,s,e)):e,Sm="oc.projectActions.selectedAction.v1",iE=Wr(zs(),Wr(zs(),zs())),wm=()=>{const t=ai().getItem(Sm);if(t===null)return{};try{const e=iE.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Nu=(t,e=Jt())=>wm()[e]?.[t]??null,aE=(t,e,s=Jt())=>{const r=wm();r[s]?.[t]!==e&&ai().setItem(Sm,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},lE=15e3,cE=3e3,dE=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},uE=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=Et(),{currentTheme:o}=br(),{terminal:i,runtime:a,git:d}=Ks(),c=Nn(),{isMobile:u}=Rn(),f=l.useMemo(()=>hn(),[]),p=$c(X=>X.instances),h=$c(X=>X.load),g=le(X=>X.terminalShell),b=le(X=>X.terminalLoginShells.includes(X.terminalShell)),x=le(X=>X.setSettingsPage),y=le(X=>X.setSettingsDialogOpen),S=le(X=>X.setSettingsProjectsSelectedId),m=le(X=>X.openContextPreview),v=zt(X=>X.ensureDirectory),w=zt(X=>X.reconcileServerSessions),T=zt(X=>X.setTabLabel),k=zt(X=>X.setTabIconKey),I=zt(X=>X.setActiveTab),F=zt(X=>X.setConnecting),O=zt(X=>X.setTabSessionId),B=zt(X=>X.setTabPurpose),j=zt(X=>X.allocateActionExecution),P=zt(X=>X.setTabLifecycle),L=zt(X=>X.setTabPreviewUrl),z=zt(X=>X.matchesActionExecution),H=zt(X=>X.captureStartedActionMutationRevisions),[R,G]=l.useState([]),_=l.useRef(null),[$,E]=l.useState(()=>t?.id?Nu(t.id):null),[D,C]=l.useState(!1),N=l.useRef({}),A=l.useRef({}),q=l.useRef({}),ee=l.useRef(new Set),Q=l.useRef(0),[he,M]=l.useState({}),V=t?.id??null,ie=t?.path??"";l.useEffect(()=>{E(V?Nu(V):null)},[V]);const ce=l.useMemo(()=>V?{id:V,path:ie}:null,[V,ie]);l.useEffect(()=>{f&&h().catch(()=>{})},[f,h]);const ne=l.useCallback(async X=>{await xr(X)},[]),je=l.useCallback(async()=>{if(!ce)return;const X=Q.current+1;Q.current=X,C(!0);try{const Be=await td(ce);if(Q.current!==X)return;_.current=Be;const Le=Be.projectActions;G(Le)}catch{if(Q.current!==X)return}finally{Q.current===X&&C(!1)}},[ce]),Ee=l.useMemo(()=>na(e||ce?.path||""),[e,ce?.path]),we=l.useMemo(()=>na(ce?.path||""),[ce?.path]),Me=l.useMemo(()=>na(c||"")||Ee,[c,Ee]),fe=l.useRef(Me);l.useEffect(()=>{fe.current=Me},[Me]);const be=zt(X=>Ee?X.getDirectoryState(Ee):void 0),ke=zt(X=>we&&we!==Ee?X.getDirectoryState(we):void 0),Ie=l.useMemo(()=>{const X=Ee?[{directory:Ee,state:be}]:[];return we&&we!==Ee&&X.push({directory:we,state:ke}),X},[be,Ee,we,ke]),Te=l.useMemo(()=>{const X=Ee?[Ee]:[];return we&&we!==Ee&&X.push(we),X},[Ee,we]),Y=l.useCallback(X=>X.id!==An&&X.runIn==="parent"&&we||Ee,[Ee,we]),ue=l.useCallback((X,Be,Le)=>`${X}::${Be}::${Le}`,[]),me=l.useCallback((X,Be,Le=zt.getState())=>X?Le.getDirectoryState(X)?.tabs.find(at=>at.purpose.type==="project-action"&&at.purpose.actionId===Be)??null:null,[]),re=l.useMemo(()=>{const X={};for(const{directory:Be,state:Le}of Ie)for(const at of Le?.tabs??[]){if(at.purpose.type!=="project-action"||!at.purpose.executionId||!at.terminalSessionId||at.lifecycle==="idle"||at.lifecycle==="exited")continue;const qe=qn(Be,at.purpose.actionId),ut=ue(Be,at.purpose.actionId,at.purpose.executionId);X[qe]={directory:Be,actionId:at.purpose.actionId,tabId:at.id,sessionId:at.terminalSessionId,executionId:at.purpose.executionId,status:at.lifecycle==="stopping"?"stopping":he[ut]?"waiting-for-preview":"running"}}return X},[ue,he,Ie]),pe=l.useCallback((X,Be,Le)=>{const at=qn(X,Be),qe=ue(X,Be,Le),dt=N.current[at]?.executionId===Le,ft=globalThis.window,st=Rt=>{ft?.clearTimeout(q.current[Rt]),delete q.current[Rt]};dt&&(delete N.current[at],st(at)),A.current[qe]?.(),delete A.current[qe],st(qe),M(Rt=>{if(!Rt[qe])return Rt;const Ke={...Rt};return delete Ke[qe],Ke})},[ue]),U=l.useCallback(X=>{A.current[X]?.(),delete A.current[X]},[]),ae=l.useCallback(X=>{window.clearTimeout(q.current[X]),delete q.current[X]},[]);l.useEffect(()=>{const X=A.current,Be=q.current;return()=>{for(const Le of Object.keys(X))U(Le);for(const Le of Object.keys(Be))ae(Le)}},[ae,U]),l.useEffect(()=>{const X=new Set(Te);for(const Be of Object.values(N.current))X.has(Be.directory)||pe(Be.directory,Be.actionId,Be.executionId);for(const Be of Object.keys(A.current)){const Le=Be.split("::",1)[0]??"";X.has(Le)||U(Be)}},[pe,U,Te]);const Re=l.useCallback((X,Be)=>{le.getState().openContextPanelTab(X,{mode:"terminal",targetDirectory:Be===X?null:Be})},[]),W=l.useMemo(()=>({id:An,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),ye=!u,de=l.useMemo(()=>ye?[...R,W]:R,[R,W,ye]),Ne=l.useMemo(()=>$?de.find(X=>X.id===$)??null:null,[de,$]);l.useEffect(()=>{je()},[je]);const[Je,Ge]=l.useState(0),ge=l.useCallback(()=>(Ge(X=>X+1),()=>Ge(X=>X-1)),[]),Ae=Je>0;l.useEffect(()=>{if(!Ae)return;const X=Te.map(Be=>Ta(i,Be,H,Le=>w(Be,Le.sessions,{startedActionMutationRevisions:Le.startedActionMutationRevisions})));return()=>{for(const Be of X)Be()}},[H,Ae,w,i,Te]),l.useEffect(()=>{for(const{directory:X,state:Be}of Ie)if(X)for(const Le of Be?.tabs??[]){if(Le.purpose.type!=="project-action")continue;const at=Le.purpose.actionId,qe=de.find(ft=>ft.id===at),ut=qe?.name??at,dt=qe?.icon||"play";Le.label!==ut&&T(X,Le.id,ut),Le.iconKey!==dt&&k(X,Le.id,dt)}},[de,k,T,Ie]),l.useEffect(()=>{const X=globalThis.window;if(!X)return;const Be=Le=>{const at=Le.detail;V&&(at?.projectId&&at.projectId!==V||je())};return X.addEventListener(sd,Be),()=>{X.removeEventListener(sd,Be)}},[je,V]),l.useEffect(()=>{const X=Le=>{delete q.current[Le];const at=N.current[Le];if(!at||at.openedUrl)return;const qe=ue(at.directory,at.actionId,at.executionId),ut=at.announced;if(ut.length!==0){if(window.clearTimeout(q.current[qe]),delete q.current[qe],at.openedUrl=!0,M(dt=>{if(!dt[qe])return dt;const ft={...dt};return delete ft[qe],ft}),ut.length===1){fa(at.directory,[]),L(at.directory,at.tabId,ut[0],{locked:!1,autoOpened:!0}),m(at.directory,ut[0]);return}at.offering=!0,fa(at.directory,ut),le.getState().openContextSurface(at.directory,"browser"),He.info(r("projectActions.toast.multipleServers"))}},Be=()=>{const Le=zt.getState(),at=Le.sessions,qe=re;for(const[ut,dt]of Object.entries(qe)){const st=at.get(dt.directory)?.tabs.find(pt=>pt.id===dt.tabId);if(!st||st.terminalSessionId!==dt.sessionId){pe(dt.directory,dt.actionId,dt.executionId);continue}const Rt=N.current[ut],Ke=Rt?.executionId===dt.executionId?Rt:{hostDirectory:fe.current||dt.directory,directory:dt.directory,tabId:dt.tabId,actionId:dt.actionId,executionId:dt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};N.current[ut]=Ke;const jt=de.find(pt=>pt.id===dt.actionId),Lt=Le.getBuffer(dt.directory,dt.tabId).chunks;if(!jt||Lt.length===0)continue;const Mt=Lt.filter(pt=>Ke.lastSeenChunkId===null||pt.id>Ke.lastSeenChunkId);if(Mt.length===0)continue;const De=Mt.map(pt=>pt.data).join(""),Tt=`${Ke.tail}${De}`;for(const pt of by(Tt))Ke.proxiedPorts.includes(pt)||Ke.proxiedPorts.push(pt);if(Ke.openInPreview&&(!Ke.openedUrl||Ke.offering)){const pt=yy(Tt,{proxiedPorts:Ke.proxiedPorts,namedAddressesReachable:!zc()}),Dt=Ke.announced.length;for(const rt of pt)Ke.announced.includes(rt)||Ke.announced.push(rt);const Ve=Ke.announced.length-Dt;Ke.offering&&Ve>0?fa(dt.directory,Ke.announced):!Ke.openedUrl&&Dt===0&&Ke.announced.length>0&&(window.clearTimeout(q.current[ut]),q.current[ut]=window.setTimeout(()=>X(ut),cE))}const At=!Ke.openedUrl&&jt.autoOpenUrl===!0&&!Ke.openInPreview?xy(Tt,{proxiedPorts:Ke.proxiedPorts,namedAddressesReachable:!zc()}):null,kt=Mt[Mt.length-1]?.id??Ke.lastSeenChunkId;if(Ke.lastSeenChunkId=kt,Ke.tail=Tt.slice(-512),At)if(Ke.openedUrl=!0,Ke.openInPreview){const pt=qe[ut];pt&&(L(pt.directory,pt.tabId,At,{locked:!1,autoOpened:!1,expectedExecutionId:pt.executionId}),pt.status==="waiting-for-preview"&&M(Dt=>{const Ve=ue(pt.directory,pt.actionId,pt.executionId);if(!Dt[Ve])return Dt;const rt={...Dt};return delete rt[Ve],rt}),window.clearTimeout(q.current[ut]),delete q.current[ut],m(pt.directory,At))}else ne(At),He.success(r("projectActions.toast.openedUrlFromOutput"));N.current[ut]=Ke}for(const ut of Object.keys(N.current))if(!qe[ut]){const dt=N.current[ut],ft=dt?at.get(dt.directory)?.tabs.find(Rt=>Rt.id===dt.tabId):void 0;if(ft?.purpose.type==="project-action"&&ft.purpose.executionId===dt?.executionId&&!!ft.terminalSessionId&&ft.lifecycle!=="idle"&&ft.lifecycle!=="exited")continue;delete N.current[ut],window.clearTimeout(q.current[ut]),delete q.current[ut]}};return Be(),zt.subscribe((Le,at)=>{(Le.sessions!==at.sessions||Le.buffers!==at.buffers)&&Be()})},[pe,fe,de,ue,m,ne,re,L,r]),l.useEffect(()=>{for(const{directory:X,state:Be}of Ie)for(const Le of Be?.tabs??[]){if(Le.purpose.type!=="project-action"||!Le.purpose.executionId||!Le.terminalSessionId||Le.lifecycle!=="running")continue;const at=Le.purpose.actionId,qe=Le.purpose.executionId,ut=ue(X,at,qe);if(A.current[ut])continue;const dt=i.connect(Le.terminalSessionId,{onEvent:ft=>{if(!z(X,Le.id,qe))return;ft.type==="snapshot"&&(zt.getState().replaceBuffer(X,Le.id,ft.data??"",ft.sequence??0,Pc(ft)),ft.status==="running"&&zt.getState().setTabLifecycle(X,Le.id,"running",{expectedExecutionId:qe}),ft.status==="exited"&&(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe)));const st=ft.type==="data"?ft.data??"":"";st&&zt.getState().appendToBuffer(X,Le.id,st,ft.sequence,ft.replayData),ft.type==="exit"&&(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe))},onError:(ft,st)=>{!st||!z(X,Le.id,qe)||(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabSessionId(X,Le.id,null,{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe))}},X);A.current[ut]=dt.close}},[pe,ue,z,i,Ie]);const Ye=l.useCallback(async X=>{const Be=Y(X);if(!Be)throw new Error(r("projectActions.error.noActiveDirectory"));const Le=qn(Be,X.id);v(Be);const at=zt.getState(),qe=me(Be,X.id,at),ut=qe?.id??at.createTab(Be);T(Be,ut,X.name),k(Be,ut,X.icon||"play"),qe||B(Be,ut,{type:"project-action",actionId:X.id,executionId:null}),I(Be,ut);const ft=zt.getState().getDirectoryState(Be)?.tabs.find(st=>st.id===ut);return{executionDirectory:Be,key:Le,tabId:ut,sessionId:ft?.terminalSessionId??null,executionId:ft?.purpose.type==="project-action"?ft.purpose.executionId:null}},[v,Y,me,I,k,T,B,r]),nt=l.useCallback(async X=>{if(a.isVSCode||!s&&u)return;if(!Ee){He.error(r("projectActions.error.noActiveDirectoryForAction"));return}const Be=qn(Y(X),X.id),Le=re[Be];if(Le&&Le.status==="running"||ee.current.has(Be))return;ee.current.add(Be);let at=null;try{const qe=X.id===An?await(async()=>{const[se,Fe]=await Promise.all([BS({id:ce?.id??"",path:Ee}),ZP(Ee)]),ot=await HP(Ee,se.actions,Fe);if(!ot)throw new Error(r("contextPanel.preview.noDevServer"));return{id:An,name:r("projectActions.actions.autoDiscover"),command:ot.command,icon:"scan-2",autoOpenUrl:!0,openUrl:ot.previewUrlHint||""}})():X,ut=qe.autoOpenUrl===!0&&(qe.openUrl||"").trim().length>0,dt=!ut&&X.id!==An,ft=fe.current||Ee,{executionDirectory:st,key:Rt,tabId:Ke}=await Ye(qe),jt=py(qe.command);if(!jt)throw new Error(r("projectActions.error.failedToRunAction"));const Lt=qe.autoOpenUrl===!0&&f&&(qe.desktopOpenSshForward||"").trim().length>0,Mt=qe.autoOpenUrl&&qe.openUrl||"";let De=!1;const Tt=ym(Mt)?await oE(d,Mt,st).catch(()=>(De=!0,"")):Mt,At=qe.autoOpenUrl?dE(Tt):null,kt=qe.autoOpenUrl&&f?FS(qe.desktopOpenSshForward,p):null;if(i.listSessions){const se=me(st,qe.id);if(se?.purpose.type==="project-action"&&se.purpose.executionId===null){const Fe=await hy(i,st,{captureStartedActionMutationRevisions:H});Fe&&w(st,Fe.sessions,{startedActionMutationRevisions:Fe.startedActionMutationRevisions})}}const pt=me(st,qe.id);let Dt,Ve;if(pt?.lifecycle==="running"&&pt.terminalSessionId&&pt.purpose.type==="project-action"&&pt.purpose.executionId)Dt=pt.terminalSessionId,Ve=pt.purpose.executionId;else{const se=pt?.purpose.type==="project-action"?pt.purpose.executionId:null;se&&pe(st,qe.id,se);const Fe=j(st,Ke,qe.id);if(!Fe)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));at={directory:st,tabId:Ke,id:Fe},F(st,Ke,!0,{expectedExecutionId:Fe});const ot=await my({terminal:i,createOptions:{cwd:st,shell:g,loginShell:b,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:jt,isRunStillExpected:()=>z(st,Ke,Fe),purpose:{type:"project-action",actionId:qe.id,executionId:Fe}});if(!z(st,Ke,Fe)){ot.sessionId===Fe&&await i.close(ot.sessionId).catch(()=>{});return}Ve=ot.purpose?.type==="project-action"?ot.purpose.executionId:Fe,Dt=ot.sessionId,B(st,Ke,{type:"project-action",actionId:qe.id,executionId:Ve}),O(st,Ke,Dt,{expectedExecutionId:Ve}),F(st,Ke,!1,{expectedExecutionId:Ve})}dt&&ft&&Re(ft,st),N.current[Rt]={hostDirectory:ft,directory:st,tabId:Ke,actionId:qe.id,executionId:Ve,lastSeenChunkId:null,openedUrl:!!kt||!!At||ut,tail:"",openInPreview:qe.id===An,announced:[],offering:!1,proxiedPorts:[]};const rt=ue(st,qe.id,Ve);F(st,Ke,!0,{expectedExecutionId:Ve});const wt=i.connect(Dt,{onEvent:se=>{if(!z(st,Ke,Ve)||se.purpose?.type==="project-action"&&se.purpose.executionId!==Ve)return;se.type==="snapshot"&&(zt.getState().replaceBuffer(st,Ke,se.data??"",se.sequence??0,Pc(se)),zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),se.purpose?.type==="project-action"&&zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:se.purpose.actionId,executionId:se.purpose.executionId}),se.status==="running"&&zt.getState().setTabLifecycle(st,Ke,"running",{expectedExecutionId:Ve}),se.status==="exited"&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve)));const Fe=se.type==="data"?se.data??"":"";Fe&&zt.getState().appendToBuffer(st,Ke,Fe,se.sequence,se.replayData),se.type==="exit"&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve))},onError:(se,Fe)=>{z(st,Ke,Ve)&&(zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),Fe&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setTabSessionId(st,Ke,null,{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve)))}},st);if(!z(st,Ke,Ve)){wt.close();return}A.current[rt]?.(),A.current[rt]=wt.close,window.clearTimeout(q.current[rt]),delete q.current[rt],qe.id===An&&!At&&(M(se=>({...se,[rt]:!0})),q.current[rt]=window.setTimeout(()=>{delete q.current[rt];const se=N.current[Rt];!se||se.executionId!==Ve||se.openedUrl||se.offering||z(st,Ke,Ve)&&(M(Fe=>{if(!Fe[rt])return Fe;const ot={...Fe};return delete ot[rt],ot}),zt.getState().setActiveTab(st,Ke),Re(se.hostDirectory,st))},lE)),kt?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),ne(kt),He.success(r("projectActions.toast.openedForwardedUrl"))):At?(L(st,Ke,At,{locked:!0,autoOpened:!0,expectedExecutionId:Ve}),m(ft,At),He.success(r("projectActions.toast.openedActionUrl"))):De?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.openUrlTemplateUnresolved"))):ut?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.invalidCustomUrlFormat"))):Lt?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):L(st,Ke,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ve})}catch(qe){if(at&&z(at.directory,at.tabId,at.id)){const{directory:ut,tabId:dt,id:ft}=at;pe(ut,X.id,ft),P(ut,dt,"exited",{expectedExecutionId:ft}),B(ut,dt,{type:"project-action",actionId:X.id,executionId:null})}if(qe instanceof Error&&qe.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(qe instanceof Error&&(qe.message==="COMMAND_MODE_UNSUPPORTED"||qe.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){He.error(r("projectActions.error.failedToCreateTerminalSession"));return}He.error(qe instanceof Error?qe.message:r("projectActions.error.failedToRunAction"))}finally{ee.current.delete(Be)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,fe,p,Ye,d,s,u,f,Ee,b,g,ne,m,re,Re,a.isVSCode,Y,z,pe,ue,me,w,j,H,F,P,B,L,O,ce?.id,r,i]),oe=l.useCallback(async X=>{const Be=qn(Y(X),X.id),Le=re[Be];Le&&await gy({terminal:i,sessionId:Le.sessionId,isExecutionStillCurrent:()=>z(Le.directory,Le.tabId,Le.executionId),markStopping:()=>{P(Le.directory,Le.tabId,"stopping",{expectedExecutionId:Le.executionId})},restoreRunning:()=>{P(Le.directory,Le.tabId,"running",{expectedExecutionId:Le.executionId})},clearSession:()=>{O(Le.directory,Le.tabId,null,{expectedExecutionId:Le.executionId})},finalizeExit:()=>{P(Le.directory,Le.tabId,"exited",{expectedExecutionId:Le.executionId}),B(Le.directory,Le.tabId,{type:"project-action",actionId:Le.actionId,executionId:null}),pe(Le.directory,Le.actionId,Le.executionId)}})},[pe,Y,z,re,P,B,O,i]),tt=l.useCallback(async X=>{if(X.source==="shared"&&ce){const Be=_.current?.trust.trusted?_.current:await td(ce);if(_.current=Be,!await _S(ce,Be))return;_.current={...Be,trust:{...Be.trust,trusted:!0}}}await nt(X)},[nt,ce]),Ue=l.useCallback(X=>re[qn(Y(X),X.id)]??null,[Y,re]),gt=(Ne&&Ue(Ne)?Ne:null)??de.find(X=>Ue(X)!==null)??Ne??de[0]??null,bt=l.useCallback(X=>{const Be=Ue(X);if(Be?.status!=="stopping"){if(Be){oe(X);return}tt(X)}},[tt,Ue,oe]),Ce=l.useCallback(X=>{tt(X)},[tt]),_e=l.useCallback(X=>{oe(X)},[oe]),ze=l.useCallback(X=>{E(X.id),V&&aE(V,X.id)},[V]),Oe=l.useCallback(()=>{ce?.id&&(S(ce.id),x("projects"),y(!0))},[y,x,S,ce?.id]),it=!a.isVSCode&&(s||!u)&&!!ce&&!!Ee;return l.useMemo(()=>({available:it,actions:it?de:[],shown:it?gt:null,isLoading:D,observe:ge,runOf:Ue,select:ze,run:Ce,stop:_e,toggle:bt,openSettings:Oe}),[it,de,D,ge,Oe,Ce,Ue,ze,gt,_e,bt])},fE=t=>{const e=Ze.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=uE(r);let i;return e[3]!==s||e[4]!==o?(i=n.jsx(LS.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=i):i=e[5],i},pE=t=>{const e=Ze.c(4),{children:s}=t,r=$S(),o=Yr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==s||e[1]!==a||e[2]!==i?(d=n.jsx(fE,{projectRef:i,directory:a,children:s}),e[0]=s,e[1]=a,e[2]=i,e[3]=d):d=e[3],d};function Ni(t,e,s){const[r,o]=l.useState(null),i=l.useRef(s);return i.current=s,l.useEffect(()=>{if(!t||r)return;let a=!1;return zS(e).then(d=>{a||o(()=>d)},d=>{console.error("[on-demand] failed to load component",d),a||i.current()}),()=>{a=!0}},[r,e,t]),r}function hE(t){const e=[],s=(r,o)=>{const i=yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const mE=new Map,gE=t=>{const e=Ze.c(23),{isVSCode:s}=t,r=Jr(),o=ns(bE),i=Ps(yE),a=mt(xE);let d;e[0]!==s?(d=O=>s?mE:O.availableWorktreesByProject,e[0]=s,e[1]=d):d=e[1];const c=mt(d),u=!s;let f;e[2]!==c||e[3]!==o||e[4]!==u?(f=bm(o,c,{includeWorktrees:u}),e[2]=c,e[3]=o,e[4]=u,e[5]=f):f=e[5];const p=f,h=Os(SE),g=Os(wE),b=Os(vE),x=`session-list-sync:${l.useId()}`;let y,S;e[6]!==x||e[7]!==r||e[8]!==i||e[9]!==a?(y=()=>(r.setBootstrapDemand(x,hE({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),S=[x,r,i,a],e[6]=x,e[7]=r,e[8]=i,e[9]=a,e[10]=y,e[11]=S):(y=e[10],S=e[11]),l.useEffect(y,S);const m=l.useRef(null);let v,w;e[12]!==s||e[13]!==p?(v=()=>{const O=new Set(p),B=m.current;m.current=O;const j=B?[...O].filter(P=>!B.has(P)):s?[...O]:[];j.length&&Tl(j,_a())},w=[s,p],e[12]=s,e[13]=p,e[14]=v,e[15]=w):(v=e[14],w=e[15]),l.useEffect(v,w);let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[16]=T):T=e[16],l.useEffect(jE,T);let k;e[17]!==g||e[18]!==h?(k=[...h,...g],e[17]=g,e[18]=h,e[19]=k):k=e[19];const I=k;let F;e[20]!==I||e[21]!==b?(F={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:I},e[20]=I,e[21]=b,e[22]=F):F=e[22],Sy(F)};function bE(t){return t.projects}function yE(t){return t.currentDirectory}function xE(t){return t.currentSessionDirectory}function SE(t){return t.activeSessions}function wE(t){return t.archivedSessions}function vE(t){return t.status==="ready"}function jE(){let t=null,e=!1;const s=new Set,r=En(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),Tp(_a());return}const i=[...s];s.clear(),i.length&&Tl(i,_a())},500)});return()=>{t&&clearTimeout(t),r()}}const kE=()=>as(()=>import("./SettingsWindow-Bugr9Hmx.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,83,146,84,147,148,132,133,134,135,141,119,120,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103,149,150,140,128,151,152])).then(t=>t.SettingsWindow),CE=()=>as(()=>import("./CommandPalette-DWX1HV4m.js"),__vite__mapDeps([153,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,151,122,123])).then(t=>t.CommandPalette),IE=()=>as(()=>import("./HelpDialog-Bw836_tH.js"),__vite__mapDeps([154,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])).then(t=>t.HelpDialog),PE=()=>as(()=>import("./ProjectActionsDialog-BS20dYCJ.js"),__vite__mapDeps([155,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])).then(t=>t.ProjectActionsDialog),EE=()=>as(()=>import("./OpenCodeStatusDialog-N9JgIC1p.js"),__vite__mapDeps([156,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])).then(t=>t.OpenCodeStatusDialog),TE=()=>as(()=>import("./RunOverview-DtxjzGnX.js"),__vite__mapDeps([157,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])).then(t=>t.RunOverview),DE=()=>as(()=>import("./ScheduledTasksDialog-HcypGtky.js"),__vite__mapDeps([158,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,143,159,160])).then(t=>t.ScheduledTasksDialog),RE=()=>as(()=>import("./ArchiveView-CEGi3y1V.js"),__vite__mapDeps([161,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])).then(t=>t.ArchiveView),NE=()=>as(()=>import("./IntegrationsCatalogView-BtdMeTHf.js"),__vite__mapDeps([162,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,147])).then(t=>t.IntegrationsCatalogView),ME=()=>as(()=>import("./UsageStatsView-DFVydqMY.js"),__vite__mapDeps([163,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])).then(t=>t.UsageStatsView),AE=()=>as(()=>import("./SourceBoardView-BD5rmib8.js"),__vite__mapDeps([164,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])).then(t=>t.SourceBoardView),OE=()=>as(()=>import("./WorktreesView-FH0uzPQG.js"),__vite__mapDeps([165,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])).then(t=>t.WorktreesView),BE=()=>as(()=>import("./SpacesView-Bcbb9aXY.js"),__vite__mapDeps([166,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,152,84])).then(t=>t.SpacesView),FE=()=>as(()=>import("./SpaceAccessDialog-BYhp5gfB.js"),__vite__mapDeps([167,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,168])).then(t=>t.SpaceAccessDialog),_E=()=>as(()=>import("./SpaceApplyDialog-CC0axZal.js"),__vite__mapDeps([169,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,170])).then(t=>t.SpaceApplyDialog),LE=()=>as(()=>import("./SpaceSetupOutput-BqurG7V4.js"),__vite__mapDeps([171,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,168])).then(t=>t.SpaceSetupOutputDialog),xn=()=>le.getState().closeMainSurfaces(),Ts=t=>{const e=Ze.c(2),{needed:s,load:r,onFailure:o}=t,i=Ni(s,r,o);let a;return e[0]!==i?(a=i?n.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},vm=l.memo(t=>{const e=Ze.c(11),{isMobile:s}=t,r=le(zE),o=!r&&!s,i=ui();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const d=Fv(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Rv,{}),e[3]=c):c=e[3];const u=r||d.state!==!1;let f;e[4]!==u?(f=n.jsx($P,{isVisible:u}),e[4]=u,e[5]=f):f=e[5];let p;return e[6]!==s||e[7]!==r||e[8]!==d||e[9]!==f?(p=n.jsx(Dv,{isOpen:r,isMobile:s,className:"border-border",topBar:c,peek:d,children:f}),e[6]=s,e[7]=r,e[8]=d,e[9]=f,e[10]=p):p=e[10],p});vm.displayName="LeftSidebar";const $E=()=>{const t=Ze.c(107);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],gE(e),wy();const s=le(KE),r=le(WE),o=le(HE),i=le(UE);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=Ni(o,kE,a),c=le(VE),u=le(GE),f=le(qE),p=le(YE),h=le(ZE),g=le(QE),b=le(XE),x=le(JE),y=le(eT),S=le(tT),m=le(sT),v=le(nT),w=Gs(rT),T=Gs(oT),k=Gs(iT),I=le(aT),F=up();let O;if(t[3]!==F||t[4]!==I){let Ue;t[6]!==I?(Ue=gt=>gt.id===I,t[6]=I,t[7]=Ue):Ue=t[7],O=F.find(Ue),t[3]=F,t[4]=I,t[5]=O}else O=t[5];const B=O;let j,P;t[8]!==B||t[9]!==I?(j=()=>{I&&!B&&le.getState().setOpenGuestPage(null)},P=[I,B],t[8]=B,t[9]=I,t[10]=j,t[11]=P):(j=t[10],P=t[11]),l.useEffect(j,P);let L;t[12]===Symbol.for("react.memo_cache_sentinel")?(L=[],t[12]=L):L=t[12],l.useEffect(cT,L);let z;t[13]===Symbol.for("react.memo_cache_sentinel")?(z=[],t[13]=z):z=t[13],l.useEffect(dT,z);const H=u||f||p||h||g||!!b||x||c||!!B;let R,G;t[14]!==H?(R=()=>{Dp(H)},G=[H],t[14]=H,t[15]=R,t[16]=G):(R=t[15],G=t[16]),l.useLayoutEffect(R,G);let _;t[17]===Symbol.for("react.memo_cache_sentinel")?(_=[],t[17]=_):_=t[17],l.useEffect(fT,_);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=[],t[18]=$):$=t[18],l.useEffect(hT,$);const{isMobile:E}=Rn();vy();let D,C;t[19]!==E||t[20]!==r?(D=()=>{le.getState().isMobile!==E&&r(E)},C=[E,r],t[19]=E,t[20]=r,t[21]=D,t[22]=C):(D=t[21],C=t[22]),l.useEffect(D,C);let N;t[23]!==y?(N=n.jsx(Ts,{needed:y,load:CE,onFailure:mT}),t[23]=y,t[24]=N):N=t[24];let A;t[25]!==S?(A=n.jsx(Ts,{needed:S,load:IE,onFailure:gT}),t[25]=S,t[26]=A):A=t[26];let q;t[27]!==m?(q=n.jsx(Ts,{needed:m,load:PE,onFailure:bT}),t[27]=m,t[28]=q):q=t[28];let ee;t[29]!==v?(ee=n.jsx(Ts,{needed:v,load:EE,onFailure:yT}),t[29]=v,t[30]=ee):ee=t[30];let Q,he;t[31]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(ky,{}),he=n.jsx(zP,{}),t[31]=Q,t[32]=he):(Q=t[31],he=t[32]);let M;t[33]!==w||t[34]!==T||t[35]!==k||t[36]!==s?(M=s?n.jsxs(n.Fragment,{children:[n.jsx(Ts,{needed:w,load:FE,onFailure:xT}),n.jsx(Cy,{}),n.jsx(Ts,{needed:T,load:_E,onFailure:ST}),n.jsx(Iy,{}),n.jsx(Ts,{needed:k,load:LE,onFailure:wT})]}):null,t[33]=w,t[34]=T,t[35]=k,t[36]=s,t[37]=M):M=t[37];let V;t[38]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(_v,{}),t[38]=V):V=t[38];let ie;t[39]!==E?(ie=n.jsx(vm,{isMobile:E}),t[39]=E,t[40]=ie):ie=t[40];let ce;t[41]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx(Tv,{}),t[41]=ce):ce=t[41];let ne;t[42]===Symbol.for("react.memo_cache_sentinel")?(ne=n.jsx(ua,{zone:"left"}),t[42]=ne):ne=t[42];const je=H&&"invisible";let Ee;t[43]!==je?(Ee=Pe("absolute inset-0",je),t[43]=je,t[44]=Ee):Ee=t[44];const we=!o&&!H;let Me;t[45]!==we?(Me=n.jsx(Cs,{children:n.jsx(xf,{active:we})}),t[45]=we,t[46]=Me):Me=t[46];let fe;t[47]!==Ee||t[48]!==Me?(fe=n.jsx("div",{className:Ee,children:Me}),t[47]=Ee,t[48]=Me,t[49]=fe):fe=t[49];let be;t[50]!==c?(be=n.jsx(Cs,{children:n.jsx(Ts,{needed:c,load:TE,onFailure:xn})}),t[50]=c,t[51]=be):be=t[51];let ke;t[52]!==u?(ke=n.jsx(Cs,{children:n.jsx(Ts,{needed:u,load:DE,onFailure:xn})}),t[52]=u,t[53]=ke):ke=t[53];let Ie;t[54]!==f?(Ie=n.jsx(Cs,{children:n.jsx(Ts,{needed:f,load:RE,onFailure:xn})}),t[54]=f,t[55]=Ie):Ie=t[55];let Te;t[56]!==p?(Te=n.jsx(Cs,{children:n.jsx(Ts,{needed:p,load:NE,onFailure:xn})}),t[56]=p,t[57]=Te):Te=t[57];let Y;t[58]!==h?(Y=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Cs,{children:n.jsx(Ts,{needed:!0,load:ME,onFailure:xn})})}),t[58]=h,t[59]=Y):Y=t[59];let ue;t[60]!==g?(ue=n.jsx(Ts,{needed:g,load:AE,onFailure:xn}),t[60]=g,t[61]=ue):ue=t[61];const me=!!b;let re;t[62]!==me?(re=n.jsx(Cs,{children:n.jsx(Ts,{needed:me,load:OE,onFailure:xn})}),t[62]=me,t[63]=re):re=t[63];let pe;t[64]!==x?(pe=x?n.jsx(Cs,{children:n.jsx(Ts,{needed:!0,load:BE,onFailure:xn})}):null,t[64]=x,t[65]=pe):pe=t[65];let U;t[66]!==B?(U=B&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Cs,{children:n.jsx(KS,{mode:`plugin:${B.id}`,surface:"page",item:null,onDismiss:vT})})}),t[66]=B,t[67]=U):U=t[67];let ae;t[68]!==fe||t[69]!==be||t[70]!==ke||t[71]!==Ie||t[72]!==Te||t[73]!==Y||t[74]!==ue||t[75]!==re||t[76]!==pe||t[77]!==U?(ae=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[fe,be,ke,Ie,Te,Y,ue,re,pe,U]}),t[68]=fe,t[69]=be,t[70]=ke,t[71]=Ie,t[72]=Te,t[73]=Y,t[74]=ue,t[75]=re,t[76]=pe,t[77]=U,t[78]=ae):ae=t[78];let Re;t[79]===Symbol.for("react.memo_cache_sentinel")?(Re=n.jsx(ua,{zone:"bottom"}),t[79]=Re):Re=t[79];let W;t[80]!==ae?(W=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ae,Re]}),t[80]=ae,t[81]=W):W=t[81];let ye,de,Ne,Je;t[82]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx(ua,{zone:"right"}),de=n.jsx(cC,{}),Ne=n.jsx(fC,{}),Je=n.jsx(gC,{}),t[82]=ye,t[83]=de,t[84]=Ne,t[85]=Je):(ye=t[82],de=t[83],Ne=t[84],Je=t[85]);let Ge;t[86]!==W?(Ge=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[ne,n.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:[W,ye,de,Ne,Je]})]})}),t[86]=W,t[87]=Ge):Ge=t[87];let ge;t[88]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Cs,{children:n.jsx(OC,{})})}),t[88]=ge):ge=t[88];let Ae;t[89]===Symbol.for("react.memo_cache_sentinel")?(Ae=n.jsx(Cs,{children:n.jsx(Cw,{})}),t[89]=Ae):Ae=t[89];let Ye;t[90]!==Ge?(Ye=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ce,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ge,ge,Ae]})]}),t[90]=Ge,t[91]=Ye):Ye=t[91];let nt;t[92]!==ie||t[93]!==Ye?(nt=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[ie,Ye]}),t[92]=ie,t[93]=Ye,t[94]=nt):nt=t[94];let oe;t[95]!==d||t[96]!==o||t[97]!==i?(oe=d?n.jsx(d,{open:o,onOpenChange:i}):null,t[95]=d,t[96]=o,t[97]=i,t[98]=oe):oe=t[98];let tt;return t[99]!==N||t[100]!==A||t[101]!==q||t[102]!==ee||t[103]!==M||t[104]!==nt||t[105]!==oe?(tt=n.jsx(WS.Provider,{value:!0,children:n.jsx(jy,{children:n.jsx(pE,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[N,A,q,ee,Q,he,M,V,nt,oe]})})})}),t[99]=N,t[100]=A,t[101]=q,t[102]=ee,t[103]=M,t[104]=nt,t[105]=oe,t[106]=tt):tt=t[106],tt};function zE(t){return t.isSidebarOpen}function KE(t){return t.isolatedSpacesEnabled}function WE(t){return t.setIsMobile}function HE(t){return t.isSettingsDialogOpen}function UE(t){return t.setSettingsDialogOpen}function VE(t){return t.runOverviewKey!==null}function GE(t){return t.isScheduledTasksDialogOpen}function qE(t){return t.isArchivePageOpen}function YE(t){return t.isIntegrationsCatalogOpen}function ZE(t){return t.isUsageStatsPageOpen}function QE(t){return t.isSourceBoardOpen}function XE(t){return t.worktreesPageProjectId}function JE(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function eT(t){return t.isCommandPaletteOpen}function tT(t){return t.isHelpDialogOpen}function sT(t){return t.isProjectActionsDialogOpen}function nT(t){return t.isOpenCodeStatusDialogOpen}function rT(t){return t.accessDialog!==null}function oT(t){return t.applyDialog!==null}function iT(t){return t.setupOutputDialog!==null}function aT(t){return t.openGuestPageId}function lT(){return le.getState().setOpenGuestPage(null)}function cT(){return ri(lT)}function dT(){return kw()}function uT(){return Dp(!1)}function fT(){return uT}function pT(){return le.getState().closeMainSurfaces()}function hT(){const t=pT,e=mt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function mT(){return le.getState().setCommandPaletteOpen(!1)}function gT(){return le.getState().setHelpDialogOpen(!1)}function bT(){return le.getState().setProjectActionsDialogOpen(!1)}function yT(){return le.getState().setOpenCodeStatusDialogOpen(!1)}function xT(){return Gs.getState().closeAccessDialog()}function ST(){return Gs.getState().closeApplyDialog()}function wT(){return Gs.getState().closeSetupOutputDialog()}function vT(){return le.getState().setOpenGuestPage(null)}const jm=12,jT=[{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"}],kT=t=>{const e=Ze.c(18),{isActive:s,burstKey:r,className:o,durationMs:i,bursts:a,onComplete:d}=t,c=r===void 0?0:r,u=i===void 0?900:i,f=a===void 0?jT:a,p=us.useRef(!1);let h,g;e[0]!==s||e[1]!==d?(h=()=>{!s&&p.current&&d?.(),s&&(p.current=!0)},g=[s,d],e[0]=s,e[1]=d,e[2]=h,e[3]=g):(h=e[2],g=e[3]),us.useEffect(h,g);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:jm},CT),e[4]=b):b=e[4];const x=b;if(!s)return null;let y;e[5]!==o?(y=Pe("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=y):y=e[6];let S;if(e[7]!==c||e[8]!==f||e[9]!==u){let v;e[11]!==c||e[12]!==u?(v=w=>{const T={"--burst-delay":`${w.delay}ms`,"--burst-x":`${w.x}%`,"--burst-y":`${w.y}%`,"--firework-color":`var(${w.colorVar})`,"--firework-duration":`${u}ms`};return n.jsx("div",{className:"firework-burst",style:T,children:x.map((k,I)=>{const F=k.x*w.radius,O=k.y*w.radius,B={"--translate-x":`${F}px`,"--translate-y":`${O}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:B},`${w.id}-${I}-${c}`)})},`${w.id}-${c}`)},e[11]=c,e[12]=u,e[13]=v):v=e[13],S=f.map(v),e[7]=c,e[8]=f,e[9]=u,e[10]=S}else S=e[10];let m;return e[14]!==c||e[15]!==y||e[16]!==S?(m=n.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":c,children:S}),e[14]=c,e[15]=y,e[16]=S,e[17]=m):m=e[17],m};function CT(t,e){const s=Math.PI*2*e/jm;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const IT=t=>{const e=Ze.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[a,d]=us.useState(i),c=us.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c.current&&(window.clearTimeout(c.current),c.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),d(PT)},e[4]=p):p=e[4];const h=p;let g;e[5]!==o?(g=()=>{f(),d(ET),c.current=window.setTimeout(()=>{d(TT),c.current=null},o)},e[5]=o,e[6]=g):g=e[6];const b=g;let x,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>f(),y=[f],e[7]=x,e[8]=y):(x=e[7],y=e[8]),us.useEffect(x,y);let S;return e[9]!==a.cycle||e[10]!==a.isActive||e[11]!==b?(S={isActive:a.isActive,burstKey:a.cycle,triggerFireworks:b,dismissFireworks:h},e[9]=a.cycle,e[10]=a.isActive,e[11]=b,e[12]=S):S=e[12],S};function PT(t){return t.isActive?{...t,isActive:!1}:t}function ET(t){return{isActive:!0,cycle:t.cycle+1}}function TT(t){return t.isActive?{...t,isActive:!1}:t}const km=l.createContext(void 0),DT=t=>{const e=Ze.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:a}=IT();let d;e[0]!==a||e[1]!==i?(d={triggerFireworks:i,dismissFireworks:a},e[0]=a,e[1]=i,e[2]=d):d=e[2];const c=d;let u;e[3]!==o||e[4]!==r?(u=n.jsx(kT,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==c?(f=n.jsxs(km.Provider,{value:c,children:[s,u]}),e[6]=s,e[7]=u,e[8]=c,e[9]=f):f=e[9],f},bR=()=>{const t=l.useContext(km);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},hl="openchamber_requests_in_flight",Cm=1e3,RT=300*1e3,si=Math.ceil(RT/Cm),NT=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(hl)==="1"}catch{return!1}},Im=()=>({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 MT=1;const AT=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},OT=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Pm=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},cr=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},BT=()=>{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 s=async(r,o)=>{const i=MT++;AT(i,Date.now());try{return await e(r,o)}finally{OT(i)}};window.fetch=s},Mu=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Pr=t=>{t.length>si&&t.splice(0,t.length-si)},FT=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Pm(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(cr(e,50)),t.p90Samples.push(cr(e,90)),t.p99Samples.push(cr(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Pr(t.samples),Pr(t.p50Samples),Pr(t.p90Samples),Pr(t.p99Samples),Pr(t.maxSamples),t.lastSampleAt=Date.now()},_T=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(FT,Cm))},Au=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ou=t=>{if(!(typeof window>"u"))try{if(t){Au(),Mu(),window.localStorage.setItem(hl,"1"),window.__openchamberRequestsInFlight__=Im(),BT(),_T();return}window.localStorage.removeItem(hl),Au(),Mu(),delete window.__openchamberRequestsInFlight__}catch{}},yR=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Im();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},xR=()=>{if(typeof window>"u")return Bu();const t=window.__openchamberRequestsInFlight__;if(!NT()||!t)return Bu();const e=Pm(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:cr(e,50),ageP90:cr(e,90),ageP99:cr(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:si}},Bu=()=>({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:si}),LT=()=>{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()??"":""},$T=async()=>{const t=LT()||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")},Fu="openchamber:menu-action",_u="openchamber:check-for-updates",zT=t=>{const e=Ze.c(21),{t:s}=Et(),r=mt(KT),o=le(WT),i=le(HT),a=le(UT),d=le(VT),c=le(GT),u=le(qT),f=le(YT),p=Rr(ZT),{setThemeMode:h}=br(),g=l.useRef(!1);let b;e[0]!==p?(b=()=>{g.current||(g.current=!0,p().then(QT).finally(()=>{g.current=!1}))},e[0]=p,e[1]=b):b=e[1];const x=b,y=XT;let S;e[2]!==c?(S=F=>{const O=HS();if(O.length===0)return;const B=mt.getState().currentSessionId,j=O.findIndex(z=>z.id===B);let P=F>0?0:O.length-1;j>=0&&(P=(j+F+O.length)%O.length);const L=O[P];L&&(c(!1),mt.getState().setCurrentSession(L.id))},e[2]=c,e[3]=S):S=e[3];const m=S,v=JT;let w;e[4]!==m||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==u||e[11]!==h||e[12]!==s||e[13]!==o||e[14]!==a||e[15]!==d?(w=F=>{e:switch(F){case"about":{f(!0);break e}case"settings":{u(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const O=mt.getState(),B=Ps.getState().currentDirectory;r(O.currentSessionId&&B?{directoryOverride:B}:void 0);break e}case"new-worktree-session":{c(!1),GS();break e}case"change-workspace":{y();break e}case"toggle-right-sidebar":{const O=Ps.getState().currentDirectory;if(!O)break e;const B=le.getState(),j=Ds(O),P=B.contextPanelByDirectory[j],L=P?Jg(P.tabs,B.contextSurfaceZones,"right",oi(P,"right").activeTabId):null;P?.isOpen?B.closeContextPanel(j):L?B.setActiveContextPanelTab(j,L):B.openContextSurface(j,"git");break e}case"open-right-sidebar-git":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"git");break e}case"open-right-sidebar-files":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"file");break e}case"toggle-terminal":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"terminal");break e}case"toggle-terminal-expanded":{const O=Ps.getState().currentDirectory;if(!O)break e;const B=Ds(O),j=le.getState(),P=j.contextPanelByDirectory[B];bl(P,j.contextSurfaceZones).has("terminal")||j.openContextSurface(B,"terminal"),j.toggleContextPanelExpanded(B,Ao(j.contextSurfaceZones,"terminal"));break e}case"copy":{const O=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(O)||$T();break e}case"theme-light":{h("light");break e}case"theme-dark":{h("dark");break e}case"theme-system":{h("system");break e}case"add-selection-to-chat":{VS();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{nd(-1);break e}case"go-forward":{nd(1);break e}case"previous-session":{m(-1);break e}case"next-session":{m(1);break e}case"previous-project":{v(-1);break e}case"next-project":{v(1);break e}case"help-dialog":{a();break e}case"download-logs":US().catch(()=>{He.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=m,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=u,e[11]=h,e[12]=s,e[13]=o,e[14]=a,e[15]=d,e[16]=w):w=e[16];const T=w;let k,I;e[17]!==T||e[18]!==x?(k=()=>{const F=B=>{const j=B.detail;j&&T(j)},O=()=>{x()};return window.addEventListener(Fu,F),window.addEventListener(_u,O),()=>{window.removeEventListener(Fu,F),window.removeEventListener(_u,O)}},I=[T,x],e[17]=T,e[18]=x,e[19]=k,e[20]=I):(k=e[19],I=e[20]),l.useEffect(k,I)};function KT(t){return t.openNewSessionDraft}function WT(t){return t.toggleCommandPalette}function HT(t){return t.setCommandPaletteOpen}function UT(t){return t.toggleHelpDialog}function VT(t){return t.toggleSidebar}function GT(t){return t.setSessionSwitcherOpen}function qT(t){return t.setSettingsDialogOpen}function YT(t){return t.setAboutDialogOpen}function ZT(t){return t.checkForUpdates}function QT(){const{available:t,error:e}=Rr.getState();if(e){He.error("Failed to check for updates",{description:e});return}t||He.success("You are on the latest version")}function XT(){Tn.requestDirectoryDialog()}function JT(t){const{activeProjectId:e,projects:s,setActiveProject:r}=ns.getState();if(s.length===0)return;const o=s.findIndex(d=>d.id===e);let i=t>0?0:s.length-1;o>=0&&(i=(o+t+s.length)%s.length);const a=s[i];a&&r(a.id)}const eD="openchamber:tray-action",tD=5e3,sD=500,nD=20,Lu=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},$u=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Em=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Tm=t=>t.title.trim()||"Question",rD=new Set,oD=(t,e)=>Kl(t,e,rD,Ap.getState().rankById),iD=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},aD=(t,e,s,r,o)=>{if(!t)return"";const i=jf(s,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||iD(t),c=$a(t);let u=c&&o.get(c)||"";if(!u){for(const[f,p]of Cn.getState().directories)if($a(f)===c){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=c?Lr(f,c):void 0;if(p?.branch){u=p.branch;break}}return u?`${d} · ${u}`:d},lD=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=Jn.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(a=>[a.providerId,a])),i=[];for(const a of ZS){if(!e.includes(a.id))continue;const d=o.get(a.id);if(!d||d.configured!==!0)continue;const c=[];for(const[f,p]of Object.entries(d.usage?.windows??{})){const h=r==="remaining"?p.remainingPercent:p.usedPercent;c.push({label:XS(f),value:QS(p.valueLabel,h)})}const u=!d.ok&&d.error?d.error:c.length===0?"No rate limits reported":null;i.push({provider:a.name,rows:c,status:u})}return{mode:r,groups:i}},cD=async()=>{try{if(li())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=eb();if(e&&Ec(e,t))return"Local OpenChamber";const r=(await ci()).hosts.find(o=>e?Ec(e,of(o)):!1);return r?.label?.trim()?ef(r.label.trim()):"Instance"}catch{return""}},dD=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=La()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set($a(i)??i,d.vcs.branch);for(const c of d.session)c?.id&&r.set(c.id,c.title);for(const[c,u]of Object.entries(d.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",h=t.get(c);(!h||h==="idle")&&t.set(c,p)}for(const[c,u]of Object.entries(d.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;s.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:Em(f),directory:i,canSave:Op(f.save)})}for(const[c,u]of Object.entries(d.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;s.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:Tm(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},uD=(t,e)=>{const s=Rp.getState().index.session,r=Os.getState().activeSessions,o=YS(r),i=m=>o.descendantsOf(m,"active").map(v=>v.id),a=le.getState();let d=0;if(a.dockBadgeEnabled)for(const m of r){if(!m?.id||m.parentID)continue;let v=s.unseenCount[m.id]??0;v===0&&a.notifyOnSubtasks&&(v=i(m.id).reduce((w,T)=>w+(s.unseenCount[T]??0),0)),v>0&&(d+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:d};const c=dD(),u=new Map(c.titleById);for(const m of r)m?.id&&m.title&&u.set(m.id,m.title);const f=Np.getState().statusById,p=m=>{const v=c.statusById.get(m);return v&&v!=="idle"?v:f.get(m)?.status.type??v??"idle"},h=m=>{const v=m.map(w=>p(w));return v.includes("busy")?"busy":v.includes("retry")?"retry":"idle"},g=ns.getState().projects,b=mt.getState().availableWorktreesByProject,x=r.filter(m=>m?.id&&!m.parentID).slice().sort(oD).slice(0,nD).map(m=>{const v=[m.id,...i(m.id)],w=ur(m)??"";return{id:m.id,title:m.title||"Untitled session",status:h(v),branch:w?c.branchByDirectory.get(w)??"":"",unseen:v.reduce((T,k)=>T+(s.unseenCount[k]??0),0),hasError:v.some(T=>s.unseenHasError[T]??!1),directory:w,subtitle:aD(w,m,g,b,c.branchByDirectory)}}),y=c.approvals.map(m=>({...m,sessionTitle:u.get(m.sessionId)||""})),S=new Set(y.map(m=>m.id));for(const[m,v]of Mp.getState().bySession){const w=u.get(m)||"";for(const T of v.permissions)S.has(T.id)||(S.add(T.id),y.push({kind:"permission",id:T.id,sessionId:m,sessionTitle:w,label:Em(T),directory:v.directory,canSave:Op(T.save)}));for(const T of[...v.forms,...v.pages])S.has(T.id)||(S.add(T.id),y.push({kind:"form",id:T.id,sessionId:m,sessionTitle:w,label:Tm(T),directory:v.directory,canSave:!1}))}return{sessions:x,approvals:y,instanceName:t,usage:lD(),dockBadgeCount:d}},fD=()=>{l.useEffect(()=>{if(!Lu()||!Do())return;const t=$u();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const k=uD(o,t),I=JSON.stringify(k);I!==s&&(s=I,vn("desktop_tray_update",k))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},sD))},d=Rp.subscribe(()=>a()),c=Os.subscribe(()=>a()),u=le.subscribe((k,I)=>{(k.dockBadgeEnabled!==I.dockBadgeEnabled||k.notifyOnSubtasks!==I.notifyOnSubtasks)&&a()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),c(),u()};if(!t)return i(),f;cD().then(k=>{e||(o=k,i())});const p=new Map,h=()=>{if(e)return;let k;try{k=La()}catch{return}const I=new Set;for(const[F,O]of k.children.entries())I.add(F),p.has(F)||p.set(F,O.subscribe(()=>a()));for(const[F,O]of p)I.has(F)||(O(),p.delete(F))};let g=null;try{g=La().subscribeRegistry(()=>{h(),a()})}catch{}h();const b=ns.subscribe(()=>a()),x=mt.subscribe(()=>a()),y=Cn.subscribe(()=>a()),S=Np.subscribe(()=>a()),m=Mp.subscribe(()=>a()),v=Ap.subscribe(()=>a()),w=Jn.subscribe(()=>a());Jn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:k,results:I}=Jn.getState();k.length>0&&k.some(O=>!I.some(B=>B.providerId===O))&&Jn.getState().fetchQuotas(k)});const T=window.setInterval(()=>{h(),i()},tD);return i(),()=>{f(),window.clearInterval(T),b(),x(),y(),S(),m(),v(),w(),g?.();for(const k of p.values())k();p.clear()}},[]),l.useEffect(()=>{if(!Lu()||!$u()||!Do())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&qS(o.sessionId,o.id,o.response).catch(()=>{He.error("Failed to respond to permission request")})};let r=null;return e(eD,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},pD=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,hD=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,mD=t=>{t.kind!=="plugin"||!t.title||He.info(t.title,{id:hD(t.kind,t.title,t.body,t.tag),description:t.body})},gD=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,bD=t=>{const e=Ze.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(hn()||!af()||!globalThis.window))return En(yD)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function yD(t){if(t.type!=="notification")return;const e=le.getState();if(!e.nativeNotificationsEnabled)return;const s=pD();if(gD(t.payload,s)){mD(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;rf()?.notifications?.notifyAgentCompletion(t.payload)}const xD=()=>{const t=Ze.c(4),{t:e}=Et(),s=le(SD);let r,o;t[0]!==s||t[1]!==e?(r=()=>En(i=>{i.type==="browser-provider-reset"&&(s("builtin"),He.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function SD(t){return t.setBrowserProvider}const zu="relay-limit-reached",wD=()=>{const t=Ze.c(3),{t:e}=Et();let s,r;t[0]!==e?(s=()=>{const o=()=>{He.error(e("relayConnection.limitReached.title"),{id:zu,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:vD}})};return Tc(lf()?.getStatus())&&o(),tb(a=>{Tc(a)?o():(a.state==="connected"||a.state==="idle")&&He.dismiss(zu)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),l.useEffect(s,r)};function vD(){return lf()?.retry()}const Ku=()=>{sb()||(Py(),JS(Ey.map(t=>t.id)))},jD=(t,e)=>{const s=Ze.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Ku,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Ku,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],l.useEffect(r,o)},Wu="pwa-install-toast-shown",Hu="pwa-install-toast-dismissed",kD=()=>{const t=Ze.c(6),{browserTab:e}=Ty(),{t:s}=Et(),r=l.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,d;t[3]!==e?(a=()=>{if(typeof window>"u"||!af()||!e)return;let c=null,u=null;const f=()=>{u!==null&&(He.dismiss(u),u=null)},p=async()=>{if(!c)return;const b=c;c=null,f(),await b.prompt();const{outcome:x}=await b.userChoice;x==="accepted"&&He.success(r.current("pwa.installPrompt.started"))},h=b=>{const x=b;if(typeof x.prompt!="function")return;x.preventDefault(),c=x;const y=Oo(),S=nb();Dy({dismissed:y.getItem(Hu),sessionShown:S.getItem(Wu),hasActiveToast:u!==null})&&(S.setItem(Wu,"true"),u=He.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Oo().setItem(Hu,"true"),f()}}}))},g=()=>{c=null,f(),He.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",h),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",h),window.removeEventListener("appinstalled",g)}},d=[e],t[3]=e,t[4]=a,t[5]=d):(a=t[4],d=t[5]),l.useEffect(a,d)},Dm=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,CD=()=>{Vs.setState({byRoot:{},runtimeSnapshots:{}});const t=le.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Qu)t.closeContextZone(e,s)},ID=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Rm=async(t,e)=>{const s=(await ci()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await ab(s.id,e);return}const r=lb(of(s));if(!r)throw new Error("host-not-found");cb({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:db(s),sshForwarded:s.sshForwarded===!0})},PD=async t=>{const e=await ci(),s=await ob(t,e.hosts);await ib({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Rm(s.hostId,{reconnectActive:!0})},ED=async t=>{const e=await rb();for(const s of e)try{s.type==="pairing"?await PD(s.link):await Rm(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(ID(o))}},ml="project-config-invalid",TD=()=>{const t=Ze.c(9),{t:e}=Et(),s=ps(DD);let r;t[0]!==s?(r=h=>h.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ps(r),[i,a]=us.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const h=ps.getState(),g=h.activeDirectoryKey;a(!0),Promise.all([h.loadProviders({directory:g,source:"projectConfigError:retry"}),h.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=d):d=t[2];const c=d;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){He.dismiss(ml);return}He.error(e("projectConfigError.toast.title"),{id:ml,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:h=>{h.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),us.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],us.useEffect(ND,p),null};function DD(t){return t.activeDirectoryKey}function RD(){He.dismiss(ml)}function ND(){return RD}const MD="\x1B",AD=new RegExp(`${MD}\\[[0-9;?]*[ -/]*[@-~]`,"g"),yo=zs().transform(t=>t.replace(AD,"").trim()).nullish(),OD=Ko({isOpenCodeReady:Ha().optional(),openCodeRunning:Ha().optional(),lastOpenCodeError:yo,opencodeBinaryResolved:yo,lastOpenCodeLaunchDiagnostics:Ko({sourceBinary:yo,binary:yo}).nullish()}),BD=async(t,e=Ys)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=OD.parse(await s.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}},FD=(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"}},_D=Ko({openchamberVersion:zs()}),LD=async(t,e=Ys)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=_D.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},$D=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function zD({version:t}){const{t:e}=Et(),[s,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Ry();r(d.available&&!d.installBlocked?{kind:"available",info:d}:{kind:"manual",info:d,error:null})}catch(d){r({kind:"manual",info:null,error:d instanceof Error?d.message:null})}},i=s.kind==="manual"?s:null,a=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(Nt,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(Z,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),n.jsx(jl,{open:s.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Uu=Xr(()=>as(()=>import("./OnboardingScreen-Bx2h2w69.js"),__vite__mapDeps([172,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])).then(t=>({default:t.OnboardingScreen}))),KD=()=>as(()=>import("./AboutDialog-BItSBkkK.js"),__vite__mapDeps([173,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])).then(t=>t.AboutDialog),WD=()=>as(()=>import("./MemoryDebugPanel-BZgSuf-z.js"),__vite__mapDeps([174,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,122,123])).then(t=>t.MemoryDebugPanel),HD=()=>{const t=Ze.c(6),e=le(YD),s=le(ZD);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=Ni(e,KD,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},UD=t=>{const e=Ze.c(3),{onClose:s}=t,r=Ni(!0,WD,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},VD=t=>{const e=Ze.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=Et(),[i,a]=l.useState(null);let d,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const O=new AbortController,B=Jt(),j=setTimeout(()=>O.abort(),5e3);return BD(O.signal).then(P=>{!O.signal.aborted&&Jt()===B&&a(P)}).catch(QD).finally(()=>clearTimeout(j)),()=>{O.abort(),clearTimeout(j)}},c=[],e[0]=d,e[1]=c):(d=e[0],c=e[1]),l.useEffect(d,c);const[u,f]=l.useState(null);let p,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const O=new AbortController,B=Jt(),j=setTimeout(()=>O.abort(),5e3);return LD(O.signal).then(P=>{O.signal.aborted||Jt()!==B||f(P&&$D(P)?P:null)}).catch(XD).finally(()=>clearTimeout(j)),()=>{O.abort(),clearTimeout(j)}},h=[],e[2]=p,e[3]=h):(p=e[2],h=e[3]),l.useEffect(p,h);const g=ps(JD),b=i?null:g?.message??null;if(u){let O;e[4]!==u?(O=n.jsx(zD,{version:u}),e[4]=u,e[5]=O):O=e[5];let B;e[6]!==r||e[7]!==o?(B=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=B):B=e[8];let j;e[9]!==r||e[10]!==s||e[11]!==B?(j=n.jsx(Nt,{type:"button",variant:"outline",onClick:s,disabled:r,children:B}),e[9]=r,e[10]=s,e[11]=B,e[12]=j):j=e[12];let P;return e[13]!==O||e[14]!==j?(P=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[O,j]})}),e[13]=O,e[14]=j,e[15]=P):P=e[15],P}let x;e[16]!==o?(x=o("startup.initRecovery.title"),e[16]=o,e[17]=x):x=e[17];let y;e[18]!==x?(y=n.jsx("h1",{className:"typography-h1 text-foreground",children:x}),e[18]=x,e[19]=y):y=e[19];let S;e[20]!==i||e[21]!==g||e[22]!==o?(S=o(FD(i,g)),e[20]=i,e[21]=g,e[22]=o,e[23]=S):S=e[23];let m;e[24]!==S?(m=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:S}),e[24]=S,e[25]=m):m=e[25];let v;e[26]!==y||e[27]!==m?(v=n.jsxs("div",{className:"flex flex-col gap-2",children:[y,m]}),e[26]=y,e[27]=m,e[28]=v):v=e[28];let w;e[29]!==b||e[30]!==o?(w=b&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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:b})]}),e[29]=b,e[30]=o,e[31]=w):w=e[31];let T;e[32]!==i||e[33]!==o?(T=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=T):T=e[34];let k;e[35]!==r||e[36]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=k):k=e[37];let I;e[38]!==r||e[39]!==s||e[40]!==k?(I=n.jsx(Nt,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=I):I=e[41];let F;return e[42]!==w||e[43]!==T||e[44]!==I||e[45]!==v?(F=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,w,T,I]})}),e[42]=w,e[43]=T,e[44]=I,e[45]=v,e[46]=F):F=e[46],F};function GD({apis:t}){l.useEffect(()=>ew(),[]),l.useEffect(()=>{ub("App:mounted"),fb()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ps(M=>M.initializeApp),s=ps(M=>M.isInitialized),r=ps(M=>M.isConnected),o=ps(M=>M.providersLoaded),i=ps(M=>M.agentsLoaded),a=ps(M=>M.loadProviders),d=ps(M=>M.loadAgents),c=mt(M=>M.error),u=mt(M=>M.clearError),f=Ps(M=>M.currentDirectory),p=Ps(M=>M.isSwitchingDirectory),[h,g]=l.useState(!1),b=kn(M=>M.refreshAll),x=tw(M=>M.refreshStatus),[y,S]=l.useState(()=>t.runtime.isVSCode),[m,v]=l.useState(!1),[w,T]=l.useState(0),[k,I]=l.useState(0),[F,O]=l.useState(!1),B=le(M=>M.wideChatLayoutEnabled),j=le(M=>M.mobileKeyboardMode),P=l.useMemo(()=>hn(),[]),[L,z]=l.useState(()=>Dc()),[H,R]=l.useState(()=>{const M=Zi();return M!==null?Rc({isDesktopShell:!0,bootOutcome:M}):null}),G=l.useRef(!1),{t:_}=Et(),$=l.useRef(!1);l.useEffect(()=>{if(!s||L!=="valid"||$.current)return;const M=Zi();M?.target!=="local"||M.status!=="ok"||!M.sshStartupFallbackHostId||($.current=!0,He.error(_("desktopHostSwitcher.startup.title"),{description:_("desktopHostSwitcher.startup.fellBackToLocal")}))},[L,s,_]);const E=l.useRef(!1);l.useEffect(()=>{!s||!Dm()||E.current||(E.current=!0,He.info(_("desktopSafeStart.title"),{description:_("desktopSafeStart.description"),duration:1/0}))},[s,_]),l.useEffect(()=>(Nc(h),Ou(h),()=>{Nc(!1),Ou(!1)}),[h]),l.useEffect(()=>{pb(j)},[j]),l.useEffect(()=>{S(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>ri(M=>{My(M)&&Ay(M),I(V=>V+1),v(!1),T(V=>V+1)}),[]);const D=rd(M=>{const V=Jt();return Object.values(M.runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===V).map(ie=>`${ie.originalSessionID}:${ie.phase}:${ie.lastForwardedMessageID??""}:${ie.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{const M=Jt(),V=Object.values(rd.getState().runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===M);for(const ie of V)sw(ie.originalSessionID)},[D,k]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",B),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[B]),l.useEffect(()=>(Mc(t),()=>Mc(null)),[t]),l.useEffect(()=>{r&&(b(t.sourceControl,{force:!0}),x(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,b,x,k]),nw();const C=L==="valid",N=H?.screen==="main";l.useEffect(()=>{if(!hb({isDesktopShell:P,bootOutcomeKnown:C}))return;rw();const M=setTimeout(()=>{const V=document.getElementById("initial-loading");V&&(V.classList.add("fade-out"),setTimeout(()=>{V.remove()},300))},150);return()=>clearTimeout(M)},[P,C]),l.useEffect(()=>{if(!P||L!=="malformed")return;const M=document.getElementById("initial-loading");M&&(M.textContent="Desktop startup failed — please restart the app.")},[P,L]),l.useEffect(()=>{y||e()},[e,y]),l.useEffect(()=>{if(y||s)return;let M=!0,V,ie=0;const ce=10,ne=1e3,je=async()=>{if(!M)return;if(ie>=ce){v(!0);return}const Ee=ps.getState();if(Ee.isInitialized){v(!1);return}ie+=1,await Ee.initializeApp();const we=ps.getState();if(!M)return;if(we.isInitialized){v(!1);return}if(ie>=ce){v(!0);return}const Me=Math.min(ne*Math.pow(2,ie-1),4e3);V=setTimeout(je,Me)};return V=setTimeout(je,ne),()=>{M=!1,V&&clearTimeout(V)}},[w,s,y]),l.useEffect(()=>{s&&v(!1)},[s]),l.useEffect(()=>{if(!m)return;const M=document.getElementById("initial-loading");M&&(M.classList.add("fade-out"),setTimeout(()=>{M.remove()},300))},[m]),l.useEffect(()=>{if(y||!r||o&&i)return;let M=!0,V=0;const ie=15,ce=async()=>{const je=ps.getState();if(!(je.providersLoaded&&je.agentsLoaded))try{je.providersLoaded||await a({source:"startupRecovery"}),ps.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};ce();const ne=setInterval(()=>{if(M){if(++V>=ie){clearInterval(ne);return}ce()}},2e3);return()=>{M=!1,clearInterval(ne)}},[r,y,d,a,o,i]),l.useEffect(()=>{p||y||r&&Mo.setDirectory(f)},[f,p,r,y]),l.useEffect(()=>{if(typeof window>"u")return;const M=V=>{const ie=V.detail,ce=typeof ie?.sessionId=="string"?ie.sessionId.trim():"";if(!ce)return;const ne=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null,je=String(ie?.runtimeKey??"").trim();if(!(je&&je!==Jt()&&yb(je,ce))){if(!ne){od(ce,typeof ie?.messageId=="string"?ie.messageId.trim():null);return}mt.getState().setCurrentSession(ce,ne)}};return window.addEventListener("openchamber:open-session",M),mb().then(V=>{for(const ie of V)od(ie.sessionId,ie.messageId)}),()=>window.removeEventListener("openchamber:open-session",M)},[]),l.useEffect(()=>{if(!hn())return;const M=()=>{ED(V=>{He.error(_(V==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":V==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",M),M(),()=>window.removeEventListener("openchamber:host-actions-ready",M)},[_]);const A=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const M=A.current;M.attempt||(M.attempt=Oy({selectNow:!By().sessionId}))},[]),l.useEffect(()=>{const M=A.current,V=()=>{const ie=M.attempt;if(!ie||M.running||M.done)return;const ce=ps.getState().isInitialized;M.running=!0,ie().then(ne=>{if(M.running=!1,ne!=="failed"||ce){M.done=!0;return}ps.getState().isInitialized&&V()})};V()},[s]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{vn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Tr()})};return window.addEventListener("openchamber:open-mini-chat",M),()=>window.removeEventListener("openchamber:open-mini-chat",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{const V=mt.getState().currentSessionId;V&&cp(V)};return window.addEventListener("focus",M),()=>window.removeEventListener("focus",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=V=>{const ie=V.detail,ce=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null,ne=typeof ie?.projectId=="string"&&ie.projectId.trim().length>0?ie.projectId.trim():null,je=!!(ce||ne);le.getState().setSessionSwitcherOpen(!1),mt.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?ne:null,directoryOverride:je?ce:null,preserveDirectoryOverride:!!ce})};return window.addEventListener("openchamber:open-draft-session",M),()=>window.removeEventListener("openchamber:open-draft-session",M)},[]),l.useEffect(()=>{typeof window>"u"||!s||p||G.current||(G.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,p]),ow(),bD(),Fy(f||null),xD(),iw(),_y(),wD(),jD(s&&r,k),kD(),aw(),Iw(),Ly();const q=l.useCallback(()=>{g(M=>!M)},[]);zT(q),fD(),Pw(!0),l.useEffect(()=>{const M=()=>g(V=>!V);return window.addEventListener("openchamber:memory-debug-toggle",M),()=>window.removeEventListener("openchamber:memory-debug-toggle",M)},[]),l.useEffect(()=>{c&&setTimeout(()=>u(),5e3)},[u,c]),l.useEffect(()=>{if(!P||L!=="not-injected")return;let M=!1,V=0;const ie=200,ce=2e3,ne=50,je=()=>{if(M)return;V++;const Ee=Dc();if(Ee!=="not-injected"){if(M=!0,z(Ee),Ee==="valid"){const Me=Zi();Me&&R(Rc({isDesktopShell:!0,bootOutcome:Me}))}return}const we=Math.min(ie*Math.pow(1.1,V),ce);if(V>=ne){const Me=document.getElementById("initial-loading");Me&&!Me.textContent?.includes("taking longer")&&(Me.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,we)};return window.setTimeout(je,ie),()=>{M=!0}},[P,L]);const ee=l.useCallback(async()=>{if(gb({isDesktopShell:hn(),isDesktopLocalOriginActive:li()})){await bb();return}window.location.reload()},[]),Q=l.useCallback(async()=>{if(!F){v(!1),O(!0);try{await ps.getState().initializeApp()}finally{O(!1)}ps.getState().isInitialized||T(M=>M+1)}},[F]),he=M=>{if(M.screen==="recovery")return M.variant};if(P&&H&&H.screen!=="main"){if(H.screen==="chooser")return n.jsx(Cs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Uu,{mode:"first-launch",localAvailable:H.localAvailable!==!1,onCliAvailable:ee,onChooseRemote:()=>{}})})})});const M=he(H),V=H.screen==="recovery"&&"url"in H?H.url:void 0,ie=H.screen==="recovery"&&"hostId"in H?H.hostId:void 0;return n.jsx(Cs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Uu,{mode:"recovery",recoveryVariant:M,recoveryHostUrl:V,recoveryHostLabel:void 0,recoveryHostId:ie,localAvailable:H.localAvailable!==!1,onCliAvailable:ee})})})})}return m&&!s&&!y?n.jsx(Cs,{children:n.jsx(VD,{onRetry:()=>{Q()},isRetrying:F},k)}):n.jsx(Cs,{children:n.jsx(lw,{sdk:Mo.getSdkClient(),directory:f||"",children:n.jsx(cw,{apis:t,children:n.jsx(DT,{children:n.jsx(bi,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:P?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(dw,{backgroundWorkEnabled:!0}),n.jsx($y,{}),n.jsx(TD,{}),n.jsx($E,{}),P?n.jsx(zy,{ready:C&&N}):null,n.jsx(uw,{}),n.jsx(fw,{}),n.jsx(pw,{}),n.jsx(Ky,{}),n.jsx(HD,{}),h&&n.jsx(UD,{onClose:()=>g(!1)})]})})})})},k)})}function qD(t){const e=Ze.c(2);let s;return e[0]!==t?(s=n.jsx(Ny,{children:n.jsx(GD,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function YD(t){return t.isAboutDialogOpen}function ZD(t){return t.setAboutDialogOpen}function QD(){}function XD(){}function JD(t){return t.lastInitFailure}const eR=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();xb();Dm()&&CD();Wy();Hy();Sb().then(()=>{hw().catch(t=>{console.error("[main] settings init failed:",t)}),mw(),gw(),bw()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Nm=document.getElementById("root");if(!Nm)throw new Error("Root element not found");yw();jg.createRoot(Nm).render(n.jsx(us.StrictMode,{children:n.jsx(xw,{children:n.jsx(Sw,{children:n.jsx(ww,{children:n.jsx(vw,{children:n.jsx(qD,{apis:eR})})})})})}));const SR=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{$d as a,bR as b,xR as g,SR as m,yR as r,Hv as u,Ld as v};
369
+ `):[],e[2]=ce,e[3]=ne):ne=e[3];const je=ne;let Ee;e[4]!==Q||e[5]!==G||e[6]!==he?(Ee=(de,Ne)=>{if(!de)return null;Ne&&is.getState().collapsedFolderIds.has(Ne)&&he(Ne);const Je=Q(de,"New folder",Ne);return G(de,Je),Je},e[4]=Q,e[5]=G,e[6]=he,e[7]=Ee):Ee=e[7];const we=Ee;let Me;e[8]!==P||e[9]!==H||e[10]!==je||e[11]!==I||e[12]!==v||e[13]!==ee||e[14]!==$||e[15]!==s.session.id||e[16]!==L||e[17]!==z||e[18]!==R||e[19]!==B||e[20]!==T||e[21]!==k||e[22]!==M?(Me={mobileVariant:$,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,descendantIds:je,showDeletionDialog:M,setDeleteSessionConfirm:R,deleteSessionConfirm:H,editingId:v,setEditingId:T,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:ee,editTitle:I,setEditTitle:B},e[8]=P,e[9]=H,e[10]=je,e[11]=I,e[12]=v,e[13]=ee,e[14]=$,e[15]=s.session.id,e[16]=L,e[17]=z,e[18]=R,e[19]=B,e[20]=T,e[21]=k,e[22]=M,e[23]=Me):Me=e[23];const fe=W5(Me),be=g?.childRenderExtrasFor,ke=s.session.directory??o;let Ie;e[24]!==N||e[25]!==i||e[26]!==A||e[27]!==ke?(Ie={groupDirectory:ke,projectId:i,archivedBucket:N,renderContext:A},e[24]=N,e[25]=i,e[26]=A,e[27]=ke,e[28]=Ie):Ie=e[28];const Te=Ie,Y=h??p??s.session.id,ue=g?.subtreeContainsEditing??V5,me=g?.menuOpenSessionId??null,re=g?.nodeStructureKey??"",pe=g?.blockingBadgeSessionScopes,U=g?.relativeTimeTick;let ae;e[29]!==P||e[30]!==E||e[31]!==Te||e[32]!==be||e[33]!==H||e[34]!==C||e[35]!==I||e[36]!==v||e[37]!==w||e[38]!==x||e[39]!==a||e[40]!==y||e[41]!==$||e[42]!==s.children||e[43]!==S||e[44]!==m||e[45]!==L||e[46]!==F||e[47]!==b||e[48]!==q||e[49]!==z||e[50]!==d||e[51]!==R||e[52]!==B||e[53]!==T||e[54]!==k||e[55]!==j||e[56]!==G||e[57]!==_||e[58]!==O?(ae=q?s.children.map(de=>n.jsx(ei,{node:de,pinnedSessionIds:b,expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:B,toggleParent:O,openSidebarMenuKey:F,setOpenSidebarMenuKey:j,allowReselect:P,onSessionSelected:L,resetSessionSearch:z,deleteSessionConfirm:H,setDeleteSessionConfirm:R,startFolderRename:G,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,depth:C+1,folderOwnerKey:a,selectionScopeKey:d,...Te,renderExtras:be?.(de)},de.session.id)):null,e[29]=P,e[30]=E,e[31]=Te,e[32]=be,e[33]=H,e[34]=C,e[35]=I,e[36]=v,e[37]=w,e[38]=x,e[39]=a,e[40]=y,e[41]=$,e[42]=s.children,e[43]=S,e[44]=m,e[45]=L,e[46]=F,e[47]=b,e[48]=q,e[49]=z,e[50]=d,e[51]=R,e[52]=B,e[53]=T,e[54]=k,e[55]=j,e[56]=G,e[57]=_,e[58]=O,e[59]=ae):ae=e[59];let Re;e[60]!==E||e[61]!==N||e[62]!==we||e[63]!==C||e[64]!==I||e[65]!==v||e[66]!==w||e[67]!==ee||e[68]!==x||e[69]!==a||e[70]!==o||e[71]!==y||e[72]!==$||e[73]!==s||e[74]!==S||e[75]!==m||e[76]!==F||e[77]!==b||e[78]!==i||e[79]!==A||e[80]!==u||e[81]!==d||e[82]!==fe.handleCancelEdit||e[83]!==fe.handleCopySessionId||e[84]!==fe.handleDeleteSession||e[85]!==fe.handleRestoreSession||e[86]!==fe.handleSaveEdit||e[87]!==fe.handleSessionDoubleClick||e[88]!==fe.handleSessionSelect||e[89]!==B||e[90]!==T||e[91]!==k||e[92]!==j||e[93]!==_||e[94]!==Y||e[95]!==ue||e[96]!==me||e[97]!==re||e[98]!==pe||e[99]!==U||e[100]!==ae||e[101]!==O?(Re=n.jsx(z5,{expandedParents:x,hasSessionSearchQuery:y,normalizedSessionSearchQuery:S,notifyOnSubtasks:m,editingId:v,editingRowKey:w,setEditingId:T,setEditingRowKey:k,editTitle:I,setEditTitle:B,handleSaveEdit:fe.handleSaveEdit,handleCancelEdit:fe.handleCancelEdit,toggleParent:O,handleSessionSelect:fe.handleSessionSelect,handleSessionDoubleClick:fe.handleSessionDoubleClick,handleCopySessionId:fe.handleCopySessionId,openSidebarMenuKey:F,setOpenSidebarMenuKey:j,createFolderAndStartRename:we,handleDeleteSession:fe.handleDeleteSession,handleRestoreSession:fe.handleRestoreSession,startSessionWorktreeMenuLoad:_,mobileVariant:$,alwaysShowActions:E,pinnedSessionIds:b,node:s,depth:C,groupDirectory:o,projectId:i,folderOwnerKey:a,selectionScopeKey:d,archivedBucket:N,secondaryMeta:u,renderContext:A,rowKey:ee,dragKey:Y,subtreeContainsEditing:ue,menuOpenSessionId:me,nodeStructureKey:re,blockingBadgeSessionScopes:pe,relativeTimeTick:U,children:ae}),e[60]=E,e[61]=N,e[62]=we,e[63]=C,e[64]=I,e[65]=v,e[66]=w,e[67]=ee,e[68]=x,e[69]=a,e[70]=o,e[71]=y,e[72]=$,e[73]=s,e[74]=S,e[75]=m,e[76]=F,e[77]=b,e[78]=i,e[79]=A,e[80]=u,e[81]=d,e[82]=fe.handleCancelEdit,e[83]=fe.handleCopySessionId,e[84]=fe.handleDeleteSession,e[85]=fe.handleRestoreSession,e[86]=fe.handleSaveEdit,e[87]=fe.handleSessionDoubleClick,e[88]=fe.handleSessionSelect,e[89]=B,e[90]=T,e[91]=k,e[92]=j,e[93]=_,e[94]=Y,e[95]=ue,e[96]=me,e[97]=re,e[98]=pe,e[99]=U,e[100]=ae,e[101]=O,e[102]=Re):Re=e[102];let W;e[103]!==H||e[104]!==s.session.id||e[105]!==fe.confirmDeleteSession||e[106]!==R||e[107]!==V||e[108]!==M?(W=H?.session.id===s.session.id?n.jsx(H5,{value:H,setValue:R,showDeletionDialog:M,setShowDeletionDialog:V,onConfirm:fe.confirmDeleteSession}):null,e[103]=H,e[104]=s.session.id,e[105]=fe.confirmDeleteSession,e[106]=R,e[107]=V,e[108]=M,e[109]=W):W=e[109];let ye;return e[110]!==Re||e[111]!==W?(ye=n.jsxs(n.Fragment,{children:[Re,W]}),e[110]=Re,e[111]=W,e[112]=ye):ye=e[112],ye}function q5(t){return t.setShowDeletionDialog}function Y5(t){return t.showDeletionDialog}function Z5(t){return t.toggleFolderCollapse}function Q5(t){return t.createFolder}const X5=(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&&Tp(t.session,e.session)&&yt(t.worktree?.path??null)===yt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,J5=(t,e)=>{if(t.node!==e.node&&!X5(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 s=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(s)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(s)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null)||(t.secondaryMeta?.inSpace??!1)!==(e.secondaryMeta?.inSpace??!1))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","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},ei=l.memo(G5,J5),eI=10,tI=4;function Su(t){const e=Ze.c(7),{providerIDs:s,ringClass:r}=t;let o;if(e[0]!==s||e[1]!==r){let a;e[3]!==r?(a=d=>n.jsx("span",{className:Pe("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(Sp,{providerId:d,className:"h-3 w-3"})},d),e[3]=r,e[4]=a):a=e[4],o=s.slice(0,tI).map(a),e[0]=s,e[1]=r,e[2]=o}else o=e[2];let i;return e[5]!==o?(i=n.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:o}),e[5]=o,e[6]=i):i=e[6],i}function sI(t){const e=Ze.c(108),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:a,projectId:d,projectLabel:c,expansionKey:u,expanded:f,forceExpanded:p,notifyOnSubtasks:h,toggleParent:g}=t,{t:b}=Et();let x;e[0]!==s.key?(x=we=>we.runOverviewKey===s.key,e[0]=s.key,e[1]=x):x=e[1];const y=le(x),S=a==="mixed-compact",m=qr(a)||S,v=a==="timeline-by-time";let w;e[2]!==v||e[3]!==d||e[4]!==a?(w=we=>(a==="timeline-mixed"||v)&&d?we.projects.find(Me=>Me.id===d)??null:null,e[2]=v,e[3]=d,e[4]=a,e[5]=w):w=e[5];const T=ns(w),k=s.lanes.length;let I;e[6]!==k||e[7]!==b?(I=k===1?b("sessions.sidebar.run.laneCountSingle",{count:k}):b("sessions.sidebar.run.laneCountPlural",{count:k}),e[6]=k,e[7]=b,e[8]=I):I=e[8];const B=I;let O;e[9]!==o?(O=[...o],e[9]=o,e[10]=O):O=e[10];const F=O;let j;e[11]!==F||e[12]!==i||e[13]!==h?(j=n.jsx(jf,{nodes:F,blockingSessionIds:i,includeUnreadSubtasks:h}),e[11]=F,e[12]=i,e[13]=h,e[14]=j):j=e[14];const P=j,L=y?"text-interactive-selection-foreground":"text-muted-foreground";let z;e[15]!==s.key?(z=()=>le.getState().setRunOverviewKey(s.key),e[15]=s.key,e[16]=z):z=e[16];const H=z;if(m){const we=s.key,Me=y?"page":void 0;let fe;e[17]!==s.title||e[18]!==b?(fe=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[17]=s.title,e[18]=b,e[19]=fe):fe=e[19];let be;e[20]!==r||e[21]!==S?(be=S?Kn(r):eI,e[20]=r,e[21]=S,e[22]=be):be=e[22];let ke;e[23]!==be?(ke={paddingInlineStart:be},e[23]=be,e[24]=ke):ke=e[24];const Ie=S?"gap-1.5 py-1":"py-1.5",Te=y?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Y;e[25]!==Ie||e[26]!==Te?(Y=Pe("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ie,Te),e[25]=Ie,e[26]=Te,e[27]=Y):Y=e[27];let ue;e[28]!==P||e[29]!==S?(ue=S?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:P}):null,e[28]=P,e[29]=S,e[30]=ue):ue=e[30];const me=s.title;let re;e[31]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(Fa,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[31]=re):re=e[31];let pe;e[32]!==B?(pe=n.jsxs(n.Fragment,{children:[re,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:B})]}),e[32]=B,e[33]=pe):pe=e[33];const U=S?null:P;let ae;e[34]!==s.lastActivity?(ae=Ep(s.lastActivity),e[34]=s.lastActivity,e[35]=ae):ae=e[35];let Re;e[36]!==s.providerIDs?(Re=n.jsx(Su,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[36]=s.providerIDs,e[37]=Re):Re=e[37];let W;e[38]!==v||e[39]!==S||e[40]!==c||e[41]!==s.title||e[42]!==pe||e[43]!==U||e[44]!==ae||e[45]!==Re||e[46]!==T||e[47]!==L?(W=n.jsx(cl,{compact:S,project:T,projectLabel:c,projectLine:v,title:me,titleClassName:L,branchLabel:null,metaLineLead:pe,statusDot:U,pinnedMarker:null,timeSlot:ae,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:Re,hideMetaOnHoverClass:""}),e[38]=v,e[39]=S,e[40]=c,e[41]=s.title,e[42]=pe,e[43]=U,e[44]=ae,e[45]=Re,e[46]=T,e[47]=L,e[48]=W):W=e[48];let ye;return e[49]!==H||e[50]!==s.key||e[51]!==ke||e[52]!==Y||e[53]!==ue||e[54]!==W||e[55]!==Me||e[56]!==fe?(ye=n.jsxs("button",{type:"button","data-run-row":we,"aria-current":Me,"aria-label":fe,onClick:H,style:ke,className:Y,children:[ue,W]}),e[49]=H,e[50]=s.key,e[51]=ke,e[52]=Y,e[53]=ue,e[54]=W,e[55]=Me,e[56]=fe,e[57]=ye):ye=e[57],ye}let R;e[58]!==u||e[59]!==p||e[60]!==g?(R=we=>{we.stopPropagation(),p||g(u)},e[58]=u,e[59]=p,e[60]=g,e[61]=R):R=e[61];const G=R,_=s.key,$=y?"page":void 0;let E;e[62]!==r?(E=Kn(r),e[62]=r,e[63]=E):E=e[63];let D;e[64]!==E?(D={paddingInlineStart:E},e[64]=E,e[65]=D):D=e[65];const C=y?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let N;e[66]!==C?(N=Pe("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",C),e[66]=C,e[67]=N):N=e[67];let A;e[68]!==G?(A=we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),G(we))},e[68]=G,e[69]=A):A=e[69];let q;e[70]!==f||e[71]!==b?(q=b(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[70]=f,e[71]=b,e[72]=q):q=e[72];let ee;e[73]!==f?(ee=n.jsx(eo,{expanded:f}),e[73]=f,e[74]=ee):ee=e[74];let Q;e[75]!==f||e[76]!==A||e[77]!==q||e[78]!==ee||e[79]!==G?(Q=n.jsx("button",{type:"button",onClick:G,onKeyDown:A,className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":f,"aria-label":q,children:ee}),e[75]=f,e[76]=A,e[77]=q,e[78]=ee,e[79]=G,e[80]=Q):Q=e[80];let he;e[81]!==H?(he=we=>{we.stopPropagation(),H()},e[81]=H,e[82]=he):he=e[82];let M;e[83]!==s.title||e[84]!==b?(M=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[83]=s.title,e[84]=b,e[85]=M):M=e[85];let V;e[86]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Fa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[86]=V):V=e[86];let ie;e[87]!==L?(ie=Pe("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",L),e[87]=L,e[88]=ie):ie=e[88];let ce;e[89]!==s.title||e[90]!==ie?(ce=n.jsx("span",{dir:"auto",className:ie,children:s.title}),e[89]=s.title,e[90]=ie,e[91]=ce):ce=e[91];let ne;e[92]!==s.providerIDs?(ne=n.jsx(Su,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[92]=s.providerIDs,e[93]=ne):ne=e[93];let je;e[94]!==P||e[95]!==he||e[96]!==M||e[97]!==ce||e[98]!==ne?(je=n.jsxs("button",{type:"button",onClick:he,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":M,children:[V,ce,ne,P]}),e[94]=P,e[95]=he,e[96]=M,e[97]=ce,e[98]=ne,e[99]=je):je=e[99];let Ee;return e[100]!==H||e[101]!==s.key||e[102]!==D||e[103]!==N||e[104]!==Q||e[105]!==je||e[106]!==$?(Ee=n.jsxs("div",{"data-run-row":_,"aria-current":$,onClick:H,style:D,className:N,children:[Q,je]}),e[100]=H,e[101]=s.key,e[102]=D,e[103]=N,e[104]=Q,e[105]=je,e[106]=$,e[107]=Ee):Ee=e[107],Ee}const nI=l.memo(sI),rI=24,oI=t=>Array.from({length:Math.min(t,rI)},(e,s)=>s),iI=(t,e,s)=>{const r=new Set(t);for(const o of e)o>=0&&o<s&&r.add(o);return[...r].sort((o,i)=>o-i)},aI=(t,e)=>t.find(s=>s.end>e)?.index??0,lI={"pb-2":8,"pb-1.5":6},wu=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,cI=(t,e)=>`${t.key}|${sr(t,e)??""}`,dI=(t,e,s={})=>{const r=sr(t,e),o=r?s.gapBySpacing?.get(r)??lI[r]:0;return(s.height??t.estimateSize)+o},sr=(t,e)=>e?.kind==="activity-header"||e?.kind==="project-header"?"pb-2":e?.kind==="group-header"&&t.kind!=="project-header"?"pb-1.5":void 0,uI=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function fI({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,a=l.useCallback(()=>e,[e]),d=l.useRef(new Map),c=l.useRef(new Map),u=l.useCallback(j=>{const P=i[j];if(!P)return 32;const L=i[j+1];return dI(P,L,{height:d.current.get(wu(P)),gapBySpacing:c.current})},[i]),f=l.useCallback((j,P,L)=>{const z=Kw(j,P,L),H=L.indexFromElement(j),R=i[H];if(R){const G=sr(R,i[H+1]),_=G&&Number.parseFloat(getComputedStyle(j).paddingBottom)||0;G&&c.current.set(G,_),d.current.set(wu(R),z-_)}return z},[i]),p=l.useCallback(j=>{const P=i[j];return P?cI(P,i[j+1]):j},[i]),h=l.useRef(0),[g,b]=l.useState(null),x=g?.slidingIndexes,y=l.useCallback(j=>{const P=Gp(j),L=x?.length?new Set([...s,...x]):s;return iI(P,L,i.length)},[s,i.length,x]),S=Vp({count:i.length,enabled:e!==null,getScrollElement:a,estimateSize:u,measureElement:f,getItemKey:p,overscan:8,rangeExtractor:y}),m=S.getVirtualItems(),v=e?S.getTotalSize():0,w=e?Math.max(v-e.clientHeight,0):0,T=e?Math.min(e.scrollTop,w):0,k=aI(m,T);l.useLayoutEffect(()=>{o(k)},[k,o]);const I=l.useRef(null),B=l.useRef(null);l.useLayoutEffect(()=>{const j=B.current;if(!j||j.rows===i||!e||uI())return;const P=iy(j.rows,i);if(!P)return;const L=j.measurements,z=S.measurementsCache,H=L[P.previousHeaderIndex],R=z[P.nextHeaderIndex];if(!H||!R)return;const G=R.start-H.start,_=P.opened?L[P.previousHeaderIndex+1]:L[P.blockEnd],$=P.opened?P.blockEnd:P.nextHeaderIndex+1,E=z[$],D=(_?.start??H.end)+G,C=E?.start??R.end,N=e.scrollTop-e.clientHeight,A=e.scrollTop+e.clientHeight*2,q=new Set,ee=[],Q=[];if(P.opened){for(let he=P.blockStart;he<P.blockEnd;he+=1)q.add(i[he].key);for(let he=$;he<z.length&&z[he].start+D-C<A;he+=1)Q.push(he)}else for(let he=P.blockStart;he<P.blockEnd;he+=1){const M=L[he];!M||M.end+G<N||M.start+G>A||ee.push({row:j.rows[he],nextRow:j.rows[he+1],start:M.start+G,end:M.end+G})}h.current+=1,b({id:h.current,revealKeys:q,ghosts:ee,followingIndex:$,from:D,to:C,slidingIndexes:Q})},[i,e,S]),l.useLayoutEffect(()=>{B.current={rows:i,measurements:S.measurementsCache}}),l.useLayoutEffect(()=>{const j=I.current;if(!g||!j)return;const P={duration:ly,easing:ay},L=g.from-g.to,z=[];for(const R of j.children){if(!(R instanceof HTMLElement))continue;const G=R.dataset.sidebarRowKey??"",_=Number(R.dataset.sidebarVirtualStart);R.dataset.sidebarGhost==="true"?z.push(R.animate(Lc(_,R.offsetHeight,g.from,g.to),{...P,fill:"forwards"})):g.revealKeys.has(G)?z.push(R.animate(Lc(_,R.offsetHeight,g.from,g.to),P)):Number(R.dataset.index)>=g.followingIndex&&L!==0&&z.push(R.animate([{transform:`translateY(${_+L}px)`},{transform:`translateY(${_}px)`}],P))}let H=!1;return Promise.all(z.map(R=>R.finished)).then(()=>{H||b(R=>R?.id===g.id?null:R)},()=>{}),()=>{H=!0;for(const R of z)R.cancel()}},[g]);const O=(j,P)=>j.treeGuides?n.jsxs("div",{className:"relative flow-root",children:[r(j,P),n.jsx(cy,{guides:j.treeGuides,slotStartPx:qh})]}):r(j,P);if(!e){const j=oI(i.length),P=j.reduce((z,H)=>z+(i[H]?.estimateSize??0),0),L=i.reduce((z,H)=>z+H.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[j.map(z=>{const H=i[z];return H?n.jsx("div",{className:sr(H,i[z+1]),children:O(H,z)},H.key):null}),L>P?n.jsx("div",{"aria-hidden":"true",style:{height:L-P}}):null]})}const F=g?.ghosts.reduce((j,P)=>Math.max(j,P.end),0)??0;return n.jsxs("div",{ref:I,"data-sidebar-virtual-ready":"true",style:{height:Math.max(v,F),position:"relative"},children:[g?.ghosts.map(j=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${sr(j.row,j.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":j.row.key,"data-sidebar-virtual-start":j.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${j.start}px)`},children:O(j.row,-1)},j.row.key)),m.map(j=>{const P=i[j.index];return P?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${sr(P,i[j.index+1])??""}`,"data-index":j.index,"data-sidebar-row-key":P.key,"data-sidebar-virtual-start":j.start,ref:S.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${j.start}px)`},children:O(P,j.index)},P.key):null})]})}const pI={pinned:"pushpin",work:"eye",chats:"chat-4",timeline:"history"},hI={pinned:"sessions.sidebar.activity.pinnedTitle",work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle",timeline:"sessions.sidebar.activity.projectsTitle"},mI=t=>{const e=Ze.c(33),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:a,onNewChat:d}=t,{t:c}=Et(),u=s==="chats",f=o?void 0:a,p=u?"pe-10":"pe-3.5";let h;e[0]!==p?(h=Pe("group flex w-full items-center gap-1.5 py-1 ps-4 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",p),e[0]=p,e[1]=h):h=e[1];const g=!r,b=pI[s],x=!o&&"group-hover:hidden";let y;e[2]!==x?(y=Pe("h-3.5 w-3.5 text-muted-foreground/80",x),e[2]=x,e[3]=y):y=e[3];let S;e[4]!==b||e[5]!==y?(S=n.jsx(Z,{name:b,className:y}),e[4]=b,e[5]=y,e[6]=S):S=e[6];let m;e[7]!==r||e[8]!==o?(m=o?null:n.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:n.jsx(Z,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[7]=r,e[8]=o,e[9]=m):m=e[9];let v;e[10]!==S||e[11]!==m?(v=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[S,m]}),e[10]=S,e[11]=m,e[12]=v):v=e[12];const w=hI[s];let T;e[13]!==c||e[14]!==w?(T=c(w),e[13]=c,e[14]=w,e[15]=T):T=e[15];let k;e[16]!==T?(k=n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:T}),e[16]=T,e[17]=k):k=e[17];let I;e[18]!==o||e[19]!==f||e[20]!==v||e[21]!==k||e[22]!==h||e[23]!==g?(I=n.jsxs("button",{type:"button",onClick:f,disabled:o,className:h,"aria-expanded":g,children:[v,k]}),e[18]=o,e[19]=f,e[20]=v,e[21]=k,e[22]=h,e[23]=g,e[24]=I):I=e[24];let B;e[25]!==i||e[26]!==u||e[27]!==d||e[28]!==c?(B=u?n.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),d()},className:Pe("absolute inset-e-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",i?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-has-[:focus-visible]/chats:opacity-100 group-has-[:focus-visible]/chats:pointer-events-auto"),"aria-label":c("sessions.sidebar.header.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})}):null,e[25]=i,e[26]=u,e[27]=d,e[28]=c,e[29]=B):B=e[29];let O;return e[30]!==I||e[31]!==B?(O=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[I,B]}),e[30]=I,e[31]=B,e[32]=O):O=e[32],O},mm=l.createContext(null);function vu(t){let e=0,s=t;for(;s;){e+=s.offsetTop;const i=s.offsetParent;s=i instanceof HTMLElement?i:null}const r=t.closest("[data-sidebar-virtual-start]"),o=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(o)?o:0)}function gI(t){const e=Ze.c(11),{suspended:s,layoutKey:r,scrollRef:o,children:i}=t,a=s===void 0?!1:s,d=r===void 0?"":r;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const u=l.useRef(c),f=l.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=y=>(u.current.add(y),f.current?.(),()=>{u.current.delete(y),f.current?.()}),e[1]=p):p=e[1];const h=p;let g;e[2]!==o||e[3]!==a?(g=()=>{const y=o.current;if(a||!y)return;const S=document.createElement("div");S.dataset.sidebarCrossfadeLayer="true",S.className="pointer-events-none sticky top-0 z-30 h-0",S.style.marginBlock="0px",y.prepend(S);let m=null,v=null,w=null,T=0;const k=new Set;let I=[];const B=window.matchMedia("(prefers-reduced-motion: reduce)"),O=(R,G)=>{const _=document.activeElement,$=_ instanceof HTMLElement&&R.host.contains(_),E=$?y.scrollTop:null;G.moveBefore&&G.isConnected&&R.host.isConnected?G.moveBefore(R.host,null):G.append(R.host),$&&_.focus({preventScroll:!0}),E!==null&&y.scrollTop!==E&&(y.scrollTop=E)},F=()=>{w?.cancel(),w=null,v?.remove(),v=null},j=()=>{let R=null,G=-1/0;for(const{entry:_,top:$}of I)$<=y.scrollTop&&$>=G&&(G=$,R=_);if(m!==R){if(F(),m&&R&&!B.matches){const _=m.host.cloneNode(!0);_ instanceof HTMLElement&&(_.inert=!0,_.setAttribute("aria-hidden","true"),_.querySelectorAll("[id]").forEach(bI),_.className="pointer-events-none absolute inset-x-0 top-0 z-30",v=_)}m&&(O(m,m.slot),m.slot.style.removeProperty("height")),m=R,S.hidden=!R,R&&(R.slot.style.height=`${R.host.getBoundingClientRect().height}px`,O(R,S),v&&(S.append(v),w=v.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=F))}},P=()=>{m&&(m.slot.style.height=`${m.host.getBoundingClientRect().height}px`);const R=vu(y)+y.clientTop;I=Array.from(u.current,G=>({entry:G,top:vu(G.slot)-R})),j()},L=new ResizeObserver(P),z=new MutationObserver(()=>{cancelAnimationFrame(T),T=requestAnimationFrame(P)});L.observe(y);const H=()=>{z.disconnect();for(const R of k)u.current.has(R)||(L.unobserve(R.host),R.slot.parentElement&&L.unobserve(R.slot.parentElement),k.delete(R));for(const R of u.current){const G=R.slot.closest("[data-sidebar-virtual-start]");G&&z.observe(G,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(R)||(L.observe(R.host),R.slot.parentElement&&L.observe(R.slot.parentElement),k.add(R))}cancelAnimationFrame(T),T=requestAnimationFrame(P)};return f.current=H,y.addEventListener("scroll",j,{passive:!0}),H(),P(),()=>{f.current=null,cancelAnimationFrame(T),y.removeEventListener("scroll",j),L.disconnect(),z.disconnect(),F(),S.hidden=!0,m&&(O(m,m.slot),m.slot.style.removeProperty("height")),S.remove()}},e[2]=o,e[3]=a,e[4]=g):g=e[4];let b;e[5]!==d||e[6]!==o||e[7]!==a?(b=[a,d,o],e[5]=d,e[6]=o,e[7]=a,e[8]=b):b=e[8],l.useLayoutEffect(g,b);let x;return e[9]!==i?(x=n.jsx(mm.Provider,{value:h,children:i}),e[9]=i,e[10]=x):x=e[10],x}function bI(t){return t.removeAttribute("id")}function yI(t){const e=Ze.c(15);let s,r;e[0]!==t?({register:r,...s}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=l.useRef(null),[i]=l.useState(xI);let a,d;e[3]!==i||e[4]!==r?(a=()=>{const h=o.current;if(!h)return;h.append(i);const g=r({slot:h,host:i});return()=>{g(),i.remove()}},d=[i,r],e[3]=i,e[4]=r,e[5]=a,e[6]=d):(a=e[5],d=e[6]),l.useLayoutEffect(a,d);let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{ref:o}),e[7]=c):c=e[7];let u;e[8]!==s?(u=n.jsx("div",{...s}),e[8]=s,e[9]=u):u=e[9];let f;e[10]!==i||e[11]!==u?(f=gl.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let p;return e[13]!==f?(p=n.jsxs(n.Fragment,{children:[c,f]}),e[13]=f,e[14]=p):p=e[14],p}function xI(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function gm(t){const e=Ze.c(3),s=l.useContext(mm);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(yI,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const SI=t=>{const e=Ze.c(3),[s,r]=l.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let a=!0;const d=()=>{Mo.getDirectoryAvailability(t).then(c=>{a&&c!=="unknown"&&r(c==="missing")})};return d(),window.addEventListener("focus",d),()=>{a=!1,window.removeEventListener("focus",d)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),l.useEffect(o,i),s},wa=t=>{const e=Ze.c(27),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:a,projectIconBackground:d,isCollapsed:c,alwaysShowActions:u,labelClassName:f}=t,p=u===void 0?!1:u,{currentTheme:h}=br(),g=o?kl[o]:null;let b;e[0]!==i?(b=Cl(i),e[0]=i,e[1]=b):b=e[1];const x=b,y=c!==void 0,S=y?p?"hidden":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0":void 0;let m;e[2]!==p||e[3]!==y||e[4]!==c?(m=y?n.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",p?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-has-[:focus-visible]/project:opacity-100"),children:n.jsx(Z,{name:c?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=p,e[3]=y,e[4]=c,e[5]=m):m=e[5];let v;e[6]!==p||e[7]!==h||e[8]!==y||e[9]!==x||e[10]!==S||e[11]!==s||e[12]!==d||e[13]!==a||e[14]!==g?(v=a?n.jsx("span",{className:Pe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",y&&p?"hidden":"inline-flex",S),style:d?{backgroundColor:d}:void 0,children:n.jsx(Il,{project:{id:s,iconImage:a},options:{themeVariant:h.metadata.variant,iconColor:h.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?n.jsx(Z,{name:g,className:"h-3.5 w-3.5",style:x?{color:x}:void 0}):n.jsx(Z,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:x?{color:x}:void 0})})}):g?n.jsx(Z,{name:g,className:Pe("h-3.5 w-3.5",S),style:x?{color:x}:void 0}):n.jsx(Z,{name:"folder",className:Pe("h-3.5 w-3.5 text-muted-foreground/80",S),style:x?{color:x}:void 0}),e[6]=p,e[7]=h,e[8]=y,e[9]=x,e[10]=S,e[11]=s,e[12]=d,e[13]=a,e[14]=g,e[15]=v):v=e[15];let w;e[16]!==m||e[17]!==v?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[m,v]}),e[16]=m,e[17]=v,e[18]=w):w=e[18];let T;e[19]!==f?(T=Pe("truncate typography-ui-header font-semibold text-foreground",f),e[19]=f,e[20]=T):T=e[20];let k;e[21]!==r||e[22]!==T?(k=n.jsx("span",{className:T,children:r}),e[21]=r,e[22]=T,e[23]=k):k=e[23];let I;return e[24]!==w||e[25]!==k?(I=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=I):I=e[26],I},wI=t=>{const e=Ze.c(68),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:a,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,isRepo:h,hideDirectoryControls:g,alwaysShowActions:b,onToggle:x,onNewSession:y,onNewWorktreeSession:S,onManageWorktrees:m,onManageSpaces:v,onOpenSourceBoard:w,onOpenFolder:T,onRenameStart:k,onArchiveAll:I,onClose:B,children:O,showCreateButtons:F,hideHeader:j,statusIndicator:P,openSidebarMenuKey:L,setOpenSidebarMenuKey:z,projectPickerOptions:H,onProjectSelect:R}=t,G=r===void 0?!1:r,_=F===void 0?!0:F,$=j===void 0?!1:j,E=P===void 0?null:P,{t:D}=Et(),C=SI(a);let N;e[0]!==G||e[1]!==s?(N={id:s,disabled:G},e[0]=G,e[1]=s,e[2]=N):N=e[2];const{attributes:A,listeners:q,setNodeRef:ee,transform:Q,transition:he,isDragging:M}=ji(N),V=l.useRef(!1),ie=`project:${s}`,ce=L===ie,[ne,je]=l.useState(!1),Ee=!!(H&&R);let we;e[3]!==ie||e[4]!==z?(we=Ae=>{Ae&&je(!1),z(Ae?ie:null)},e[3]=ie,e[4]=z,e[5]=we):we=e[5];const Me=we;let fe;e[6]!==g||e[7]!==h||e[8]!==I||e[9]!==B||e[10]!==v||e[11]!==m||e[12]!==y||e[13]!==T||e[14]!==w||e[15]!==k||e[16]!==_||e[17]!==D?(fe=Ae=>n.jsxs(n.Fragment,{children:[_&&!h&&!g&&y&&n.jsxs(Ae,{onClick:y,children:[n.jsx(Z,{name:"add",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.newSession")]}),h&&!g&&m&&n.jsxs(Ae,{onClick:m,children:[n.jsx(Z,{name:"node-tree",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.manageWorktrees")]}),h&&!g&&v&&n.jsxs(Ae,{onClick:v,children:[n.jsx(Z,{name:"box-3",className:"me-1.5 h-4 w-4"}),D("spaces.page.menuItem")]}),h&&!g&&w&&n.jsxs(Ae,{onClick:w,children:[n.jsx(Z,{name:"git-pull-request",className:"me-1.5 h-4 w-4"}),D("sourceBoard.title")]}),T&&n.jsxs(Ae,{onClick:T,children:[n.jsx(Z,{name:"folder-received",className:"me-1.5 h-4 w-4"}),D(ap())]}),n.jsxs(Ae,{onClick:k,children:[n.jsx(Z,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.edit")]}),I&&n.jsxs(Ae,{onClick:I,children:[n.jsx(Z,{name:"archive",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Ae,{onClick:B,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1.5 h-4 w-4"}),D("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=g,e[7]=h,e[8]=I,e[9]=B,e[10]=v,e[11]=m,e[12]=y,e[13]=T,e[14]=w,e[15]=k,e[16]=_,e[17]=D,e[18]=fe):fe=e[18];const be=fe,ke=kI,Ie=CI,Te=II;let Y;e[19]===Symbol.for("react.memo_cache_sentinel")?(Y=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey)&&(V.current=!0)},e[19]=Y):Y=e[19];const ue=Y;let me;e[20]!==x?(me=()=>{if(V.current){V.current=!1;return}x()},e[20]=x,e[21]=me):me=e[21];const re=me,U=(_&&h&&!g&&!!S?1:0)+(g?0:1),ae=U===2?"[--oc-actions-reserve:66px]":U===1&&_?"[--oc-actions-reserve:38px]":_||U===1?"[--oc-actions-reserve:12px]":void 0,Re=b?void 0:ce?"oc-actions-mask":"group-hover/project:oc-actions-mask group-has-[:focus-visible]/project:oc-actions-mask",W=b?void 0:ce?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-has-[:focus-visible]/project:opacity-0";let ye;e[22]!==Q?(ye=ki.Transform.toString(Q),e[22]=Q,e[23]=ye):ye=e[23];let de;e[24]!==ye||e[25]!==he?(de={transform:ye,transition:he},e[24]=ye,e[25]=he,e[26]=de):de=e[26];const Ne=M&&"opacity-30";let Je;e[27]!==Ne?(Je=Pe("relative",Ne),e[27]=Ne,e[28]=Je):Je=e[28];let Ge;e[29]!==b||e[30]!==A||e[31]!==C||e[32]!==Me||e[33]!==re||e[34]!==ae||e[35]!==W||e[36]!==Re||e[37]!==g||e[38]!==$||e[39]!==s||e[40]!==p||e[41]!==ne||e[42]!==ce||e[43]!==Ee||e[44]!==h||e[45]!==q||e[46]!==y||e[47]!==S||e[48]!==R||e[49]!==c||e[50]!==i||e[51]!==a||e[52]!==d||e[53]!==f||e[54]!==u||e[55]!==o||e[56]!==H||e[57]!==be||e[58]!==_||e[59]!==E||e[60]!==D?(Ge=$?null:n.jsx(n.Fragment,{children:n.jsxs(Zr,{open:ne,onOpenChange:je,children:[n.jsx(zl,{render:n.jsx(gm,{className:Pe("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Ae=>{g||(Ae.preventDefault(),je(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",...A,children:[Ee?n.jsxs(Rs,{children:[n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button",className:Pe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",h&&!g?b||ce?"pe-20":"pe-0 group-hover/project:pe-20 group-has-[:focus-visible]/project:pe-20":b||ce?"pe-14":"pe-0 group-hover/project:pe-14 group-has-[:focus-visible]/project:pe-14"),"aria-label":D("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(wa,{id:s,projectLabel:o,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f}),n.jsx(Z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),a?n.jsx(Qo,{directory:a,className:"ms-auto"}):null]})}),n.jsx(Ms,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:H?.map(Ae=>n.jsxs(rs,{onClick:()=>R?.(Ae.id),className:"flex items-center justify-between gap-3",title:Ae.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(wa,{...Ae})}),Ae.id===s?n.jsx(Z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Ae.id))})]}):n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:ue,onClick:re,...q,className:Pe("@container flex-1 min-w-0 flex items-center gap-1.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",b?h&&!g?"pe-20":"pe-14":ae),children:[n.jsx(wa,{id:s,projectLabel:o,projectIcon:d,projectColor:c,projectIconImage:u,projectIconBackground:f,isCollapsed:p,alwaysShowActions:b,labelClassName:Pe("[--oc-actions-inset:20px]",Re)}),C?n.jsx("span",{className:Pe("inline-flex flex-shrink-0 items-center text-status-warning",W),title:D("sessions.sidebar.project.folderMissing"),"aria-label":D("sessions.sidebar.project.folderMissing"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,E?n.jsx("span",{className:Pe("ms-1 inline-flex flex-shrink-0 items-center",W),children:E}):null,a?n.jsx(Qo,{directory:a,className:Pe("ms-auto",W)}):null]})}),n.jsx(Kt,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:Pe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",_?"inset-e-7":"inset-e-0.5"),children:[_&&h&&!g&&S?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),S()},className:Pe("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",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Z,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(Rs,{open:ce,onOpenChange:Me,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Pe("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",ce?"opacity-100 pointer-events-auto":b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Ie,onMouseDown:Te,onClick:ke,children:n.jsx(Z,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Ms,{align:"end",className:"min-w-[180px]",children:be(rs)})]})]}),_&&y?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),y()},className:Pe("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",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-has-[:focus-visible]/project:opacity-100 group-has-[:focus-visible]/project:pointer-events-auto"),"aria-label":D(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:D(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Ll,{className:"min-w-[180px]",children:be($n)})]})}),e[29]=b,e[30]=A,e[31]=C,e[32]=Me,e[33]=re,e[34]=ae,e[35]=W,e[36]=Re,e[37]=g,e[38]=$,e[39]=s,e[40]=p,e[41]=ne,e[42]=ce,e[43]=Ee,e[44]=h,e[45]=q,e[46]=y,e[47]=S,e[48]=R,e[49]=c,e[50]=i,e[51]=a,e[52]=d,e[53]=f,e[54]=u,e[55]=o,e[56]=H,e[57]=be,e[58]=_,e[59]=E,e[60]=D,e[61]=Ge):Ge=e[61];let ge;return e[62]!==O||e[63]!==ee||e[64]!==de||e[65]!==Je||e[66]!==Ge?(ge=n.jsxs("div",{ref:ee,style:de,className:Je,children:[Ge,O]}),e[62]=O,e[63]=ee,e[64]=de,e[65]=Je,e[66]=Ge,e[67]=ge):ge=e[67],ge},vI=t=>{const e=Ze.c(21),{id:s,disabled:r,children:o}=t,i=r===void 0?!1:r;let a;e[0]!==i||e[1]!==s?(a={id:s,disabled:i},e[0]=i,e[1]=s,e[2]=a):a=e[2];const{listeners:d,setNodeRef:c,setActivatorNodeRef:u,transform:f,transition:p,isDragging:h}=ji(a);let g;e[3]!==d||e[4]!==u?(g={listeners:d,setActivatorNodeRef:u},e[3]=d,e[4]=u,e[5]=g):g=e[5];const b=g;let x;e[6]!==f?(x=ki.Transform.toString(f),e[6]=f,e[7]=x):x=e[7];let y;e[8]!==x||e[9]!==p?(y={transform:x,transition:p},e[8]=x,e[9]=p,e[10]=y):y=e[10];const S=h&&"opacity-50";let m;e[11]!==S?(m=Pe("space-y-0.5 rounded-md",S),e[11]=S,e[12]=m):m=e[12];let v;e[13]!==o||e[14]!==b?(v=o(b),e[13]=o,e[14]=b,e[15]=v):v=e[15];let w;return e[16]!==c||e[17]!==y||e[18]!==m||e[19]!==v?(w=n.jsx("div",{ref:c,style:y,className:m,children:v}),e[16]=c,e[17]=y,e[18]=m,e[19]=v,e[20]=w):w=e[20],w},jI=l.memo(vI);function kI(t){t.stopPropagation()}function CI(t){t.stopPropagation()}function II(t){t.stopPropagation()}const ju=[],PI=t=>{const e=Ze.c(6),{nodes:s,includeUnreadSubtasks:r,children:o}=t;let i;e[0]!==r||e[1]!==s?(i={nodes:s,includeUnreadSubtasks:r},e[0]=r,e[1]=s,e[2]=i):i=e[2];const a=wf(i);let d;return e[3]!==o||e[4]!==a?(d=o(a),e[3]=o,e[4]=a,e[5]=d):d=e[5],d},va=(t,e)=>e?t.sessions.some(s=>gr(s,e)):!1,EI=(t,e,s)=>t.sessions.some(r=>Gh(r,r,e,s,t.directory,t.directory)),TI=(t,e,s)=>{const r=o=>{const i=o.session.id;return e.get(i)!==s.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},DI=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const a=`project:${r}:${i.session.id}`;return e.has(a)!==s.has(a)?!0:i.children.some(o)};return t.sessions.some(o)},RI=(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&&EI(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&TI(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&DI(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(va(e.group,t.editingId)||va(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&va(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=Zo(e.group.sessions,t.openSidebarMenuKey,"project",s),o=Zo(e.group.sessions,e.openSidebarMenuKey,"project",s);if(r||o)return!1}if(t.folderRename!==e.folderRename){const s=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??yt(e.group.directory??null)];if(s.includes(t.folderRename?.scopeKey??null)||s.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},NI=l.memo(function(e){const s=Ze.c(23),{label:r,sessions:o,worktree:i}=e,{t:a}=Et(),d=dm();let c;s[0]!==o||s[1]!==d||s[2]!==i?(c=S=>{S.stopPropagation(),Tn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:d||S.shiftKey})},s[0]=o,s[1]=d,s[2]=i,s[3]=c):c=s[3];const u=d?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=Pe("inline-flex h-6 w-6 items-center justify-center rounded-md hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u),s[4]=u,s[5]=f):f=s[5];let p;s[6]!==r||s[7]!==d||s[8]!==a?(p=d?a("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):a("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=d,s[8]=a,s[9]=p):p=s[9];let h;s[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"}),s[10]=h):h=s[10];let g;s[11]!==c||s[12]!==f||s[13]!==p?(g=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:c,className:f,"aria-label":p,children:h})}),s[11]=c,s[12]=f,s[13]=p,s[14]=g):g=s[14];let b;s[15]!==d||s[16]!==a?(b=a(d?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=d,s[16]=a,s[17]=b):b=s[17];let x;s[18]!==b?(x=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b})}),s[18]=b,s[19]=x):x=s[19];let y;return s[20]!==g||s[21]!==x?(y=n.jsxs(Ut,{children:[g,x]}),s[20]=g,s[21]=x,s[22]=y):y=s[22],y}),ku=[];function MI(t){const{t:e}=Et(),s=Wl(),r=Zg(t.group.space?.id),o=Gs(Se=>{const We=t.group.space?.id;return We!=null&&rS(Se.journey?.get(We),Se.spaces.get(We),Se.actions.get(We))}),{group:i,groupKey:a,projectId:d,hideGroupLabel:c,renderBody:u=!0,isEmpty:f=!1,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,groupSearchDataByGroup:g,visibleSessionCount:b,sessionBatchSize:x,collapsedGroups:y,hideDirectoryControls:S,showMoreGroupSessions:m,resetGroupSessionLimit:v,mobileVariant:w,alwaysShowActions:T,activeProjectId:k,setActiveProjectIdOnly:I,setSessionSwitcherOpen:B,openNewSessionDraft:O,pinnedSessionIds:F,sessionOrderIndex:j,notifyOnSubtasks:P,onToggleCollapsedGroup:L,dragHandleProps:z,compactBodyPadding:H=!1,expandedParents:R,editingId:G,editingRowKey:_,openSidebarMenuKey:$,editTitle:E,folderRename:D,setFolderRenameDraft:C,clearFolderRename:N}=t,q=ns(Se=>d?Se.projects.find(We=>We.id===d)?.path??null:null)??i.directory??null,ee=is(Se=>Se.toggleFolderCollapse),Q=is(Se=>Se.renameFolder),he=is(Se=>Se.deleteFolder),M=is(Se=>Se.addSessionToFolder),V=le(Se=>Se.showDeletionDialog),[ie,ce]=l.useState(null),ne=l.useCallback((Se,We)=>{const K=j.get(Se.session.id),xe=j.get(We.session.id);if(K!==void 0||xe!==void 0){if(K===void 0)return 1;if(xe===void 0)return-1;if(K!==xe)return K-xe}return Kl(Se.session,We.session,F,up)},[F,j]),je=p?g.get(i):null,Ee=p?!1:y.has(a),we=oS(!i.isMain&&i.worktree?i.worktree.path:null),Me=i.isMain||i.isArchivedBucket||c?null:yt(i.directory??null),fe=i.isMain||i.isArchivedBucket||c?null:i.branch?.trim()||null,be=vp(Me,fe),ke=be?`var(--pr-${be.visualState})`:void 0,Ie=Cp(be,e),Te=be?Bl(be.provider,be.number):"",Y=be?Ie?`${Te} · ${Ie}`:Te:void 0,ue=Jr(),me=l.useMemo(()=>{const Se=i.folderScopes?.map(We=>yt(We.directory))??[yt(i.directory??null)];return[...new Set(Se.filter(We=>!!We))]},[i.directory,i.folderScopes]);l.useSyncExternalStore(l.useCallback(Se=>me.length>0?ue.subscribeBootstrap(Se):()=>{},[me.length,ue]),l.useCallback(()=>me.map(Se=>`${Se}\0${ue.getBootstrapState(Se)??""}\0${ue.getBootstrapFailure(Se)??""}\0${ue.getInitializationState(Se)??""}\0${ue.getInitializationFailure(Se)??""}`).join(""),[me,ue]),l.useCallback(()=>"",[]));const re=me.some(Se=>{const We=ue.getBootstrapState(Se);return We==="queued"||We==="running"}),pe=me.find(Se=>ue.getBootstrapState(Se)==="failed"||ue.getInitializationState(Se)==="failed")??null,U=pe!==null&&ue.getBootstrapState(pe)==="failed",ae=pe?U?ue.getBootstrapFailure(pe):ue.getInitializationFailure(pe):void 0,Re=ae==="os-permission"&&nf(),[W,ye]=l.useState(!1),de=l.useCallback(()=>{pe&&ue.requestBootstrap({directory:pe,priority:Ee?"visible":"expanded",reason:i.isMain?"project-expanded":"worktree-expanded",force:!0})},[ue,pe,i.isMain,Ee]),Ne=l.useCallback(async()=>{if(!(!pe||!Re||W)){ye(!0);try{(await rf(pe)).success&&de()}finally{ye(!1)}}},[Re,pe,W,de]),Je=x??(S?10:7),Ge=Math.max(Je,b??Je),ge=p?je?.groupMatches===!0:!1,Ae=p,Ye=l.useMemo(()=>[...Ae?je?.filteredNodes??[]:i.sessions].sort(ne),[ne,i.sessions,je?.filteredNodes,Ae]),nt=i.folderScopeKey??yt(i.directory??null),oe=lr(d,i.directory),tt=l.useMemo(()=>i.folderScopes&&i.folderScopes.length>0?i.folderScopes:nt?[{scopeKey:nt,directory:i.directory??null}]:[],[nt,i.directory,i.folderScopes]),Ue=is(hr(l.useCallback(Se=>tt.map(({scopeKey:We})=>Se.foldersMap[We]??ju),[tt]))),gt=l.useMemo(()=>tt.flatMap(({scopeKey:Se,directory:We},K)=>(Ue[K]??ju).map(Xe=>({folder:Xe,scopeKey:Se,scopeDirectory:We}))),[Ue,tt]),bt=is(hr(l.useCallback(Se=>new Set(Ue.flatMap(We=>We.filter(K=>Se.collapsedFolderIds.has(K.id)).map(K=>K.id))),[Ue]))),Ce=l.useMemo(()=>{const Se=new Map,We=K=>{K.forEach(xe=>{Se.set(xe.session.id,xe),xe.children.length>0&&We(xe.children)})};return We(Ye),Se},[Ye]),_e=l.useMemo(()=>gt.map(({folder:Se,scopeKey:We,scopeDirectory:K})=>{const xe=ll(Se.sessionIds,Ce).sort(ne);return{folder:Se,scopeKey:We,scopeDirectory:K,nodes:xe}}),[gt,Ce,ne]),ze=l.useMemo(()=>{const Se=Vh(_e.map(({folder:We,nodes:K})=>({id:We.id,name:We.name,parentId:We.parentId,nodeCount:K.length})),{archivedBucket:i.isArchivedBucket===!0,searchQuery:p?h:""});return _e.filter(({folder:We})=>Se.has(We.id))},[_e,i.isArchivedBucket,p,h]),Oe=G,it=$,X=l.useMemo(()=>new Set(ze.flatMap(Se=>Se.folder.sessionIds)),[ze]),Be=l.useMemo(()=>Ye.filter(Se=>!X.has(Se.session.id)),[Ye,X]),Le=l.useMemo(()=>{const Se=new Map(ze.map(We=>[We.folder.id,We]));return Uh(ze.map(We=>We.folder)).map(We=>Se.get(We.id)).filter(We=>!!We)},[ze]),at=l.useMemo(()=>{const Se=new Map;return ze.forEach(We=>{if(!We.folder.parentId)return;const K=Se.get(We.folder.parentId)??[];K.push(We),Se.set(We.folder.parentId,K)}),Se},[ze]),qe=l.useMemo(()=>{const Se=new Map(ze.map(xe=>[xe.folder.id,xe])),We=new Map,K=(xe,Xe)=>{const lt=We.get(xe);if(lt!==void 0)return lt;if(Xe.has(xe))return[];Xe.add(xe);const Bt=Se.get(xe),Pt=Bt?[...Bt.nodes]:[];for(const Gt of at.get(xe)??[])Pt.push(...K(Gt.folder.id,Xe));return We.set(xe,Pt),Pt};return ze.forEach(({folder:xe})=>K(xe.id,new Set)),We},[ze,at]),ut="project",dt=l.useMemo(()=>{const Se=new Set;return qd(Ye,Oe,Se),ze.forEach(({nodes:We})=>{qd(We,Oe,Se)}),Se},[Ye,ze,Oe]),ft=l.useMemo(()=>{if(!it)return null;const Se=Zo(Ye,it,ut,!!i.isArchivedBucket);if(Se)return Se;for(const{nodes:We}of ze){const K=Zo(We,it,ut,!!i.isArchivedBucket);if(K)return K}return null},[it,Ye,ze,i.isArchivedBucket]),st=l.useCallback(Se=>{const We=new WeakMap,K=xe=>{We.set(xe,Gr(xe));for(const Xe of xe.children)K(Xe)};return Se.forEach(K),We},[]),Rt=l.useMemo(()=>st(Ye),[st,Ye]),Ke=l.useMemo(()=>{const Se=new WeakMap;return ze.forEach(({nodes:We})=>{We.forEach(K=>Se.set(K,Gr(K)))}),Se},[ze]),jt=l.useCallback(Se=>Rt.get(Se)??Ke.get(Se)??"",[Rt,Ke]),Lt=l.useCallback(Se=>({subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(Se)}),[dt,ft,jt]),Mt=Be.length,De=i.isArchivedBucket||p?Be:Be.slice(0,Ge),Tt=Mt-De.length,At=!i.isArchivedBucket&&!p&&Mt>Je&&Tt===0,kt=l.useCallback(Se=>{const We=[],K=xe=>{xe.forEach(Xe=>{We.push(Xe.session),Xe.children.length>0&&K(Xe.children)})};return K(Se),We},[]),pt=l.useMemo(()=>kt(Ye),[kt,Ye]),Dt=l.useMemo(()=>{if(be||i.isMain||i.isArchivedBucket||c)return ku;const Se=new Map;for(const We of pt)for(const K of Hl(We))Se.has(K.key)||Se.set(K.key,K);return Se.size>0?[...Se.values()]:ku},[pt,i.isArchivedBucket,i.isMain,be,c]),Ve=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="github"?[zr("issue",Se)]:[]),[Dt]),rt=zo(Ve),wt=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="linear"?[Ul(Se.identifier)]:[]),[Dt]),se=kp(wt),Fe=l.useMemo(()=>Dt.flatMap(Se=>Se.source==="gitlab"?[Kr("issue",Se.ref)]:[]),[Dt]),ot=zo(Fe),$e=l.useMemo(()=>Ip(Dt,rt,se,ot).map(Se=>({...Se,text:Se.statusKey?`${Se.label} · ${e(Se.statusKey)}`:Se.statusText?`${Se.label} · ${Se.statusText}`:Se.label})),[ot,rt,Dt,se,e]),Ct=$e[0]??null,Yt=l.useMemo(()=>{if(!i.isArchivedBucket)return new Map;const Se=new Map,We=new Map;for(const{folder:xe}of ze){if(!xe.parentId)continue;const Xe=We.get(xe.parentId)??[];Xe.push(xe.id),We.set(xe.parentId,Xe)}const K=(xe,Xe)=>{if(Xe.has(xe))return[];Xe.add(xe);const lt=ze.find(({folder:Gt})=>Gt.id===xe),Bt=lt?kt(lt.nodes):[],Pt=We.get(xe)??[];for(const Gt of Pt)Bt.push(...K(Gt,Xe));return Bt};for(const{folder:xe}of ze)Se.set(xe.id,K(xe.id,new Set));return Se},[ze,kt,i.isArchivedBucket]);if(p&&!ge&&Le.length===0&&Be.length===0)return null;const es=!i.isMain&&!!i.branch,Zt=i.branch&&iS(i.branch,i.label)?{label:i.branch}:null,ss=Ee?n.jsx(jf,{nodes:Ye,includeUnreadSubtasks:P}):null,bs=(Se,We)=>{const{folder:K,scopeKey:xe,scopeDirectory:Xe,nodes:lt}=Se,Bt=Yt.get(K.id)??[],Pt=D?.folderId===K.id&&D?.scopeKey===xe,Gt=p?!1:bt.has(K.id),Ft=Wt=>n.jsx(rm,{folderId:K.id,scopeKey:xe,ownerKey:oe,children:(qt,vs)=>n.jsx(nm,{folder:K,displayName:We,sessions:lt,isCollapsed:Gt,collapsedActivityState:Wt,onToggle:()=>ee(K.id),onRename:ds=>{Q(xe,K.id,ds)},onDelete:()=>{if(i.isArchivedBucket){Tn.requestDelete({sessions:Bt,mode:"session"});return}if(!V){he(xe,K.id);return}const ds=ze.filter(({folder:Fs})=>Fs.parentId===K.id).length,bn=lt.length;ce({scopeKey:xe,folderId:K.id,folderName:K.name,subFolderCount:ds,sessionCount:bn})},groupDirectory:Xe??i.directory,projectId:d,mobileVariant:w,alwaysShowActions:T,isRenaming:Pt,renameDraft:Pt?D?.draft:void 0,onRenameDraftChange:C,onRenameSave:()=>{const ds=D?.draft.trim()??"";ds&&Q(xe,K.id,ds),N()},onRenameCancel:N,droppableRef:qt,isDropTarget:vs,depth:0,onNewSession:()=>{d&&d!==k&&I(d),w&&B(!1),O({selectedProjectId:d,directoryOverride:Xe??i.directory,targetFolderId:K.id,target:i.draftTarget})},hideActions:!1,archivedBucket:i.isArchivedBucket===!0,children:lt.map(ds=>n.jsx(ei,{node:ds,pinnedSessionIds:F,expandedParents:R,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:P,editingId:G,editingRowKey:_,editTitle:E,openSidebarMenuKey:$,mobileVariant:w,alwaysShowActions:T,groupDirectory:Xe??i.directory,projectId:d,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:i.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(ds),childRenderExtrasFor:Lt},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},ds.session.id))})},K.id);return Gt?n.jsx(PI,{nodes:qe.get(K.id)??lt,includeUnreadSubtasks:P,children:Ft},K.id):Ft(null)},ls=()=>{const Se=new Map;for(const Xe of ze){const lt=Xe.folder.parentId;if(!lt)continue;const Bt=Se.get(lt);Bt?Bt.push(Xe):Se.set(lt,[Xe])}const We=[],K=new Set,xe=(Xe,lt)=>{if(K.has(Xe.folder.id))return;K.add(Xe.folder.id);const Bt=lt?`${lt} / ${Xe.folder.name}`:Xe.folder.name;We.push(bs(Xe,Bt)),!(!p&&bt.has(Xe.folder.id))&&(Se.get(Xe.folder.id)??[]).forEach(Gt=>xe(Gt,Bt))};return Le.forEach(Xe=>xe(Xe,"")),We},ms=!!(!i.isMain&&i.worktree&&!we),fs=i.worktree?.worktreeStatus==="missing"?n.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:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,Es=i.space&&i.space.state!=="complete"&&!o?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.spaceStale"),"aria-label":e("sessions.sidebar.group.spaceStale"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,cs=ms||!!i.space,Qe=!!i.space,vt=T?Qe?"pe-20":cs?"pe-14":"pe-7":Pe("pe-2",Qe?"[--oc-actions-reserve:68px]":cs?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),$t=T?void 0:"group-hover/gh:oc-actions-mask group-has-[:focus-visible]/gh:oc-actions-mask",ve=T?void 0:"transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",ct=f?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(eo,{expanded:!Ee}),ht=Se=>n.jsx("span",{className:"relative me-1 inline-flex size-3.5 flex-shrink-0 items-center justify-center",children:f||T?Se:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex items-center justify-center transition-opacity group-hover/gh:opacity-0 group-has-[:focus-visible]/gh:opacity-0",children:Se}),n.jsx("span",{className:"absolute inset-0 inline-flex items-center justify-center text-muted-foreground opacity-0 transition-opacity group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100",children:ct})]})}),Ot=be&&Ie?[{key:`pr:${be.number}`,icon:"git-pull-request",text:`${Te} · ${Ie}`,title:be.title,color:ke,url:be.url}]:[],te=pe?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ae==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":U?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),Re?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:W,onClick:()=>{Ne()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:de,children:e("sessions.sidebar.group.empty.retry")})]}):null,et=Se=>n.jsx(ei,{node:Se,pinnedSessionIds:F,expandedParents:R,hasSessionSearchQuery:p,normalizedSessionSearchQuery:h,notifyOnSubtasks:P,editingId:G,editingRowKey:_,editTitle:E,openSidebarMenuKey:$,mobileVariant:w,alwaysShowActions:T,groupDirectory:i.directory,projectId:d,folderOwnerKey:oe,selectionScopeKey:oe,archivedBucket:i.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:dt,menuOpenSessionId:ft,nodeStructureKey:jt(Se),childRenderExtrasFor:Lt},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},Se.session.id),xt=n.jsxs(i5,{scopeKey:tt[0]?.scopeKey??nt,ownerKey:oe,hasFolders:ze.length>0,onSessionDroppedOnFolder:(Se,We)=>{const K=ze.find(({folder:Xe,scopeKey:lt})=>Xe.id===We.folderId&&lt===We.scopeKey);if(!K)return;const xe=is.getState();for(const{scopeKey:Xe}of tt)Xe!==K.scopeKey&&xe.getSessionFolderId(Xe,Se)&&xe.removeSessionFromFolder(Xe,Se);M(K.scopeKey,We.folderId,Se)},children:[ls(),De.map(et),Mt===0&&ze.length===0&&!r?!i.isArchivedBucket&&!re&&!te&&i.directory&&!i.emptyMessage?n.jsx(Nt,{variant:"link",size:"xs",className:"w-full justify-start ps-[26px] text-start font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{d&&d!==k&&I(d),w&&B(!1),O({selectedProjectId:d,directoryOverride:i.directory,target:i.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-muted-foreground",children:i.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):re?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Fo,{className:"size-3"}),e("sessions.sidebar.group.empty.loadingSessions")]}):te||(i.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Mt>0&&te?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:te}):null,Tt>0?n.jsx("button",{type:"button",onClick:()=>m(a,De.length,x??7),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,At?n.jsx("button",{type:"button",onClick:()=>v(a),className:"mt-0.5 flex items-center justify-start rounded-md ps-[26px] pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),It="pb-2",St=n.jsx(hm,{value:ie,setValue:ce,onConfirm:()=>{const Se=ie;Se&&(he(Se.scopeKey,Se.folderId),ce(null))}});return c?u?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:Pe("oc-group-body",It),children:xt})}),St]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:Pe("oc-group",we&&"opacity-60"),"aria-busy":we||void 0,children:[n.jsxs("div",{className:Pe("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[n.jsxs(Ut,{disabled:be?!Ie:!Ct,children:[n.jsx(Ht,{asChild:!0,closeDelay:lm,children:n.jsx("div",{className:"min-w-0 flex-1",...f?{}:{onClick:()=>L(a),role:"button",tabIndex:0,onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),L(a))},"aria-label":Ee?e("sessions.sidebar.group.expandAria",{label:i.label}):e("sessions.sidebar.group.collapseAria",{label:i.label}),"aria-expanded":!Ee},children:n.jsxs("div",{ref:z?.setActivatorNodeRef,style:{paddingInlineStart:Kn(0)},className:Pe("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",vt),...z?.listeners??{},children:[n.jsxs("div",{className:Pe("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",$t),children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:i.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-0.5",children:[ht(n.jsx(Z,{name:"archive",className:"h-3 w-3 shrink-0 text-muted-foreground"})),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:vo(i.label,h)}),fs,ss]}):!i.isMain||i.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[ht(we?n.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-muted-foreground",title:e("sessions.sidebar.group.worktreeRemoving"),role:"status","aria-label":e("sessions.sidebar.group.worktreeRemoving"),children:n.jsx(Fo,{className:"h-3.5 w-3.5"})}):n.jsx(Z,{name:i.space?"box-3":"git-branch",className:Pe("h-3 w-3 shrink-0",ke?"oc-ref-tint":"text-muted-foreground"),style:ke?or(ke):void 0,"aria-label":i.space?e("sessions.sidebar.group.space"):void 0})),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-medium text-foreground/85",children:vo(i.label,h)}),fs,Es,ss,be?n.jsx("button",{type:"button",className:Pe("ms-auto flex-shrink-0 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",ke&&"oc-ref-tint",ve),style:ke?or(ke):void 0,disabled:!be.url,"aria-label":Y,onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),be.url&&s(be.url,q,Se)},children:Te}):Ct?n.jsxs("button",{type:"button",className:Pe("ms-auto inline-flex flex-shrink-0 items-center gap-1 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Ct.color?"oc-ref-tint":"text-muted-foreground",ve),style:Ct.color?or(Ct.color):void 0,"aria-label":$e.map(Se=>Se.text).join(", "),onPointerDown:Se=>Se.stopPropagation(),onKeyDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),!(Se.target instanceof Element&&Se.target.closest("[data-ref-more]"))&&s(Ct.url,q,Se)},children:[n.jsx(Z,{name:Ct.icon,className:"h-3 w-3"}),Ct.label,$e.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",$e.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[ct,n.jsx("span",{className:"min-w-0 truncate",children:vo(i.label,h)}),ss]})}),es&&Zt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[i.isArchivedBucket?n.jsx(Z,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx(Z,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Zt.label})]}):null]}),!i.isArchivedBucket&&i.directory?n.jsx(Qo,{directory:i.directory,className:Pe("self-center",ve)}):null]})})}),Ot.length>0?n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Xo,{items:Ot,directory:q})}):!be&&Ct?n.jsx(Kt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Xo,{items:$e,directory:q})}):null]}),n.jsxs(bi,{delayDuration:400,children:[i.isArchivedBucket&&pt.length>0?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),Tn.requestDelete({sessions:pt,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:i.label}),children:n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,i.directory&&!i.isMain&&i.worktree&&!we?n.jsx("div",{className:Pe("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsx(NI,{label:i.label,sessions:pt,worktree:i.worktree})}):null,i.space?n.jsx("div",{className:Pe("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),i.space&&Gs.getState().openAccessDialog(i.space.id)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("spaces.group.access.giveAria",{label:i.label}),children:n.jsx(Z,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,i.space?n.jsx("div",{className:Pe("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(dy,{spaceId:i.space.id,label:i.label})}):null,i.directory?n.jsx("div",{className:Pe("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",T?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-has-[:focus-visible]/gh:opacity-100"),children:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),d&&d!==k&&I(d),w&&B(!1),O({selectedProjectId:d,directoryOverride:i.directory,preserveDirectoryOverride:!!i.space})},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:i.label}),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),i.space?n.jsx(uy,{spaceId:i.space.id,className:"pb-1 ps-2"}):null,!Ee&&u?n.jsx("div",{className:Pe("oc-group-body",It),children:xt}):null]}),St]})}const AI=l.memo(MI,RI),ja=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},OI=(t,e)=>{const s=new Set;for(const r of t)if(!r.isArchivedBucket)for(const o of r.sessions){const{session:i}=o;i.time?.archived||e(i)||s.add(i.id)}return[...s]},BI=(t,e,s)=>t.flatMap(r=>{const o=e(r);return o.some(s)?[]:[{id:r,descendantIds:o}]}),FI=(t,e)=>{const s=new Set(e),r=t.filter(({id:o,descendantIds:i})=>s.has(o)||i.some(a=>s.has(a))).length;return{archived:t.length-r,failed:r}},Cu=10,Iu=(t,e)=>wp(t.label?.trim()||di(t.normalizedPath,e)||t.normalizedPath);function _I(t){const e=Ze.c(104),{model:s,view:r,actions:o}=t;As("ui.sidebar_projects_list.render");const{t:i}=Et(),a=Jr(),{files:d}=Ks(),c=is(QI),u=is(ZI),f=is(YI),p=is(qI),h=le(GI),g=le(VI)&&!Dn(),b=aS(),[x,y]=l.useState(null),[S,m]=l.useState(null),[v,w]=l.useState(null),[T,k]=l.useState(null),[I,B]=l.useState(null),O=I?.kind==="project",F=l.useRef(null);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[0]=j):j=e[0];let P;e[1]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[1]=P):P=e[1];let L;e[2]===Symbol.for("react.memo_cache_sentinel")?(L={coordinateGetter:Ow},e[2]=L):L=e[2];const z=yi(mn(Si,j),mn(xi,P),mn(Nw,L));let H;e[3]===Symbol.for("react.memo_cache_sentinel")?(H=W=>{F.current=W,k(W)},e[3]=H):H=e[3];const R=H;let G;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let W;e[7]!==r.homeDirectory?(W=ye=>({id:ye.project.id,projectLabel:Iu(ye.project,r.homeDirectory),projectDescription:fr(ye.project.normalizedPath,r.homeDirectory),projectIcon:ye.project.icon,projectColor:ye.project.color,projectIconImage:ye.project.iconImage,projectIconBackground:ye.project.iconBackground}),e[7]=r.homeDirectory,e[8]=W):W=e[8],G=s.projectSections.map(W),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=G}else G=e[6];const _=G,$=lS(),{confirm:E}=$;let D;e[9]!==E||e[10]!==i?(D=async(W,ye)=>{const de=cS.getState().ids,Ne=BI(OI(ye,Ae=>gi(de,Ae.directory,Ae.id)||Ra(Ae.id)||Vl(Ae)),UI,Ra);if(Ne.length===0){He.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await E({title:i("sessions.sidebar.project.archiveAll.title",{project:W}),message:Ne.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ne.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ne.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{failedIds:Ge}=await mt.getState().archiveSessions(Ne.flatMap(HI)),ge=FI(Ne,Ge);ge.archived>0&&He.success(ge.archived===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:ge.archived}):i("sessions.sidebar.bulkActions.archivedPlural",{count:ge.archived})),ge.failed>0&&He.error(ge.failed===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ge.failed}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:ge.failed}))},e[9]=E,e[10]=i,e[11]=D):D=e[11];const C=D;let N;e[12]!==d||e[13]!==i?(N=W=>{d.revealPath&&d.revealPath(W).catch(()=>{He.error(i("sidebarFilesTree.toast.revealFailed"))})},e[12]=d,e[13]=i,e[14]=N):N=e[14];const A=N;let q;e[15]!==S?(q=W=>`${W.kind}:${W.id}`===S,e[15]=S,e[16]=q):q=e[16];const ee=s.rowModel.stickyHeaders.findIndex(q);let Q;if(e[17]!==v||e[18]!==s.groupProps.editingRowKey||e[19]!==s.rowModel.rowIndexByKey||e[20]!==s.rowModel.rows||e[21]!==s.rowModel.stickyHeaders||e[22]!==s.state.openSidebarMenuKey||e[23]!==ee){if(Q=new Set,v){let W;e[25]!==v||e[26]!==s.rowModel.rowIndexByKey?(W=s.rowModel.rowIndexByKey.get(v),e[25]=v,e[26]=s.rowModel.rowIndexByKey,e[27]=W):W=e[27];const ye=W;ye!==void 0&&Q.add(ye)}for(let W=0;W<s.rowModel.rows.length;W=W+1,W){const ye=s.rowModel.rows[W];ye?.kind==="session"&&(s.groupProps.editingRowKey===ye.key||s.state.openSidebarMenuKey===`session-menu:${ye.key}`||s.state.openSidebarMenuKey===`session-context:${ye.key}`)&&Q.add(W)}if(ee>=0){const W=Math.max(0,ee-1),ye=Math.min(s.rowModel.stickyHeaders.length-1,ee+1);for(let de=W;de<=ye;de=de+1,de){const Ne=s.rowModel.stickyHeaders[de];Ne&&Q.add(Ne.rowIndex)}}e[17]=v,e[18]=s.groupProps.editingRowKey,e[19]=s.rowModel.rowIndexByKey,e[20]=s.rowModel.rows,e[21]=s.rowModel.stickyHeaders,e[22]=s.state.openSidebarMenuKey,e[23]=ee,e[24]=Q}else Q=e[24];const he=Q;let M;e[28]!==s.rowModel.stickyHeaders?(M=W=>{const ye=x3(s.rowModel.stickyHeaders,W),de=ye?`${ye.kind}:${ye.id}`:null;m(Ne=>Ne===de?Ne:de)},e[28]=s.rowModel.stickyHeaders,e[29]=M):M=e[29];const V=M;let ie;e[30]!==a||e[31]!==i?(ie=W=>{const ye=()=>{if(!W.status.directory){Dp();return}a.requestBootstrap({directory:W.status.directory,priority:"expanded",reason:W.group.isMain?"project-expanded":"worktree-expanded",force:!0})},de=async()=>{if(!W.status.directory)return;(await rf(W.status.directory)).success&&ye()};let Ne;e:switch(W.status.state){case"permission-denied":{Ne=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ne=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ne=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ne=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:W.flat?Cu:Qd(W.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[W.status.state==="loading"?n.jsx(Fo,{className:"size-3"}):null,Ne,W.status.canGrantAccess?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{de()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,W.status.state!=="loading"?n.jsx(Nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:ye,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=a,e[31]=i,e[32]=ie):ie=e[32];const ce=ie;let ne;e[33]!==o||e[34]!==f||e[35]!==d||e[36]!==s.emptyState||e[37]!==s.groupProps||e[38]!==s.projectRepoStatus||e[39]!==s.searchEmptyState||e[40]!==s.singleProjectMode||e[41]!==s.state||e[42]!==A||e[43]!==b||e[44]!==_||e[45]!==u||e[46]!==ce||e[47]!==C||e[48]!==h||e[49]!==g||e[50]!==i||e[51]!==c||e[52]!==r?(ne=W=>{if(W.kind==="activity-header")return n.jsx(gm,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(mI,{activityKey:W.activityKey,collapsed:W.collapsed,forceExpanded:W.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!W.collapsed){const de=`activity:${W.activityKey}`;o.group.resetGroupSessionLimit(de),s.state.setVisibleActivityCountByKey(Ne=>{if(!Ne.has(de))return Ne;const Je=new Map(Ne);return Je.delete(de),Je})}s.state.setCollapsedActivityKeys(de=>{const Ne=new Set(de);return Ne.has(W.activityKey)?Ne.delete(W.activityKey):Ne.add(W.activityKey),Ne})},onNewChat:()=>{le.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Qg,directoryOverride:null})}})});if(W.kind==="project-header"){const de=W.section.project,Ne=Iu(de,r.homeDirectory);return n.jsx(wI,{id:de.id,disabled:s.singleProjectMode||W.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Ne,projectDescription:fr(de.normalizedPath,r.homeDirectory),projectDirectory:de.normalizedPath,projectIcon:de.icon,projectColor:de.color,projectIconImage:de.iconImage,projectIconBackground:de.iconBackground,isCollapsed:W.collapsed,isRepo:!!s.projectRepoStatus.get(de.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:W.collapsed?o.renderProjectStatusIndicator?.(de.id,W.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?_:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!W.forceExpanded&&!s.singleProjectMode&&o.toggleProject(de.id)},onNewSession:()=>{ja({projectId:de.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:de.id,directoryOverride:de.normalizedPath})},onNewWorktreeSession:()=>{ja({projectId:de.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(de.id),onManageSpaces:g?()=>le.getState().setSpacesPageProjectId(de.id):void 0,onOpenSourceBoard:b?()=>b(de.id):void 0,onOpenFolder:de.normalizedPath&&d.revealPath?()=>A(de.normalizedPath):void 0,onRenameStart:()=>o.openProjectEditDialog(de.id),onArchiveAll:()=>{C(Ne,W.section.groups)},onClose:()=>o.removeProject(de.id),showCreateButtons:!0})}if(W.kind==="group-header")return n.jsx(jI,{id:W.groupKey,disabled:W.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:de=>n.jsx(AI,{...s.groupProps,...o.group,group:W.group,groupKey:W.groupKey,projectId:W.projectId,isEmpty:W.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get(W.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:de,renderBody:!1})});if(W.kind==="folder-header"){const de=s.groupProps.folderRename?.folderId===W.folder.id&&s.groupProps.folderRename.scopeKey===W.scopeKey;return n.jsx(rm,{folderId:W.folder.id,scopeKey:W.scopeKey,ownerKey:W.ownerKey,disabled:!W.dropEnabled,children:(Ne,Je)=>n.jsx(r5,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:W.activityNodes,folder:W.folder,displayName:W.displayName,sessions:W.nodes,depth:W.depth,canExpand:!W.empty,isCollapsed:W.collapsed,onToggle:W.forceExpanded?WI:()=>c(W.folder.id),onRename:Ge=>u(W.scopeKey,W.folder.id,Ge),onDelete:()=>{W.archived?Tn.requestDelete({sessions:[...W.deleteSessions],mode:"session"}):h?y({scopeKey:W.scopeKey,folderId:W.folder.id,folderName:W.folder.name,subFolderCount:W.subFolderCount,sessionCount:W.nodes.length}):f(W.scopeKey,W.folder.id)},renderBody:!1,groupDirectory:W.scopeDirectory??W.group.directory,projectId:W.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:de,renameDraft:de?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const Ge=s.groupProps.folderRename?.draft.trim();Ge&&u(W.scopeKey,W.folder.id,Ge),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Ne,isDropTarget:Je,onNewSession:()=>{ja({projectId:W.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:W.projectId,directoryOverride:W.scopeDirectory??W.group.directory,targetFolderId:W.folder.id,target:W.group.draftTarget})},archivedBucket:W.archived})})}if(W.kind==="session"){const de=new Set;return gr(W.node,s.state.editingId)&&de.add(W.node.session.id),n.jsx("div",{onFocusCapture:()=>w(W.key),onBlurCapture:()=>w(Ne=>Ne===W.key?null:Ne),children:n.jsx(ei,{...s.groupProps,node:W.node,depth:W.depth,groupDirectory:W.groupDirectory,projectId:W.projectId,folderOwnerKey:W.ownerKey,selectionScopeKey:W.selectionScopeKey,archivedBucket:W.archived,renderContext:W.renderContext,rowKey:W.key,dragKey:W.key,secondaryMeta:W.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:de,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${W.key}`||s.state.openSidebarMenuKey===`session-context:${W.key}`?W.node.session.id:null,nodeStructureKey:W.blockingBadgeSessionScopes?`${Gr(W.node)}:${JSON.stringify(W.blockingBadgeSessionScopes)}`:Gr(W.node),blockingBadgeSessionScopes:W.blockingBadgeSessionScopes}})})}if(W.kind==="run")return n.jsx(nI,{run:W.run,depth:W.depth,laneNodes:W.laneNodes,blockingSessionIds:W.blockingSessionIds,renderContext:W.renderContext,projectId:W.projectId,projectLabel:W.projectLabel,expansionKey:W.expansionKey,expanded:W.expanded,forceExpanded:W.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const ye=W.kind==="show-control"&&W.flat===!0?Cu:Qd(W.kind==="show-control"||W.kind==="empty"?W.depth??0:0);return W.kind==="show-control"?n.jsx("div",{children:n.jsx("button",{type:"button",className:"mt-0.5 flex items-center justify-start rounded-md pe-1.5 py-0.5 text-start text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",style:{paddingInlineStart:ye},onClick:()=>{W.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(de=>{const Ne=new Map(de);return W.control==="more"?Ne.set(W.containerKey,W.currentCount+W.increment):Ne.delete(W.containerKey),Ne}):W.control==="more"?o.group.showMoreGroupSessions(W.containerKey,W.currentCount,W.increment):o.group.resetGroupSessionLimit(W.containerKey)},children:i(W.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):W.kind==="status"?ce(W):W.emptyKind==="sidebar"?s.emptyState:W.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:ye},children:i("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=o,e[34]=f,e[35]=d,e[36]=s.emptyState,e[37]=s.groupProps,e[38]=s.projectRepoStatus,e[39]=s.searchEmptyState,e[40]=s.singleProjectMode,e[41]=s.state,e[42]=A,e[43]=b,e[44]=_,e[45]=u,e[46]=ce,e[47]=C,e[48]=h,e[49]=g,e[50]=i,e[51]=c,e[52]=r,e[53]=ne):ne=e[53];const je=ne;let Ee;if(e[54]!==I||e[55]!==s.rowModel.rows){let W;e[57]!==I?(W=ye=>ye.kind==="project-header"?I?.kind==="group"?[]:[ye.section.project.id]:ye.kind!=="group-header"?[]:I?.kind==="project"?[]:I?.kind==="group"&&ye.projectId!==I.projectId?[]:[ye.groupKey],e[57]=I,e[58]=W):W=e[58],Ee=s.rowModel.rows.flatMap(W),e[54]=I,e[55]=s.rowModel.rows,e[56]=Ee}else Ee=e[56];const we=Ee;let Me;e[59]!==s.sectionsForRender?(Me=new Set(s.sectionsForRender.map(KI)),e[59]=s.sectionsForRender,e[60]=Me):Me=e[60];const fe=Me;let be;e[61]!==s.rowModel.stickyHeaders?(be=s.rowModel.stickyHeaders.map(zI).join(""),e[61]=s.rowModel.stickyHeaders,e[62]=be):be=e[62];const ke=be;let Ie;e[63]!==s.rowModel.rows||e[64]!==fe?(Ie=W=>{const ye=String(W.active.id);if(fe.has(ye)){B({kind:"project"});return}const de=s.rowModel.rows.find(Ne=>Ne.kind==="group-header"&&Ne.groupKey===ye);B(de?{kind:"group",projectId:de.projectId}:null)},e[63]=s.rowModel.rows,e[64]=fe,e[65]=Ie):Ie=e[65];let Te;e[66]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>B(null),e[66]=Te):Te=e[66];let Y;e[67]!==o||e[68]!==p||e[69]!==s.rowModel.folderAuthorityByOwner||e[70]!==s.rowModel.folderDropTargets||e[71]!==s.rowModel.rows||e[72]!==s.sectionsForRender||e[73]!==s.state||e[74]!==r?(Y=W=>{if(B(null),!W.over)return;const ye=W.active.data.current,de=W.over.data.current;if(ye?.type==="session"&&ye.sessionId&&ye.ownerKey&&ye.archivedBucket!==!0&&de?.type==="folder"&&de.folderId&&de.scopeKey&&de.ownerKey===ye.ownerKey){const bt=s.rowModel.folderDropTargets.find(ze=>ze.folderId===de.folderId&&ze.scopeKey===de.scopeKey&&ze.ownerKey===ye.ownerKey),Ce=s.rowModel.folderAuthorityByOwner.get(ye.ownerKey);if(!bt?.enabled||Ce?.complete!==!0)return;const _e=is.getState();for(const ze of Ce.scopeKeys)ze!==de.scopeKey&&_e.removeSessionFromFolder(ze,ye.sessionId);p(de.scopeKey,de.folderId,ye.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||W.active.id===W.over.id)return;const Ne=String(W.active.id),Je=String(W.over.id),Ge=s.sectionsForRender.map($I),ge=Ge.indexOf(Ne),Ae=Ge.indexOf(Je);if(ge>=0&&Ae>=0&&r.projectSortOrder==="manual"){o.reorderProjects(ge,Ae);return}const Ye=s.rowModel.rows.find(bt=>bt.kind==="group-header"&&bt.groupKey===Ne),nt=s.rowModel.rows.find(bt=>bt.kind==="group-header"&&bt.groupKey===Je);if(!Ye||!nt||Ye.projectId!==nt.projectId||!Ye.projectId)return;const oe=Ye.projectId,tt=s.sectionsForRender.find(bt=>bt.project.id===oe);if(!tt)return;const Ue=tt.groups.findIndex(bt=>bt.id===Ye.group.id),gt=tt.groups.findIndex(bt=>bt.id===nt.group.id);Ue<0||gt<0||o.setGroupOrderByProject(bt=>new Map(bt).set(oe,$p(tt.groups,Ue,gt).map(LI)))},e[67]=o,e[68]=p,e[69]=s.rowModel.folderAuthorityByOwner,e[70]=s.rowModel.folderDropTargets,e[71]=s.rowModel.rows,e[72]=s.sectionsForRender,e[73]=s.state,e[74]=r,e[75]=Y):Y=e[75];let ue;e[76]!==V||e[77]!==s.rowModel||e[78]!==he||e[79]!==je||e[80]!==T?(ue=n.jsx(fI,{model:s.rowModel,scrollElement:T,pinnedRowIndexes:he,renderRow:je,onFirstVisibleIndexChange:V}),e[76]=V,e[77]=s.rowModel,e[78]=he,e[79]=je,e[80]=T,e[81]=ue):ue=e[81];let me;e[82]!==we||e[83]!==ue?(me=n.jsx(Gl,{items:we,strategy:zp,children:ue}),e[82]=we,e[83]=ue,e[84]=me):me=e[84];let re;e[85]!==z||e[86]!==Ie||e[87]!==Y||e[88]!==me?(re=n.jsx(Qr,{ref:R,useScrollShadow:!0,hideTopScrollShadow:!0,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 ps-2.5 pe-2 [overflow-anchor:none]",children:n.jsx(wi,{sensors:z,collisionDetection:vi,onDragStart:Ie,onDragCancel:Te,onDragEnd:Y,children:me})}),e[85]=z,e[86]=Ie,e[87]=Y,e[88]=me,e[89]=re):re=e[89];let pe;e[90]!==O||e[91]!==re||e[92]!==ke?(pe=n.jsx(gI,{suspended:O,layoutKey:ke,scrollRef:F,children:re}),e[90]=O,e[91]=re,e[92]=ke,e[93]=pe):pe=e[93];let U;e[94]!==f||e[95]!==x?(U=()=>{x&&(f(x.scopeKey,x.folderId),y(null))},e[94]=f,e[95]=x,e[96]=U):U=e[96];let ae;e[97]!==x||e[98]!==U?(ae=n.jsx(hm,{value:x,setValue:y,onConfirm:U}),e[97]=x,e[98]=U,e[99]=ae):ae=e[99];let Re;return e[100]!==$.dialog||e[101]!==pe||e[102]!==ae?(Re=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[pe,ae,$.dialog]}),e[100]=$.dialog,e[101]=pe,e[102]=ae,e[103]=Re):Re=e[103],Re}function LI(t){return t.id}function $I(t){return t.project.id}function zI(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function KI(t){return t.project.id}function WI(){}function HI(t){const{id:e,descendantIds:s}=t;return[e,...s]}function UI(t){return wl(t,[],!1)}function VI(t){return t.isolatedSpacesEnabled}function GI(t){return t.showDeletionDialog}function qI(t){return t.addSessionToFolder}function YI(t){return t.deleteFolder}function ZI(t){return t.renameFolder}function QI(t){return t.toggleFolderCollapse}const XI=l.memo(_I),pl=new Map,Pu=(t,e)=>{for(const s of t){const r=yt(s??null);r&&!pl.has(r)&&pl.set(r,e)}},Eu=t=>{const e=yt(t??null);return e?pl.get(e)??0:0},Ir=t=>!!t.time?.archived,JI=(t,e)=>{if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const[s,r]of e)if(t.get(s)?.scopeDirectory!==r.scopeDirectory)return!1;return!0},eP=t=>{const{t:e}=Et(),s=l.useRef(t.gitBranches);s.current=t.gitBranches;const r=l.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const o=l.useRef(t.sessionOwners),i=l.useMemo(()=>(JI(o.current,t.sessionOwners)||(o.current=t.sessionOwners),o.current),[t.sessionOwners]),a=l.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),d=l.useCallback(f=>{const p=yt(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${p}`.toLowerCase()},[e]),c=l.useCallback((f,p)=>{if(!p)return f;const h=p.trim().toLowerCase(),g=h.startsWith("ses_");return f.flatMap(b=>{if(g&&Ir(b.session))return[];if(g?b.session.id.toLowerCase()===h:$o([d(b.session)],p))return[b];const y=c(b.children,p);return y.length===0?[]:[{...b,children:y}]})},[d]),u=l.useCallback((f,p,h,g,b)=>{const x=yt(p??null),y=xp(f),S=new Map(y.map(N=>[N.id,N])),m=new Map;y.forEach(N=>{const A=N.parentID;if(!A)return;const q=S.get(A);if(!q||Ir(q)||Ir(N))return;const ee=m.get(A)??[];ee.push(N),m.set(A,ee)});const v=dS(h,x),w=(x&&!t.isVSCode?t.spacesByProject?.get(x):void 0)??[],T=new Map;for(const N of w){const A=yt(N.directory);A&&T.set(A,N)}const k=N=>{const A=yt(N.directory??null),q=t.worktreeMetadata.get(N.id)??null;if(q)return q;if(A){const ee=ta(A,v);if(ee&&A!==x)return ee}return null},I=new Set,B=N=>{I.add(N.id);const A=m.get(N.id)??[],q=[];for(const ee of A)I.has(ee.id)||q.push(B(ee));return{session:N,children:q,worktree:k(N)}},O=N=>{const A=N.parentID;if(!A)return!1;if(Ir(N))return!0;const q=S.get(A);return!!(q&&Ir(q))},F=y.filter(N=>{const A=N.parentID;return A?!S.has(A)&&!O(N):!0}),j=[],P=N=>{I.has(N.id)||j.push(B(N))};F.forEach(P),y.forEach(N=>{O(N)||P(N)});const L=new Map,z="__archived__",H=N=>{if(N.time?.archived)return z;if(t.isVSCode||t.runKeyBySessionId?.has(N.id))return x??"__project_root__";const A=i?.get(N.id)?.scopeDirectory;if(A){if(A===x)return x??"__project_root__";if(T.has(A))return A;const he=ta(A,v);if(he)return yt(he.path)??he.path}const ee=yt(t.worktreeMetadata.get(N.id)?.path??null)??ur(N);if(!ee||ee===x)return x??"__project_root__";const Q=ta(ee,v);return Q?yt(Q.path)??Q.path:x??"__project_root__"};j.forEach(N=>{const A=H(N.session);L.has(A)||L.set(A,[]),L.get(A)?.push(N)});const R=x??"__project_root__",G=[{id:"root",label:b&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:x?fr(x,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:x,folderScopeKey:x,sessions:L.get(R)??[]}],_=new Map;h.forEach(N=>{const A=yt(N.path)??N.path,q=L.get(A)??[],ee=q.length>0,Q=q.reduce((he,M)=>{const V=uS(M.session,r.current);return Number.isFinite(V)?Math.max(he,V):he},0);_.set(A,{hasActiveSession:ee,lastUpdatedAt:Q})});const $=(N,A)=>{const q=(N.label||N.branch||N.name||N.path||"").toLowerCase(),ee=(A.label||A.branch||A.name||A.path||"").toLowerCase();return q.localeCompare(ee)},E=t.worktreeSortOrder!=="recent"?[...h].sort($):[...h].sort((N,A)=>{const q=yt(N.path)??N.path,ee=yt(A.path)??A.path,Q=_.get(q)??{hasActiveSession:!1,lastUpdatedAt:0},he=_.get(ee)??{hasActiveSession:!1,lastUpdatedAt:0};if(Q.hasActiveSession!==he.hasActiveSession)return Q.hasActiveSession?-1:1;if(Q.hasActiveSession&&he.hasActiveSession)return he.lastUpdatedAt-Q.lastUpdatedAt;const M=Eu(N.path),V=Eu(A.path);return M!==V?V-M:$(N,A)});(t.isVSCode?[]:E).forEach(N=>{const A=yt(N.path)??N.path,q=s.current.get(A)?.trim()||null,ee=N.branch?.trim()||null,Q=fS(N,q,di(A,t.homeDirectory)||A);G.push({id:`worktree:${A}`,label:Q,branch:q||ee,description:fr(A,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:N,directory:A,folderScopeKey:A,sessions:L.get(A)??[]})});for(const[N,A]of T)G.push({id:`space:${A.id}`,label:A.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:A,directory:N,folderScopeKey:N,sessions:L.get(N)??[]});const C=L.get(z)??[];return C.length>0&&G.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&x?yp(x):null,sessions:C}),G},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,i,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:a,buildSessionSearchText:d,filterSessionNodesForSearch:c,buildGroupedSessions:u}},tP=t=>{const e=Ze.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:a,onCreateFolderAndMove:d,onRemoveFromFolder:c,canRemoveFromFolder:u,onRestore:f,onArchive:p,onDelete:h,onDone:g}=t,{t:b}=Et(),x=s>0,y=x&&!!r&&!i;let S;e[0]!==s||e[1]!==b?(S=b("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=b,e[2]=S):S=e[2];let m;e[3]!==S?(m=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:S}),e[3]=S,e[4]=m):m=e[4];let v;e[5]!==y||e[6]!==u||e[7]!==d||e[8]!==a||e[9]!==c||e[10]!==o||e[11]!==b?(v=y?n.jsxs(Rs,{children:[n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.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":b("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx(Z,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Ms,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(rs,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(C=>n.jsx(rs,{onClick:()=>a(C.id),children:n.jsx("span",{className:"flex-1 truncate",children:C.name})},C.id)),n.jsx(In,{}),n.jsxs(rs,{onClick:d,children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(rs,{onClick:c,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=y,e[6]=u,e[7]=d,e[8]=a,e[9]=c,e[10]=o,e[11]=b,e[12]=v):v=e[12];let w;e[13]!==i||e[14]!==x||e[15]!==f||e[16]!==b?(w=i?n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.restore"),children:n.jsx(Z,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=x,e[15]=f,e[16]=b,e[17]=w):w=e[17];let T;e[18]!==i||e[19]!==x||e[20]!==p||e[21]!==b?(T=i?null:n.jsxs(Ut,{children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:p,disabled:!x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.archive"),children:n.jsx(Z,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=x,e[20]=p,e[21]=b,e[22]=T):T=e[22];const k=!x;let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=Pe("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]=I):I=e[23];let B;e[24]!==b?(B=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=B):B=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(Z,{name:"delete-bin",className:"h-4 w-4"}),e[26]=O):O=e[26];let F;e[27]!==h||e[28]!==k||e[29]!==B?(F=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,disabled:k,className:I,"aria-label":B,children:O})}),e[27]=h,e[28]=k,e[29]=B,e[30]=F):F=e[30];let j;e[31]!==b?(j=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=j):j=e[32];let P;e[33]!==j?(P=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:j})}),e[33]=j,e[34]=P):P=e[34];let L;e[35]!==F||e[36]!==P?(L=n.jsxs(Ut,{children:[F,P]}),e[35]=F,e[36]=P,e[37]=L):L=e[37];let z;e[38]!==b?(z=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=z):z=e[39];let H;e[40]===Symbol.for("react.memo_cache_sentinel")?(H=n.jsx(Z,{name:"close",className:"h-4 w-4"}),e[40]=H):H=e[40];let R;e[41]!==g||e[42]!==z?(R=n.jsx(Ht,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":z,children:H})}),e[41]=g,e[42]=z,e[43]=R):R=e[43];let G;e[44]!==b?(G=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=G):G=e[45];let _;e[46]!==G?(_=n.jsx(Kt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:G})}),e[46]=G,e[47]=_):_=e[47];let $;e[48]!==R||e[49]!==_?($=n.jsxs(Ut,{children:[R,_]}),e[48]=R,e[49]=_,e[50]=$):$=e[50];let E;e[51]!==L||e[52]!==$||e[53]!==v||e[54]!==w||e[55]!==T?(E=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[v,w,T,L,$]}),e[51]=L,e[52]=$,e[53]=v,e[54]=w,e[55]=T,e[56]=E):E=e[56];let D;return e[57]!==m||e[58]!==E?(D=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[m,E]}),e[57]=m,e[58]=E,e[59]=D):D=e[59],D},Tu=new Map,sP=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},nP=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||am(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},rP=t=>{const e=Ze.c(89),{t:s}=Et();let r;e[0]!==s?(r=re=>{const pe=pS(re);return pe?{description:vf(pe,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:a,foldersMap:d,getFolderScopesForProject:c,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:p,archiveSessions:h,unarchiveSessions:g,deleteSessions:b,bulkDeleteConfirm:x,setBulkDeleteConfirm:y}=t,S=xs(oP),m=xs(iP),v=m>0,w=xs(aP),T=xs(lP),k=im(),I=cP,B=dP;let O;e[2]!==v||e[3]!==k||e[4]!==w?(O=v&&am(w,k?.getSessionsById()??Tu),e[2]=v,e[3]=k,e[4]=w,e[5]=O):O=e[5];const F=O;let j;e:{if(T){j=T;break e}j=null}const P=j;let L;e[6]!==P||e[7]!==c?(L=sP(P,c),e[6]=P,e[7]=c,e[8]=L):L=e[8];const z=L;let H;if(e[9]!==d||e[10]!==z){let re;e[12]!==d?(re=pe=>d[pe]??[],e[12]=d,e[13]=re):re=e[13],H=z.flatMap(re),e[9]=d,e[10]=z,e[11]=H}else H=e[11];const R=H;let G;e[14]!==d||e[15]!==z?(G=re=>{for(const pe of z)if((d[pe]??[]).some(U=>U.id===re))return pe;return null},e[14]=d,e[15]=z,e[16]=G):G=e[16];const _=G;let $;e:{if(!v){$=!1;break e}for(const re of z)for(const pe of d[re]??[])for(const U of pe.sessionIds)if(w.has(U)){$=!0;break e}$=!1}const E=$;let D;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==z?(D=(re,pe)=>{const U=Array.from(w);for(const ae of z)ae!==re&&f(ae,U);u(re,pe,U)},e[17]=u,e[18]=f,e[19]=w,e[20]=z,e[21]=D):D=e[21];const C=D;let N;e[22]!==v||e[23]!==C||e[24]!==_?(N=re=>{if(!v)return;const pe=_(re);pe&&C(pe,re)},e[22]=v,e[23]=C,e[24]=_,e[25]=N):N=e[25];const A=N;let q;e[26]!==p||e[27]!==v||e[28]!==C||e[29]!==z?(q=()=>{const re=z[0];if(!re||!v)return;const pe=p(re);pe&&C(re,pe.id)},e[26]=p,e[27]=v,e[28]=C,e[29]=z,e[30]=q):q=e[30];const ee=q;let Q;e[31]!==v||e[32]!==f||e[33]!==w||e[34]!==z?(Q=()=>{if(!v)return;const re=Array.from(w);for(const pe of z)f(pe,re)},e[31]=v,e[32]=f,e[33]=w,e[34]=z,e[35]=Q):Q=e[35];const he=Q;let M;e[36]!==h||e[37]!==b||e[38]!==o||e[39]!==s?(M=async(re,pe)=>{if(re.length!==0)if(pe){const{deletedIds:U,failedIds:ae}=await b(re);U.length>0&&He.success(U.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:U.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:U.length})),ae.length>0&&He.error(ae.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ae.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:ae.length}),o(ae)),xs.getState().removeMany(U)}else{const{archivedIds:U,failedIds:ae}=await h(re);U.length>0&&He.success(U.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:U.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:U.length})),ae.length>0&&He.error(ae.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:ae.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:ae.length}),o(ae)),xs.getState().removeMany(U)}},e[36]=h,e[37]=b,e[38]=o,e[39]=s,e[40]=M):M=e[40];const V=M;let ie;e[41]!==V||e[42]!==v||e[43]!==w||e[44]!==y||e[45]!==a?(ie=re=>{if(!v)return;const pe=Array.from(w);if(!a){V(pe,re);return}y({sessionIds:pe,sessionCount:pe.length,archivedBucket:re})},e[41]=V,e[42]=v,e[43]=w,e[44]=y,e[45]=a,e[46]=ie):ie=e[46];const ce=ie;let ne;e[47]!==F||e[48]!==ce?(ne=()=>ce(F),e[47]=F,e[48]=ce,e[49]=ne):ne=e[49];const je=ne;let Ee;e[50]!==ce?(Ee=()=>ce(!1),e[50]=ce,e[51]=Ee):Ee=e[51];const we=Ee;let Me;e[52]!==ce?(Me=()=>ce(!0),e[52]=ce,e[53]=Me):Me=e[53];const fe=Me;let be;e[54]!==F||e[55]!==o||e[56]!==v||e[57]!==w||e[58]!==s||e[59]!==g?(be=async()=>{if(!v||!F)return;const re=Array.from(w),{restoredIds:pe,failedIds:U}=await g(re);pe.length>0&&He.success(pe.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:pe.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:pe.length})),U.length>0&&He.error(U.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:U.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:U.length}),o(U)),xs.getState().removeMany(pe)},e[54]=F,e[55]=o,e[56]=v,e[57]=w,e[58]=s,e[59]=g,e[60]=be):be=e[60];const ke=be;let Ie;e[61]!==x||e[62]!==V||e[63]!==k||e[64]!==y?(Ie=async()=>{if(!x)return;const re=k?.getSessionsById()??Tu,pe=nP(x,re);if(!pe.ready){y(pe.value);return}y(null),await V(pe.value.sessionIds,pe.value.archivedBucket)},e[61]=x,e[62]=V,e[63]=k,e[64]=y,e[65]=Ie):Ie=e[65];const Te=Ie;let Y,ue;e[66]!==x||e[67]!==je||e[68]!==i||e[69]!==k||e[70]!==S?(Y=()=>{if(!S)return;const re=/Macintosh|Mac OS X/.test(navigator.userAgent||""),pe=U=>{if(x||i)return;const ae=U.target instanceof HTMLElement?U.target:null;if(ae&&(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable))return;const Re=re?U.metaKey:U.ctrlKey;if(U.key==="Escape"){U.preventDefault(),xs.getState().disable();return}if(Re&&U.key==="Backspace"){U.preventDefault(),je();return}if(Re&&(U.key==="a"||U.key==="A")){const W=l5(k?.getEntries()??[],k?.getDescendantIds()??[],xs.getState().scopeKey);if(!W)return;U.preventDefault(),xs.getState().replaceAll(W.ids,W.scopeKey)}};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},ue=[x,je,i,k,S],e[66]=x,e[67]=je,e[68]=i,e[69]=k,e[70]=S,e[71]=Y,e[72]=ue):(Y=e[71],ue=e[72]),l.useEffect(Y,ue);let me;return e[73]!==E||e[74]!==R||e[75]!==F||e[76]!==Te||e[77]!==P||e[78]!==we||e[79]!==ee||e[80]!==je||e[81]!==fe||e[82]!==A||e[83]!==he||e[84]!==ke||e[85]!==v||e[86]!==m||e[87]!==S?(me={selectionModeEnabled:S,hasSelection:v,selectedIdsSize:m,bulkScopeIsArchived:F,derivedSelectionScope:P,bulkScopeFolders:R,bulkCanRemoveFromFolder:E,handleToggleSelectionMode:I,handleExitSelectionMode:B,handleBulkMoveToFolder:A,handleBulkCreateFolderAndMove:ee,handleBulkRemoveFromFolder:he,handleBulkDelete:je,handleBulkArchive:we,handleBulkHardDelete:fe,handleBulkRestore:ke,confirmBulkDelete:Te},e[73]=E,e[74]=R,e[75]=F,e[76]=Te,e[77]=P,e[78]=we,e[79]=ee,e[80]=je,e[81]=fe,e[82]=A,e[83]=he,e[84]=ke,e[85]=v,e[86]=m,e[87]=S,e[88]=me):me=e[88],me};function oP(t){return t.enabled}function iP(t){return t.selectedIds.size}function aP(t){return t.selectedIds}function lP(t){return t.scopeKey}function cP(){xs.getState().toggleMode()}function dP(){xs.getState().disable()}function uP(t){const e=Ze.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,a]=l.useState(null),d=le(SP),c=le(xP),u=is(yP),f=is(bP),p=is(gP),h=is(mP),g=mt(hP),b=mt(pP),x=mt(fP);let y;e[0]!==f||e[1]!==o?(y=k=>{const I=f(k,"New folder");return o(k,I),I},e[0]=f,e[1]=o,e[2]=y):y=e[2];let S;e[3]!==p||e[4]!==g||e[5]!==i||e[6]!==x||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==h||e[11]!==d||e[12]!==y||e[13]!==b?(S={isInlineEditing:r,showDeletionDialog:d,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:p,removeSessionsFromFolders:h,createFolderAndStartRename:y,archiveSessions:g,unarchiveSessions:b,deleteSessions:x,bulkDeleteConfirm:i,setBulkDeleteConfirm:a},e[3]=p,e[4]=g,e[5]=i,e[6]=x,e[7]=u,e[8]=s,e[9]=r,e[10]=h,e[11]=d,e[12]=y,e[13]=b,e[14]=S):S=e[14];const m=rP(S);let v;e[15]!==m.bulkCanRemoveFromFolder||e[16]!==m.bulkScopeFolders||e[17]!==m.bulkScopeIsArchived||e[18]!==m.derivedSelectionScope||e[19]!==m.handleBulkArchive||e[20]!==m.handleBulkCreateFolderAndMove||e[21]!==m.handleBulkHardDelete||e[22]!==m.handleBulkMoveToFolder||e[23]!==m.handleBulkRemoveFromFolder||e[24]!==m.handleBulkRestore||e[25]!==m.handleExitSelectionMode||e[26]!==m.selectedIdsSize||e[27]!==m.selectionModeEnabled?(v=m.selectionModeEnabled?n.jsx(tP,{selectedCount:m.selectedIdsSize,scopeKey:m.derivedSelectionScope,scopeFolders:m.bulkScopeFolders,archivedBucket:m.bulkScopeIsArchived,onMoveToFolder:m.handleBulkMoveToFolder,onCreateFolderAndMove:m.handleBulkCreateFolderAndMove,onRemoveFromFolder:m.handleBulkRemoveFromFolder,canRemoveFromFolder:m.bulkCanRemoveFromFolder,onRestore:m.handleBulkRestore,onArchive:m.handleBulkArchive,onDelete:m.handleBulkHardDelete,onDone:m.handleExitSelectionMode}):null,e[15]=m.bulkCanRemoveFromFolder,e[16]=m.bulkScopeFolders,e[17]=m.bulkScopeIsArchived,e[18]=m.derivedSelectionScope,e[19]=m.handleBulkArchive,e[20]=m.handleBulkCreateFolderAndMove,e[21]=m.handleBulkHardDelete,e[22]=m.handleBulkMoveToFolder,e[23]=m.handleBulkRemoveFromFolder,e[24]=m.handleBulkRestore,e[25]=m.handleExitSelectionMode,e[26]=m.selectedIdsSize,e[27]=m.selectionModeEnabled,e[28]=v):v=e[28];let w;e[29]!==m.confirmBulkDelete||e[30]!==i||e[31]!==c||e[32]!==d?(w=n.jsx(U5,{value:i,setValue:a,showDeletionDialog:d,setShowDeletionDialog:c,onConfirm:m.confirmBulkDelete}),e[29]=m.confirmBulkDelete,e[30]=i,e[31]=c,e[32]=d,e[33]=w):w=e[33];let T;return e[34]!==v||e[35]!==w?(T=n.jsxs(n.Fragment,{children:[v,w]}),e[34]=v,e[35]=w,e[36]=T):T=e[36],T}function fP(t){return t.deleteSessions}function pP(t){return t.unarchiveSessions}function hP(t){return t.archiveSessions}function mP(t){return t.removeSessionsFromFolders}function gP(t){return t.addSessionsToFolder}function bP(t){return t.createFolder}function yP(t){return t.foldersMap}function xP(t){return t.setShowDeletionDialog}function SP(t){return t.showDeletionDialog}const bm="oc.sessions.expandedParents.v3",wP=Ci(zs()),vP=()=>{try{const t=globalThis.localStorage.getItem(bm);if(t===null)return new Set;const e=wP.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},jP=()=>{const[t,e]=l.useState(vP),s=l.useRef(t);s.current=t;const r=l.useCallback(o=>{const i=hS(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(bm,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},kP=t=>{const e=Ze.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,a=Os(CP),d=Os(IP);let c;e[0]!==o||e[1]!==r?(c=[...r.flatMap(PP),...o?[{key:"activity:chats",group:o}]:[]].map(DP),e[0]=o,e[1]=r,e[2]=c):c=e[2];const u=c;let f;e[3]!==u?(f=new Set(u.flatMap(RP)),e[3]=u,e[4]=f):f=e[4];let p;e[5]!==f?(p=[...f],e[5]=f,e[6]=p):p=e[6];const h=p;let g;e[7]!==s||e[8]!==h.length?(g=v=>h.length>0?s.subscribeBootstrap(v):NP,e[7]=s,e[8]=h.length,e[9]=g):g=e[9];let b;e[10]!==s||e[11]!==h?(b=()=>h.map(v=>`${v}\0${s.getBootstrapState(v)??""}\0${s.getBootstrapFailure(v)??""}\0${s.getInitializationState(v)??""}\0${s.getInitializationFailure(v)??""}`).join(""),e[10]=s,e[11]=h,e[12]=b):b=e[12];const x=l.useSyncExternalStore(g,b,MP);let y;if(e[13]!==i||e[14]!==s||e[15]!==a||e[16]!==u||e[17]!==d){y=new Map;for(const{key:v,archived:w,directories:T}of u){const k=T.find(I=>s.getBootstrapState(I)==="failed"||s.getInitializationState(I)==="failed");if(k){const I=s.getBootstrapState(k)==="failed",B=I?s.getBootstrapFailure(k):s.getInitializationFailure(k);y.set(v,{state:B==="os-permission"?"permission-denied":I?"load-failed":"initialization-failed",directory:k,canGrantAccess:B==="os-permission"&&i})}else{const I=d||!w&&T.length>0&&T.every(B=>s.getBootstrapState(B)==="complete");y.set(v,{state:I?"ready":a==="error"?"load-failed":"loading",directory:I?T[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=a,e[16]=u,e[17]=d,e[18]=y}else y=e[18];const S=y;let m;return e[19]!==x||e[20]!==S?(m={groupStatusByKey:S,bootstrapSnapshot:x},e[19]=x,e[20]=S,e[21]=m):m=e[21],m};function CP(t){return t.status}function IP(t){return t.hasLoaded}function PP(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function EP(t){return yt(t.directory)}function TP(t){return!!t}function DP(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:zn(s).map(EP).filter(TP)}}function RP(t){return t.directories}function NP(){}function MP(){return""}const AP=6e4,OP=[],Du=[],Ru={pinned:[],work:[]},BP=t=>!t.parentID,FP=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:a,...d}=s,c=is(ve=>ve.foldersMap),u=is(ve=>ve.collapsedFolderIds),f=is(ve=>ve.createFolder),p=is(ve=>ve.addSessionToFolder),h=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:b,toggleGroup:x,toggleProject:y,setCollapsedActivities:S}=i,m=mS({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),v=gS(ve=>ve.projects),w=Xg(),T=l.useMemo(()=>new Map(w.map(ve=>[ve.id,ve.name])),[w]),k=l.useMemo(()=>{const ve=new Map;for(const ct of w){const ht=yt(ct.projectDirectory);if(!ht)continue;const Ot=ve.get(ht);Ot?Ot.push(ct):ve.set(ht,[ct])}return ve},[w]),I=l.useMemo(()=>bS(m.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,m.archivedSessions,v,w),[v,m.archivedSessions,m.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[B,O]=l.useState(new Map),[F,j]=l.useState(new Map),P=l.useCallback((ve,ct,ht=7)=>{O(Ot=>new Map(Ot).set(ve,ct+ht))},[]),L=l.useCallback(ve=>{O(ct=>{if(!ct.has(ve))return ct;const ht=new Map(ct);return ht.delete(ve),ht})},[]);l.useEffect(()=>{O(ve=>{if(ve.size===0)return ve;const ct=te=>h.collapsedGroups.has(te)||[...h.collapsedProjects].some(et=>te===Jh(et)||te.startsWith(`${et}:`)),ht=[...ve.keys()].filter(ct);if(ht.length===0)return ve;const Ot=new Map(ve);for(const te of ht)Ot.delete(te);return Ot})},[h.collapsedGroups,h.collapsedProjects]);const z=ts(ve=>ve.showChatsSection),H=ts(ve=>ve.projectDisplayMode),R=ts(ve=>ve.singleProjectId),G=ts(ve=>ve.setSingleProjectId),$=!t.isVSCode&&!Jg()&&H==="single",E=e.sidebarViewMode==="timeline"&&!t.isVSCode,D=ts(ve=>ve.listSessionGrouping),C=E&&D==="time",N=l.useMemo(()=>yS(m.rootSessions,ve=>yt(t.worktreeMetadata.get(ve.id)?.projectDirectory??ve.directory??null)),[m.rootSessions,t.worktreeMetadata]),A=l.useRef(null),q=l.useMemo(()=>{const ve=Array.from(N.runKeyBySessionId,([ct,ht])=>`${ct}\0${ht}`).sort().join("");return A.current?.signature!==ve&&(A.current={signature:ve,map:N.runKeyBySessionId}),A.current.map},[N]),[ee,Q]=l.useState(null),[he,M]=l.useState(null),[V,ie]=l.useState(""),[ce,ne]=l.useState(null),[je,Ee]=l.useState(null),[we,Me]=l.useState(null),fe=l.useCallback((ve,ct)=>{Me({scopeKey:ve,folderId:ct.id,draft:ct.name})},[]),be=l.useCallback(ve=>{Me(ct=>ct?{...ct,draft:ve}:null)},[]),ke=l.useCallback(()=>Me(null),[]),{expandedParents:Ie,toggleParent:Te}=jP(),Y=mt(ve=>ve.setCurrentSession),ue=l.useCallback((ve,ct)=>{ve!==mt.getState().currentSessionId&&Y(ve,ct)},[Y]),me=Pp(),re=ts(ve=>ve.worktreeSortOrder),{buildGroupedSessions:pe,filterSessionNodesForSearch:U,buildGroupSearchText:ae}=eP({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:m.pinnedSessionIds,sessionOrderRanks:m.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:re,sessionOwners:I.bySessionId,spacesByProject:k,runKeyBySessionId:q}),{getSessionsForProject:Re,getArchivedSessionsForProject:W}=A4({ownership:I}),ye=xS(),de=l.useMemo(()=>{if(t.isVSCode)return null;const ve=ye??m.chatSessions.map(ht=>xl(ht.directory)).find(Boolean)??null;if(!ve)return null;const ct=Array.from(new Set([ve,...m.chatSessions.map(ht=>yt(ht.directory??null)).filter(Boolean)])).filter(ht=>!!ht).map(ht=>({scopeKey:ht,directory:ht}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:ve,folderScopeKey:ve,folderScopes:ct,draftTarget:"chat",sessions:m.chatSessions.filter(ht=>!ht.time?.archived&&BP(ht)).map(ht=>Gn(m.childrenMap,ht))}},[m.chatSessions,m.childrenMap,ye,t.isVSCode]),Ne=l.useMemo(()=>de?[de]:OP,[de]),{projectSections:Je,groupSearchDataByGroup:Ge,sectionsForRender:ge,flatSectionsForRender:Ae}=L4({normalizedProjects:t.projects,getSessionsForProject:Re,getArchivedSessionsForProject:W,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:m.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:pe,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:U,buildGroupSearchText:ae,foldersMap:c,standaloneGroups:Ne}),Ye=e.onSearchMatchCountChange;l.useEffect(()=>()=>Ye(0),[Ye]);const nt=Jr(),oe=e.useGroupedSections?ge:Ae,tt=l.useMemo(()=>e.showInlineArchived?oe:oe.map(ve=>ve.groups.some(ct=>ct.isArchivedBucket)?{...ve,groups:ve.groups.filter(ct=>!ct.isArchivedBucket)}:ve),[oe,e.showInlineArchived]),Ue=l.useCallback(ve=>Ae.find(ht=>ht.project.id===ve)?.groups.find(ht=>!ht.isArchivedBucket)?.folderScopes??[],[Ae]);P4({enabled:!0,normalizedProjects:t.projects,ownership:I,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:m.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:c,createFolder:f,addSessionToFolder:p});const{sourceControl:gt}=Ks(),bt=ys(ve=>ve.ensureEntry),Ce=ys(ve=>ve.setParams),_e=ys(ve=>ve.refreshTargets),ze=ys(ve=>ve.clearDirectoryStatus),Oe=ys(ve=>ve.beginActiveContextsLoad),it=ys(ve=>ve.commitActiveContexts),X=ys(ve=>ve.releaseActiveContexts),Be=ys(ve=>ve.activeContextRegistrations),Le=l.useId(),at=l.useRef(new Set),qe=l.useRef(new Map),ut=l.useMemo(()=>new Map(m.orderedSessions.map((ve,ct)=>[ve.id,ct])),[m.orderedSessions]),[dt,ft]=l.useState(null),st=l.useRef([]),Rt=e.projectSortOrder==="recent";l.useEffect(()=>{Rt||ft(null)},[Rt]);const Ke=l.useMemo(()=>{const ve=re!=="manual"?tt:tt.map(ht=>{const Ot=g(ht.project.id,ht.groups);return Ot===ht.groups?ht:{...ht,groups:Ot}}),ct=SS(ve,e.projectSortOrder,ht=>ht.project.id,I.sessionsByProject);return[...dt&&Rt?wS(ct,dt,ht=>ht.project.id):ct]},[g,dt,Rt,I.sessionsByProject,tt,e.projectSortOrder,re]);l.useEffect(()=>{st.current=Ke.map(ve=>ve.project.id)},[Ke]);const jt=l.useMemo(()=>{if(!E)return Du;const ve=new Set(m.rootSessions.map(et=>et.id)),ct=m.orderedSessions.filter(et=>ve.has(et.id)&&!et.time?.archived),ht=new Map,Ot=$c({sessions:ct,projects:t.projects,ownerBySessionId:I.bySessionId,spaceLabelById:T,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return Xd({sessions:ct,getSessionLocation:et=>Ot.get(et)??null,getSessionNode:et=>{const xt=Gn(m.childrenMap,et),It=Ot.get(et.id);return ht.set(et.id,al(xt,!1,It?.groupDirectory??et.directory??null)),{...xt,children:[],worktree:It?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(et=>({...et,blockingBadgeSessionScopes:ht.get(et.node.session.id)}))},[m.childrenMap,m.orderedSessions,m.rootSessions,I.bySessionId,T,E,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Lt=le(ve=>ve.sessionWorkEnabled),Mt=ts(ve=>ve.showWorkSection),De=ts(ve=>ve.showPinnedSection),Tt=ts(ve=>ve.detailedZoneRows),At=!E&&!Tt,kt=l.useMemo(()=>{const ve=Lt&&Mt;if(!ve&&!De)return Ru;const ct=[],ht=[];for(const Ot of m.orderedSessions)Ot.parentID||Ot.time?.archived||yl(Ot.directory)||(De&&gi(m.pinnedSessionIds,Ot.directory,Ot.id)?ct.push(Ot):ve&&Vl(Ot)&&ht.push(Ot));return ct.length===0&&ht.length===0?Ru:{pinned:ct,work:ht}},[m.orderedSessions,m.pinnedSessionIds,Lt,De,Mt]),pt=kt.work,Dt=l.useMemo(()=>new Set([...kt.pinned,...kt.work].map(ve=>ve.id)),[kt]),Ve=l.useCallback(ve=>{if(ve.length===0)return Du;const ct=$c({sessions:[...ve],projects:t.projects,ownerBySessionId:I.bySessionId,spaceLabelById:T,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),ht=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ot=new Map,te=new Map(ve.map(St=>[St.id,Gn(m.childrenMap,St)])),et=new Map(ve.map(St=>{const Se=te.get(St.id)??Gn(m.childrenMap,St),We=ct.get(St.id)?.worktree??null;if(At){const xe=ht?Yh(Se,ht)??Se:Se;return[St.id,{...xe,worktree:We}]}Ot.set(St.id,al(Se,!1,ct.get(St.id)?.groupDirectory??St.directory??null));const K={...Se,children:[],worktree:We};return[St.id,K]})),xt=c3(ve,St=>te.get(St.id)??Gn(m.childrenMap,St),ht,E?"session":"tree");return Xd({sessions:xt.sessions,getSessionLocation:St=>ct.get(St)??null,getSessionNode:St=>et.get(St.id)??Gn(m.childrenMap,St),query:""}).map(St=>({...St,blockingBadgeSessionScopes:Ot.get(St.node.session.id),searchMatchCount:xt.matchCountById.get(St.node.session.id)}))},[E,At,m.childrenMap,I.bySessionId,T,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),rt=l.useMemo(()=>Ve(kt.pinned),[Ve,kt.pinned]),wt=l.useMemo(()=>Ve(kt.work),[Ve,kt.work]),se=l.useMemo(()=>{const ve=new Map,ct=new Map,ht=new Map,Ot=new Map,te=new Set,et=(It,St)=>{const Se=St?.trim();It&&Se&&ve.set(kS(It,Se),{directory:It,branch:Se})},xt=It=>{if(et(yt(It.worktree?.path??null),It.worktree?.branch),!t.isVSCode){for(const St of jp(It.session))ct.set(`${St.owner.toLowerCase()}/${St.repo.toLowerCase()}#${St.number}`,{owner:St.owner,repo:St.repo,number:St.number});for(const St of Hl(It.session))St.source==="github"?ht.set(`${St.owner.toLowerCase()}/${St.repo.toLowerCase()}#${St.number}`,{owner:St.owner,repo:St.repo,number:St.number}):St.source==="linear"&&te.add(St.identifier.toUpperCase());for(const St of jS(It.session))Ot.set(St.key,St)}It.children.forEach(xt)};return rt.forEach(It=>xt(It.node)),wt.forEach(It=>xt(It.node)),C?(h.collapsedActivities.has("timeline")||jt.forEach(It=>xt(It.node)),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]}):E?(jt.forEach(It=>{(!It.projectId||!h.collapsedProjects.has(It.projectId))&&xt(It.node)}),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]}):(Je.forEach(It=>{h.collapsedProjects.has(It.project.id)||It.groups.forEach(St=>{if(St.isArchivedBucket||(St.sessions.forEach(xt),St.isMain))return;const Se=yt(St.directory??null);et(Se,St.branch?.trim()||t.gitBranches.get(Se||""))})}),{targets:ve,linkedRefs:[...ct.values()],linkedIssueRefs:[...ht.values()],linearIdentifiers:[...te],gitlabRefs:[...Ot.values()]})},[rt,Je,h.collapsedActivities,h.collapsedProjects,C,jt,E,t.gitBranches,t.isVSCode,wt]),Fe=se.targets,ot=l.useRef(null),$e=l.useMemo(()=>{const ve=I4(Fe.values()),ct=JSON.stringify(ve);return ot.current?.signature!==ct&&(ot.current={signature:ct,candidates:ve}),ot.current.candidates},[Fe]);l.useEffect(()=>{const ve=$e,ct=Jt(),ht=new Set(ve.map(We=>We.directory));if(iu(qe.current,ct,ht,(We,K)=>X(We,K,Le)),ve.length===0)return;let Ot=!1;const te=async(We,K=AP)=>{const xe=Date.now(),Xe=new Map,lt=Ft=>{const Wt=Xe.get(Ft);if(Wt)return Wt;const qt=Oe(ct,Ft,Le),vs=Mn.scope(Ft),ds=Nr(()=>Mn.read(vs,gt)).then(bn=>{if(Ot||ct!==Jt())return null;const Fs=bn.contexts[0],Xs=Fs&&Aa(kn.getState().entries[er(Fs)],Fs).connected?[Fs]:[];return it(ct,Ft,Le,qt,Xs)?(Xs.length===0&&ze(Ft),Xs):null});return Xe.set(Ft,ds),ds},Bt=await Promise.all(ve.filter(Ft=>!We||Ft.directory===We).map(async Ft=>(await lt(Ft.directory)??[]).map(qt=>({...Ft,context:qt}))));if(Ot||ct!==Jt())return;const Pt=new Map,Gt=new Map;for(const Ft of Bt.flat()){const Wt=Qf(Ft.context,Ft.branch);Gt.set(Wt,{context:Ft.context,branch:Ft.branch});const qt=ys.getState().entries[Wt],vs=qt?.status?.changeRequest??qt?.status?.pr,ds=vs?.state,Fs=!!vs&&!(ds==="closed"||ds==="merged"),Xs=Math.max(qt?.lastRefreshAt??0,qt?.lastDiscoveryPollAt??0),_s=!!(qt?.isInitialStatusResolved&&!Fs&&(!at.current.has(Wt)||xe-Xs>=K));(!qt||!qt.isInitialStatusResolved||_s)&&(_s&&at.current.add(Wt),Pt.has(Wt)||Pt.set(Wt,{context:Ft.context,branch:Ft.branch}))}Gt.forEach((Ft,Wt)=>{bt(Wt),Ce(Wt,{directory:Ft.context.directory,branch:Ft.branch,remoteName:Ft.context.primaryRemote,canShow:!0,identity:Ft.context,readContext:Ft.context,sourceControl:gt,authChecked:!0,connected:!0})}),Pt.size!==0&&await _e([...Pt.values()],{silent:!0,markInitialResolved:!0})},et=[...new Set(ve.map(We=>We.directory))].map(We=>Mn.scope(We)),xt=et.map(We=>{let K=Mn.snapshot(We);return Mn.subscribe(We,()=>{const xe=Mn.snapshot(We),Xe=K.read!==null&&K!==xe;K=xe,Xe&&!Ot&&te(We.directory)})}),It=kn.subscribe((We,K)=>{if(!(Ot||ct!==Jt()||We.entries===K.entries))for(const xe of et){const Xe=Mn.snapshot(xe).contexts[0];if(!Xe)continue;const lt=er(Xe);We.entries[lt]!==K.entries[lt]&&te(xe.directory)}});te();const St=En(We=>{!Ot&&We.type==="source-control-activity"&&ht.has(We.directory)&&te(We.directory,0)}),Se=()=>{!Ot&&document.visibilityState==="visible"&&te()};return document.addEventListener("visibilitychange",Se),()=>{Ot=!0,It(),xt.forEach(We=>We()),St(),document.removeEventListener("visibilitychange",Se)}},[Oe,ze,it,$e,bt,_e,X,Ce,gt,Le]),l.useEffect(()=>()=>iu(qe.current,Jt(),new Set,(ve,ct)=>X(ve,ct,Le)),[X,Le]);const Ct=l.useMemo(()=>vS(Be,Fe.values()),[Be,Fe]),Yt=Jf(Ct),es=l.useMemo(()=>[...Yt,...se.linkedRefs.map(ve=>zr("pull",ve)),...se.linkedIssueRefs.map(ve=>zr("issue",ve)),...se.gitlabRefs.map(ve=>ve.thread==="pull"?Kr("pull",ve):Kr("issue",ve)),...se.linearIdentifiers.map(Ul)],[Yt,se]);Xf(es);const{groupStatusByKey:Zt,bootstrapSnapshot:ss}=kP({childStores:nt,sections:Ke,chatGroup:de,canGrantAccess:nf()});let bs=null;$&&(Je.some(ve=>ve.project.id===R)?bs=R:Je.some(ve=>ve.project.id===e.activeProjectId)?bs=e.activeProjectId:bs=Je[0]?.project.id??null);const ls=l.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ge,collapsedGroups:h.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:ut,expandedParents:Ie,editingId:ee,editingRowKey:he,editTitle:V,sessionBatchSize:$&&!e.useGroupedSections?20:void 0,setEditingId:Q,setEditingRowKey:M,setEditTitle:ie,toggleParent:Te,allowReselect:a.allowReselect,onSessionSelected:a.onSessionSelected,resetSessionSearch:a.resetSessionSearch,deleteSessionConfirm:je,setDeleteSessionConfirm:Ee,startFolderRename:fe,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:we,setFolderRenameDraft:be,clearFolderRename:ke}),[m.pinnedSessionIds,r,o,h.collapsedGroups,Ge,ut,V,ee,he,Ie,we,be,ke,fe,je,s.startSessionWorktreeMenuLoad,a,Te,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,$]),ms=l.useMemo(()=>({showMoreGroupSessions:P,resetGroupSessionLimit:L,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,onToggleCollapsedGroup:x}),[L,P,x,d.openNewSessionDraft,d.setActiveProjectIdOnly,d.setSessionSwitcherOpen]),fs=l.useMemo(()=>{const ve=new Map;for(const ct of Ke)for(const ht of ct.groups){const Ot=lr(ct.project.id,ht.directory);if(!Ot)continue;const te=zn(ht),et=ve.get(Ot),xt=[...new Set([...et?.scopeKeys??[],...te.map(St=>St.scopeKey)])],It=m.hasAuthoritativeGlobalSessions&&te.every(St=>{const Se=yt(St.directory);return!Se||nt.getBootstrapState(Se)==="complete"});ve.set(Ot,{scopeKeys:xt,complete:(et?.complete??!0)&&It})}if(de){const ct=lr(null,de.directory);ct&&ve.set(ct,{scopeKeys:zn(de).map(ht=>ht.scopeKey),complete:m.hasAuthoritativeGlobalSessions})}return ve},[ss,de,nt,m.hasAuthoritativeGlobalSessions,Ke]),Es=l.useMemo(()=>new Map([...B,...F]),[F,B]),cs=l.useMemo(()=>S3({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:E?"timeline":"projects",listGrouping:D,sections:Ke,authoritativeSections:Je,chatGroup:z?de:null,timelineItems:jt,pinnedItems:rt,workItems:wt,zoneSessionIds:Dt,detailedZoneRows:Tt,foldersMap:c,groupSearchDataByGroup:Ge,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:h.collapsedProjects,collapsedGroups:h.collapsedGroups,collapsedFolders:u,collapsedActivities:h.collapsedActivities,expandedParents:Ie,visibleCountByContainer:Es,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:ut,groupStatusByKey:Zt,folderAuthorityByOwner:fs,activeProjectId:e.activeProjectId,singleProjectMode:$&&!E,singleProjectId:bs,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:$&&!e.useGroupedSections?20:void 0,runIndex:N}),[N,de,z,h.collapsedActivities,jt,E,D,rt,wt,Dt,Tt,u,m.pinnedSessionIds,Ie,fs,c,Ge,Zt,Ke,Je,h.collapsedGroups,h.collapsedProjects,bs,ut,$,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Es]);l.useEffect(()=>{Ye(cs.searchMatchCount)},[Ye,cs.searchMatchCount]),l.useEffect(()=>{if(e.hasSessionSearchQuery)return;const ve=is.getState().toggleFolderCollapse;for(const ct of cs.rows)ct.kind==="group-header"&&ct.empty&&h.collapsedGroups.has(ct.groupKey)?x(ct.groupKey):ct.kind==="folder-header"&&ct.empty&&u.has(ct.folder.id)&&ve(ct.folder.id)},[u,h.collapsedGroups,cs.rows,x,e.hasSessionSearchQuery]);const Qe=l.useMemo(()=>({rowModel:cs,sectionsForRender:Ke,projectSections:Je,singleProjectMode:$,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ee,openSidebarMenuKey:ce,setOpenSidebarMenuKey:ne,visibleSessionCountByGroup:B,collapsedActivityKeys:h.collapsedActivities,setCollapsedActivityKeys:S,visibleActivityCountByKey:F,setVisibleActivityCountByKey:j},groupProps:ls}),[ls,ee,ce,Je,Ke,cs,t.projectRepoStatus,e.emptyState,e.searchEmptyState,B,F,h.collapsedActivities,S,$]),vt=l.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:re}),[re,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),$t=l.useMemo(()=>({group:ms,toggleProject:y,setActiveProjectIdOnly:d.setActiveProjectIdOnly,setSessionSwitcherOpen:d.setSessionSwitcherOpen,openNewSessionDraft:d.openNewSessionDraft,openNewWorktreeDialog:d.openNewWorktreeDialog,openWorktreesPage:d.openWorktreesPage,openProjectEditDialog:d.openProjectEditDialog,removeProject:d.removeProject,reorderProjects:d.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:d.renderProjectStatusIndicator,setSingleProjectId:G}),[ms,d.openNewSessionDraft,d.openNewWorktreeDialog,d.openProjectEditDialog,d.openWorktreesPage,d.removeProject,d.reorderProjects,d.setActiveProjectIdOnly,d.setSessionSwitcherOpen,b,y,d.renderProjectStatusIndicator,G]);return n.jsxs(n.Fragment,{children:[n.jsx(w4,{}),n.jsx(R4,{projectSections:Je,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:I.bySessionId,handleSessionSelect:ue}),n.jsx(U4,{sortedSessions:m.orderedSessions,workSessions:pt,prefetchSession:me,children:n.jsxs(a5,{entries:cs.selectionEntries,descendantIds:cs.selectionDescendantIds,sessionsById:cs.sessionById,children:[n.jsx(uP,{getFolderScopesForProject:Ue,isInlineEditing:ee!==null,startFolderRename:fe}),n.jsx("div",{className:"contents",onPointerEnter:ve=>{Rt&&ve.pointerType==="mouse"&&ft(st.current)},onPointerLeave:()=>ft(null),children:n.jsx(XI,{model:Qe,view:vt,actions:$t})})]})})]})},_P=t=>{const e=Ze.c(3),[s,r]=l.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let o;return e[0]!==t||e[1]!==s?(o=s?n.jsx(FP,{...t}):null,e[0]=t,e[1]=s,e[2]=o):o=e[2],o},ym=(t,e,s)=>{const r=new Set;for(const o of t){const i=yt(o.path);i&&r.add(i)}if(s?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const a=yt(i.path);a&&r.add(a)}return r},Nu="oc.sessions.activeSessionByProject",LP=Wr(zs(),zs().min(1).catch("")),$P=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{Pa("react.session_sidebar_render"),As("ui.session_sidebar.render"),As(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),As(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:a}=Et(),[d,c]=l.useState(!1),[u,f]=l.useState(""),p=l.useCallback(()=>c(!0),[]),h=l.useCallback(()=>{f(""),c(!1)},[]),[g,b]=l.useState(0),x=l.useRef(null),y=l.useRef(null),[S,m]=l.useState(null),v=l.useMemo(()=>Oo(),[]),[w,T]=l.useState(new Map),k=le(De=>De.isNewWorktreeDialogOpen),I=le(De=>De.setNewWorktreeDialogOpen),[B,O]=l.useState(!1),F=l.useMemo(()=>{try{const De=v.getItem(Nu);if(!De)return new Map;const Tt=LP.safeParse(JSON.parse(De));if(!Tt.success)return new Map;const At=new Map;return Object.entries(Tt.data).forEach(([kt,pt])=>{pt&&At.set(kt,pt)}),At}catch{return new Map}},[v]),j=l.useCallback(De=>{try{v.setItem(Nu,JSON.stringify(Object.fromEntries(De.entries())))}catch{}},[v]),[P,L]=l.useState(new Map),z=Ps(De=>De.homeDirectory),H=ns(De=>De.projects),R=ns(De=>De.activeProjectId),G=ns(De=>De.removeProject),_=ns(De=>De.setActiveProjectIdOnly),$=ns(De=>De.updateProjectMeta),E=ns(De=>De.reorderProjects),D=le(De=>De.setSettingsDialogOpen),C=le(De=>De.toggleHelpDialog),N=le(De=>De.setAboutDialogOpen),A=le(De=>De.setSessionSwitcherOpen),q=le(De=>De.setWorktreesPageProjectId),ee=le(De=>De.notifyOnSubtasks),Q=l.useMemo(()=>u.trim().toLowerCase(),[u]),he=Q.length>0;JC({enabled:t,isSessionSearchOpen:d,openSessionSearch:p,closeSessionSearch:h,sessionSearchInputRef:y,sessionSearchContainerRef:x});const M=CS(t),V=l.useMemo(()=>Dn(),[]),ie=mt(De=>De.worktreeMetadata),ce=mt(De=>De.availableWorktreesByProject),ne=mt(De=>De.openNewSessionDraft),je=l.useMemo(()=>ym(H,ce,{includeWorktrees:!V}),[ce,V,H]),Ee=l.useCallback(De=>{le.getState().closeMainSurfaces(),ne(De),V&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[V,ne]),we=Rr(hr(De=>({checkForUpdates:De.checkForUpdates,available:De.available,runtimeType:De.runtimeType,info:De.info,downloading:De.downloading,downloaded:De.downloaded,installing:De.installing,progress:De.progress,error:De.error,downloadUpdate:De.downloadUpdate,restartToUpdate:De.restartToUpdate}))),Me=Jt(),fe=l.useMemo(()=>`${Me}|${H.map(De=>`${De.id}:${yt(De.path)??""}`).join("|")}`,[H,Me]),[be,ke]=l.useState(V?fe:null),[Ie,Te]=l.useReducer(De=>De+1,0),Y=!V&&be!==fe,[ue,me]=l.useState(new Set),re=l.useRef(ue);re.current=ue;const pe=ps(De=>De.isConnected),U=l.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});l.useEffect(()=>{let De=!1;return(async()=>{const At=Me,kt=ps.getState().isConnected,pt=ns.getState().projects;if(mt.setState({worktreeDiscoveryByProject:new Map(pt.map($e=>[yt($e.path)??$e.path,"loading"]))}),pt.length===0||V){De||(U.current={runtimeKey:null,revision:0,worktreesByProject:new Map},me(new Set),ke(fe));return}const Dt=mt.getState().availableWorktreesByProject,Ve=oc({rawWorktreesByProjectRef:U,publishedWorktreesByProject:Dt,runtimeKey:At}),rt=Ve.revision,wt=new Map(Ve.worktreesByProject),se=new Set;if(await Nr(()=>Promise.all(pt.map(async $e=>{const Ct=yt($e.path);if(Ct)try{if(!(Cn.getState().directories.get(Ct)?.isGitRepo??await Nf(Ct))){wt.delete(Ct);return}const Zt=await ed({id:$e.id,path:Ct});if(De)return;Zt.length===0?wt.delete(Ct):wt.set(Ct,Zt)}catch{se.add(Ct)}}))),De||Jt()!==At)return;const Fe=new Set(pt.map($e=>yt($e.path)).filter(Boolean));for(const $e of wt.keys())Fe.has($e)||wt.delete($e);I5({rawWorktreesByProjectRef:U,runtimeKey:At,capturedRevision:rt,nextRawWorktreesByProject:wt,publishedWorktreesByProject:Dt,partitionWorktreesByRegisteredProject:Jc,projects:pt,worktreeMapsEqual:Xc,recordWorktreesSeen:Pu,publishTopology:$e=>{mt.setState($e)},requestRediscovery:()=>{Te()},now:()=>Date.now()})&&(me(se),mt.setState({worktreeDiscoveryByProject:new Map(pt.map($e=>{const Ct=yt($e.path)??$e.path;return[Ct,se.has(Ct)?"error":"ready"]}))}),ke(fe),se.size>0&&!kt&&ps.getState().isConnected&&Te())})(),()=>{De=!0}},[V,fe,Me,Ie]),l.useEffect(()=>{pe&&re.current.size>0&&Te()},[pe]);const ae=l.useMemo(()=>hn(),[]),{isTablet:Re}=Rn(),W=e||Re,ye=l.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noSessions.description")})]}),[a]),de=l.useMemo(()=>H.find(De=>De.id===S)??null,[H,S]),Ne=l.useCallback(De=>{S&&$(S,{label:De.label,icon:De.icon,color:De.color,iconBackground:De.iconBackground,defaultAgent:De.defaultAgent??null,defaultModel:De.defaultModel??null,defaultVariant:De.defaultVariant??null})},[S,$]),Je=l.useCallback(()=>{I(!0)},[I]),Ge=l.useCallback(()=>{const De=Rr.getState();if(De.available&&De.info){O(!0);return}we.checkForUpdates().then(()=>{const{available:Tt,error:At}=Rr.getState();if(At){He.error(a("sessions.sidebar.updateCheck.errorTitle"),{description:At});return}if(!Tt){He.success(a("sessions.sidebar.updateCheck.latestVersion"));return}O(!0)})},[a,we]),ge=l.useCallback(()=>{e&&A(!1),D(!0)},[e,A,D]),Ae=we.available&&(we.runtimeType==="desktop"||we.runtimeType==="web"),Ye=l.useCallback(()=>{Tn.requestDirectoryDialog()},[]),nt=l.useMemo(()=>H.flatMap(De=>{const Tt=yt(De.path);return Tt?[{id:De.id,path:De.path,label:De.label,normalizedPath:Tt,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}]:[]}),[H]),oe=l.useMemo(()=>nt.map(De=>De.normalizedPath),[nt]),tt=IS(oe,t);E3({enabled:t,normalizedProjects:nt,gitRepoStatus:tt,setProjectRepoStatus:T,setProjectRootBranches:L});const Ue=mt(De=>De.isLoading),gt=l.useRef(!1);R&&w.has(R)&&(gt.current=!!w.get(R));const bt=ts(De=>De.showArchivedSessions),Ce=ts(De=>De.projectSortOrder),_e=ts(De=>De.sidebarViewMode),ze=V?"projects":_e,Oe=ze==="timeline"?"manual":Ce,it=ns(De=>De.manualProjectOrder),X={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:a,isTablet:Re,projects:H,activeProjectId:R,manualProjectOrder:it,worktreeMetadata:ie,availableWorktreesByProject:ce,gitBranches:M,gitRepoStatus:tt,updateStore:we,showArchivedSessions:bt,projectSortOrder:Oe,projectRepoStatus:w,projectRootBranches:P,resolvedWorktreeTopologyKey:be,unresolvedWorktreeProjectPaths:ue,isSessionSearchOpen:d,sessionSearchQuery:u,editingProjectDialogId:S,updateDialogOpen:B},Be=l.useRef(null),Le=Be.current;if(Le){let De=!1;for(const Tt of Object.keys(X))Object.is(Le[Tt],X[Tt])||(As(`ui.session_sidebar.source.${Tt}`),De=!0);De||As("ui.session_sidebar.source.parent_or_context")}Be.current=X;const at=l.useMemo(()=>PS(nt,Oe,it),[nt,Oe,it]),qe=v3({isVSCode:V,projects:at}),ut=l.useMemo(()=>n.jsx(x4,{query:u,showArchive:!V,resetSessionSearch:h}),[V,h,u]),dt=V&&bt,ft=!V,Ke=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 w-4",Lt=l.useMemo(()=>({projects:H,getCurrentProjects:()=>ns.getState().projects,rawWorktreesByProjectRef:U,getPublishedWorktreesByProject:()=>mt.getState().availableWorktreesByProject,resolveProject:De=>Na(De),listProjectWorktrees:ed,partitionWorktreesByRegisteredProject:Jc,worktreeMapsEqual:Xc,recordWorktreesSeen:Pu,publishTopology:De=>{mt.setState(De)},getRuntimeKey:Jt,now:()=>Date.now()}),[H]),Mt=l.useCallback(De=>{const Tt=pm(De,{projects:H,resolveProject:Na});return C5(De,{...Lt,projectRootBranch:Tt?P.get(Tt.id)??null:null})},[P,H,Lt]);return l.useEffect(()=>{if(V)return;const De=Tt=>{for(const At of Tt){const kt=yt(At.path),pt=Jt(),Dt=Ve=>{!kt||Jt()!==pt||mt.setState(rt=>({worktreeDiscoveryByProject:new Map(rt.worktreeDiscoveryByProject).set(kt,Ve)}))};Dt("loading"),um(At,null,Lt).then(()=>{!kt||Jt()!==pt||(Dt("ready"),me(Ve=>{if(!Ve.has(kt))return Ve;const rt=new Set(Ve);return rt.delete(kt),rt}))}).catch(()=>{!kt||Jt()!==pt||(Dt("error"),me(Ve=>new Set(Ve).add(kt)))})}};return En(Tt=>{if(Tt.type==="session-created"){const At=ES(Tt.directory,ns.getState().projects);if(!At){Te();return}De([At]);return}Tt.type==="worktree-changed"&&De(TS(Tt.directories))})},[V,Lt]),n.jsx(bi,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:x,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(_3,{hideDirectoryControls:o,showProjectDisplayControls:!V,showSectionControls:!V,handleOpenDirectoryDialog:Ye,showSourceBoard:!e&&!V,headerActionIconClass:jt,headerActionButtonClass:Ke,isSessionSearchOpen:d,openSessionSearch:p,closeSessionSearch:h,sessionSearchInputRef:y,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:he,searchMatchCount:g,collapseAll:qe.actions.collapseAll,expandAll:qe.actions.expandAll}),n.jsx(_P,{topology:{projects:at,availableWorktreesByProject:ce,knownDirectories:je,isVSCode:V,worktreeMetadata:ie,gitBranches:M,projectRepoStatus:w,projectRootBranches:P,lastRepoStatus:gt.current},view:{isVisible:t,hasSessionSearchQuery:he,normalizedSessionSearchQuery:Q,activeProjectId:R,showInlineArchived:dt,useGroupedSections:ft,homeDirectory:z,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:ae,projectSortOrder:Oe,sidebarViewMode:ze,emptyState:ye,searchEmptyState:ut,isSessionsLoading:Ue,isWorktreeTopologyLoading:Y,unresolvedWorktreeProjectPaths:ue,projectView:qe.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:h},alwaysShowActions:W,notifyOnSubtasks:ee,setActiveProjectIdOnly:_,setSessionSwitcherOpen:A,openNewSessionDraft:Ee,openNewWorktreeDialog:Je,openWorktreesPage:De=>{e&&A(!1),q(De)},openProjectEditDialog:m,removeProject:G,reorderProjects:E,startSessionWorktreeMenuLoad:Mt,initialActiveSessionByProject:F,persistActiveSessionByProject:j,projectViewActions:qe.actions}}),n.jsx(b4,{onOpenSettings:ge,onOpenShortcuts:C,onOpenAbout:()=>N(!0),onOpenUpdate:Ge,showRuntimeButtons:!V,showUpdateButton:Ae}),n.jsx(jl,{open:B,onOpenChange:O,info:we.info,downloading:we.downloading,downloaded:we.downloaded,installing:we.installing,progress:we.progress,error:we.error,onDownload:we.downloadUpdate,onRestart:we.restartToUpdate,runtimeType:we.runtimeType}),n.jsx(O3,{open:!!de,onOpenChange:De=>{De||m(null)},project:de,onSave:Ne}),n.jsx(DS,{open:k,onOpenChange:I,onWorktreeCreated:De=>{le.getState().closeMainSurfaces(),e&&A(!1),ne({directoryOverride:De,preserveDirectoryOverride:!0})}})]})})},zP=l.memo($P),ln=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Us=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},KP=()=>{const{t}=Et(),{git:e,sourceControl:s}=Ks(),[r,o]=l.useState(!1),[i,a]=l.useState(null),[d,c]=l.useState([]),[u,f]=l.useState(!1),[p,h]=l.useState(!1),[g,b]=l.useState(!1),[x,y]=l.useState(!1),[S,m]=l.useState(new Set),v=mt(Y=>Y.getWorktreeMetadata),w=mt(Y=>Y.newSessionDraft),T=mt(Y=>Y.setNewSessionDraftTarget),k=mt(Y=>Y.setDraftBootstrapPendingDirectory),I=RS,B=MS,O=mt(Y=>Y.deleteSessions),F=mt(Y=>Y.archiveSessions),j=le(Y=>Y.showDeletionDialog),P=le(Y=>Y.setShowDeletionDialog),L=Ps(Y=>Y.currentDirectory),z=Ps(Y=>Y.homeDirectory),H=ns(Y=>Y.projects),R=ns(Y=>Y.activeProjectId),{isMobile:G,isTablet:_,hasTouchInput:$}=Rn(),E=G||_||$,D=l.useMemo(()=>{const ue=(R?H.find(me=>me.id===R)??null:null)?.path??L;return Us(ue)},[R,L,H]),C=l.useCallback(Y=>{const me=Us(Y.projectDirectory)||D;return{id:(H.find(pe=>Us(pe.path)===me)??null)?.id??`path:${me}`,path:me}},[D,H]),N=x&&S.size>0,A=l.useMemo(()=>{const Y=i?.worktree;return Y&&typeof Y.branch=="string"&&Y.branch.trim().length>0?!!Y.status?.upstream?.split("/")[0]?.trim():d.length>0&&d.every(({metadata:ue})=>typeof ue.branch=="string"&&ue.branch.trim().length>0&&!!ue.status?.upstream?.split("/")[0]?.trim())},[i?.worktree,d]),q=i?.mode==="worktree",ee=g||!q||!A,Q=g||!q,he=l.useCallback(Y=>{a({sessions:Y.sessions,dateLabel:Y.dateLabel,mode:Y.mode??"session",worktree:Y.worktree??null})},[]),M=l.useCallback(()=>{a(null),c([]),f(!1),h(!1),b(!1),y(!1),m(new Set)},[]),V=l.useCallback(async Y=>{if(Y.sessions.length===0)return;if(Y.sessions.length===1){const pe=Y.sessions[0];await I(pe.id)?He.success(t("sessions.sidebar.session.delete.success")):He.error(t("sessions.sidebar.session.delete.error"));return}const ue=Y.sessions.map(pe=>pe.id),{deletedIds:me,failedIds:re}=await O(ue);if(me.length>0){const pe=re.length>0?re.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:re.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:re.length}):Y.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Y.dateLabel}):void 0;He.success(me.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:me.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:me.length}),{description:ln(pe)})}re.length>0&&He.error(re.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:re.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:re.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[I,O,t]);l.useEffect(()=>Tn.onDirectoryRequest(()=>{o(!0)}),[]),l.useEffect(()=>{if(!i){c([]),f(!1),h(!1),y(!1),m(new Set);return}const Y=i.sessions.map(re=>{const pe=v(re.id);return pe?{session:re,metadata:pe}:null}).filter(re=>!!re);c(Y),f(!1),y(!1),m(new Set);const ue=new Map;if(i.worktree?.path&&ue.set(Us(i.worktree.path),i.worktree),Y.forEach(({metadata:re})=>{re.path&&ue.set(Us(re.path),re)}),ue.size===0){y(!0);return}let me=!1;return(async()=>{const re=new Map,pe=new Set;await Promise.all(Array.from(ue.entries()).map(async([U,ae])=>{try{const Re=await td(ae.path);re.set(U,Re),Re?.isDirty&&pe.add(U)}catch{ae.status&&(re.set(U,ae.status),ae.status.isDirty&&pe.add(U))}})).catch(U=>{console.warn("Failed to inspect worktree status before deletion:",U)}),!me&&(m(pe),y(!0),a(U=>{if(!U?.worktree?.path)return U;const ae=Us(U.worktree.path),Re=re.get(ae);if(!Re)return U;const W=U.worktree.status;return W?.isDirty===Re.isDirty&&W?.ahead===Re.ahead&&W?.behind===Re.behind&&W?.upstream===Re.upstream?U:{...U,worktree:{...U.worktree,status:Re}}}),c(U=>U.map(ae=>{const Re=Us(ae.metadata.path),W=re.get(Re);return W?{session:ae.session,metadata:{...ae.metadata,status:W}}:ae})))})(),()=>{me=!0}},[i,v]),l.useEffect(()=>{A||f(!1)},[A]);const ie=l.useCallback(async(Y,ue,me)=>{const re=u&&A,pe=C(Y),U=Us(Y.path),ae=Us(pe.path);try{await Mf(pe,Y,{deleteRemoteBranch:re,deleteLocalBranch:ue,remoteName:Y.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const Re=ye=>!!(U&&ye&&Ef(U,ye)),W=Us(w?.directoryOverride);return w?.open&&Re(W)&&ae&&(k(null),T({projectId:pe.id,directoryOverride:ae},{force:!0})),Re(Us(L))&&ae&&Ps.getState().setDirectory(ae,{showOverlay:!1}),!0}catch(Re){return He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:sa(Y)}),{id:me,description:ln(Re instanceof Error?Re.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[A,L,u,C,e,w?.directoryOverride,w?.open,k,T,s,t]),ce=l.useCallback((Y,ue,me)=>{const re=u&&A,pe=He.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:sa(Y)}));return NS(Y.path),(async()=>{try{const U=await fy({sessionIds:ue,removeWorktree:()=>ie(Y,me,pe),archiveSessions:async W=>W.length===1?await B(W[0])?{archivedIds:W,failedIds:[]}:{archivedIds:[],failedIds:W}:F(W)});if(!U.removed)return;const ae=t(re?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");He.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:sa(Y)}),{id:pe,description:ln(ae)});const{failedIds:Re}=U.archive;Re.length>0&&He.error(Re.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Re.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:Re.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(U){He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:pe,description:ln(U instanceof Error?U.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{AS(Y.path)}})()},[B,F,A,u,ie,t]),ne=l.useRef(new Set),je=l.useCallback(async(Y,ue)=>{const me=Us(Y.path);if(!ne.current.has(me)){ne.current.add(me);try{const re=await td(Y.path).catch(()=>{});if(!OS(re)){he({sessions:ue,mode:"worktree",worktree:Y});return}await ce(Y,ue.map(pe=>pe.id),!0)}finally{ne.current.delete(me)}}},[he,ce]);l.useEffect(()=>Tn.onDeleteRequest(Y=>{if(!j&&(Y.mode??"session")==="session"){V(Y);return}if(Y.mode==="worktree"&&Y.skipDialogIfSafe&&Y.worktree){je(Y.worktree,Y.sessions);return}he(Y)}),[he,j,V,je]);const Ee=l.useCallback(async()=>{if(i){b(!0);try{if(q){const Y=i.worktree??d[0]?.metadata;if(!Y){He.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}ce(Y,i.sessions.map(ue=>ue.id),p),M();return}if(i.sessions.length===1){const Y=i.sessions[0];if(!await I(Y.id)){He.error(t("sessions.sidebar.session.delete.error")),b(!1);return}He.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const Y=i.sessions.map(re=>re.id),{deletedIds:ue,failedIds:me}=await O(Y);if(ue.length>0){const re=me.length>0?me.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:me.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:me.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;He.success(ue.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ue.length}),{description:ln(re),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(me.length>0&&(He.error(me.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:me.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:me.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ue.length===0)){b(!1);return}}M()}finally{b(!1)}}},[i,d,p,I,O,M,q,ce,t]),we=i?.worktree??d[0]?.metadata??null;let Me="";if(i?.mode==="worktree"){const Y=i.sessions.length;Y===0?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):Y===1?Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:Y}):Me=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:Y})}else if(i){const Y=i.sessions.length;Y===1?Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):Me=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:Y,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:Y})}const fe=i?n.jsxs("div",{className:Pe(q?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:Pe(q?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[q&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:i.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:i.sessions.length})]}),n.jsxs("ul",{className:Pe(q?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(Y=>n.jsxs("li",{className:Pe(q?"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:[n.jsx("span",{className:Pe(!q&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:Y.title||t("sessions.sidebar.session.untitled")})]},Y.id)),i.sessions.length>5&&n.jsx("li",{className:Pe(q?"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:i.sessions.length-5})})]})]}),q?n.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Z,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),we?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:we.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:we?fr(we.path,z):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),N&&n.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):n.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,be=q?A?n.jsxs("button",{type:"button",onClick:()=>{ee||f(Y=>!Y)},disabled:ee,"aria-pressed":u,className:Pe("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:[u?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):n.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,ke=q?n.jsxs("button",{type:"button",onClick:()=>{Q||h(Y=>!Y)},disabled:Q,"aria-pressed":p,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Q?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[p?n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}):n.jsx(Z,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ie=q?n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex flex-col items-start gap-1",children:[ke,be]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:M,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",onClick:Ee,disabled:g,children:t(g?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):n.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[n.jsxs("button",{type:"button",onClick:()=>P(!j),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":!j,children:[j?n.jsx(Z,{name:"checkbox-blank",className:"size-4"}):n.jsx(Z,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Nt,{variant:"ghost",onClick:M,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Nt,{variant:"destructive",onClick:Ee,disabled:g,children:g?t("sessions.sidebar.sessionDialogs.actions.deleting"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),Te=q?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):i?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[E?n.jsx(BS,{open:!!i,onClose:()=>{g||M()},title:Te,footer:n.jsx("div",{className:"flex justify-end gap-2",children:Ie}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[Me&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Me}),fe]})}):n.jsx(Qs,{open:!!i,onOpenChange:Y=>{if(!Y){if(g)return;M()}},children:n.jsxs(Zs,{className:Pe(q?"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:[n.jsxs(on,{children:[n.jsxs(nn,{className:Pe(q&&"flex items-center gap-2"),children:[q&&n.jsx(Z,{name:"delete-bin",className:"h-5 w-5"}),Te]}),Me&&n.jsx(rn,{children:Me})]}),n.jsx("div",{className:Pe(q&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:fe}),n.jsx(Pn,{className:"mt-2 gap-2 pt-1 pb-1",children:Ie})]})}),n.jsx(py,{open:r,onOpenChange:o})]})},WP=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],HP=["dev","start","preview","serve"];async function UP(t,e,s){if(!t)return null;const r=qP(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=YP(s);if(o){const i=await ZP(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await VP(t)){const o=await GP(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function VP(t){const e=`${t}/index.html`,s=await ti(e,t);return typeof s=="string"&&s.trim().length>0}async function GP(){try{const t=await Ys("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function qP(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(HP.some(o=>s.includes(o)))return e}return null}function YP(t){for(const{pattern:e}of WP)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function ZP(t){const e=await ti(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await ti(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function ti(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Ys(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=of()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Ys(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function QP(t){try{const e=await ti(`${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 XP=/\{(worktree|branch)\}/g,ka=63,JP=new Set(["main","master"]),xm=t=>/\{(worktree|branch)\}/.test(t??""),eE=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Sm=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=ka)return e;const s=await eE(e);return s?`${e.slice(0,ka-7).replace(/-+$/,"")}-${s}`:e.slice(0,ka).replace(/-+$/,"")},tE=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},sE=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:tE(i.current),linkedWorktree:o}},nE=async t=>!t.linkedWorktree||!t.branch||JP.has(t.branch)?"":Sm(t.branch.split("/").pop()??""),rE=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,a=o>=0?r.slice(o):"",d=i.split(".").map(c=>c.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${d.join(".")}${a}`},oE=async(t,e)=>{const s={worktree:await nE(e),branch:e.branch?await Sm(e.branch):""},r=t.replace(XP,(c,u)=>s[u]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",a="",d=""]=o;return`${i}${rE(a)}${d}`},iE=async(t,e,s)=>xm(e)?oE(e,await sE(t,s,e)):e,wm="oc.projectActions.selectedAction.v1",aE=Wr(zs(),Wr(zs(),zs())),vm=()=>{const t=ai().getItem(wm);if(t===null)return{};try{const e=aE.safeParse(JSON.parse(t));return e.success?e.data:{}}catch{return{}}},Mu=(t,e=Jt())=>vm()[e]?.[t]??null,lE=(t,e,s=Jt())=>{const r=vm();r[s]?.[t]!==e&&ai().setItem(wm,JSON.stringify({...r,[s]:{...r[s],[t]:e}}))},cE=15e3,dE=3e3,uE=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},fE=({projectRef:t,directory:e,allowMobile:s=!1})=>{const{t:r}=Et(),{currentTheme:o}=br(),{terminal:i,runtime:a,git:d}=Ks(),c=Nn(),{isMobile:u}=Rn(),f=l.useMemo(()=>hn(),[]),p=zc(X=>X.instances),h=zc(X=>X.load),g=le(X=>X.terminalShell),b=le(X=>X.terminalLoginShells.includes(X.terminalShell)),x=le(X=>X.setSettingsPage),y=le(X=>X.setSettingsDialogOpen),S=le(X=>X.setSettingsProjectsSelectedId),m=le(X=>X.openContextPreview),v=zt(X=>X.ensureDirectory),w=zt(X=>X.reconcileServerSessions),T=zt(X=>X.setTabLabel),k=zt(X=>X.setTabIconKey),I=zt(X=>X.setActiveTab),B=zt(X=>X.setConnecting),O=zt(X=>X.setTabSessionId),F=zt(X=>X.setTabPurpose),j=zt(X=>X.allocateActionExecution),P=zt(X=>X.setTabLifecycle),L=zt(X=>X.setTabPreviewUrl),z=zt(X=>X.matchesActionExecution),H=zt(X=>X.captureStartedActionMutationRevisions),[R,G]=l.useState([]),_=l.useRef(null),[$,E]=l.useState(()=>t?.id?Mu(t.id):null),[D,C]=l.useState(!1),N=l.useRef({}),A=l.useRef({}),q=l.useRef({}),ee=l.useRef(new Set),Q=l.useRef(0),[he,M]=l.useState({}),V=t?.id??null,ie=t?.path??"";l.useEffect(()=>{E(V?Mu(V):null)},[V]);const ce=l.useMemo(()=>V?{id:V,path:ie}:null,[V,ie]);l.useEffect(()=>{f&&h().catch(()=>{})},[f,h]);const ne=l.useCallback(async X=>{await xr(X)},[]),je=l.useCallback(async()=>{if(!ce)return;const X=Q.current+1;Q.current=X,C(!0);try{const Be=await sd(ce);if(Q.current!==X)return;_.current=Be;const Le=Be.projectActions;G(Le)}catch{if(Q.current!==X)return}finally{Q.current===X&&C(!1)}},[ce]),Ee=l.useMemo(()=>na(e||ce?.path||""),[e,ce?.path]),we=l.useMemo(()=>na(ce?.path||""),[ce?.path]),Me=l.useMemo(()=>na(c||"")||Ee,[c,Ee]),fe=l.useRef(Me);l.useEffect(()=>{fe.current=Me},[Me]);const be=zt(X=>Ee?X.getDirectoryState(Ee):void 0),ke=zt(X=>we&&we!==Ee?X.getDirectoryState(we):void 0),Ie=l.useMemo(()=>{const X=Ee?[{directory:Ee,state:be}]:[];return we&&we!==Ee&&X.push({directory:we,state:ke}),X},[be,Ee,we,ke]),Te=l.useMemo(()=>{const X=Ee?[Ee]:[];return we&&we!==Ee&&X.push(we),X},[Ee,we]),Y=l.useCallback(X=>X.id!==An&&X.runIn==="parent"&&we||Ee,[Ee,we]),ue=l.useCallback((X,Be,Le)=>`${X}::${Be}::${Le}`,[]),me=l.useCallback((X,Be,Le=zt.getState())=>X?Le.getDirectoryState(X)?.tabs.find(at=>at.purpose.type==="project-action"&&at.purpose.actionId===Be)??null:null,[]),re=l.useMemo(()=>{const X={};for(const{directory:Be,state:Le}of Ie)for(const at of Le?.tabs??[]){if(at.purpose.type!=="project-action"||!at.purpose.executionId||!at.terminalSessionId||at.lifecycle==="idle"||at.lifecycle==="exited")continue;const qe=qn(Be,at.purpose.actionId),ut=ue(Be,at.purpose.actionId,at.purpose.executionId);X[qe]={directory:Be,actionId:at.purpose.actionId,tabId:at.id,sessionId:at.terminalSessionId,executionId:at.purpose.executionId,status:at.lifecycle==="stopping"?"stopping":he[ut]?"waiting-for-preview":"running"}}return X},[ue,he,Ie]),pe=l.useCallback((X,Be,Le)=>{const at=qn(X,Be),qe=ue(X,Be,Le),dt=N.current[at]?.executionId===Le,ft=globalThis.window,st=Rt=>{ft?.clearTimeout(q.current[Rt]),delete q.current[Rt]};dt&&(delete N.current[at],st(at)),A.current[qe]?.(),delete A.current[qe],st(qe),M(Rt=>{if(!Rt[qe])return Rt;const Ke={...Rt};return delete Ke[qe],Ke})},[ue]),U=l.useCallback(X=>{A.current[X]?.(),delete A.current[X]},[]),ae=l.useCallback(X=>{window.clearTimeout(q.current[X]),delete q.current[X]},[]);l.useEffect(()=>{const X=A.current,Be=q.current;return()=>{for(const Le of Object.keys(X))U(Le);for(const Le of Object.keys(Be))ae(Le)}},[ae,U]),l.useEffect(()=>{const X=new Set(Te);for(const Be of Object.values(N.current))X.has(Be.directory)||pe(Be.directory,Be.actionId,Be.executionId);for(const Be of Object.keys(A.current)){const Le=Be.split("::",1)[0]??"";X.has(Le)||U(Be)}},[pe,U,Te]);const Re=l.useCallback((X,Be)=>{le.getState().openContextPanelTab(X,{mode:"terminal",targetDirectory:Be===X?null:Be})},[]),W=l.useMemo(()=>({id:An,name:r("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[r]),ye=!u,de=l.useMemo(()=>ye?[...R,W]:R,[R,W,ye]),Ne=l.useMemo(()=>$?de.find(X=>X.id===$)??null:null,[de,$]);l.useEffect(()=>{je()},[je]);const[Je,Ge]=l.useState(0),ge=l.useCallback(()=>(Ge(X=>X+1),()=>Ge(X=>X-1)),[]),Ae=Je>0;l.useEffect(()=>{if(!Ae)return;const X=Te.map(Be=>Ta(i,Be,H,Le=>w(Be,Le.sessions,{startedActionMutationRevisions:Le.startedActionMutationRevisions})));return()=>{for(const Be of X)Be()}},[H,Ae,w,i,Te]),l.useEffect(()=>{for(const{directory:X,state:Be}of Ie)if(X)for(const Le of Be?.tabs??[]){if(Le.purpose.type!=="project-action")continue;const at=Le.purpose.actionId,qe=de.find(ft=>ft.id===at),ut=qe?.name??at,dt=qe?.icon||"play";Le.label!==ut&&T(X,Le.id,ut),Le.iconKey!==dt&&k(X,Le.id,dt)}},[de,k,T,Ie]),l.useEffect(()=>{const X=globalThis.window;if(!X)return;const Be=Le=>{const at=Le.detail;V&&(at?.projectId&&at.projectId!==V||je())};return X.addEventListener(nd,Be),()=>{X.removeEventListener(nd,Be)}},[je,V]),l.useEffect(()=>{const X=Le=>{delete q.current[Le];const at=N.current[Le];if(!at||at.openedUrl)return;const qe=ue(at.directory,at.actionId,at.executionId),ut=at.announced;if(ut.length!==0){if(window.clearTimeout(q.current[qe]),delete q.current[qe],at.openedUrl=!0,M(dt=>{if(!dt[qe])return dt;const ft={...dt};return delete ft[qe],ft}),ut.length===1){fa(at.directory,[]),L(at.directory,at.tabId,ut[0],{locked:!1,autoOpened:!0}),m(at.directory,ut[0]);return}at.offering=!0,fa(at.directory,ut),le.getState().openContextSurface(at.directory,"browser"),He.info(r("projectActions.toast.multipleServers"))}},Be=()=>{const Le=zt.getState(),at=Le.sessions,qe=re;for(const[ut,dt]of Object.entries(qe)){const st=at.get(dt.directory)?.tabs.find(pt=>pt.id===dt.tabId);if(!st||st.terminalSessionId!==dt.sessionId){pe(dt.directory,dt.actionId,dt.executionId);continue}const Rt=N.current[ut],Ke=Rt?.executionId===dt.executionId?Rt:{hostDirectory:fe.current||dt.directory,directory:dt.directory,tabId:dt.tabId,actionId:dt.actionId,executionId:dt.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};N.current[ut]=Ke;const jt=de.find(pt=>pt.id===dt.actionId),Lt=Le.getBuffer(dt.directory,dt.tabId).chunks;if(!jt||Lt.length===0)continue;const Mt=Lt.filter(pt=>Ke.lastSeenChunkId===null||pt.id>Ke.lastSeenChunkId);if(Mt.length===0)continue;const De=Mt.map(pt=>pt.data).join(""),Tt=`${Ke.tail}${De}`;for(const pt of yy(Tt))Ke.proxiedPorts.includes(pt)||Ke.proxiedPorts.push(pt);if(Ke.openInPreview&&(!Ke.openedUrl||Ke.offering)){const pt=xy(Tt,{proxiedPorts:Ke.proxiedPorts,namedAddressesReachable:!Kc()}),Dt=Ke.announced.length;for(const rt of pt)Ke.announced.includes(rt)||Ke.announced.push(rt);const Ve=Ke.announced.length-Dt;Ke.offering&&Ve>0?fa(dt.directory,Ke.announced):!Ke.openedUrl&&Dt===0&&Ke.announced.length>0&&(window.clearTimeout(q.current[ut]),q.current[ut]=window.setTimeout(()=>X(ut),dE))}const At=!Ke.openedUrl&&jt.autoOpenUrl===!0&&!Ke.openInPreview?Sy(Tt,{proxiedPorts:Ke.proxiedPorts,namedAddressesReachable:!Kc()}):null,kt=Mt[Mt.length-1]?.id??Ke.lastSeenChunkId;if(Ke.lastSeenChunkId=kt,Ke.tail=Tt.slice(-512),At)if(Ke.openedUrl=!0,Ke.openInPreview){const pt=qe[ut];pt&&(L(pt.directory,pt.tabId,At,{locked:!1,autoOpened:!1,expectedExecutionId:pt.executionId}),pt.status==="waiting-for-preview"&&M(Dt=>{const Ve=ue(pt.directory,pt.actionId,pt.executionId);if(!Dt[Ve])return Dt;const rt={...Dt};return delete rt[Ve],rt}),window.clearTimeout(q.current[ut]),delete q.current[ut],m(pt.directory,At))}else ne(At),He.success(r("projectActions.toast.openedUrlFromOutput"));N.current[ut]=Ke}for(const ut of Object.keys(N.current))if(!qe[ut]){const dt=N.current[ut],ft=dt?at.get(dt.directory)?.tabs.find(Rt=>Rt.id===dt.tabId):void 0;if(ft?.purpose.type==="project-action"&&ft.purpose.executionId===dt?.executionId&&!!ft.terminalSessionId&&ft.lifecycle!=="idle"&&ft.lifecycle!=="exited")continue;delete N.current[ut],window.clearTimeout(q.current[ut]),delete q.current[ut]}};return Be(),zt.subscribe((Le,at)=>{(Le.sessions!==at.sessions||Le.buffers!==at.buffers)&&Be()})},[pe,fe,de,ue,m,ne,re,L,r]),l.useEffect(()=>{for(const{directory:X,state:Be}of Ie)for(const Le of Be?.tabs??[]){if(Le.purpose.type!=="project-action"||!Le.purpose.executionId||!Le.terminalSessionId||Le.lifecycle!=="running")continue;const at=Le.purpose.actionId,qe=Le.purpose.executionId,ut=ue(X,at,qe);if(A.current[ut])continue;const dt=i.connect(Le.terminalSessionId,{onEvent:ft=>{if(!z(X,Le.id,qe))return;ft.type==="snapshot"&&(zt.getState().replaceBuffer(X,Le.id,ft.data??"",ft.sequence??0,Ec(ft)),ft.status==="running"&&zt.getState().setTabLifecycle(X,Le.id,"running",{expectedExecutionId:qe}),ft.status==="exited"&&(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe)));const st=ft.type==="data"?ft.data??"":"";st&&zt.getState().appendToBuffer(X,Le.id,st,ft.sequence,ft.replayData),ft.type==="exit"&&(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe))},onError:(ft,st)=>{!st||!z(X,Le.id,qe)||(zt.getState().setTabLifecycle(X,Le.id,"exited",{expectedExecutionId:qe}),zt.getState().setTabSessionId(X,Le.id,null,{expectedExecutionId:qe}),zt.getState().setTabPurpose(X,Le.id,{type:"project-action",actionId:at,executionId:null}),pe(X,at,qe))}},X);A.current[ut]=dt.close}},[pe,ue,z,i,Ie]);const Ye=l.useCallback(async X=>{const Be=Y(X);if(!Be)throw new Error(r("projectActions.error.noActiveDirectory"));const Le=qn(Be,X.id);v(Be);const at=zt.getState(),qe=me(Be,X.id,at),ut=qe?.id??at.createTab(Be);T(Be,ut,X.name),k(Be,ut,X.icon||"play"),qe||F(Be,ut,{type:"project-action",actionId:X.id,executionId:null}),I(Be,ut);const ft=zt.getState().getDirectoryState(Be)?.tabs.find(st=>st.id===ut);return{executionDirectory:Be,key:Le,tabId:ut,sessionId:ft?.terminalSessionId??null,executionId:ft?.purpose.type==="project-action"?ft.purpose.executionId:null}},[v,Y,me,I,k,T,F,r]),nt=l.useCallback(async X=>{if(a.isVSCode||!s&&u)return;if(!Ee){He.error(r("projectActions.error.noActiveDirectoryForAction"));return}const Be=qn(Y(X),X.id),Le=re[Be];if(Le&&Le.status==="running"||ee.current.has(Be))return;ee.current.add(Be);let at=null;try{const qe=X.id===An?await(async()=>{const[se,Fe]=await Promise.all([FS({id:ce?.id??"",path:Ee}),QP(Ee)]),ot=await UP(Ee,se.actions,Fe);if(!ot)throw new Error(r("contextPanel.preview.noDevServer"));return{id:An,name:r("projectActions.actions.autoDiscover"),command:ot.command,icon:"scan-2",autoOpenUrl:!0,openUrl:ot.previewUrlHint||""}})():X,ut=qe.autoOpenUrl===!0&&(qe.openUrl||"").trim().length>0,dt=!ut&&X.id!==An,ft=fe.current||Ee,{executionDirectory:st,key:Rt,tabId:Ke}=await Ye(qe),jt=hy(qe.command);if(!jt)throw new Error(r("projectActions.error.failedToRunAction"));const Lt=qe.autoOpenUrl===!0&&f&&(qe.desktopOpenSshForward||"").trim().length>0,Mt=qe.autoOpenUrl&&qe.openUrl||"";let De=!1;const Tt=xm(Mt)?await iE(d,Mt,st).catch(()=>(De=!0,"")):Mt,At=qe.autoOpenUrl?uE(Tt):null,kt=qe.autoOpenUrl&&f?_S(qe.desktopOpenSshForward,p):null;if(i.listSessions){const se=me(st,qe.id);if(se?.purpose.type==="project-action"&&se.purpose.executionId===null){const Fe=await my(i,st,{captureStartedActionMutationRevisions:H});Fe&&w(st,Fe.sessions,{startedActionMutationRevisions:Fe.startedActionMutationRevisions})}}const pt=me(st,qe.id);let Dt,Ve;if(pt?.lifecycle==="running"&&pt.terminalSessionId&&pt.purpose.type==="project-action"&&pt.purpose.executionId)Dt=pt.terminalSessionId,Ve=pt.purpose.executionId;else{const se=pt?.purpose.type==="project-action"?pt.purpose.executionId:null;se&&pe(st,qe.id,se);const Fe=j(st,Ke,qe.id);if(!Fe)throw new Error(r("projectActions.error.failedToCreateTerminalSession"));at={directory:st,tabId:Ke,id:Fe},B(st,Ke,!0,{expectedExecutionId:Fe});const ot=await gy({terminal:i,createOptions:{cwd:st,shell:g,loginShell:b,themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground},command:jt,isRunStillExpected:()=>z(st,Ke,Fe),purpose:{type:"project-action",actionId:qe.id,executionId:Fe}});if(!z(st,Ke,Fe)){ot.sessionId===Fe&&await i.close(ot.sessionId).catch(()=>{});return}Ve=ot.purpose?.type==="project-action"?ot.purpose.executionId:Fe,Dt=ot.sessionId,F(st,Ke,{type:"project-action",actionId:qe.id,executionId:Ve}),O(st,Ke,Dt,{expectedExecutionId:Ve}),B(st,Ke,!1,{expectedExecutionId:Ve})}dt&&ft&&Re(ft,st),N.current[Rt]={hostDirectory:ft,directory:st,tabId:Ke,actionId:qe.id,executionId:Ve,lastSeenChunkId:null,openedUrl:!!kt||!!At||ut,tail:"",openInPreview:qe.id===An,announced:[],offering:!1,proxiedPorts:[]};const rt=ue(st,qe.id,Ve);B(st,Ke,!0,{expectedExecutionId:Ve});const wt=i.connect(Dt,{onEvent:se=>{if(!z(st,Ke,Ve)||se.purpose?.type==="project-action"&&se.purpose.executionId!==Ve)return;se.type==="snapshot"&&(zt.getState().replaceBuffer(st,Ke,se.data??"",se.sequence??0,Ec(se)),zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),se.purpose?.type==="project-action"&&zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:se.purpose.actionId,executionId:se.purpose.executionId}),se.status==="running"&&zt.getState().setTabLifecycle(st,Ke,"running",{expectedExecutionId:Ve}),se.status==="exited"&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve)));const Fe=se.type==="data"?se.data??"":"";Fe&&zt.getState().appendToBuffer(st,Ke,Fe,se.sequence,se.replayData),se.type==="exit"&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve))},onError:(se,Fe)=>{z(st,Ke,Ve)&&(zt.getState().setConnecting(st,Ke,!1,{expectedExecutionId:Ve}),Fe&&(zt.getState().setTabLifecycle(st,Ke,"exited",{expectedExecutionId:Ve}),zt.getState().setTabSessionId(st,Ke,null,{expectedExecutionId:Ve}),zt.getState().setTabPurpose(st,Ke,{type:"project-action",actionId:qe.id,executionId:null}),pe(st,qe.id,Ve)))}},st);if(!z(st,Ke,Ve)){wt.close();return}A.current[rt]?.(),A.current[rt]=wt.close,window.clearTimeout(q.current[rt]),delete q.current[rt],qe.id===An&&!At&&(M(se=>({...se,[rt]:!0})),q.current[rt]=window.setTimeout(()=>{delete q.current[rt];const se=N.current[Rt];!se||se.executionId!==Ve||se.openedUrl||se.offering||z(st,Ke,Ve)&&(M(Fe=>{if(!Fe[rt])return Fe;const ot={...Fe};return delete ot[rt],ot}),zt.getState().setActiveTab(st,Ke),Re(se.hostDirectory,st))},cE)),kt?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),ne(kt),He.success(r("projectActions.toast.openedForwardedUrl"))):At?(L(st,Ke,At,{locked:!0,autoOpened:!0,expectedExecutionId:Ve}),m(ft,At),He.success(r("projectActions.toast.openedActionUrl"))):De?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.openUrlTemplateUnresolved"))):ut?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.invalidCustomUrlFormat"))):Lt?(L(st,Ke,null,{locked:!0,expectedExecutionId:Ve}),He.error(r("projectActions.error.selectedDesktopSshForwardUnavailable"))):L(st,Ke,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ve})}catch(qe){if(at&&z(at.directory,at.tabId,at.id)){const{directory:ut,tabId:dt,id:ft}=at;pe(ut,X.id,ft),P(ut,dt,"exited",{expectedExecutionId:ft}),F(ut,dt,{type:"project-action",actionId:X.id,executionId:null})}if(qe instanceof Error&&qe.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(qe instanceof Error&&(qe.message==="COMMAND_MODE_UNSUPPORTED"||qe.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){He.error(r("projectActions.error.failedToCreateTerminalSession"));return}He.error(qe instanceof Error?qe.message:r("projectActions.error.failedToRunAction"))}finally{ee.current.delete(Be)}},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,fe,p,Ye,d,s,u,f,Ee,b,g,ne,m,re,Re,a.isVSCode,Y,z,pe,ue,me,w,j,H,B,P,F,L,O,ce?.id,r,i]),oe=l.useCallback(async X=>{const Be=qn(Y(X),X.id),Le=re[Be];Le&&await by({terminal:i,sessionId:Le.sessionId,isExecutionStillCurrent:()=>z(Le.directory,Le.tabId,Le.executionId),markStopping:()=>{P(Le.directory,Le.tabId,"stopping",{expectedExecutionId:Le.executionId})},restoreRunning:()=>{P(Le.directory,Le.tabId,"running",{expectedExecutionId:Le.executionId})},clearSession:()=>{O(Le.directory,Le.tabId,null,{expectedExecutionId:Le.executionId})},finalizeExit:()=>{P(Le.directory,Le.tabId,"exited",{expectedExecutionId:Le.executionId}),F(Le.directory,Le.tabId,{type:"project-action",actionId:Le.actionId,executionId:null}),pe(Le.directory,Le.actionId,Le.executionId)}})},[pe,Y,z,re,P,F,O,i]),tt=l.useCallback(async X=>{if(X.source==="shared"&&ce){const Be=_.current?.trust.trusted?_.current:await sd(ce);if(_.current=Be,!await LS(ce,Be))return;_.current={...Be,trust:{...Be.trust,trusted:!0}}}await nt(X)},[nt,ce]),Ue=l.useCallback(X=>re[qn(Y(X),X.id)]??null,[Y,re]),gt=(Ne&&Ue(Ne)?Ne:null)??de.find(X=>Ue(X)!==null)??Ne??de[0]??null,bt=l.useCallback(X=>{const Be=Ue(X);if(Be?.status!=="stopping"){if(Be){oe(X);return}tt(X)}},[tt,Ue,oe]),Ce=l.useCallback(X=>{tt(X)},[tt]),_e=l.useCallback(X=>{oe(X)},[oe]),ze=l.useCallback(X=>{E(X.id),V&&lE(V,X.id)},[V]),Oe=l.useCallback(()=>{ce?.id&&(S(ce.id),x("projects"),y(!0))},[y,x,S,ce?.id]),it=!a.isVSCode&&(s||!u)&&!!ce&&!!Ee;return l.useMemo(()=>({available:it,actions:it?de:[],shown:it?gt:null,isLoading:D,observe:ge,runOf:Ue,select:ze,run:Ce,stop:_e,toggle:bt,openSettings:Oe}),[it,de,D,ge,Oe,Ce,Ue,ze,gt,_e,bt])},pE=t=>{const e=Ze.c(6);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=fE(r);let i;return e[3]!==s||e[4]!==o?(i=n.jsx($S.Provider,{value:o,children:s}),e[3]=s,e[4]=o,e[5]=i):i=e[5],i},hE=t=>{const e=Ze.c(4),{children:s}=t,r=zS(),o=Yr(),i=o?.kind==="preparing"?null:r?.projectRef??null,a=o?.kind==="ready"?o.directory:r?.directory??"";let d;return e[0]!==s||e[1]!==a||e[2]!==i?(d=n.jsx(pE,{projectRef:i,directory:a,children:s}),e[0]=s,e[1]=a,e[2]=i,e[3]=d):d=e[3],d};function Ni(t,e,s){const[r,o]=l.useState(null),i=l.useRef(s);return i.current=s,l.useEffect(()=>{if(!t||r)return;let a=!1;return KS(e).then(d=>{a||o(()=>d)},d=>{console.error("[on-demand] failed to load component",d),a||i.current()}),()=>{a=!0}},[r,e,t]),r}function mE(t){const e=[],s=(r,o)=>{const i=yt(r);!i||e.some(a=>a.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const gE=new Map,bE=t=>{const e=Ze.c(23),{isVSCode:s}=t,r=Jr(),o=ns(yE),i=Ps(xE),a=mt(SE);let d;e[0]!==s?(d=O=>s?gE:O.availableWorktreesByProject,e[0]=s,e[1]=d):d=e[1];const c=mt(d),u=!s;let f;e[2]!==c||e[3]!==o||e[4]!==u?(f=ym(o,c,{includeWorktrees:u}),e[2]=c,e[3]=o,e[4]=u,e[5]=f):f=e[5];const p=f,h=Os(wE),g=Os(vE),b=Os(jE),x=`session-list-sync:${l.useId()}`;let y,S;e[6]!==x||e[7]!==r||e[8]!==i||e[9]!==a?(y=()=>(r.setBootstrapDemand(x,mE({currentDirectory:i,currentSessionDirectory:a})),()=>r.clearBootstrapDemand(x)),S=[x,r,i,a],e[6]=x,e[7]=r,e[8]=i,e[9]=a,e[10]=y,e[11]=S):(y=e[10],S=e[11]),l.useEffect(y,S);const m=l.useRef(null);let v,w;e[12]!==s||e[13]!==p?(v=()=>{const O=new Set(p),F=m.current;m.current=O;const j=F?[...O].filter(P=>!F.has(P)):s?[...O]:[];j.length&&Tl(j,_a())},w=[s,p],e[12]=s,e[13]=p,e[14]=v,e[15]=w):(v=e[14],w=e[15]),l.useEffect(v,w);let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[16]=T):T=e[16],l.useEffect(kE,T);let k;e[17]!==g||e[18]!==h?(k=[...h,...g],e[17]=g,e[18]=h,e[19]=k):k=e[19];const I=k;let B;e[20]!==I||e[21]!==b?(B={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:I},e[20]=I,e[21]=b,e[22]=B):B=e[22],wy(B)};function yE(t){return t.projects}function xE(t){return t.currentDirectory}function SE(t){return t.currentSessionDirectory}function wE(t){return t.activeSessions}function vE(t){return t.archivedSessions}function jE(t){return t.status==="ready"}function kE(){let t=null,e=!1;const s=new Set,r=En(o=>{if(o.type==="scheduled-task-ran")e=!0;else if(o.type==="session-created")s.add(o.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,s.clear(),Dp(_a());return}const i=[...s];s.clear(),i.length&&Tl(i,_a())},500)});return()=>{t&&clearTimeout(t),r()}}const CE=()=>as(()=>import("./SettingsWindow-Cndsj5Vu.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,83,146,84,147,148,132,133,134,135,141,119,120,105,106,90,91,92,93,94,95,96,97,98,99,100,101,102,103,149,150,140,128,151,152])).then(t=>t.SettingsWindow),IE=()=>as(()=>import("./CommandPalette-DEcmPHdC.js"),__vite__mapDeps([153,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,151,122,123])).then(t=>t.CommandPalette),PE=()=>as(()=>import("./HelpDialog-CLyz3_xd.js"),__vite__mapDeps([154,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])).then(t=>t.HelpDialog),EE=()=>as(()=>import("./ProjectActionsDialog-BPh74BCt.js"),__vite__mapDeps([155,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])).then(t=>t.ProjectActionsDialog),TE=()=>as(()=>import("./OpenCodeStatusDialog-skpJZSjK.js"),__vite__mapDeps([156,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])).then(t=>t.OpenCodeStatusDialog),DE=()=>as(()=>import("./RunOverview-Cngm2OOp.js"),__vite__mapDeps([157,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])).then(t=>t.RunOverview),RE=()=>as(()=>import("./ScheduledTasksDialog-DUjDdkw2.js"),__vite__mapDeps([158,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,143,159,160])).then(t=>t.ScheduledTasksDialog),NE=()=>as(()=>import("./ArchiveView-4-LVDLmf.js"),__vite__mapDeps([161,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])).then(t=>t.ArchiveView),ME=()=>as(()=>import("./IntegrationsCatalogView-u1gS0Vk8.js"),__vite__mapDeps([162,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,147])).then(t=>t.IntegrationsCatalogView),AE=()=>as(()=>import("./UsageStatsView-CsC_RzAH.js"),__vite__mapDeps([163,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])).then(t=>t.UsageStatsView),OE=()=>as(()=>import("./SourceBoardView-8Wp0oUvB.js"),__vite__mapDeps([164,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])).then(t=>t.SourceBoardView),BE=()=>as(()=>import("./WorktreesView-D102xE1o.js"),__vite__mapDeps([165,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])).then(t=>t.WorktreesView),FE=()=>as(()=>import("./SpacesView-BwcDCv3D.js"),__vite__mapDeps([166,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,152,84])).then(t=>t.SpacesView),_E=()=>as(()=>import("./SpaceAccessDialog-CxfCzTpe.js"),__vite__mapDeps([167,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,168])).then(t=>t.SpaceAccessDialog),LE=()=>as(()=>import("./SpaceApplyDialog-CYp0A76N.js"),__vite__mapDeps([169,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,170])).then(t=>t.SpaceApplyDialog),$E=()=>as(()=>import("./SpaceSetupOutput-RNo0mWrR.js"),__vite__mapDeps([171,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,168])).then(t=>t.SpaceSetupOutputDialog),xn=()=>le.getState().closeMainSurfaces(),Ts=t=>{const e=Ze.c(2),{needed:s,load:r,onFailure:o}=t,i=Ni(s,r,o);let a;return e[0]!==i?(a=i?n.jsx(i,{}):null,e[0]=i,e[1]=a):a=e[1],a},jm=l.memo(t=>{const e=Ze.c(11),{isMobile:s}=t,r=le(KE),o=!r&&!s,i=ui();let a;e[0]!==o||e[1]!==i?(a={enabled:o,layoutAnimationMs:i},e[0]=o,e[1]=i,e[2]=a):a=e[2];const d=_v(a);let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(Nv,{}),e[3]=c):c=e[3];const u=r||d.state!==!1;let f;e[4]!==u?(f=n.jsx(zP,{isVisible:u}),e[4]=u,e[5]=f):f=e[5];let p;return e[6]!==s||e[7]!==r||e[8]!==d||e[9]!==f?(p=n.jsx(Rv,{isOpen:r,isMobile:s,className:"border-border",topBar:c,peek:d,children:f}),e[6]=s,e[7]=r,e[8]=d,e[9]=f,e[10]=p):p=e[10],p});jm.displayName="LeftSidebar";const zE=()=>{const t=Ze.c(107);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],bE(e),vy();const s=le(WE),r=le(HE),o=le(UE),i=le(VE);let a;t[1]!==i?(a=()=>i(!1),t[1]=i,t[2]=a):a=t[2];const d=Ni(o,CE,a),c=le(GE),u=le(qE),f=le(YE),p=le(ZE),h=le(QE),g=le(XE),b=le(JE),x=le(eT),y=le(tT),S=le(sT),m=le(nT),v=le(rT),w=Gs(oT),T=Gs(iT),k=Gs(aT),I=le(lT),B=fp();let O;if(t[3]!==B||t[4]!==I){let Ue;t[6]!==I?(Ue=gt=>gt.id===I,t[6]=I,t[7]=Ue):Ue=t[7],O=B.find(Ue),t[3]=B,t[4]=I,t[5]=O}else O=t[5];const F=O;let j,P;t[8]!==F||t[9]!==I?(j=()=>{I&&!F&&le.getState().setOpenGuestPage(null)},P=[I,F],t[8]=F,t[9]=I,t[10]=j,t[11]=P):(j=t[10],P=t[11]),l.useEffect(j,P);let L;t[12]===Symbol.for("react.memo_cache_sentinel")?(L=[],t[12]=L):L=t[12],l.useEffect(dT,L);let z;t[13]===Symbol.for("react.memo_cache_sentinel")?(z=[],t[13]=z):z=t[13],l.useEffect(uT,z);const H=u||f||p||h||g||!!b||x||c||!!F;let R,G;t[14]!==H?(R=()=>{Rp(H)},G=[H],t[14]=H,t[15]=R,t[16]=G):(R=t[15],G=t[16]),l.useLayoutEffect(R,G);let _;t[17]===Symbol.for("react.memo_cache_sentinel")?(_=[],t[17]=_):_=t[17],l.useEffect(pT,_);let $;t[18]===Symbol.for("react.memo_cache_sentinel")?($=[],t[18]=$):$=t[18],l.useEffect(mT,$);const{isMobile:E}=Rn();jy();let D,C;t[19]!==E||t[20]!==r?(D=()=>{le.getState().isMobile!==E&&r(E)},C=[E,r],t[19]=E,t[20]=r,t[21]=D,t[22]=C):(D=t[21],C=t[22]),l.useEffect(D,C);let N;t[23]!==y?(N=n.jsx(Ts,{needed:y,load:IE,onFailure:gT}),t[23]=y,t[24]=N):N=t[24];let A;t[25]!==S?(A=n.jsx(Ts,{needed:S,load:PE,onFailure:bT}),t[25]=S,t[26]=A):A=t[26];let q;t[27]!==m?(q=n.jsx(Ts,{needed:m,load:EE,onFailure:yT}),t[27]=m,t[28]=q):q=t[28];let ee;t[29]!==v?(ee=n.jsx(Ts,{needed:v,load:TE,onFailure:xT}),t[29]=v,t[30]=ee):ee=t[30];let Q,he;t[31]===Symbol.for("react.memo_cache_sentinel")?(Q=n.jsx(Cy,{}),he=n.jsx(KP,{}),t[31]=Q,t[32]=he):(Q=t[31],he=t[32]);let M;t[33]!==w||t[34]!==T||t[35]!==k||t[36]!==s?(M=s?n.jsxs(n.Fragment,{children:[n.jsx(Ts,{needed:w,load:_E,onFailure:ST}),n.jsx(Iy,{}),n.jsx(Ts,{needed:T,load:LE,onFailure:wT}),n.jsx(Py,{}),n.jsx(Ts,{needed:k,load:$E,onFailure:vT})]}):null,t[33]=w,t[34]=T,t[35]=k,t[36]=s,t[37]=M):M=t[37];let V;t[38]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Lv,{}),t[38]=V):V=t[38];let ie;t[39]!==E?(ie=n.jsx(jm,{isMobile:E}),t[39]=E,t[40]=ie):ie=t[40];let ce;t[41]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx(Dv,{}),t[41]=ce):ce=t[41];let ne;t[42]===Symbol.for("react.memo_cache_sentinel")?(ne=n.jsx(ua,{zone:"left"}),t[42]=ne):ne=t[42];const je=H&&"invisible";let Ee;t[43]!==je?(Ee=Pe("absolute inset-0",je),t[43]=je,t[44]=Ee):Ee=t[44];const we=!o&&!H;let Me;t[45]!==we?(Me=n.jsx(Cs,{children:n.jsx(Sf,{active:we})}),t[45]=we,t[46]=Me):Me=t[46];let fe;t[47]!==Ee||t[48]!==Me?(fe=n.jsx("div",{className:Ee,children:Me}),t[47]=Ee,t[48]=Me,t[49]=fe):fe=t[49];let be;t[50]!==c?(be=n.jsx(Cs,{children:n.jsx(Ts,{needed:c,load:DE,onFailure:xn})}),t[50]=c,t[51]=be):be=t[51];let ke;t[52]!==u?(ke=n.jsx(Cs,{children:n.jsx(Ts,{needed:u,load:RE,onFailure:xn})}),t[52]=u,t[53]=ke):ke=t[53];let Ie;t[54]!==f?(Ie=n.jsx(Cs,{children:n.jsx(Ts,{needed:f,load:NE,onFailure:xn})}),t[54]=f,t[55]=Ie):Ie=t[55];let Te;t[56]!==p?(Te=n.jsx(Cs,{children:n.jsx(Ts,{needed:p,load:ME,onFailure:xn})}),t[56]=p,t[57]=Te):Te=t[57];let Y;t[58]!==h?(Y=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Cs,{children:n.jsx(Ts,{needed:!0,load:AE,onFailure:xn})})}),t[58]=h,t[59]=Y):Y=t[59];let ue;t[60]!==g?(ue=n.jsx(Ts,{needed:g,load:OE,onFailure:xn}),t[60]=g,t[61]=ue):ue=t[61];const me=!!b;let re;t[62]!==me?(re=n.jsx(Cs,{children:n.jsx(Ts,{needed:me,load:BE,onFailure:xn})}),t[62]=me,t[63]=re):re=t[63];let pe;t[64]!==x?(pe=x?n.jsx(Cs,{children:n.jsx(Ts,{needed:!0,load:FE,onFailure:xn})}):null,t[64]=x,t[65]=pe):pe=t[65];let U;t[66]!==F?(U=F&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Cs,{children:n.jsx(WS,{mode:`plugin:${F.id}`,surface:"page",item:null,onDismiss:jT})})}),t[66]=F,t[67]=U):U=t[67];let ae;t[68]!==fe||t[69]!==be||t[70]!==ke||t[71]!==Ie||t[72]!==Te||t[73]!==Y||t[74]!==ue||t[75]!==re||t[76]!==pe||t[77]!==U?(ae=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[fe,be,ke,Ie,Te,Y,ue,re,pe,U]}),t[68]=fe,t[69]=be,t[70]=ke,t[71]=Ie,t[72]=Te,t[73]=Y,t[74]=ue,t[75]=re,t[76]=pe,t[77]=U,t[78]=ae):ae=t[78];let Re;t[79]===Symbol.for("react.memo_cache_sentinel")?(Re=n.jsx(ua,{zone:"bottom"}),t[79]=Re):Re=t[79];let W;t[80]!==ae?(W=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ae,Re]}),t[80]=ae,t[81]=W):W=t[81];let ye,de,Ne,Je;t[82]===Symbol.for("react.memo_cache_sentinel")?(ye=n.jsx(ua,{zone:"right"}),de=n.jsx(dC,{}),Ne=n.jsx(pC,{}),Je=n.jsx(bC,{}),t[82]=ye,t[83]=de,t[84]=Ne,t[85]=Je):(ye=t[82],de=t[83],Ne=t[84],Je=t[85]);let Ge;t[86]!==W?(Ge=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true","data-workspace-row":"true",children:[ne,n.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:[W,ye,de,Ne,Je]})]})}),t[86]=W,t[87]=Ge):Ge=t[87];let ge;t[88]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(Cs,{children:n.jsx(BC,{})})}),t[88]=ge):ge=t[88];let Ae;t[89]===Symbol.for("react.memo_cache_sentinel")?(Ae=n.jsx(Cs,{children:n.jsx(Iw,{})}),t[89]=Ae):Ae=t[89];let Ye;t[90]!==Ge?(Ye=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ce,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[Ge,ge,Ae]})]}),t[90]=Ge,t[91]=Ye):Ye=t[91];let nt;t[92]!==ie||t[93]!==Ye?(nt=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[ie,Ye]}),t[92]=ie,t[93]=Ye,t[94]=nt):nt=t[94];let oe;t[95]!==d||t[96]!==o||t[97]!==i?(oe=d?n.jsx(d,{open:o,onOpenChange:i}):null,t[95]=d,t[96]=o,t[97]=i,t[98]=oe):oe=t[98];let tt;return t[99]!==N||t[100]!==A||t[101]!==q||t[102]!==ee||t[103]!==M||t[104]!==nt||t[105]!==oe?(tt=n.jsx(HS.Provider,{value:!0,children:n.jsx(ky,{children:n.jsx(hE,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[N,A,q,ee,Q,he,M,V,nt,oe]})})})}),t[99]=N,t[100]=A,t[101]=q,t[102]=ee,t[103]=M,t[104]=nt,t[105]=oe,t[106]=tt):tt=t[106],tt};function KE(t){return t.isSidebarOpen}function WE(t){return t.isolatedSpacesEnabled}function HE(t){return t.setIsMobile}function UE(t){return t.isSettingsDialogOpen}function VE(t){return t.setSettingsDialogOpen}function GE(t){return t.runOverviewKey!==null}function qE(t){return t.isScheduledTasksDialogOpen}function YE(t){return t.isArchivePageOpen}function ZE(t){return t.isIntegrationsCatalogOpen}function QE(t){return t.isUsageStatsPageOpen}function XE(t){return t.isSourceBoardOpen}function JE(t){return t.worktreesPageProjectId}function eT(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function tT(t){return t.isCommandPaletteOpen}function sT(t){return t.isHelpDialogOpen}function nT(t){return t.isProjectActionsDialogOpen}function rT(t){return t.isOpenCodeStatusDialogOpen}function oT(t){return t.accessDialog!==null}function iT(t){return t.applyDialog!==null}function aT(t){return t.setupOutputDialog!==null}function lT(t){return t.openGuestPageId}function cT(){return le.getState().setOpenGuestPage(null)}function dT(){return ri(cT)}function uT(){return Cw()}function fT(){return Rp(!1)}function pT(){return fT}function hT(){return le.getState().closeMainSurfaces()}function mT(){const t=hT,e=mt.subscribe((s,r)=>{const o=!!s.currentSessionId&&s.currentSessionId!==r.currentSessionId,i=!!s.newSessionDraft?.open&&s.newSessionDraft!==r.newSessionDraft;(o||i)&&t()});return()=>{e()}}function gT(){return le.getState().setCommandPaletteOpen(!1)}function bT(){return le.getState().setHelpDialogOpen(!1)}function yT(){return le.getState().setProjectActionsDialogOpen(!1)}function xT(){return le.getState().setOpenCodeStatusDialogOpen(!1)}function ST(){return Gs.getState().closeAccessDialog()}function wT(){return Gs.getState().closeApplyDialog()}function vT(){return Gs.getState().closeSetupOutputDialog()}function jT(){return le.getState().setOpenGuestPage(null)}const km=12,kT=[{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"}],CT=t=>{const e=Ze.c(18),{isActive:s,burstKey:r,className:o,durationMs:i,bursts:a,onComplete:d}=t,c=r===void 0?0:r,u=i===void 0?900:i,f=a===void 0?kT:a,p=us.useRef(!1);let h,g;e[0]!==s||e[1]!==d?(h=()=>{!s&&p.current&&d?.(),s&&(p.current=!0)},g=[s,d],e[0]=s,e[1]=d,e[2]=h,e[3]=g):(h=e[2],g=e[3]),us.useEffect(h,g);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:km},IT),e[4]=b):b=e[4];const x=b;if(!s)return null;let y;e[5]!==o?(y=Pe("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=y):y=e[6];let S;if(e[7]!==c||e[8]!==f||e[9]!==u){let v;e[11]!==c||e[12]!==u?(v=w=>{const T={"--burst-delay":`${w.delay}ms`,"--burst-x":`${w.x}%`,"--burst-y":`${w.y}%`,"--firework-color":`var(${w.colorVar})`,"--firework-duration":`${u}ms`};return n.jsx("div",{className:"firework-burst",style:T,children:x.map((k,I)=>{const B=k.x*w.radius,O=k.y*w.radius,F={"--translate-x":`${B}px`,"--translate-y":`${O}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:F},`${w.id}-${I}-${c}`)})},`${w.id}-${c}`)},e[11]=c,e[12]=u,e[13]=v):v=e[13],S=f.map(v),e[7]=c,e[8]=f,e[9]=u,e[10]=S}else S=e[10];let m;return e[14]!==c||e[15]!==y||e[16]!==S?(m=n.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":c,children:S}),e[14]=c,e[15]=y,e[16]=S,e[17]=m):m=e[17],m};function IT(t,e){const s=Math.PI*2*e/km;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const PT=t=>{const e=Ze.c(13);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{durationMs:r}=s,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[a,d]=us.useState(i),c=us.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c.current&&(window.clearTimeout(c.current),c.current=null)},e[3]=u):u=e[3];const f=u;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f(),d(ET)},e[4]=p):p=e[4];const h=p;let g;e[5]!==o?(g=()=>{f(),d(TT),c.current=window.setTimeout(()=>{d(DT),c.current=null},o)},e[5]=o,e[6]=g):g=e[6];const b=g;let x,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>()=>f(),y=[f],e[7]=x,e[8]=y):(x=e[7],y=e[8]),us.useEffect(x,y);let S;return e[9]!==a.cycle||e[10]!==a.isActive||e[11]!==b?(S={isActive:a.isActive,burstKey:a.cycle,triggerFireworks:b,dismissFireworks:h},e[9]=a.cycle,e[10]=a.isActive,e[11]=b,e[12]=S):S=e[12],S};function ET(t){return t.isActive?{...t,isActive:!1}:t}function TT(t){return{isActive:!0,cycle:t.cycle+1}}function DT(t){return t.isActive?{...t,isActive:!1}:t}const Cm=l.createContext(void 0),RT=t=>{const e=Ze.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:a}=PT();let d;e[0]!==a||e[1]!==i?(d={triggerFireworks:i,dismissFireworks:a},e[0]=a,e[1]=i,e[2]=d):d=e[2];const c=d;let u;e[3]!==o||e[4]!==r?(u=n.jsx(CT,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==s||e[7]!==u||e[8]!==c?(f=n.jsxs(Cm.Provider,{value:c,children:[s,u]}),e[6]=s,e[7]=u,e[8]=c,e[9]=f):f=e[9],f},yR=()=>{const t=l.useContext(Cm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},hl="openchamber_requests_in_flight",Im=1e3,NT=300*1e3,si=Math.ceil(NT/Im),MT=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(hl)==="1"}catch{return!1}},Pm=()=>({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 AT=1;const OT=(t,e)=>{const s=window.__openchamberRequestsInFlight__;!s||!s.enabled||(s.inFlight+=1,s.totalStarted+=1,s.inFlight>s.peak&&(s.peak=s.inFlight),s.inFlightStarts.set(t,e))},BT=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},Em=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),s=[];for(const r of t.inFlightStarts.values())s.push(Math.max(0,e-r));return s.sort((r,o)=>r-o),s},cr=(t,e)=>{const s=t.length;if(s===0)return 0;if(s===1)return t[0];const r=e/100*(s-1),o=Math.floor(r),i=Math.ceil(r);return o===i?t[o]:t[o]+(t[i]-t[o])*(r-o)},FT=()=>{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 s=async(r,o)=>{const i=AT++;OT(i,Date.now());try{return await e(r,o)}finally{BT(i)}};window.fetch=s},Au=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Pr=t=>{t.length>si&&t.splice(0,t.length-si)},_T=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=Em(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(cr(e,50)),t.p90Samples.push(cr(e,90)),t.p99Samples.push(cr(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,Pr(t.samples),Pr(t.p50Samples),Pr(t.p90Samples),Pr(t.p99Samples),Pr(t.maxSamples),t.lastSampleAt=Date.now()},LT=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(_T,Im))},Ou=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Bu=t=>{if(!(typeof window>"u"))try{if(t){Ou(),Au(),window.localStorage.setItem(hl,"1"),window.__openchamberRequestsInFlight__=Pm(),FT(),LT();return}window.localStorage.removeItem(hl),Ou(),Au(),delete window.__openchamberRequestsInFlight__}catch{}},xR=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Pm();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},SR=()=>{if(typeof window>"u")return Fu();const t=window.__openchamberRequestsInFlight__;if(!MT()||!t)return Fu();const e=Em(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:cr(e,50),ageP90:cr(e,90),ageP99:cr(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:si}},Fu=()=>({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:si}),$T=()=>{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()??"":""},zT=async()=>{const t=$T()||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")},_u="openchamber:menu-action",Lu="openchamber:check-for-updates",KT=t=>{const e=Ze.c(21),{t:s}=Et(),r=mt(WT),o=le(HT),i=le(UT),a=le(VT),d=le(GT),c=le(qT),u=le(YT),f=le(ZT),p=Rr(QT),{setThemeMode:h}=br(),g=l.useRef(!1);let b;e[0]!==p?(b=()=>{g.current||(g.current=!0,p().then(XT).finally(()=>{g.current=!1}))},e[0]=p,e[1]=b):b=e[1];const x=b,y=JT;let S;e[2]!==c?(S=B=>{const O=US();if(O.length===0)return;const F=mt.getState().currentSessionId,j=O.findIndex(z=>z.id===F);let P=B>0?0:O.length-1;j>=0&&(P=(j+B+O.length)%O.length);const L=O[P];L&&(c(!1),mt.getState().setCurrentSession(L.id))},e[2]=c,e[3]=S):S=e[3];const m=S,v=eD;let w;e[4]!==m||e[5]!==t||e[6]!==r||e[7]!==f||e[8]!==i||e[9]!==c||e[10]!==u||e[11]!==h||e[12]!==s||e[13]!==o||e[14]!==a||e[15]!==d?(w=B=>{e:switch(B){case"about":{f(!0);break e}case"settings":{u(!0);break e}case"command-palette":{o();break e}case"quick-open":{i(!0);break e}case"new-session":{c(!1);const O=mt.getState(),F=Ps.getState().currentDirectory;r(O.currentSessionId&&F?{directoryOverride:F}:void 0);break e}case"new-worktree-session":{c(!1),qS();break e}case"change-workspace":{y();break e}case"toggle-right-sidebar":{const O=Ps.getState().currentDirectory;if(!O)break e;const F=le.getState(),j=Ds(O),P=F.contextPanelByDirectory[j],L=P?eb(P.tabs,F.contextSurfaceZones,"right",oi(P,"right").activeTabId):null;P?.isOpen?F.closeContextPanel(j):L?F.setActiveContextPanelTab(j,L):F.openContextSurface(j,"git");break e}case"open-right-sidebar-git":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"git");break e}case"open-right-sidebar-files":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"file");break e}case"toggle-terminal":{const O=Ps.getState().currentDirectory;if(!O)break e;le.getState().openContextSurface(Ds(O),"terminal");break e}case"toggle-terminal-expanded":{const O=Ps.getState().currentDirectory;if(!O)break e;const F=Ds(O),j=le.getState(),P=j.contextPanelByDirectory[F];bl(P,j.contextSurfaceZones).has("terminal")||j.openContextSurface(F,"terminal"),j.toggleContextPanelExpanded(F,Ao(j.contextSurfaceZones,"terminal"));break e}case"copy":{const O=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(O)||zT();break e}case"theme-light":{h("light");break e}case"theme-dark":{h("dark");break e}case"theme-system":{h("system");break e}case"add-selection-to-chat":{GS();break e}case"toggle-sidebar":{d();break e}case"toggle-memory-debug":{t?.();break e}case"go-back":{rd(-1);break e}case"go-forward":{rd(1);break e}case"previous-session":{m(-1);break e}case"next-session":{m(1);break e}case"previous-project":{v(-1);break e}case"next-project":{v(1);break e}case"help-dialog":{a();break e}case"download-logs":VS().catch(()=>{He.error(s("openCodeStatusDialog.toast.collectFailed"))})}},e[4]=m,e[5]=t,e[6]=r,e[7]=f,e[8]=i,e[9]=c,e[10]=u,e[11]=h,e[12]=s,e[13]=o,e[14]=a,e[15]=d,e[16]=w):w=e[16];const T=w;let k,I;e[17]!==T||e[18]!==x?(k=()=>{const B=F=>{const j=F.detail;j&&T(j)},O=()=>{x()};return window.addEventListener(_u,B),window.addEventListener(Lu,O),()=>{window.removeEventListener(_u,B),window.removeEventListener(Lu,O)}},I=[T,x],e[17]=T,e[18]=x,e[19]=k,e[20]=I):(k=e[19],I=e[20]),l.useEffect(k,I)};function WT(t){return t.openNewSessionDraft}function HT(t){return t.toggleCommandPalette}function UT(t){return t.setCommandPaletteOpen}function VT(t){return t.toggleHelpDialog}function GT(t){return t.toggleSidebar}function qT(t){return t.setSessionSwitcherOpen}function YT(t){return t.setSettingsDialogOpen}function ZT(t){return t.setAboutDialogOpen}function QT(t){return t.checkForUpdates}function XT(){const{available:t,error:e}=Rr.getState();if(e){He.error("Failed to check for updates",{description:e});return}t||He.success("You are on the latest version")}function JT(){Tn.requestDirectoryDialog()}function eD(t){const{activeProjectId:e,projects:s,setActiveProject:r}=ns.getState();if(s.length===0)return;const o=s.findIndex(d=>d.id===e);let i=t>0?0:s.length-1;o>=0&&(i=(o+t+s.length)%s.length);const a=s[i];a&&r(a.id)}const tD="openchamber:tray-action",sD=5e3,nD=500,rD=20,$u=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},zu=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Tm=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Dm=t=>t.title.trim()||"Question",oD=new Set,iD=(t,e)=>Kl(t,e,oD,Op.getState().rankById),aD=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},lD=(t,e,s,r,o)=>{if(!t)return"";const i=kf(s,r,t),a=e.project?.name,d=i?.label?.trim()||a?.trim()||aD(t),c=$a(t);let u=c&&o.get(c)||"";if(!u){for(const[f,p]of Cn.getState().directories)if($a(f)===c){u=p.status?.current??"";break}}if(!u)for(const f of r.values()){const p=c?Lr(f,c):void 0;if(p?.branch){u=p.branch;break}}return u?`${d} · ${u}`:d},cD=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=Jn.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(a=>[a.providerId,a])),i=[];for(const a of QS){if(!e.includes(a.id))continue;const d=o.get(a.id);if(!d||d.configured!==!0)continue;const c=[];for(const[f,p]of Object.entries(d.usage?.windows??{})){const h=r==="remaining"?p.remainingPercent:p.usedPercent;c.push({label:JS(f),value:XS(p.valueLabel,h)})}const u=!d.ok&&d.error?d.error:c.length===0?"No rate limits reported":null;i.push({provider:a.name,rows:c,status:u})}return{mode:r,groups:i}},dD=async()=>{try{if(li())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=tb();if(e&&Tc(e,t))return"Local OpenChamber";const r=(await ci()).hosts.find(o=>e?Tc(e,af(o)):!1);return r?.label?.trim()?tf(r.label.trim()):"Instance"}catch{return""}},uD=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=La()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,a]of o.children.entries()){const d=a.getState();d.vcs?.branch&&e.set($a(i)??i,d.vcs.branch);for(const c of d.session)c?.id&&r.set(c.id,c.title);for(const[c,u]of Object.entries(d.session_status??{})){const f=u?.type,p=f==="busy"?"busy":f==="retry"?"retry":"idle",h=t.get(c);(!h||h==="idle")&&t.set(c,p)}for(const[c,u]of Object.entries(d.permission??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;s.push({kind:"permission",id:f.id,sessionId:p,sessionTitle:"",label:Tm(f),directory:i,canSave:Bp(f.save)})}for(const[c,u]of Object.entries(d.form??{}))for(const f of u??[]){if(!f?.id)continue;const p=f.sessionID||c;s.push({kind:"form",id:f.id,sessionId:p,sessionTitle:"",label:Dm(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},fD=(t,e)=>{const s=Np.getState().index.session,r=Os.getState().activeSessions,o=ZS(r),i=m=>o.descendantsOf(m,"active").map(v=>v.id),a=le.getState();let d=0;if(a.dockBadgeEnabled)for(const m of r){if(!m?.id||m.parentID)continue;let v=s.unseenCount[m.id]??0;v===0&&a.notifyOnSubtasks&&(v=i(m.id).reduce((w,T)=>w+(s.unseenCount[T]??0),0)),v>0&&(d+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:d};const c=uD(),u=new Map(c.titleById);for(const m of r)m?.id&&m.title&&u.set(m.id,m.title);const f=Mp.getState().statusById,p=m=>{const v=c.statusById.get(m);return v&&v!=="idle"?v:f.get(m)?.status.type??v??"idle"},h=m=>{const v=m.map(w=>p(w));return v.includes("busy")?"busy":v.includes("retry")?"retry":"idle"},g=ns.getState().projects,b=mt.getState().availableWorktreesByProject,x=r.filter(m=>m?.id&&!m.parentID).slice().sort(iD).slice(0,rD).map(m=>{const v=[m.id,...i(m.id)],w=ur(m)??"";return{id:m.id,title:m.title||"Untitled session",status:h(v),branch:w?c.branchByDirectory.get(w)??"":"",unseen:v.reduce((T,k)=>T+(s.unseenCount[k]??0),0),hasError:v.some(T=>s.unseenHasError[T]??!1),directory:w,subtitle:lD(w,m,g,b,c.branchByDirectory)}}),y=c.approvals.map(m=>({...m,sessionTitle:u.get(m.sessionId)||""})),S=new Set(y.map(m=>m.id));for(const[m,v]of Ap.getState().bySession){const w=u.get(m)||"";for(const T of v.permissions)S.has(T.id)||(S.add(T.id),y.push({kind:"permission",id:T.id,sessionId:m,sessionTitle:w,label:Tm(T),directory:v.directory,canSave:Bp(T.save)}));for(const T of[...v.forms,...v.pages])S.has(T.id)||(S.add(T.id),y.push({kind:"form",id:T.id,sessionId:m,sessionTitle:w,label:Dm(T),directory:v.directory,canSave:!1}))}return{sessions:x,approvals:y,instanceName:t,usage:cD(),dockBadgeCount:d}},pD=()=>{l.useEffect(()=>{if(!$u()||!Do())return;const t=zu();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const k=fD(o,t),I=JSON.stringify(k);I!==s&&(s=I,vn("desktop_tray_update",k))},a=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},nD))},d=Np.subscribe(()=>a()),c=Os.subscribe(()=>a()),u=le.subscribe((k,I)=>{(k.dockBadgeEnabled!==I.dockBadgeEnabled||k.notifyOnSubtasks!==I.notifyOnSubtasks)&&a()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),d(),c(),u()};if(!t)return i(),f;dD().then(k=>{e||(o=k,i())});const p=new Map,h=()=>{if(e)return;let k;try{k=La()}catch{return}const I=new Set;for(const[B,O]of k.children.entries())I.add(B),p.has(B)||p.set(B,O.subscribe(()=>a()));for(const[B,O]of p)I.has(B)||(O(),p.delete(B))};let g=null;try{g=La().subscribeRegistry(()=>{h(),a()})}catch{}h();const b=ns.subscribe(()=>a()),x=mt.subscribe(()=>a()),y=Cn.subscribe(()=>a()),S=Mp.subscribe(()=>a()),m=Ap.subscribe(()=>a()),v=Op.subscribe(()=>a()),w=Jn.subscribe(()=>a());Jn.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:k,results:I}=Jn.getState();k.length>0&&k.some(O=>!I.some(F=>F.providerId===O))&&Jn.getState().fetchQuotas(k)});const T=window.setInterval(()=>{h(),i()},sD);return i(),()=>{f(),window.clearInterval(T),b(),x(),y(),S(),m(),v(),w(),g?.();for(const k of p.values())k();p.clear()}},[]),l.useEffect(()=>{if(!$u()||!zu()||!Do())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&YS(o.sessionId,o.id,o.response).catch(()=>{He.error("Failed to respond to permission request")})};let r=null;return e(tD,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||s(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},hD=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,mD=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,gD=t=>{t.kind!=="plugin"||!t.title||He.info(t.title,{id:mD(t.kind,t.title,t.body,t.tag),description:t.body})},bD=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,yD=t=>{const e=Ze.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(hn()||!lf()||!globalThis.window))return En(xD)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function xD(t){if(t.type!=="notification")return;const e=le.getState();if(!e.nativeNotificationsEnabled)return;const s=hD();if(bD(t.payload,s)){gD(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;of()?.notifications?.notifyAgentCompletion(t.payload)}const SD=()=>{const t=Ze.c(4),{t:e}=Et(),s=le(wD);let r,o;t[0]!==s||t[1]!==e?(r=()=>En(i=>{i.type==="browser-provider-reset"&&(s("builtin"),He.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:i.guestName})))}),o=[s,e],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),l.useEffect(r,o)};function wD(t){return t.setBrowserProvider}const Ku="relay-limit-reached",vD=()=>{const t=Ze.c(3),{t:e}=Et();let s,r;t[0]!==e?(s=()=>{const o=()=>{He.error(e("relayConnection.limitReached.title"),{id:Ku,description:e("relayConnection.limitReached.description"),duration:1/0,action:{label:e("relayConnection.limitReached.retry"),onClick:jD}})};return Dc(cf()?.getStatus())&&o(),sb(a=>{Dc(a)?o():(a.state==="connected"||a.state==="idle")&&He.dismiss(Ku)})},r=[e],t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]),l.useEffect(s,r)};function jD(){return cf()?.retry()}const Wu=()=>{nb()||(Ey(),ew(Ty.map(t=>t.id)))},kD=(t,e)=>{const s=Ze.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const a=window.requestIdleCallback(Wu,{timeout:1e4});return()=>window.cancelIdleCallback(a)}const i=setTimeout(Wu,3e3);return()=>clearTimeout(i)},s[0]=t,s[1]=r):r=s[1];let o;s[2]!==e||s[3]!==t?(o=[t,e],s[2]=e,s[3]=t,s[4]=o):o=s[4],l.useEffect(r,o)},Hu="pwa-install-toast-shown",Uu="pwa-install-toast-dismissed",CD=()=>{const t=Ze.c(6),{browserTab:e}=Dy(),{t:s}=Et(),r=l.useRef(s);let o,i;t[0]!==s?(o=()=>{r.current=s},i=[s],t[0]=s,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let a,d;t[3]!==e?(a=()=>{if(typeof window>"u"||!lf()||!e)return;let c=null,u=null;const f=()=>{u!==null&&(He.dismiss(u),u=null)},p=async()=>{if(!c)return;const b=c;c=null,f(),await b.prompt();const{outcome:x}=await b.userChoice;x==="accepted"&&He.success(r.current("pwa.installPrompt.started"))},h=b=>{const x=b;if(typeof x.prompt!="function")return;x.preventDefault(),c=x;const y=Oo(),S=rb();Ry({dismissed:y.getItem(Uu),sessionShown:S.getItem(Hu),hasActiveToast:u!==null})&&(S.setItem(Hu,"true"),u=He.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{p()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Oo().setItem(Uu,"true"),f()}}}))},g=()=>{c=null,f(),He.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",h),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",h),window.removeEventListener("appinstalled",g)}},d=[e],t[3]=e,t[4]=a,t[5]=d):(a=t[4],d=t[5]),l.useEffect(a,d)},Rm=()=>globalThis.window?.__OPENCHAMBER_SAFE_START__===!0,ID=()=>{Vs.setState({byRoot:{},runtimeSnapshots:{}});const t=le.getState();for(const e of Object.keys(t.contextPanelByDirectory))for(const s of Xu)t.closeContextZone(e,s)},PD=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",Nm=async(t,e)=>{const s=(await ci()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await lb(s.id,e);return}const r=cb(af(s));if(!r)throw new Error("host-not-found");db({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:ub(s),sshForwarded:s.sshForwarded===!0})},ED=async t=>{const e=await ci(),s=await ib(t,e.hosts);await ab({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await Nm(s.hostId,{reconnectActive:!0})},TD=async t=>{const e=await ob();for(const s of e)try{s.type==="pairing"?await ED(s.link):await Nm(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(PD(o))}},ml="project-config-invalid",DD=()=>{const t=Ze.c(9),{t:e}=Et(),s=ps(RD);let r;t[0]!==s?(r=h=>h.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ps(r),[i,a]=us.useState(!1);let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const h=ps.getState(),g=h.activeDirectoryKey;a(!0),Promise.all([h.loadProviders({directory:g,source:"projectConfigError:retry"}),h.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>a(!1))},t[2]=d):d=t[2];const c=d;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){He.dismiss(ml);return}He.error(e("projectConfigError.toast.title"),{id:ml,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:h=>{h.preventDefault(),i||c()}}})},f=[o,i,c,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),us.useEffect(u,f);let p;return t[8]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[8]=p):p=t[8],us.useEffect(MD,p),null};function RD(t){return t.activeDirectoryKey}function ND(){He.dismiss(ml)}function MD(){return ND}const AD="\x1B",OD=new RegExp(`${AD}\\[[0-9;?]*[ -/]*[@-~]`,"g"),yo=zs().transform(t=>t.replace(OD,"").trim()).nullish(),BD=Ko({isOpenCodeReady:Ha().optional(),openCodeRunning:Ha().optional(),lastOpenCodeError:yo,opencodeBinaryResolved:yo,lastOpenCodeLaunchDiagnostics:Ko({sourceBinary:yo,binary:yo}).nullish()}),FD=async(t,e=Ys)=>{const s=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)throw new Error(`Startup diagnostics request failed (${s.status})`);const r=BD.parse(await s.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}},_D=(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=Ko({openchamberVersion:zs()}),$D=async(t,e=Ys)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=LD.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},zD=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function KD({version:t}){const{t:e}=Et(),[s,r]=l.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const d=await Ny();r(d.available&&!d.installBlocked?{kind:"available",info:d}:{kind:"manual",info:d,error:null})}catch(d){r({kind:"manual",info:null,error:d instanceof Error?d.message:null})}},i=s.kind==="manual"?s:null,a=i?.info?.updateCommand||"openchamber update";return n.jsxs("div",{className:"flex w-full flex-col items-center gap-3",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"typography-h1 text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-markdown text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(Nt,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx(Z,{name:s.kind==="checking"?"loader":"download",className:s.kind==="checking"?"size-4 animate-spin":"size-4"}),s.kind==="checking"?e("startup.serverOutdated.checking"):e("onboarding.desktopRecovery.remoteIncompatible.updateServer")]}),i&&n.jsxs("div",{className:"w-full space-y-2 text-start",children:[!i.info?.available&&n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("startup.serverOutdated.noUpdate")}),i.error&&n.jsx("p",{className:"typography-meta text-muted-foreground",children:i.error}),i.info?.installBlocked==="desktop-host"?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:i.info.version||""})}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("onboarding.desktopRecovery.remoteIncompatible.manualUpdate")}),n.jsx("code",{className:"block select-text rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono text-sm text-foreground",children:a})]})]}),n.jsx(jl,{open:s.kind==="available",onOpenChange:d=>{d||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Vu=Xr(()=>as(()=>import("./OnboardingScreen-xzT7ckY0.js"),__vite__mapDeps([172,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])).then(t=>({default:t.OnboardingScreen}))),WD=()=>as(()=>import("./AboutDialog-C8mAGhnz.js"),__vite__mapDeps([173,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])).then(t=>t.AboutDialog),HD=()=>as(()=>import("./MemoryDebugPanel-9z1jGWze.js"),__vite__mapDeps([174,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,122,123])).then(t=>t.MemoryDebugPanel),UD=()=>{const t=Ze.c(6),e=le(ZD),s=le(QD);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=Ni(e,WD,r);if(!o)return null;let i;return t[2]!==o||t[3]!==e||t[4]!==s?(i=n.jsx(o,{open:e,onOpenChange:s}),t[2]=o,t[3]=e,t[4]=s,t[5]=i):i=t[5],i},VD=t=>{const e=Ze.c(3),{onClose:s}=t,r=Ni(!0,HD,s);let o;return e[0]!==r||e[1]!==s?(o=r?n.jsx(r,{onClose:s}):null,e[0]=r,e[1]=s,e[2]=o):o=e[2],o},GD=t=>{const e=Ze.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=Et(),[i,a]=l.useState(null);let d,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const O=new AbortController,F=Jt(),j=setTimeout(()=>O.abort(),5e3);return FD(O.signal).then(P=>{!O.signal.aborted&&Jt()===F&&a(P)}).catch(XD).finally(()=>clearTimeout(j)),()=>{O.abort(),clearTimeout(j)}},c=[],e[0]=d,e[1]=c):(d=e[0],c=e[1]),l.useEffect(d,c);const[u,f]=l.useState(null);let p,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{const O=new AbortController,F=Jt(),j=setTimeout(()=>O.abort(),5e3);return $D(O.signal).then(P=>{O.signal.aborted||Jt()!==F||f(P&&zD(P)?P:null)}).catch(JD).finally(()=>clearTimeout(j)),()=>{O.abort(),clearTimeout(j)}},h=[],e[2]=p,e[3]=h):(p=e[2],h=e[3]),l.useEffect(p,h);const g=ps(eR),b=i?null:g?.message??null;if(u){let O;e[4]!==u?(O=n.jsx(KD,{version:u}),e[4]=u,e[5]=O):O=e[5];let F;e[6]!==r||e[7]!==o?(F=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=F):F=e[8];let j;e[9]!==r||e[10]!==s||e[11]!==F?(j=n.jsx(Nt,{type:"button",variant:"outline",onClick:s,disabled:r,children:F}),e[9]=r,e[10]=s,e[11]=F,e[12]=j):j=e[12];let P;return e[13]!==O||e[14]!==j?(P=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[O,j]})}),e[13]=O,e[14]=j,e[15]=P):P=e[15],P}let x;e[16]!==o?(x=o("startup.initRecovery.title"),e[16]=o,e[17]=x):x=e[17];let y;e[18]!==x?(y=n.jsx("h1",{className:"typography-h1 text-foreground",children:x}),e[18]=x,e[19]=y):y=e[19];let S;e[20]!==i||e[21]!==g||e[22]!==o?(S=o(_D(i,g)),e[20]=i,e[21]=g,e[22]=o,e[23]=S):S=e[23];let m;e[24]!==S?(m=n.jsx("p",{className:"typography-markdown text-muted-foreground",children:S}),e[24]=S,e[25]=m):m=e[25];let v;e[26]!==y||e[27]!==m?(v=n.jsxs("div",{className:"flex flex-col gap-2",children:[y,m]}),e[26]=y,e[27]=m,e[28]=v):v=e[28];let w;e[29]!==b||e[30]!==o?(w=b&&n.jsxs("dl",{className:"w-full min-w-0 text-start","aria-live":"polite",children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.lastError")}),n.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:b})]}),e[29]=b,e[30]=o,e[31]=w):w=e[31];let T;e[32]!==i||e[33]!==o?(T=i&&n.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-start","aria-live":"polite",children:[i.binary&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.binary")}),n.jsx("dd",{className:"break-all font-mono typography-meta",children:i.binary})]}),i.error&&n.jsxs("div",{children:[n.jsx("dt",{className:"typography-meta text-muted-foreground",children:o("startup.initRecovery.error")}),n.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:i.error})]})]}),e[32]=i,e[33]=o,e[34]=T):T=e[34];let k;e[35]!==r||e[36]!==o?(k=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=k):k=e[37];let I;e[38]!==r||e[39]!==s||e[40]!==k?(I=n.jsx(Nt,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=I):I=e[41];let B;return e[42]!==w||e[43]!==T||e[44]!==I||e[45]!==v?(B=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[v,w,T,I]})}),e[42]=w,e[43]=T,e[44]=I,e[45]=v,e[46]=B):B=e[46],B};function qD({apis:t}){l.useEffect(()=>tw(),[]),l.useEffect(()=>{fb("App:mounted"),pb()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ps(M=>M.initializeApp),s=ps(M=>M.isInitialized),r=ps(M=>M.isConnected),o=ps(M=>M.providersLoaded),i=ps(M=>M.agentsLoaded),a=ps(M=>M.loadProviders),d=ps(M=>M.loadAgents),c=mt(M=>M.error),u=mt(M=>M.clearError),f=Ps(M=>M.currentDirectory),p=Ps(M=>M.isSwitchingDirectory),[h,g]=l.useState(!1),b=kn(M=>M.refreshAll),x=sw(M=>M.refreshStatus),[y,S]=l.useState(()=>t.runtime.isVSCode),[m,v]=l.useState(!1),[w,T]=l.useState(0),[k,I]=l.useState(0),[B,O]=l.useState(!1),F=le(M=>M.wideChatLayoutEnabled),j=le(M=>M.mobileKeyboardMode),P=l.useMemo(()=>hn(),[]),[L,z]=l.useState(()=>Rc()),[H,R]=l.useState(()=>{const M=Zi();return M!==null?Nc({isDesktopShell:!0,bootOutcome:M}):null}),G=l.useRef(!1),{t:_}=Et(),$=l.useRef(!1);l.useEffect(()=>{if(!s||L!=="valid"||$.current)return;const M=Zi();M?.target!=="local"||M.status!=="ok"||!M.sshStartupFallbackHostId||($.current=!0,He.error(_("desktopHostSwitcher.startup.title"),{description:_("desktopHostSwitcher.startup.fellBackToLocal")}))},[L,s,_]);const E=l.useRef(!1);l.useEffect(()=>{!s||!Rm()||E.current||(E.current=!0,He.info(_("desktopSafeStart.title"),{description:_("desktopSafeStart.description"),duration:1/0}))},[s,_]),l.useEffect(()=>(Mc(h),Bu(h),()=>{Mc(!1),Bu(!1)}),[h]),l.useEffect(()=>{hb(j)},[j]),l.useEffect(()=>{S(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>ri(M=>{Ay(M)&&Oy(M),I(V=>V+1),v(!1),T(V=>V+1)}),[]);const D=od(M=>{const V=Jt();return Object.values(M.runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===V).map(ie=>`${ie.originalSessionID}:${ie.phase}:${ie.lastForwardedMessageID??""}:${ie.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{const M=Jt(),V=Object.values(od.getState().runsByOriginalSessionID).filter(ie=>ie.status==="running"&&ie.runtimeKey===M);for(const ie of V)nw(ie.originalSessionID)},[D,k]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",F),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[F]),l.useEffect(()=>(Ac(t),()=>Ac(null)),[t]),l.useEffect(()=>{r&&(b(t.sourceControl,{force:!0}),x(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,b,x,k]),rw();const C=L==="valid",N=H?.screen==="main";l.useEffect(()=>{if(!mb({isDesktopShell:P,bootOutcomeKnown:C}))return;ow();const M=setTimeout(()=>{const V=document.getElementById("initial-loading");V&&(V.classList.add("fade-out"),setTimeout(()=>{V.remove()},300))},150);return()=>clearTimeout(M)},[P,C]),l.useEffect(()=>{if(!P||L!=="malformed")return;const M=document.getElementById("initial-loading");M&&(M.textContent="Desktop startup failed — please restart the app.")},[P,L]),l.useEffect(()=>{y||e()},[e,y]),l.useEffect(()=>{if(y||s)return;let M=!0,V,ie=0;const ce=10,ne=1e3,je=async()=>{if(!M)return;if(ie>=ce){v(!0);return}const Ee=ps.getState();if(Ee.isInitialized){v(!1);return}ie+=1,await Ee.initializeApp();const we=ps.getState();if(!M)return;if(we.isInitialized){v(!1);return}if(ie>=ce){v(!0);return}const Me=Math.min(ne*Math.pow(2,ie-1),4e3);V=setTimeout(je,Me)};return V=setTimeout(je,ne),()=>{M=!1,V&&clearTimeout(V)}},[w,s,y]),l.useEffect(()=>{s&&v(!1)},[s]),l.useEffect(()=>{if(!m)return;const M=document.getElementById("initial-loading");M&&(M.classList.add("fade-out"),setTimeout(()=>{M.remove()},300))},[m]),l.useEffect(()=>{if(y||!r||o&&i)return;let M=!0,V=0;const ie=15,ce=async()=>{const je=ps.getState();if(!(je.providersLoaded&&je.agentsLoaded))try{je.providersLoaded||await a({source:"startupRecovery"}),ps.getState().agentsLoaded||await d({source:"startupRecovery"})}catch{}};ce();const ne=setInterval(()=>{if(M){if(++V>=ie){clearInterval(ne);return}ce()}},2e3);return()=>{M=!1,clearInterval(ne)}},[r,y,d,a,o,i]),l.useEffect(()=>{p||y||r&&Mo.setDirectory(f)},[f,p,r,y]),l.useEffect(()=>{if(typeof window>"u")return;const M=V=>{const ie=V.detail,ce=typeof ie?.sessionId=="string"?ie.sessionId.trim():"";if(!ce)return;const ne=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null,je=String(ie?.runtimeKey??"").trim();if(!(je&&je!==Jt()&&xb(je,ce))){if(!ne){id(ce,typeof ie?.messageId=="string"?ie.messageId.trim():null);return}mt.getState().setCurrentSession(ce,ne)}};return window.addEventListener("openchamber:open-session",M),gb().then(V=>{for(const ie of V)id(ie.sessionId,ie.messageId)}),()=>window.removeEventListener("openchamber:open-session",M)},[]),l.useEffect(()=>{if(!hn())return;const M=()=>{TD(V=>{He.error(_(V==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":V==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",M),M(),()=>window.removeEventListener("openchamber:host-actions-ready",M)},[_]);const A=l.useRef({attempt:null,running:!1,done:!1});l.useLayoutEffect(()=>{const M=A.current;M.attempt||(M.attempt=By({selectNow:!Fy().sessionId}))},[]),l.useEffect(()=>{const M=A.current,V=()=>{const ie=M.attempt;if(!ie||M.running||M.done)return;const ce=ps.getState().isInitialized;M.running=!0,ie().then(ne=>{if(M.running=!1,ne!=="failed"||ce){M.done=!0;return}ps.getState().isInitialized&&V()})};V()},[s]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{vn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null,...Tr()})};return window.addEventListener("openchamber:open-mini-chat",M),()=>window.removeEventListener("openchamber:open-mini-chat",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=()=>{const V=mt.getState().currentSessionId;V&&dp(V)};return window.addEventListener("focus",M),()=>window.removeEventListener("focus",M)},[]),l.useEffect(()=>{if(typeof window>"u")return;const M=V=>{const ie=V.detail,ce=typeof ie?.directory=="string"&&ie.directory.trim().length>0?ie.directory.trim():null,ne=typeof ie?.projectId=="string"&&ie.projectId.trim().length>0?ie.projectId.trim():null,je=!!(ce||ne);le.getState().setSessionSwitcherOpen(!1),mt.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?ne:null,directoryOverride:je?ce:null,preserveDirectoryOverride:!!ce})};return window.addEventListener("openchamber:open-draft-session",M),()=>window.removeEventListener("openchamber:open-draft-session",M)},[]),l.useEffect(()=>{typeof window>"u"||!s||p||G.current||(G.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,p]),iw(),yD(),_y(f||null),SD(),aw(),Ly(),vD(),kD(s&&r,k),CD(),lw(),Pw(),$y();const q=l.useCallback(()=>{g(M=>!M)},[]);KT(q),pD(),Ew(!0),l.useEffect(()=>{const M=()=>g(V=>!V);return window.addEventListener("openchamber:memory-debug-toggle",M),()=>window.removeEventListener("openchamber:memory-debug-toggle",M)},[]),l.useEffect(()=>{c&&setTimeout(()=>u(),5e3)},[u,c]),l.useEffect(()=>{if(!P||L!=="not-injected")return;let M=!1,V=0;const ie=200,ce=2e3,ne=50,je=()=>{if(M)return;V++;const Ee=Rc();if(Ee!=="not-injected"){if(M=!0,z(Ee),Ee==="valid"){const Me=Zi();Me&&R(Nc({isDesktopShell:!0,bootOutcome:Me}))}return}const we=Math.min(ie*Math.pow(1.1,V),ce);if(V>=ne){const Me=document.getElementById("initial-loading");Me&&!Me.textContent?.includes("taking longer")&&(Me.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,we)};return window.setTimeout(je,ie),()=>{M=!0}},[P,L]);const ee=l.useCallback(async()=>{if(bb({isDesktopShell:hn(),isDesktopLocalOriginActive:li()})){await yb();return}window.location.reload()},[]),Q=l.useCallback(async()=>{if(!B){v(!1),O(!0);try{await ps.getState().initializeApp()}finally{O(!1)}ps.getState().isInitialized||T(M=>M+1)}},[B]),he=M=>{if(M.screen==="recovery")return M.variant};if(P&&H&&H.screen!=="main"){if(H.screen==="chooser")return n.jsx(Cs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Vu,{mode:"first-launch",localAvailable:H.localAvailable!==!1,onCliAvailable:ee,onChooseRemote:()=>{}})})})});const M=he(H),V=H.screen==="recovery"&&"url"in H?H.url:void 0,ie=H.screen==="recovery"&&"hostId"in H?H.hostId:void 0;return n.jsx(Cs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Vu,{mode:"recovery",recoveryVariant:M,recoveryHostUrl:V,recoveryHostLabel:void 0,recoveryHostId:ie,localAvailable:H.localAvailable!==!1,onCliAvailable:ee})})})})}return m&&!s&&!y?n.jsx(Cs,{children:n.jsx(GD,{onRetry:()=>{Q()},isRetrying:B},k)}):n.jsx(Cs,{children:n.jsx(cw,{sdk:Mo.getSdkClient(),directory:f||"",children:n.jsx(dw,{apis:t,children:n.jsx(RT,{children:n.jsx(bi,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:P?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(uw,{backgroundWorkEnabled:!0}),n.jsx(zy,{}),n.jsx(DD,{}),n.jsx(zE,{}),P?n.jsx(Ky,{ready:C&&N}):null,n.jsx(fw,{}),n.jsx(pw,{}),n.jsx(hw,{}),n.jsx(Wy,{}),n.jsx(UD,{}),h&&n.jsx(VD,{onClose:()=>g(!1)})]})})})})},k)})}function YD(t){const e=Ze.c(2);let s;return e[0]!==t?(s=n.jsx(My,{children:n.jsx(qD,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function ZD(t){return t.isAboutDialogOpen}function QD(t){return t.setAboutDialogOpen}function XD(){}function JD(){}function eR(t){return t.lastInitFailure}const tR=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Sb();Rm()&&ID();Hy();Uy();wb().then(()=>{mw().catch(t=>{console.error("[main] settings init failed:",t)}),gw(),bw(),yw()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Mm=document.getElementById("root");if(!Mm)throw new Error("Root element not found");xw();kg.createRoot(Mm).render(n.jsx(us.StrictMode,{children:n.jsx(Sw,{children:n.jsx(ww,{children:n.jsx(vw,{children:n.jsx(jw,{children:n.jsx(YD,{apis:tR})})})})})}));const wR=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{zd as a,yR as b,SR as g,wR as m,xR as r,Uv as u,$d as v};