@openchamber/web 2.3.0 → 2.3.1

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 (250) hide show
  1. package/dist/assets/AboutDialog-C1ulAXh5.js +1 -0
  2. package/dist/assets/ArchiveView-DJo1Bpw_.js +1 -0
  3. package/dist/assets/{CommandPalette-1VlA7PbL.js → CommandPalette-B6r6DPF9.js} +2 -2
  4. package/dist/assets/{DiffView-SHdJJ6tl.js → DiffView-mJuVm7Z4.js} +2 -2
  5. package/dist/assets/{FilePreviewCommentMenu-DlVgwRsr.js → FilePreviewCommentMenu-Ca4ziuof.js} +1 -1
  6. package/dist/assets/{FilesView-BeMtsSlV.js → FilesView-BBFbfDp9.js} +3 -3
  7. package/dist/assets/{GitView-npRGKKx8.js → GitView-WL1wkRFF.js} +3 -3
  8. package/dist/assets/GuestSurfacePane-peVDY5gW.js +1 -0
  9. package/dist/assets/HelpDialog-Dxc2yneu.js +1 -0
  10. package/dist/assets/{InProgressOperationBanner-B6iO22_7.js → InProgressOperationBanner-Dy0RiPsD.js} +1 -1
  11. package/dist/assets/JsonTreeView-BKUmh7Iw.js +1 -0
  12. package/dist/assets/MarkdownImageGallery-Cd6hLNmi.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-C-3B3mBt.js +1 -0
  14. package/dist/assets/MemoryDebugPanel-b116r1SF.js +1 -0
  15. package/dist/assets/OnboardingScreen-vBEhpU3q.js +1 -0
  16. package/dist/assets/OpenCodeStatusDialog-DH7dJ6MH.js +1 -0
  17. package/dist/assets/{PatchDiff-Du2s7T3U.js → PatchDiff-yM7vgQgi.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-B9K0gBvV.js → PierreDiffViewer-DnHKbYGl.js} +1 -1
  19. package/dist/assets/{PlanView-IkTcPrbw.js → PlanView-j0hLJmto.js} +2 -2
  20. package/dist/assets/RunOverview-ZuFZvDcu.js +2 -0
  21. package/dist/assets/ScheduledTasksDialog-UKXFFI91.js +5 -0
  22. package/dist/assets/{SettingsView-DIy5ZL4-.js → SettingsView-gB_NvyX4.js} +8 -8
  23. package/dist/assets/SettingsWindow-Dfb_RFpD.js +1 -0
  24. package/dist/assets/SourceBoardView-BjaL0nKs.js +1 -0
  25. package/dist/assets/SpaceAccessDialog-XzHRmIdT.js +1 -0
  26. package/dist/assets/SpaceApplyDialog-CxX9mrzT.js +1 -0
  27. package/dist/assets/{SpaceRow-YPmKQKeD.js → SpaceRow-vCpOCANO.js} +1 -1
  28. package/dist/assets/SpaceSetupOutput-CDZvJCf_.js +1 -0
  29. package/dist/assets/SpacesView-D3a9bCzn.js +1 -0
  30. package/dist/assets/{SubmoduleDiffSummary-RDY5md3p.js → SubmoduleDiffSummary-CQyRcvDZ.js} +1 -1
  31. package/dist/assets/{ToolOutputDialog-Dx85XZJs.js → ToolOutputDialog-judR_5mS.js} +2 -2
  32. package/dist/assets/{ToolPartDiffPreview-Dtv0xF9O.js → ToolPartDiffPreview-Ca9ISxfg.js} +1 -1
  33. package/dist/assets/UsageStatsView-C63Emjfj.js +1 -0
  34. package/dist/assets/{Virtualizer-DL535kyR.js → Virtualizer-DNgIEKcx.js} +1 -1
  35. package/dist/assets/{WalkthroughView-DcxbT5tc.js → WalkthroughView-D74b_7sC.js} +2 -2
  36. package/dist/assets/WorktreesView-hcm8Eb_C.js +1 -0
  37. package/dist/assets/appThemeRegistry-COeayQaQ.js +1 -0
  38. package/dist/assets/{ar-lP51qqz9.js → ar-1_zdYVV5.js} +2 -2
  39. package/dist/assets/computeVirtualFileMetrics-MZqvCQy0.js +3 -0
  40. package/dist/assets/{de-CpROAvTV.js → de-Ci7SGEQP.js} +3 -3
  41. package/dist/assets/{decorate-BNB7jeKg.js → decorate-CZeRRVC7.js} +1 -1
  42. package/dist/assets/{es-Bb8LKRhE.js → es-ZJii-6Tt.js} +2 -2
  43. package/dist/assets/{fr-BlNN9FC2.js → fr-C-hK8mvI.js} +2 -2
  44. package/dist/assets/{he-r546pCuc.js → he-t07CylP8.js} +2 -2
  45. package/dist/assets/index-D2tPUss-.js +1 -0
  46. package/dist/assets/{initializeSharedPreferences-dCHO04bl.js → initializeSharedPreferences-FxFkTjgn.js} +1 -1
  47. package/dist/assets/{isDiffPlainText-BwicHPpI.js → isDiffPlainText-C1F9opE5.js} +1 -1
  48. package/dist/assets/{isFilePlainText-Dk2R7BJo.js → isFilePlainText-B4SyJ-ni.js} +1 -1
  49. package/dist/assets/{ja-evNvJAHz.js → ja-iJr8aONy.js} +2 -2
  50. package/dist/assets/{katex-CMY-1eWf.css → katex-BEX7X_K8.css} +1 -1
  51. package/dist/assets/{katex.min-Iw9WSgM9.js → katex.min-C-51hS9A.js} +18 -18
  52. package/dist/assets/{ko-BPQP7lXe.js → ko-D5ow_yz-.js} +2 -2
  53. package/dist/assets/main-BtGnuno4.js +1048 -0
  54. package/dist/assets/main-uj5954n5.js +2 -0
  55. package/dist/assets/markdownCore-rBXCnAJp.js +9 -0
  56. package/dist/assets/miniChat-yWQmT2OS.js +2 -0
  57. package/dist/assets/mobile-NDAeGtzL.js +2 -0
  58. package/dist/assets/{moveWorkspacePath-B31RGdgu.js → moveWorkspacePath-BINgpJ9S.js} +1 -1
  59. package/dist/assets/{nl-CkQXd1nU.js → nl-CfqYrSVe.js} +2 -2
  60. package/dist/assets/{parseDiffFromFile-DcsKSY0J.js → parseDiffFromFile--DE4eHIp.js} +2 -2
  61. package/dist/assets/{patchFileDiff-Cx-HpjyI.js → patchFileDiff-BfFUmWgS.js} +1 -1
  62. package/dist/assets/pierreDiffTint-D9K6_CVD.js +29 -0
  63. package/dist/assets/{pl-C4i9Aizi.js → pl-Bn2_jAhL.js} +4 -4
  64. package/dist/assets/{pt-BR-CoYnG1CH.js → pt-BR-ZSDgn6cI.js} +2 -2
  65. package/dist/assets/relocateRestoredSession-C85Tk2y9.js +1 -0
  66. package/dist/assets/renderElectronMiniChatApp-BvAEmWhZ.js +2 -0
  67. package/dist/assets/{renderMobileApp-gDKxRJQi.js → renderMobileApp-T20l8ise.js} +7 -7
  68. package/dist/assets/{restartOpenCode-dq-SGun3.js → restartOpenCode-VEmIrLer.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-ExJsaWzA.js +55 -0
  70. package/dist/assets/scheduledTasksApi-NSyxVfHu.js +1 -0
  71. package/dist/assets/{selectionMarkdown-sDTBbKLh.js → selectionMarkdown-BJ2RhTXc.js} +2 -2
  72. package/dist/assets/{sessionOwnership-kZAtwMQd.js → sessionOwnership-BAX1xEJC.js} +1 -1
  73. package/dist/assets/{shikiHighlight-BRNXPlF-.js → shikiHighlight-DOzrE7BE.js} +1 -1
  74. package/dist/assets/{space-apply-CCOKLfrX.js → space-apply-DB_ZfJBW.js} +1 -1
  75. package/dist/assets/space-close-1kNlTkW1.js +1 -0
  76. package/dist/assets/{spaceNetwork-DUxJClu3.js → spaceNetwork-DA16ov_y.js} +1 -1
  77. package/dist/assets/{textMateThemeFromAppTheme-B6UJwdZz.js → textMateThemeFromAppTheme-BfIrjFAU.js} +1 -1
  78. package/dist/assets/{tr-D-_lz-lC.js → tr-C89uz1hs.js} +2 -2
  79. package/dist/assets/{uk-B49PGMYB.js → uk-uTYVPFrO.js} +2 -2
  80. package/dist/assets/{useAppFontEffects-3EN8Ava3.js → useAppFontEffects-C1ceAD51.js} +185 -185
  81. package/dist/assets/useCallableModelProviders-BkLsgs6y.js +1 -0
  82. package/dist/assets/{useInlineCommentController-l9cWyfuR.js → useInlineCommentController-ynkUsoVA.js} +1 -1
  83. package/dist/assets/{useRootScrollLock-UAQn24Y8.js → useRootScrollLock-DnoKH1HE.js} +2 -2
  84. package/dist/assets/{vendor-codemirror-autocomplete-C8FBSI9t.js → vendor-codemirror-autocomplete-BRKmCSiY.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-commands-BhRb6jns.js → vendor-codemirror-commands-MmBpgSOc.js} +1 -1
  86. package/dist/assets/vendor-codemirror-lang-angular-Bj5Pk8sp.js +1 -0
  87. package/dist/assets/vendor-codemirror-lang-cpp-tZt-BOgi.js +1 -0
  88. package/dist/assets/vendor-codemirror-lang-css-DfdrZ848.js +1 -0
  89. package/dist/assets/{vendor-codemirror-lang-go-BHJEONih.js → vendor-codemirror-lang-go-C9OcoXdP.js} +2 -2
  90. package/dist/assets/vendor-codemirror-lang-html-C5kFuJzc.js +1 -0
  91. package/dist/assets/vendor-codemirror-lang-java-Divn2dnj.js +1 -0
  92. package/dist/assets/{vendor-codemirror-lang-javascript-CUmSxayT.js → vendor-codemirror-lang-javascript-DmPuKUEa.js} +2 -2
  93. package/dist/assets/vendor-codemirror-lang-jinja-B-8miA-Q.js +1 -0
  94. package/dist/assets/vendor-codemirror-lang-json-L0wsFFxi.js +1 -0
  95. package/dist/assets/vendor-codemirror-lang-less-CWlCIxCI.js +1 -0
  96. package/dist/assets/vendor-codemirror-lang-liquid-Dm8xthAW.js +1 -0
  97. package/dist/assets/vendor-codemirror-lang-markdown-CPn-qinN.js +1 -0
  98. package/dist/assets/vendor-codemirror-lang-php-DKIOifjN.js +1 -0
  99. package/dist/assets/vendor-codemirror-lang-python-BAVa3Hg5.js +3 -0
  100. package/dist/assets/vendor-codemirror-lang-rust-Dab90hdg.js +1 -0
  101. package/dist/assets/vendor-codemirror-lang-sass-eezaHFBZ.js +1 -0
  102. package/dist/assets/{vendor-codemirror-lang-sql-C1Jj9uuJ.js → vendor-codemirror-lang-sql-Vu-PR7cv.js} +2 -2
  103. package/dist/assets/vendor-codemirror-lang-vue-BthRGZHy.js +1 -0
  104. package/dist/assets/vendor-codemirror-lang-wast-Db6KSic0.js +1 -0
  105. package/dist/assets/vendor-codemirror-lang-xml-DQkh4sc1.js +1 -0
  106. package/dist/assets/vendor-codemirror-lang-yaml-Bt2N__AW.js +1 -0
  107. package/dist/assets/vendor-codemirror-language-DkBxRck3.js +3 -0
  108. package/dist/assets/vendor-codemirror-language-data-CTYHXywt.js +2 -0
  109. package/dist/assets/{vendor-codemirror-search-CvXM_pZg.js → vendor-codemirror-search-BKAwkhkm.js} +1 -1
  110. package/dist/assets/vendor-codemirror-streamparser-CmlTsbN2.js +1 -0
  111. package/dist/assets/vendor-codemirror-view-B66jUSmE.js +4 -0
  112. package/dist/assets/{vendor-replit-codemirror-vim-Ck2X_WZC.js → vendor-replit-codemirror-vim-D0bqFa1D.js} +5 -5
  113. package/dist/assets/{worker-DdhrXE7g.js → worker-BbEdJ2Oi.js} +18 -18
  114. package/dist/assets/workerFactory-Bw5qLmrM.js +1 -0
  115. package/dist/assets/{zh-CN-CS-9Os9n.js → zh-CN-DdTNG52a.js} +2 -2
  116. package/dist/assets/{zh-TW-D0XYVdcl.js → zh-TW-DPm_33Fi.js} +2 -2
  117. package/dist/index.html +3 -3
  118. package/dist/mini-chat.html +3 -3
  119. package/dist/mobile.html +3 -3
  120. package/package.json +2 -2
  121. package/server/index.js +4 -0
  122. package/server/lib/environment/store.js +3 -4
  123. package/server/lib/environment/store.test.js +17 -0
  124. package/server/lib/fs/DOCUMENTATION.md +4 -2
  125. package/server/lib/fs/routes.js +48 -13
  126. package/server/lib/fs/routes.test.js +118 -5
  127. package/server/lib/git/DOCUMENTATION.md +3 -1
  128. package/server/lib/git/contributor-remote.js +4 -0
  129. package/server/lib/git/contributor-remote.test.js +21 -0
  130. package/server/lib/git/service.js +20 -25
  131. package/server/lib/git/service.test.js +99 -0
  132. package/server/lib/git/worktree-creation.js +4 -5
  133. package/server/lib/github/DOCUMENTATION.md +1 -1
  134. package/server/lib/github/routes.auth.test.js +14 -0
  135. package/server/lib/github/routes.js +13 -5
  136. package/server/lib/github/routes.mutations.test.js +18 -2
  137. package/server/lib/message-queue/DOCUMENTATION.md +8 -2
  138. package/server/lib/message-queue/runtime.js +3 -2
  139. package/server/lib/message-queue/runtime.test.js +64 -2
  140. package/server/lib/openchamber-control/service.js +48 -13
  141. package/server/lib/openchamber-control/service.test.js +42 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +3 -1
  143. package/server/lib/opencode/project-start-command.d.ts +11 -0
  144. package/server/lib/opencode/project-start-command.js +56 -0
  145. package/server/lib/opencode/project-start-command.test.js +80 -0
  146. package/server/lib/opencode/session-activity.js +43 -3
  147. package/server/lib/opencode/session-activity.test.js +97 -0
  148. package/server/lib/opencode/settings-runtime.js +19 -1
  149. package/server/lib/opencode/settings-runtime.test.js +23 -0
  150. package/server/lib/opencode/skill-routes.js +34 -1
  151. package/server/lib/opencode/skill-routes.test.js +99 -0
  152. package/server/lib/quota/DOCUMENTATION.md +13 -1
  153. package/server/lib/quota/providers/antigravity/api.js +104 -0
  154. package/server/lib/quota/providers/antigravity/auth.js +45 -0
  155. package/server/lib/quota/providers/antigravity/index.js +76 -0
  156. package/server/lib/quota/providers/antigravity/transforms.js +168 -0
  157. package/server/lib/quota/providers/antigravity/transforms.test.js +162 -0
  158. package/server/lib/quota/providers/codex.js +28 -4
  159. package/server/lib/quota/providers/codex.test.js +29 -0
  160. package/server/lib/quota/providers/google/auth.js +4 -49
  161. package/server/lib/quota/providers/google/transforms.js +3 -22
  162. package/server/lib/quota/providers/index.js +8 -0
  163. package/server/lib/quota/providers/opencode-go.js +3 -1
  164. package/server/lib/quota/providers/opencode-go.test.js +12 -0
  165. package/server/lib/routing/DOCUMENTATION.md +3 -1
  166. package/server/lib/routing/runtime.js +34 -1
  167. package/server/lib/routing/runtime.test.js +43 -1
  168. package/server/lib/scheduled-tasks/DOCUMENTATION.md +11 -0
  169. package/server/lib/scheduled-tasks/existing-session.js +52 -8
  170. package/server/lib/scheduled-tasks/existing-session.test.js +121 -0
  171. package/server/lib/scheduled-tasks/routes.js +26 -0
  172. package/server/lib/scheduled-tasks/runtime.js +1 -0
  173. package/server/lib/session-assist/runtime.js +3 -0
  174. package/server/lib/session-assist/runtime.test.js +47 -0
  175. package/server/lib/skills-catalog/DOCUMENTATION.md +10 -1
  176. package/server/lib/skills-catalog/install.js +1 -1
  177. package/server/lib/skills-catalog/installed-sources.d.ts +17 -0
  178. package/server/lib/skills-catalog/installed-sources.js +112 -0
  179. package/server/lib/skills-catalog/installed-sources.test.js +94 -0
  180. package/server/lib/small-model/DOCUMENTATION.md +12 -5
  181. package/server/lib/small-model/index.js +6 -4
  182. package/server/lib/small-model/index.test.js +40 -0
  183. package/server/lib/small-model/routes.js +3 -2
  184. package/server/lib/source-control/change-request-worktree.js +2 -6
  185. package/server/lib/source-control/mutation-storage.js +4 -1
  186. package/server/lib/source-control/mutation-storage.test.js +21 -0
  187. package/server/lib/spaces/DOCUMENTATION.md +1 -1
  188. package/server/lib/spaces/journey.js +10 -3
  189. package/server/lib/spaces/journey.test.js +13 -1
  190. package/server/lib/terminal/history.js +22 -2
  191. package/server/lib/terminal/history.test.js +23 -0
  192. package/server/lib/terminal/theme-response.js +14 -0
  193. package/server/lib/terminal/theme-response.test.js +10 -0
  194. package/dist/assets/AboutDialog-e8ek_kPI.js +0 -1
  195. package/dist/assets/ArchiveView-CjF4_TFg.js +0 -1
  196. package/dist/assets/GuestSurfacePane-4kmEXPLD.js +0 -1
  197. package/dist/assets/HelpDialog-CITMqPDK.js +0 -1
  198. package/dist/assets/JsonTreeView-xGikhCtL.js +0 -1
  199. package/dist/assets/MarkdownImageGallery-D0FJyr7C.js +0 -1
  200. package/dist/assets/MarkdownRendererImpl-BIM7Pjwk.js +0 -1
  201. package/dist/assets/MemoryDebugPanel-CBk8QW-M.js +0 -1
  202. package/dist/assets/OnboardingScreen-Cy6ARiMS.js +0 -1
  203. package/dist/assets/OpenCodeStatusDialog-YMHuJzwt.js +0 -1
  204. package/dist/assets/RunOverview-CHkGSW1x.js +0 -2
  205. package/dist/assets/ScheduledTasksDialog-77SO8zdJ.js +0 -4
  206. package/dist/assets/SettingsWindow-X74FIkdo.js +0 -1
  207. package/dist/assets/SourceBoardView-Cff2ejOW.js +0 -1
  208. package/dist/assets/SpaceAccessDialog-BXMZNRei.js +0 -1
  209. package/dist/assets/SpaceApplyDialog-BEJd2ryu.js +0 -1
  210. package/dist/assets/SpaceSetupOutput-Cb3XcIII.js +0 -1
  211. package/dist/assets/SpacesView-I3HaRKtW.js +0 -1
  212. package/dist/assets/UsageStatsView-DwTt9zIz.js +0 -1
  213. package/dist/assets/WorktreesView-Bh7GLvrR.js +0 -1
  214. package/dist/assets/appThemeRegistry-Bzb67M9O.js +0 -1
  215. package/dist/assets/computeVirtualFileMetrics-WAp98Bb7.js +0 -3
  216. package/dist/assets/index-BsupKM40.js +0 -1
  217. package/dist/assets/main-C_QGhDBL.js +0 -1048
  218. package/dist/assets/main-pWZ7F_hy.js +0 -2
  219. package/dist/assets/markdownCore-6gz4uJDQ.js +0 -9
  220. package/dist/assets/miniChat-DnaTfdYh.js +0 -2
  221. package/dist/assets/mobile-C7DIJqP8.js +0 -2
  222. package/dist/assets/pierreDiffTint-B297eqF0.js +0 -28
  223. package/dist/assets/relocateRestoredSession-D3lujODj.js +0 -1
  224. package/dist/assets/renderElectronMiniChatApp-BF4hNe69.js +0 -2
  225. package/dist/assets/runtimeEndpointReset-D6Lxhk0S.js +0 -55
  226. package/dist/assets/scheduledTasksApi-DUbAMrjW.js +0 -1
  227. package/dist/assets/space-close-CWcWwH4_.js +0 -1
  228. package/dist/assets/useCallableModelProviders-BB9xkUzM.js +0 -1
  229. package/dist/assets/vendor-codemirror-lang-angular-BpYCRJSk.js +0 -1
  230. package/dist/assets/vendor-codemirror-lang-cpp-BI3uPyjT.js +0 -1
  231. package/dist/assets/vendor-codemirror-lang-css-B2_PZTBl.js +0 -1
  232. package/dist/assets/vendor-codemirror-lang-html-BpvvTxbZ.js +0 -1
  233. package/dist/assets/vendor-codemirror-lang-java-BM5LQZ4u.js +0 -1
  234. package/dist/assets/vendor-codemirror-lang-jinja-D8nLZQPK.js +0 -1
  235. package/dist/assets/vendor-codemirror-lang-json-VDxF27mO.js +0 -1
  236. package/dist/assets/vendor-codemirror-lang-less-BecU2BJP.js +0 -1
  237. package/dist/assets/vendor-codemirror-lang-liquid-DCw83Anh.js +0 -1
  238. package/dist/assets/vendor-codemirror-lang-markdown-CimQAQbQ.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-php-C5Kpnpyb.js +0 -1
  240. package/dist/assets/vendor-codemirror-lang-python-BFE1OJNx.js +0 -3
  241. package/dist/assets/vendor-codemirror-lang-rust-hqZDyGIJ.js +0 -1
  242. package/dist/assets/vendor-codemirror-lang-sass-CAZML-Jl.js +0 -1
  243. package/dist/assets/vendor-codemirror-lang-vue-BHOTXcKp.js +0 -1
  244. package/dist/assets/vendor-codemirror-lang-wast-DcCHfPUI.js +0 -1
  245. package/dist/assets/vendor-codemirror-lang-xml-BO_V-1wZ.js +0 -1
  246. package/dist/assets/vendor-codemirror-lang-yaml-CPimap_N.js +0 -1
  247. package/dist/assets/vendor-codemirror-language-BBADuAkg.js +0 -3
  248. package/dist/assets/vendor-codemirror-language-data-Cu5ZbrPm.js +0 -2
  249. package/dist/assets/vendor-codemirror-view-1e0FQ6Wn.js +0 -4
  250. package/dist/assets/workerFactory-De9YXIdE.js +0 -1
@@ -0,0 +1,1048 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitView-WL1wkRFF.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-C-51hS9A.js","assets/vendor-zod-CVhJ1Zpv.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DgOf1DP0.js","assets/katex-BEX7X_K8.css","assets/useAppFontEffects-C1ceAD51.js","assets/vendor-base-ui-CXFyogip.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-CvuLsk7D.js","assets/vendor-tanstack-virtual-core-DPaNcJcT.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-MmBpgSOc.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-DkBxRck3.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-DmPuKUEa.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BRKmCSiY.js","assets/vendor-codemirror-lang-json-L0wsFFxi.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-DfdrZ848.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-C5kFuJzc.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CPn-qinN.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CTYHXywt.js","assets/vendor-codemirror-lang-python-BAVa3Hg5.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-BCBzRcfK.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-ExJsaWzA.js","assets/InProgressOperationBanner-Dy0RiPsD.js","assets/changesTree-CePHbFcj.js","assets/PierreDiffViewer-DnHKbYGl.js","assets/parseDiffFromFile--DE4eHIp.js","assets/computeVirtualFileMetrics-MZqvCQy0.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-C1F9opE5.js","assets/pierreDiffTint-D9K6_CVD.js","assets/Virtualizer-DNgIEKcx.js","assets/useInlineCommentController-ynkUsoVA.js","assets/appThemeRegistry-COeayQaQ.js","assets/textMateThemeFromAppTheme-BfIrjFAU.js","assets/useRootScrollLock-DnoKH1HE.js","assets/moveWorkspacePath-BINgpJ9S.js","assets/sessionOwnership-BAX1xEJC.js","assets/PlanView-j0hLJmto.js","assets/shikiHighlight-DOzrE7BE.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-D0bqFa1D.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/FilePreviewCommentMenu-Ca4ziuof.js","assets/WalkthroughView-D74b_7sC.js","assets/patchFileDiff-BfFUmWgS.js","assets/useCallableModelProviders-BkLsgs6y.js","assets/DiffView-mJuVm7Z4.js","assets/SubmoduleDiffSummary-CQyRcvDZ.js","assets/FilesView-BBFbfDp9.js","assets/JsonTreeView-BKUmh7Iw.js","assets/Virtualizer-BP6uuKe_.js","assets/isFilePlainText-B4SyJ-ni.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/scheduledTasksApi-NSyxVfHu.js","assets/GuestSurfacePane-peVDY5gW.js","assets/SettingsWindow-Dfb_RFpD.js","assets/SettingsView-gB_NvyX4.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/restartOpenCode-VEmIrLer.js","assets/CommandPalette-B6r6DPF9.js","assets/HelpDialog-Dxc2yneu.js","assets/OpenCodeStatusDialog-DH7dJ6MH.js","assets/RunOverview-ZuFZvDcu.js","assets/ScheduledTasksDialog-UKXFFI91.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/ArchiveView-DJo1Bpw_.js","assets/UsageStatsView-C63Emjfj.js","assets/SourceBoardView-BjaL0nKs.js","assets/WorktreesView-hcm8Eb_C.js","assets/SpacesView-D3a9bCzn.js","assets/SpaceRow-vCpOCANO.js","assets/SpaceAccessDialog-XzHRmIdT.js","assets/spaceNetwork-DA16ov_y.js","assets/SpaceApplyDialog-CxX9mrzT.js","assets/space-apply-DB_ZfJBW.js","assets/SpaceSetupOutput-CDZvJCf_.js","assets/OnboardingScreen-vBEhpU3q.js","assets/AboutDialog-C1ulAXh5.js","assets/MemoryDebugPanel-b116r1SF.js"])))=>i.map(i=>d[i]);
2
+ import{f as Ke,j as n,R as c,r as ds,c as ya,h as Jp}from"./vendor-react-BUCujlKS.js";import{u as ue,cm as Ls,b as $s,m as Sn,e as gs,cw as Ud,ah as xa,Y as Yt,$ as Bo,n as ot,aV as Ss,aq as pn,ao as mo,ap as hn,cx as to,a2 as hr,aG as em,at as qd,cy as tm,b7 as vs,cz as Sa,cA as go,cB as Fo,cC as sm,cD as pr,cE as Ii,cF as _o,cG as Yn,a8 as bo,l as an,cH as Kn,aU as nm,cI as Yd,cJ as rm,cK as om,cL as fn,cM as im,cN as Xd,cO as am,cP as lm,cQ as Qd,cR as cm,q as dm,t as um,b9 as fm,aY as Lo,aZ as hm,b1 as pm,b2 as mm,aj as gm,an as bm,ai as _s,v as yo,aR as xo,cS as ym,as as va,cr as wa,bb as So,aI as En,bm as os,a0 as Zd,az as $o,cT as xm,cU as Sm,cV as vm,aJ as Jd,cl as zo,cW as eu,cX as wm,cY as Ti,cZ as km,bI as tu,bJ as su,Z as jm,bn as Cm,bc as Pm,c_ as Em,c$ as Bl,bx as nu,ar as ru,_ as Nm,be as Rm,d0 as Dm,d1 as Im,aE as Tm,aC as Mm,d2 as Am,aK as Om,bd as Bm,bA as Fm,d3 as _m,d4 as Lm,d5 as Fl,d6 as ci,d7 as _l,d8 as Ll,d9 as $m,av as $l,da as zm,db as Km,dc as Wm,aD as Hm,dd as Vm,i as Gm,a as Um}from"./katex.min-C-51hS9A.js";import{_ as ss}from"./vendor-vite-runtime-DD1OZmLC.js";import{b7 as qm,b8 as ka,a7 as Ym,ai as ou,b9 as Xm,a2 as Qm,a3 as Zm,a5 as Mi,g as Jm,l as eg,h as tg,f as sg,j as ng,k as rg,m as og,P as ig,Q as ag,K as lg,W as cg,X as dg,R as ug,G as fg,w as hg,u as pg,C as mg,ba as Tn,aq as gg,bb as iu,bc as au,D as lu,A as Cr,F as cu,z as ja,$ as bg,a0 as yg,an as xg,ao as Sg,Z as vg,aE as du,bd as wg,ap as kg,aW as jg,S as zl,be as Cg,aI as Ca,aH as Pg,a8 as Eg,a6 as uu,bf as Dn,bg as fu,ah as Ng,bh as hu,bi as Rg,bj as Kl,a9 as Dg,aa as Ig,b as Tg,a as Mg,bk as Ag,bl as or,ae as Og,bm as Bg,af as Wl,a1 as mr,ab as Fg,a4 as _g,ag as Lg,ar as $g,aD as zg,av as Kg,bn as Wg,aA as Hg,aB as Vg,aG as Gg,bo as Ug,bp as qg,bq as Yg,a$ as Xg,br as Qg,aJ as Zg,aF as Jg,bs as eb,at as tb,bt as sb,bu as nb,aw as rb,ax as ob,az as ib,ay as ab,aC as lb,bv as cb,bw as db}from"./runtimeEndpointReset-ExJsaWzA.js";import{u as vt,jN as ub,I as Z,U as At,V as Tt,T as Ot,as as Pr,a2 as Zt,F as nt,cc as pu,L as ke,cu as Pa,cv as Ea,cw as Na,lb as zr,G as ws,J as Xn,ef as mu,ee as gu,b7 as Ai,lc as fb,ld as bu,b8 as yu,dy as xu,aE as js,aF as Cs,aG as Ps,bT as bn,aH as qt,l as Us,E as qs,D as Ys,Q as Ko,Z as Qn,q as zs,t as Ks,z as Le,le as hb,lf as pb,lg as Hl,lh as Vl,a1 as Su,li as mb,lj as Gl,lk as gb,ll as vu,lm as Ra,ln as Oi,by as wu,lo as bb,lp as yb,lq as xb,gr as ku,lr as Da,ls as Sb,gi as _n,ar as Mn,lt as vb,gj as wb,d2 as ju,lu as kb,d3 as jb,lv as Cu,ak as Wo,lw as Pu,lx as Eu,ly as Nu,lz as Ru,lA as Du,lB as Iu,ii as sr,bd as Ia,an as Ta,d7 as Tu,o as yn,B as Ct,lC as Mu,eN as Ma,lD as Bi,n as Er,aI as bs,ag as Au,aj as Ou,lE as Cb,lF as Pb,aq as Ws,iv as Bu,iu as Fu,ex as mn,bS as Fi,ie as Eb,dP as Nb,ap as vn,lG as Rb,lH as Db,c7 as Ib,c6 as Tb,fp as Mb,f6 as Ab,fF as Ob,ew as _u,dQ as tn,d_ as Bb,ac as ls,dZ as Lu,ez as _i,ey as Ln,eA as $u,lI as zu,lJ as Ku,lK as Fb,lL as _b,jK as Lb,eC as Aa,bJ as $b,bH as zb,bG as Kb,bI as Wb,bB as Hb,y as vo,co as Ul,bM as Vb,bO as ql,lM as Gb,lN as Ub,jL as qb,cb as Oa,dY as Yb,e0 as Ba,eK as Xb,d$ as Qb,ao as gn,fv as Wu,ct as Zb,lO as Fn,aa as Jb,lP as ey,_ as ns,gl as Hu,lQ as ty,bD as sy,x as Vu,br as ny,lR as ry,lS as oy,eM as Gu,lT as nr,lU as Uu,lV as Li,lW as $i,lX as Yl,g7 as In,g6 as so,cg as iy,lY as ay,lZ as Nr,cY as Fa,l_ as _a,l$ as ly,cx as wn,m0 as cy,m1 as dy,m2 as uy,m3 as fy,a7 as hy,m4 as qu,aL as py,eU as my,aN as gy,m5 as Bn,m6 as Xl,m7 as Ql,m8 as di,bj as by,m9 as Zl,fQ as yy,fT as xy,e3 as Sy,fU as vy,bb as wy,g5 as La,g8 as Yu,ma as Ho,g9 as $a,ga as za,cI as ky,C as jy,mb as ui,mc as Cy,md as Py,me as Xu,mf as Ey,mg as Qu,hq as Ny,mh as Ry,mi as Dy,mj as Iy,mk as Ty,ah as My,ml as Jl,mm as Ay,mn as ec,mo as tc,gG as wo,gf as Ka,cH as Zu,mp as Oy,gF as Wa,gH as gr,mq as Ju,l3 as cs,ih as ef,ij as tf,g2 as sf,g3 as nf,g4 as rf,mr as By,kO as sc,ms as Fy,mt as of,mu as _y,mv as af,mw as zi,bF as lf,mx as Ha,my as Ly,mz as $y,mA as zy,cF as Vo,la as Xt,mB as Ky,kg as cf,mC as df,mD as uf,mE as Sr,mF as nc,mG as Wy,mH as vr,mI as Hy,mJ as Vy,mK as Va,mL as ko,mM as Ga,mN as ff,mO as hf,mP as pf,mQ as mf,a9 as Gy,mR as Uy,gn as qy,gv as Yy,gy as Ua,gI as Xy,gw as Qy,gx as Zy,mS as Jy,eg as ex,N as tx,eh as gf,k0 as sx,mT as nx,mU as rx,mV as Wn,mW as ox,go as ix,mX as no,de as Go,gz as Ki,mY as ax,gJ as lx,mZ as cx,m_ as bf,O as xn,gC as dx,m$ as ux,e5 as fx,ci as yf,n0 as hx,n1 as px,n2 as rc,ke as mx,n3 as gx,a3 as bx,gE as yx,kM as xx,f7 as kn,n4 as Sx,n5 as vx,n6 as wx,cS as kx,n7 as jx,dp as oc,dn as ic,bA as ac,n8 as Cx,n9 as Px,cf as Ex,na as Nx,gq as lc,gs as fi,gt as Rx,nb as Dx,gu as Ix,nc as Tx,k as Mx,nd as Ax,eo as Wi,fM as Ox,ne as xf,nf as Bx,cL as Fx,ng as cc,nh as _x,cJ as Lx,dA as Sf,ni as Hi,W as vf,dz as wf,cG as kf,nj as $x,nk as jf,b$ as ro,h_ as zx,gg as Kx,h$ as Wx,jc as Hx,gk as Vx,bR as Gx,k$ as dc,nl as Ux,da as qx,nm as Yx,cU as uc,db as Xx,dd as Qx,dc as Zx,dj as Jx,di as e1,g_ as t1,dh as s1,df as n1,dg as r1,a as o1,s as i1,b as a1,c as l1,h5 as c1,dq as d1,dr as u1,ds as f1,dt as h1}from"./useAppFontEffects-C1ceAD51.js";import{u as Cf,S as p1,W as Pf,f as Ef,a as m1,G as g1,b as b1,c as y1}from"./useRootScrollLock-DnoKH1HE.js";import{f as Rr,h as Bs,T as Dr,M as Ir,D as Tr,j as Mr,i as Nf,d as x1,b as S1,k as v1}from"./vendor-dnd-kit-core-BZknOX2w.js";import{r as w1,h as k1,u as Ar,S as Uo,s as Rf,a as qa,v as Ya}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Or}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Df,M as If,k as Tf,l as Vi,m as Gi,n as Ui,o as Mf,p as j1,q as C1}from"./vendor-base-ui-CXFyogip.js";import{c as Br,u as Zn,p as P1}from"./vendor-zustand-BAGL70zf.js";import{r as Xa,a as qo,n as E1,s as rn,o as qi,b as fc}from"./vendor-zod-CVhJ1Zpv.js";import{D as N1,a as R1,m as hc,G as D1}from"./moveWorkspacePath-BINgpJ9S.js";import{c as I1}from"./sessionOwnership-BAX1xEJC.js";import{u as T1}from"./vendor-tanstack-react-virtual-CvuLsk7D.js";import{m as M1,d as A1}from"./vendor-tanstack-virtual-core-DPaNcJcT.js";const O1=t=>{const e=Ke.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=vt(),l=ue(B1);let a;e[0]!==s?(a=Ls(s),e[0]=s,e[1]=a):a=e[1];const d=a;let u;e[2]!==d?(u=w=>ub(d?w.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=$s(u);let h;e[4]!==d?(h=w=>d?w.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=h):h=e[5];const m=$s(h);if(!l||!d||!f||Sn())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 v;e[8]!==d?(v=()=>$s.getState().openApplyDialog(d),e[8]=d,e[9]=v):v=e[9];let x;e[10]!==o?(x=n.jsx(Z,{name:"git-merge",className:o}),e[10]=o,e[11]=x):x=e[11];let S;e[12]!==m||e[13]!==r||e[14]!==b||e[15]!==v||e[16]!==x?(S=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":b,disabled:m,onClick:v,className:r,children:x})}),e[12]=m,e[13]=r,e[14]=b,e[15]=v,e[16]=x,e[17]=S):S=e[17];let p;e[18]!==b?(p=n.jsx(Tt,{side:"bottom",children:b}),e[18]=b,e[19]=p):p=e[19];let y;return e[20]!==S||e[21]!==p?(y=n.jsxs(Ot,{children:[S,p]}),e[20]=S,e[21]=p,e[22]=y):y=e[22],y};function B1(t){return t.isolatedSpacesEnabled}function F1(t){const e=Ke.c(36),{directory:s,className:r}=t,{currentTheme:o}=Pr(),i=Zt($1),l=nt(L1),a=gs(_1);let d;e[0]!==s||e[1]!==a?(d=Ud(s,a),e[0]=s,e[1]=a,e[2]=d):d=e[2];const u=d;let f;e[3]!==s||e[4]!==u||e[5]!==i||e[6]!==l?(f=u||!s?null:pu(i,l,s),e[3]=s,e[4]=u,e[5]=i,e[6]=l,e[7]=f):f=e[7];const h=f;if(u){let P;e[8]!==r?(P=ke("h-3.5 w-3.5 shrink-0 text-muted-foreground/80",r),e[8]=r,e[9]=P):P=e[9];let A;return e[10]!==P?(A=n.jsx(Z,{name:"chat-4",className:P}),e[10]=P,e[11]=A):A=e[11],A}if(!h)return null;const m=h.icon?Pa[h.icon]:null;let g;e[12]!==h.color?(g=Ea(h.color)??void 0,e[12]=h.color,e[13]=g):g=e[13];const b=g;let v;e[14]!==r||e[15]!==b||e[16]!==m?(v=m?n.jsx(Z,{name:m,className:ke("h-3.5 w-3.5 shrink-0",r),style:b?{color:b}:void 0}):n.jsx(Z,{name:"folder",className:ke("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]=m,e[17]=v):v=e[17];const x=v;if(!h.iconImage)return x;let S;e[18]!==r?(S=ke("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 p;e[20]!==h.iconBackground?(p=h.iconBackground?{backgroundColor:h.iconBackground}:void 0,e[20]=h.iconBackground,e[21]=p):p=e[21];let y;e[22]!==h.iconImage||e[23]!==h.id?(y={id:h.id,iconImage:h.iconImage},e[22]=h.iconImage,e[23]=h.id,e[24]=y):y=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 j;e[28]!==x||e[29]!==y||e[30]!==w?(j=n.jsx(Na,{project:y,options:w,className:"h-full w-full object-contain",fallback:x}),e[28]=x,e[29]=y,e[30]=w,e[31]=j):j=e[31];let k;return e[32]!==S||e[33]!==p||e[34]!==j?(k=n.jsx("span",{className:S,style:p,children:j}),e[32]=S,e[33]=p,e[34]=j,e[35]=k):k=e[35],k}function _1(t){return t.homeDirectory}function L1(t){return t.availableWorktreesByProject}function $1(t){return t.projects}const fr=24,z1=(t,e,s=fr)=>{const r=e.right-(t.right-s);if(r>0)return r;const o=e.left-(t.left+s);return o<0?o:0},K1=({transform:t})=>({...t,y:0}),W1=16,H1=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*W1:t.deltaY;t.currentTarget.scrollLeft+=xa(t.currentTarget)?-e:e},V1={Item:qt,Separator:bn},G1={Item:({className:t,...e})=>n.jsx(If,{className:ke(yu,t),...e}),Separator:({className:t,...e})=>n.jsx(Df,{className:ke(bu,t),...e})},U1=t=>{const e=Ke.c(63),{tab:s,isActive:r,suppressControls:o,onSelect:i,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:h}=vt(),[m,g]=c.useState(!1),[b,v]=c.useState(!1),[x,S]=c.useState(!1);let p;e[0]!==s.id?(p={id:s.id},e[0]=s.id,e[1]=p):p=e[1];const{attributes:y,listeners:w,setNodeRef:j,transform:k,transition:P,isDragging:A}=Ar(p);let F;e[2]!==h||e[3]!==s.session.title?(F=s.session.title?.trim()||h("sessions.sidebar.session.untitled"),e[2]=h,e[3]=s.session.title,e[4]=F):F=e[4];const D=F,E=!o&&(m||b),T=s.id;let $;e[5]!==s.session?($=Xn(s.session),e[5]=s.session,e[6]=$):$=e[6];const O=ka(T,$),K=mu(s.id),I=K!==null,N=gu(s.id)>0&&!r&&!I,C=I||N;let R;e[7]!==d||e[8]!==x||e[9]!==r||e[10]!==m||e[11]!==i||e[12]!==s?(R=pe=>({session:s.session,open:m||x,isActive:r,select:()=>i(s),closeOtherTabs:()=>d(s.id),components:pe}),e[7]=d,e[8]=x,e[9]=r,e[10]=m,e[11]=i,e[12]=s,e[13]=R):R=e[13];const H=R;let M;e[14]!==k?(M=Or.Translate.toString(k),e[14]=k,e[15]=M):M=e[15];let _;e[16]!==M||e[17]!==P?(_={transform:M,transition:P},e[16]=M,e[17]=P,e[18]=_):_=e[18];const B=A&&"z-10 opacity-60";let ee;e[19]!==B?(ee=ke("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",B),e[19]=B,e[20]=ee):ee=e[20];const ne=r?"true":"false";let re;e[21]!==r?(re=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=re):re=e[22];let te;e[23]!==u?(te=pe=>u?.(pe),e[23]=u,e[24]=te):te=e[24];let W;e[25]!==f||e[26]!==r||e[27]!==O||e[28]!==H||e[29]!==m||e[30]!==l||e[31]!==u||e[32]!==i||e[33]!==E||e[34]!==a||e[35]!==C||e[36]!==o||e[37]!==h||e[38]!==s||e[39]!==D||e[40]!==K?(W=n.jsx(Tf,{render:pe=>n.jsxs("div",{...pe,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>i(s),onKeyDown:r?void 0:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),i(s))},onAuxClick:U=>{U.button===1&&(U.preventDefault(),l(s.id))},"data-controls-open":E?"true":"false",className:ke("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":ke("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",E&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:ke("flex min-w-0 flex-1 items-center",!o&&"group-hover/session-tab:pe-10",E&&"pe-10"),children:[n.jsx(F1,{directory:Xn(s.session),className:"me-1.5"}),n.jsx("div",{className:ke("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!o&&"session-tab-title"),children:r?f: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:D})})}),O?n.jsx(Z,{name:"loader-4",className:"ms-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":h("sessions.aiRename.generating")}):C?n.jsx(xu,{state:K??"unread",className:ke("ms-1.5 shrink-0",!o&&"group-hover/session-tab:opacity-0",E&&"opacity-0")}):null]}),o?null:n.jsxs("div",{onClick:Y1,onPointerDown:X1,className:ke("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",E&&"flex opacity-100"),children:[n.jsxs(js,{open:m,onOpenChange:U=>{g(U),U&&v(!0)},onOpenChangeComplete:U=>{U||v(!1),u?.(U)},children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":h("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(Ps,{align:"start",className:"min-w-[190px]",children:a(H(V1))})]}),n.jsx("button",{type:"button","aria-label":h("header.sessionTabs.closeTab"),onClick:()=>l(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]=f,e[26]=r,e[27]=O,e[28]=H,e[29]=m,e[30]=l,e[31]=u,e[32]=i,e[33]=E,e[34]=a,e[35]=C,e[36]=o,e[37]=h,e[38]=s,e[39]=D,e[40]=K,e[41]=W):W=e[41];let q,oe;e[42]===Symbol.for("react.memo_cache_sentinel")?(q={color:"var(--surface-elevated-foreground)"},oe=ke(Ai,"min-w-[190px]"),e[42]=q,e[43]=oe):(q=e[42],oe=e[43]);let de;e[44]!==H||e[45]!==a?(de=a(H(G1)),e[44]=H,e[45]=a,e[46]=de):de=e[46];let ce;e[47]!==de?(ce=n.jsx(Vi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(Ui,{"data-slot":"dropdown-menu-content",style:q,className:oe,children:de})})}),e[47]=de,e[48]=ce):ce=e[48];let je;e[49]!==x||e[50]!==te||e[51]!==W||e[52]!==ce?(je=n.jsxs(Mf,{open:x,onOpenChange:S,onOpenChangeComplete:te,children:[W,ce]}),e[49]=x,e[50]=te,e[51]=W,e[52]=ce,e[53]=je):je=e[53];let be;return e[54]!==y||e[55]!==w||e[56]!==j||e[57]!==ne||e[58]!==re||e[59]!==je||e[60]!==_||e[61]!==ee?(be=n.jsx("div",{ref:j,style:_,className:ee,"data-active":ne,...re,...y,...w,children:je}),e[54]=y,e[55]=w,e[56]=j,e[57]=ne,e[58]=re,e[59]=je,e[60]=_,e[61]=ee,e[62]=be):be=e[62],be},q1=t=>{const e=Ke.c(66),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,l=o===void 0?!1:o,{t:a,direction:d}=vt(),u=d==="rtl",f=zr(Q1),h=zr(Z1),m=zr(J1),g=zr(eS),b=nt(tS),v=nt(sS),x=ws(nS),S=qm(b);let p,y;e[0]!==S||e[1]!==b||e[2]!==h?(p=()=>{b&&h(b,S)},y=[b,S,h],e[0]=S,e[1]=b,e[2]=h,e[3]=p,e[4]=y):(p=e[3],y=e[4]),c.useEffect(p,y);let w;if(e[5]!==x){w=new Map;for(const G of x)w.set(G.id,G);e[5]=x,e[6]=w}else w=e[6];const j=w;let k;if(e[7]!==j||e[8]!==f){k=[];for(const G of f){const ae=j.get(G);ae&&k.push({id:G,session:ae})}e[7]=j,e[8]=f,e[9]=k}else k=e[9];const P=k;let A;e[10]!==v?(A=G=>{v(G.id,Xn(G.session))},e[10]=v,e[11]=A):A=e[11];const F=A,D=rS;let E;e[12]!==m||e[13]!==b||e[14]!==F||e[15]!==P?(E=G=>{if(m(G),b&&b!==G){const ae=P.find(ye=>ye.id===G);ae&&F(ae)}},e[12]=m,e[13]=b,e[14]=F,e[15]=P,e[16]=E):E=e[16];const T=E;let $;e[17]===Symbol.for("react.memo_cache_sentinel")?($={activationConstraint:{distance:8}},e[17]=$):$=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{delay:200,tolerance:6}},e[18]=O):O=e[18];const K=Rr(Bs(Ir,$),Bs(Dr,O));let I;e[19]!==g?(I=G=>{const{active:ae,over:ye}=G;ye&&ae.id!==ye.id&&g(String(ae.id),String(ye.id))},e[19]=g,e[20]=I):I=e[20];const X=I,N=c.useRef(null);let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C={left:!1,right:!1},e[21]=C):C=e[21];const[R,H]=c.useState(C);let M;e[22]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{const G=N.current;if(!G)return;const ae=G.scrollWidth-G.clientWidth,ye=xa(G)?ae+G.scrollLeft:G.scrollLeft,ge=ye>2,Se=ye<ae-2;H(ve=>ve.left===ge&&ve.right===Se?ve:{left:ge,right:Se})},e[22]=M):M=e[22];const _=M;let B;e[23]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{_();const G=N.current;if(!G||!globalThis.ResizeObserver)return;const ae=new ResizeObserver(_);return ae.observe(G),()=>ae.disconnect()},e[23]=B):B=e[23];let ee;e[24]!==P.length?(ee=[_,P.length],e[24]=P.length,e[25]=ee):ee=e[25],c.useEffect(B,ee);let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{const G=N.current,ae=G?.querySelector("[data-active-session-tab]");if(!G||!ae)return;const ye=z1(G.getBoundingClientRect(),ae.getBoundingClientRect());ye!==0&&(G.scrollLeft=G.scrollLeft+ye,_())},e[26]=ne):ne=e[26];let re;e[27]!==b?(re=[b,_],e[27]=b,e[28]=re):re=e[28],c.useEffect(ne,re);const te=R.left&&R.right?`linear-gradient(to right, transparent, black ${fr}px, black calc(100% - ${fr}px), transparent)`:R.left?`linear-gradient(to right, transparent, black ${fr}px)`:R.right?`linear-gradient(to right, black calc(100% - ${fr}px), transparent)`:void 0;let W;e[29]!==P?(W=P.map(oS),e[29]=P,e[30]=W):W=e[30];const q=W;let oe;e[31]!==b||e[32]!==P?(oe=!!b&&!P.some(G=>G.id===b),e[31]=b,e[32]=P,e[33]=oe):oe=e[33];const de=oe;let ce;e[34]!==a?(ce=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=ce):ce=e[35];let je;e[36]!==te?(je=te?{maskImage:te,WebkitMaskImage:te}:void 0,e[36]=te,e[37]=je):je=e[37];let be;e[38]===Symbol.for("react.memo_cache_sentinel")?(be=[K1],e[38]=be):be=e[38];const pe=u?w1:k1;let U;e[39]!==i||e[40]!==b||e[41]!==T||e[42]!==F||e[43]!==r||e[44]!==s||e[45]!==l||e[46]!==P?(U=P.map(G=>n.jsx(U1,{tab:G,isActive:G.id===b,suppressControls:G.id===b&&l,onSelect:F,onClose:D,renderMenu:s,closeOtherTabs:T,onMenuOpenChangeComplete:r,children:G.id===b?i:null},G.id)),e[39]=i,e[40]=b,e[41]=T,e[42]=F,e[43]=r,e[44]=s,e[45]=l,e[46]=P,e[47]=U):U=e[47];let Pe;e[48]!==pe||e[49]!==U||e[50]!==q?(Pe=n.jsx(Uo,{items:q,strategy:pe,children:U}),e[48]=pe,e[49]=U,e[50]=q,e[51]=Pe):Pe=e[51];let xe;e[52]!==X||e[53]!==K||e[54]!==Pe?(xe=n.jsx(Tr,{sensors:K,collisionDetection:Mr,modifiers:be,onDragEnd:X,children:Pe}),e[52]=X,e[53]=K,e[54]=Pe,e[55]=xe):xe=e[55];let Ee;e[56]!==i||e[57]!==de?(Ee=de?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[56]=i,e[57]=de,e[58]=Ee):Ee=e[58];let L;e[59]!==je||e[60]!==xe||e[61]!==Ee?(L=n.jsxs("div",{ref:N,onScroll:_,onWheel:H1,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:je,children:[xe,Ee]}),e[59]=je,e[60]=xe,e[61]=Ee,e[62]=L):L=e[62];let ie;return e[63]!==ce||e[64]!==L?(ie=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ce,children:L}),e[63]=ce,e[64]=L,e[65]=ie):ie=e[65],ie};function Y1(t){return t.stopPropagation()}function X1(t){return t.stopPropagation()}function Q1(t){return t.tabIds}function Z1(t){return t.ensureTab}function J1(t){return t.closeOtherTabs}function eS(t){return t.reorderTabs}function tS(t){return t.currentSessionId}function sS(t){return t.setCurrentSession}function nS(t){return t.activeSessions}function rS(t){fb(t)}function oS(t){return t.id}const iS=500;function Qt(t){const e=Ke.c(9),{hint:s,children:r}=t,[o,i]=c.useState(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(f,h)=>{f&&h.reason==="trigger-focus"||i(f)},e[0]=l):l=e[0];let a;e[1]!==r?(a=n.jsx(At,{asChild:!0,children:r}),e[1]=r,e[2]=a):a=e[2];let d;e[3]!==s?(d=n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-64",children:s}),e[3]=s,e[4]=d):d=e[4];let u;return e[5]!==o||e[6]!==a||e[7]!==d?(u=n.jsxs(Ot,{delayDuration:iS,open:o,onOpenChange:l,children:[a,d]}),e[5]=o,e[6]=a,e[7]=d,e[8]=u):u=e[8],u}const aS=t=>{const e=Ke.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=vt(),l=Zt(lS),a=gs(cS);let d;e[0]!==i?(d=i("sessions.moveChatToProject.title"),e[0]=i,e[1]=d):d=e[1];let u;e[2]!==d?(u=n.jsx(Us,{children:d}),e[2]=d,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 h;e[6]!==f?(h=n.jsx(qs,{children:f}),e[6]=f,e[7]=h):h=e[7];let m;e[8]!==u||e[9]!==h?(m=n.jsxs(Ys,{children:[u,h]}),e[8]=u,e[9]=h,e[10]=m):m=e[10];let g;if(e[11]!==a||e[12]!==r||e[13]!==o||e[14]!==l){let S;e[16]!==a||e[17]!==r||e[18]!==o?(S=p=>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(p.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:p.label?.trim()||Ko(p.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:Qn(p.path,a)})]},p.id),e[16]=a,e[17]=r,e[18]=o,e[19]=S):S=e[19],g=l.map(S),e[11]=a,e[12]=r,e[13]=o,e[14]=l,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 v;e[22]!==m||e[23]!==b?(v=n.jsxs(zs,{className:"max-w-md",children:[m,b]}),e[22]=m,e[23]=b,e[24]=v):v=e[24];let x;return e[25]!==r||e[26]!==s||e[27]!==v?(x=n.jsx(Ks,{open:s,onOpenChange:r,children:v}),e[25]=r,e[26]=s,e[27]=v,e[28]=x):x=e[28],x};function lS(t){return t.projects}function cS(t){return t.homeDirectory}function pc(t){const e=Ke.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=vt();let l;e[0]!==s?(l=k=>!!k.entityById.get(s)?.time.archived,e[0]=s,e[1]=l):l=e[1];const a=ws(l);let d;e[2]!==s?(d=k=>!!k.entityById.get(s)?.parentID,e[2]=s,e[3]=d):d=e[3];const u=ws(d),f=nt(dS);let h;e[4]!==s||e[5]!==i||e[6]!==f?(h=async()=>{await f(s)?Le.success(i("sessions.sidebar.session.restore.success")):Le.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=h):h=e[7];const m=h;if(a&&u)return null;const g=a?"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 v;e[11]!==a||e[12]!==r||e[13]!==m?(v=a?()=>{m()}:r,e[11]=a,e[12]=r,e[13]=m,e[14]=v):v=e[14];const x=a?"inbox-unarchive":"inbox-archive";let S;e[15]!==x?(S=n.jsx(Z,{name:x,className:"me-1 size-4"}),e[15]=x,e[16]=S):S=e[16];const p=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let y;e[17]!==i||e[18]!==p?(y=i(p),e[17]=i,e[18]=p,e[19]=y):y=e[19];let w;e[20]!==o||e[21]!==y||e[22]!==v||e[23]!==S?(w=n.jsxs(o,{onClick:v,children:[S,y]}),e[20]=o,e[21]=y,e[22]=v,e[23]=S,e[24]=w):w=e[24];let j;return e[25]!==w||e[26]!==b?(j=n.jsx(Qt,{hint:b,children:w}),e[25]=w,e[26]=b,e[27]=j):j=e[27],j}function dS(t){return t.unarchiveSession}const Af=async t=>{const{entry:e,session:s}=t,r=Yt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(hb(e.action)&&pb(e.guest,"conversation"))){await Hl(e,Vl(e.action.id,o),t.t,r);return}let l=!1;const a=Bo(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Hl(e,Vl(e.action.id,o,d),t.t,r)}};function Yi(t){const e=Ke.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:l}=vt(),{pending:a,disabled:d,hint:u,run:f}=Ym(s,r,o),h=a?"loader-4":"ai-generate-2",m=a?"me-1 size-4 animate-spin":"me-1 size-[15px]";let g;e[0]!==h||e[1]!==m?(g=n.jsx(Z,{name:h,className:m}),e[0]=h,e[1]=m,e[2]=g):g=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let v;e[5]!==i||e[6]!==d||e[7]!==f||e[8]!==g||e[9]!==b?(v=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:d,onClick:f,className:"w-full",children:[g,b]})}),e[5]=i,e[6]=d,e[7]=f,e[8]=g,e[9]=b,e[10]=v):v=e[10];let x;return e[11]!==u||e[12]!==v?(x=n.jsx(Qt,{hint:u,children:v}),e[11]=u,e[12]=v,e[13]=x):x=e[13],x}const jo=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class Of extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const Yo=Br(()=>({pendingSessionIds:new Set})),Bf=t=>{const e=Ke.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],Yo(s)},mc=(t,e)=>{Yo.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}})},uS=async(t,e)=>{try{const d=(await xb(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=ot(t),r=ot(e)??e,o=nt.getState().availableWorktreesByProject,l=(o.get(r)??o.get(e)??[]).find(a=>ot(a.path)===s)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},gc=t=>{for(const e of t){const s=gb(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class fS extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const hS=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new fS(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},pS=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(vu(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Su(i,s,e),nt.getState().setWorktreeMetadata(i.id,r.get(i.id)??null)}catch(l){o.push({sessionId:i.id,error:l instanceof Error?l:new Error(String(l))})}}return o},bc=async(t,e,s)=>{try{await ku(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${s.message}`)}throw s},yc=async(t,e)=>{const s=e?[t,e]:[t];try{await Ra(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},Qa=async(t,e)=>{if(Yo.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");mc(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(a=>[a.id,nt.getState().getWorktreeMetadata(a.id)]));gc(s);let o=null;const i=[];let l=!1;try{o=await e();for(const[a,d]of s.entries()){gc(s.slice(a));try{await Su(d,t.sourceDirectory,o.directory)}catch(u){throw mb(u)&&(l=!0),u}i.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,o.metadata?Gl(o.metadata):null)}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await pS(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(l&&await yc(t.sourceDirectory,o?.directory),u.length>0)throw hS(d,u);if(o?.onMoveFailure&&!l)return o.onMoveFailure(d);throw o?.onMoveFailure&&l?new Of(d):d}return nt.getState().setWorktreeMetadata(t.root.id,o.metadata?Gl(o.metadata):null),await yc(t.sourceDirectory,o.directory),o.directory}finally{mc(t.root.id,!1)}},mS=async t=>{const e=ot(t.sourceDirectory)??t.sourceDirectory,s=ot(t.destination.path)??t.destination.path;if(e===s)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return Qa(t,async()=>({directory:t.destination.path,metadata:t.destination}))},gS=async t=>{if((ot(t.sourceDirectory)??t.sourceDirectory)===(ot(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return Qa(t,async()=>({directory:t.projectDirectory,metadata:null}))},bS=async t=>Qa(t,async()=>{const e=Oi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await wu(t.sourceDirectory)?await uS(t.sourceDirectory,e.path):null,r=await bb(e,s?{startRef:s}:{});try{await yb(r.path)}catch(o){const i=o instanceof Error?o:new Error(String(o));return bc(e,r,i)}return{directory:r.path,metadata:r,onMoveFailure:async o=>bc(e,r,o)}}),yS=t=>{(t.kind==="existing"?mS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?gS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):bS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Le.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));Le.error(t.messages.failure,{description:r instanceof Of?t.messages.outcomeUnknown:r.message})})},Co=t=>{Yo.getState().pendingSessionIds.has(t.root.id)||yS(t)},hi="--oc-titlebar-controls-width",Xi=new Set;let br=null;const Ff=t=>{br===null?t.style.removeProperty(hi):t.style.getPropertyValue(hi)!==br&&t.style.setProperty(hi,br)},xS=t=>{const e=`${Math.round(t)}px`;e!==br&&(br=e,Xi.forEach(Ff))},_f=t=>{if(t)return Xi.add(t),Ff(t),()=>{Xi.delete(t)}},ir="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",jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},SS=()=>{Ss("ui.header.render");const{t,direction:e}=vt(),s=ue(V=>V.isSidebarOpen),r=Da(),o=ue(V=>V.sessionTabsEnabled),i=nt(V=>!!V.newSessionDraft?.open),l=nt(V=>V.currentSessionId),a=Sb(l??""),d=Bf(l??""),u=ws(Zn(c.useCallback(V=>{if(!l)return null;const De=[...V.activeSessions,...V.archivedSessions].find(Qe=>Qe.id===l);if(!De)return null;const _e=De;return{title:De.title??null,directory:_e.directory??null,created:De.time?.created??null,slug:_e.slug??null,parentId:De.parentID??null}},[l]))),f=Zt(Zn(V=>{if(!V.activeProjectId)return null;const De=V.projects.find(_e=>_e.id===V.activeProjectId);return De?{id:De.id,path:De.path,label:De.label}:null})),h=c.useMemo(()=>{if(!f)return null;const V=f.label?.trim();if(V)return V;const De=f.path.split(/[\\/]/).filter(Boolean);return De[De.length-1]??null},[f]),m=_n(V=>V.loadSettings),{isMobile:g}=Mn(),b=c.useRef(null),[v,x]=c.useState(()=>typeof window>"u"?!1:pn()),S=c.useMemo(()=>mo(),[]),p=vb(),[y,w]=c.useState(!1),j=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:k,side:P}=Cf(),A=c.useMemo(()=>{if(typeof window>"u")return null;const V=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(typeof navigator>"u")return null;const De=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!De)return null;const _e=Number.parseInt(De[1],10),Qe=Number.parseInt(De[2],10);return Number.isNaN(_e)?null:_e===10?Qe:_e},[]);ds.useEffect(()=>{typeof window>"u"||x(pn())},[]);const F=c.useMemo(()=>Sn(),[]),D=ue(V=>V.workStatusPanelVisible),E=ue(V=>V.workStatusPanelEnabled),T=ue(V=>V.setWorkStatusPanelEnabled),$=ue(V=>V.workStatusPanelFits),O=ue(V=>V.workStatusOverlayOpen),K=ue(V=>V.setWorkStatusOverlayOpen),X=E&&$||O,N=c.useCallback(()=>{if(E&&!$){K(!O);return}T(!E)},[K,T,O,E,$]);wb(),c.useEffect(()=>{m()},[m]);const C=l?u??null:null,R=c.useRef(null),[H,M]=c.useState(0);c.useEffect(()=>{if(!l){R.current&&(R.current=null,M(Qe=>Qe+1));return}if(C){R.current={sessionId:l,session:C,expiresAt:Date.now()+2e3};return}const V=R.current;if(!V||V.sessionId!==l)return;const De=V.expiresAt-Date.now();if(De<=0){R.current=null,M(Qe=>Qe+1);return}const _e=window.setTimeout(()=>{R.current?.sessionId===l&&(R.current=null),M(Qe=>Qe+1)},De);return()=>{window.clearTimeout(_e)}},[l,C]);const _=(()=>{if(C)return C;if(!l)return null;const V=R.current;return V&&V.sessionId===l&&V.expiresAt>Date.now()?V.session:null})(),B=nt(V=>l?V.worktreeMetadata.get(l)?.path??"":""),ee=nt(V=>l?V.worktreeMetadata.get(l)?.branch?.trim()??null:null),ne=ju(V=>l?V.getAttachment(l):void 0),re=c.useMemo(()=>ne?kb(ne,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ne]),te=c.useMemo(()=>ne?ne.legacy?"legacy":ne.degraded?"degraded":ne.worktreeStatus==="pending"?"pending":ne.worktreeStatus==="missing"?"missing":ne.worktreeStatus==="invalid"?"invalid":ne.attentionReason?"attention":null:null,[ne]),W=c.useMemo(()=>jn(B||""),[B]),q=c.useMemo(()=>{const V=typeof _?.directory=="string"?_.directory:"";return jn(V||"")},[_?.directory]),oe=ka(l??"",q),de=nt(V=>V.newSessionDraft?.open?jn(V.newSessionDraft.bootstrapPendingDirectory??V.newSessionDraft.directoryOverride??""):""),ce=nt(V=>V.newSessionDraft.target),je=nt(V=>V.newSessionDraft.selectedProjectId),be=nt(V=>V.currentSessionDirectory),pe=gs(V=>V.homeDirectory),U=c.useMemo(()=>W||q||de,[de,q,W]),Pe=nt(V=>{const De=jn(W||q||"");if(!De)return null;for(const _e of V.availableWorktreesByProject.values()){const yt=_e.find(Dt=>jn(Dt.path)===De)?.branch?.trim();if(yt)return yt}return null}),Ee=jb(U||null)||ee||Pe,L=i?ce==="chat":Ud(q||be,pe),ie=!L&&!D&&!!(h||Ee||!i&&te),G=c.useMemo(()=>{if(!l)return h??"OpenChamber";const V=_?.title?.trim();return V&&V.length>0?V:"Untitled Session"},[h,_?.title,l]),ae=Cu(),ye=nt(V=>V.updateSessionTitle),ge=nt(V=>V.archiveSessions),Se=nt(V=>V.deleteSessions),[ve,Te]=c.useState(!1),[z,he]=c.useState(!1),se=c.useRef(null),[Re,Ue]=c.useState(""),[We,He]=c.useState(!1),Be=Zt(V=>V.projects.length>0),[Y,Me]=c.useState(null),Ge=c.useRef(null),Ve=c.useCallback(()=>{l&&(Ue(_?.title?.trim()||G),Te(!0))},[_?.title,l,G]),dt=c.useRef(Ve);dt.current=Ve;const et=c.useCallback(V=>{V&&(V.focus(),V.select())},[]);c.useEffect(()=>{if(he(!1),Me(null),l&&se.current===l){se.current=null,dt.current();return}Te(!1),Ue("")},[l]);const ct=c.useCallback(async()=>{if(!l)return;const V=Re.trim();V&&V!==_?.title?.trim()&&await ye(l,V),Te(!1)},[_?.title,l,Re,ye]);c.useEffect(()=>{if(!ve)return;const V=De=>{const _e=De.target;(!_e||!Ge.current?.contains(_e))&&ct()};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[ve,ct]);const me=c.useCallback(V=>{V&&Wo(V).then(De=>{Le[De.ok?"success":"error"](t(De.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(t("sessions.sidebar.session.copyId.error")))},[t]),Ne=c.useCallback(async()=>{if(!l||!U){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const V=await ae({sessionID:l,directory:U}).catch(()=>null);if(!V){Le.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(V.length===0){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const De=Pu(V,_?.title??null),_e=Eu(_?.title??null);await Nu(De,_e)||Ru(De,_e),Le.success(t("sessions.sidebar.session.export.success"))},[_?.title,l,ae,U,t]),qe=Du(),Ye=c.useMemo(()=>Iu(qe),[qe]),$e=c.useCallback(V=>{l&&Af({entry:V,t,session:{id:l,title:_?.title,directory:q??U},loadRecords:async()=>{if(!U)return null;try{return await ae({sessionID:l,directory:U})}catch{return null}},onLoadFailed:()=>Le.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[_?.title,l,ae,U,q,t]),tt=c.useCallback(V=>Ye.map(De=>n.jsxs(V,{onClick:()=>$e(De),children:[n.jsx(sr,{icon:De.icon,iconSrc:De.iconSrc,className:"me-1 size-4"}),De.action.label]},`${De.guest.id}:${De.action.id}`)),[Ye,$e]),ht=a?.type==="busy"||a?.type==="retry",wt=c.useCallback(()=>{if(!l||!q||ht||d)return;const V=ws.getState().activeSessions,De=V.find(yt=>yt.id===l);if(!De)return;const _e=[],Qe=[l];for(let yt=0;yt<Qe.length;yt+=1){const Dt=Qe[yt];for(const zt of V)zt.parentID===Dt&&(_e.push(zt),Qe.push(zt.id))}Co({kind:"quick",root:De,descendants:_e,sourceDirectory:q,messages:jo(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[l,ht,d,q,t]),Bt=c.useCallback(V=>{if(!l||!q||ht||d)return;const De=ws.getState().activeSessions,_e=De.find(Dt=>Dt.id===l);if(!_e)return;const Qe=[],yt=[l];for(let Dt=0;Dt<yt.length;Dt+=1)for(const zt of De)zt.parentID===yt[Dt]&&(Qe.push(zt),yt.push(zt.id));Co({kind:"project",root:_e,descendants:Qe,sourceDirectory:q,projectDirectory:V,messages:jo(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[l,ht,d,q,t]),kt=c.useCallback(async(V,De)=>{const _e=[De,...ou(De,[],V==="delete")],Qe=nt.getState().currentSessionId===De?De:null;if(V==="delete"){const{failedIds:zt}=await Se(_e);zt.length>0?Le.error(t("sessions.sidebar.session.delete.error")):Le.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:yt,failedIds:Dt}=await ge(_e);if(Dt.length>0){Le.error(t("sessions.sidebar.session.archive.error"));return}Le.success(t("sessions.sidebar.session.archive.success"),Xm(yt,Qe,t))},[ge,Se,t]),St=c.useCallback(async()=>{if(!Y)return;const{action:V,sessionId:De}=Y;Me(null),await kt(V,De)},[Y,kt]),xt=ue(V=>V.openGuestPageId),Mt=Ia(V=>V.guests.find(De=>De.id===xt)),jt=ue(V=>V.isScheduledTasksDialogOpen),$t=ue(V=>V.isArchivePageOpen),Kt=ue(V=>V.isUsageStatsPageOpen),Wt=ue(V=>V.isSourceBoardOpen),rt=ue(V=>V.worktreesPageProjectId),ut=ue(V=>V.isolatedSpacesEnabled?V.spacesPageProjectId:null),pt=ue(V=>V.runOverviewKey),fe=Qm(pt),lt=rt??ut,ft=Zt(V=>{if(!lt)return null;const De=V.projects.find(_e=>_e.id===lt);return De?.label?.trim()||De?.path?.split("/").pop()||null}),mt=c.useMemo(()=>Mt?{title:Mt.pageTitle??Mt.name,subtitle:null}:jt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:$t?{title:t("sessions.archivePage.title"),subtitle:null}:Kt?{title:t("usageStats.title"),subtitle:null}:Wt?{title:t("sourceBoard.title"),subtitle:null}:rt?{title:t("sessions.worktreesPage.title",{project:ft??""}),subtitle:null}:ut?{title:t("spaces.page.title",{project:ft??""}),subtitle:null}:pt?{title:fe??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[Mt,$t,fe,pt,jt,Wt,Kt,ut,ft,t,rt]),Rt=Ta(V=>V.planModeEnabled),we=nt(V=>V.isSessionPlanAvailable),it=Rt&&l?we(l):!1,Q=c.useRef("");c.useEffect(()=>{if(!Rt||!l)return;const V=`${l||"none"}:${q||"none"}:${_?.created||0}:${_?.slug||"none"}`;Q.current!==V&&(Q.current=V)},[Rt,it,_?.slug,_?.created,l,q]);const le=q||jn(be||"")||W,Xe=c.useCallback(()=>{hn("desktop_open_draft_mini_chat_window",{directory:L?"":de,projectId:L?null:je,apiBaseUrl:hr(),clientToken:to()}).catch(V=>{console.warn("[header] failed to open draft mini chat window",V)})},[de,je,L]),Ae=c.useCallback(()=>{if(i){Xe();return}l&&hn("desktop_open_session_mini_chat_window",{sessionId:l,directory:q||jn(be||"")||W,apiBaseUrl:hr(),clientToken:to()}).catch(V=>{console.warn("[header] failed to open session mini chat window",V)})},[l,Xe,i,be,q,W]),Je=S&&(i||!!l),Fe=c.useCallback((V,De)=>{hn("desktop_open_session_mini_chat_window",{sessionId:V,directory:De,apiBaseUrl:hr(),clientToken:to()}).catch(_e=>{console.warn("[header] failed to open session mini chat window",_e)})},[]),gt=ir,bt=c.useMemo(()=>v&&j&&!y?"88px":p?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!v||k)&&!F?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[v,y,j,p,F,k]),Et=(!v||k)&&!F?"calc(0.75rem + var(--oc-wco-right-inset, 0px))":"0.75rem",Ft=e==="rtl",es=Ft?Et:bt,Ie=Ft?bt:Et,Ze=k&&P!==qd(e);ds.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-start-inset",es)},[es]);const at=s?"0.75rem":"var(--oc-titlebar-start-inset, 0.75rem)",Lt=s?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ds.useEffect(()=>{if(!v||!j){w(!1);return}let V=!1;const De=async()=>{try{const Qe=await hn("desktop_is_window_fullscreen");V||w(Qe===!0)}catch{V||w(!1)}},_e=()=>{De()};return De(),window.addEventListener("openchamber:window-resized",_e),()=>{V=!0,window.removeEventListener("openchamber:window-resized",_e)}},[v,j]);const Vt=c.useMemo(()=>!v||!j||A===null?"":A>=26?"h-11":A<=15?"h-14":"",[v,j,A]),Ht=c.useMemo(()=>v&&j&&!y?A!==null&&A<=15?"56px":"44px":"0px",[v,y,j,A]),Oe=c.useMemo(()=>{const De=`max(${v&&j?"2.75rem":"3rem"}, ${Ht}, var(--oc-wco-titlebar-height, 0px))`,_e=v&&!k||F;if(_e&&Ht==="0px")return{};const Qe={minHeight:De,height:De};return!Ze&&(!_e||Ft)&&(Qe.paddingInlineEnd=Ie),Qe},[Ze,v,j,Ft,F,Ie,Ht,k]),ze=c.useRef(null),st=c.useCallback(V=>{!V||V===ze.current||(ze.current=V,document.documentElement.style.setProperty("--oc-header-height",`${V}px`))},[]),Nt=c.useCallback(()=>{typeof document>"u"||st(b.current?.getBoundingClientRect().height)},[st]);ds.useEffect(()=>{if(typeof window>"u")return;Nt();const V=b.current;if(!V||typeof ResizeObserver>"u")return()=>{};let De=0;const _e=()=>{De||(De=requestAnimationFrame(()=>{De=0,Nt()}))},Qe=new ResizeObserver(yt=>{const Dt=yt[yt.length-1];st(Dt?.borderBoxSize?.[0]?.blockSize??Dt?.target.getBoundingClientRect().height)});return Qe.observe(V),window.addEventListener("resize",_e),window.addEventListener("orientationchange",_e),()=>{De&&cancelAnimationFrame(De),Qe.disconnect(),window.removeEventListener("resize",_e),window.removeEventListener("orientationchange",_e)}},[st,Nt]),ds.useEffect(()=>{Nt()},[Nt,g,Vt]);const It=c.useCallback(async V=>{const De=V.target;De.closest(".app-region-no-drag")||De.closest("button, a, input, select, textarea")||V.button===0&&v&&await em()},[v]);Tu({rename_current_session:()=>{if(!l||g)return!1;Ve()},archive_current_session:()=>{if(!l||g||ws.getState().entityById.get(l)?.time.archived)return!1;if(ue.getState().showDeletionDialog){Me({action:"archive",sessionId:l});return}kt("archive",l)}});const ts=n.jsxs(n.Fragment,{children:[n.jsx(O1,{directory:U,className:ke(ir,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"}),n.jsx(Zm,{directory:U,className:ke(ir,"text-muted-foreground hover:text-foreground"),iconClassName:"h-4 w-4"})]}),fs=c.useCallback(({session:V,open:De,isActive:_e,select:Qe,closeOtherTabs:yt,components:Dt})=>{const{Item:zt,Separator:Jt}=Dt,Ds=_e&&!F&&!L&&_&&!_.parentId,ys=_e&&!F&&L&&_&&!_.parentId&&Be;return n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(zt,{onClick:()=>{_e||Qe(),se.current=V.id},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Yi,{sessionID:V.id,directory:V.directory,open:De,Item:zt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(zt,{onClick:()=>me(V.id),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Jt,{}),_e?n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(zt,{onClick:()=>{Ne()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,S?n.jsxs(zt,{onClick:()=>Fe(V.id,_e?le:V.directory??""),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,_e?tt(zt):null,Ds?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(zt,{disabled:!q||ht||d,onClick:wt,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,ys?n.jsx(Qt,{hint:t(ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(zt,{disabled:!q||ht||d,onClick:()=>He(!0),className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(Jt,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(zt,{onClick:yt,children:[n.jsx(Z,{name:"close-circle",className:"me-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(Jt,{}),n.jsx(pc,{sessionId:V.id,Item:zt,onArchive:()=>Me({action:"archive",sessionId:V.id})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(zt,{className:"text-destructive focus:text-destructive",onClick:()=>Me({action:"delete",sessionId:V.id}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[me,_,le,Ne,S,Be,L,ht,d,F,wt,Fe,tt,q,t]),us=()=>n.jsxs("div",{onMouseDown:It,className:ke("app-region-drag relative flex h-12 select-none items-center",Ze?"pe-0":"pe-2.5",Vt),style:Oe,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:at,transitionDuration:`${r}ms`}}),n.jsx("div",{ref:_f,"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] ease-out motion-reduce:transition-none",style:{width:Lt,transitionDuration:`${r}ms`}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[mt?n.jsxs(n.Fragment,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{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:()=>ue.getState().closeMainSurfaces(),children:n.jsx(Z,{name:"arrow-left",className:"size-4"})})}),n.jsx(Tt,{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:mt.title}),mt.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:mt.subtitle}):null]})]}):F||!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:[oe?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(p1,{align:"start",children:n.jsx("button",{type:"button",className:gt,"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:[ve?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),ct()},children:[n.jsx("input",{ref:et,value:Re,onChange:V=>Ue(V.target.value),onKeyDown:V=>Mi(V,()=>Te(!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:()=>Te(!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:G}),ie?n.jsxs("span",{className:ke("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:[h?n.jsx("span",{className:"truncate",children:h}):null,Ee?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx(Z,{name:"git-branch",className:ke("flex-shrink-0 text-muted-foreground/70",i?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:ke("truncate",i&&"text-muted-foreground"),children:Ee})]}):null,!i&&te?n.jsxs("span",{className:ke("inline-flex min-w-0 items-center gap-0.5",te==="attention"||te==="invalid"||te==="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:re})]}):null]}):null]}),n.jsx("div",{className:ke("flex h-[18px] shrink-0 items-center justify-center",ie?"self-start":"self-center"),children:l&&!i&&!ve?n.jsxs(js,{open:z,onOpenChange:he,onOpenChangeComplete:V=>{!V&&se.current&&se.current===l&&(se.current=null,Ve())},children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{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(Ps,{align:"end",className:"min-w-[190px]",children:[n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(qt,{onClick:()=>{se.current=l},children:[n.jsx(Z,{name:"pencil-ai",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(Yi,{sessionID:l,directory:q,open:z,Item:qt}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(qt,{onClick:()=>l&&me(l),children:[n.jsx(Z,{name:"file-copy",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(bn,{}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(qt,{onClick:()=>{Ne()},children:[n.jsx(Z,{name:"download",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),S?n.jsxs(qt,{onClick:()=>Fe(l,le),children:[n.jsx(Z,{name:"picture-in-picture-2",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.openInMiniChat")]}):null,tt(qt),!F&&!L&&_&&!_.parentId?n.jsx(Qt,{hint:t(d?"sessions.sidebar.session.moveToWorktree.tooltipMoving":ht?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(qt,{disabled:!q||ht||d,onClick:wt,className:"w-full",children:[n.jsx(Z,{name:"folder-shared",className:"me-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(bn,{}),n.jsx(pc,{sessionId:l,Item:qt,onArchive:()=>Me({action:"archive",sessionId:l})}),n.jsx(Qt,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(qt,{className:"text-destructive focus:text-destructive",onClick:()=>{l&&Me({action:"delete",sessionId:l})},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(q1,{renderMenu:fs,suppressActiveTabControls:ve,onMenuOpenChangeComplete:V=>{!V&&se.current&&se.current===l&&(se.current=null,Ve())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ve?n.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:V=>V.stopPropagation(),onSubmit:V=>{V.preventDefault(),ct()},children:[n.jsx("input",{ref:et,value:Re,onChange:V=>Ue(V.target.value),onKeyDown:V=>Mi(V,()=>Te(!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:()=>Te(!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"):G})})})}),mt||F||!o?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[Je?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":t(i?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Ae,className:ir,children:n.jsx(Z,{name:"picture-in-picture-2",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",children:t(i?"header.actions.newMiniChat":"header.actions.openSessionMiniChat")})]}):null,F?null:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":X,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:N,className:ke(ir,X&&"text-foreground"),children:n.jsx(Z,{name:"list-indefinite",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",children:t(E&&!$?O?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":E?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ts,n.jsx(Pf,{visible:Ze,position:P})]})]})]});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:us()}),n.jsx(aS,{open:We,onOpenChange:He,onPick:Bt}),n.jsx(Ks,{open:Y!==null,onOpenChange:V=>{V||Me(null)},children:n.jsxs(zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Ys,{children:[n.jsx(Us,{children:Y?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(qs,{children:Y?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:G}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:G})})]}),n.jsxs(yn,{children:[n.jsx(Ct,{variant:"outline",size:"sm",onClick:()=>Me(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",size:"sm",onClick:()=>{St()},children:Y?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})})]})},xc=280,Sc=264,vc=500,vS=({isOpen:t,isMobile:e,children:s,className:r,topBar:o})=>{const{t:i,direction:l}=vt(),a=ue(O=>O.sidebarWidth),d=ue(O=>O.setSidebarWidth),[u,f]=c.useState(!1),h=c.useRef(0),m=c.useRef(a||xc),g=c.useRef(null),b=c.useRef(null),v=c.useRef(null),x=c.useCallback(O=>Math.min(vc,Math.max(Sc,O)),[]),S=c.useCallback(O=>{const K=v.current;K&&(K.style.width=`${O}px`,K.style.minWidth=`${O}px`,K.style.maxWidth=`${O}px`,K.style.setProperty("--oc-left-sidebar-width",`${O}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${O}px`))},[]);c.useEffect(()=>{e&&u&&f(!1)},[e,u]),c.useEffect(()=>{u||(g.current=null,b.current=null)},[u]);const p=Math.min(vc,Math.max(Sc,a||xc)),y=t?p:0,w=u?g.current??y:y,j=u?w:p;c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${j}px`)},[j]);const[k,P]=c.useState(!t);t&&k&&P(!1);const A=Da(),F=c.useRef(t),D=c.useRef(t);if(c.useLayoutEffect(()=>{F.current=t,D.current!==t&&(D.current=t,Mu(A),t||Ma(()=>{F.current||P(!0)}))},[t,A]),e)return null;const E=O=>{if(t){try{O.currentTarget.setPointerCapture(O.pointerId)}catch{}b.current=O.pointerId,f(!0),h.current=O.clientX,m.current=y,g.current=y,S(y),O.preventDefault()}},T=O=>{if(e||!u||b.current!==O.pointerId)return;const K=(O.clientX-h.current)*(l==="rtl"?-1:1),I=x(m.current+K);g.current!==I&&(g.current=I,S(I))},$=O=>{if(b.current!==O.pointerId||e)return;try{O.currentTarget.releasePointerCapture(O.pointerId)}catch{}const K=x(g.current??y);b.current=null,g.current=null,f(!1),d(K)};return n.jsxs("div",{ref:v,"data-left-sidebar":"",className:ke("relative flex h-full overflow-hidden border-e border-border",u?"transition-none":"transition-[width,min-width,max-width] motion-reduce:transition-none","bg-sidebar",!t&&"border-e-0",r),style:{width:`${w}px`,minWidth:`${w}px`,maxWidth:`${w}px`,"--oc-left-sidebar-width":`${j}px`,overflowX:"clip",transitionDuration:`${A}ms`,transitionTimingFunction:Bi},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:ke("absolute inset-e-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",u&&"bg-[var(--interactive-border)]"),onPointerDown:E,onPointerMove:T,onPointerUp:$,onPointerCancel:$,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),n.jsxs("aside",{className:ke("relative z-10 flex h-full shrink-0 flex-col transition-opacity ease-out motion-reduce:transition-none",u&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",transitionDuration:`${A}ms`,overflowX:"hidden",contentVisibility:k?"hidden":void 0},inert:!t||void 0,children:[o,n.jsx(Er,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(bs,{children:s})})]})]})},wS=()=>{const t=Ke.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:_f,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},Kr="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",kS=()=>{const t=Ke.c(45),{t:e,locale:s,direction:r}=vt(),o=ue(jS),i=ue(CS),l=ue(PS),a=c.useRef(null),d=Au(Ou("toggle_sidebar",l)),u=ES,{usesFramelessChrome:f,side:h}=Cf();let m;t[0]!==s?(m=R=>{const H=R.currentTarget.getBoundingClientRect();hn("desktop_show_app_menu",{x:H.left,y:H.bottom,locale:s}).catch(NS)},t[0]=s,t[1]=m):m=t[1];const g=m;let b,v;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const R=a.current;if(!R)return;const H=()=>{const _=Math.max(R.getBoundingClientRect().width,R.scrollWidth);xS(_)};if(H(),typeof ResizeObserver>"u")return;const M=new ResizeObserver(H);return M.observe(R),()=>{M.disconnect()}},v=[],t[2]=b,t[3]=v):(b=t[2],v=t[3]),c.useEffect(b,v);const x="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 p;t[4]!==S?(p={height:"var(--oc-header-height, 3rem)",paddingInlineStart:"var(--oc-titlebar-start-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=p):p=t[5];const y="flex min-w-0 items-center gap-2";let w;t[6]!==r||t[7]!==f||t[8]!==h?(w=f&&h===qd(r)?n.jsx(Pf,{visible:!0,position:h}):null,t[6]=r,t[7]=f,t[8]=h,t[9]=w):w=t[9];let j;t[10]!==g||t[11]!==e||t[12]!==f?(j=f?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:g,"aria-label":e("header.actions.openAppMenuAria"),className:ke(Kr,"shrink-0"),children:n.jsx(Z,{name:"menu-2",className:"h-4 w-4"})})}),n.jsx(Tt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[10]=g,t[11]=e,t[12]=f,t[13]=j):j=t[13];const k=Ot;let P;t[14]!==e?(P=e("header.actions.openSessionsAria"),t[14]=e,t[15]=P):P=t[15];const A=i&&"text-foreground";let F;t[16]!==A?(F=ke(Kr,"shrink-0",A),t[16]=A,t[17]=F):F=t[17];let D;t[18]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Z,{name:"layout-left",className:"h-4 w-4"}),t[18]=D):D=t[18];let E;t[19]!==i||t[20]!==F||t[21]!==P||t[22]!==o?(E=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,"data-sidebar-toggle":"","aria-label":P,"aria-pressed":i,className:F,children:D})}),t[19]=i,t[20]=F,t[21]=P,t[22]=o,t[23]=E):E=t[23];const T=Tt,$=e("header.actions.openSessionsWithShortcut",{shortcut:d});let O;t[24]!==$?(O=n.jsx("p",{children:$}),t[24]=$,t[25]=O):O=t[25];let K;t[26]!==T||t[27]!==O?(K=n.jsx(T,{children:O}),t[26]=T,t[27]=O,t[28]=K):K=t[28];let I;t[29]!==k||t[30]!==E||t[31]!==K?(I=n.jsxs(k,{children:[E,K]}),t[29]=k,t[30]=E,t[31]=K,t[32]=I):I=t[32];let X;t[33]!==u||t[34]!==i||t[35]!==e?(X=i?n.jsxs("button",{type:"button",onClick:u,className:ke(Kr,"-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(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:u,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:ke(Kr,"-ms-1 shrink-0"),children:n.jsx(Z,{name:"chat-new",className:"h-4 w-4"})})}),n.jsx(Tt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[33]=u,t[34]=i,t[35]=e,t[36]=X):X=t[36];let N;t[37]!==I||t[38]!==X||t[39]!==w||t[40]!==j?(N=n.jsxs("div",{ref:a,className:y,children:[w,j,I,X]}),t[37]=I,t[38]=X,t[39]=w,t[40]=j,t[41]=N):N=t[41];let C;return t[42]!==N||t[43]!==p?(C=n.jsx("div",{className:x,style:p,children:N}),t[42]=N,t[43]=p,t[44]=C):C=t[44],C};function jS(t){return t.toggleSidebar}function CS(t){return t.isSidebarOpen}function PS(t){return t.shortcutOverrides}function ES(){ue.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function NS(t){console.warn("[titlebar] failed to open app menu",t)}function RS(t,e,s){const r=Ke.c(5),[o,i]=c.useState();let l,a;return r[0]!==s||r[1]!==t||r[2]!==e?(l=()=>{if(e){i(void 0);return}if(!t){i(void 0);return}i(void 0);let d=!1;return(async()=>{const[u,f]=await Promise.all([Cb(t),Pb(t)]).catch(DS);if(d)return;const h=ot(u),m=ot(f);if(!h||!m||m===h)return;const g=s||"",b=m.split("/").filter(Boolean).pop()||m;i({source:"sdk",path:m,projectDirectory:h,branch:g,label:g||b,name:b,worktreeRoot:m,worktreeStatus:"ready",headState:g?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,s],r[0]=s,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??o}function DS(){return["",""]}const IS=()=>{const t=Ke.c(3),e=ue(TS),s=ue(MS);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 TS(t){return t.setSettingsDialogOpen}function MS(t){return t.setSettingsPage}const AS="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",wc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",OS=({className:t,identity:e=Fu})=>{const{t:s}=vt(),{sourceControl:r}=Ws(),o=Bu(e),i=e.provider==="gitlab",l=i?"gitlab":"github-fill",a=o?.status??null,d=mn(S=>S.setStatus),[u,f]=c.useState(!1),h=c.useCallback(async S=>{if(!(!S||u)){f(!0);try{d(e,await r.authActivate(e,S))}catch(p){console.error("Failed to switch source control account:",p)}finally{f(!1)}}},[e,u,d,r]);if(a?.status!=="connected")return null;const m=a.user.username||null,g=a.user.avatarUrl??null,b=a.accounts,v=i?m?s("header.gitlab.connectedWithLogin",{login:m}):s("header.gitlab.connected"):m?s("header.github.connectedWithLogin",{login:m}):s("header.github.connected"),x=g?n.jsx("img",{src:g,alt:m?s("header.github.avatarWithLogin",{login:m}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx(Z,{name:l,className:"h-3.5 w-3.5 text-foreground"});return b.length<=1?n.jsx("div",{className:ke(wc,t),title:v,children:x}):n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ke(wc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:v,disabled:u,children:x})}),n.jsxs(Ps,{align:"end",className:"w-64",children:[n.jsx(Fi,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(bn,{}),b.map(S=>{const p=S.user,y=!!S.current,w=s(Eb(S.source??"oauth"));return n.jsxs(qt,{className:"gap-2",disabled:u,onSelect:()=>{y||h(S.id)},children:[p?.avatarUrl?n.jsx("img",{src:p.avatarUrl,alt:p.username?s("header.github.avatarWithLogin",{login:p.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:l,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:p?.name?.trim()||p.username||(i?"GitLab":"GitHub")}),p.username?n.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[n.jsx("span",{className:"font-mono",children:p.username}),n.jsx("span",{className:"mx-1 opacity-50",children:"·"}),n.jsx("span",{children:w})]}):null]}),y?n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}):null]},S.id)})]})]})},BS=t=>JSON.stringify(Nb(t)),FS=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}},Lf=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function _S(t){if(!Lf(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function LS(t,e,s){const r=Ke.c(16),{sourceControl:o}=Ws(),[i,l]=ds.useState(null);let a;r[0]!==t.bindingRevision||r[1]!==t.provider||r[2]!==t.repositoryId||r[3]!==e?(a=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]=a):a=r[4];const d=a;let u;r[5]!==t||r[6]!==d||r[7]!==e||r[8]!==o?(u=()=>{if(t.provider!=="github")return;let h=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(m=>{if(h||!m.connected)return;const g=m.items.find(b=>b.kind==="pull"&&b.number===e);g&&l({key:d,pull:g})}).catch($S),()=>{h=!0}},r[5]=t,r[6]=d,r[7]=e,r[8]=o,r[9]=u):u=r[9];let f;return r[10]!==t||r[11]!==d||r[12]!==e||r[13]!==s||r[14]!==o?(f=[t,d,e,s,o],r[10]=t,r[11]=d,r[12]=e,r[13]=s,r[14]=o,r[15]=f):f=r[15],ds.useEffect(u,f),i?.key===d?i.pull:null}function $S(){}const zS=t=>{const e=Ke.c(58),{directory:s,context:r,changeRequest:o,onChanged:i}=t,l=vn(),a=Zt(KS),[d,u]=ds.useState(0),[f,h]=ds.useState(!1),[m]=ds.useState(WS),g=LS(r,o.number,d);let b;e[0]!==o?(b=Rb(o),e[0]=o,e[1]=b):b=e[1];const v=b;let x;e[2]!==g||e[3]!==v?(x=g?{...v,labels:g.labels,commentCount:g.commentCount}:v,e[2]=g,e[3]=v,e[4]=x):x=e[4];const S=x,{detail:p,refresh:y}=Db(s,S,!0),w=Jm(S);let j;e[5]!==i||e[6]!==y?(j=()=>{y(),u(HS),i()},e[5]=i,e[6]=y,e[7]=j):j=e[7];const k=j;let P;e[8]!==S?(P={source:"github",reference:S},e[8]=S,e[9]=P):P=e[9];const A=P,F=l??s;let D;e[10]===Symbol.for("react.memo_cache_sentinel")?(D={status:"idle"},e[10]=D):D=e[10];let E;e[11]!==r||e[12]!==A||e[13]!==k?(E=n.jsx(sg,{item:A,project:null,context:r,onStartWorktree:GS,onChanged:k}),e[11]=r,e[12]=A,e[13]=k,e[14]=E):E=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=()=>h(!0),e[15]=T):T=e[15];let $;e[16]!==w.attachComment||e[17]!==w.attachComments?($={onAttach:w.attachComment,onAttachAll:w.attachComments},e[16]=w.attachComment,e[17]=w.attachComments,e[18]=$):$=e[18];let O;e[19]!==r||e[20]!==S||e[21]!==k?(O=n.jsx(ng,{reference:S,context:r,onChanged:k}),e[19]=r,e[20]=S,e[21]=k,e[22]=O):O=e[22];let K;e[23]!==r||e[24]!==p||e[25]!==S||e[26]!==k?(K=n.jsx(rg,{pull:S,detail:p,context:r,onChanged:k}),e[23]=r,e[24]=p,e[25]=S,e[26]=k,e[27]=K):K=e[27];let I;e[28]!==r||e[29]!==S||e[30]!==k?(I=n.jsx(eg,{reference:S,context:r,onRefresh:k},S.number),e[28]=r,e[29]=S,e[30]=k,e[31]=I):I=e[31];const X=a??"";let N;e[32]!==F||e[33]!==X?(N={id:X,path:F},e[32]=F,e[33]=X,e[34]=N):N=e[34];let C;e[35]!==r||e[36]!==F||e[37]!==S||e[38]!==N?(C=n.jsx(og,{pull:S,project:N,context:r,projectOwnsDirectory:US,currentDirectory:F}),e[35]=r,e[36]=F,e[37]=S,e[38]=N,e[39]=C):C=e[39];let R;e[40]!==p||e[41]!==A||e[42]!==m||e[43]!==K||e[44]!==I||e[45]!==C||e[46]!==E||e[47]!==$||e[48]!==O?(R=n.jsx(Ib,{item:A,pullStatus:Tb,linearDetail:D,githubDetail:p,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:VS,now:m,footer:E,onOpenChecks:T,commentAttachments:$,labelsControl:O,reviewersControl:K,reply:I,pullLinks:C}),e[40]=p,e[41]=A,e[42]=m,e[43]=K,e[44]=I,e[45]=C,e[46]=E,e[47]=$,e[48]=O,e[49]=R):R=e[49];let H;e[50]!==w.attachFailedChecks||e[51]!==f||e[52]!==r||e[53]!==S?(H=n.jsx(tg,{pull:S,context:r,open:f,onOpenChange:h,onAttachFailed:w.attachFailedChecks}),e[50]=w.attachFailedChecks,e[51]=f,e[52]=r,e[53]=S,e[54]=H):H=e[54];let M;return e[55]!==R||e[56]!==H?(M=n.jsxs(n.Fragment,{children:[R,H]}),e[55]=R,e[56]=H,e[57]=M):M=e[57],M};function KS(t){return t.activeProjectId}function WS(){return Date.now()}function HS(t){return t+1}function VS(){}function GS(){}function US(){return!0}function qS(t,e){const{git:s,sourceControl:r}=Ws(),{t:o}=vt(),i=ig(),l=ag({directory:t,branch:e,chooseContributor:i.choose}),a=lg(t,s,r),d=async()=>{const f=a.start();if(!f)return Le.info(o("gitView.pr.toast.gitBusy")),!1;const h=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await l.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(m){if(m instanceof Mb){if(m.code==="stale-runtime")return!1;const g=l.errorMessage(m);return g?Le.info(g):Le.error(h),!1}return m instanceof Ab||m instanceof Ob?(Le.error(h,{description:m.message||void 0}),!1):(Le.error(h,{description:m instanceof Error?m.message:String(m)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[l.context?n.jsx(cg,{context:l.context,onSelect:l.settle}):null,l.confirmDialog,n.jsx(dg,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,dialogs:u}}const YS=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"}},XS=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=nt.getState(),o=s?r(s):null;!s||!o||ot(o)!==ot(t)||Gb(s,o,Ub({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},QS=t=>{const e=t?.changeRequest??t?.pr;return e?qb({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},ZS=[2e3,5e3];let kc=0;const JS=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(kc+=1,`source-control-${Date.now().toString(36)}-${kc.toString(36)}`)},ev=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),$f="openchamber:pr-create-as-draft:v1",jc=()=>{try{return localStorage.getItem($f)==="true"}catch{return!1}},tv=t=>{try{localStorage.setItem($f,String(t))}catch{}},pi=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),dn=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):""},sv=(t,e)=>{const s=dn(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},nv=(t,e)=>`${t}::${e}`,mi=new Map,Cc=Oa;function rv(t,e,s){const r=Ke.c(14);let o;r[0]!==s?(o=s?BS(s):null,r[0]=s,r[1]=o):o=r[1];const i=o;let l;r[2]===Symbol.for("react.memo_cache_sentinel")?(l={contextKey:null,detectedUpstream:null,upstreamBranches:[]},r[2]=l):l=r[2];const[a,d]=c.useState(l);let u,f;r[3]!==i||r[4]!==t||r[5]!==s||r[6]!==e?(u=()=>{if(!t||!s||!i)return;let m=!1;return(async()=>{try{const g=await FS(e,s);m||d({contextKey:i,detectedUpstream:g.upstream,upstreamBranches:g.branches})}catch{}})(),()=>{m=!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]),c.useEffect(u,f);let h;return r[9]!==i||r[10]!==a.contextKey||r[11]!==a.detectedUpstream||r[12]!==a.upstreamBranches?(h=a.contextKey===i?{detectedUpstream:a.detectedUpstream,upstreamBranches:a.upstreamBranches}:{detectedUpstream:null,upstreamBranches:[]},r[9]=i,r[10]=a.contextKey,r[11]=a.detectedUpstream,r[12]=a.upstreamBranches,r[13]=h):h=r[13],h}const ov=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:l})=>{const{t:a}=vt(),d=_u(t),u=c.useCallback((Oe,ze)=>a(tn(Oe,d?.provider),ze),[d?.provider,a]),f=IS(),{sourceControl:h}=Ws(),m=mn(Oe=>Oe.entries),{isMobile:g,hasTouchInput:b,screenWidth:v}=Mn(),x=ue(Oe=>Oe.openContextSurface),S=Bb(Oe=>Oe.requestTarget),p=!g&&v>=768&&!Sn(),y=c.useMemo(()=>nv(t,e),[t,e]),w=c.useMemo(()=>mi.get(y)??null,[y]),j=ls(Oe=>Oe.ensureEntry),k=ls(Oe=>Oe.setParams),P=ls(Oe=>Oe.beginActiveContextsLoad),A=ls(Oe=>Oe.commitActiveContexts),F=ls(Oe=>Oe.releaseActiveContexts),D=c.useId(),E=ls(Oe=>Oe.startWatching),T=ls(Oe=>Oe.stopWatching),$=ls(Oe=>Oe.refresh),[O,K]=c.useState(()=>w?.title??pi(e)),[I,X]=c.useState(()=>w?.body??""),[N,C]=c.useState(()=>w?.draft??jc()),[R,H]=c.useState(()=>w?.additionalContext??""),[M,_]=c.useState(()=>{const Oe=typeof w?.targetBaseBranch=="string"?dn(w.targetBaseBranch):"";return Oe||dn(s)}),[B,ee]=c.useState(!1),[ne,re]=c.useState(!1),[te,W]=c.useState(!1),q=Lu(t,h),oe=q.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const Oe=q.scope.runtimeKey,ze=P(Oe,t,D),st=q.contexts.filter(Nt=>_i(m[Ln(Nt)],Nt).connected);return A(Oe,t,D,ze,st),()=>{F(Oe,t,D)}},[P,q.contexts,q.scope.runtimeKey,A,t,F,m,D]);const ce=q.contexts[0]??null,je=mn(Oe=>d?Oe.entries[Ln(d)]?.hasChecked===!0:!1),be=ce?.primaryRemote??null,pe=c.useMemo(()=>ce?Ln(ce):"",[ce]),U=mn(Oe=>Oe.entries[pe]),Pe=ce?_i(U,ce):{authChecked:U?.hasChecked??!1,connected:!1},xe=Pe.authChecked,[Ee,L]=c.useState(0),[ie,G]=c.useState({key:"",status:"loading",capabilities:null}),[ae,ye]=c.useState(!1),{detectedUpstream:ge,upstreamBranches:Se}=rv(t,h,ce);c.useEffect(()=>{if(!ce)return;let Oe=!1;const ze=Ln(ce);return G({key:ze,status:"loading",capabilities:null}),h.capabilities(ce).then(st=>{Oe||G({key:ze,status:"ready",capabilities:st})}).catch(()=>{Oe||G({key:ze,status:"error",capabilities:null})}),()=>{Oe=!0}},[Ee,ce,h]);const ve=ie.key===pe?ie:null,Te=ve?.status==="ready"?ve.capabilities:null;c.useEffect(()=>{ye(!1)},[t]);const he=!!(t&&e&&s&&(e!==s||ge!==null)),se=c.useMemo(()=>ce?$u(ce,e):"",[e,ce]),Re=c.useRef(se);Re.current=se;const Ue=c.useCallback((Oe,ze)=>Oe===Yt()&&ze===Re.current,[]),We=ls(Oe=>Oe.entries[se]),He=c.useMemo(()=>se?[se]:[],[se]);zu(Ku(He));const Be=We?.isLoading??!1,Y=Pe.connected?We?.status??null:null,Me=q.error?u("settings.gitlab.status.operationFailed"):We?.error??null,Ge=We?.isInitialStatusResolved??!1,Ve=c.useMemo(()=>{const Oe=ae?null:be,ze=new Set;for(const It of i){const ts=sv(It,Oe);!ts||ts==="HEAD"||ze.add(ts)}if(ae)for(const It of Se)It&&It!=="HEAD"&&ze.add(It);const st=dn(s);st&&st!=="HEAD"&&ze.add(st);const Nt=dn(M);return Nt&&Nt!=="HEAD"&&ze.add(Nt),Array.from(ze).sort((It,ts)=>It.localeCompare(ts))},[s,i,be,M,Se,ae]);c.useEffect(()=>{const Oe=dn(s);if(!M&&Oe){_(Oe);return}if(Ve.length!==0&&!Ve.includes(M)){const ze=Ve.includes(Oe)?Oe:Ve[0];ze&&_(ze)}},[Ve,s,M]);const dt=c.useRef([]),et=c.useRef(new Map),ct=c.useCallback(Oe=>{const ze=et.current.get(Oe);if(ze?.inFlight)return null;if(ze)return ze.inFlight=!0,ze.key;const st=JS();return et.current.set(Oe,{key:st,inFlight:!0}),st},[]),me=c.useCallback((Oe,ze,st)=>{const Nt=et.current.get(Oe);!Nt||Nt.key!==ze||(st?Nt.inFlight=!1:et.current.delete(Oe))},[]);c.useEffect(()=>{ge&&ye(!0)},[ge]),c.useEffect(()=>{ae&&ge?.defaultBranch&&_(ge.defaultBranch)},[ae,ge?.defaultBranch]);const Ne=Y?.changeRequest??Y?.pr??null,qe=Y?.identity??ce,Ye=c.useMemo(()=>Y?.project??(Y?.repo&&qe?{...Y.repo,...qe,id:`${Y.repo.owner}/${Y.repo.repo}`,name:Y.repo.repo}:null),[Y?.project,Y?.repo,qe]),$e=Ne?.state==="merged"||Ne?.state==="closed",tt=$e?null:Ne,ht=Y?.ci?.summary??Y?.checks??null,[wt,Bt]=c.useState(!1),kt=c.useRef(!0);c.useEffect(()=>(kt.current=!0,()=>{kt.current=!1}),[]);const St=c.useCallback(async Oe=>{await $(se,Oe)},[se,$]),xt=c.useCallback((Oe,ze)=>{dt.current.forEach(st=>{window.clearTimeout(st)}),dt.current=ZS.map(st=>window.setTimeout(()=>{Ue(Oe,ze)&&$(ze,{force:!0,silent:!0,markInitialResolved:!0})},st))},[Ue,$]),Mt=c.useCallback(async(Oe,ze,st)=>{await _S({error:Oe,isCurrent:()=>Ue(ze,st),refresh:()=>$(st,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>xt(ze,st)})},[Ue,$,xt]);c.useEffect(()=>{!ce||!se||(j(se),k(se,{directory:t,branch:e,remoteName:ce.primaryRemote,canShow:he,identity:ce,readContext:ce,sourceControl:h,authChecked:Pe.authChecked,connected:Pe.connected}))},[e,he,t,j,se,ce,h,Pe.authChecked,Pe.connected,k]);const jt=600,$t=c.useCallback(async()=>{if(wt)return;Bt(!0);const Oe=Date.now();try{await St({force:!0})}finally{const ze=jt-(Date.now()-Oe);ze>0&&await new Promise(st=>window.setTimeout(st,ze)),kt.current&&Bt(!1)}},[wt,St]);c.useEffect(()=>{if(!(!ce||!se))return E(se),()=>{T(se)}},[se,ce,E,T]),c.useEffect(()=>{const Oe=mi.get(y)??null;K(Oe?.title??pi(e)),X(Oe?.body??""),C(Oe?.draft??jc()),_(Oe?.targetBaseBranch?dn(Oe.targetBaseBranch):dn(s))},[s,e,y]),c.useEffect(()=>{!ce||!se||!Pe.connected||St({markInitialResolved:!0})},[se,ce,St,Pe.connected]),c.useEffect(()=>{!he||!ce||!Pe.connected||St({force:!0,silent:!0,markInitialResolved:!0})},[he,ce,St,Pe.connected]),c.useEffect(()=>{const Oe=()=>{const st=ls.getState().entries[se]?.lastRefreshAt??0;Date.now()-st>6e4&&St({force:!0,silent:!0})},ze=()=>{document.visibilityState==="visible"&&Oe()};return window.addEventListener("focus",Oe),document.addEventListener("visibilitychange",ze),()=>{window.removeEventListener("focus",Oe),document.removeEventListener("visibilitychange",ze)}},[se,St]),c.useEffect(()=>{xe&&!Pe.connected&&St({force:!0,silent:!0,markInitialResolved:!0})},[St,Pe.connected,xe]),c.useEffect(()=>{!t||!e||mi.set(y,{title:O,body:I,draft:N,additionalContext:R,targetBaseBranch:M})},[y,O,I,N,R,M,t,e]),c.useEffect(()=>()=>{dt.current.forEach(Oe=>{window.clearTimeout(Oe)}),dt.current=[]},[se,oe]),c.useEffect(()=>()=>{et.current.clear()},[]);const Kt=ae&&ge?.defaultBranchSha?ge.defaultBranchSha:ce?`${ce.primaryRemote}/${M}`:M;c.useEffect(()=>{if(!t||!e||!Kt)return;let Oe=!1;return Fb(t,{from:Kt,to:e,maxCount:2}).then(ze=>{const st=ze.all.length===1?ze.all[0]?.message.trim():"";Oe||!st||K(Nt=>Nt===pi(e)?st:Nt)}).catch(()=>{}),()=>{Oe=!0}},[e,Kt,t]);const Wt=!r||o>0,rt=qS(t,e),ut=c.useId(),pt=Oe=>{C(Oe),tv(Oe)},fe=c.useCallback(async()=>{if(!B&&t){ee(!0);try{const ze={base:Kt,head:e,...ce?.provider?{changeRequestProvider:ce.provider}:{}};R&&(ze.context=R);const st=await _b(t,ze);st.title?.trim()&&K(st.title.trim()),st.body?.trim()&&X(st.body.trim()),l?.()}catch(Oe){const ze=Oe instanceof Error?Oe.message:String(Oe);Le.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:ze})}finally{ee(!1)}}},[R,e,Kt,t,B,l,ce,u]),lt=c.useCallback(async()=>{if(Te?.changeRequests!==!0){Le.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const Oe=O.trim();if(!Oe){Le.error(u("gitView.pr.toast.titleRequired"));return}const ze=M.trim();if(!ze){Le.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!ae&&ze===e){Le.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const st=ae?ge:Ye;if(!ce||!st){Le.error(u("gitView.pr.toast.createPrFailed"),{description:Me??u("gitView.pr.statusUnavailable")});return}if(Wt&&(re(!0),!await rt.push())){re(!1);return}const Nt=Yt(),It=se,ts={owner:st.owner,name:st.name},fs=I.trim()?I:void 0,us=ae?void 0:ce.primaryRemote,Ce=ae?ce.primaryRemote:void 0,V=ev(Nt,ce,[ts.owner,ts.name,e,ze,Oe,fs,N,us,Ce]),De=ct(V);if(!De){re(!1);return}re(!0);let _e=!1,Qe=!1;try{const yt={...ce,idempotencyKey:De,target:{project:ts,head:e,base:ze},title:Oe,draft:N};fs!==void 0&&(yt.body=fs),us&&(yt.remote=us),Ce&&(yt.headRemote=Ce);const Dt=await h.changeRequestCreate(yt);if(Qe=!0,me(V,De,!1),!Ue(Nt,It)||(Le.success(u("gitView.pr.toast.prCreated")),await St({force:!0}),!Ue(Nt,It)))return;const zt=ls.getState().entries[It]?.status,Jt=zt?.changeRequest??zt?.pr;Jt&&Jt.number===Dt.target.number&&XS(t,Jt),xt(Nt,It)}catch(yt){const Dt=yt instanceof Error?yt:new Error(String(yt));_e=Lf(Dt);const zt=Dt.message;Le.error(u("gitView.pr.toast.createPrFailed"),{description:zt}),_e&&await Mt(Dt,Nt,It)}finally{Qe||me(V,De,_e),re(!1)}},[ct,I,e,rt,ge,t,N,Me,me,Ue,Wt,se,ce,Mt,St,xt,h,Te?.changeRequests,Ye,M,O,ae,u]),ft="border-0 bg-transparent rounded-none px-4 py-3";if(!he)return n.jsx("section",{className:ft,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(OS,{identity:d??void 0})]})});const mt=Y?.changeRequest&&Y.changeRequest.state==="open"?Y.changeRequest:tt&&Ye&&qe?{...qe,id:`${Ye.owner}/${Ye.name}#${tt.number}`,number:tt.number,project:{...qe,id:Ye.id,owner:Ye.owner,name:Ye.name,url:Ye.url??""},title:tt.title,body:tt.body,url:tt.url,state:tt.state,draft:tt.draft,base:tt.base,head:tt.head,headSha:tt.headSha,mergeable:tt.mergeable,mergeableState:tt.mergeableState}:null;if(mt&&ce)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(zS,{directory:t,context:ce,changeRequest:mt,onChanged:()=>{St({force:!0,silent:!0,markInitialResolved:!0})}})});const Rt=Ye?.url||null,we=ae&&ge?.url?ge.url:Rt,it=ve?.status==="error",Q=!!Y?.connected,le=!!(!ce&&d&&q.status==="ready"&&je),Xe=!!(qe&&xe&&Y?.connected===!1)||le,Ae=qe??d,Je=Ae?Lb(Ae.provider):null,Fe=QS(Y),gt=Fe?`var(--pr-${Fe})`:"var(--status-info)",bt=Fe==="draft"?"git-pr-draft":Fe==="merged"?"git-merge":Fe==="closed"?"git-close-pull-request":"git-pull-request",Et=Ne?[`${Ne.state}${Ne.draft?" (draft)":""}`,Ne.state==="open"&&Ne.mergeable===!1?u("gitView.pr.notMergeable"):null,Ne.state==="open"&&typeof Ne.mergeableState=="string"&&Ne.mergeableState&&Ne.mergeableState!=="unknown"?Ne.mergeableState:null].filter(Boolean).join(" · "):"",Ft=ht?ht.total>0?`${ht.success}/${ht.total} ${u("gitView.pr.checks.label")}`:`${ht.state} ${u("gitView.pr.checks.label")}`:"",es="px-0 py-3 border-b border-border/40 flex flex-col gap-1",Ie="flex flex-col gap-3 py-3",Ze=n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Be||wt,onClick:()=>{$t()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx(Z,{name:Be||wt?"loader-4":"refresh",className:ke("size-4 text-muted-foreground",(Be||wt)&&"animate-spin")})})}),n.jsx(Tt,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),at=te||R.trim().length>0,Lt=Wt?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,Vt=u(Wt?N?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":N?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),Ht=ne||!Q||Te?.changeRequests!==!0||!M.trim()||!ae&&M.trim()===e;return n.jsxs("section",{className:ft,children:[Ne?n.jsxs("div",{className:es,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(Ct,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Cc(Ne.url)},"aria-label":Je?u("gitView.pr.actions.openOnProviderAria",{provider:Je}):u("gitView.header.openPullRequest"),children:[n.jsx(Z,{name:bt,className:"size-4 shrink-0",style:{color:gt}}),Je?u("gitView.pr.actions.openOnProvider",{provider:Je}):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:Aa(qe?.provider,Ne.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Ze})]}),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:gt},children:Et}),ht?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${YS(ht.state)}`}),Ft]}):null,r&&be&&r.split("/")[0]!==be?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",be]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:p&&(ce?.provider==="github"||ce?.provider==="gitlab")?n.jsxs(Ct,{variant:"outline",size:"sm",className:ke("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",AS),onClick:()=>{S(t,{source:{kind:"pr",number:Ne.number,...Ye?{sourceRepo:{owner:Ye.owner,repo:Ye.name}}:{}},context:ce}),x(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:Ie,children:[it?n.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error-border)] 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(Ct,{variant:"outline",size:"sm",onClick:()=>L(Oe=>Oe+1),children:u("settings.sourceControl.transport.retry")})]}):null,Xe&&Je?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:Je})}),n.jsx(Ct,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,Me?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:Me}),q.error?n.jsx(Ct,{variant:"outline",size:"sm",onClick:()=>{q.retry()},disabled:q.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,we?n.jsx(Ct,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:we,target:"_blank",rel:"noopener noreferrer",children:[n.jsx(Z,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(tt||!Ne&&!Ge)&&!Me&&!Xe&&(q.status==="loading"||ce)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[Ne&&$e?n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[n.jsx(Z,{name:Ne.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:gt}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:Ne.state==="merged"?u("gitView.pr.history.merged",{number:Ne.number,base:Ne.base||M}):u("gitView.pr.history.closed",{number:Ne.number})}),n.jsx(Ct,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Cc(Ne.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:Je}),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"}),ae&&ge?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[ge.owner,"/",ge.name]}):null,Ve.length>0?n.jsxs($b,{value:M,onValueChange:_,children:[n.jsx(zb,{className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(Kb,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(Wb,{children:Ve.map(Oe=>n.jsx(Hb,{value:Oe,children:Oe},Oe))})]}):n.jsx(vo,{value:M,onChange:Oe=>_(Oe.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:[we?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:we,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(Tt,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,Ze]})]}),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(vo,{value:O,onChange:Oe=>K(Oe.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:ut,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Ct,{variant:"ghost",size:"xs",className:"rounded-e-none",onClick:fe,disabled:B||ne,children:[B?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(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"xs",className:"rounded-s-none border-s-0 px-1",disabled:B||ne,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(Ps,{align:"end",className:"w-60",children:n.jsxs(qt,{onSelect:()=>W(!0),children:[n.jsx(Z,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),at?n.jsxs("div",{className:"relative",children:[n.jsx(Ul,{value:R,onChange:Oe=>H(Oe.target.value),className:"min-h-[72px] pe-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:te&&!R}),n.jsx(Ct,{variant:"ghost",size:"xs",className:"absolute inset-e-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{H(""),W(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx(Z,{name:"close",className:"size-3.5"})})]}):null,n.jsx(Ul,{id:ut,value:I,onChange:Oe=>X(Oe.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:b?"on":"off",autoCapitalize:b?"sentences":"off",spellCheck:b})]}),Lt?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"}),Lt]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(Ct,{size:"sm",className:"justify-center gap-2 rounded-e-none",onClick:lt,disabled:Ht,children:[ne?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(Z,{name:N?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:Vt})]}),n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{size:"sm",className:"rounded-s-none border-s-0 px-1.5",disabled:ne,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx(Z,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(Ps,{align:"end",className:"w-56",children:n.jsxs(Vb,{value:N?"draft":"ready",onValueChange:Oe=>pt(Oe==="draft"),children:[n.jsx(ql,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(ql,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),rt.dialogs]})]})]})},iv=()=>{const t=Ke.c(100),{t:e}=vt(),{git:s,sourceControl:r}=Ws(),o=vn(),{rootIsGitRepo:i,gitDirectory:l,nestedRepos:a}=Yb(o??null),d=Ba(l??null),u=Xb(l??null),f=Qb(l??null),h=Lu(l,r),{ensureAll:m,ensureNestedRepos:g,selectNestedRepo:b}=gn(Zn(av)),v=nt(lv),x=nt(cv),S=nt(dv),p=nt(uv);let y;t[0]!==o?(y=ot(o),t[0]=o,t[1]=y):y=t[1];const w=y;let j;if(t[2]!==p||t[3]!==w||t[4]!==S){e:{if(!w){j=void 0;break e}let xe;if(t[6]!==p||t[7]!==w){let L;t[9]!==w?(L=ie=>ot(ie.path)===w,t[9]=w,t[10]=L):L=t[10],xe=p.find(L),t[6]=p,t[7]=w,t[8]=xe}else xe=t[8];const Ee=xe;if(Ee){j=Ee;break e}for(const L of S.values())if(ot(L.path)===w){j=L;break e}j=void 0}t[2]=p,t[3]=w,t[4]=S,t[5]=j}else j=t[5];const k=j;let P;t[11]!==v||t[12]!==k||t[13]!==x?.open||t[14]!==S?(P=()=>{if(v)return S.get(v)??k;if(x?.open)return k},t[11]=v,t[12]=k,t[13]=x?.open,t[14]=S,t[15]=P):P=t[15],x?.open;let A;t[16]!==P?(A=P(),t[16]=P,t[17]=A):A=t[17];const F=A;let D;t[18]!==v?(D=xe=>v?xe.getAttachment(v):void 0,t[18]=v,t[19]=D):D=t[19];const E=ju(D),T=E&&!E.degraded&&!E.legacy?E.worktreeRoot??void 0:void 0,$=RS(o,F,d?.current??void 0);let O,K;t[20]!==m||t[21]!==s||t[22]!==l?(O=()=>{!l||!s||m(l,s)},K=[l,m,s],t[20]=m,t[21]=s,t[22]=l,t[23]=O,t[24]=K):(O=t[23],K=t[24]),c.useEffect(O,K);const[I,X]=c.useState(null);let N;t[25]!==T||t[26]!==$?.projectDirectory?(N=()=>{const xe=T||$?.projectDirectory;if(!xe){X(null);return}let Ee=!1;return Wu(xe).then(L=>{if(Ee)return;const ie=L.trim();X(ie&&ie!=="HEAD"?ie:null)}).catch(()=>{Ee||X(null)}),()=>{Ee=!0}},t[25]=T,t[26]=$?.projectDirectory,t[27]=N):N=t[27];const C=$?.projectDirectory;let R;t[28]!==T||t[29]!==C?(R=[T,C],t[28]=T,t[29]=C,t[30]=R):R=t[30],c.useEffect(N,R);let H;e:{if(!u?.all){let Ee;t[31]===Symbol.for("react.memo_cache_sentinel")?(Ee=[],t[31]=Ee):Ee=t[31],H=Ee;break e}let xe;t[32]!==u.all?(xe=u.all.filter(fv).sort(),t[32]=u.all,t[33]=xe):xe=t[33],H=xe}const M=H;let _;e:{if(!u?.all){let Ee;t[34]===Symbol.for("react.memo_cache_sentinel")?(Ee=[],t[34]=Ee):Ee=t[34],_=Ee;break e}let xe;t[35]!==u.all?(xe=u.all.filter(hv).map(pv).sort(),t[35]=u.all,t[36]=xe):xe=t[36],_=xe}const B=_,ee=d?.current??null,ne=h.contexts[0]?.primaryRemote,re=ne?u?.defaultBranches?.[ne]:void 0;let te;t[37]!==h.contexts[0]||t[38]!==h.read?.repository.remotes||t[39]!==ee||t[40]!==re||t[41]!==M||t[42]!==I||t[43]!==$?.createdFromBranch?(te=()=>ug({remoteNames:new Set(h.contexts[0]?.primaryRemote?[h.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(h.read?.repository.remotes.map(mv)??[]),localBranches:M,worktreeCreatedFromBranch:$?.createdFromBranch,rootBranchHint:I,defaultBranch:re,headBranch:ee,fallbackToConventional:!1}),t[37]=h.contexts[0],t[38]=h.read?.repository.remotes,t[39]=ee,t[40]=re,t[41]=M,t[42]=I,t[43]=$?.createdFromBranch,t[44]=te):te=t[44],$?.createdFromBranch;let W;t[45]!==te?(W=te(),t[45]=te,t[46]=W):W=t[46];const q=W,oe=_u(o??null)?.provider;if(!o){let xe;t[47]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=xe):xe=t[47];let Ee;t[48]!==oe||t[49]!==e?(Ee=e(tn("gitView.pullRequest.title",oe)),t[48]=oe,t[49]=e,t[50]=Ee):Ee=t[50];let L;t[51]!==Ee?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ee}),t[51]=Ee,t[52]=L):L=t[52];let ie;t[53]!==oe||t[54]!==e?(ie=e(tn("gitView.pullRequest.createHint",oe)),t[53]=oe,t[54]=e,t[55]=ie):ie=t[55];let G;t[56]!==ie?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ie}),t[56]=ie,t[57]=G):G=t[57];let ae;return t[58]!==L||t[59]!==G?(ae=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[xe,L,G]}),t[58]=L,t[59]=G,t[60]=ae):ae=t[60],ae}if(i===!1&&f!==!0){let xe;t[61]!==o||t[62]!==g?(xe=()=>{g(o,{force:!0})},t[61]=o,t[62]=g,t[63]=xe):xe=t[63];let Ee;return t[64]!==o||t[65]!==f||t[66]!==a||t[67]!==i||t[68]!==xe?(Ee=n.jsx(fg,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:f,nestedRepos:a,onRetryDiscovery:xe}),t[64]=o,t[65]=f,t[66]=a,t[67]=i,t[68]=xe,t[69]=Ee):Ee=t[69],Ee}if(!ee){let xe;t[70]===Symbol.for("react.memo_cache_sentinel")?(xe=n.jsx(Z,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=xe):xe=t[70];let Ee;t[71]!==oe||t[72]!==e?(Ee=e(tn("gitView.pullRequest.title",oe)),t[71]=oe,t[72]=e,t[73]=Ee):Ee=t[73];let L;t[74]!==Ee?(L=n.jsx("div",{className:"typography-ui-header text-foreground",children:Ee}),t[74]=Ee,t[75]=L):L=t[75];let ie;t[76]!==oe||t[77]!==e?(ie=e(tn("gitView.pullRequest.createHint",oe)),t[76]=oe,t[77]=e,t[78]=ie):ie=t[78];let G;t[79]!==ie?(G=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ie}),t[79]=ie,t[80]=G):G=t[80];let ae;return t[81]!==L||t[82]!==G?(ae=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[xe,L,G]}),t[81]=L,t[82]=G,t[83]=ae):ae=t[83],ae}const de=i===!1&&Array.isArray(a)&&a.length>0;let ce;t[84]!==o||t[85]!==l||t[86]!==a||t[87]!==b||t[88]!==de?(ce=de?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(hg,{repositories:a,selectedRepository:l??null,onSelectRepository:xe=>{o&&b(o,xe)},repositoryRoot:o??void 0})}):null,t[84]=o,t[85]=l,t[86]=a,t[87]=b,t[88]=de,t[89]=ce):ce=t[89];const je=l??o,be=d?.tracking??void 0,pe=d?.ahead??0;let U;t[90]!==q||t[91]!==ee||t[92]!==B||t[93]!==je||t[94]!==be||t[95]!==pe?(U=n.jsx(Er,{as:Zb,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(ov,{directory:je,branch:ee,baseBranch:q,trackingBranch:be,ahead:pe,remoteBranches:B})}),t[90]=q,t[91]=ee,t[92]=B,t[93]=je,t[94]=be,t[95]=pe,t[96]=U):U=t[96];let Pe;return t[97]!==ce||t[98]!==U?(Pe=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ce,U]}),t[97]=ce,t[98]=U,t[99]=Pe):Pe=t[99],Pe};function av(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function lv(t){return t.currentSessionId}function cv(t){return t.newSessionDraft}function dv(t){return t.worktreeMetadata}function uv(t){return t.availableWorktrees}function fv(t){return!t.startsWith("remotes/")}function hv(t){return t.startsWith("remotes/")}function pv(t){return t.replace(/^remotes\//,"")}function mv(t){return t.name}const Po=new Map,gv=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},bv=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},yv=(t,e)=>{if(e.length===0)return Po;const s=new Set(e),r=new Map,o=new Map;for(const i of t)for(const l of i.session){if(!s.has(l.id))continue;const a=l.title?.trim();if(!a)continue;const d=bv(l),u=r.get(l.id);u!==void 0&&u>d||(r.set(l.id,d),o.set(l.id,a))}return o.size===0?Po:o},Za=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Pc=60,xv=t=>{try{return new URL(t).origin}catch{return""}},gi=new Set,zf=Br()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=xv(s);!i||!r||e().byOrigin[i]||gi.has(i)||(gi.add(i),Fn("desktop_browser_fetch_favicon",{url:r,webContentsId:o}).then(l=>{const a=typeof l?.dataUrl=="string"?l.dataUrl:"";a&&t(d=>{const u={...d.byOrigin,[i]:a},f=Object.keys(u);if(f.length<=Pc)return{byOrigin:u};for(const h of f.slice(0,f.length-Pc))delete u[h];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{gi.delete(i)}))}})),Ja=t=>t,Qi=t=>{const e=Ja(t).type;return typeof e=="string"?e:""},Sv=t=>{const e=Ja(t).tool;return typeof e=="string"?e:""},vv=t=>{const e=Ja(t).text;return typeof e=="string"?e:""},wv=t=>{const e=Qi(t);return e==="tool"?Sv(t).trim().toLowerCase()||"tool":e||"unknown"},kv=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=wv(s);e.includes(r)||e.push(r)}return e.join(" + ")},jv=t=>t.replace(/\s+/g," ").trim(),Cv=t=>{for(const s of t)if(Qi(s)==="text"){const r=jv(vv(s));if(r.length===0)continue;return r}const e=t.filter(s=>Qi(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Pv=(t,e,s)=>`${s(t)} / ${s(e)}`,Ev=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Nv=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Ev(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}})},Zi={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},oo={user:0,assistant:0,tool:0,other:0},un=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Ec=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{...Zi,total:un(s)};if(!s||typeof s!="object")return Zi;const r=s,o=un(r.input),i=un(r.output),l=un(r.reasoning),a=un(r.cache?.read),d=un(r.cache?.write),u=un(r.total);return{input:o,output:i,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:o+i+l+a+d}},Rv=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Ns=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+Ns(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+Ns(s),0):0,Dv=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...oo,assistant:Ns(s.text)+Ns(s.content)};const o=Rv(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Ns(s.input)+Ns(s.output)+Ns(s.error)+Ns(s.call?.input)+Ns(s.call?.output)+Ns(s.call?.error)+Ns(s.raw)+Math.round(Ns(s.metadata)*.25)+Math.round(Ns(s.state)*.1)+Math.round((tm(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}},Nc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),Iv=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Tv=(t,e)=>{if(t.length===0)return{...oo};const s=t.reduce((r,o)=>{const i=Iv(o);let l={...oo};for(const a of o.parts)l=Nc(l,Dv(a,i));return Nc(r,l)},{...oo});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)}},Nn=t=>t.toLocaleString(Vu()),Mv=(t,e)=>!t||!Number.isFinite(t)?"-":sy(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Av=(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}},Ov=()=>{const t=Ke.c(219),{t:e}=vt(),s=pg(),r=ue(Bv);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={},t[0]=o):o=t[0];const[i,l]=c.useState(o),[a,d]=c.useState(null),u=c.useRef(null),f=nt(Fv),h=nt(_v),m=Jb(h??void 0),g=ey(f??"",h??void 0),b=ns(Lv);let v;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),l($v),d(null)},t[1]=v):v=t[1];let x;t[2]!==h||t[3]!==f?(x=[h,f],t[2]=h,t[3]=f,t[4]=x):x=t[4],c.useEffect(v,x);let S,p;t[5]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},p=[],t[5]=S,t[6]=p):(S=t[5],p=t[6]),c.useEffect(S,p);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=async(Je,Fe)=>{(await Wo(Fe)).ok?(d(Je),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(bt=>bt===Je?null:bt),u.current=null},2e3)):d(null)},t[7]=y):y=t[7];const w=y;let j;t[8]!==f||t[9]!==m?(j=f?m.find(Je=>Je.id===f)??null:null,t[8]=f,t[9]=m,t[10]=j):j=t[10];const k=j;let P,A,F,D,E,T,$;if(t[11]!==g){P=g.filter(zv),$=g.filter(Kv);const Je=Hu(g.map(Wv));F=Je?g[Je.index]??null:null,D=Je?.state==="compacted";let Fe;t[19]!==F?(T=F?Ec(F):Zi,Fe=ty({input:T.input,cache:{read:T.cacheRead,write:T.cacheWrite}}),t[19]=F,t[20]=Fe,t[21]=T):(Fe=t[20],T=t[21]),A=Fe,E=P.reduce(Hv,0),t[11]=g,t[12]=P,t[13]=A,t[14]=F,t[15]=D,t[16]=E,t[17]=T,t[18]=$}else P=t[12],A=t[13],F=t[14],D=t[15],E=t[16],T=t[17],$=t[18];const O=E,K=F?.info??null,I=b,X=K?.providerID||"",N=K?.modelID||"";let C;t[22]!==N||t[23]!==I||t[24]!==X?(C=Av(I,X,N),t[22]=N,t[23]=I,t[24]=X,t[25]=C):C=t[25];const R=C,H=R.contextLimit,M=D?null:H&&H>0?Math.min(999,T.total/H*100):0;let _;if(t[26]!==g){const Je=[...g].reverse().find(Vv),Fe=Je?.info.role==="system"?Je.info.text:"";_=Tv(g,Fe),t[26]=g,t[27]=_}else _=t[27];const B=_,ee=B.user,ne=B.assistant,re=B.tool,te=Math.max(0,T.input-ee-ne-re),W=ee+ne+re+te,q=g[0]?.info?.time?.created,oe=g.length>0?g[g.length-1]?.info?.time?.created:null;let de;t[28]!==k?.title||t[29]!==e?(de=k?.title||e("contextSidebar.session.untitled"),t[28]=k?.title,t[29]=e,t[30]=de):de=t[30];const ce=k?.time?.created??q??null,je=oe??k?.time?.created??null;let be;t[31]!==ne||t[32]!==te||t[33]!==re||t[34]!==ee?(be={user:ee,assistant:ne,tool:re,other:te},t[31]=ne,t[32]=te,t[33]=re,t[34]=ee,t[35]=be):be=t[35];let pe;t[36]!==P.length||t[37]!==W||t[38]!==A||t[39]!==H||t[40]!==R||t[41]!==g.length||t[42]!==de||t[43]!==ce||t[44]!==je||t[45]!==be||t[46]!==T||t[47]!==O||t[48]!==M||t[49]!==$.length?(pe={sessionTitle:de,messagesCount:g.length,userMessagesCount:$.length,assistantMessagesCount:P.length,createdAt:ce,lastActivityAt:je,providerModel:R,tokenBreakdown:T,usagePercent:M,cacheHitRate:A,totalAssistantCost:O,contextLimit:H,breakdown:be,breakdownTotal:W},t[36]=P.length,t[37]=W,t[38]=A,t[39]=H,t[40]=R,t[41]=g.length,t[42]=de,t[43]=ce,t[44]=je,t[45]=be,t[46]=T,t[47]=O,t[48]=M,t[49]=$.length,t[50]=pe):pe=t[50];const U=pe;if(!f){let Je;t[51]!==e?(Je=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Je):Je=t[52];let Fe;return t[53]!==Je?(Fe=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Je}),t[53]=Je,t[54]=Fe):Fe=t[54],Fe}let Pe;t[55]!==e?(Pe=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=Pe):Pe=t[56];let xe;t[57]!==Pe||t[58]!==U.breakdown.user?(xe={key:"user",label:Pe,value:U.breakdown.user,color:"var(--status-success)"},t[57]=Pe,t[58]=U.breakdown.user,t[59]=xe):xe=t[59];let Ee;t[60]!==e?(Ee=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=Ee):Ee=t[61];let L;t[62]!==Ee||t[63]!==U.breakdown.assistant?(L={key:"assistant",label:Ee,value:U.breakdown.assistant,color:"var(--primary-base)"},t[62]=Ee,t[63]=U.breakdown.assistant,t[64]=L):L=t[64];let ie;t[65]!==e?(ie=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ie):ie=t[66];let G;t[67]!==ie||t[68]!==U.breakdown.tool?(G={key:"tool",label:ie,value:U.breakdown.tool,color:"var(--status-warning)"},t[67]=ie,t[68]=U.breakdown.tool,t[69]=G):G=t[69];let ae;t[70]!==e?(ae=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=ae):ae=t[71];let ye;t[72]!==ae||t[73]!==U.breakdown.other?(ye={key:"other",label:ae,value:U.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=ae,t[73]=U.breakdown.other,t[74]=ye):ye=t[74];let ge;t[75]!==xe||t[76]!==L||t[77]!==G||t[78]!==ye?(ge=[xe,L,G,ye],t[75]=xe,t[76]=L,t[77]=G,t[78]=ye,t[79]=ge):ge=t[79];const Se=ge;let ve;t[80]!==s||t[81]!==U.sessionTitle?(ve=s?n.jsx(mg,{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:U.sessionTitle,children:U.sessionTitle})})}):null,t[80]=s,t[81]=U.sessionTitle,t[82]=ve):ve=t[82];let Te;t[83]!==s||t[84]!==U.sessionTitle?(Te=s?null:n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate oc-ui-start-align",children:U.sessionTitle}),t[83]=s,t[84]=U.sessionTitle,t[85]=Te):Te=t[85];const z=!s&&"mt-1";let he;t[86]!==z?(he=ke(z,"flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70"),t[86]=z,t[87]=he):he=t[87];let se;t[88]!==U.providerModel.modelName||t[89]!==U.providerModel.providerName?(se=n.jsxs("span",{children:[U.providerModel.providerName," / ",U.providerModel.modelName]}),t[88]=U.providerModel.modelName,t[89]=U.providerModel.providerName,t[90]=se):se=t[90];let Re;t[91]!==r||t[92]!==U.createdAt?(Re=U.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:Mv(U.createdAt,r)})]}),t[91]=r,t[92]=U.createdAt,t[93]=Re):Re=t[93];let Ue;t[94]!==he||t[95]!==se||t[96]!==Re?(Ue=n.jsxs("div",{className:he,children:[se,Re]}),t[94]=he,t[95]=se,t[96]=Re,t[97]=Ue):Ue=t[97];let We;t[98]!==Te||t[99]!==Ue?(We=n.jsxs("div",{className:"mb-6",children:[Te,Ue]}),t[98]=Te,t[99]=Ue,t[100]=We):We=t[100];let He;t[101]!==e?(He=e("contextSidebar.section.context"),t[101]=e,t[102]=He):He=t[102];let Be;t[103]!==He?(Be=n.jsx("span",{className:"typography-micro text-muted-foreground",children:He}),t[103]=He,t[104]=Be):Be=t[104];let Y;t[105]!==U.tokenBreakdown.total||t[106]!==U.usagePercent?(Y=U.usagePercent===null?"—":Nn(U.tokenBreakdown.total),t[105]=U.tokenBreakdown.total,t[106]=U.usagePercent,t[107]=Y):Y=t[107];let Me;t[108]!==U.contextLimit?(Me=U.contextLimit?` / ${Nn(U.contextLimit)}`:"",t[108]=U.contextLimit,t[109]=Me):Me=t[109];let Ge;t[110]!==Y||t[111]!==Me?(Ge=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Y,Me]}),t[110]=Y,t[111]=Me,t[112]=Ge):Ge=t[112];let Ve;t[113]!==Be||t[114]!==Ge?(Ve=n.jsxs("div",{className:"flex items-baseline justify-between",children:[Be,Ge]}),t[113]=Be,t[114]=Ge,t[115]=Ve):Ve=t[115];let dt;t[116]!==U.usagePercent?(dt=U.usagePercent!==null&&U.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,U.usagePercent)}%`,backgroundColor:U.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[116]=U.usagePercent,t[117]=dt):dt=t[117];let et;t[118]!==dt?(et=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:dt}),t[118]=dt,t[119]=et):et=t[119];let ct;t[120]!==e||t[121]!==U.usagePercent?(ct=U.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:U.usagePercent.toFixed(1)}),t[120]=e,t[121]=U.usagePercent,t[122]=ct):ct=t[122];let me;t[123]!==ct?(me=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:ct}),t[123]=ct,t[124]=me):me=t[124];let Ne;t[125]!==Ve||t[126]!==et||t[127]!==me?(Ne=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ve,et,me]}),t[125]=Ve,t[126]=et,t[127]=me,t[128]=Ne):Ne=t[128];let qe;t[129]!==e?(qe=e("contextSidebar.stats.messages"),t[129]=e,t[130]=qe):qe=t[130];let Ye;t[131]!==U.messagesCount?(Ye=Nn(U.messagesCount),t[131]=U.messagesCount,t[132]=Ye):Ye=t[132];let $e;t[133]!==qe||t[134]!==Ye?($e={label:qe,value:Ye},t[133]=qe,t[134]=Ye,t[135]=$e):$e=t[135];let tt;t[136]!==e?(tt=e("contextSidebar.stats.user"),t[136]=e,t[137]=tt):tt=t[137];let ht;t[138]!==U.userMessagesCount?(ht=Nn(U.userMessagesCount),t[138]=U.userMessagesCount,t[139]=ht):ht=t[139];let wt;t[140]!==tt||t[141]!==ht?(wt={label:tt,value:ht},t[140]=tt,t[141]=ht,t[142]=wt):wt=t[142];let Bt;t[143]!==e?(Bt=e("contextSidebar.stats.assistant"),t[143]=e,t[144]=Bt):Bt=t[144];let kt;t[145]!==U.assistantMessagesCount?(kt=Nn(U.assistantMessagesCount),t[145]=U.assistantMessagesCount,t[146]=kt):kt=t[146];let St;t[147]!==Bt||t[148]!==kt?(St={label:Bt,value:kt},t[147]=Bt,t[148]=kt,t[149]=St):St=t[149];let xt;t[150]!==e?(xt=e("contextSidebar.stats.cost"),t[150]=e,t[151]=xt):xt=t[151];let Mt;t[152]!==U.totalAssistantCost?(Mt=Ef(U.totalAssistantCost),t[152]=U.totalAssistantCost,t[153]=Mt):Mt=t[153];let jt;t[154]!==xt||t[155]!==Mt?(jt={label:xt,value:Mt},t[154]=xt,t[155]=Mt,t[156]=jt):jt=t[156];let $t;t[157]!==$e||t[158]!==wt||t[159]!==St||t[160]!==jt?($t=[$e,wt,St,jt],t[157]=$e,t[158]=wt,t[159]=St,t[160]=jt,t[161]=$t):$t=t[161];const Kt=$t;let Wt;t[162]!==Kt?(Wt=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:Kt.map(Gv)}),t[162]=Kt,t[163]=Wt):Wt=t[163];let rt;t[164]!==e?(rt=e("contextSidebar.section.lastAssistantMessage"),t[164]=e,t[165]=rt):rt=t[165];let ut;t[166]!==rt?(ut=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:rt}),t[166]=rt,t[167]=ut):ut=t[167];let pt;t[168]!==e||t[169]!==U.cacheHitRate.hasInput||t[170]!==U.cacheHitRate.percent||t[171]!==U.tokenBreakdown.cacheRead||t[172]!==U.tokenBreakdown.cacheWrite||t[173]!==U.tokenBreakdown.input||t[174]!==U.tokenBreakdown.output||t[175]!==U.tokenBreakdown.reasoning?(pt=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:U.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:U.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:U.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:U.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:U.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:U.cacheHitRate.hasInput?U.cacheHitRate.percent:null,format:"percent"}].map(Uv)}),t[168]=e,t[169]=U.cacheHitRate.hasInput,t[170]=U.cacheHitRate.percent,t[171]=U.tokenBreakdown.cacheRead,t[172]=U.tokenBreakdown.cacheWrite,t[173]=U.tokenBreakdown.input,t[174]=U.tokenBreakdown.output,t[175]=U.tokenBreakdown.reasoning,t[176]=pt):pt=t[176];let fe;t[177]!==ut||t[178]!==pt?(fe=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[ut,pt]}),t[177]=ut,t[178]=pt,t[179]=fe):fe=t[179];let lt;t[180]!==Se||t[181]!==U.breakdownTotal?(lt=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Se.map(Je=>Je.value<=0||U.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${Je.value/U.breakdownTotal*100}%`,backgroundColor:Je.color}},Je.key))}),t[180]=Se,t[181]=U.breakdownTotal,t[182]=lt):lt=t[182];let ft;t[183]!==Se||t[184]!==U.breakdownTotal?(ft=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:Se.map(Je=>{const Fe=U.breakdownTotal>0?Je.value/U.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:Je.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Je.label," ",n.jsxs("span",{className:"tabular-nums",children:[Fe.toFixed(0),"%"]})]})]},Je.key)})}),t[183]=Se,t[184]=U.breakdownTotal,t[185]=ft):ft=t[185];let mt;t[186]!==lt||t[187]!==ft?(mt=n.jsxs("div",{className:"mb-6",children:[lt,ft]}),t[186]=lt,t[187]=ft,t[188]=mt):mt=t[188];let Rt;t[189]!==e?(Rt=e("contextSidebar.section.rawMessages"),t[189]=e,t[190]=Rt):Rt=t[190];let we;t[191]!==Rt?(we=n.jsx("div",{className:"typography-micro text-muted-foreground",children:Rt}),t[191]=Rt,t[192]=we):we=t[192];let it;if(t[193]!==a||t[194]!==i||t[195]!==g||t[196]!==e||t[197]!==r){let Je;t[199]!==a||t[200]!==i||t[201]!==e||t[202]!==r?(Je=Fe=>{const gt=Fe.info.role,bt=gt==="assistant",Et=gt==="user",Ft=i[Fe.info.id]===!0,es=a===Fe.info.id,Ie=Fe.info.time?.created??null,Ze=kv(Fe.parts),at=bt?Ec({info:Fe.info,parts:Fe.parts}):null,Lt=Et?Cv(Fe.parts):"",Vt=Nv(Ie,r),Ht=Ze||"—",Oe=at?Pv(at.input,at.output,Nn):"",ze=gt||"unknown",st=Ze?`${ze}: ${Ze}`:ze,Nt=Ft?JSON.stringify({info:Fe.info,parts:Fe.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":Ft,onClick:()=>{l(It=>({...It,[Fe.info.id]:It[Fe.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:bt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Et?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Lt]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:bt?Ht:st}),bt&&n.jsx("span",{className:"text-end text-muted-foreground tabular-nums",children:Oe})]}),n.jsx("span",{className:"text-end text-muted-foreground",children:Vt})]})}),Ft&&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:It=>{It.stopPropagation(),w(Fe.info.id,Nt)},"aria-label":e(es?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(es?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:es?n.jsx(Z,{name:"check",className:"size-3.5"}):n.jsx(Z,{name:"file-copy",className:"size-3.5"})})}),n.jsx(ny,{language:"json",code:Nt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Fe.info.id)},t[199]=a,t[200]=i,t[201]=e,t[202]=r,t[203]=Je):Je=t[203],it=[...g].reverse().map(Je),t[193]=a,t[194]=i,t[195]=g,t[196]=e,t[197]=r,t[198]=it}else it=t[198];let Q;t[204]!==it?(Q=n.jsx("div",{className:"mt-2.5 space-y-1",children:it}),t[204]=it,t[205]=Q):Q=t[205];let le;t[206]!==we||t[207]!==Q?(le=n.jsxs("div",{children:[we,Q]}),t[206]=we,t[207]=Q,t[208]=le):le=t[208];let Xe;t[209]!==We||t[210]!==Ne||t[211]!==Wt||t[212]!==fe||t[213]!==mt||t[214]!==le?(Xe=n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[We,Ne,Wt,fe,mt,le]}),t[209]=We,t[210]=Ne,t[211]=Wt,t[212]=fe,t[213]=mt,t[214]=le,t[215]=Xe):Xe=t[215];let Ae;return t[216]!==ve||t[217]!==Xe?(Ae=n.jsxs(Er,{outerClassName:"h-full",className:"bg-background",children:[ve,Xe]}),t[216]=ve,t[217]=Xe,t[218]=Ae):Ae=t[218],Ae};function Bv(t){return t.timeFormatPreference}function Fv(t){return t.currentSessionId}function _v(t){return t.currentSessionDirectory}function Lv(t){return t.providers}function $v(t){return Object.keys(t).length>0?{}:t}function zv(t){return t.info.role==="assistant"}function Kv(t){return t.info.role==="user"}function Wv(t){return t.info}function Hv(t,e){const s=un(e.info.cost);return t+s}function Vv(t){return t.info.role==="system"}function Gv(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 Uv(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)}%`:Nn(t.value):"—"})]},t.label)}const Kf=(t,e,s,r=t.currentTarget)=>{t.key!=="Escape"||!e||t.target instanceof Node&&!(r??t.currentTarget).contains(t.target)||ry(t.target)||oy(t.target)||t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),s())},qv=280,Yv=.28,Xv=240,Qv=.35,Zv=(t,e,s=null)=>{const r=t.left+t.width,o=e.left+e.width,i=e.top+e.height,l=s?s.top:i-Math.min(Xv,e.height*Qv),a=Math.min(qv,t.width*Yv,e.width/4),d=e.left-t.left>=1,u=r-o>=1,f=Math.max(0,l-t.top),h=d?e.left:t.left+a,m=u?o:r-a;return{left:{left:t.left,top:t.top,width:h-t.left,height:d?t.height:f},right:{left:m,top:t.top,width:r-m,height:u?t.height:f},bottom:{left:e.left,top:l,width:e.width,height:Math.max(0,i-l)}}},bi=(t,e)=>e.x>=t.left&&e.x<t.left+t.width&&e.y>=t.top&&e.y<t.top+t.height,Jv=(t,e)=>bi(t.bottom,e)?"bottom":bi(t.left,e)?"left":bi(t.right,e)?"right":null,on=Br(()=>({drag:null,hovered:null})),io=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},yi=t=>({left:t.left+6,top:t.top,width:Math.max(0,t.width-12),height:Math.max(0,t.height-8)}),xi=t=>io(document.querySelector(`[data-context-zone="${t}"][data-context-panel-open="true"] [data-zone-card]`)),Wf=t=>{const e=io(document.querySelector("[data-workspace-row]")),s=io(document.querySelector("[data-workspace-chat]"));if(!e||!s)return!1;const r=document.querySelector('[data-context-zone="bottom"][data-context-panel-open="true"]'),o=Zv(e,s,io(r)),i={left:xi("left")??yi(o.left),right:xi("right")??yi(o.right),bottom:xi("bottom")??yi(o.bottom)};return on.setState({drag:{...t,targets:o,frames:i},hovered:null}),!0},Hf=t=>{const{drag:e,hovered:s}=on.getState();if(!e)return;const r=Jv(e.targets,t);r!==s&&on.setState({hovered:r})},Ji=()=>{on.getState().drag&&on.setState({drag:null,hovered:null})},Vf=t=>{const{drag:e,hovered:s}=on.getState();if(on.setState({drag:null,hovered:null}),!e||!s)return!1;const r=ue.getState();s!==e.from&&r.moveContextSurfaceToZone(e.mode,s);const o=t?vs(t):"";if(o){const i=ue.getState();Sa(i.contextPanelByDirectory[o],i.contextSurfaceZones).has(e.mode)||i.openContextSurface(o,e.mode)}return!0},el=(t,e)=>{let s=!1;const r=i=>{const l={x:i.clientX,y:i.clientY};e(l)?(s||(s=Wf(t)),s&&Hf(l)):s&&(Ji(),s=!1)};window.addEventListener("pointermove",r);const o=()=>window.removeEventListener("pointermove",r);return{finish:i=>(o(),s?(Vf(i),!0):!1),cancel:()=>{o(),s&&Ji()}}},Rc={left:null,right:null,bottom:null},wr=Br(()=>({body:Rc,headerSlot:Rc})),Gf=(t,e,s)=>{const r=wr.getState()[t];r[e]!==s&&wr.setState({[t]:{...r,[e]:s}})},ew=(t,e)=>Gf("body",t,e),tw=(t,e)=>Gf("headerSlot",t,e),ao=t=>{const e=c.useRef(t);e.current=t;const[s,r]=c.useState(t),o=c.useCallback(()=>r(e.current),[]);return c.useLayoutEffect(()=>{Ma(o)},[t,o]),c.useEffect(()=>()=>Gu(o),[o]),t||s},sw=nr(()=>ss(()=>import("./GitView-WL1wkRFF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124])).then(t=>({default:t.GitView}))),nw=nr(()=>ss(()=>import("./PlanView-j0hLJmto.js"),__vite__mapDeps([125,1,2,3,4,5,6,7,8,126,29,30,31,32,33,34,28,35,36,37,38,127,128,129,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,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,119,84,130,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104])).then(t=>({default:t.PlanView}))),Uf=320,qf=600,Yf=400,rw=100,ow=24,iw=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},Dc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Uf,Math.round(t))):qf,aw=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Uf,t-Yf),lw=(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},lo=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Yn(t)?Ia.getState().guests.find(r=>r.id===bo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),cw=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},dw=(t,e,s)=>{if(t.mode==="chat"){const r=Za(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"?_o(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?cw(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):lo(t.mode,s)},uw=t=>{const e=Ke.c(8),{mode:s}=t,r=_a();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,l=i?.icon??ly,a=i?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=n.jsx(sr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(Fa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(au,{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:"github",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==="plan")return n.jsx(Z,{name:"file-text",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")return n.jsx(Z,{name:"chat-4",className:"h-3.5 w-3.5"});if(Yn(t.mode))return n.jsx(uw,{mode:t.mode});if(t.mode==="browser"){const s=fw(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"})}},fw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},hw=t=>{const e=Nr(),s=c.useRef(Po),r=c.useRef(t);r.current=t;const o=t.length>0;return c.useSyncExternalStore(c.useCallback(i=>o?e.subscribeAllSelected(l=>l.session,i):()=>{},[e,o]),c.useCallback(()=>{const i=Array.from(e.children.values(),a=>a.getState()),l=yv(i,r.current);return gv(s.current,l)?s.current:(s.current=l,l)},[e]),()=>Po)},pw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,mw=8,gw='button, a, input, textarea, select, label, [role="button"], [role="tab"], [role="combobox"], [role="switch"], [role="slider"], [data-sortable-tab-id], [contenteditable="true"]',bw=t=>t==="context"||t==="git"||t==="pr"||t==="notes"||t==="plan",Xf=320,Qf=160,Zf=200,yw={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"}},Tc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Qf,Math.round(t))):Xf,xw=t=>t===null?Number.POSITIVE_INFINITY:Math.max(Qf,t-Zf),Si=({zone:t="right"})=>{const e=yw[t],s=Da(),r=e.axis==="y",{t:o,direction:i}=vt(),l=i==="rtl",a=vn()??"",d=Uu(a||null),u=c.useCallback((we,it)=>o(tn(we,d),it),[d,o]),f=c.useMemo(()=>iw(a),[a]),h=ue(we=>f?we.contextPanelByDirectory[f]:void 0),m=ue(we=>we.contextSurfaceZones),g=ue(we=>we.closeContextZone),b=ue(we=>we.closeContextPanelTab),v=ue(we=>we.pinContextPanelTab),x=ue(we=>we.toggleContextPanelExpanded),S=ue(we=>we.setContextPanelWidth),p=ue(we=>we.setContextPanelHeight),y=ue(we=>we.setActiveContextPanelTab),w=ue(we=>we.reorderContextPanelTabs),j=ue(we=>we.contextEditorTreeVisible),k=ue(we=>we.contextEditorTreeWidth),P=ue(we=>we.setContextEditorTreeWidth),A=ue(we=>we.toggleContextEditorTree),F=ue(we=>we.contextEditorVisible),D=ue(we=>we.toggleContextEditor),E=ue(we=>we.fileTreeSide),T=ue(we=>we.openNewContextBrowserTab),$=zf(we=>we.byOrigin),[O,K]=c.useState(null),I=c.useCallback(we=>{K(we),tw(t,we)},[t]),X=c.useCallback(we=>{ew(t,we)},[t]),N=c.useMemo(()=>h?.tabs??[],[h?.tabs]),C=h?go(h,m,t):null,R=h?Fo(h,t):sm,H=Li(we=>we.workStatusReserved),M=Li(we=>we.chatCovered),_=t==="bottom"&&M,B=!!(R.isOpen&&C)&&!_,ee=c.useMemo(()=>N.some(we=>we.mode==="file"&&we.targetPath),[N]),ne=ee&&(F||!j),re=C?.mode??null,te=!r&&re==="file"&&!ne,W=!!(B&&R.expanded&&!te),q=re?r?h?.heightByMode?.[re]:h?.widthByMode?.[re]:void 0,oe=te?k:r?Tc(q??Xf,Number.POSITIVE_INFINITY):Dc(q??(re?$i(re):qf),Number.POSITIVE_INFINITY),de=c.useCallback((we,it)=>r?Tc(we,xw(it)):Dc(we,aw(it)),[r]),ce=r?Zf:Yf,je=t==="right"?"left":t==="left"?"right":null,be=ue(we=>{if(!je||!f)return 0;const it=we.contextPanelByDirectory[f],Q=it&&pr(it,we.contextSurfaceZones,je)?go(it,we.contextSurfaceZones,je):null;if(!it||!Q)return 0;const le=it.tabs.some(Xe=>Xe.mode==="file"&&Xe.targetPath)&&(we.contextEditorVisible||!we.contextEditorTreeVisible);return Q.mode==="file"&&!le?we.contextEditorTreeWidth:it.widthByMode[Q.mode]??$i(Q.mode)}),pe=je==="right"&&H&&!M&&be===0?Yl:be,[U,Pe]=c.useState(null),xe=c.useRef(null),Ee=c.useRef(pe);Ee.current=pe;const L=c.useRef(()=>!1);L.current=we=>W||!te&&we-Ee.current-ce<oe;const ie=c.useCallback(()=>{const we=xe.current;Pe(we!==null&&L.current(we)?we:null)},[]),G=U!==null?U-pe:null,ae=t==="left"?U:G,ye=te?oe:de(oe,G),ge=B&&C?.mode==="chat",Se=c.useMemo(()=>{const we=[];if(!ge)return we;for(const it of N){if(it.mode!=="chat")continue;const Q=Za(it.dedupeKey);Q&&!we.includes(Q)&&we.push(Q)}return we},[ge,N]),ve=hw(Se),[Te,z]=c.useState(!1),he=c.useRef(0),se=c.useRef(ye),Re=c.useRef(null),Ue=c.useRef(null),We=c.useRef(null),He=c.useRef(!1);c.useLayoutEffect(()=>{const we=r?We.current?.parentElement:We.current?.closest("[data-workspace-row]");if(!we||typeof ResizeObserver>"u")return;const it=new ResizeObserver(Q=>{const le=Q[Q.length-1]?.contentRect,Xe=r?le?.height:le?.width;xe.current=Xe?Math.round(Xe):null,Ma(ie)});return it.observe(we),xe.current=(r?we.clientHeight:we.clientWidth)||null,ie(),()=>{it.disconnect(),Gu(ie)}},[ie,r]),c.useLayoutEffect(()=>{ie()},[ie,oe,W,pe]),c.useEffect(()=>{if(!B||He.current){He.current=B;return}const we=window.requestAnimationFrame(()=>{We.current?.focus({preventScroll:!0})});return He.current=!0,()=>window.cancelAnimationFrame(we)},[B]);const Be=c.useRef(null),Y=c.useRef(null),Me=c.useCallback(()=>{Y.current=null;const we=We.current,it=Re.current;!we||it===null||we.style.setProperty(e.sizeVariable,`${it}px`)},[e.sizeVariable]);c.useEffect(()=>()=>{Y.current!==null&&clearTimeout(Y.current)},[]);const Ge=c.useCallback(we=>{const it=Be.current,Q=te?Ii(we):de(we,it);return it===null?Q:Math.min(Q,Math.max(1,it))},[de,te]),Ve=c.useCallback(we=>{if(!B||W||!f)return;Ue.current=we.pointerId,z(!0),he.current=r?we.clientY:we.clientX,se.current=ye,Re.current=ye;const it=r?We.current?.parentElement?.clientHeight:(We.current?.closest("[data-workspace-row]")?.clientWidth??0)-Ee.current;Be.current=it&&it>0?it:null,document.documentElement.style.cursor=r?"row-resize":"col-resize",we.preventDefault()},[f,W,B,r,ye]),dt=c.useCallback(()=>{const we=Ge(Re.current??ye);Re.current=null,Be.current=null,Y.current!==null&&(clearTimeout(Y.current),Y.current=null),document.documentElement.style.cursor="",te?P(we):f&&re&&(r?p(f,re,we):S(f,re,we)),z(!1),Ue.current=null},[re,Ge,f,te,r,P,p,S,ye]);c.useEffect(()=>{if(!Te)return;const we=le=>{if(Ue.current!==le.pointerId)return;const Xe=r?le.clientY:le.clientX,Ae=t==="left"?Xe-he.current:he.current-Xe,Je=!r&&l?-Ae:Ae,Fe=Ge(se.current+Je);Re.current!==Fe&&(Re.current=Fe,Y.current===null&&(Y.current=setTimeout(Me,rw)))},it=le=>{Ue.current===le.pointerId&&dt()},Q=()=>{dt()};return window.addEventListener("pointermove",we),window.addEventListener("pointerup",it),window.addEventListener("pointercancel",it),window.addEventListener("blur",Q),()=>{window.removeEventListener("pointermove",we),window.removeEventListener("pointerup",it),window.removeEventListener("pointercancel",it),window.removeEventListener("blur",Q)}},[Me,Ge,dt,Te,l,r,t]),c.useEffect(()=>{Te||(Re.current=null,document.documentElement.style.cursor="")},[Te]);const et=c.useCallback(()=>{f&&g(f,t)},[g,f,t]),ct=c.useCallback(()=>{f&&x(f,t)},[f,x,t]),me=c.useCallback(we=>{Kf(we,B,et)},[et,B]),Ne=C?.mode==="file"||C?.mode==="chat"||C?.mode==="browser",qe=c.useMemo(()=>C?N.filter(we=>we.mode===C.mode):[],[C,N]),Ye=c.useMemo(()=>qe.map(we=>{const it=dw(we,ve,u),Q=pw(it,ow),le=lw(we.targetPath,a);return{id:we.id,label:Q,icon:Ic(we,$),title:le?`${it}: ${le}`:it,closeLabel:o("contextPanel.tab.closeTabAria",{label:Q}),preview:we.preview}}),[qe,a,$,ve,o,u]),$e=C?.mode==="context"?n.jsx(Tn,{value:O,children:n.jsx(Ov,{})}):C?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:O,children:n.jsx(sw,{isActive:B})})}):C?.mode==="pr"?n.jsx(iv,{}):C?.mode==="notes"?n.jsx(Tn,{value:O,children:n.jsx(gg,{visible:B})}):C?.mode==="plan"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:O,children:n.jsx(nw,{targetPath:C.targetPath,savedProjectPlan:C.projectPlanId&&C.projectPlanRef?{projectRef:C.projectPlanRef,planId:C.projectPlanId}:null})})}):null,tt=C?.mode==="file",ht=ue(we=>we.closeContextPanelTabs),wt=c.useCallback(we=>{if(!f)return null;const{id:it,index:Q,allIds:le,close:Xe}=we,Ae=()=>ht(f,le.filter(Ze=>Ze!==it)),Je=le.slice(0,Q),Fe=le.slice(Q+1),gt=()=>ht(f,l?Fe:Je),bt=()=>ht(f,l?Je:Fe),Et=()=>ht(f,le),Ft=le.length>1,es=l?Q===le.length-1:Q===0,Ie=l?Q===0:Q===le.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(In,{onClick:Xe,children:[n.jsx(Z,{name:"close",className:"me-2 size-4"}),o("contextPanel.tab.menu.close")]}),n.jsx(so,{}),n.jsxs(In,{onClick:Ae,disabled:!Ft,children:[n.jsx(Z,{name:"expand-horizontal",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeOthers")]}),n.jsxs(In,{onClick:gt,disabled:es,children:[n.jsx(Z,{name:"expand-left",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(In,{onClick:bt,disabled:Ie,children:[n.jsx(Z,{name:"expand-right",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeToRight")]}),n.jsx(so,{}),n.jsxs(In,{onClick:Et,disabled:!Ft,children:[n.jsx(Z,{name:"close-circle",className:"me-2 size-4"}),o("contextPanel.tab.menu.closeAll")]}),C?n.jsxs(n.Fragment,{children:[n.jsx(so,{}),n.jsx(iu,{mode:C.mode})]}):null]})},[C,ht,f,l,o]),Bt=c.useCallback((we,it)=>{const Q=N.find(Xe=>Xe.id===we);if(!Q)return null;const le=el({mode:Q.mode,label:lo(Q.mode,u),from:t},it);return{finish:()=>le.finish(f),cancel:le.cancel}},[f,u,N,t]),[kt,St]=c.useState(null),xt=c.useCallback(we=>{if(!C||we.button!==0||we.pointerType==="touch"||we.target instanceof Element&&we.target.closest(gw))return;const it=C.mode,Q=lo(it,u),le={x:we.clientX,y:we.clientY};let Xe=!1;const Ae=bt=>{const Et={x:bt.clientX,y:bt.clientY};!Xe&&(Math.hypot(Et.x-le.x,Et.y-le.y)<mw||(Xe=Wf({mode:it,label:Q,from:t}),!Xe))||Hf(Et)},Je=()=>{window.removeEventListener("pointermove",Ae),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",gt),window.removeEventListener("blur",gt)},Fe=()=>{Je(),Xe&&Vf(f)},gt=()=>{Je(),Xe&&Ji()};window.addEventListener("pointermove",Ae),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",gt),window.addEventListener("blur",gt)},[C,f,u,t]);c.useEffect(()=>{if(kt)return kt.addEventListener("pointerdown",xt),()=>kt.removeEventListener("pointerdown",xt)},[xt,kt]);const Mt=n.jsxs("header",{ref:St,className:"group/panel-header flex min-h-10 select-none items-stretch border-b border-border",children:[Ne?n.jsx(iy,{items:Ye,activeId:C?.id??null,onSelect:we=>{f&&y(f,we)},onClose:we=>{f&&b(f,we)},onReorder:(we,it)=>{f&&w(f,we,it)},onDoubleClickTab:we=>{f&&v(f,we)},layoutMode:"scrollable",variant:"default",tabContextMenu:wt,onTabDragOut:Bt}):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:[C?.mode==="pr"&&d==="gitlab"?n.jsx(Z,{name:"gitlab",className:"h-3.5 w-3.5"}):C?Ic(C,$):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?.mode==="pr"&&d==="gitlab"?o("contextPanel.mode.mr"):C?lo(C.mode,u):null})]}),n.jsx("div",{ref:I,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:[C?.mode==="browser"?n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f&&T(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,tt?["left","right"].map(we=>{const it=we===E;if(!it&&!ee)return null;const Q=o(it?"contextRail.editorTree.toggle":"contextRail.editor.toggle");return n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:it?A:D,className:"h-7 w-7 p-0",title:Q,"aria-label":Q,"aria-pressed":it?j:ne,children:n.jsx(Z,{name:we==="left"?"layout-left":"layout-right",className:"h-3.5 w-3.5"})},we)}):null,te?null:n.jsx(Ct,{type:"button",variant:"ghost",size:"sm",onClick:ct,className:"h-7 w-7 p-0",title:o(W?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":o(W?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:W?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(Ct,{type:"button",variant:"ghost",size:"sm",onClick:et,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"})})]})]}),jt=t==="right"&&H&&!M,$t=ae!==null?`${ae}px`:"100%",Kt=B?W?$t:`min(var(${e.sizeVariable}), 100%)`:jt?`${Yl}px`:"0px",Wt=t==="bottom"&&pr(h,m,"left"),rt=t==="bottom"&&(H&&!M||pr(h,m,"right")),ut=`${B}|${W}|${jt}|${B?oe:""}`,pt=c.useRef(ut),fe=c.useRef(M),lt=fe.current!==M;c.useLayoutEffect(()=>{fe.current=M},[M]),c.useLayoutEffect(()=>{pt.current!==ut&&(pt.current=ut,lt||Mu(s))},[ut,lt,s]);const ft=!ao(B),mt={[e.sizeVariable]:B&&W?$t:`${ye}px`,...r?{height:Kt,maxHeight:"100%"}:{width:Kt,maxWidth:"100%"},transitionDuration:lt?"0ms":`${s}ms`,transitionTimingFunction:Bi},Rt=W?ae!==null?`calc(${ae}px - ${e.gutterSize})`:"100%":`calc(var(${e.sizeVariable}) - ${e.gutterSize})`;return n.jsxs("aside",{ref:We,"data-context-panel":"true","data-context-zone":t,"data-right-slot":t==="right"?"":void 0,"data-context-panel-open":B?"true":"false",tabIndex:-1,className:ke("flex min-h-0 flex-col overflow-clip bg-background",W?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:me,style:mt,children:[t==="right"?n.jsx("div",{ref:ay,className:ke("absolute inset-y-0 inset-e-0 z-0 flex",M&&"invisible")}):null,B&&!W&&n.jsx("div",{className:e.handle,onPointerDown:Ve,role:"separator","aria-orientation":r?"horizontal":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{"data-zone-card":"",className:ke("relative z-10 flex min-h-0 shrink-0 flex-col motion-reduce:transition-none",e.gutter,t==="bottom"&&(Wt?"ms-0":"ms-2"),t==="bottom"&&(rt?"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]",!B&&"pointer-events-none select-none opacity-0"),style:{...r?{height:Rt,width:`calc(100% - ${(Wt?0:.5)+(rt?0:.375)}rem)`}:{width:Rt},transitionDuration:`${s}ms`,transitionTimingFunction:Bi},inert:ft||void 0,children:[Mt,n.jsx("div",{ref:X,className:ke("relative min-h-0 flex-1 overflow-hidden",Te&&"pointer-events-none"),children:C&&bw(C.mode)?$e:null})]})]})},Sw=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},vw=async(t,e)=>{try{const s=await an("/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(Sw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},ww=async t=>{try{const e=await an("/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}},kw=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}},jw=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=kw(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)},ea="__openchamberBrowserAnnotationActive",Cw=`(() => {
3
+ try {
4
+ var host = document.querySelector('[data-openchamber-annotation]');
5
+ if (host && host.parentNode) host.parentNode.removeChild(host);
6
+ } catch (error) { /* page navigated away */ }
7
+ try {
8
+ var cursor = document.getElementById('openchamber-annotation-cursor');
9
+ if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
10
+ } catch (error) { /* page navigated away */ }
11
+ try { delete window['${ea}']; } catch (error) { /* non-configurable */ }
12
+ })();`,Pw=(t,e)=>{const s=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
13
+ var CONFIG = ${s};
14
+ var THEME = CONFIG.theme;
15
+ var LABELS = CONFIG.labels;
16
+ var OVERLAY_ATTR = 'data-openchamber-annotation';
17
+ var Z_OVERLAY = 2147483646;
18
+ var MAX_TEXT = 400;
19
+ var MIN_RECT = 3;
20
+ var EDITOR_GAP = 10;
21
+
22
+ try {
23
+ var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
24
+ if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
25
+ } catch (error) { /* nothing to clean */ }
26
+
27
+ window['${ea}'] = true;
28
+
29
+ var counter = 0;
30
+ var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
31
+
32
+ var selected = null;
33
+ var regions = [];
34
+ var strokes = [];
35
+ var tool = 'select';
36
+ var settled = false;
37
+
38
+ // ---------------------------------------------------------------- geometry
39
+
40
+ var rectFrom = function (domRect) {
41
+ return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
42
+ };
43
+ var normalizeRect = function (ax, ay, bx, by) {
44
+ return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
45
+ };
46
+ var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
47
+
48
+ // ------------------------------------------------------------- description
49
+
50
+ var isOverlayNode = function (element) {
51
+ var node = element;
52
+ while (node) {
53
+ if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
54
+ node = node.parentNode || (node.host || null);
55
+ }
56
+ return false;
57
+ };
58
+
59
+ var elementFromPoint = function (x, y) {
60
+ var found = document.elementFromPoint(x, y);
61
+ if (!found || isOverlayNode(found)) return null;
62
+ return found;
63
+ };
64
+
65
+ var selectorPart = function (element) {
66
+ var part = element.tagName.toLowerCase();
67
+ if (element.id) return part + '#' + element.id;
68
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
69
+ if (className) {
70
+ var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
71
+ if (first) part += '.' + first;
72
+ }
73
+ return part;
74
+ };
75
+
76
+ var buildSelector = function (element) {
77
+ if (element.id) return '#' + element.id;
78
+ var parts = [];
79
+ var node = element;
80
+ var depth = 0;
81
+ while (node && node.nodeType === 1 && depth < 5) {
82
+ var part = selectorPart(node);
83
+ var parent = node.parentElement;
84
+ if (parent) {
85
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
86
+ return child.tagName === node.tagName;
87
+ });
88
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
89
+ }
90
+ parts.unshift(part);
91
+ if (node.id) break;
92
+ node = parent;
93
+ depth += 1;
94
+ }
95
+ return parts.join(' > ');
96
+ };
97
+
98
+ var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
99
+ var STYLE_PROPS = [
100
+ 'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
101
+ 'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
102
+ 'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
103
+ ];
104
+
105
+ var describe = function (element) {
106
+ var computed = window.getComputedStyle(element);
107
+ var attributes = {};
108
+ for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
109
+ var name = INTERESTING_ATTRS[i];
110
+ var value = element.getAttribute(name);
111
+ if (value) attributes[name] = String(value).slice(0, 200);
112
+ }
113
+ var computedStyle = {};
114
+ for (var j = 0; j < STYLE_PROPS.length; j += 1) {
115
+ var prop = STYLE_PROPS[j];
116
+ computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
117
+ }
118
+ var ancestry = [];
119
+ var node = element.parentElement;
120
+ var depth = 0;
121
+ while (node && node.nodeType === 1 && depth < 4) {
122
+ var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
123
+ if (node.id) entry.id = node.id;
124
+ var cls = typeof node.className === 'string' ? node.className.trim() : '';
125
+ if (cls) entry.className = cls.slice(0, 200);
126
+ ancestry.unshift(entry);
127
+ node = node.parentElement;
128
+ depth += 1;
129
+ }
130
+ var box = element.getBoundingClientRect();
131
+ var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
132
+ return {
133
+ tag: element.tagName.toLowerCase(),
134
+ text: text.slice(0, MAX_TEXT),
135
+ selector: buildSelector(element),
136
+ path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
137
+ bounds: rectFrom(box),
138
+ center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
139
+ attributes: attributes,
140
+ computedStyle: computedStyle,
141
+ ancestry: ancestry
142
+ };
143
+ };
144
+
145
+ // ------------------------------------------------------------------ chrome
146
+
147
+ var host = document.createElement('div');
148
+ host.setAttribute(OVERLAY_ATTR, '');
149
+ // A manual popover: shown, it joins the browser's top layer without making
150
+ // the rest of the page inert. See "top layer" below.
151
+ host.setAttribute('popover', 'manual');
152
+ // Every declaration is !important: as a popover, and later inside a page
153
+ // dialog, the host matches page rules such as [popover]{background:...},
154
+ // which would otherwise paint a sheet over the whole page.
155
+ host.style.cssText = [
156
+ 'all:initial', 'display:block', 'position:fixed', 'inset:0', 'width:auto', 'height:auto',
157
+ 'max-width:none', 'max-height:none', 'margin:0', 'padding:0', 'border:0', 'background:transparent',
158
+ 'overflow:visible', 'opacity:1', 'transform:none', 'z-index:' + Z_OVERLAY, 'pointer-events:none'
159
+ ].join(' !important;') + ' !important';
160
+ var shadow = host.attachShadow({ mode: 'closed' });
161
+
162
+ var style = document.createElement('style');
163
+ style.textContent = [
164
+ ':host{all:initial}',
165
+ '*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
166
+ '.layer{position:fixed;inset:0;pointer-events:none}',
167
+ '.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
168
+ '.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
169
+ '.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
170
+ '.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
171
+ '.tools button:hover{background:' + THEME.primaryFaint + '}',
172
+ '.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
173
+ '.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
174
+ '.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
175
+ '.editor textarea::placeholder{color:' + THEME.mutedText + '}',
176
+ '.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
177
+ '.editor button svg{width:16px;height:16px;display:block}',
178
+ '.editor button[disabled]{opacity:.5;cursor:default}'
179
+ ].join('');
180
+ shadow.appendChild(style);
181
+
182
+ var cursorStyle = document.createElement('style');
183
+ cursorStyle.id = 'openchamber-annotation-cursor';
184
+ document.head.appendChild(cursorStyle);
185
+ var setCursor = function (value) {
186
+ cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
187
+ };
188
+
189
+ var svgNS = 'http://www.w3.org/2000/svg';
190
+ var svg = document.createElementNS(svgNS, 'svg');
191
+ svg.setAttribute('class', 'layer');
192
+ svg.style.overflow = 'visible';
193
+ shadow.appendChild(svg);
194
+
195
+ var hoverBox = document.createElement('div');
196
+ hoverBox.className = 'box';
197
+ var hoverLabel = document.createElement('div');
198
+ hoverLabel.className = 'label';
199
+ var marqueeBox = document.createElement('div');
200
+ marqueeBox.className = 'box';
201
+ shadow.append(hoverBox, hoverLabel, marqueeBox);
202
+
203
+ var positionBox = function (node, rect) {
204
+ node.style.display = 'block';
205
+ node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
206
+ node.style.width = rect.width + 'px';
207
+ node.style.height = rect.height + 'px';
208
+ };
209
+
210
+ var tools = document.createElement('div');
211
+ tools.className = 'tools';
212
+ shadow.appendChild(tools);
213
+
214
+ var toolButtons = {};
215
+ [['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
216
+ var button = document.createElement('button');
217
+ button.type = 'button';
218
+ button.textContent = entry[1];
219
+ button.addEventListener('click', function () { setTool(entry[0]); });
220
+ toolButtons[entry[0]] = button;
221
+ tools.appendChild(button);
222
+ });
223
+
224
+ var editor = document.createElement('div');
225
+ editor.className = 'editor';
226
+ shadow.appendChild(editor);
227
+
228
+ var comment = document.createElement('textarea');
229
+ comment.rows = 1;
230
+ comment.placeholder = LABELS.commentPlaceholder;
231
+ var submit = document.createElement('button');
232
+ submit.type = 'button';
233
+ // Icon-only attach button (Remix attachment-2), matching the chat comment
234
+ // input; the localized label stays available to assistive tech.
235
+ submit.setAttribute('aria-label', LABELS.submit);
236
+ submit.title = LABELS.submit;
237
+ submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
238
+ editor.append(comment, submit);
239
+
240
+ /**
241
+ * Grows the box with its content.
242
+ *
243
+ * A hidden element reports scrollHeight 0, so measuring one collapses the
244
+ * field to nothing — which is what left a sliver of a click target and an
245
+ * invisible caret. Measuring only while visible, and never below the CSS
246
+ * min-height, keeps it usable.
247
+ */
248
+ var resizeComment = function () {
249
+ if (editor.style.display === 'none') return;
250
+ comment.style.height = 'auto';
251
+ comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
252
+ };
253
+ comment.addEventListener('input', resizeComment);
254
+
255
+ // -------------------------------------------------------------- selection
256
+
257
+ var lastTargetRect = null;
258
+
259
+ /** Places the comment box under whatever was just marked, kept on screen. */
260
+ var positionEditor = function () {
261
+ if (!lastTargetRect) {
262
+ editor.style.display = 'none';
263
+ return;
264
+ }
265
+ var wasHidden = editor.style.display === 'none';
266
+ editor.style.display = 'flex';
267
+ // Measured now that it is laid out, not while it was still hidden.
268
+ if (wasHidden) resizeComment();
269
+ var box = editor.getBoundingClientRect();
270
+ var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
271
+ var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
272
+ // Above the target when there is no room below, so the box is never left
273
+ // half off the bottom of the page.
274
+ if (top + box.height > window.innerHeight - 8) {
275
+ top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
276
+ }
277
+ left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
278
+ editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
279
+ };
280
+
281
+ /** Focus after layout: focusing a zero-height field puts the caret nowhere. */
282
+ var focusComment = function () {
283
+ requestAnimationFrame(function () {
284
+ try {
285
+ comment.focus({ preventScroll: true });
286
+ comment.setSelectionRange(comment.value.length, comment.value.length);
287
+ } catch (error) { /* field went away */ }
288
+ });
289
+ };
290
+
291
+ var hasTargets = function () {
292
+ return Boolean(selected) || regions.length > 0 || strokes.length > 0;
293
+ };
294
+
295
+ var syncChrome = function () {
296
+ submit.disabled = !hasTargets();
297
+ if (!hasTargets()) {
298
+ lastTargetRect = null;
299
+ editor.style.display = 'none';
300
+ return;
301
+ }
302
+ positionEditor();
303
+ };
304
+
305
+ var syncSelectionVisuals = function () {
306
+ if (!selected) return;
307
+ var rect = rectFrom(selected.element.getBoundingClientRect());
308
+ if (!usableRect(rect)) {
309
+ selected.outline.style.display = 'none';
310
+ selected.badge.style.display = 'none';
311
+ return;
312
+ }
313
+ positionBox(selected.outline, rect);
314
+ selected.badge.style.display = 'block';
315
+ selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
316
+ lastTargetRect = rect;
317
+ };
318
+
319
+ var dropSelection = function () {
320
+ if (!selected) return;
321
+ selected.outline.remove();
322
+ selected.badge.remove();
323
+ selected = null;
324
+ };
325
+
326
+ var selectElement = function (element) {
327
+ var wasSelected = selected && selected.element === element;
328
+ dropSelection();
329
+ if (wasSelected) {
330
+ // Clicking the chosen element again clears it, so a misclick costs one
331
+ // click rather than starting over.
332
+ lastTargetRect = null;
333
+ syncChrome();
334
+ return;
335
+ }
336
+ var outline = document.createElement('div');
337
+ outline.className = 'box';
338
+ var badge = document.createElement('div');
339
+ badge.className = 'label';
340
+ badge.textContent = selectorPart(element);
341
+ shadow.append(outline, badge);
342
+ selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
343
+ syncSelectionVisuals();
344
+ syncChrome();
345
+ focusComment();
346
+ };
347
+
348
+ var setTool = function (next) {
349
+ tool = next;
350
+ hoverBox.style.display = 'none';
351
+ hoverLabel.style.display = 'none';
352
+ marqueeBox.style.display = 'none';
353
+ setCursor(next === 'select' ? '' : 'crosshair');
354
+ for (var key in toolButtons) {
355
+ if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
356
+ toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
357
+ }
358
+ }
359
+ };
360
+
361
+ // ------------------------------------------------------------- interaction
362
+
363
+ var drag = null;
364
+
365
+ var onPointerMove = function (event) {
366
+ if (drag) {
367
+ if (drag.kind === 'marquee') {
368
+ drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
369
+ positionBox(marqueeBox, drag.rect);
370
+ } else if (drag.kind === 'draw') {
371
+ drag.points.push({ x: event.clientX, y: event.clientY });
372
+ drag.path.setAttribute('d', drag.points.map(function (point, index) {
373
+ return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
374
+ }).join(' '));
375
+ }
376
+ return;
377
+ }
378
+
379
+ if (tool !== 'select') return;
380
+ var element = elementFromPoint(event.clientX, event.clientY);
381
+ if (!element) {
382
+ hoverBox.style.display = 'none';
383
+ hoverLabel.style.display = 'none';
384
+ return;
385
+ }
386
+ var rect = rectFrom(element.getBoundingClientRect());
387
+ positionBox(hoverBox, rect);
388
+ hoverLabel.textContent = selectorPart(element);
389
+ hoverLabel.style.display = 'block';
390
+ hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
391
+ };
392
+
393
+ var onPointerDown = function (event) {
394
+ if (event.button !== 0) return;
395
+ if (isOverlayNode(event.target)) return;
396
+ event.preventDefault();
397
+ event.stopPropagation();
398
+
399
+ if (tool === 'select') {
400
+ var element = elementFromPoint(event.clientX, event.clientY);
401
+ if (element) selectElement(element);
402
+ return;
403
+ }
404
+
405
+ if (tool === 'marquee') {
406
+ drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
407
+ return;
408
+ }
409
+
410
+ var path = document.createElementNS(svgNS, 'path');
411
+ path.setAttribute('fill', 'none');
412
+ path.setAttribute('stroke', THEME.primary);
413
+ path.setAttribute('stroke-width', '2.5');
414
+ path.setAttribute('stroke-linecap', 'round');
415
+ path.setAttribute('stroke-linejoin', 'round');
416
+ svg.appendChild(path);
417
+ drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
418
+ };
419
+
420
+ var onPointerUp = function () {
421
+ if (!drag) return;
422
+ var finished = drag;
423
+ drag = null;
424
+
425
+ if (finished.kind === 'marquee') {
426
+ marqueeBox.style.display = 'none';
427
+ var rect = finished.rect;
428
+ if (!rect || !usableRect(rect)) return;
429
+ // A region marks an area, not the elements inside it: expanding it into a
430
+ // selection made the result depend on the page's markup rather than on
431
+ // what was drawn.
432
+ regions.push({ id: nextId('region'), rect: rect });
433
+ var outline = document.createElementNS(svgNS, 'rect');
434
+ outline.setAttribute('x', String(rect.x));
435
+ outline.setAttribute('y', String(rect.y));
436
+ outline.setAttribute('width', String(rect.width));
437
+ outline.setAttribute('height', String(rect.height));
438
+ outline.style.fill = THEME.primarySoft;
439
+ outline.setAttribute('stroke', THEME.primary);
440
+ outline.setAttribute('stroke-width', '1.5');
441
+ outline.setAttribute('rx', '2');
442
+ svg.appendChild(outline);
443
+ lastTargetRect = rect;
444
+ syncChrome();
445
+ focusComment();
446
+ return;
447
+ }
448
+
449
+ var points = finished.points;
450
+ if (points.length < 2) {
451
+ if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
452
+ return;
453
+ }
454
+ var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
455
+ for (var p = 1; p < points.length; p += 1) {
456
+ minX = Math.min(minX, points[p].x);
457
+ minY = Math.min(minY, points[p].y);
458
+ maxX = Math.max(maxX, points[p].x);
459
+ maxY = Math.max(maxY, points[p].y);
460
+ }
461
+ var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
462
+ strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
463
+ lastTargetRect = bounds;
464
+ syncChrome();
465
+ focusComment();
466
+ };
467
+
468
+ /**
469
+ * Swallows the page's own mouse handling while annotating.
470
+ *
471
+ * Blocking pointerdown is not enough: a click still follows it, so marking a
472
+ * button pressed that button and marking a link navigated away from the page
473
+ * being annotated. These are the events that reach page code, so these are
474
+ * the ones that have to stop.
475
+ */
476
+ var blockPageInteraction = function (event) {
477
+ if (isOverlayNode(event.target)) return;
478
+ event.preventDefault();
479
+ event.stopPropagation();
480
+ };
481
+ var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
482
+
483
+ var onScrollOrResize = function () {
484
+ syncSelectionVisuals();
485
+ positionEditor();
486
+ };
487
+
488
+ var onKeyDown = function (event) {
489
+ if (event.isComposing || event.keyCode === 229) return;
490
+ if (event.key === 'Escape') {
491
+ event.preventDefault();
492
+ event.stopImmediatePropagation();
493
+ finish(null);
494
+ }
495
+ };
496
+
497
+ var onCommentKeyDown = function (event) {
498
+ // Do not let the annotated page treat typed letters as its own shortcuts.
499
+ event.stopPropagation();
500
+ // WebKit can report the composition-confirming Enter as keyCode 229.
501
+ if (event.isComposing || event.keyCode === 229) return;
502
+ if (event.key === 'Enter' && !event.shiftKey) {
503
+ event.preventDefault();
504
+ attach();
505
+ }
506
+ };
507
+
508
+ document.addEventListener('pointermove', onPointerMove, true);
509
+ document.addEventListener('pointerdown', onPointerDown, true);
510
+ document.addEventListener('pointerup', onPointerUp, true);
511
+ BLOCKED_EVENTS.forEach(function (name) {
512
+ window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
513
+ });
514
+ window.addEventListener('scroll', onScrollOrResize, true);
515
+ window.addEventListener('resize', onScrollOrResize, true);
516
+ window.addEventListener('keydown', onKeyDown, true);
517
+ comment.addEventListener('keydown', onCommentKeyDown);
518
+
519
+ // --------------------------------------------------------------- top layer
520
+
521
+ /**
522
+ * Keeps the chrome above a modal dialog or popover the page opens.
523
+ *
524
+ * Those render in the browser's top layer, which no z-index reaches, and a
525
+ * modal dialog also makes everything outside itself inert: the outlines drew
526
+ * under the dialog and the comment box took no typing. So the host is shown
527
+ * as a popover, which puts it in the top layer too, and it lives inside the
528
+ * page's topmost modal dialog, where that inertness does not reach. Showing it
529
+ * again whenever the page puts something new on top keeps it last, so above.
530
+ *
531
+ * Opening our own modal dialog instead would make the page's dialog inert,
532
+ * which is the thing being annotated.
533
+ */
534
+ var modals = [];
535
+
536
+ var isModalDialog = function (element) {
537
+ if (element.tagName !== 'DIALOG') return false;
538
+ try { return element.matches(':modal'); } catch (error) { return false; }
539
+ };
540
+
541
+ var trackDialog = function (dialog) {
542
+ var index = modals.indexOf(dialog);
543
+ if (index !== -1) modals.splice(index, 1);
544
+ // Opened last, so on top. Dialogs already open when annotation starts are
545
+ // taken in document order, which is the usual order of nesting.
546
+ if (isModalDialog(dialog)) modals.push(dialog);
547
+ };
548
+
549
+ var topModal = function () {
550
+ for (var i = modals.length - 1; i >= 0; i -= 1) {
551
+ if (modals[i].isConnected && isModalDialog(modals[i])) return modals[i];
552
+ }
553
+ return null;
554
+ };
555
+
556
+ var placeHost = function () {
557
+ var parent = topModal() || document.body || document.documentElement;
558
+ var hadFocus = shadow.activeElement === comment;
559
+ if (host.parentNode !== parent) parent.appendChild(host);
560
+ try {
561
+ if (host.matches(':popover-open')) host.hidePopover();
562
+ host.showPopover();
563
+ } catch (error) { /* no popover support: the z-index still covers ordinary pages */ }
564
+ // Moving the host blurs the comment box mid-sentence.
565
+ if (hadFocus) comment.focus({ preventScroll: true });
566
+ };
567
+
568
+ var topLayerObserver = new window.MutationObserver(function (records) {
569
+ var changed = false;
570
+ for (var i = 0; i < records.length; i += 1) {
571
+ if (records[i].type === 'attributes' && records[i].target.tagName === 'DIALOG') {
572
+ trackDialog(records[i].target);
573
+ changed = true;
574
+ }
575
+ }
576
+ if (!host.isConnected) {
577
+ // Removed on purpose, not along with a dialog: the session was cancelled
578
+ // from the app or replaced by a new one. End it, so its listeners stop
579
+ // swallowing the page's clicks and nothing brings the host back.
580
+ for (var j = 0; j < records.length; j += 1) {
581
+ if (Array.prototype.indexOf.call(records[j].removedNodes, host) !== -1) {
582
+ finish(null);
583
+ return;
584
+ }
585
+ }
586
+ changed = true;
587
+ }
588
+ if (!changed) return;
589
+ placeHost();
590
+ // Our own move is not a page change.
591
+ topLayerObserver.takeRecords();
592
+ });
593
+
594
+ var onToggle = function (event) {
595
+ if (event.target === host || event.newState !== 'open') return;
596
+ placeHost();
597
+ topLayerObserver.takeRecords();
598
+ };
599
+
600
+ // With the host inside the page's dialog, clicks on our chrome would reach
601
+ // the dialog's own handlers, and a click outside its box commonly closes it.
602
+ // Typing in the comment box would reach its key handlers the same way.
603
+ var CHROME_EVENTS = BLOCKED_EVENTS.concat([
604
+ 'pointerdown', 'pointerup', 'keydown', 'keyup', 'keypress', 'beforeinput', 'input'
605
+ ]);
606
+ var keepChromeEvent = function (event) { event.stopPropagation(); };
607
+ CHROME_EVENTS.forEach(function (name) {
608
+ host.addEventListener(name, keepChromeEvent);
609
+ });
610
+
611
+ var startTopLayer = function () {
612
+ Array.prototype.forEach.call(document.querySelectorAll('dialog'), trackDialog);
613
+ placeHost();
614
+ topLayerObserver.observe(document.documentElement, {
615
+ subtree: true,
616
+ childList: true,
617
+ attributes: true,
618
+ attributeFilter: ['open']
619
+ });
620
+ document.addEventListener('toggle', onToggle, true);
621
+ };
622
+
623
+ // ------------------------------------------------------------------ finish
624
+
625
+ var teardown = function () {
626
+ document.removeEventListener('pointermove', onPointerMove, true);
627
+ document.removeEventListener('pointerdown', onPointerDown, true);
628
+ document.removeEventListener('pointerup', onPointerUp, true);
629
+ BLOCKED_EVENTS.forEach(function (name) {
630
+ window.removeEventListener(name, blockPageInteraction, true);
631
+ });
632
+ window.removeEventListener('scroll', onScrollOrResize, true);
633
+ window.removeEventListener('resize', onScrollOrResize, true);
634
+ window.removeEventListener('keydown', onKeyDown, true);
635
+ comment.removeEventListener('keydown', onCommentKeyDown);
636
+ topLayerObserver.disconnect();
637
+ document.removeEventListener('toggle', onToggle, true);
638
+ setCursor('');
639
+ if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
640
+ if (host.parentNode) host.parentNode.removeChild(host);
641
+ try { delete window['${ea}']; } catch (error) { /* non-configurable */ }
642
+ };
643
+
644
+ var finish = function (payload) {
645
+ if (settled) return;
646
+ settled = true;
647
+ teardown();
648
+ // Removing the chrome is not enough: the host screenshots this page right
649
+ // after we resolve, and the compositor can still hold a frame containing
650
+ // our outlines. Yield two frames so the page has actually repainted.
651
+ requestAnimationFrame(function () {
652
+ requestAnimationFrame(function () { resolve(payload); });
653
+ });
654
+ };
655
+
656
+ var attach = function () {
657
+ if (!hasTargets()) return;
658
+ finish({
659
+ id: 'annotation-' + Date.now(),
660
+ pageUrl: String(location.href),
661
+ pageTitle: String(document.title || ''),
662
+ viewport: { width: window.innerWidth, height: window.innerHeight },
663
+ devicePixelRatio: window.devicePixelRatio || 1,
664
+ comment: comment.value,
665
+ // Zero or one element, never more. Kept as a list so elements, regions
666
+ // and strokes stay one uniform shape for everything downstream.
667
+ elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
668
+ regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
669
+ strokes: strokes.map(function (entry) {
670
+ return { id: entry.id, points: entry.points, bounds: entry.bounds };
671
+ })
672
+ });
673
+ };
674
+
675
+ submit.addEventListener('click', attach);
676
+
677
+ startTopLayer();
678
+ setTool('select');
679
+ syncChrome();
680
+ });`},Ew={kind:"idle"},Xs=t=>typeof t=="object"&&t!==null,sn=t=>typeof t=="number"&&Number.isFinite(t),Mc=t=>Xs(t)&&Object.values(t).every(e=>typeof e=="string"),tl=t=>Xs(t)&&sn(t.x)&&sn(t.y)&&sn(t.width)&&sn(t.height),Jf=t=>Xs(t)&&sn(t.x)&&sn(t.y),Nw=t=>Xs(t)&&typeof t.tag=="string"&&typeof t.selectorPart=="string"&&(t.id===void 0||typeof t.id=="string")&&(t.className===void 0||typeof t.className=="string"),Rw=t=>Xs(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&tl(t.bounds)&&Jf(t.center)&&Mc(t.attributes)&&Mc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Nw),Dw=t=>Xs(t)&&typeof t.id=="string"&&Rw(t.element),Iw=t=>Xs(t)&&typeof t.id=="string"&&tl(t.rect),Tw=t=>Xs(t)&&typeof t.id=="string"&&tl(t.bounds)&&Array.isArray(t.points)&&t.points.every(Jf),Mw=t=>Xs(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&Xs(t.viewport)&&sn(t.viewport.width)&&sn(t.viewport.height)&&sn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Dw)&&Array.isArray(t.regions)&&t.regions.every(Iw)&&Array.isArray(t.strokes)&&t.strokes.every(Tw),Aw=1600,Ow=t=>new Promise((e,s)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>s(new Error("Failed to decode browser page capture")),r.src=t}),Bw=async({base64:t,mime:e,captureWidth:s,captureHeight:r,cssWidth:o,cssHeight:i,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await Ow(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),h=Math.max(1,u.naturalHeight||r),m=f/Math.max(1,o||f),g=h/Math.max(1,i||h),b=Math.min(1,Aw/f),v=document.createElement("canvas");v.width=Math.max(1,Math.floor(f*b)),v.height=Math.max(1,Math.floor(h*b));const x=v.getContext("2d");if(!x)return null;x.scale(b,b),x.drawImage(u,0,0,f,h);const S=j=>({x:j.x*m,y:j.y*g,width:j.width*m,height:j.height*g}),p=Math.max(2,2.5*m/Math.max(b,.2));x.strokeStyle=a,x.fillStyle=d;const y=j=>{const k=S(j);x.lineWidth=p,x.fillRect(k.x,k.y,k.width,k.height),x.strokeRect(k.x,k.y,k.width,k.height)};for(const j of l.elements)y(j.element.bounds);for(const j of l.regions)y(j.rect);for(const j of l.strokes)j.points.length<2||(x.beginPath(),j.points.forEach((k,P)=>{const A=k.x*m,F=k.y*g;P===0?x.moveTo(A,F):x.lineTo(A,F)}),x.lineCap="round",x.lineJoin="round",x.lineWidth=p*1.4,x.stroke());const w=await new Promise(j=>v.toBlob(j,"image/jpeg",.85));return w?new File([w],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Fw="({ width: window.innerWidth, height: window.innerHeight })",_w=async t=>{try{const e=await t.executeJavaScript(Fw,!0);if(!e||typeof e!="object")return null;const s=e;return typeof s.width!="number"||typeof s.height!="number"||!Number.isFinite(s.width)||!Number.isFinite(s.height)?null:{width:s.width,height:s.height}}catch{return null}},co=async t=>{try{await t.executeJavaScript(Cw,!1)}catch{}},Lw=async({host:t,theme:e,labels:s})=>{const r=Pw(e,s),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!Mw(o))return await co(t),null;const i=o;try{const l=await _w(t)??i.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:i,screenshot:null};const d=await Bw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:i,accentColor:e.primary,accentFill:e.primarySoft});return{payload:i,screenshot:d}}catch{return{payload:i,screenshot:null}}},Ms={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},$w=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const s=window.getComputedStyle(t).backgroundColor;return s&&s!=="rgba(0, 0, 0, 0)"?s:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},zw=t=>{const e=$w();if(!e)return{...Ms,colorScheme:t};try{const s=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,o=e.readVariable("--oc-glass-tooltip-opacity")||"62%",i=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${o}, transparent)`)||Ms.glassSurface,glassFilter:`blur(${i}) saturate(${l})`,primary:s("--primary",Ms.primary),primarySoft:r("--primary",16,Ms.primarySoft),primaryFaint:r("--primary",10,Ms.primaryFaint),primaryContrast:s("--primary-foreground",Ms.primaryContrast),surface:s("--surface-background",Ms.surface),surfaceElevated:s("--surface-elevated",Ms.surfaceElevated),border:s("--border",Ms.border),text:s("--foreground",Ms.text),mutedText:s("--muted-foreground",Ms.mutedText)}}catch{return{...Ms,colorScheme:t}}finally{e.dispose()}},Kw=t=>({sessionId:t.sessionId,directory:t.directory?vs(t.directory):null}),Ww=2e3,Hw=50,vi=400,Rs=new Map,nn=new Map;let ta=null,sa=null;const sl=new Map;let en=null,yr=null;const uo=async t=>{try{const e=await an("/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}},Vw=async(t,e)=>{try{const s=await an("/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)}},eh=async(t,e=Ww)=>{const s=Date.now()+e;for(;!Rs.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,Hw));return Rs.get(t)??null},Ac=t=>Rs.has(t)||nn.has(t),Eo=t=>Rs.get(t)??nn.get(t)??null,na=()=>[...Rs.values(),...[...nn.values()].filter(t=>!Rs.has(t.tabId))],th=t=>{const e=sa?Eo(sa):null,s=e?.directory===ta?e:null;if(!t.sessionId){if(s)return s.tabId;const i=na().filter(d=>d.directory===ta),l=i.filter(d=>Rs.has(d.tabId)),a=l.length>0?l:i;return a.length>0?a[a.length-1].tabId:null}if(s?.ownerSessionId===t.sessionId)return s.tabId;const r=sl.get(t.sessionId);if(r&&Eo(r)?.ownerSessionId===t.sessionId)return r;const o=na().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},Gw=(t,e)=>{t.sessionId&&Eo(e)?.ownerSessionId===t.sessionId&&sl.set(t.sessionId,e)},sh=async t=>{const e=Rs.get(t);if(e)return e;const s=nn.get(t);return s?(s.wake(),eh(t)):null},nh=t=>{const e=th(t);return na().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}})},rh=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Uw=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.`,qw=t=>{const e=nh(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:
681
+ ${e.map(r=>`- ${r.id}: ${r.title||r.url||"blank"} (opened by ${r.owner})`).join(`
682
+ `)}`:"")},Vs=(t,e)=>Vw(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:cy()})}:e),Yw=async t=>{const e=t.action==="browser.open",s=Kw(t.context),{tabId:r,...o}=t.parameters,i=r===void 0?null:String(r);if(i!==null){if(!Ac(i)){if(Rs.size===0&&nn.size===0&&!en)return;if(await new Promise(d=>setTimeout(d,vi)),Ac(i)){await Oc(t,s,i,o);return}if(!await uo(t.requestId))return;await Vs(t,{ok:!1,error:Uw(i)});return}await Oc(t,s,i,o);return}const l=th(s);if(!l&&!(e&&en)){if(!s.sessionId||(await new Promise(d=>setTimeout(d,vi)),!await uo(t.requestId)))return;await Vs(t,{ok:!1,error:qw(s)});return}if(!(e&&en!==null)&&s.sessionId&&Eo(l)?.ownerSessionId!==s.sessionId&&await new Promise(d=>setTimeout(d,vi)),!!await uo(t.requestId))try{const d=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!d){await Vs(t,{ok:!1,error:"url is required"});return}const u=e&&en?en(d,t.context):null;if(e&&!u&&!l){await Vs(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(u){s.sessionId&&sl.set(s.sessionId,u);const h=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!h||h==="fill"){await Vs(t,{ok:!0,data:{url:d,opened:!0,tabId:u}});return}const m=await eh(u);if(!m){await Vs(t,{ok:!0,data:{url:d,opened:!0,tabId:u,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 g=await m.run("browser.resize",{viewport:h}),b=g&&typeof g=="object"?g.viewport??null:null;await Vs(t,{ok:!0,data:{url:d,opened:!0,tabId:u,viewportApplied:!0,viewport:b}});return}const f=await sh(l);await Vs(t,f?await oh(f,s,t.action,o):{ok:!1,error:rh(l)})}catch(d){await Vs(t,{ok:!1,error:d instanceof Error?d.message:String(d)})}},Oc=async(t,e,s,r)=>{if(!await uo(t.requestId))return;Gw(e,s);const o=await sh(s);await Vs(t,o?await oh(o,e,t.action,r):{ok:!1,error:rh(s)})},oh=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:nh(e)}}:{ok:!0,data:o}}catch(o){return{ok:!1,error:o instanceof Error?o.message:String(o)}}},nl=()=>{yr||(yr=wn(t=>{t.type==="browser-control-request"&&Yw({requestId:t.requestId,action:t.action,parameters:t.parameters,context:t.context})}))},rl=()=>{Rs.size>0||nn.size>0||en||!yr||(yr(),yr=null)},Xw=t=>(Rs.set(t.tabId,t),nl(),()=>{Rs.get(t.tabId)===t&&Rs.delete(t.tabId),rl()}),Qw=t=>(nn.set(t.tabId,t),nl(),()=>{nn.get(t.tabId)===t&&nn.delete(t.tabId),rl()}),Zw=(t,e)=>{ta=t,e&&(sa=e)},Jw=t=>(en=t,nl(),()=>{en===t&&(en=null),rl()}),e0=50,t0=6,s0=2048,n0=200,ih=t=>{const e=Kn(String(t??"").trim());if(!e||e.length>s0)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},r0=(t,e)=>{const s=ih(e.url);if(!s)return t;const r=t.find(l=>l.url===s),o=String(e.title??"").trim().slice(0,n0)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(l=>l.url!==s)].slice(0,e0)},o0=(t,e)=>{const s=ih(e);return t.filter(r=>r.url!==s)},i0=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),ah=(t,e,s=t0)=>{const r=String(e??"").trim().toLowerCase(),o=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return o.slice(0,s);const i=r.replace(/^https?:\/\//,"");return o.filter(l=>{const a=i0(l);return l.url===r||a===i?!1:a.includes(i)}).slice(0,s)},Bc=20,fo=t=>{const e=ot((t||"").trim());return e?JSON.stringify([Yt(),e]):""},a0=t=>{const e=Object.keys(t);if(e.length<=Bc)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Bc);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},Hn=Br()(P1(t=>({byProject:{},recordVisit:(e,s)=>{const r=fo(e);r&&t(o=>{const i=o.byProject[r]??[],l=r0(i,{...s,at:Date.now()});return l===i?o:{byProject:a0({...o.byProject,[r]:l})}})},forget:(e,s)=>{const r=fo(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:o0(i,s)}}:o})},clear:e=>{const s=fo(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:nm(),partialize:t=>({byProject:t.byProject})})),l0=[],lh=t=>e=>{const s=fo(t);return(s?e.byProject[s]:void 0)??l0},ol=t=>{const e=Ke.c(10),{t:s}=vt();let r;e[0]!==t?(r=Ls(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 l=$s(i);if(o===null)return null;if(!l){let u;return e[4]!==s?(u=s("contextPanel.browser.spaceAddress"),e[4]=s,e[5]=u):u=e[5],u}let a;e[6]!==l.machine||e[7]!==l.placeId||e[8]!==s?(a=l.machine??(l.placeId==="docker"?s("spaces.create.place.localDocker"):l.placeId),e[6]=l.machine,e[7]=l.placeId,e[8]=s,e[9]=a):a=e[9];const d=a;return`${l.name} · ${d}`},Fc=6e3,c0=120,d0=80,u0=100,f0=`
683
+ var MAX_ELEMENTS = ${c0};
684
+ var MAX_LABEL_CHARS = ${d0};
685
+ var visible = function (element) {
686
+ var rect = element.getBoundingClientRect();
687
+ if (rect.width < 1 || rect.height < 1) return false;
688
+ var style = window.getComputedStyle(element);
689
+ return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
690
+ };
691
+ var label = function (element) {
692
+ var aria = element.getAttribute('aria-label');
693
+ if (aria) return aria.trim();
694
+ var value = element.getAttribute('value');
695
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
696
+ if (text) return text.slice(0, MAX_LABEL_CHARS);
697
+ if (value) return String(value).slice(0, MAX_LABEL_CHARS);
698
+ var placeholder = element.getAttribute('placeholder');
699
+ return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
700
+ };
701
+ var isUnique = function (selector) {
702
+ try {
703
+ return document.querySelectorAll(selector).length === 1;
704
+ } catch (error) {
705
+ return false;
706
+ }
707
+ };
708
+
709
+ /**
710
+ * Names an element by what it is, falling back to where it sits.
711
+ *
712
+ * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
713
+ * only until the markup shifts, and says nothing about what it points at.
714
+ * Anything the page states about identity — an id, a test id, an accessible
715
+ * name — outlives edits and reads as the thing it selects. The chain remains
716
+ * as the last resort, because something always has to work.
717
+ */
718
+ var cssPath = function (element) {
719
+ var tag = element.tagName.toLowerCase();
720
+
721
+ if (element.id) {
722
+ var byId = '#' + CSS.escape(element.id);
723
+ if (isUnique(byId)) return byId;
724
+ }
725
+ var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
726
+ for (var a = 0; a < stableAttrs.length; a += 1) {
727
+ var value = element.getAttribute(stableAttrs[a]);
728
+ if (!value) continue;
729
+ var raw = String(value);
730
+ // A value containing a quote would need escaping for no real gain: such
731
+ // attributes are rare, and the positional chain still covers them.
732
+ if (raw.indexOf('"') !== -1) continue;
733
+ var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
734
+ if (isUnique(byAttr)) return byAttr;
735
+ }
736
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
737
+ if (className) {
738
+ var classes = className.split(/\\s+/).filter(Boolean);
739
+ for (var c = 0; c < classes.length; c += 1) {
740
+ var byClass = tag + '.' + CSS.escape(classes[c]);
741
+ if (isUnique(byClass)) return byClass;
742
+ }
743
+ }
744
+
745
+ var parts = [];
746
+ var node = element;
747
+ var depth = 0;
748
+ while (node && node.nodeType === 1 && depth < 6) {
749
+ var part = node.tagName.toLowerCase();
750
+ var parent = node.parentElement;
751
+ if (!parent) { parts.unshift(part); break; }
752
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
753
+ return child.tagName === node.tagName;
754
+ });
755
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
756
+ parts.unshift(part);
757
+ if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
758
+ node = parent;
759
+ depth += 1;
760
+ }
761
+ return parts.join(' > ');
762
+ };
763
+
764
+ /** What a screen reader would announce, or '' when there is nothing to say. */
765
+ var accessibleName = function (element) {
766
+ var aria = element.getAttribute('aria-label');
767
+ if (aria && aria.trim()) return aria.trim();
768
+ var labelled = element.getAttribute('aria-labelledby');
769
+ if (labelled) {
770
+ var source = document.getElementById(labelled.split(/\\s+/)[0]);
771
+ if (source && (source.innerText || '').trim()) return source.innerText.trim();
772
+ }
773
+ var title = element.getAttribute('title');
774
+ if (title && title.trim()) return title.trim();
775
+ var alt = element.getAttribute('alt');
776
+ if (alt && alt.trim()) return alt.trim();
777
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
778
+ if (text) return text;
779
+ var value = element.getAttribute('value');
780
+ return value && String(value).trim() ? String(value).trim() : '';
781
+ };
782
+ var findByText = function (needle) {
783
+ var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
784
+ var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
785
+ var exact = null;
786
+ var partial = null;
787
+ for (var i = 0; i < candidates.length; i += 1) {
788
+ var element = candidates[i];
789
+ if (!visible(element)) continue;
790
+ var text = label(element).toLowerCase();
791
+ if (!text) continue;
792
+ if (text === wanted) { exact = element; break; }
793
+ if (!partial && text.indexOf(wanted) !== -1) partial = element;
794
+ }
795
+ return exact || partial;
796
+ };
797
+ `,Fr=t=>`(() => {
798
+ ${f0}
799
+ ${t}
800
+ })()`,h0=({selector:t}={})=>Fr(`
801
+ var scopeSelector = ${JSON.stringify(t??"")};
802
+ var root = document;
803
+ if (scopeSelector) {
804
+ try { root = document.querySelector(scopeSelector); }
805
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
806
+ if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
807
+ }
808
+ var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
809
+ var elements = [];
810
+ var visibleTotal = 0;
811
+ for (var i = 0; i < interactive.length; i += 1) {
812
+ var element = interactive[i];
813
+ if (!visible(element)) continue;
814
+ visibleTotal += 1;
815
+ if (elements.length >= MAX_ELEMENTS) continue;
816
+
817
+ var rect = element.getBoundingClientRect();
818
+ // Empty and default-valued fields are left out rather than serialized as
819
+ // "" and false. Repeated across a hundred entries that overhead dwarfed
820
+ // the information it carried.
821
+ var entry = {
822
+ selector: cssPath(element),
823
+ tag: element.tagName.toLowerCase(),
824
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
825
+ };
826
+ // The list covers the whole document so anything can be clicked without
827
+ // scrolling to it first, which means bounds alone do not say what is on
828
+ // screen — a negative y reads as a bug otherwise.
829
+ if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
830
+ var type = element.getAttribute('type');
831
+ if (type) entry.type = type;
832
+ var role = element.getAttribute('role');
833
+ if (role) entry.role = role;
834
+ var labelText = label(element);
835
+ if (labelText) entry.label = labelText;
836
+ if (element.disabled === true) entry.disabled = true;
837
+ // Flagged rather than described: reporting the accessible name of every
838
+ // element would cost more than it tells, while its absence on something
839
+ // clickable is a defect worth naming.
840
+ if (!accessibleName(element)) entry.missingAccessibleName = true;
841
+ elements.push(entry);
842
+ }
843
+ var body = document.body ? (document.body.innerText || '') : '';
844
+ var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
845
+ var docEl = document.documentElement;
846
+ var result = {
847
+ ok: true,
848
+ url: String(location.href),
849
+ title: String(document.title || ''),
850
+ scope: scopeSelector || 'document',
851
+ scrollY: Math.round(window.scrollY),
852
+ maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
853
+ text: text.slice(0, ${Fc}),
854
+ elements: elements
855
+ };
856
+ // State what was dropped. A capped list that reports only its own length
857
+ // reads as the whole page, and the agent acts as if it had seen everything.
858
+ if (text.length > ${Fc}) {
859
+ result.textTruncated = true;
860
+ result.textTotalChars = text.length;
861
+ }
862
+ if (visibleTotal > elements.length) {
863
+ result.elementsTruncated = true;
864
+ result.interactiveElementsOnPage = visibleTotal;
865
+ }
866
+ return result;
867
+ `),p0=({selector:t,text:e})=>Fr(`
868
+ var selector = ${JSON.stringify(t??"")};
869
+ var text = ${JSON.stringify(e??"")};
870
+ var target = null;
871
+ if (selector) {
872
+ try { target = document.querySelector(selector); }
873
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
874
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
875
+ } else {
876
+ target = findByText(text);
877
+ if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
878
+ }
879
+ if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
880
+ target.scrollIntoView({ block: 'center', inline: 'center' });
881
+
882
+ // A real click is a sequence, and many widgets act on its first half:
883
+ // custom selects open on mousedown or focus and ignore the click itself.
884
+ // Replay what the mouse would send to the middle of the element. The event
885
+ // goes to whatever is drawn there when that sits inside the target, as it
886
+ // would under a real pointer; anything else keeps the target the agent named.
887
+ var rect = target.getBoundingClientRect();
888
+ var x = rect.left + rect.width / 2;
889
+ var y = rect.top + rect.height / 2;
890
+ var drawn = document.elementFromPoint(x, y);
891
+ var hit = drawn && target.contains(drawn) ? drawn : target;
892
+ var fire = function (element, Type, type, extra) {
893
+ var init = {
894
+ bubbles: true, cancelable: true, composed: true, view: window,
895
+ clientX: x, clientY: y, button: 0, buttons: 0, detail: 1,
896
+ pointerId: 1, pointerType: 'mouse', isPrimary: true
897
+ };
898
+ for (var key in extra) init[key] = extra[key];
899
+ return element.dispatchEvent(new Type(type, init));
900
+ };
901
+ var Pointer = window.PointerEvent || window.MouseEvent;
902
+ var Mouse = window.MouseEvent;
903
+ var notBubbling = { bubbles: false, cancelable: false };
904
+
905
+ fire(hit, Pointer, 'pointerover', {});
906
+ fire(hit, Pointer, 'pointerenter', notBubbling);
907
+ fire(hit, Mouse, 'mouseover', {});
908
+ fire(hit, Mouse, 'mouseenter', notBubbling);
909
+ var pointerDown = fire(hit, Pointer, 'pointerdown', { buttons: 1 });
910
+ // A cancelled pointerdown suppresses the mouse events, as in a browser.
911
+ var mouseDown = pointerDown ? fire(hit, Mouse, 'mousedown', { buttons: 1 }) : true;
912
+ // Focus moves on mousedown unless the page prevented it, to the nearest
913
+ // focusable element under the pointer; with none, the old focus is lost.
914
+ if (mouseDown) {
915
+ var focusable = hit.closest('a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]:not([contenteditable="false"])');
916
+ if (focusable && focusable.disabled !== true) focusable.focus({ preventScroll: true });
917
+ else if (document.activeElement && document.activeElement !== document.body) document.activeElement.blur();
918
+ }
919
+ // The mousedown may have redrawn the widget; the release lands on what is
920
+ // under the pointer now, and the click on what both halves share.
921
+ var redrawn = document.elementFromPoint(x, y);
922
+ var up = redrawn && target.contains(redrawn) ? redrawn : (target.isConnected ? target : hit);
923
+ fire(up, Pointer, 'pointerup', {});
924
+ if (pointerDown) fire(up, Mouse, 'mouseup', {});
925
+ var clicked = up;
926
+ if (hit.isConnected) {
927
+ while (clicked && !clicked.contains(hit)) clicked = clicked.parentElement;
928
+ }
929
+ fire(clicked || up, Mouse, 'click', {});
930
+ return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
931
+ `),m0=({selector:t,value:e,submit:s})=>Fr(`
932
+ var selector = ${JSON.stringify(t)};
933
+ var value = ${JSON.stringify(e)};
934
+ var target = null;
935
+ try { target = document.querySelector(selector); }
936
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
937
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
938
+
939
+ var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
940
+ if (!editable) return { ok: false, error: selector + ' is not a text field' };
941
+ if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
942
+
943
+ target.scrollIntoView({ block: 'center' });
944
+ target.focus();
945
+ if (target.isContentEditable) {
946
+ target.textContent = value;
947
+ } else {
948
+ // Frameworks track the value through the native setter; assigning the
949
+ // property directly leaves React and friends unaware of the change.
950
+ var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
951
+ var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
952
+ if (setter && setter.set) setter.set.call(target, value);
953
+ else target.value = value;
954
+ }
955
+ target.dispatchEvent(new Event('input', { bubbles: true }));
956
+ target.dispatchEvent(new Event('change', { bubbles: true }));
957
+
958
+ if (${s?"true":"false"}) {
959
+ var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
960
+ target.dispatchEvent(new KeyboardEvent('keydown', enter));
961
+ target.dispatchEvent(new KeyboardEvent('keyup', enter));
962
+ var form = target.form;
963
+ if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
964
+ }
965
+ return { ok: true, selector: cssPath(target), url: String(location.href) };
966
+ `),g0=({selector:t,direction:e})=>Fr(`
967
+ var selector = ${JSON.stringify(t??"")};
968
+ var direction = ${JSON.stringify(e??"")};
969
+
970
+ // Two frames let the layout catch up, but a page in a hidden background tab
971
+ // is not composited and gets no frames at all while still reporting itself
972
+ // visible, so the wait is capped by a timer. The scroll
973
+ // itself is instant, so the position read then is already the final one.
974
+ var settle = function (extra) {
975
+ return new Promise(function (resolve) {
976
+ var done = false;
977
+ var finish = function () {
978
+ if (done) return;
979
+ done = true;
980
+ var doc = document.documentElement;
981
+ var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
982
+ var scrollY = Math.round(window.scrollY);
983
+ var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
984
+ result.atTop = scrollY <= 1;
985
+ result.atBottom = scrollY >= maxScrollY - 1;
986
+ for (var key in extra) {
987
+ if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
988
+ }
989
+ resolve(result);
990
+ };
991
+ requestAnimationFrame(function () {
992
+ requestAnimationFrame(finish);
993
+ });
994
+ setTimeout(finish, ${u0});
995
+ });
996
+ };
997
+
998
+ if (selector) {
999
+ var target = null;
1000
+ try { target = document.querySelector(selector); }
1001
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
1002
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
1003
+ // Instant on purpose: the page's own smooth scrolling would still be
1004
+ // animating when the next action runs against it.
1005
+ target.scrollIntoView({ block: 'center', behavior: 'instant' });
1006
+ return settle({ scrolledTo: cssPath(target) });
1007
+ }
1008
+
1009
+ var doc = document.documentElement;
1010
+ var page = Math.round(window.innerHeight * 0.85);
1011
+ var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
1012
+ if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
1013
+ else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
1014
+ else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
1015
+ else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
1016
+ else return { ok: false, error: 'Unknown scroll direction: ' + direction };
1017
+ return settle({ direction: direction });
1018
+ `),b0=["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"],y0=({selector:t})=>Fr(`
1019
+ var selector = ${JSON.stringify(t)};
1020
+ var target = null;
1021
+ try { target = document.querySelector(selector); }
1022
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
1023
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
1024
+
1025
+ var computed = window.getComputedStyle(target);
1026
+ var styles = {};
1027
+ var props = ${JSON.stringify(b0)};
1028
+ for (var i = 0; i < props.length; i += 1) {
1029
+ var value = computed.getPropertyValue(props[i]);
1030
+ if (value) styles[props[i]] = String(value).trim();
1031
+ }
1032
+
1033
+ var rect = target.getBoundingClientRect();
1034
+ return {
1035
+ ok: true,
1036
+ selector: cssPath(target),
1037
+ tag: target.tagName.toLowerCase(),
1038
+ label: label(target),
1039
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
1040
+ inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
1041
+ styles: styles
1042
+ };
1043
+ `),x0=t=>{const e=Ke.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:l}=t,{t:a}=vt();if(s.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==l||e[6]!==o||e[7]!==a){let h;e[9]!==r||e[10]!==i||e[11]!==l||e[12]!==o||e[13]!==a?(h=(m,g)=>n.jsxs("div",{role:"option","aria-selected":g===r,className:ke("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(m.url)},onPointerEnter:()=>l(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:m.title||_o(m.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:m.url})]}),n.jsx("button",{type:"button",className:ke("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),i(m.url)},children:n.jsx(Z,{name:"close",className:"size-3","aria-hidden":"true"})})]},m.url),e[9]=r,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=h):h=e[14],u=s.map(h),e[2]=r,e[3]=s,e[4]=i,e[5]=l,e[6]=o,e[7]=a,e[8]=u}else u=e[8];let f;return e[15]!==d||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":d,children:u}),e[15]=d,e[16]=u,e[17]=f):f=e[17],f},As=t=>{const e=Ke.c(17),{icon:s,label:r,onClick:o,disabled:i,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=ke("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let 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 h;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==f?(h=n.jsx(At,{asChild:!0,children:n.jsx(Ct,{type:"button",variant:a,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":l,children:f})}),e[4]=i,e[5]=r,e[6]=o,e[7]=l,e[8]=a,e[9]=u,e[10]=f,e[11]=h):h=e[11];let m;e[12]!==r?(m=n.jsx(Tt,{sideOffset:6,children:r}),e[12]=r,e[13]=m):m=e[13];let g;return e[14]!==h||e[15]!==m?(g=n.jsxs(Ot,{children:[h,m]}),e[14]=h,e[15]=m,e[16]=g):g=e[16],g},ch=t=>{const e=Ke.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:l,onSubmit:a,onBack:d,onForward:u,onReload:f,onOpenExternal:h,canOpenExternal:m,canGoBack:g,canGoForward:b,isLoading:v,onAnnotate:x,onOpenDevTools:S,isAnnotating:p,onHardReload:y,onZoomIn:w,onZoomOut:j,onZoomReset:k,zoomPercent:P,onClearCookies:A,onClearCache:F,onToggleDeviceBar:D,isDeviceBarOpen:E}=t;let T;e[0]!==o?(T=o===void 0?[]:o,e[0]=o,e[1]=T):T=e[1];const $=T,O=m===void 0?!0:m,K=P===void 0?100:P,{t:I}=vt(),[X,N]=c.useState(!1),[C,R]=c.useState(-1);let H;e[2]!==X||e[3]!==$?(H=X?$:[],e[2]=X,e[3]=$,e[4]=H):H=e[4];const M=H;let _;e[5]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{R(-1)},e[5]=_):_=e[5];let B;e[6]!==s||e[7]!==X?(B=[s,X],e[6]=s,e[7]=X,e[8]=B):B=e[8],c.useEffect(_,B);let ee;e[9]!==a?(ee=Ve=>{N(!1),R(-1),a(Ve)},e[9]=a,e[10]=ee):ee=e[10];const ne=ee;let re;e[11]!==C||e[12]!==ne||e[13]!==M?(re=Ve=>{if(M.length!==0){if(Ve.key==="ArrowDown"||Ve.key==="ArrowUp"){Ve.preventDefault();const dt=Ve.key==="ArrowDown"?1:-1,et=M.length;R(ct=>{const me=ct+dt;return me<-1?et-1:me>=et?-1:me});return}if(Ve.key==="Escape"&&C>=0){Ve.preventDefault(),R(-1);return}if(Ve.key==="Enter"&&C>=0){Ve.preventDefault();const dt=M[C];dt&&ne(dt.url)}}},e[11]=C,e[12]=ne,e[13]=M,e[14]=re):re=e[14];const te=re;let W;e[15]!==I?(W=I("contextPanel.browser.back"),e[15]=I,e[16]=W):W=e[16];const q=!g;let oe;e[17]!==d||e[18]!==W||e[19]!==q?(oe=n.jsx(As,{icon:"arrow-left",label:W,onClick:d,disabled:q}),e[17]=d,e[18]=W,e[19]=q,e[20]=oe):oe=e[20];let de;e[21]!==I?(de=I("contextPanel.browser.forward"),e[21]=I,e[22]=de):de=e[22];const ce=!b;let je;e[23]!==u||e[24]!==de||e[25]!==ce?(je=n.jsx(As,{icon:"arrow-right",label:de,onClick:u,disabled:ce}),e[23]=u,e[24]=de,e[25]=ce,e[26]=je):je=e[26];let be;e[27]!==v||e[28]!==I?(be=I(v?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=v,e[28]=I,e[29]=be):be=e[29];let pe;e[30]!==f||e[31]!==be?(pe=n.jsx(As,{icon:"refresh",label:be,onClick:f}),e[30]=f,e[31]=be,e[32]=pe):pe=e[32];let U;e[33]!==y||e[34]!==I?(U=y?n.jsx(As,{icon:"restart",label:I("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=I,e[35]=U):U=e[35];let Pe;e[36]!==s||e[37]!==ne?(Pe=Ve=>{Ve.preventDefault(),ne(s)},e[36]=s,e[37]=ne,e[38]=Pe):Pe=e[38];let xe;e[39]!==r?(xe=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]=xe):xe=e[40];let Ee;e[41]!==l?(Ee=Ve=>l(Ve.target.value),e[41]=l,e[42]=Ee):Ee=e[42];let L,ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(L=()=>N(!0),ie=()=>N(!1),e[43]=L,e[44]=ie):(L=e[43],ie=e[44]);const G=M.length>0,ae=r&&"ps-8";let ye;e[45]!==ae?(ye=ke("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3",ae,"typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[45]=ae,e[46]=ye):ye=e[46];let ge;e[47]!==I?(ge=I("contextPanel.browser.addressAria"),e[47]=I,e[48]=ge):ge=e[48];let Se;e[49]!==s||e[50]!==te||e[51]!==Ee||e[52]!==G||e[53]!==ye||e[54]!==ge?(Se=n.jsx("input",{value:s,onChange:Ee,onFocus:L,onBlur:ie,onKeyDown:te,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":G,"aria-controls":"openchamber-browser-address-suggestions",className:ye,"aria-label":ge}),e[49]=s,e[50]=te,e[51]=Ee,e[52]=G,e[53]=ye,e[54]=ge,e[55]=Se):Se=e[55];let ve;e[56]!==i?(ve=Ve=>i?.(Ve),e[56]=i,e[57]=ve):ve=e[57];let Te;e[58]!==C||e[59]!==ne||e[60]!==ve||e[61]!==M?(Te=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(x0,{entries:M,activeIndex:C,onSelect:ne,onForget:ve,onHighlight:R})}),e[58]=C,e[59]=ne,e[60]=ve,e[61]=M,e[62]=Te):Te=e[62];let z;e[63]!==Pe||e[64]!==xe||e[65]!==Se||e[66]!==Te?(z=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Pe,children:[xe,Se,Te]}),e[63]=Pe,e[64]=xe,e[65]=Se,e[66]=Te,e[67]=z):z=e[67];let he;e[68]!==w||e[69]!==j||e[70]!==k||e[71]!==I||e[72]!==K?(he=j&&w?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(As,{icon:"subtract",label:I("contextPanel.browser.zoomOut"),onClick:j}),K!==100&&k?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsxs(Ct,{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":I("contextPanel.browser.zoomReset"),children:[K,"%"]})}),n.jsx(Tt,{sideOffset:6,children:I("contextPanel.browser.zoomReset")})]}):null,n.jsx(As,{icon:"add",label:I("contextPanel.browser.zoomIn"),onClick:w})]}):null,e[68]=w,e[69]=j,e[70]=k,e[71]=I,e[72]=K,e[73]=he):he=e[73];let se;e[74]!==A||e[75]!==I?(se=A?n.jsx(As,{icon:"delete-bin",label:I("contextPanel.browser.clearCookies"),onClick:A}):null,e[74]=A,e[75]=I,e[76]=se):se=e[76];let Re;e[77]!==F||e[78]!==I?(Re=F?n.jsx(As,{icon:"database-2",label:I("contextPanel.browser.clearCache"),onClick:F}):null,e[77]=F,e[78]=I,e[79]=Re):Re=e[79];let Ue;e[80]!==E||e[81]!==D||e[82]!==I?(Ue=D?n.jsx(As,{icon:"smartphone",label:I("contextPanel.browser.deviceToolbar"),onClick:D,pressed:E}):null,e[80]=E,e[81]=D,e[82]=I,e[83]=Ue):Ue=e[83];let We;e[84]!==p||e[85]!==x||e[86]!==I?(We=x?n.jsx(As,{icon:"markup",label:I("contextPanel.browser.annotate.toggle"),onClick:x,pressed:p}):null,e[84]=p,e[85]=x,e[86]=I,e[87]=We):We=e[87];let He;e[88]!==S||e[89]!==I?(He=S?n.jsx(As,{icon:"terminal-box",label:I("contextPanel.browser.devTools"),onClick:S}):null,e[88]=S,e[89]=I,e[90]=He):He=e[90];let Be;e[91]!==I?(Be=I("contextPanel.browser.openExternal"),e[91]=I,e[92]=Be):Be=e[92];const Y=!O;let Me;e[93]!==h||e[94]!==Be||e[95]!==Y?(Me=n.jsx(As,{icon:"external-link",label:Be,onClick:h,disabled:Y}),e[93]=h,e[94]=Be,e[95]=Y,e[96]=Me):Me=e[96];let Ge;return e[97]!==oe||e[98]!==je||e[99]!==pe||e[100]!==U||e[101]!==z||e[102]!==he||e[103]!==se||e[104]!==Re||e[105]!==Ue||e[106]!==We||e[107]!==He||e[108]!==Me?(Ge=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[oe,je,pe,U,z,he,se,Re,Ue,We,He,Me]}),e[97]=oe,e[98]=je,e[99]=pe,e[100]=U,e[101]=z,e[102]=he,e[103]=se,e[104]=Re,e[105]=Ue,e[106]=We,e[107]=He,e[108]=Me,e[109]=Ge):Ge=e[109],Ge},No={kind:"fill"},_c=240,S0=3840,dh=[{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}],Lc=t=>Number.isFinite(t)?Math.round(Math.min(S0,Math.max(_c,t))):_c,Ro=t=>t.kind==="fill"?null:{width:t.width,height:t.height},uh=t=>{const e=dh.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},v0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},w0=(t,e)=>{const s=Ro(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}},k0=["mobile","tablet","desktop","fill"],j0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},$c=t=>typeof t=="string"&&k0.includes(t),ra=t=>t==="fill"?No:uh(j0[t])??No,Wr=t=>{const e=Ro(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=ra(s),o=Ro(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}},C0=t=>{const e=Ke.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:l}=t,{t:a}=vt();let d;e[0]!==s?(d=Ro(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let h;e[2]!==r||e[3]!==u?(h=(re,te)=>{const W=Number.parseInt(te,10);if(!Number.isFinite(W))return;const q=u??{width:1280,height:800};r({kind:"custom",width:Lc(re==="width"?W:q.width),height:Lc(re==="height"?W:q.height)})},e[2]=r,e[3]=u,e[4]=h):h=e[4];const m=h;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=ke("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=g):g=e[5];const b=g;let v;e[6]!==r?(v=re=>{const te=uh(re.target.value);r(te??No)},e[6]=r,e[7]=v):v=e[7];let x;e[8]!==a?(x=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=x):x=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=ke("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=S):S=e[10];let p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let y;e[13]!==p?(y=n.jsx("option",{value:"",children:p}),e[13]=p,e[14]=y):y=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=dh.map(P0),e[15]=w):w=e[15];let j;e[16]!==f||e[17]!==v||e[18]!==x||e[19]!==y?(j=n.jsxs("select",{value:f,onChange:v,"aria-label":x,className:S,children:[y,w]}),e[16]=f,e[17]=v,e[18]=x,e[19]=y,e[20]=j):j=e[20];const k=u?String(u.width):"";let P;e[21]!==m?(P=re=>m("width",re.target.value),e[21]=m,e[22]=P):P=e[22];let A;e[23]!==a?(A=a("contextPanel.browser.device.width"),e[23]=a,e[24]=A):A=e[24];let F;e[25]!==k||e[26]!==P||e[27]!==A?(F=n.jsx("input",{value:k,onChange:P,placeholder:"—",inputMode:"numeric","aria-label":A,className:b}),e[25]=k,e[26]=P,e[27]=A,e[28]=F):F=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const E=u?String(u.height):"";let T;e[30]!==m?(T=re=>m("height",re.target.value),e[30]=m,e[31]=T):T=e[31];let $;e[32]!==a?($=a("contextPanel.browser.device.height"),e[32]=a,e[33]=$):$=e[33];let O;e[34]!==E||e[35]!==T||e[36]!==$?(O=n.jsx("input",{value:E,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":$,className:b}),e[34]=E,e[35]=T,e[36]=$,e[37]=O):O=e[37];let K;e[38]!==r||e[39]!==s?(K=()=>r(v0(s)),e[38]=r,e[39]=s,e[40]=K):K=e[40];const I=!u;let X;e[41]!==a?(X=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=X):X=e[42];let N;e[43]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx(Z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=N):N=e[43];let C;e[44]!==K||e[45]!==I||e[46]!==X?(C=n.jsx(At,{asChild:!0,children:n.jsx(Ct,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:K,disabled:I,"aria-label":X,children:N})}),e[44]=K,e[45]=I,e[46]=X,e[47]=C):C=e[47];let R;e[48]!==a?(R=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=R):R=e[49];let H;e[50]!==R?(H=n.jsx(Tt,{sideOffset:6,children:R}),e[50]=R,e[51]=H):H=e[51];let M;e[52]!==C||e[53]!==H?(M=n.jsxs(Ot,{children:[C,H]}),e[52]=C,e[53]=H,e[54]=M):M=e[54];let _;e[55]!==l||e[56]!==u?(_=u&&l<1?n.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=_):_=e[57];let B;e[58]===Symbol.for("react.memo_cache_sentinel")?(B=["system","light","dark"],e[58]=B):B=e[58];let ee;e[59]!==o||e[60]!==i||e[61]!==a?(ee=n.jsx("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:B.map(re=>n.jsx(Ct,{type:"button",variant:o===re?"secondary":"ghost",size:"xs",className:ke("shrink-0 rounded-full px-2.5 typography-micro",o===re?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(re),"aria-pressed":o===re,children:a(re==="system"?"contextPanel.browser.device.schemeSystem":re==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},re))}),e[59]=o,e[60]=i,e[61]=a,e[62]=ee):ee=e[62];let ne;return e[63]!==j||e[64]!==F||e[65]!==O||e[66]!==M||e[67]!==_||e[68]!==ee?(ne=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,F,D,O,M,_,ee]}),e[63]=j,e[64]=F,e[65]=O,e[66]=M,e[67]=_,e[68]=ee,e[69]=ne):ne=e[69],ne};function P0(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const fh="oc.browser.hiddenDevServerPorts.v1",E0=Xa(rn(),qo(E1().int().positive())),oa=new Set,hh=[];let Hr=null;const il=()=>{const t=Yd().getItem(fh);if(Hr&&Hr.raw===t)return Hr.value;let e={};if(t!==null)try{const s=E0.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return Hr={raw:t,value:e},e},ph=t=>{Yd().setItem(fh,JSON.stringify(t));for(const e of oa)e()},N0=(t=Yt())=>il()[t]??hh,R0=t=>{const e=Yt(),s=il(),r=s[e]??[];r.includes(t)||ph({...s,[e]:[...r,t].sort((o,i)=>o-i)})},D0=()=>{const t=Yt(),e=il();if(!e[t])return;const s={...e};delete s[t],ph(s)},I0=t=>(oa.add(t),()=>{oa.delete(t)}),T0=()=>c.useSyncExternalStore(I0,M0,A0);function M0(){return N0()}function A0(){return hh}const O0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},B0=2e3,F0=t=>qu("http://localhost",t),mh=t=>{const e=Ke.c(51),{onOpen:s,directory:r}=t,o=r===void 0?"":r,{t:i}=vt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=dy(o);let f;e[1]!==o?(f=()=>F0(o),e[1]=o,e[2]=f):f=e[2];const[h]=c.useState(f);let m;e[3]!==o?(m=()=>fy(o),e[3]=o,e[4]=m):m=e[4];const[g]=c.useState(m);let b;e[5]!==o?(b=rm(o),e[5]=o,e[6]=b):b=e[6];const v=b,x=ol(o),S=om(o);let p,y;e[7]!==o||e[8]!==S?(p=()=>{if(S){d({kind:"ready",servers:[]});return}let R=!0,H=null;const M=new AbortController,_=()=>{vw(M.signal,o).then(B=>{R&&(d(B),H=setTimeout(_,B0))})};return _(),()=>{R=!1,H&&clearTimeout(H),M.abort()}},y=[o,S],e[7]=o,e[8]=S,e[9]=p,e[10]=y):(p=e[9],y=e[10]),c.useEffect(p,y);const w=a.kind==="ready"?a.servers:null;let j;e[11]!==u||e[12]!==w?(j=jw({announced:u,discovered:w}),e[11]=u,e[12]=w,e[13]=j):j=e[13];const k=j,P=T0();let A;if(e[14]!==k||e[15]!==P){let R;e[17]!==P?(R=H=>H.announced||!P.includes(H.port),e[17]=P,e[18]=R):R=e[18],A=k.filter(R),e[14]=k,e[15]=P,e[16]=A}else A=e[16];const F=A,D=k.length-F.length;let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx(hy,{width:110,height:110,className:"shrink-0 opacity-20"}),e[19]=E):E=e[19];let T;e[20]!==i?(T=i("contextPanel.browser.empty"),e[20]=i,e[21]=T):T=e[21];let $;e[22]!==T?($=n.jsx("span",{className:"typography-ui-header text-foreground",children:T}),e[22]=T,e[23]=$):$=e[23];let O;e[24]!==i?(O=i("contextPanel.browser.emptyHint"),e[24]=i,e[25]=O):O=e[25];let K;e[26]!==O?(K=n.jsx("span",{className:"typography-micro text-muted-foreground",children:O}),e[26]=O,e[27]=K):K=e[27];let I;e[28]!==$||e[29]!==K?(I=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[$,K]}),e[28]=$,e[29]=K,e[30]=I):I=e[30];let X;e[31]!==u||e[32]!==k.length||e[33]!==o||e[34]!==D||e[35]!==v||e[36]!==s||e[37]!==h||e[38]!==x||e[39]!==g||e[40]!==i||e[41]!==F?(X=k.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:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),h&&!g?n.jsx("span",{className:"shrink-0 pb-1 text-start typography-micro text-muted-foreground",children:i("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(R=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(Ct,{type:"button",variant:"outline",size:"sm",className:ke("min-w-0 flex-1 justify-start gap-2",h&&"cursor-default opacity-60"),"aria-disabled":h||void 0,onClick:()=>{h||(uy(o),s(R.url))},children:[v?n.jsx("span",{className:"shrink-0",role:"img","aria-label":x??i("contextPanel.browser.spaceAddress"),title:x??i("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:_o(R.url)||R.url}),g?n.jsx("span",{className:"ms-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("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:O0(R.url)})]}),R.announced?null:n.jsx(Ct,{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:()=>R0(R.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:R.port}),title:i("contextPanel.browser.devServers.hide",{port:R.port}),children:n.jsx(Z,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},R.port))}),D>0?n.jsx(Ct,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:D0,children:D===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:D}):i("contextPanel.browser.devServers.showHiddenPlural",{count:D})}):null]}):null,e[31]=u,e[32]=k.length,e[33]=o,e[34]=D,e[35]=v,e[36]=s,e[37]=h,e[38]=x,e[39]=g,e[40]=i,e[41]=F,e[42]=X):X=e[42];let N;e[43]!==k.length||e[44]!==a.kind||e[45]!==i?(N=k.length===0&&a.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[43]=k.length,e[44]=a.kind,e[45]=i,e[46]=N):N=e[46];let C;return e[47]!==I||e[48]!==X||e[49]!==N?(C=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:[E,I,X,N]}),e[47]=I,e[48]=X,e[49]=N,e[50]=C):C=e[50],C},ks=t=>Math.round(t),_0=(t,e)=>{const s=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),o=t.ancestry.map(a=>a.selectorPart).join(" > "),i=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,s?`- Text: ${s}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${ks(l.x)}, y=${ks(l.y)}, width=${ks(l.width)}, height=${ks(l.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(a=>typeof a=="string")},L0=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${ks(s.x)}, y=${ks(s.y)}, width=${ks(s.width)}, height=${ks(s.height)}`},$0=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${ks(s.x)}, y=${ks(s.y)}, width=${ks(s.width)}, height=${ks(s.height)}`},z0=({payload:t,screenshotAttached:e,intro:s})=>{const r=s.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${ks(t.viewport.width)}x${ks(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[l,a]of t.elements.entries())i.push("",..._0(a.element,l));return t.regions.length>0&&(i.push(""),t.regions.forEach((l,a)=>i.push(L0(l,a)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((l,a)=>i.push($0(l,a)))),i.filter(l=>typeof l=="string").join(`
1044
+ `)},K0=t=>{const e=Ke.c(7),{t:s}=vt(),r=nt(H0),o=nt(V0),i=py(G0),l=my(U0);let a;return e[0]!==l||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==s?(a=async d=>{const u=r??(o?"draft":null);if(!u){Le.error(s("contextPanel.browser.annotate.noSession"));return}let f=!1;if(d.screenshot)try{await l(d.screenshot),f=!0}catch{f=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:z0({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.success(s("contextPanel.browser.annotate.attached")),requestAnimationFrame(gy)},e[0]=l,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=s,e[6]=a):a=e[6],a},W0=()=>{const t=Ke.c(16),{t:e}=vt();let s;t[0]!==e?(s=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=s):s=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==s||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==l?(a={select:s,marquee:r,draw:o,commentPlaceholder:i,submit:l},t[10]=s,t[11]=r,t[12]=o,t[13]=i,t[14]=l,t[15]=a):a=t[15],a};function H0(t){return t.currentSessionId}function V0(t){return t.newSessionDraft?.open}function G0(t){return t.addDraft}function U0(t){return t.addAttachedFile}const q0=3e4,Y0=3,X0=250,Q0={attempts:0,windowStartedAt:null},Z0=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=q0,r=s?0:t.attempts;return r>=Y0?null:{delayMs:X0*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},J0=-3,Vr=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",$n=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},ek=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:Ew),[i,l]=c.useState(e),[a,d]=c.useState(""),[u,f]=c.useState(!1),[h,m]=c.useState(!1),g=c.useRef(s);g.current=s;const b=c.useRef(Q0);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return Vr(D)?D:""}catch{return""}},x=()=>{try{f(t.canGoBack()),m(t.canGoForward())}catch{}},S=D=>{Vr(D)&&(l(D),g.current(D))},p=()=>{const D=v();o({kind:"loading",url:D})},y=()=>{const D=v();let E="";try{E=t.getTitle()||""}catch{E=""}d(E),S(D),x(),o(T=>T.kind==="failed"?T:{kind:"ready",url:D,title:E})},w=D=>{const E=$n(D);Vr(E.url)&&(S(E.url),x())},j=D=>{const E=$n(D),T=Array.isArray(E.favicons)?E.favicons.find(Boolean):"",$=v();if(!T||!$)return;let O=-1;try{O=t.getWebContentsId()}catch{return}!Number.isFinite(O)||O<0||zf.getState().resolve($,T,O)},k=D=>{const E=$n(D);typeof E.title=="string"&&d(E.title)},P=D=>{const E=$n(D);if(E.isMainFrame===!1)return;const T=typeof E.errorCode=="number"?E.errorCode:0;T!==J0&&o({kind:"failed",url:Vr(E.validatedURL)?E.validatedURL:v(),code:T,description:typeof E.errorDescription=="string"?E.errorDescription:""})};let A=null;const F=()=>{const D=v(),E=Z0(b.current,Date.now());if(!E){o({kind:"failed",url:D,code:0,description:"",crashed:!0});return}b.current=E.state,o({kind:"loading",url:D}),A=setTimeout(()=>{A=null;try{t.reload()}catch{o({kind:"failed",url:D,code:0,description:"",crashed:!0})}},E.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",w),t.addEventListener("did-navigate-in-page",w),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",P),t.addEventListener("render-process-gone",F),t.addEventListener("crashed",F);try{!t.isLoading()&&v()&&y()}catch{}return()=>{A!==null&&clearTimeout(A),t.removeEventListener("render-process-gone",F),t.removeEventListener("crashed",F),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",w),t.removeEventListener("did-navigate-in-page",w),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",P)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:h}},zc=1e3,gh=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},tk=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},sk=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},nk=(t,e)=>{const s=c.useRef(0),r=c.useRef(0),o=c.useRef(0),i=c.useRef(null),l=c.useCallback(()=>{if(!t||document.activeElement!==t)return;const a=i.current;a&&a.isConnected&&a!==document.body?a.focus({preventScroll:!0}):t.blur()},[t]);return c.useEffect(()=>{if(!t)return;document.activeElement!==t&&(i.current=sk());const a=d=>{if(document.activeElement!==t){i.current=tk(d);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&gh(u)&&!f||r.current>0||l()};return document.addEventListener("focusin",a,!0),()=>document.removeEventListener("focusin",a,!0)},[l,e,t]),c.useCallback(async a=>{const d=t!==null&&document.activeElement===t;let u=!1;const f=()=>{u&&(u=!1,r.current-=1,o.current=Date.now()+zc,!d&&r.current===0&&l())},h=()=>(u||(u=!0,r.current+=1),f);s.current+=1;try{return await a(h)}finally{s.current-=1,o.current=Date.now()+zc,f()}},[l,t])},rk=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)),ok=()=>document.visibilityState==="visible",ik=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Gr=.5,ak=-3,lk=4,ck="persist:openchamber-browser",bh=(t,e,s)=>Ls(t)!==null&&Qd(e)?{icon:"box-3",label:s}:void 0,Kc=t=>{const e=Ls(t);return e?`openchamber-space-preview:${e}`:ck},Wc=20,dk=600,uk=2e4,fk=15e3,hk=t=>{if(!t||gh(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}},pk=({initialUrl:t,directory:e,tabID:s,ownerSessionId:r,visible:o})=>{const{t:i}=vt(),{currentTheme:l}=Pr(),a=c.useRef(null),[d,u]=c.useState(null),f=c.useCallback(me=>{a.current=me,u(me)},[]),h=ue(me=>me.setContextPanelTabTargetPath),m=c.useRef(Kn(t)),g=m.current!==fn?m.current:"",[b,v]=c.useState(g?null:fn),x=ol(e),[S,p]=c.useState(g),[y,w]=c.useState(!1),[j,k]=c.useState(!1),[P,A]=c.useState(0),F=c.useRef(0),[D,E]=c.useState(!1),[T,$]=c.useState(No),O=c.useRef(T);O.current=T;const K=c.useRef([]),[I,X]=c.useState("system"),[N,C]=c.useState({width:0,height:0}),R=c.useRef(null),H=c.useRef(null),M=vs(e),_=c.useRef(!!g&&!im(M,s)),B=c.useRef(null);c.useEffect(()=>{Xd(M,s)},[M,s]);const ee=c.useRef(!1),ne=c.useRef(Date.now()),re=c.useCallback(me=>{!me||me===fn||!e||!s||h(e,s,me)},[e,s,h]),te=ek(d,{initialUrl:g,onUrlChange:c.useCallback(me=>{const Ne=Bn(me);p(Ne),re(Ne)},[re])}),[W,q]=c.useState(null),[oe,de]=c.useState(Ls(e)===null);c.useEffect(()=>{const me=Ls(e);if(me===null){de(!0);return}let Ne=!0;return de(!1),Fn("desktop_space_preview_prepare",{spaceId:me}).then(()=>{Ne&&de(!0)}).catch(()=>{Ne&&q(g||"http://localhost/")}),()=>{Ne=!1}},[e,g]);const ce=K0(e),je=W0(),be=te.status.kind==="loading",pe=Hn(lh(e)),U=Hn(me=>me.recordVisit),Pe=Hn(me=>me.forget);c.useEffect(()=>{te.status.kind==="ready"&&U(e,{url:Bn(te.status.url),title:te.status.title})},[e,te.status,U]);const xe=c.useMemo(()=>ah(pe,S),[pe,S]),Ee=c.useCallback(me=>{const Ne=Kn(me);Ne!==fn&&(_.current=!1,p(Ne),q(null),Xl(Ne,e).then(qe=>{const Ye=a.current;if(!Ye){v(qe);return}try{Ye.loadURL(qe)}catch{v(qe)}}).catch(qe=>{qe instanceof Ql&&q(Ne)}))},[e]);c.useEffect(()=>{if(!g)return;let me=!0;return Xl(g,e).then(Ne=>{me&&v(Ne)}).catch(Ne=>{if(me){if(Ne instanceof Ql){q(g),_.current=!1,v(fn);return}v(g)}}),()=>{me=!1}},[]);const L=c.useMemo(()=>({executeJavaScript:async(me,Ne)=>{const qe=a.current;if(!qe)throw new Error("Browser view is not available");return qe.executeJavaScript(me,Ne)},capturePage:async()=>{const me=a.current;if(!me)return null;const Ne=me.getWebContentsId();return Number.isFinite(Ne)?await Fn("desktop_browser_capture_page",{webContentsId:Ne}):null}}),[]),ie=c.useCallback(()=>{if(y){w(!1),co(L);return}if(!te.url){Le.error(i("contextPanel.browser.annotate.noPage"));return}const me=zw(l.metadata.variant==="light"?"light":"dark");w(!0),Lw({host:L,theme:me,labels:je}).then(async Ne=>{w(!1),Ne&&await ce(Ne)}).catch(()=>{w(!1),Le.error(i("contextPanel.browser.annotate.failed"))})},[L,ce,l,y,te.url,je,i]);c.useEffect(()=>{if(!y)return;const me=Ne=>{by(Ne)||Ne.key!=="Escape"||(Ne.preventDefault(),Ne.stopImmediatePropagation(),w(!1),co(L))};return window.addEventListener("keydown",me,!0),()=>window.removeEventListener("keydown",me,!0)},[L,y]);const G=c.useRef(!1);c.useEffect(()=>{if(!d)return;const me=()=>{G.current=!0};return d.addEventListener("dom-ready",me),d.addEventListener("did-fail-load",me),()=>{d.removeEventListener("dom-ready",me),d.removeEventListener("did-fail-load",me)}},[d]);const ae=c.useCallback(async()=>{const me=Date.now()+fk;for(;!(a.current&&G.current)&&Date.now()<me;)await new Promise(Ne=>setTimeout(Ne,100));return a.current},[]),ye=c.useCallback(async(me=8e3)=>{const Ne=Date.now();for(;;){const qe=a.current;if(!qe)return!1;let Ye=!1;try{Ye=qe.isLoading()}catch{return!1}if(!Ye)return!0;if(Date.now()-Ne>me)return!1;await new Promise($e=>setTimeout($e,120))}},[]),ge=c.useCallback(async(me,Ne,qe)=>{const Ye=await ae();if(!Ye)throw new Error("The browser panel is not ready");const $e=()=>{$c(Ne.viewport)&&($(ra(Ne.viewport)),E(!0))};if(me==="browser.back"||me==="browser.forward"){const xt=me==="browser.back";if(!(xt?Ye.canGoBack():Ye.canGoForward()))throw new Error(xt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");xt?Ye.goBack():Ye.goForward(),await new Promise($t=>setTimeout($t,150)),await ye();let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{url:Bn(Ye.getURL()),title:jt}}if(me==="browser.capture"){const xt=hk(R.current);try{await new Promise($t=>{requestAnimationFrame(()=>requestAnimationFrame(()=>$t()))}),await ye();const Mt=await L.capturePage();if(!Mt)throw new Error("The page could not be captured");let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{...Mt,url:Bn(Ye.getURL()),title:jt,viewport:Wr(O.current)}}finally{xt()}}if(me==="browser.resize"){if(!$c(Ne.viewport))throw new Error("viewport is required");return $e(),await new Promise(xt=>setTimeout(xt,200)),await ye(),{viewport:Wr(ra(Ne.viewport))}}if(me==="browser.open"){const xt=typeof Ne.url=="string"?Ne.url:"";if(!xt)throw new Error("url is required");$e(),Ee(xt),await new Promise($t=>setTimeout($t,150));const Mt=await ye(25e3);let jt="";try{jt=Ye.getTitle()||""}catch{jt=""}return{url:Kn(xt),title:jt,opened:!0,settled:Mt,viewport:Wr(O.current)}}await ye();const tt=xt=>typeof xt=="string"&&xt?xt:void 0,wt=(()=>{switch(me){case"browser.snapshot":return h0({selector:tt(Ne.selector)});case"browser.click":return p0({selector:tt(Ne.selector),text:tt(Ne.text)});case"browser.type":return m0({selector:String(Ne.selector??""),value:String(Ne.value??""),submit:Ne.submit===!0});case"browser.inspect":return y0({selector:String(Ne.selector??"")});case"browser.scroll":return g0({selector:tt(Ne.selector),direction:tt(Ne.direction)});default:return null}})();if(!wt)throw new Error(`Unsupported browser action: ${me}`);let Bt=()=>{};(me==="browser.click"||me==="browser.type")&&(await Fn("desktop_browser_keep_page_focused",{webContentsId:Ye.getWebContentsId()}).then(Mt=>Mt.focused===!0).catch(()=>!1)||(Bt=qe(),Ye.focus({preventScroll:!0})));let kt;try{kt=await Ye.executeJavaScript(wt,!0)}finally{Bt()}if(!kt||typeof kt!="object")throw new Error("The page returned no result");const St=kt;if(St.ok!==!0)throw new Error(typeof St.error=="string"&&St.error?St.error:"Browser action failed");if(me==="browser.snapshot"){const xt=K.current;return{...St,viewport:Wr(O.current),...xt.length>0?{consoleProblems:[...xt]}:{}}}return(me==="browser.click"||me==="browser.type"&&Ne.submit===!0)&&(await new Promise(xt=>setTimeout(xt,150)),await ye()),kt},[L,Ee,ye,ae]),Se=nk(d,R),[ve,Te]=c.useState(!1),z=c.useCallback((me,Ne)=>(Te(!0),Se(qe=>ge(me,Ne,qe))),[Se,ge]),he=c.useCallback(()=>{const me=a.current;if(!me)return{title:"",url:""};let Ne="",qe="";try{Ne=me.getTitle()||""}catch{Ne=""}try{qe=Bn(me.getURL())}catch{qe=""}return{title:Ne,url:qe}},[]);c.useEffect(()=>Xw({tabId:s,directory:M,ownerSessionId:r,describe:he,run:z}),[he,r,z,M,s]),c.useEffect(()=>{const me=L;return()=>{co(me)}},[L]),c.useEffect(()=>{if(!d)return;const me=qe=>{const Ye=qe;if(typeof Ye.level!="number"||Ye.level<2)return;const $e=Ye.sourceId?`${Ye.sourceId}${Ye.line?`:${Ye.line}`:""}`:"";K.current.push({level:Ye.level>=3?"error":"warning",message:String(Ye.message??"").slice(0,400),source:$e}),K.current.length>Wc&&K.current.splice(0,K.current.length-Wc)},Ne=()=>{K.current=[]};return d.addEventListener("console-message",me),d.addEventListener("did-start-loading",Ne),()=>{d.removeEventListener("console-message",me),d.removeEventListener("did-start-loading",Ne)}},[d]);const se=c.useRef(new Set),Re=c.useCallback(me=>{se.current.clear(),Ee(me)},[Ee]),Ue=c.useRef(te.status);Ue.current=te.status;const We=c.useRef(!1);te.status.kind==="ready"&&te.status.url&&(We.current=!0),c.useEffect(()=>am(M,s,me=>{cm(Ue.current,We.current)&&Re(me)}),[Re,M,s]),c.useEffect(()=>{if(!d)return;const me=qe=>{const Ye=$n(qe),$e=typeof Ye.url=="string"?Ye.url:"";!$e||!Zl($e,e)||(qe.preventDefault(),Ee($e))},Ne=qe=>{const Ye=$n(qe);if(Ye.isMainFrame===!1||Ye.errorCode===-3)return;const $e=typeof Ye.validatedURL=="string"?Ye.validatedURL:"";!$e||!Zl($e,e)||se.current.has($e)||(se.current.add($e),Ee($e))};return d.addEventListener("will-navigate",me),d.addEventListener("did-fail-load",Ne),()=>{d.removeEventListener("will-navigate",me),d.removeEventListener("did-fail-load",Ne)}},[e,Ee,d]),c.useEffect(()=>{if(!d)return;const me=Ne=>{const qe=Ne.detail;Ne.preventDefault(),qe?.url&&Ee(qe.url)};return d.addEventListener("new-window",me),()=>d.removeEventListener("new-window",me)},[Ee,d]);const He=c.useCallback(me=>{const Ne=Math.min(lk,Math.max(ak,me));F.current=Ne,A(Ne);try{a.current?.setZoomLevel(Ne)}catch{}},[]);c.useEffect(()=>{const me=Ne=>{if(!(Ne instanceof CustomEvent))return;const qe=Ne.detail,Ye=a.current;!Ye||document.activeElement!==Ye||(qe==="zoom-in"?He(F.current+Gr):qe==="zoom-out"?He(F.current-Gr):qe==="zoom-reset"&&He(0))};return window.addEventListener("openchamber:zoom",me),()=>window.removeEventListener("openchamber:zoom",me)},[He]);const Be=c.useCallback(me=>{Fn("desktop_browser_clear_data",{partition:Kc(e),cookies:me==="cookies",cache:me==="cache"}).then(()=>{Le.success(i(me==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{a.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(i("contextPanel.browser.clearFailed")))},[e,i]);c.useEffect(()=>{const me=R.current;if(!me||typeof ResizeObserver>"u")return;const Ne=new ResizeObserver(qe=>{const Ye=qe[0]?.contentRect;Ye&&C({width:Ye.width,height:Ye.height})});return Ne.observe(me),()=>Ne.disconnect()},[]);const Y=c.useCallback(me=>{X(me);const Ne=a.current;if(!Ne)return;let qe=-1;try{qe=Ne.getWebContentsId()}catch{return}Fn("desktop_browser_set_color_scheme",{webContentsId:qe,scheme:me}).catch(Ye=>{X("system"),Le.error(Ye instanceof Error?Ye.message:i("contextPanel.browser.device.schemeFailed"))})},[i]),Me=c.useCallback(()=>{try{be?a.current?.stop():a.current?.reload()}catch{}},[be]),Ge=te.status,Ve=c.useSyncExternalStore(rk,ok),dt=o&&Ve||r!==null||ve;c.useEffect(()=>{const me=tt=>{k(!0);const ht=setTimeout(()=>{try{a.current?.reload()}catch{}},tt);return()=>clearTimeout(ht)};if(Ge.kind==="loading")return;const Ne=_.current||B.current===Ge;if(_.current&&(Ge.kind==="failed"||Ge.kind==="ready"&&Ge.url)&&(_.current=!1,B.current=Ge),Ge.kind==="failed"){const tt=lm(Ge,{run:H.current,restored:Ne,watched:dt,now:Date.now()});if(H.current=tt.run,tt.next==="retry")return me(tt.delayMs);k(tt.next==="pause");return}if(H.current=null,Ge.kind!=="ready"||!Ge.url||!Qd(Ge.url)){ee.current=!0,k(!1);return}if(Ne||ee.current||Date.now()-ne.current>uk){ee.current=!0,k(!1);return}let qe=!1,Ye=null;return(Ls(e)?Promise.resolve(null):ww(Bn(Ge.url))).then(tt=>{if(!qe){if(tt===null||tt<500){ee.current=!0,k(!1);return}Ye=me(dk)}}),()=>{qe=!0,Ye?.()}},[e,Ge,dt]);const et=te.status.kind==="failed"&&!j?te.status:null,ct=w0(T,N);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(ch,{address:S,onAddressChange:p,onSubmit:Re,suggestions:xe,onForgetSuggestion:me=>Pe(e,me),onBack:()=>{try{a.current?.goBack()}catch{}},onForward:()=>{try{a.current?.goForward()}catch{}},onReload:Me,onOpenExternal:()=>{Oa(te.url||S)},addressMark:bh(e,S,x??i("contextPanel.browser.spaceAddress")),canOpenExternal:Ls(e)===null,canGoBack:te.canGoBack,canGoForward:te.canGoForward,isLoading:be,onAnnotate:ie,isAnnotating:y,onOpenDevTools:()=>{try{a.current?.openDevTools()}catch{}},onHardReload:()=>{try{a.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>He(P+Gr),onZoomOut:()=>He(P-Gr),onZoomReset:()=>He(0),zoomPercent:Math.round(Math.pow(1.2,P)*100),onClearCookies:()=>Be("cookies"),onClearCache:()=>Be("cache"),onToggleDeviceBar:()=>E(me=>!me),isDeviceBarOpen:D}),D?n.jsx(C0,{viewport:T,onViewportChange:$,colorScheme:I,onColorSchemeChange:Y,scale:ct?.scale??1}):null,n.jsxs("div",{ref:R,className:ke("relative min-h-0 flex-1 bg-background",ct&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[b!==null&&oe?n.jsx("webview",{ref:f,src:b,partition:Kc(e),allowpopups:!0,style:ct?{width:`${ct.width}px`,height:`${ct.height}px`,transform:`scale(${ct.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,b!==null&&!g&&!te.url&&!be?n.jsx(mh,{onOpen:Re,directory:e}):null,j?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:i("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.waitingForServerHint")})]}):null,W?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[Ls(e)!==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:i("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i(Ls(e)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:W})})]}):null,et&&!W?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:et.crashed?i("contextPanel.browser.crashed"):i("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:et.crashed?i("contextPanel.browser.crashedHint"):et.description||i("contextPanel.browser.loadFailedUnknown")})]}):null,be?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 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},mk=t=>{const e=Ke.c(74),{initialUrl:s,directory:r,tabID:o}=t,{t:i}=vt(),l=ue(bk);let a;e[0]!==s?(a=Kn(s),e[0]=s,e[1]=a):a=e[1];const d=a,u=d!==fn?d:"",[f,h]=c.useState(u);let m;e[2]!==r||e[3]!==u?(m=di(u,r),e[2]=r,e[3]=u,e[4]=m):m=e[4];const[g,b]=c.useState(m);let v;e[5]!==r||e[6]!==u?(v=qu(u,r)?u:"",e[5]=r,e[6]=u,e[7]=v):v=e[7];const[x,S]=c.useState(v);let p;e[8]!==r?(p=Ls(r),e[8]=r,e[9]=p):p=e[9];const y=p!==null,w=ol(r);let j;e[10]!==u?(j=u?[u]:[],e[10]=u,e[11]=j):j=e[11];const[k,P]=c.useState(j),[A,F]=c.useState(u?0:-1),[D,E]=c.useReducer(yk,0);let T,$;e[12]!==r||e[13]!==o?(T=()=>{Xd(vs(r),o)},$=[r,o],e[12]=r,e[13]=o,e[14]=T,e[15]=$):(T=e[14],$=e[15]),c.useEffect(T,$);let O;e[16]!==r||e[17]!==l||e[18]!==o?(O=Pe=>{!Pe||Pe===fn||!r||!o||l(r,o,Pe)},e[16]=r,e[17]=l,e[18]=o,e[19]=O):O=e[19];const K=O;let I;e[20]!==r?(I=lh(r),e[20]=r,e[21]=I):I=e[21];const X=Hn(I),N=Hn(xk),C=Hn(Sk);let R;e[22]!==f||e[23]!==X?(R=ah(X,f),e[22]=f,e[23]=X,e[24]=R):R=e[24];const H=R;let M;e[25]!==r||e[26]!==A||e[27]!==K||e[28]!==N?(M=Pe=>{const xe=Kn(Pe);if(xe===fn)return;h(xe);const Ee=di(xe,r);b(Ee),S(Ee?"":xe),K(xe),N(r,{url:xe}),P(L=>{const ie=A>=0?L.slice(0,A+1):[];return ie[ie.length-1]===xe?(F(ie.length-1),ie):(F(ie.length),[...ie,xe])})},e[25]=r,e[26]=A,e[27]=K,e[28]=N,e[29]=M):M=e[29];const _=M;let B;e[30]!==r||e[31]!==k||e[32]!==K?(B=Pe=>{const xe=k[Pe];if(!xe)return;F(Pe),h(xe);const Ee=di(xe,r);b(Ee),S(Ee?"":xe),K(xe)},e[30]=r,e[31]=k,e[32]=K,e[33]=B):B=e[33];const ee=B;let ne;e[34]!==r||e[35]!==C?(ne=Pe=>C(r,Pe),e[34]=r,e[35]=C,e[36]=ne):ne=e[36];let re,te;e[37]!==ee||e[38]!==A?(re=()=>ee(A-1),te=()=>ee(A+1),e[37]=ee,e[38]=A,e[39]=re,e[40]=te):(re=e[39],te=e[40]);let W;e[41]!==f||e[42]!==g?(W=()=>{Oa(g||f)},e[41]=f,e[42]=g,e[43]=W):W=e[43];let q;e[44]!==w||e[45]!==i?(q=w??i("contextPanel.browser.spaceAddress"),e[44]=w,e[45]=i,e[46]=q):q=e[46];let oe;e[47]!==f||e[48]!==r||e[49]!==q?(oe=bh(r,f,q),e[47]=f,e[48]=r,e[49]=q,e[50]=oe):oe=e[50];const de=!x,ce=A>0,je=A>=0&&A<k.length-1;let be;e[51]!==f||e[52]!==_||e[53]!==H||e[54]!==ne||e[55]!==re||e[56]!==te||e[57]!==W||e[58]!==oe||e[59]!==de||e[60]!==ce||e[61]!==je?(be=n.jsx(ch,{address:f,onAddressChange:h,onSubmit:_,suggestions:H,onForgetSuggestion:ne,onBack:re,onForward:te,onReload:E,onOpenExternal:W,addressMark:oe,canOpenExternal:de,canGoBack:ce,canGoForward:je,isLoading:!1}),e[51]=f,e[52]=_,e[53]=H,e[54]=ne,e[55]=re,e[56]=te,e[57]=W,e[58]=oe,e[59]=de,e[60]=ce,e[61]=je,e[62]=be):be=e[62];let pe;e[63]!==r||e[64]!==y||e[65]!==g||e[66]!==_||e[67]!==D||e[68]!==i||e[69]!==x?(pe=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[y?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:i(y?"contextPanel.browser.spaceLoopback.title":"contextPanel.browser.remoteLoopback.title",{url:_o(x)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.remoteLoopback.hint")})]}):g?n.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${D}`):n.jsx(mh,{onOpen:_,directory:r})}),e[63]=r,e[64]=y,e[65]=g,e[66]=_,e[67]=D,e[68]=i,e[69]=x,e[70]=pe):pe=e[70];let U;return e[71]!==be||e[72]!==pe?(U=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[be,pe]}),e[71]=be,e[72]=pe,e[73]=U):U=e[73],U},gk=t=>{const e=Ke.c(3),[s]=c.useState(ik);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(pk,{...t}):n.jsx(mk,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function bk(t){return t.setContextPanelTabTargetPath}function yk(t){return t+1}function xk(t){return t.recordVisit}function Sk(t){return t.forget}const vk=t=>{const e=Ke.c(13),{zone:s,children:r}=t,[o]=c.useState(wk);let i;e[0]!==s?(i=m=>m.body[s],e[0]=s,e[1]=i):i=e[1];const l=wr(i);let a,d;e[2]!==l||e[3]!==o||e[4]!==s?(a=()=>{const m=l??wr.getState().body[s];if(!m){o.remove();return}if(o.parentElement===m)return;const g=document.activeElement;m.moveBefore&&o.isConnected?m.moveBefore(o,null):m.append(o),g instanceof HTMLElement&&o.contains(g)&&document.activeElement!==g&&g.focus({preventScroll:!0})},d=[l,o,s],e[2]=l,e[3]=o,e[4]=s,e[5]=a,e[6]=d):(a=e[5],d=e[6]),c.useLayoutEffect(a,d);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]),c.useLayoutEffect(u,f);let h;return e[10]!==r||e[11]!==o?(h=ya.createPortal(r,o),e[10]=r,e[11]=o,e[12]=h):h=e[12],h};function wk(){const t=document.createElement("div");return t.style.display="contents",t}const ia=2e4,kk=(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},Ur=(t,e)=>dm(um.getState().dictionary,t,e),jk=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"},Ck=async(t,e,s)=>{const r=!!(s?.directory&&!wy(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 an(`/api/fs/read?${o.toString()}`,{cache:"no-store",headers:s?.directory?{"x-opencode-directory":s.directory}:void 0});if(!i.ok){const l=await i.json().catch(()=>({error:i.statusText}));throw new Error(l.error||"Failed to read file")}return i.text()},Pk=async(t,e,s)=>{if(yy(e)||xy(e)||Sy(e))return{ok:!0};try{const r=await Ck(t,e,s);return vy(r)?{ok:!1,reason:"binary"}:kk(r,ia)>ia?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:jk(r)}}},Ek=t=>{if(t==="too-large"){const e=ia.toLocaleString(Vu());return Ur("contextFileOpen.failure.tooLarge",{count:e})}return Ur(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Hc=8;let kr=null;const yh=(t,e)=>Math.abs(e.clientX-t.x)<=Hc&&Math.abs(e.clientY-t.y)<=Hc,xh=t=>{kr={x:t.clientX,y:t.clientY}},Sh=t=>{const e=kr;return kr=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:yh(e,t)},vh=t=>kr!==null&&yh(kr,t);let wh=null;const Vc=t=>{wh=t},kh=()=>wh,Gc=t=>{const e=t.lastIndexOf("/");return e<0?"":e===0?"/":t.slice(0,e)},jh=(t,e,s)=>{const r=e===null?s:e.type==="directory"?e.path:Gc(e.path);return!r||Gc(t.path)===r||t.type==="directory"&&fm(r,t.path,t.path)!==null?null:r},Nk=(t,e)=>{const s=t.path.slice(t.path.lastIndexOf("/")+1);return e.endsWith("/")?`${e}${s}`:`${e}/${s}`},Vn=t=>Array.from(t.types).includes("Files"),xr=t=>Array.from(t.types).includes(Ho)?kh():null,Ch=(t,e,s)=>t.getData(Ho)===Xo(e,s.path),Rk=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]:[]})},Dk=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),rs=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},Xo=(t,e)=>{const s=rs(e),r=rs(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},ar=(t,e)=>{const s=Xo(t,e);if(s!==".")return s;const r=rs(t);return r.split("/").filter(Boolean).pop()??r},ho=t=>{const e=rs(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},Ik=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),Tk=new Set(["node_modules"]),Mk=t=>Tk.has(t),Ak=t=>{const e=rs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Ok=8,Gs=new Map,al=t=>JSON.stringify([Yt(),t]),Bk=t=>{const e=al(t),s=Gs.get(e);return s?(s.touchedAt=Date.now(),Gs.delete(e),Gs.set(e,s),s):null},wi=t=>{const e=al(t),s=Gs.get(e);if(s)return s.touchedAt=Date.now(),s;if(Gs.size>=Ok){const o=Gs.keys().next().value;o!==void 0&&Gs.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Gs.set(e,r),r},Fk=t=>{const e=Ke.c(127),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:l,depth:a,isOpen:d,status:u,badge:f,isDropTarget:h,isDragSource:m,canUpload:g,canMove:b,permissions:v,downloadFile:x,onSelect:S,onToggle:p,onRevealPath:y,onOpenDialog:w,onSetDropTarget:j,onDropFiles:k,onPickFiles:P,onMoveDragChange:A,onSetMoveDropTarget:F,onMoveDrop:D}=t,{t:E}=vt(),T=s.type==="directory";let $;e[0]!==T||e[1]!==s.path?($=T?s.path:ho(s.path),e[0]=T,e[1]=s.path,e[2]=$):$=e[2];const O=$,{canRename:K,canCreateFile:I,canCreateFolder:X,canDelete:N,canReveal:C}=v,R=!T&&!!x,H=C&&!l,M=T&&g,_=K||I||X||M||N||R||H,[B,ee]=c.useState(!1),[ne,re]=c.useState(!1);let te;e[3]!==_?(te=$e=>{_&&($e?.preventDefault(),re(!0))},e[3]=_,e[4]=te):te=e[4];const W=te;let q;e[5]!==T||e[6]!==s||e[7]!==S||e[8]!==p?(q=()=>{T?p(s.path):S(s)},e[5]=T,e[6]=s,e[7]=S,e[8]=p,e[9]=q):q=e[9];const oe=q;let de;e[10]!==T||e[11]!==s||e[12]!==S?(de=()=>{T||S(s,{pin:!0})},e[10]=T,e[11]=s,e[12]=S,e[13]=de):de=e[13];const ce=de;let je;e[14]===Symbol.for("react.memo_cache_sentinel")?(je=$e=>{$e.stopPropagation(),re(!1),ee(!0)},e[14]=je):je=e[14];const be=je;let pe;e[15]!==I||e[16]!==X||e[17]!==N||e[18]!==K||e[19]!==H||e[20]!==M||e[21]!==x||e[22]!==l||e[23]!==T||e[24]!==s||e[25]!==w||e[26]!==P||e[27]!==y||e[28]!==E?(pe=$e=>{const{Item:tt,Separator:ht}=$e;return n.jsxs(n.Fragment,{children:[K&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),w("rename",s)},children:[n.jsx(Z,{name:"edit",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.rename")]}),n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),Wo(s.path).then(Bt=>{if(Bt.ok){Le.success(E("sidebarFilesTree.toast.pathCopied"));return}Le.error(E("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(Z,{name:"file-copy",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.copyPath")]}),!T&&x&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),x(s.path).catch(Bt=>{console.error("Download failed:",Bt),Le.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"download",className:"me-2 h-4 w-4"})," ",E(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),H&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),y(s.path)},children:[n.jsx(Z,{name:"folder-received",className:"me-2 h-4 w-4"})," ",E(Yu())]}),!T&&H&&Lo()&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),hm(s.path).then(Bt=>{Bt||Le.error(E("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(Z,{name:"external-link",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.openInDefaultApp")]}),T&&(I||X||M)&&n.jsxs(n.Fragment,{children:[n.jsx(ht,{}),I&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),w("createFile",s)},children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFile")]}),X&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),w("createFolder",s)},children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.newFolder")]}),M&&n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),P(s.path)},children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.uploadFiles")]})]}),N&&n.jsxs(n.Fragment,{children:[n.jsx(ht,{}),n.jsxs(tt,{onClick:wt=>{wt.stopPropagation(),w("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"delete-bin",className:"me-2 h-4 w-4"})," ",E("sidebarFilesTree.menu.delete")]})]})]})},e[15]=I,e[16]=X,e[17]=N,e[18]=K,e[19]=H,e[20]=M,e[21]=x,e[22]=l,e[23]=T,e[24]=s,e[25]=w,e[26]=P,e[27]=y,e[28]=E,e[29]=pe):pe=e[29];const U=pe;let Pe;e[30]!==b||e[31]!==s.path||e[32]!==s.type||e[33]!==A||e[34]!==r?(Pe=$e=>{xh($e);const tt=Xo(r,s.path);!tt||tt==="."||($e.dataTransfer.setData(Ho,tt),$e.dataTransfer.effectAllowed=b?"copyMove":"copy",b&&A({path:s.path,type:s.type}))},e[30]=b,e[31]=s.path,e[32]=s.type,e[33]=A,e[34]=r,e[35]=Pe):Pe=e[35];const xe=Pe;let Ee;e[36]!==b||e[37]!==oe||e[38]!==A?(Ee=$e=>{b&&A(null),Sh($e)&&oe()},e[36]=b,e[37]=oe,e[38]=A,e[39]=Ee):Ee=e[39];const L=Ee;let ie;e[40]!==g||e[41]!==j||e[42]!==O?(ie=$e=>{!g||!O||!Vn($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),$e.dataTransfer.dropEffect="copy",j(O))},e[40]=g,e[41]=j,e[42]=O,e[43]=ie):ie=e[43];const G=ie;let ae;e[44]!==g||e[45]!==j||e[46]!==O?(ae=$e=>{!g||!O||!Vn($e.dataTransfer)||$e.relatedTarget instanceof Node&&$e.currentTarget.contains($e.relatedTarget)||($e.stopPropagation(),j(null))},e[44]=g,e[45]=j,e[46]=O,e[47]=ae):ae=e[47];const ye=ae;let ge;e[48]!==g||e[49]!==k||e[50]!==O?(ge=$e=>{!g||!O||!Vn($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),k(O,$e.dataTransfer))},e[48]=g,e[49]=k,e[50]=O,e[51]=ge):ge=e[51];const Se=ge;let ve;e[52]!==s.path||e[53]!==s.type||e[54]!==r?(ve=($e,tt)=>vh($e)?null:jh(tt,{path:s.path,type:s.type},r),e[52]=s.path,e[53]=s.type,e[54]=r,e[55]=ve):ve=e[55];const Te=ve;let z;e[56]!==b||e[57]!==Te||e[58]!==G||e[59]!==F?(z=$e=>{const tt=b?xr($e.dataTransfer):null;if(!tt){G($e);return}$e.stopPropagation();const ht=Te($e,tt);F(ht),ht&&($e.preventDefault(),$e.dataTransfer.dropEffect="move")},e[56]=b,e[57]=Te,e[58]=G,e[59]=F,e[60]=z):z=e[60];const he=z;let se;e[61]!==b||e[62]!==Te||e[63]!==Se||e[64]!==D||e[65]!==F||e[66]!==r?(se=$e=>{const tt=b?xr($e.dataTransfer):null;if(!tt){Se($e);return}$e.stopPropagation(),$e.preventDefault(),F(null);const ht=Te($e,tt);ht&&Ch($e.dataTransfer,r,tt)&&D(tt,ht)},e[61]=b,e[62]=Te,e[63]=Se,e[64]=D,e[65]=F,e[66]=r,e[67]=se):se=e[67];const Re=se;let Ue;e[68]===Symbol.for("react.memo_cache_sentinel")?(Ue={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[68]=Ue):Ue=e[68];let We;e[69]!==W||e[70]!==ye||e[71]!==he||e[72]!==Re?(We=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Ue,onContextMenu:W,onDragEnter:he,onDragOver:he,onDragLeave:ye,onDrop:Re}),e[69]=W,e[70]=ye,e[71]=he,e[72]=Re,e[73]=We):We=e[73];let He;e[74]!==a?(He=n.jsx(cu,{depth:a}),e[74]=a,e[75]=He):He=e[75];let Be;e[76]!==i||e[77]!==m||e[78]!==h?(Be=ke("flex w-full items-center gap-1.5 rounded-md py-1 pe-8 text-start transition-colors select-none",h?"bg-interactive-selection text-interactive-selection-foreground ring-2 ring-inset ring-primary":lu(i),m&&"opacity-50"),e[76]=i,e[77]=m,e[78]=h,e[79]=Be):Be=e[79];let Y;e[80]!==a?(Y=ja(a),e[80]=a,e[81]=Y):Y=e[81];let Me;e[82]!==Y?(Me={paddingInlineStart:Y},e[82]=Y,e[83]=Me):Me=e[83];let Ge;e[84]!==T||e[85]!==o||e[86]!==s.extension||e[87]!==s.path?(Ge=T?n.jsx(Cr,{expanded:o}):n.jsx(Fa,{filePath:s.path,extension:s.extension,className:"ms-0.5 size-3.5"}),e[84]=T,e[85]=o,e[86]=s.extension,e[87]=s.path,e[88]=Ge):Ge=e[88];let Ve;e[89]!==s.name||e[90]!==s.path?(Ve=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]=Ve):Ve=e[91];let dt;e[92]!==T||e[93]!==d||e[94]!==u?(dt=!T&&n.jsx(bg,{isOpen:d,status:u}),e[92]=T,e[93]=d,e[94]=u,e[95]=dt):dt=e[95];let et;e[96]!==f||e[97]!==T?(et=T&&f&&n.jsx(yg,{badge:f}),e[96]=f,e[97]=T,e[98]=et):et=e[98];let ct;e[99]!==W||e[100]!==ce||e[101]!==L||e[102]!==xe||e[103]!==oe||e[104]!==Be||e[105]!==Me||e[106]!==Ge||e[107]!==Ve||e[108]!==dt||e[109]!==et?(ct=n.jsxs("button",{type:"button",onClick:oe,onDoubleClick:ce,onContextMenu:W,draggable:!0,onDragStart:xe,onDragEnd:L,className:Be,style:Me,children:[Ge,Ve,dt,et]}),e[99]=W,e[100]=ce,e[101]=L,e[102]=xe,e[103]=oe,e[104]=Be,e[105]=Me,e[106]=Ge,e[107]=Ve,e[108]=dt,e[109]=et,e[110]=ct):ct=e[110];let me;e[111]!==B||e[112]!==_||e[113]!==U||e[114]!==E?(me=_&&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(js,{open:B,onOpenChange:ee,children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:be,title:E("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":E("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx(Z,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:E("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(Ps,{align:"end",side:"bottom",onCloseAutoFocus:()=>ee(!1),children:U({Item:qt,Separator:bn})})]})}),e[111]=B,e[112]=_,e[113]=U,e[114]=E,e[115]=me):me=e[115];let Ne;e[116]!==We||e[117]!==He||e[118]!==ct||e[119]!==me?(Ne=n.jsxs($a,{render:We,children:[He,ct,me]}),e[116]=We,e[117]=He,e[118]=ct,e[119]=me,e[120]=Ne):Ne=e[120];let qe;e[121]!==U?(qe=n.jsx(La,{className:"min-w-[180px]",children:U({Item:In,Separator:so})}),e[121]=U,e[122]=qe):qe=e[122];let Ye;return e[123]!==ne||e[124]!==Ne||e[125]!==qe?(Ye=n.jsxs(za,{open:ne,onOpenChange:re,children:[Ne,qe]}),e[123]=ne,e[124]=Ne,e[125]=qe,e[126]=Ye):Ye=e[126],Ye},_k=(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,Lk=c.memo(Fk,_k),$k=t=>{const e=Ke.c(6),{visible:s}=t,r=s===void 0?!0:s,o=gn(Kk),i=vn();let l;e[0]!==i||e[1]!==o?(l=JSON.stringify([o,i]),e[0]=i,e[1]=o,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=n.jsx(zk,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},zk=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:s}=vt(),{files:r,runtime:o}=Ws(),i=pm(o.platform),l=vn()??"",a=rs(l.trim()),d=al(a),u=mm(),f=gm(),h=bm(Q=>Q.searchFiles),m=ue(Q=>Q.openContextFile),g=Ba(t?l:null),[b,v]=c.useState(""),x=ky(b,200),S=c.useRef(null),[p,y]=c.useState([]),[w,j]=c.useState(!1),[k,P]=c.useState(null),[A,F]=c.useState(null),[D,E]=c.useState(null),[T,$]=c.useState(null),{hasTouchOnlyPointer:O}=Mn(),K=!!(r.rename&&a)&&!O,I=ue(Q=>Q.confirmFileTreeMove),X=ue(Q=>Q.setConfirmFileTreeMove),[N,C]=c.useState({}),[R,H]=c.useState({}),M=c.useRef(new Set),_=c.useRef(new Map),B=c.useMemo(()=>new N1,[]);c.useEffect(()=>()=>B.clear(),[B]);const ee=c.useRef(null);c.useEffect(()=>{if(P(null),E(null),$(null),!a){C({}),H({}),M.current=new Set;return}const Q=Bk(a);Q?(C({...Q.childrenByDir}),H({...Q.loadErrorsByDir}),M.current=new Set(Q.loadedDirs)):(C({}),H({}),M.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const Q=wi(a);Q.childrenByDir=N},[a,N]),c.useEffect(()=>{if(!a)return;const Q=wi(a);Q.loadErrorsByDir=R},[a,R]),c.useEffect(()=>{if(!a)return;const Q=wi(a);Q.loadedDirs=new Set(M.current)},[a,N,R]),c.useEffect(()=>()=>{if(!a)return;const Q=Gs.get(d);Q&&Q.loadedDirs.size===0&&Object.keys(Q.childrenByDir).length===0&&Gs.delete(d)},[d,a]);const ne=c.useMemo(()=>[],[]),re=c.useMemo(()=>[],[]),te=_s(Q=>a?Q.byRoot[a]?.expandedPaths??ne:ne),W=c.useMemo(()=>new Set(te),[te]),q=_s(Q=>a?Q.byRoot[a]?.selectedPath??null:null),oe=_s(Q=>Q.setSelectedPath),de=c.useRef(null),ce=c.useRef(null);c.useEffect(()=>{ce.current=q},[q]);const je=_s(Q=>Q.addOpenPath),be=_s(Q=>Q.removeOpenPathsByPrefix),pe=_s(Q=>Q.toggleExpandedPath),U=_s(Q=>Q.expandPath),Pe=_s(Q=>Q.collapseAllExpandedPaths),xe=ue(Q=>a?Q.contextPanelByDirectory[a]?.tabs??re:re),Ee=c.useMemo(()=>new Set(xe.map(Q=>Q.mode==="file"?Q.targetPath:null).filter(Q=>typeof Q=="string"&&Q.length>0).map(Q=>rs(Q))),[xe]),[L,ie]=c.useState(null),[G,ae]=c.useState(null),[ye,ge]=c.useState(""),[Se,ve]=c.useState(!1),Te=!!r.writeFile,z=!!r.createDirectory,he=!!r.rename,se=!!r.delete,Re=!!r.revealPath,Ue=c.useMemo(()=>({canRename:he,canCreateFile:Te,canCreateFolder:z,canDelete:se,canReveal:Re}),[he,Te,z,se,Re]),We=c.useCallback(Q=>{r.revealPath&&r.revealPath(Q).catch(()=>{Le.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),He=c.useCallback((Q,le)=>{ie(Q),ae(le),ge(Q==="rename"&&le.name||""),ve(!1)},[]),Be=c.useCallback((Q,le)=>{const Xe=le.filter(Ae=>Ae&&typeof Ae.name=="string"&&Ae.name.length>0).filter(Ae=>u||!Ae.name.startsWith(".")).filter(Ae=>f||!Mk(Ae.name)).map(Ae=>{const Je=Ae.name,Fe=rs(Ae.path||""),gt=Fe?Ik(Fe)?Fe:rs(`${Q}/${Fe}`):rs(`${Q}/${Je}`),bt=Ae.isDirectory?"directory":"file",Et=bt==="file"&&Je.includes(".")?Je.split(".").pop()?.toLowerCase():void 0;return{name:Je,path:gt,type:bt,extension:Et}});return Dk(Xe)},[f,u]),Y=c.useCallback(async(Q,le,Xe=!1)=>{if(!e.current||le?.())return;const Ae=rs(Q.trim());if(!Ae||!Xe&&M.current.has(Ae))return;const Je=Yt();return B.run(Ae,async Fe=>{const gt=()=>!Fe()||Yt()!==Je;try{const bt=!f,Et=r.listDirectory?(await r.listDirectory(Ae,{respectGitignore:bt})).entries:await yo.listLocalDirectory(Ae,{respectGitignore:bt});if(gt())return;_.current.set(Ae,Et.length);const Ft=Be(Ae,Et);M.current=new Set(M.current),M.current.add(Ae),H(es=>{if(!es[Ae])return es;const Ie={...es};return delete Ie[Ae],Ie}),C(es=>es[Ae]&&R1(es[Ae],Ft)?es:{...es,[Ae]:Ft})}catch(bt){if(gt())return;const Et=bt instanceof Error?bt.message:String(bt??"");console.error("Failed to load sidebar directory:",bt),H(Ft=>({...Ft,[Ae]:Et}))}},Xe)},[B,r,Be,f]),Me=c.useCallback(async()=>{if(!a)return;ee.current?.abort();const Q=new AbortController;ee.current=Q,B.clear();try{const Xe=(_s.getState().byRoot[a]?.expandedPaths??[]).map(Fe=>rs(Fe)).filter(Fe=>!!Fe&&Fe!==a&&Fe.startsWith(`${a}/`)),Ae=[a,...Xe];M.current=new Set(M.current);for(const Fe of Ae)M.current.delete(Fe);H(Fe=>{if(Object.keys(Fe).length===0)return Fe;const gt={...Fe};let bt=!1;for(const Et of Ae)Et in gt&&(delete gt[Et],bt=!0);return bt?gt:Fe});const Je=()=>Q.signal.aborted;await Y(a,Je);for(let Fe=0;Fe<Xe.length&&!Q.signal.aborted;Fe+=3){const gt=Xe.slice(Fe,Fe+3);await Promise.all(gt.map(bt=>Y(bt,Je)))}}catch(le){if(Q.signal.aborted)return;console.error("Failed to refresh sidebar tree:",le)}finally{ee.current===Q&&(ee.current=null)}},[B,Y,a]),Ge=c.useCallback(async Q=>{if(!Q){await Me();return}const le=rs(Q);M.current=new Set(M.current),M.current.delete(le),await Y(le,void 0,!0)},[Y,Me]);c.useEffect(()=>{a&&(ee.current?.abort(),M.current=new Set,B.clear(),H({}),C(Q=>Object.keys(Q).length===0?Q:{}),Y(a))},[B,Y,a,u,f]),c.useEffect(()=>{if(!t||!a||te.length===0)return;const Q=te.map(Ae=>rs(Ae)).filter(Ae=>!!Ae&&Ae!==a&&Ae.startsWith(`${a}/`)&&!M.current.has(Ae)&&!B.has(Ae)).sort((Ae,Je)=>Ae.split("/").length-Je.split("/").length);if(Q.length===0)return;let le=!1;const Xe=()=>le;return(async()=>{for(let Ae=0;Ae<Q.length&&!le;Ae+=3){const Je=Q.slice(Ae,Ae+3);await Promise.all(Je.map(Fe=>Y(Fe,Xe)))}})(),()=>{le=!0}},[B,te,Y,a,t]);const Ve=c.useRef(t);c.useEffect(()=>{const Q=t&&!Ve.current;Ve.current=t,Q&&Me()},[Me,t]);const dt=c.useCallback(({directories:Q})=>{if(!a)return;const le=new Set((_s.getState().byRoot[a]?.expandedPaths??[]).map(Et=>rs(Et))),Xe=a==="/"?"/":`${a}/`,Ae=Et=>{for(let Ft=Et;Ft!==a;Ft=ho(Ft))if(!Ft.startsWith(Xe)||!le.has(Ft))return!1;return!0},Je=Et=>{for(let Ft=Et;Ft===a||Ft.startsWith(Xe);Ft=ho(Ft)){if(M.current.has(Ft))return Ft;if(Ft===a)break}return null},Fe=new Set,gt=new Set;for(const Et of Q??M.current){const Ft=Je(rs(Et));Ft&&(Ae(Ft)?Fe:gt).add(Ft)}gt.size>0&&(M.current=new Set([...M.current].filter(Et=>!gt.has(Et))));const bt=[...Fe].filter(Et=>(_.current.get(Et)??0)<=xg);(async()=>{for(let Et=0;Et<bt.length;Et+=3)await Promise.all(bt.slice(Et,Et+3).map(Ft=>Y(Ft,void 0,!0)))})()},[Y,a]);Sg({root:a,active:t,whileInactive:"drop",onChanges:dt}),c.useEffect(()=>{if(!t)return;if(!l){y([]),j(!1);return}const Q=x.trim();if(!Q){y([]),j(!1);return}let le=!1;return j(!0),h(l,Q,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(Xe=>{if(le)return;const Je=Xe.filter(Fe=>f||!Ak(Fe.path)).map(Fe=>({name:Fe.name,path:rs(Fe.path),type:"file",extension:Fe.extension,relativePath:Fe.relativePath}));y(Je)}).catch(()=>{le||y([])}).finally(()=>{le||j(!1)}),()=>{le=!0}},[l,x,h,u,f,t]);const et=c.useMemo(()=>{const Q=new Map;if(!g?.files)return Q;for(const le of g.files)le.index==="A"||le.working_dir==="?"?Q.set(le.path,"git-added"):le.index==="D"?Q.set(le.path,"git-deleted"):(le.index==="M"||le.working_dir==="M")&&Q.set(le.path,"git-modified");return Q},[g]),ct=c.useMemo(()=>{const Q=new Map;if(!g?.files||!a)return Q;for(const le of g.files){const Xe=le.index==="M"||le.working_dir==="M",Ae=le.index==="A"||le.working_dir==="?";if(!Xe&&!Ae)continue;const Je=le.path.split("/");if(Je.length<=1)continue;let Fe=a;for(let gt=0;gt<Je.length-1;gt++){Fe=`${Fe}/${Je[gt]}`;let bt=Q.get(Fe);bt||(bt={modified:0,added:0},Q.set(Fe,bt)),Xe&&bt.modified++,Ae&&bt.added++}}return Q},[g,a]),me=c.useCallback(Q=>{if(et.size===0)return null;const le=Q.startsWith(a+"/")?Q.slice(a.length+1):Q;return et.get(le)??null},[et,a]),Ne=c.useCallback(Q=>{if(ct.size===0)return null;const le=ct.get(Q);return le&&le.modified+le.added>0?le:null},[ct]),qe=c.useCallback(async(Q,le)=>{if(!a)return;const Xe=await Pk(r,Q.path,{directory:a});if(!Xe.ok){Le.error(Ek(Xe.reason));return}oe(a,Q.path),je(a,Q.path),m(a,Q.path,{preview:!le?.pin&&!ue.getState().isMobile})},[je,r,m,a,oe]),Ye=c.useCallback(async Q=>{const le=rs(Q);a&&(pe(a,le),M.current.has(le)||await Y(le))},[Y,a,pe]),{canUpload:$e,uploadingDirectory:tt,uploadFiles:ht,pickFiles:wt,uploadElements:Bt}=vg({root:a,refreshDirectory:Ge}),kt=tt!==null,St=tt??k,xt=c.useCallback((Q,le)=>{const Xe=Rk(le);Xe.length!==0&&(P(null),ht(Q,Xe))},[ht]),Mt=c.useCallback(Q=>{if(Vc(Q),!Q){F(null),E(null);return}requestAnimationFrame(()=>{kh()?.path===Q.path&&F(Q.path)})},[]),jt=c.useCallback(async(Q,le)=>{const Xe=Nk(Q,le),Ae=await hc(r,a,Q.path,Xe);if(Ae==="conflict"){Le.error(s("sidebarFilesTree.toast.nameTaken",{name:Xe.slice(Xe.lastIndexOf("/")+1),folder:ar(a,le)}));return}if(Ae==="failed"){Le.error(s("sidebarFilesTree.toast.operationFailed"));return}le!==a&&U(a,le),await Promise.all([Ge(ho(Q.path)),Ge(le)]).catch(()=>{})},[U,r,Ge,a,s]),$t=c.useCallback((Q,le)=>{if(ue.getState().confirmFileTreeMove){$({source:Q,targetDirectory:le});return}jt(Q,le)},[jt]),Kt=c.useCallback(()=>{T&&($(null),jt(T.source,T.targetDirectory))},[jt,T]),Wt=c.useCallback((Q,le)=>!K||vh(Q)?null:jh(le,null,a),[K,a]),rt=c.useCallback(Q=>{const le=xr(Q.dataTransfer);if(le){const Xe=Wt(Q,le);if(E(Xe),!Xe)return;Q.preventDefault(),Q.dataTransfer.dropEffect="move";return}!$e||kt||!a||!Vn(Q.dataTransfer)||(Q.preventDefault(),Q.dataTransfer.dropEffect="copy",P(a))},[$e,Wt,kt,a]),ut=c.useCallback(Q=>{if(!(Q.relatedTarget instanceof Node&&Q.currentTarget.contains(Q.relatedTarget))){if(xr(Q.dataTransfer)){E(null);return}Vn(Q.dataTransfer)&&P(null)}},[]),pt=c.useCallback(Q=>{const le=xr(Q.dataTransfer);if(le){Q.preventDefault(),E(null);const Xe=Wt(Q,le);Xe&&Ch(Q.dataTransfer,a,le)&&$t(le,Xe);return}!$e||kt||!a||!Vn(Q.dataTransfer)||(Q.preventDefault(),xt(a,Q.dataTransfer))},[$e,Wt,xt,$t,kt,a]),fe=c.useCallback(async Q=>{if(Q?.preventDefault(),!G||!L)return;ve(!0);const le=()=>ve(!1),Xe=()=>ie(null);if(L==="createFile"){if(!ye.trim()){Le.error(s("sidebarFilesTree.toast.filenameRequired")),le();return}if(!r.writeFile){Le.error(s("sidebarFilesTree.toast.writeNotSupported")),le();return}const Ae=G.path,Je=Ae?`${Ae}/`:"",Fe=rs(`${Je}${ye.trim()}`);await r.writeFile(Fe,"").then(async gt=>{gt.success&&(Le.success(s("sidebarFilesTree.toast.fileCreated")),await Ge(Ae)),Xe()}).catch(()=>Le.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}if(L==="createFolder"){if(!ye.trim()){Le.error(s("sidebarFilesTree.toast.folderNameRequired")),le();return}const Ae=G.path,Je=Ae?`${Ae}/`:"",Fe=rs(`${Je}${ye.trim()}`);await r.createDirectory(Fe).then(async gt=>{gt.success&&(Le.success(s("sidebarFilesTree.toast.folderCreated")),await Ge(Ae)),Xe()}).catch(()=>Le.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}if(L==="rename"){if(!ye.trim()){Le.error(s("sidebarFilesTree.toast.nameRequired")),le();return}if(!r.rename){Le.error(s("sidebarFilesTree.toast.renameNotSupported")),le();return}const Ae=G.path,Je=Ae.split("/").slice(0,-1).join("/"),Fe=Je?`${Je}/`:"",gt=ye.trim(),bt=rs(`${Fe}${gt}`);try{const Et=await hc(r,a,Ae,bt);Et==="moved"?(Le.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await Ge(Je),Xe()):Et==="conflict"?Le.error(s("sidebarFilesTree.toast.nameTaken",{name:gt,folder:ar(a,Je)})):Le.error(s("sidebarFilesTree.toast.operationFailed"))}catch{Le.error(s("sidebarFilesTree.toast.operationFailed"))}finally{le()}return}if(L==="delete"){if(!r.delete){Le.error(s("sidebarFilesTree.toast.deleteNotSupported")),le();return}const Ae=G.path,Je=Ae.split("/").slice(0,-1).join("/");await r.delete(Ae).then(async Fe=>{Fe.success&&(Le.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await Ge(Je),a&&be(a,Ae),(q===Ae||q&&q.startsWith(Ae+"/"))&&oe(a,null)),Xe()}).catch(()=>Le.error(s("sidebarFilesTree.toast.operationFailed"))).finally(le);return}le()},[L,G,ye,r,Ge,be,a,q,oe,s]);function lt(Q,le){return(N[Q]??[]).map(Ae=>{const Je=Ae.type==="directory",Fe=Je&&W.has(Ae.path),gt=q===Ae.path;return n.jsxs("li",{"data-file-tree-path":Je?void 0:Ae.path,children:[n.jsx(Lk,{node:Ae,root:a,isExpanded:Fe,isActive:gt,isBrowserClient:i,depth:le,isOpen:!Je&&Ee.has(Ae.path),status:Je?void 0:me(Ae.path),badge:Je?Ne(Ae.path):void 0,isDropTarget:Je&&(St===Ae.path||D===Ae.path),isDragSource:A===Ae.path,canUpload:$e&&!kt,canMove:K,permissions:Ue,downloadFile:r.downloadFile,onSelect:qe,onToggle:Ye,onRevealPath:We,onOpenDialog:He,onSetDropTarget:P,onDropFiles:xt,onPickFiles:wt,onMoveDragChange:Mt,onSetMoveDropTarget:E,onMoveDrop:$t}),Je&&Fe&&n.jsxs("ul",{className:"flex flex-col",children:[R[Ae.path]?n.jsxs("li",{className:"relative flex items-center gap-2 py-1 pe-2 typography-meta text-muted-foreground",style:{paddingInlineStart:ja(le+1)},children:[n.jsx(cu,{depth:le+1}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:R[Ae.path],children:R[Ae.path]}),n.jsxs(Ct,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ge(Ae.path)},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,lt(Ae.path,le+1)]})]},Ae.path)})}c.useEffect(()=>{const Q=ce.current,le=de.current;if(!Q||!le)return;const Xe=le.querySelector(`[data-file-tree-path="${CSS.escape(Q)}"]`);!Xe||Xe.offsetParent===null||(ce.current=null,Xe.scrollIntoView({block:"nearest"}))});const ft=!!(a&&N[a]),mt=a?R[a]:null,Rt=St?ar(a,St):"",we=D?ar(a,D):"",it=T?T.source.path.slice(T.source.path.lastIndexOf("/")+1):"";return n.jsxs("section",{ref:de,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:[Te||z||$e?n.jsxs(js,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{variant:"ghost",size:"sm",className:"size-6 p-0 flex-shrink-0","aria-label":s("sidebarFilesTree.actions.addMenuTitle"),children:n.jsx(Z,{name:kt?"loader-4":"add",className:ke("h-4 w-4",kt&&"animate-spin")})})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.addMenuTitle")})]}),n.jsxs(Ps,{align:"end",className:"min-w-[180px]",children:[Te?n.jsxs(qt,{onClick:()=>He("createFile",{path:l,type:"directory"}),children:[n.jsx(Z,{name:"file-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFile")]}):null,z?n.jsxs(qt,{onClick:()=>He("createFolder",{path:l,type:"directory"}),children:[n.jsx(Z,{name:"folder-add",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.newFolder")]}):null,$e?n.jsxs(qt,{disabled:!a||kt,onClick:()=>wt(a),children:[n.jsx(Z,{name:"upload-2",className:"me-2 h-4 w-4"})," ",s("sidebarFilesTree.menu.uploadFiles")]}):null]})]}):null,n.jsx(D1,{className:"size-6"}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ct,{variant:"ghost",size:"sm",onClick:()=>{Me()},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx(Z,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(Ct,{variant:"ghost",size:"sm",onClick:()=>{a&&Pe(a)},className:"size-6 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx(Z,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Tt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0 px-2 py-2",children:[n.jsx(Z,{name:"search",className:"pointer-events-none absolute inset-s-4 top-4 h-4 w-4 text-muted-foreground"}),n.jsx(vo,{ref:S,value:b,onChange:Q=>v(Q.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 ps-8 pe-8 typography-meta"}),b.trim().length>0?n.jsx("button",{type:"button","aria-label":s("sidebarFilesTree.search.clearAria"),className:"absolute inset-e-4 top-4 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{v(""),S.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.jsx(Er,{outerClassName:"h-full min-h-0",className:ke("px-1.5 py-1.5",(St===a||D===a)&&"bg-interactive-selection/10"),onDragEnter:rt,onDragOver:rt,onDragLeave:ut,onDrop:pt,children:n.jsx("ul",{className:"flex flex-col",children:w?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"}),s("sidebarFilesTree.state.searching")]}):p.length>0?p.map(Q=>{const le=q===Q.path;return n.jsx("li",{"data-file-tree-path":Q.path,children:n.jsxs("button",{type:"button",onClick:()=>qe(Q),onDoubleClick:()=>qe(Q,{pin:!0}),draggable:!0,onDragStart:Xe=>{xh(Xe),Vc(null);const Ae=Q.relativePath||Xo(a??"",Q.path);!Ae||Ae==="."||(Xe.dataTransfer.setData(Ho,Ae),Xe.dataTransfer.effectAllowed="copy")},onDragEnd:Xe=>{Sh(Xe)&&qe(Q)},className:ke("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-start transition-colors",lu(le)),title:Q.path,children:[n.jsx(Fa,{filePath:Q.path,extension:Q.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:`‎${Q.relativePath??Q.path}‎`})]})},Q.path)}):mt?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:mt}),n.jsxs(Ct,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Me()},children:[n.jsx(Z,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):ft&&a?lt(a,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),St?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:ke("size-4 flex-shrink-0",kt&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Rt,children:s(kt?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Rt})})]}):D?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:we,children:s("sidebarFilesTree.drop.moveTarget",{path:we})})]}):null]}),Bt,n.jsx(Ks,{open:!!L,onOpenChange:Q=>!Q&&ie(null),children:n.jsxs(zs,{children:[n.jsxs(Ys,{children:[n.jsxs(Us,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),L==="rename"&&s("sidebarFilesTree.dialog.rename.title"),L==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(qs,{children:[L==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:G?.path??s("sidebarFilesTree.dialog.rootFallback")}),L==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:G?.name??""}),L==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:G?.name??""})]})]}),L!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(vo,{value:ye,onChange:Q=>ge(Q.target.value),placeholder:s(L==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:Q=>{Q.key==="Enter"&&fe()},autoFocus:!0})}),n.jsxs(yn,{children:[n.jsx(Ct,{variant:"outline",onClick:()=>ie(null),disabled:Se,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(Ct,{variant:L==="delete"?"destructive":"default",onClick:()=>{fe()},disabled:Se||L!=="delete"&&!ye.trim(),children:Se?n.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"}):s(L==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})}),n.jsx(Ks,{open:T!==null,onOpenChange:Q=>{Q||$(null)},children:n.jsxs(zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Ys,{children:[n.jsx(Us,{children:s("sidebarFilesTree.dialog.move.title")}),n.jsx(qs,{children:T?s("sidebarFilesTree.dialog.move.description",{name:it,folder:ar(a,T.targetDirectory)}):null})]}),n.jsxs(yn,{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:()=>X(!I),children:[n.jsx(jy,{checked:!I,onChange:Q=>X(!Q),ariaLabel:s("sidebarFilesTree.dialog.move.neverAsk")}),n.jsx("span",{children:s("sidebarFilesTree.dialog.move.neverAsk")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ct,{variant:"ghost",onClick:()=>$(null),children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(Ct,{onClick:Kt,children:s("sidebarFilesTree.dialog.move.confirm")})]})]})]})})]})};function Kk(t){return t.runtimeKey}const Wk=nr(()=>ss(()=>import("./WalkthroughView-D74b_7sC.js"),__vite__mapDeps([131,1,2,9,3,4,5,6,7,8,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,84,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,133,87,116,117,118,119,120,121,122,123,124])).then(t=>({default:t.WalkthroughView}))),Hk=nr(()=>ss(()=>import("./DiffView-mJuVm7Z4.js"),__vite__mapDeps([134,1,2,3,4,5,6,7,8,132,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,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,135,87,116,117,118,119,120,121,86,122,123,124])).then(t=>({default:t.DiffView}))),Vk=nr(()=>ss(()=>import("./FilesView-BBFbfDp9.js"),__vite__mapDeps([136,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,126,127,128,129,123,137,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,138,139,140,120,121,84,118,141,119,130,142])).then(t=>({default:t.FilesView}))),Ph=c.lazy(()=>ss(()=>import("./useAppFontEffects-C1ceAD51.js").then(t=>t.np),__vite__mapDeps([9,1,2,3,4,5,6,7,8,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}))),Uc=c.lazy(()=>ss(()=>import("./GuestSurfacePane-peVDY5gW.js"),__vite__mapDeps([143,1,2,9,3,4,5,6,7,8,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}))),Eh={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}},Gk=t=>{const e=Ke.c(12),{mode:s,docking:r}=t,[o,i]=c.useState(null),l=Eh[r.dock],a=Math.max(Ey,o??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=ke("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let f;e[3]!==l.vertical||e[4]!==a?(f=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=f):f=e[5];let h;e[6]!==s?(h=n.jsx(Ph,{mode:s,onResize:i}),e[6]=s,e[7]=h):h=e[7];let m;return e[8]!==u||e[9]!==f||e[10]!==h?(m=n.jsx("div",{className:u,style:f,children:h}),e[8]=u,e[9]=f,e[10]=h,e[11]=m):m=e[11],m},Uk=({visible:t,active:e,fill:s=!1,side:r})=>{const{t:o}=vt(),i=ue(y=>y.contextEditorTreeWidth),l=ue(y=>y.setContextEditorTreeWidth),[a,d]=c.useState(!1),u=c.useRef(0),f=c.useRef(i),h=c.useRef(null),m=c.useRef(null),g=c.useRef(null),b=c.useCallback(y=>{const w=g.current;w&&(w.style.width=`${y}px`,w.style.setProperty("--oc-editor-tree-width",`${y}px`))},[]),v=y=>{if(t){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}m.current=y.pointerId,d(!0),u.current=y.clientX,f.current=i,h.current=i,y.preventDefault()}},x=y=>{if(!a||m.current!==y.pointerId)return;const w=r==="left"?y.clientX-u.current:u.current-y.clientX,j=xa(y.currentTarget)?-w:w,k=Ii(f.current+j);h.current!==k&&(h.current=k,b(k))},S=y=>{if(m.current!==y.pointerId)return;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}const w=Ii(h.current??i);m.current=null,h.current=null,d(!1),l(w)},p=t?i:0;return n.jsxs("div",{ref:g,className:ke("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:`${a?h.current??p:p}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${a?h.current??i:i}px`,overflowX:"clip",transitionProperty:a?"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:ke("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:ke("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",a&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:x,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":o("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:ke("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",a&&"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($k,{visible:t&&e})})]})},Cn=t=>{const e=Ke.c(12),{zone:s,isOpen:r,directoryKey:o,className:i,children:l}=t,a=ue(Yk);let d;e[0]!==a||e[1]!==o||e[2]!==r||e[3]!==s?(d=m=>{Kf(m,r,()=>{o&&a(o,s)},m.currentTarget.closest("[data-context-zone]"))},e[0]=a,e[1]=o,e[2]=r,e[3]=s,e[4]=d):d=e[4];const u=d;let f;e[5]!==l||e[6]!==i||e[7]!==u?(f=n.jsx("div",{className:i,onKeyDownCapture:u,children:l}),e[5]=l,e[6]=i,e[7]=u,e[8]=f):f=e[8];let h;return e[9]!==f||e[10]!==s?(h=n.jsx(vk,{zone:s,children:f}),e[9]=f,e[10]=s,e[11]=h):h=e[11],h},qk=()=>{const{t}=vt(),e=vn()??"",s=c.useMemo(()=>e?vs(e):"",[e]),r=ue(L=>s?L.contextPanelByDirectory[s]:void 0),o=ue(L=>L.contextSurfaceZones),i=ue(L=>L.contextPanelByDirectory),l=ue(L=>L.closeContextPanelTab),a=ue(L=>L.closeContextFile),d=ue(L=>L.openContextPanelTab),u=ue(L=>L.openAgentBrowserTab),f=ue(L=>L.openContextFile),h=ue(L=>L.contextEditorTreeVisible),m=ue(L=>L.contextEditorVisible),g=ue(L=>L.fileTreeSide),b=_s(L=>L.setSelectedPath),v=wr(L=>L.headerSlot),x=c.useMemo(()=>r?.tabs??[],[r?.tabs]),S=Li(L=>L.chatCovered),p=c.useMemo(()=>{const L=ie=>{const G=r?go(r,o,ie):null,ae=ie==="bottom"&&S;return{activeTab:G,isOpen:!!(r&&Fo(r,ie).isOpen&&G)&&!ae}};return{left:L("left"),right:L("right"),bottom:L("bottom")}},[S,r,o]),y={left:ao(p.left.isOpen),right:ao(p.right.isOpen),bottom:ao(p.bottom.isOpen)},w=L=>!y[L],j=L=>{const ie=xo(o,L);return{zone:ie,...p[ie]}},k=j("file"),P=j("chat"),A=j("browser"),F=j("diff"),D=j("terminal"),E=j("walkthrough"),[T,$]=c.useState(()=>new Set),O=c.useCallback(L=>{$(ie=>ie.has(L)?ie:new Set(ie).add(L))},[]);c.useEffect(()=>Jw((L,ie)=>{const G=ie.directory?vs(ie.directory):s;if(!G)return null;const ae=u(G,L,ie.sessionId);return ae&&O(ae),ae}),[s,u,O]),c.useEffect(()=>wn(L=>{if(L.type!=="file-open-request")return;const ie=L.directory??e;ie&&f(ie,L.path)}),[e,f]);const K=A.activeTab?.mode==="browser"?A.activeTab.id:null;c.useEffect(()=>{Zw(s,K)},[s,K]);const I=k.activeTab;c.useEffect(()=>{!s||I?.mode!=="file"||!I.targetPath||b(s,I.targetPath,{allowOutsideRoot:!0})},[s,I,b]);const X=c.useMemo(()=>x.some(L=>L.mode==="file"&&L.targetPath),[x]),N=c.useMemo(()=>x.some(L=>L.mode==="file"),[x]),C=X&&(m||!h),R=k.activeTab?.mode==="file",H=c.useCallback(L=>{s&&a(s,L)},[a,s]),M=P.isOpen&&P.activeTab?.mode==="chat"?P.activeTab:null,_=M?Za(M.dedupeKey):null,B=c.useMemo(()=>(M?.targetDirectory?vs(M.targetDirectory):"")||s||null,[M?.targetDirectory,s]),ee=c.useMemo(()=>_?{sessionId:_,directory:B}:null,[_,B]);c.useEffect(()=>{if(!B||!_||typeof window>"u")return;const L=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ui(B,_,!1);return}Xu(_),ui(B,_,!0)};L();const ie=window.setInterval(L,1e4);return window.addEventListener("focus",L),window.addEventListener("blur",L),document.addEventListener("visibilitychange",L),()=>{window.clearInterval(ie),window.removeEventListener("focus",L),window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",L),ui(B,_,!1)}},[B,_]);const ne=F.activeTab,re=c.useCallback(L=>{!s||ne?.mode!=="diff"||d(s,{mode:"diff",targetPath:ne.targetPath,stagedDiff:L==="staged",diffScope:L})},[ne,s,d]),te=A.isOpen&&A.activeTab?.mode==="browser"?A.activeTab.id:null;c.useEffect(()=>{te&&O(te)},[te,O]);const{loadedBrowserTabs:W,sleepingBrowserTabs:q}=c.useMemo(()=>{const L=[],ie=[];for(const[ae,ye]of Object.entries(i)){const ge=ae===s;for(const Se of ye.tabs){if(Se.mode!=="browser"||!ge&&Se.ownerSessionId===null)continue;const ve={directory:ae,id:Se.id,targetPath:Se.targetPath,ownerSessionId:Se.ownerSessionId};(T.has(Se.id)||ge&&Se.id===te?L:ie).push(ve)}}const G=ae=>`${ae.directory}\0${ae.id}`;return L.sort((ae,ye)=>G(ae)<G(ye)?-1:1),{loadedBrowserTabs:L,sleepingBrowserTabs:ie}},[i,s,te,T]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const L=q.map(ie=>Qw({tabId:ie.id,directory:ie.directory,ownerSessionId:ie.ownerSessionId,describe:()=>({title:"",url:ie.targetPath??""}),wake:()=>O(ie.id)}));return()=>L.forEach(ie=>ie())},[q,O]);const oe=c.useMemo(()=>x.filter(L=>L.mode==="diff"),[x]),de=c.useMemo(()=>x.find(L=>L.mode==="terminal")??null,[x]),ce=c.useMemo(()=>x.some(L=>L.mode==="walkthrough"),[x]),je=c.useMemo(()=>x.filter(L=>Yn(L.mode)),[x]),be=Ia(L=>L.guests),pe=c.useMemo(()=>new Set(be.filter(Cy).map(L=>L.id)),[be]),U=c.useMemo(()=>{const L=new Map;for(const ie of be){const G=Py(ie);G&&L.set(ie.id,G)}return L},[be]),Pe=D.zone,xe=c.useCallback(L=>{const ie=el({mode:"terminal",label:t("layout.mainTab.terminal"),from:Pe},L);return{finish:()=>ie.finish(s),cancel:ie.cancel}},[s,t,Pe]),Ee=(L,ie)=>ie?v[L]:null;return n.jsxs(n.Fragment,{children:[N?n.jsxs(Cn,{zone:k.zone,isOpen:k.isOpen,directoryKey:s,className:ke("absolute inset-0 flex",g==="left"&&"flex-row-reverse",R?"flex":"hidden"),children:[X||!h?n.jsx("div",{className:ke("h-full min-w-0 flex-1",X&&!C&&"hidden"),children:X?n.jsx(c.Suspense,{fallback:null,children:n.jsx(Vk,{mode:"editor-only",visible:!w(k.zone)&&R&&C,onCloseFile:H})}):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,n.jsx(Uk,{visible:h,active:k.isOpen&&R,fill:!C,side:g})]}):null,M&&_&&ee?n.jsx(Cn,{zone:P.zone,isOpen:P.isOpen,directoryKey:s,className:"absolute inset-0 bg-background",children:n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:_}),className:"h-full",children:n.jsx(du,{pinnedSession:ee,readOnly:M.readOnly})})},M.id):null,W.map(L=>{const ie=L.directory===s&&A.activeTab?.id===L.id;return n.jsx(Cn,{zone:A.zone,isOpen:A.isOpen,directoryKey:s,className:ke("absolute inset-0",!ie&&"invisible pointer-events-none"),children:n.jsx("div",{className:"h-full","aria-hidden":!ie||void 0,children:n.jsx(gk,{initialUrl:L.targetPath??"",directory:L.directory,tabID:L.id,ownerSessionId:L.ownerSessionId,visible:ie&&A.isOpen})})},`${L.directory}\0${L.id}`)}),oe.map(L=>{const ie=F.activeTab?.id===L.id;return n.jsx(Cn,{zone:F.zone,isOpen:F.isOpen,directoryKey:s,className:ke("absolute inset-0",!ie&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:Ee(F.zone,ie),children:n.jsx(Hk,{visible:F.isOpen&&ie,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:L.diffScope??(L.stagedDiff?"staged":null),onDiffScopeChange:re,targetFilePath:L.targetPath,flushContent:!0})})})},L.id)}),de?n.jsx(Cn,{zone:D.zone,isOpen:D.isOpen,directoryKey:s,className:ke("absolute inset-0",D.activeTab?.mode==="terminal"?"block":"hidden"),children:n.jsx(Tn,{value:Ee(D.zone,D.activeTab?.mode==="terminal"),children:n.jsx(wg.Provider,{value:xe,children:n.jsx(kg,{visible:D.isOpen&&D.activeTab?.mode==="terminal",directory:de.targetDirectory,onLastTabClosed:()=>{s&&l(s,de.id)}})})})}):null,ce?n.jsx(Cn,{zone:E.zone,isOpen:E.isOpen,directoryKey:s,className:ke("absolute inset-0",E.activeTab?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(Tn,{value:Ee(E.zone,E.activeTab?.mode==="walkthrough"),children:n.jsx(Wk,{directory:e,visible:E.isOpen&&E.activeTab?.mode==="walkthrough"})})})}):null,je.map(L=>{if(!Yn(L.mode))return null;const ie=j(L.mode),G=bo(L.mode),ae=pe.has(G),ye=U.get(G),ge=ie.activeTab?.id===L.id,Se=ge&&ie.isOpen;return ae&&!ye&&!Se?null:n.jsx(Cn,{zone:ie.zone,isOpen:ie.isOpen,directoryKey:s,className:ke("absolute inset-0",ge?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:ae?ye?n.jsxs("div",{className:ke("flex h-full",Eh[ye.dock].container),children:[n.jsx(Gk,{mode:L.mode,docking:ye}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Se?n.jsx(Uc,{mode:L.mode}):null})]}):n.jsx(Uc,{mode:L.mode}):n.jsx(Ph,{mode:L.mode})})},L.id)})]})};function Yk(t){return t.closeContextZone}const Xk={left:"contextPanel.zone.dropLeft",bottom:"contextPanel.zone.dropBottom",right:"contextPanel.zone.dropRight"},Qk=()=>{const t=Ke.c(20),{t:e}=vt(),s=on(Zk),r=on(Jk),o=c.useRef(null),[i,l]=c.useState(!1);let a,d;t[0]!==s?(a=()=>{if(!s){l(!1);return}const S=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(S)},d=[s],t[0]=s,t[1]=a,t[2]=d):(a=t[1],d=t[2]),c.useEffect(a,d);let u,f;if(t[3]!==s?(u=()=>{if(!s)return;const S=p=>{const y=o.current;y&&(y.style.transform=`translate(${p.clientX+12}px, ${p.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]),c.useEffect(u,f),!s)return null;const h=i?"opacity-100":"opacity-0";let m;t[6]!==h?(m=ke("absolute inset-0 bg-surface-overlay/40 transition-opacity duration-150 ease-out motion-reduce:transition-none",h),t[6]=h,t[7]=m):m=t[7];let g;t[8]!==m?(g=n.jsx("div",{className:m}),t[8]=m,t[9]=g):g=t[9];let b;t[10]!==s.frames||t[11]!==r||t[12]!==e?(b=ym.map(S=>{const p=s.frames[S];if(p.width<=0||p.height<=0)return null;const y=r===S;return n.jsx("div",{className:ke("absolute flex items-center justify-center rounded-[10px] border transition-colors duration-100",y?"border-primary bg-background/90 text-foreground shadow-sm":"border-border bg-background/80 text-muted-foreground"),style:{left:p.left,top:p.top,width:p.width,height:p.height},children:n.jsx("span",{className:"typography-ui-label",children:e(Xk[S])})},S)}),t[10]=s.frames,t[11]=r,t[12]=e,t[13]=b):b=t[13];let v;t[14]!==s.label?(v=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]=v):v=t[15];let x;return t[16]!==g||t[17]!==b||t[18]!==v?(x=ya.createPortal(n.jsxs("div",{className:"pointer-events-none fixed inset-0 z-[60]","aria-hidden":"true",children:[g,b,v]}),document.body),t[16]=g,t[17]=b,t[18]=v,t[19]=x):x=t[19],x};function Zk(t){return t.drag}function Jk(t){return t.hovered}const qc=400,ej=({rowWidth:t,leftWidth:e,rightWidth:s,sidebarWidth:r,opening:o})=>{let i=t-e-s;if(i>=qc)return{collapseSidebar:!1,displace:null};const l=r!==null;if(l&&(i+=r),i>=qc)return{collapseSidebar:l,displace:null};const a=o==="left"?"right":"left";return{collapseSidebar:l,displace:(a==="left"?e:s)>0?a:null}},tj=()=>{const t=Ke.c(5),e=vn();let s;t[0]!==e?(s=e?vs(e):"",t[0]=e,t[1]=s):s=t[1];const r=s,o=c.useRef(null);let i,l;return t[2]!==r?(i=()=>{if(!r)return;const a=x=>{const S=x.contextPanelByDirectory[r];return{left:pr(S,x.contextSurfaceZones,"left"),right:pr(S,x.contextSurfaceZones,"right")}},d=(x,S,p)=>{const y=x.contextPanelByDirectory[r],w=p&&y?go(y,x.contextSurfaceZones,S):null;return w?y?.widthByMode[w.mode]??$i(w.mode):0};let u=null,f=!1,h=a(ue.getState());const m=x=>{f=!0,ue.getState().setSidebarOpen(x),f=!1},g=o.current;g&&!h[g]&&(o.current=null,ue.getState().isSidebarOpen||m(!0));const b=(x,S,p)=>{const y=document.querySelector("[data-workspace-row]")?.clientWidth;if(!y)return;const w=ej({rowWidth:y,leftWidth:d(x,"left",p.left),rightWidth:d(x,"right",p.right),sidebarWidth:x.isSidebarOpen?x.sidebarWidth:null,opening:S});if(w.displace){const j=Fo(x.contextPanelByDirectory[r],w.displace).activeTabId;j&&(u={side:w.displace,by:S,tabId:j})}w.collapseSidebar&&(o.current=S,m(!1)),w.displace&&x.closeContextZone(r,w.displace)},v=x=>{if(u?.side===x){o.current===x&&(o.current=u.by);return}const S=u?.by===x?u:null;S&&(u=null),o.current===x&&(S?o.current=S.side:(o.current=null,ue.getState().isSidebarOpen||m(!0))),S&&ue.getState().setActiveContextPanelTab(r,S.tabId)};return ue.subscribe((x,S)=>{x.isSidebarOpen!==S.isSidebarOpen&&!f&&(o.current=null);const p=a(x),y=h;h=p;const w=["left","right"],j=w.filter(P=>p[P]&&!y[P]),k=w.filter(P=>!p[P]&&y[P]);for(const P of k){const A=P==="left"?"right":"left";j.includes(A)&&(o.current===P&&(o.current=A),u?.by===P&&(u=null))}for(const P of k)v(P);for(const P of j)b(x,P,p)})},l=[r],t[2]=r,t[3]=i,t[4]=l):(i=t[3],l=t[4]),c.useEffect(i,l),null},sj=t=>{const e=Ke.c(29),{surfaceId:s,label:r,checked:o,onChange:i}=t,{t:l}=vt();let a;e[0]!==s?(a={id:s},e[0]=s,e[1]=a):a=e[1];const{attributes:d,listeners:u,setNodeRef:f,setActivatorNodeRef:h,transform:m,transition:g,isDragging:b}=Ar(a);let v;e[2]!==m?(v=Or.Translate.toString(m),e[2]=m,e[3]=v):v=e[3];let x;e[4]!==v||e[5]!==g?(x={transform:v,transition:g},e[4]=v,e[5]=g,e[6]=x):x=e[6];const S=b&&"z-10 opacity-60";let p;e[7]!==S?(p=ke("relative flex items-center gap-2",S),e[7]=S,e[8]=p):p=e[8];let y;e[9]!==r||e[10]!==l?(y=l("contextRail.configure.reorder",{label:r}),e[9]=r,e[10]=l,e[11]=y):y=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(Z,{name:"draggable",className:"size-4"}),e[12]=w):w=e[12];let j;e[13]!==d||e[14]!==u||e[15]!==h||e[16]!==y?(j=n.jsx(Ct,{ref:h,variant:"ghost",size:"icon",...d,...u,"aria-label":y,className:"shrink-0 touch-none select-none cursor-grab text-muted-foreground hover:bg-transparent active:cursor-grabbing",children:w}),e[13]=d,e[14]=u,e[15]=h,e[16]=y,e[17]=j):j=e[17];const k=`layout.context-rail.surface.${s}`;let P;e[18]!==o||e[19]!==r||e[20]!==i||e[21]!==k?(P=n.jsx(Ny,{settingsItem:k,checked:o,onChange:i,label:r,ariaLabel:r,className:"min-w-0 flex-1"}),e[18]=o,e[19]=r,e[20]=i,e[21]=k,e[22]=P):P=e[22];let A;return e[23]!==f||e[24]!==P||e[25]!==x||e[26]!==p||e[27]!==j?(A=n.jsxs("div",{ref:f,style:x,className:p,children:[j,P]}),e[23]=f,e[24]=P,e[25]=x,e[26]=p,e[27]=j,e[28]=A):A=e[28],A},nj=t=>{const e=Ke.c(86),{open:s,onOpenChange:r}=t,{t:o}=vt(),i=ue(rj),l=ue(oj),a=ue(ij),d=ue(aj),u=ue(lj),f=_a();let h;e[0]!==i||e[1]!==f?(h=Qu(i,f),e[0]=i,e[1]=f,e[2]=h):h=e[2];const m=h,g=a.length===0;let b;if(e[3]!==a||e[4]!==m){let be;e[6]!==a?(be=pe=>a.includes(pe.id),e[6]=a,e[7]=be):be=e[7],b=m.every(be),e[3]=a,e[4]=m,e[5]=b}else b=e[5];const v=b,x=c.useRef(!1);let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S={activationConstraint:{distance:8}},e[8]=S):S=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={activationConstraint:{delay:200,tolerance:6}},e[9]=p):p=e[9];let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:Rf},e[10]=y):y=e[10];const w=Rr(Bs(Ir,S),Bs(Dr,p),Bs(Nf,y));let j;e[11]!==i||e[12]!==l||e[13]!==m?(j=be=>{const{active:pe,over:U}=be;if(x.current=!1,!U||pe.id===U.id)return;const Pe=m.findIndex(ie=>ie.id===pe.id),xe=m.findIndex(ie=>ie.id===U.id);if(Pe<0||xe<0)return;const Ee=qa(m,Pe,xe).map(cj),L=new Set(Ee);l([...Ee,...i.filter(ie=>!L.has(ie))])},e[11]=i,e[12]=l,e[13]=m,e[14]=j):j=e[14];const k=j;let P;e[15]!==m||e[16]!==o?(P=(be,pe)=>{const U=pe===void 0?be:pe,Pe=m.find(xe=>xe.id===be);if(Pe)return o("contextRail.configure.position",{label:Pe.label??o(Pe.labelKey),position:m.findIndex(xe=>xe.id===U)+1,count:m.length})},e[15]=m,e[16]=o,e[17]=P):P=e[17];const A=P;let F,D;e[18]!==A?(F=be=>{const{active:pe}=be;return A(pe.id)},D=be=>{const{active:pe,over:U}=be;return U?A(pe.id,U.id):void 0},e[18]=A,e[19]=F,e[20]=D):(F=e[19],D=e[20]);let E;e[21]!==A||e[22]!==o?(E=be=>{const{active:pe,over:U}=be;return U?A(pe.id,U.id):o("contextRail.configure.dragCancelled")},e[21]=A,e[22]=o,e[23]=E):E=e[23];let T;e[24]!==o?(T=()=>o("contextRail.configure.dragCancelled"),e[24]=o,e[25]=T):T=e[25];let $;e[26]!==E||e[27]!==T||e[28]!==F||e[29]!==D?($={onDragStart:F,onDragOver:D,onDragEnd:E,onDragCancel:T},e[26]=E,e[27]=T,e[28]=F,e[29]=D,e[30]=$):$=e[30];const O=$;let K;e[31]!==o?(K=o("contextRail.configure.dragInstructions"),e[31]=o,e[32]=K):K=e[32];let I;e[33]!==K?(I={draggable:K},e[33]=K,e[34]=I):I=e[34];let X;e[35]!==O||e[36]!==I?(X={screenReaderInstructions:I,announcements:O},e[35]=O,e[36]=I,e[37]=X):X=e[37];const N=X;let C;e[38]!==r?(C=(be,pe)=>{if(!be&&pe.reason==="escape-key"&&x.current){pe.cancel(),pe.allowPropagation();return}x.current=!1,r(be)},e[38]=r,e[39]=C):C=e[39];let R;e[40]===Symbol.for("react.memo_cache_sentinel")?(R=be=>{x.current&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(be.key)&&be.preventBaseUIHandler()},e[40]=R):R=e[40];let H;e[41]!==o?(H=o("contextRail.configure.dialogTitle"),e[41]=o,e[42]=H):H=e[42];let M;e[43]!==H?(M=n.jsx(Us,{children:H}),e[43]=H,e[44]=M):M=e[44];let _;e[45]!==o?(_=o("contextRail.configure.dialogDescription"),e[45]=o,e[46]=_):_=e[46];let B;e[47]!==_?(B=n.jsx(qs,{children:_}),e[47]=_,e[48]=B):B=e[48];let ee;e[49]!==M||e[50]!==B?(ee=n.jsxs(Ys,{children:[M,B]}),e[49]=M,e[50]=B,e[51]=ee):ee=e[51];let ne,re;e[52]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>{x.current=!0},re=()=>{x.current=!1},e[52]=ne,e[53]=re):(ne=e[52],re=e[53]);let te;if(e[54]!==a||e[55]!==d||e[56]!==m||e[57]!==o){let be;e[59]!==a||e[60]!==d||e[61]!==o?(be=pe=>n.jsx(sj,{surfaceId:pe.id,checked:!a.includes(pe.id),onChange:U=>d(pe.id,U),label:pe.label??o(pe.labelKey)},pe.id),e[59]=a,e[60]=d,e[61]=o,e[62]=be):be=e[62],te=m.map(be),e[54]=a,e[55]=d,e[56]=m,e[57]=o,e[58]=te}else te=e[58];let W;e[63]!==te?(W=n.jsx("div",{className:"flex flex-col",children:te}),e[63]=te,e[64]=W):W=e[64];let q;e[65]!==m||e[66]!==W?(q=n.jsx(Uo,{items:m,strategy:Ya,children:W}),e[65]=m,e[66]=W,e[67]=q):q=e[67];let oe;e[68]!==N||e[69]!==k||e[70]!==w||e[71]!==q?(oe=n.jsx(Tr,{sensors:w,collisionDetection:Mr,onDragStart:ne,onDragCancel:re,onDragEnd:k,accessibility:N,children:q}),e[68]=N,e[69]=k,e[70]=w,e[71]=q,e[72]=oe):oe=e[72];let de;e[73]!==g||e[74]!==v||e[75]!==u||e[76]!==o?(de=g?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[v?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(Ct,{variant:"link",size:"xs",onClick:()=>u([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[73]=g,e[74]=v,e[75]=u,e[76]=o,e[77]=de):de=e[77];let ce;e[78]!==ee||e[79]!==oe||e[80]!==de?(ce=n.jsxs(zs,{className:"max-w-md",onKeyDown:R,children:[ee,oe,de]}),e[78]=ee,e[79]=oe,e[80]=de,e[81]=ce):ce=e[81];let je;return e[82]!==s||e[83]!==C||e[84]!==ce?(je=n.jsx(Ks,{open:s,onOpenChange:C,children:ce}),e[82]=s,e[83]=C,e[84]=ce,e[85]=je):je=e[85],je};function rj(t){return t.contextRailOrder}function oj(t){return t.setContextRailOrder}function ij(t){return t.contextRailHiddenSurfaces}function aj(t){return t.setContextRailSurfaceVisible}function lj(t){return t.setContextRailHiddenSurfaces}function cj(t){return t.id}const dj=t=>{const e=Hu(t);return e?e.state==="measured"?{state:"measured",totalTokens:e.totalTokens}:{state:"compacted"}:null},uj=(t,e)=>t===null||e===null?t===e:t.state!==e.state?!1:t.state==="compacted"||e.state==="measured"&&t.totalTokens===e.totalTokens,Nh=()=>{const t=Ke.c(4),e=nt(pj),s=nt(mj)??void 0,r=Dy(e??"",s,dj,uj),{context:o}=Iy(e,s),i=o>0?o:Ty;let l;return t[0]!==r||t[1]!==i||t[2]!==e?(l={sessionId:e,fill:r,limit:i},t[0]=r,t[1]=i,t[2]=e,t[3]=l):l=t[3],l},Yc=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),Js=18,aa=2,la=(Js-aa)/2,Xc=2*Math.PI*la,fj=t=>{const e=Ke.c(8),{className:s}=t,{fill:r,limit:o}=Nh(),i=r?.state==="measured"?Math.min(100,r.totalTokens/o*100):0;let l;e[0]!==s?(l=ke("shrink-0",s),e[0]=s,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("circle",{cx:Js/2,cy:Js/2,r:la,fill:"none",stroke:"currentColor",strokeOpacity:.3,strokeWidth:aa}),e[2]=a):a=e[2];let d;e[3]!==i?(d=i>0?n.jsx("circle",{cx:Js/2,cy:Js/2,r:la,fill:"none",stroke:"currentColor",strokeWidth:aa,strokeLinecap:"round",strokeDasharray:Xc,strokeDashoffset:Xc*(1-i/100),transform:`rotate(-90 ${Js/2} ${Js/2})`}):null,e[3]=i,e[4]=d):d=e[4];let u;return e[5]!==l||e[6]!==d?(u=n.jsxs("svg",{viewBox:`0 0 ${Js} ${Js}`,className:l,"aria-hidden":"true",children:[a,d]}),e[5]=l,e[6]=d,e[7]=u):u=e[7],u},hj=()=>{const t=Ke.c(16),{t:e}=vt(),{sessionId:s,fill:r,limit:o}=Nh(),{totalCost:i}=Ry(s);if(!s||!r)return null;let l;t[0]!==r.state||t[1]!==r.totalTokens||t[2]!==e?(l=r.state==="measured"?e("contextUsage.tooltip.usedTokens",{tokens:Yc(r.totalTokens)}):e("contextUsage.compacted.description"),t[0]=r.state,t[1]=r.totalTokens,t[2]=e,t[3]=l):l=t[3];let a;t[4]!==o||t[5]!==e?(a=e("contextUsage.tooltip.contextLimit",{tokens:Yc(o)}),t[4]=o,t[5]=e,t[6]=a):a=t[6];let d;t[7]!==e||t[8]!==i?(d=i!==null&&i>0?[e("contextUsage.tooltip.cost",{cost:Ef(i)})]:[],t[7]=e,t[8]=i,t[9]=d):d=t[9];let u;t[10]!==l||t[11]!==a||t[12]!==d?(u=[l,a,...d],t[10]=l,t[11]=a,t[12]=d,t[13]=u):u=t[13];const f=u;let h;return t[14]!==f?(h=n.jsx("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border/60 pt-1 tabular-nums",children:f.map(gj)}),t[14]=f,t[15]=h):h=t[15],h};function pj(t){return t.currentSessionId}function mj(t){return t.currentSessionDirectory}function gj(t){return n.jsx("span",{className:"typography-micro text-muted-foreground",children:t},t)}const Rh=150,bj=500,yj=[],xj=t=>t>99?"99+":String(t),Sj=t=>{const e=Ke.c(62),{surface:s,isActive:r,showActivityDot:o,label:i,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:h,onSelect:m}=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:v,setNodeRef:x,transform:S,transition:p,isDragging:y}=Ar(g);let w;e[2]!==a?(w=a!=null&&a>0?xj(a):null,e[2]=a,e[3]=w):w=e[3];const j=w;let k;e[4]!==S?(k=Or.Translate.toString(S),e[4]=S,e[5]=k):k=e[5];let P;e[6]!==k||e[7]!==p?(P={transform:k,transition:p},e[6]=k,e[7]=p,e[8]=P):P=e[8];const A=y&&"z-10 opacity-70";let F;e[9]!==A?(F=ke("relative",A),e[9]=A,e[10]=F):F=e[10];let D;e[11]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("div",{}),e[11]=D):D=e[11];let E;e[12]!==m||e[13]!==s?(E=()=>m(s),e[12]=m,e[13]=s,e[14]=E):E=e[14];const T=d??i,$=s.id,O=r?"text-primary":"text-muted-foreground hover:text-foreground";let K;e[15]!==O?(K=ke("flex h-7 w-7 touch-none select-none items-center justify-center rounded-md transition-colors",O),e[15]=O,e[16]=K):K=e[16];let I;e[17]!==s.icon||e[18]!==s.iconSrc||e[19]!==s.id?(I=s.id==="diff"?n.jsx(au,{className:"h-[18px] w-[18px]"}):s.id==="context"?n.jsx(fj,{className:"h-[18px] w-[18px]"}):n.jsx(sr,{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]=I):I=e[20];let X;e[21]!==j||e[22]!==f||e[23]!==o||e[24]!==h?(X=h&&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}):j?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:j}):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]=j,e[22]=f,e[23]=o,e[24]=h,e[25]=X):X=e[25];let N;e[26]!==b||e[27]!==r||e[28]!==v||e[29]!==s.id||e[30]!==K||e[31]!==I||e[32]!==X||e[33]!==E||e[34]!==T?(N=n.jsx(At,{asChild:!0,children:n.jsxs("button",{type:"button",...b,...v,onClick:E,"aria-label":T,"aria-pressed":r,"data-context-surface":$,className:K,children:[I,X]})}),e[26]=b,e[27]=r,e[28]=v,e[29]=s.id,e[30]=K,e[31]=I,e[32]=X,e[33]=E,e[34]=T,e[35]=N):N=e[35];let C;e[36]!==i?(C=n.jsx("span",{children:i}),e[36]=i,e[37]=C):C=e[37];let R;e[38]!==l?(R=n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[38]=l,e[39]=R):R=e[39];let H;e[40]!==u?(H=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[40]=u,e[41]=H):H=e[41];let M;e[42]!==s.id?(M=s.id==="context"?n.jsx(hj,{}):null,e[42]=s.id,e[43]=M):M=e[43];let _;e[44]!==C||e[45]!==R||e[46]!==H||e[47]!==M?(_=n.jsx(Tt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[C,R,H,M]})}),e[44]=C,e[45]=R,e[46]=H,e[47]=M,e[48]=_):_=e[48];let B;e[49]!==N||e[50]!==_?(B=n.jsx($a,{render:D,children:n.jsxs(Ot,{delayDuration:Rh,children:[N,_]})}),e[49]=N,e[50]=_,e[51]=B):B=e[51];let ee;e[52]!==s.mode?(ee=n.jsx(La,{children:n.jsx(iu,{mode:s.mode})}),e[52]=s.mode,e[53]=ee):ee=e[53];let ne;e[54]!==B||e[55]!==ee?(ne=n.jsxs(za,{children:[B,ee]}),e[54]=B,e[55]=ee,e[56]=ne):ne=e[56];let re;return e[57]!==x||e[58]!==ne||e[59]!==P||e[60]!==F?(re=n.jsx("div",{ref:x,style:P,className:F,children:ne}),e[57]=x,e[58]=ne,e[59]=P,e[60]=F,e[61]=re):re=e[61],re},vj=()=>{const t=Ke.c(99),{t:e}=vt(),s=vn();let r;t[0]!==s?(r=s?vs(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=he=>o?he.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const l=ue(i),a=ue(wj),d=ue(kj),u=ue(jj),f=ue(Cj),h=ue(Pj),m=ue(Ej),g=ue(Nj),b=ue(Rj),v=Ta(Dj),x=Bu(Fu)?.hasChecked??!1,S=mn(Tj),p=Uu(o||null),{screenWidth:y}=Mn(),w=Ba(o||null);let j;t[4]!==b?(j=My("switch_context_surface",b),t[4]=b,t[5]=j):j=t[5];const k=j,[P,A]=c.useState(!1);let F,D;t[6]!==k?(F=()=>{const he=new Set;let se=null,Re=!1;const Ue=Mj,We=()=>{ec(k,he)?!Re&&se===null&&(se=setTimeout(()=>A(!0),bj)):(Re=!1,se!==null&&(clearTimeout(se),se=null),A(!1))},He=Me=>{if(he.add(Me.key.toLowerCase()),Ue(Me.key)&&ec(k,he)){Re=!0,se!==null&&(clearTimeout(se),se=null),A(!1);return}We()},Be=Me=>{he.delete(Me.key.toLowerCase()),We()},Y=()=>{he.clear(),Re=!1,se!==null&&(clearTimeout(se),se=null),A(!1)};return window.addEventListener("keydown",He,!0),window.addEventListener("keyup",Be,!0),window.addEventListener("blur",Y),()=>{window.removeEventListener("keydown",He,!0),window.removeEventListener("keyup",Be,!0),window.removeEventListener("blur",Y),se!==null&&clearTimeout(se)}},D=[k],t[6]=k,t[7]=F,t[8]=D):(F=t[7],D=t[8]),c.useEffect(F,D);let E;t[9]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{distance:8}},t[9]=E):E=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const $=Rr(Bs(Ir,E),Bs(Dr,T)),O=_a(),K=Jl(Aj),I=Jl(Oj),X=l?.tabs??yj;let N;t[11]!==g||t[12]!==l?(N=Sa(l,g),t[11]=g,t[12]=l,t[13]=N):N=t[13];const C=N,R=w?.files.length??0;let H;if(t[14]!==u||t[15]!==d||t[16]!==O||t[17]!==v||t[18]!==p||t[19]!==y||t[20]!==S||t[21]!==X){let he;t[23]!==p?(he=se=>se.id==="pr"&&p==="gitlab"?{...se,icon:"gitlab"}:se,t[23]=p,t[24]=he):he=t[24],H=Ay({railOrder:d,hiddenSurfaces:u,planModeEnabled:v,isVSCode:Sn(),screenWidth:y,tabs:X,sourceControlConnected:S,extras:O}).map(he),t[14]=u,t[15]=d,t[16]=O,t[17]=v,t[18]=p,t[19]=y,t[20]=S,t[21]=X,t[22]=H}else H=t[22];const M=H;let _,B;t[25]!==m||t[26]!==g||t[27]!==o||t[28]!==x||t[29]!==C||t[30]!==S?(B=()=>{!o||!x||S||!C.has("pr")||m(o,xo(g,"pr"))},_=[m,g,o,x,C,S],t[25]=m,t[26]=g,t[27]=o,t[28]=x,t[29]=C,t[30]=S,t[31]=_,t[32]=B):(_=t[31],B=t[32]),c.useEffect(B,_);const[ee,ne]=c.useState(!1),re=c.useRef(null),te=c.useRef(null);let W;t[33]!==p||t[34]!==M||t[35]!==e?(W=he=>{const se=M.find(Ue=>Ue.id===he.active.id),Re=re.current?.getBoundingClientRect().left;!se||Re===void 0||(te.current?.cancel(),te.current=el({mode:se.mode,label:se.label??e(tn(se.labelKey,p)),from:xo(ue.getState().contextSurfaceZones,se.mode)},Ue=>Ue.x<Re-16))},t[33]=p,t[34]=M,t[35]=e,t[36]=W):W=t[36];const q=W;let oe;t[37]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{te.current?.cancel(),te.current=null},t[37]=oe):oe=t[37];const de=oe;let ce,je;t[38]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>()=>te.current?.cancel(),je=[],t[38]=ce,t[39]=je):(ce=t[38],je=t[39]),c.useEffect(ce,je);let be;t[40]!==o||t[41]!==O||t[42]!==f?(be=he=>{const se=te.current;if(te.current=null,se?.finish(o))return;const{active:Re,over:Ue}=he;if(!Ue||Re.id===Ue.id)return;const We=Qu(ue.getState().contextRailOrder,O).map(Bj),He=We.indexOf(Re.id),Be=We.indexOf(Ue.id);He===-1||Be===-1||f(qa(We,He,Be))},t[40]=o,t[41]=O,t[42]=f,t[43]=be):be=t[43];const pe=be;if(!o)return null;let U;t[44]!==e?(U=e("contextRail.aria.rail"),t[44]=e,t[45]=U):U=t[45];let Pe;t[46]!==M?(Pe=M.map(Fj),t[46]=M,t[47]=Pe):Pe=t[47];let xe;if(t[48]!==R||t[49]!==I||t[50]!==o||t[51]!==K||t[52]!==h||t[53]!==p||t[54]!==P||t[55]!==C||t[56]!==M||t[57]!==e||t[58]!==a){let he;t[60]!==R||t[61]!==I||t[62]!==o||t[63]!==K||t[64]!==h||t[65]!==p||t[66]!==P||t[67]!==C||t[68]!==e||t[69]!==a?(he=(se,Re)=>{const Ue=se.label??e(tn(se.labelKey,p)),We=se.id==="git"&&!a?R:0,He=Yn(se.mode)&&!C.has(se.mode)?K[bo(se.mode)]??0:0,Be=We>0?We:He>0?He:null,Y=Be!==null&&We===0;return n.jsx(Sj,{surface:se,isActive:C.has(se.mode),showActivityDot:!1,label:Ue,description:e(tn(se.descriptionKey,p)),badgeCount:Be,badgeAriaLabel:Be!==null?e(Y?Be===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Be===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:Ue,count:Be}):null,badgeDescription:Be!==null?e(Y?Be===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Be===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Be}):null,orderNumber:Re+1,showOrderNumber:P,onSelect:Me=>{Yn(Me.mode)&&I(bo(Me.mode)),h(o,Me.mode)}},se.id)},t[60]=R,t[61]=I,t[62]=o,t[63]=K,t[64]=h,t[65]=p,t[66]=P,t[67]=C,t[68]=e,t[69]=a,t[70]=he):he=t[70],xe=M.map(he),t[48]=R,t[49]=I,t[50]=o,t[51]=K,t[52]=h,t[53]=p,t[54]=P,t[55]=C,t[56]=M,t[57]=e,t[58]=a,t[59]=xe}else xe=t[59];let Ee;t[71]!==Pe||t[72]!==xe?(Ee=n.jsx(Uo,{items:Pe,strategy:Ya,children:xe}),t[71]=Pe,t[72]=xe,t[73]=Ee):Ee=t[73];let L;t[74]!==pe||t[75]!==q||t[76]!==$||t[77]!==Ee?(L=n.jsx(Tr,{sensors:$,collisionDetection:Mr,onDragStart:q,onDragCancel:de,onDragEnd:pe,children:Ee}),t[74]=pe,t[75]=q,t[76]=$,t[77]=Ee,t[78]=L):L=t[78];let ie;t[79]!==e?(ie=e("contextRail.configure.open"),t[79]=e,t[80]=ie):ie=t[80];let G;t[81]===Symbol.for("react.memo_cache_sentinel")?(G=()=>ne(!0),t[81]=G):G=t[81];let ae;t[82]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Z,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[82]=ae):ae=t[82];let ye;t[83]!==ie?(ye=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":ie,onClick:G,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ae})}),t[83]=ie,t[84]=ye):ye=t[84];let ge;t[85]!==e?(ge=e("contextRail.configure.open"),t[85]=e,t[86]=ge):ge=t[86];let Se;t[87]!==ge?(Se=n.jsx(Tt,{side:"left",sideOffset:8,children:ge}),t[87]=ge,t[88]=Se):Se=t[88];let ve;t[89]!==ye||t[90]!==Se?(ve=n.jsxs(Ot,{delayDuration:Rh,children:[ye,Se]}),t[89]=ye,t[90]=Se,t[91]=ve):ve=t[91];let Te;t[92]!==ee?(Te=n.jsx(nj,{open:ee,onOpenChange:ne}),t[92]=ee,t[93]=Te):Te=t[93];let z;return t[94]!==U||t[95]!==L||t[96]!==ve||t[97]!==Te?(z=n.jsxs("nav",{ref:re,"aria-label":U,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-2 bg-background py-2",children:[L,ve,Te]}),t[94]=U,t[95]=L,t[96]=ve,t[97]=Te,t[98]=z):z=t[98],z};function wj(t){return t.workStatusPanelVisible}function kj(t){return t.contextRailOrder}function jj(t){return t.contextRailHiddenSurfaces}function Cj(t){return t.setContextRailOrder}function Pj(t){return t.openContextSurface}function Ej(t){return t.closeContextZone}function Nj(t){return t.contextSurfaceZones}function Rj(t){return t.shortcutOverrides}function Dj(t){return t.planModeEnabled}function Ij(t){return t.status?.status==="connected"}function Tj(t){return Object.values(t.entries).some(Ij)}function Mj(t){return t.length===1&&t>="0"&&t<="9"}function Aj(t){return t.countByGuest}function Oj(t){return t.clearBadge}function Bj(t){return t.id}function Fj(t){return t.id}const _j=t=>{const e=Ke.c(16),{enabled:s,isSessionSearchOpen:r,openSessionSearch:o,closeSessionSearch:i,sessionSearchInputRef:l,sessionSearchContainerRef:a}=t,d=s===void 0?!0:s;let u,f;e[0]!==d||e[1]!==r||e[2]!==l?(u=()=>{if(!d||!r||typeof window>"u")return;const v=window.requestAnimationFrame(()=>{l.current?.focus(),l.current?.select()});return()=>window.cancelAnimationFrame(v)},f=[d,r,l],e[0]=d,e[1]=r,e[2]=l,e[3]=u,e[4]=f):(u=e[3],f=e[4]),c.useEffect(u,f);let h,m;e[5]!==d||e[6]!==o||e[7]!==l?(h=()=>{if(!d||typeof window>"u")return;const v=()=>{o(),l.current?.focus(),l.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",v),()=>window.removeEventListener("openchamber:sidebar-session-search",v)},m=[d,o,l],e[5]=d,e[6]=o,e[7]=l,e[8]=h,e[9]=m):(h=e[8],m=e[9]),c.useEffect(h,m);let g,b;e[10]!==i||e[11]!==d||e[12]!==r||e[13]!==a?(g=()=>{if(!d||!r||typeof document>"u")return;const v=x=>{a.current&&(a.current.contains(x.target)||i())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},b=[d,r,i,a],e[10]=i,e[11]=d,e[12]=r,e[13]=a,e[14]=g,e[15]=b):(g=e[14],b=e[15]),c.useEffect(g,b)},Lj=t=>{const e=Ke.c(4);let s;e[0]!==t?(s=(i,l)=>{const a=t.get(i);if(!a||a.length===0)return l;const d=new Map(l.map($j)),u=[];a.forEach(m=>{const g=d.get(m);g&&(u.push(g),d.delete(m))});const f=[],h=[];return l.forEach(m=>{d.has(m.id)&&(m.isArchivedBucket?h.push(m):f.push(m))}),[...f,...u,...h]},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 $j(t){return[t.id,t]}const zj=(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}))},Qc=(t,e,s)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const l of o.children)i=r(l)||i;return i&&s.add(o.session.id),i};for(const o of t)r(o)},Jn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(Jn(s,e))return!0;return!1},Kj=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!va(r),Wj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,ca=(t,e,s)=>{const r=new Map,o=i=>{const l=Xn(i.session)??ot(i.worktree?.path)??s;if(l){const a=r.get(l)??[];a.push(i.session.id),r.set(l,a)}if(!(i===t&&e))for(const a of i.children)o(a)};return o(t),[...r].map(([i,l])=>({directory:i,sessionIDs:l}))},da=(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})},Dh=t=>{const e=new Map(t.map(l=>[l.id,l])),s=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=s.get(l.parentId)??[];a.push(l),s.set(l.parentId,a)}const r=new Set,o=[],i=l=>{if(r.has(l.id))return;o.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of s.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&i(l)}),t.forEach(i),o},Ih=(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 m=o.get(u.parentId)??[];m.push(u.id),o.set(u.parentId,m)}const f=new Set;let h=u.id;for(;h;){if(f.has(h)){i.add(u.id);break}f.add(h),h=r.get(h)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const f=r.get(u);if(!f)return!1;a.add(u);let h=i.has(u);return!h&&e.archivedBucket&&f.nodeCount===0?h=(o.get(u)??[]).some(d):(!h&&!e.searchQuery&&(h=!0),!h&&(f.nodeCount>0||!s&&wo([f.name],e.searchQuery))&&(h=!0),h||(h=(o.get(u)??[]).some(d))),a.delete(u),h&&l.add(u),h};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Zc=new WeakMap;let Jc=1;const Hj=t=>{const e=Zc.get(t);if(e!==void 0)return e;const s=Jc;return Jc+=1,Zc.set(t,s),s},jr=t=>t.children.length===0?"":t.children.map(s=>{const r=Hj(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${jr(s)}`}).join("|"),Th=(t,e,s,r,o,i)=>{const l=Yt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??o,h=u.session.directory??i,m=tc(l,f??"",d.session.id),g=tc(l,h??"",u.session.id);return(m?s.has(m):!1)!==(g?r.has(g):!1)?!0:d.children.some((b,v)=>a(b,u.children[v]))};return a(t,e)},Vj=(t,e)=>t?t.branchLabel??null:e??null,Gj=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=ot(t?.path??null);return s&&r?{directory:r,branch:s}:null},Do=(t,e,s,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const l=a=>{if(`${s}:${o}:${a.session.id}`===e)return i=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),i},Rn=(t,e)=>`${t}\0${e}`,Gn=(t,e)=>t??wa(e)??ot(e??null),er=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ot(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},ll=t=>t.startsWith("__archived__:"),cl=(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},Mh=(t,e)=>cl(t.session,e)||t.children.some(s=>Mh(s,e)),Ah=(t,e)=>(cl(t.session,e)?1:0)+t.children.reduce((s,r)=>s+Ah(r,e),0),ed=({sessions:t,getSessionLocation:e,getSessionNode:s,query:r})=>t.flatMap(o=>{if(!cl(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}}]}),Oh=["chats","work"],Un=t=>t==="timeline"||t==="timeline-mixed",qr=t=>"run"in t,Uj=(t,e)=>`${t}:active:run:${e}`,ki=(t,e,s)=>{if(s||e.runKeyBySessionId.size===0)return[...t];const r=[],o=new Map;for(const i of t){const l=e.runKeyBySessionId.get(i.session.id),a=l?e.runs.get(l):void 0;if(!a){r.push(i);continue}const d=o.get(a.key);if(d){d.lanes.push(i);continue}const u={run:a,lanes:[i]};o.set(a.key,u),r.push(u)}for(const i of o.values()){const l=new Map(i.run.memberIds.map((a,d)=>[a,d]));i.lanes.sort((a,d)=>(l.get(a.session.id)??0)-(l.get(d.session.id)??0))}return r},Bh=(t,e)=>{const s=e.trim().toLowerCase(),r=s.startsWith("ses_"),o=i=>i.reduce((l,a)=>l+(!r||a.session.id.toLowerCase()===s?1:0)+o(a.children),0);return o(t)},td=[],qj=new Set,sd=32,nd=52,Yj=3,Xj=7,rd=7,od=7,Fh=t=>`timeline-project:${t}`,lr=32,cn=28,id=(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 Ka(t.session,e.session,s,Zu)},ji=t=>{const e=new Map,s=new Map,r=[],o=new WeakMap,i=t.map(l=>({node:l,visited:!1})).reverse();for(;i.length>0;){const l=i.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),s.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),o.set(l.node,[d,d+1]),i.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const f=l.node.children[u];f&&i.push({node:f,visited:!1})}continue}const a=o.get(l.node);a&&o.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:s,preorderIds:Object.freeze(r),subtreeRangeByNode:o}},Qj=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,Zj=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},Jj=t=>{const e=[],s=[],r=[],o=[],i=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds),f=t.workSessionIds??qj,h=N=>d&&f.has(N);let m=0;const b=[...[...t.authoritativeSections.flatMap(N=>N.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;b.length>0;){const N=b.pop();N&&(l.set(N.session.id,N.session),b.push(...N.children))}const v=N=>{const C=a.get(N)??0;return a.set(N,C+1),C===0?N:`${N}:${C}`},x=N=>{e.push(Object.freeze(N))},S=t.runIndex??Oy,p=(N,C)=>{const R=Uj(C.renderContext,N.run.key),H=!Un(C.renderContext)&&(d||t.expandedParents.has(R)),M=N.lanes[0]?.session.id,_=M&&C.getSecondaryMeta?C.getSecondaryMeta(M):C.secondaryMeta,B=Object.freeze([...new Set(N.lanes.flatMap(ee=>(C.getBlockingBadgeSessionScopes?.(ee.session.id)??[]).flatMap(ne=>ne.sessionIDs)))]);x({kind:"run",key:v(`${C.containerKey}:run:${N.run.key}`),estimateSize:Un(C.renderContext)?nd:sd,run:N.run,depth:C.baseDepth??0,laneNodes:Object.freeze([...N.lanes]),blockingSessionIds:B,projectId:C.projectId,projectLabel:_?.projectLabel??null,groupDirectory:C.groupDirectory,renderContext:C.renderContext,expansionKey:R,expanded:H,forceExpanded:d}),H&&w(N.lanes,(C.baseDepth??0)+1,C)},y=N=>{for(const C of ki(N.nodes,S,N.archived))qr(C)?p(C,N):w([C],N.baseDepth??0,N)},w=(N,C,R)=>{const H=[...N].reverse().map(M=>({node:M,depth:C,directory:R.groupDirectory}));for(;H.length>0;){const M=H.pop();if(!M)continue;const _=v(`${R.containerKey}:session:${M.node.session.id}`),B=M.node.session.directory??M.directory;l.set(M.node.session.id,M.node.session),x({kind:"session",key:_,estimateSize:Un(R.renderContext)?nd:sd,node:M.node,blockingBadgeSessionScopes:M.depth===C?R.getBlockingBadgeSessionScopes?.(M.node.session.id)??R.blockingBadgeSessionScopes:void 0,depth:M.depth,projectId:R.projectId,groupDirectory:M.directory,ownerKey:R.ownerKey,selectionScopeKey:R.selectionScopeKey,archived:R.archived,renderContext:R.renderContext,secondaryMeta:R.getSecondaryMeta?R.getSecondaryMeta(M.node.session.id):R.secondaryMeta??null});const ee=R.indexedNodes?.subtreeRangeByNode.get(M.node),ne=ee&&ee[1]>ee[0]+1?Object.freeze([(R.selectionPoolOffset??0)+ee[0]+1,(R.selectionPoolOffset??0)+ee[1]]):void 0;if(s.push(Object.freeze({id:M.node.session.id,rowKey:_,scopeKey:R.selectionScopeKey,archived:R.archived,descendantRange:ne})),!(!d&&!t.expandedParents.has(Qj(R.renderContext,R.archived,M.node.session.id))))for(let re=M.node.children.length-1;re>=0;re-=1){const te=M.node.children[re];te&&H.push({node:te,depth:M.depth+1,directory:B})}}},j=N=>{const C=t.groupSearchDataByGroup.get(N);if(C?.hasMatch!==!0)return 0;const R=f.size>0?C.filteredNodes.filter(M=>h(M.session.id)):[];return Math.max(0,C.matchedSessionCount-Bh(R,t.normalizedQuery))+C.folderNameMatchCount+(C.groupMatches?1:0)},k=(N,C,R,H,M)=>{const _=t.groupSearchDataByGroup.get(N);if(d){const Y=j(N);if(Y===0)return;m+=Y}const B=(d?_?.filteredNodes??[]:N.sessions).filter(Y=>!h(Y.session.id)).sort((Y,Me)=>id(Y,Me,u,t.sessionOrderIndex)),ee=ji(B),ne=r.length;r.push(...ee.preorderIds);for(const[Y,Me]of ee.sessionsById)l.set(Y,Me);const re=Gn(R,N.directory),te=!d&&t.collapsedGroups.has(C),W=H?0:1,q=M!==void 0&&M.renderContext!=="project",oe=t.groupStatusByKey.get(C),de=B.length===0&&(!oe||oe.state==="ready")&&er(N).every(({scopeKey:Y})=>(t.foldersMap[Y]??td).length===0);if(!H){const Y=ee.preorderIds.flatMap(Me=>ee.sessionsById.get(Me)??[]);x({kind:"group-header",key:`${C}:header`,estimateSize:lr,group:N,groupKey:C,projectId:R,collapsed:te&&!de,forceExpanded:d,empty:de,allSessions:Object.freeze(Y)})}if(te&&!de)return;const ce=er(N).flatMap(({scopeKey:Y,directory:Me})=>(t.foldersMap[Y]??td).map(Ge=>({folder:Ge,scopeKey:Y,scopeDirectory:Me,ownerKey:re,nodes:da(Ge.sessionIds,ee.byId).sort((Ve,dt)=>id(Ve,dt,u,t.sessionOrderIndex))}))),je=Ih(ce.map(Y=>({id:Y.folder.id,name:Y.folder.name,parentId:Y.folder.parentId,nodeCount:Y.nodes.length})),{archivedBucket:N.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),be=ce.filter(Y=>je.has(Y.folder.id)),pe=new Map(be.map(Y=>[Rn(Y.scopeKey,Y.folder.id),Y])),U=new Map;for(const Y of be){if(!Y.folder.parentId)continue;const Me=Rn(Y.scopeKey,Y.folder.parentId),Ge=U.get(Me)??[];Ge.push(Y),U.set(Me,Ge)}const Pe=Dh(be.map(Y=>({...Y.folder,scopeKey:Y.scopeKey}))).map(Y=>pe.get(Rn(Y.scopeKey??"",Y.id))).filter(Y=>!!Y),xe=new Set(be.flatMap(Y=>Y.folder.sessionIds)),Ee=B.filter(Y=>!xe.has(Y.session.id)),L=new Map,ie=Pe.map(Y=>({folder:Y,visited:!1})),G=new Set;for(;ie.length>0;){const Y=ie.pop();if(!Y)continue;const Me=Rn(Y.folder.scopeKey,Y.folder.folder.id);if(!Y.visited){if(G.has(Me))continue;G.add(Me),ie.push({folder:Y.folder,visited:!0});for(const Ve of U.get(Me)??[])ie.push({folder:Ve,visited:!1});continue}const Ge=Y.folder.nodes.flatMap(Ve=>{const dt=ee.subtreeRangeByNode.get(Ve);return dt?ee.preorderIds.slice(dt[0],dt[1]).flatMap(et=>ee.sessionsById.get(et)??[]):[Ve.session]});for(const Ve of U.get(Me)??[])Ge.push(...L.get(Rn(Ve.scopeKey,Ve.folder.id))??[]);L.set(Me,Object.freeze(Ge))}const ae=new Set,ye=(Y,Me)=>{const Ge=Rn(Y.scopeKey,Y.folder.id);if(ae.has(Ge))return;ae.add(Ge);const Ve=Me?`${Me} / ${Y.folder.name}`:Y.folder.name,dt=`${C}:folder:${Ge}`,et=Y.nodes.length===0&&(U.get(Ge)?.length??0)===0,ct=!d&&!et&&t.collapsedFolders.has(Y.folder.id),me=L.get(Ge)??[],Ne=ct&&!N.isArchivedBucket?da([...new Set(me.map($e=>$e.id))],ee.byId):[],qe=re?t.folderAuthorityByOwner.get(re):void 0,Ye=!!re&&!N.isArchivedBucket&&!ll(Y.scopeKey)&&qe?.complete===!0&&qe.scopeKeys.includes(Y.scopeKey);if(x({kind:"folder-header",key:dt,estimateSize:lr,depth:W,group:N,folder:Y.folder,displayName:Ve,scopeKey:Y.scopeKey,scopeDirectory:Y.scopeDirectory,ownerKey:re,nodes:Y.nodes,activityNodes:Ne,projectId:R,archived:N.isArchivedBucket===!0,collapsed:ct,forceExpanded:d,deleteSessions:me,subFolderCount:U.get(Ge)?.length??0,dropEnabled:Ye}),re&&i.push(Object.freeze({rowKey:dt,scopeKey:Y.scopeKey,folderId:Y.folder.id,ownerKey:re,enabled:Ye})),!ct){y({nodes:Y.nodes,containerKey:dt,projectId:R,groupDirectory:Y.scopeDirectory??N.directory,ownerKey:re,selectionScopeKey:re,archived:N.isArchivedBucket===!0,renderContext:"project",indexedNodes:ee,selectionPoolOffset:ne,baseDepth:W+1});for(const $e of U.get(Ge)??[])ye($e,Ve)}};for(const Y of Pe)ye(Y,"");const ge=R?t.sessionBatchSize:void 0,Se=M?.initial??ge??(t.hideDirectoryControls?10:rd),ve=M?.increment??ge??od,Te=Math.max(Se,t.visibleCountByContainer.get(C)??Se),z=Y=>!qr(Y)&&M?.pinnedAlwaysVisible===!0&&Wa(u,Y.session.directory??N.directory,Y.session.id),he=ki(Ee,S,N.isArchivedBucket===!0),se=he.filter(Y=>!z(Y));let Re=Te;const Ue=N.isArchivedBucket||d?he:he.filter(Y=>z(Y)?!0:Re<=0?!1:(Re-=1,!0)),We=Ue.flatMap(Y=>qr(Y)?Y.lanes:[Y]);y({nodes:We,containerKey:C,projectId:R,groupDirectory:N.directory,ownerKey:re,selectionScopeKey:re,archived:N.isArchivedBucket===!0,renderContext:M?.renderContext??"project",indexedNodes:ee,selectionPoolOffset:ne,baseDepth:W});const He=he.length-Ue.length,Be=Te-Re;!d&&!N.isArchivedBucket&&He>0?x({kind:"show-control",key:`${C}:more`,estimateSize:cn,control:"more",containerKey:C,currentCount:Be,increment:ve,depth:W,flat:q}):!d&&!N.isArchivedBucket&&se.length>Se&&He===0&&x({kind:"show-control",key:`${C}:fewer`,estimateSize:cn,control:"fewer",containerKey:C,currentCount:Be,increment:ve,depth:W,flat:q}),B.length===0&&be.length===0?oe&&oe.state!=="ready"?x({kind:"status",key:`${C}:status`,estimateSize:cn,status:oe,group:N,groupKey:C,depth:W,flat:q}):N.isArchivedBucket&&x({kind:"empty",key:`${C}:empty`,estimateSize:cn,emptyKind:"archived",depth:W}):oe&&oe.state!=="ready"&&oe.state!=="loading"&&x({kind:"status",key:`${C}:status`,estimateSize:cn,status:oe,group:N,groupKey:C,depth:W,flat:q})},P=N=>{const C=!d&&t.collapsedActivities.has(N),R=e.length;return x({kind:"activity-header",key:`activity:${N}:header`,estimateSize:lr,activityKey:N,collapsed:C,forceExpanded:d}),o.push(Object.freeze({rowIndex:R,kind:"activity",id:N})),C},A=t.viewMode==="timeline",F=N=>"run"in N,D=N=>{const C=ki(N.map(H=>H.node),S,!1),R=new Map(N.map(H=>[H.node,H]));return C.flatMap(H=>{if(!qr(H)){const M=R.get(H);return M?[M]:[]}return[{run:H.run,items:H.lanes.flatMap(M=>R.get(M)??[])}]})},E=(N,C,R)=>{const H=N.items[0];if(!H)return;const M=N.items.map(te=>te.node),_=ji(M),B=r.length;r.push(..._.preorderIds);const ee=Gn(H.projectId,H.groupDirectory),ne=new Map(N.items.map(te=>[te.node.session.id,te.getSecondaryMeta?te.getSecondaryMeta(te.node.session.id):te.secondaryMeta])),re=new Map(N.items.map(te=>[te.node.session.id,te.blockingBadgeSessionScopes]));p({run:N.run,lanes:M},{nodes:M,containerKey:C,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:ee,selectionScopeKey:null,archived:!1,renderContext:R,getSecondaryMeta:te=>ne.get(te)??null,getBlockingBadgeSessionScopes:te=>re.get(te),indexedNodes:_,selectionPoolOffset:B})},T=(N,C,R,H=()=>1)=>{for(const M of D(N)){if(F(M)){E(M,C,R),d&&(m+=M.items.reduce((re,te)=>re+H(te),0));continue}const _=M,B=ji([_.node]),ee=r.length;r.push(...B.preorderIds);const ne=Gn(_.projectId,_.groupDirectory);y({nodes:[_.node],containerKey:C,projectId:_.projectId,groupDirectory:_.groupDirectory,ownerKey:ne,selectionScopeKey:null,archived:!1,renderContext:R,blockingBadgeSessionScopes:_.blockingBadgeSessionScopes,secondaryMeta:_.secondaryMeta,getSecondaryMeta:_.getSecondaryMeta,indexedNodes:B,selectionPoolOffset:ee}),d&&(m+=H(_))}};t.chatGroup&&(!d||j(t.chatGroup)>0)&&(P("chats")||k(t.chatGroup,"activity:chats",null,!0,{initial:Yj,increment:Xj,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}));const $="timeline-mixed",O=(N,C,R,H,M)=>{const _=Math.max(H,t.visibleCountByContainer.get(C)??H),B=D(N),ee=d?B:B.slice(0,_);T(ee.flatMap(ne=>F(ne)?ne.items:[ne]),C,R),!d&&(B.length>ee.length?x({kind:"show-control",key:`${C}:more`,estimateSize:cn,control:"more",containerKey:C,currentCount:ee.length,increment:M,flat:!0}):B.length>H&&x({kind:"show-control",key:`${C}:fewer`,estimateSize:cn,control:"fewer",containerKey:C,currentCount:ee.length,increment:M,flat:!0}))},K=t.workItems??[];if(K.length>0&&(P("work")||T(K,"activity:work",$,C=>Ah(C.node,t.normalizedQuery))),A){const N=new Map;for(const C of t.timelineItems??[]){if(!C.projectId||h(C.node.session.id))continue;const R=N.get(C.projectId);R?R.push(C):N.set(C.projectId,[C])}for(const C of t.sections){const R=C.project.id,H=N.get(R)??[];if(d&&H.length===0)continue;const M=!d&&t.collapsedProjects.has(R),_=e.length;if(x({kind:"project-header",key:`project:${R}:header`,estimateSize:lr,section:C,collapsed:M,forceExpanded:d}),o.push(Object.freeze({rowIndex:_,kind:"project",id:R})),M)continue;if(H.length>0){O(H,Fh(R),"timeline",rd,od);continue}const B=C.groups.find(re=>re.isMain);if(!B)continue;const ee=`${R}:${B.id}`,ne=t.groupStatusByKey.get(ee);ne&&ne.state!=="ready"&&x({kind:"status",key:`${ee}:status`,estimateSize:cn,status:ne,group:B,groupKey:ee,flat:!0})}}let I=A?[]:t.singleProjectMode?t.sections.filter(N=>N.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const N=I.find(C=>C.project.id===t.activeProjectId)??I[0];I=N?[N]:[]}for(const N of I){const C=zj(N,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!C.some(H=>j(H.group)>0))continue;const R=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(N.project.id);if(!t.showOnlyMainWorkspace){const H=e.length;x({kind:"project-header",key:`project:${N.project.id}:header`,estimateSize:lr,section:N,collapsed:R,forceExpanded:d}),o.push(Object.freeze({rowIndex:H,kind:"project",id:N.project.id}))}if(!R)for(const H of C)k(H.group,H.groupKey,H.projectId,H.hideGroupLabel)}e.length===0&&x({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const X=new Map;return e.forEach((N,C)=>X.set(N.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:X,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?m:0})},Yr="oc.sessions.projectCollapse",ad="oc.sessions.groupOrder",ld="oc.sessions.groupCollapse",cd=t=>{if(!t)return new Set;try{const e=qo(rn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},e2=t=>{if(!t)return new Map;try{const e=Xa(rn(),qo(rn())).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}},t2=t=>{const e=Ke.c(40),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=So(),e[0]=o):o=e[0];const i=o;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>cd(i.getItem(Yr)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>cd(i.getItem(ld)),e[2]=u):u=e[2];const[f,h]=c.useState(u),[m,g]=c.useState(s2);let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=()=>e2(i.getItem(ad)),e[3]=b):b=e[3];const[v,x]=c.useState(b),S=c.useRef(0),p=c.useRef(!1),y=c.useRef(!1),w=c.useRef(null),j=c.useRef(null);let k;e[4]!==s?(k=()=>{if(s)return;const de=j.current;if(j.current=null,w.current=null,!de)return;const{projects:ce}=Zt.getState(),je=ce.map(be=>({...be,sidebarCollapsed:de.has(be.id)}));En({projects:je}).catch(n2)},e[4]=s,e[5]=k):k=e[5];const P=k;let A;e[6]!==P||e[7]!==s?(A=de=>{!globalThis.window||s||(j.current=de,w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{P()},700))},e[6]=P,e[7]=s,e[8]=A):A=e[8];const F=A;let D,E;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&w.current!==null&&window.clearTimeout(w.current),w.current=null,j.current=null},E=[],e[9]=D,e[10]=E):(D=e[9],E=e[10]),c.useEffect(D,E);let T,$;e[11]!==v?($=()=>{if(y.current)try{i.setItem(ad,JSON.stringify(Object.fromEntries(v.entries())))}catch{}},T=[v,i],e[11]=v,e[12]=T,e[13]=$):(T=e[12],$=e[13]),c.useEffect($,T);let O,K;e[14]!==f?(O=()=>{if(p.current)try{i.setItem(ld,JSON.stringify(Array.from(f)))}catch{}},K=[f,i],e[14]=f,e[15]=O,e[16]=K):(O=e[15],K=e[16]),c.useEffect(O,K);let I;e[17]!==r||e[18]!==F?(I=()=>{S.current=Date.now()+150,p.current=!0,h(new Set),g(r2),d(()=>{const de=new Set(r.map(o2));try{i.setItem(Yr,JSON.stringify(Array.from(de)))}catch{}return F(de),de})},e[17]=r,e[18]=F,e[19]=I):I=e[19];const X=I;let N;e[20]!==F?(N=()=>{S.current=Date.now()+150,p.current=!0,h(new Set),g(i2),d(()=>{const de=new Set;try{i.setItem(Yr,JSON.stringify([]))}catch{}return F(de),de})},e[20]=F,e[21]=N):N=e[21];const C=N;let R;e[22]!==F?(R=de=>{S.current=Date.now()+150,d(ce=>{const je=new Set(ce);je.has(de)?je.delete(de):je.add(de);try{i.setItem(Yr,JSON.stringify(Array.from(je)))}catch{}return F(je),je})},e[22]=F,e[23]=R):R=e[23];const H=R;let M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=de=>{p.current=!0,h(ce=>{const je=new Set(ce);return je.has(de)?je.delete(de):je.add(de),je})},e[24]=M):M=e[24];const _=M;let B;e[25]===Symbol.for("react.memo_cache_sentinel")?(B=de=>{y.current=!0,x(de)},e[25]=B):B=e[25];const ee=B,{getOrderedGroups:ne}=Lj(v);let re;e[26]!==m||e[27]!==f||e[28]!==a||e[29]!==v?(re={collapsedProjects:a,collapsedGroups:f,collapsedActivities:m,groupOrderByProject:v},e[26]=m,e[27]=f,e[28]=a,e[29]=v,e[30]=re):re=e[30];const te=re;let W;e[31]!==X||e[32]!==C||e[33]!==ne||e[34]!==F||e[35]!==H?(W={setCollapsedProjects:d,toggleProject:H,collapseAll:X,expandAll:C,scheduleCollapsedProjectsPersist:F,setCollapsedGroups:h,setCollapsedActivities:g,toggleGroup:_,setGroupOrderByProject:ee,getOrderedGroups:ne},e[31]=X,e[32]=C,e[33]=ne,e[34]=F,e[35]=H,e[36]=W):W=e[36];const q=W;let oe;return e[37]!==q||e[38]!==te?(oe={state:te,actions:q},e[37]=q,e[38]=te,e[39]=oe):oe=e[39],oe};function s2(){return new Set}function n2(){}function r2(t){return new Set([...t,...Oh])}function o2(t){return t.id}function i2(t){const e=new Set(t);for(const s of Oh)e.delete(s);return e}const a2=5*6e4,l2=t=>{const e=Ke.c(38),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=Ws(),u=gn(c2),f=gn(d2),h=c.useRef(null),m=c.useRef(a);let g,b;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==f?(g=()=>{const E=a&&!m.current;m.current=a;const T=h.current;if(!(!E||!d||!T||T.git!==d||T.runtimeKey!==f))for(const $ of T.paths)gr(()=>u($,d))},b=[a,u,d,f],e[0]=a,e[1]=u,e[2]=d,e[3]=f,e[4]=g,e[5]=b):(g=e[4],b=e[5]),c.useEffect(g,b);let v,x;e[6]!==a||e[7]!==u||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==i?(v=()=>{if(!a)return;if(!d||s.length===0){h.current=null,i(new Map);return}let E=h.current;(!E||E.runtimeKey!==f||E.git!==d)&&(E={runtimeKey:f,git:d,paths:new Set},h.current=E);const{paths:T}=E,$=new Set(s.map(u2));for(const I of T)$.has(I)||T.delete(I);const O=[...$].filter(I=>!T.has(I));if(O.length===0)return;for(const I of O)T.add(I);const K=I=>{const X=gn.getState().directories.get(I);X?.isGitRepo!==!1&&!X?.status&&T.delete(I)};gr(async()=>{await d.prefetchProjectStatuses?.(O),await Promise.all(O.map(I=>u(I,d).then(()=>K(I),()=>K(I))))})},x=[a,s,d,f,u,i],e[6]=a,e[7]=u,e[8]=d,e[9]=f,e[10]=s,e[11]=i,e[12]=v,e[13]=x):(v=e[12],x=e[13]),c.useEffect(v,x);let S,p;e[14]!==a||e[15]!==o||e[16]!==s||e[17]!==i?(S=()=>{if(!a)return;const E=new Map;s.forEach(T=>{E.set(T.id,o.get(T.normalizedPath)?.isGitRepo??null)}),i(E)},p=[a,s,o,i],e[14]=a,e[15]=o,e[16]=s,e[17]=i,e[18]=S,e[19]=p):(S=e[18],p=e[19]),c.useEffect(S,p);let y;if(e[20]!==o||e[21]!==s){let E;e[23]!==o?(E=T=>{const $=o.get(T.normalizedPath)?.branch??"";return`${T.id}:${$}`},e[23]=o,e[24]=E):E=e[24],y=s.map(E).join("|"),e[20]=o,e[21]=s,e[22]=y}else y=e[22];const w=y;let j;e[25]===Symbol.for("react.memo_cache_sentinel")?(j=new Map,e[25]=j):j=e[25];const k=c.useRef(j);let P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=new Map,e[26]=P):P=e[26];const A=c.useRef(P);let F;e[27]!==a||e[28]!==o||e[29]!==s||e[30]!==l?(F=()=>{if(!a)return;let E=!1;const T=setTimeout(()=>{(async()=>{const O=new Set(s.map(f2));for(const R of k.current.keys())O.has(R)||(k.current.delete(R),A.current.delete(R));const K=Date.now(),I=s.filter(R=>{const H=o.get(R.normalizedPath);if(H?.isGitRepo===!1)return k.current.delete(R.id),A.current.delete(R.id),!1;if(H?.isGitRepo!==!0||H.branch===null)return!1;const M=H.branch.trim(),_=`${R.normalizedPath}\0${M}`,B=k.current.get(R.id);if(B===_){const ee=A.current.get(R.id);return ee&&(ee.at=K),!1}return!(B!==void 0&&K-(A.current.get(R.id)?.at??0)<a2)});if(I.length===0)return;const X=await gr(()=>Promise.all(I.map(async R=>{const H=o.get(R.normalizedPath)?.branch?.trim()??"",M=`${R.normalizedPath}\0${H}`,_=await Wu(R.normalizedPath,H?{knownBranch:H}:void 0).catch(h2);return{id:R.id,inputKey:M,branch:_}})));if(E)return;const N=X.filter(p2);if(N.length===0)return;const C=Date.now();l(R=>{const H=new Map(R);return N.forEach(M=>{const{id:_,branch:B}=M;B&&H.set(_,B)}),H}),N.forEach(R=>{const{id:H,inputKey:M,branch:_}=R;k.current.set(H,M),_&&A.current.set(H,{branch:_,at:C})})})()},150);return()=>{E=!0,clearTimeout(T)}},e[27]=a,e[28]=o,e[29]=s,e[30]=l,e[31]=F):F=e[31];let D;e[32]!==a||e[33]!==o||e[34]!==s||e[35]!==w||e[36]!==l?(D=[a,s,w,o,l],e[32]=a,e[33]=o,e[34]=s,e[35]=w,e[36]=l,e[37]=D):D=e[37],c.useEffect(F,D)};function c2(t){return t.ensureStatus}function d2(t){return t.runtimeKey}function u2(t){return t.normalizedPath}function f2(t){return t.id}function h2(){return null}function p2(t){return t.branch}const m2=t=>{const e=Ke.c(19),{open:s,onOpenChange:r,project:o,onSave:i}=t,l=ue(g2),[a,d]=c.useState("general");let u,f;e[0]!==s?(u=()=>{s&&d("general")},f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),c.useEffect(u,f);const h=o?.id??null;let m;e:{if(!h){m=void 0;break e}let S;e[3]!==r||e[4]!==h||e[5]!==l?(S=()=>{r(!1),l(h)},e[3]=r,e[4]=h,e[5]=l,e[6]=S):S=e[6],m=S}const g=m;let b;e[7]!==g||e[8]!==i||e[9]!==s||e[10]!==o||e[11]!==a?(b=s&&o?n.jsx(jg,{frame:"dialog",project:o,onIdentitySave:i,tab:a,onTabChange:d,onOpenWorktrees:g}):null,e[7]=g,e[8]=i,e[9]=s,e[10]=o,e[11]=a,e[12]=b):b=e[12];let v;e[13]!==b?(v=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]=v):v=e[14];let x;return e[15]!==r||e[16]!==s||e[17]!==v?(x=n.jsx(Ks,{open:s,onOpenChange:r,children:v}),e[15]=r,e[16]=s,e[17]=v,e[18]=x):x=e[18],x};function g2(t){return t.setWorktreesPageProjectId}function b2(t,e,s,r){const o=Ke.c(6),[i,l]=c.useState(!0);let a,d;return o[0]!==e||o[1]!==r||o[2]!==s||o[3]!==t?(a=()=>{const u=t.current,f=e.current,h=s.current;if(!u||!f||!h||r===0)return;const m=()=>{const b=f.lastElementChild,v=b?b.getBoundingClientRect().width:0,x=Number.parseFloat(getComputedStyle(f).columnGap)||0,S=Number.parseFloat(getComputedStyle(u).columnGap)||0,p=f.getBoundingClientRect().width+r*(x+v),y=u.getBoundingClientRect().right-f.getBoundingClientRect().left-h.getBoundingClientRect().width-S;l(p<=y)};m();const g=new ResizeObserver(m);return g.observe(u),g.observe(f),g.observe(h),()=>g.disconnect()},d=[t,e,s,r],o[0]=e,o[1]=r,o[2]=s,o[3]=t,o[4]=a,o[5]=d):(a=o[4],d=o[5]),c.useLayoutEffect(a,d),i}const _h="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",Lh="text-muted-foreground hover:text-foreground hover:bg-transparent";function Xr(t){const e=Ke.c(14),{label:s,pressed:r,onClick:o,className:i,children:l}=t,a=r?_h:Lh;let d;e[0]!==i||e[1]!==a?(d=ke(i,a),e[0]=i,e[1]=a,e[2]=d):d=e[2];let u;e[3]!==l||e[4]!==s||e[5]!==o||e[6]!==r||e[7]!==d?(u=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:d,"aria-label":s,"aria-pressed":r,children:l})}),e[3]=l,e[4]=s,e[5]=o,e[6]=r,e[7]=d,e[8]=u):u=e[8];let f;e[9]!==s?(f=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let h;return e[11]!==u||e[12]!==f?(h=n.jsxs(Ot,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13],h}function y2(t){const e=Ke.c(245),{t:s}=vt(),r=Ju(),{hideDirectoryControls:o,showProjectDisplayControls:i,showSectionControls:l,handleOpenDirectoryDialog:a,showSourceBoard:d,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:h,openSessionSearch:m,closeSessionSearch:g,sessionSearchInputRef:b,sessionSearchQuery:v,setSessionSearchQuery:x,hasSessionSearchQuery:S,searchMatchCount:p,collapseAll:y,expandAll:w}=t,j=c.useRef(null),k=c.useRef(null),P=c.useRef(null),A=b2(j,k,P,r.length),F=cs(L2),D=cs(_2),E=ue(F2),T=ue(B2),$=ue(O2),O=ue(A2),K=os(M2),I=os(T2),X=os(I2),N=os(D2),C=ue(R2),R=os(N2),H=os(E2),M=os(P2),_=os(C2),B=os(j2),ee=os(k2),ne=os(w2),re=os(v2),te=i&&B==="timeline",W=i&&!te&&ne==="single";let q;e[0]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(Z,{name:"check",className:"h-4 w-4 text-primary"}),e[0]=q):q=e[0];const oe=q;let de;e[1]!==s?(de=(rt,ut,pt,fe)=>{const lt=ut.find(ft=>{const[mt]=ft;return mt===pt})?.[1];return n.jsxs(sf,{children:[n.jsxs(nf,{children:[n.jsx("span",{className:"flex-1",children:s(rt)}),lt?n.jsx("span",{className:"ms-4 text-muted-foreground",children:s(lt)}):null]}),n.jsx(rf,{className:"min-w-[160px]",children:ut.map(ft=>{const[mt,Rt]=ft;return n.jsxs(qt,{onClick:()=>fe(mt),className:"flex items-center justify-between",children:[n.jsx("span",{children:s(Rt)}),pt===mt?oe:null]},mt)})})]})},e[1]=s,e[2]=de):de=e[2];const ce=de;let je;e[3]!==s?(je=(rt,ut,pt)=>n.jsxs(qt,{onClick:pt,className:"flex items-center justify-between",children:[n.jsx("span",{children:s(rt)}),ut?oe:null]}),e[3]=s,e[4]=je):je=e[4];const be=je;let pe;e[5]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(Z,{name:"checkbox-multiple",className:"h-4 w-4"}),e[5]=pe):pe=e[5];let U;e[6]!==F||e[7]!==s?(U=s(F?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[6]=F,e[7]=s,e[8]=U):U=e[8];let Pe;e[9]!==U?(Pe=n.jsx("span",{children:U}),e[9]=U,e[10]=Pe):Pe=e[10];let xe;e[11]!==Pe||e[12]!==D?(xe=n.jsxs(qt,{onClick:D,className:"flex items-center gap-2",children:[pe,Pe]},"select"),e[11]=Pe,e[12]=D,e[13]=xe):xe=e[13];let Ee;if(e[14]!==ce||e[15]!==y||e[16]!==w||e[17]!==W||e[18]!==ne||e[19]!==R||e[20]!==C||e[21]!==re||e[22]!==H||e[23]!==I||e[24]!==N||e[25]!==ee||e[26]!==_||e[27]!==K||e[28]!==i||e[29]!==l||e[30]!==X||e[31]!==B||e[32]!==s||e[33]!==xe||e[34]!==te||e[35]!==be||e[36]!==M){if(Ee=[xe],i){let rt;e[38]!==s?(rt=s("sessions.sidebar.header.viewMode.label"),e[38]=s,e[39]=rt):rt=e[39];let ut;e[40]!==rt?(ut=n.jsx(Fi,{children:rt}),e[40]=rt,e[41]=ut):ut=e[41];let pt;e[42]!==ee||e[43]!==B||e[44]!==s?(pt=[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(lt=>{const[ft,mt]=lt;return n.jsxs(qt,{onClick:()=>{ee(ft),En({sidebarViewMode:ft})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(mt)}),B===ft?oe:null]},ft)}),e[42]=ee,e[43]=B,e[44]=s,e[45]=pt):pt=e[45];let fe;e[46]!==ut||e[47]!==pt?(fe=n.jsxs(n.Fragment,{children:[ut,pt]}),e[46]=ut,e[47]=pt,e[48]=fe):fe=e[48],Ee.push(fe)}if(!te){let rt;if(e[49]!==ce||e[50]!==R||e[51]!==H){let lt;e[53]!==H?(lt=ft=>{H(ft),En({sidebarProjectSortOrder:ft})},e[53]=H,e[54]=lt):lt=e[54],rt=ce("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"]],R,lt),e[49]=ce,e[50]=R,e[51]=H,e[52]=rt}else rt=e[52];let ut;e[55]!==ce||e[56]!==_||e[57]!==i||e[58]!==M?(ut=i?ce("sessions.sidebar.header.actions.sortWorktrees",[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]],M,lt=>{_(lt),En({sidebarWorktreeSortOrder:lt})}):null,e[55]=ce,e[56]=_,e[57]=i,e[58]=M,e[59]=ut):ut=e[59];let pt;e[60]!==ce||e[61]!==ne||e[62]!==re||e[63]!==i?(pt=i?ce("sessions.sidebar.header.projectDisplay.label",[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]],ne,lt=>{re(lt),En({sidebarProjectDisplayMode:lt})}):null,e[60]=ce,e[61]=ne,e[62]=re,e[63]=i,e[64]=pt):pt=e[64];let fe;e[65]!==rt||e[66]!==ut||e[67]!==pt?(fe=n.jsxs(n.Fragment,{children:[rt,ut,pt]}),e[65]=rt,e[66]=ut,e[67]=pt,e[68]=fe):fe=e[68],Ee.push(fe)}if(l){let rt;e[69]!==I||e[70]!==K?(rt=()=>{I(!K),En({sidebarShowChatsSection:!K})},e[69]=I,e[70]=K,e[71]=rt):rt=e[71];let ut;e[72]!==K||e[73]!==rt||e[74]!==be?(ut=be("sessions.sidebar.header.displayMode.showChats",K,rt),e[72]=K,e[73]=rt,e[74]=be,e[75]=ut):ut=e[75];let pt;e[76]!==C||e[77]!==N||e[78]!==X||e[79]!==be?(pt=C?be("sessions.sidebar.header.displayMode.showWork",X,()=>{N(!X),En({sidebarShowWorkSection:!X})}):null,e[76]=C,e[77]=N,e[78]=X,e[79]=be,e[80]=pt):pt=e[80];let fe;e[81]!==ut||e[82]!==pt?(fe=n.jsxs(n.Fragment,{children:[ut,pt]}),e[81]=ut,e[82]=pt,e[83]=fe):fe=e[83],Ee.push(fe)}if(!W){let rt;e[84]===Symbol.for("react.memo_cache_sentinel")?(rt=n.jsx(Z,{name:"contract-up-down",className:"h-4 w-4"}),e[84]=rt):rt=e[84];let ut;e[85]!==s?(ut=s("sessions.sidebar.header.displayMode.collapseAll"),e[85]=s,e[86]=ut):ut=e[86];let pt;e[87]!==ut?(pt=n.jsx("span",{children:ut}),e[87]=ut,e[88]=pt):pt=e[88];let fe;e[89]!==y||e[90]!==pt?(fe=n.jsxs(qt,{onClick:y,className:"flex items-center gap-2",children:[rt,pt]}),e[89]=y,e[90]=pt,e[91]=fe):fe=e[91];let lt;e[92]===Symbol.for("react.memo_cache_sentinel")?(lt=n.jsx(Z,{name:"expand-up-down",className:"h-4 w-4"}),e[92]=lt):lt=e[92];let ft;e[93]!==s?(ft=s("sessions.sidebar.header.displayMode.expandAll"),e[93]=s,e[94]=ft):ft=e[94];let mt;e[95]!==ft?(mt=n.jsx("span",{children:ft}),e[95]=ft,e[96]=mt):mt=e[96];let Rt;e[97]!==w||e[98]!==mt?(Rt=n.jsxs(qt,{onClick:w,className:"flex items-center gap-2",children:[lt,mt]}),e[97]=w,e[98]=mt,e[99]=Rt):Rt=e[99];let we;e[100]!==fe||e[101]!==Rt?(we=n.jsxs(n.Fragment,{children:[fe,Rt]}),e[100]=fe,e[101]=Rt,e[102]=we):we=e[102],Ee.push(we)}e[14]=ce,e[15]=y,e[16]=w,e[17]=W,e[18]=ne,e[19]=R,e[20]=C,e[21]=re,e[22]=H,e[23]=I,e[24]=N,e[25]=ee,e[26]=_,e[27]=K,e[28]=i,e[29]=l,e[30]=X,e[31]=B,e[32]=s,e[33]=xe,e[34]=te,e[35]=be,e[36]=M,e[37]=Ee}else Ee=e[37];if(o){let rt;e[103]!==s?(rt=s("sessions.sidebar.header.search.placeholder"),e[103]=s,e[104]=rt):rt=e[104];let ut;e[105]!==s?(ut=s("sessions.sidebar.header.search.clear"),e[105]=s,e[106]=ut):ut=e[106];let pt;e[107]!==S||e[108]!==p||e[109]!==s?(pt=S?p===1?s("sessions.sidebar.header.search.matchCountSingle",{count:p}):s("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,e[107]=S,e[108]=p,e[109]=s,e[110]=pt):pt=e[110];let fe;e[111]!==s?(fe=s("sessions.sidebar.header.search.escapeHint"),e[111]=s,e[112]=fe):fe=e[112];let lt;return e[113]!==g||e[114]!==b||e[115]!==v||e[116]!==x||e[117]!==fe||e[118]!==rt||e[119]!==ut||e[120]!==pt?(lt=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(zl,{inputRef:b,value:v,onSearch:x,onClose:g,placeholder:rt,clearLabel:ut,leadingHint:pt,trailingHint:fe})}),e[113]=g,e[114]=b,e[115]=v,e[116]=x,e[117]=fe,e[118]=rt,e[119]=ut,e[120]=pt,e[121]=lt):lt=e[121],lt}let L;e[122]!==f||e[123]!==u||e[124]!==E||e[125]!==d||e[126]!==s?(L=d?n.jsx(Xr,{label:s("sourceBoard.title"),pressed:E,onClick:()=>ue.getState().setSourceBoardOpen(!E),className:f,children:n.jsx(Z,{name:"todo",className:u})}):null,e[122]=f,e[123]=u,e[124]=E,e[125]=d,e[126]=s,e[127]=L):L=e[127];let ie;e[128]!==s?(ie=s("sessions.sidebar.header.actions.scheduledTasks"),e[128]=s,e[129]=ie):ie=e[129];let G;e[130]!==T?(G=()=>ue.getState().setScheduledTasksDialogOpen(!T),e[130]=T,e[131]=G):G=e[131];let ae;e[132]!==u?(ae=n.jsx(Z,{name:"calendar-schedule",className:u}),e[132]=u,e[133]=ae):ae=e[133];let ye;e[134]!==f||e[135]!==T||e[136]!==ae||e[137]!==ie||e[138]!==G?(ye=n.jsx(Xr,{label:ie,pressed:T,onClick:G,className:f,children:ae}),e[134]=f,e[135]=T,e[136]=ae,e[137]=ie,e[138]=G,e[139]=ye):ye=e[139];let ge;e[140]!==s?(ge=s("sessions.sidebar.nav.archive"),e[140]=s,e[141]=ge):ge=e[141];let Se;e[142]!==$?(Se=()=>ue.getState().setArchivePageOpen(!$),e[142]=$,e[143]=Se):Se=e[143];let ve;e[144]!==u?(ve=n.jsx(Z,{name:"archive",className:u}),e[144]=u,e[145]=ve):ve=e[145];let Te;e[146]!==f||e[147]!==$||e[148]!==ge||e[149]!==Se||e[150]!==ve?(Te=n.jsx(Xr,{label:ge,pressed:$,onClick:Se,className:f,children:ve}),e[146]=f,e[147]=$,e[148]=ge,e[149]=Se,e[150]=ve,e[151]=Te):Te=e[151];let z;e[152]!==ye||e[153]!==Te||e[154]!==L?(z=n.jsxs("div",{ref:k,className:"flex items-center gap-1.5",children:[L,ye,Te]}),e[152]=ye,e[153]=Te,e[154]=L,e[155]=z):z=e[155];let he;e[156]!==r||e[157]!==A||e[158]!==f||e[159]!==u||e[160]!==O||e[161]!==s?(he=A?r.map(rt=>{const ut=O===rt.id;return n.jsx(Xr,{label:rt.pageTitle??rt.name,pressed:ut,onClick:()=>ue.getState().setOpenGuestPage(ut?null:rt.id),className:f,children:n.jsx(sr,{icon:tf(rt.icon),iconSrc:ef(rt.id,rt.icon,Zd().authenticatedAsset),className:u})},rt.id)}):r.length>0&&n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsx(Ct,{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(Ps,{align:"start",children:[n.jsx(Fi,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(S2)]})]}),e[156]=r,e[157]=A,e[158]=f,e[159]=u,e[160]=O,e[161]=s,e[162]=he):he=e[162];let se;e[163]!==z||e[164]!==he?(se=n.jsxs("div",{className:"ms-[3px] flex min-w-0 items-center gap-1.5",children:[z,he]}),e[163]=z,e[164]=he,e[165]=se):se=e[165];const Re=h?g:m,Ue=h?_h:Lh;let We;e[166]!==f||e[167]!==Ue?(We=ke(f,Ue),e[166]=f,e[167]=Ue,e[168]=We):We=e[168];let He;e[169]!==s?(He=s("sessions.sidebar.header.actions.searchSessions"),e[169]=s,e[170]=He):He=e[170];let Be;e[171]!==u?(Be=n.jsx(Z,{name:"search",className:u}),e[171]=u,e[172]=Be):Be=e[172];let Y;e[173]!==h||e[174]!==Re||e[175]!==We||e[176]!==He||e[177]!==Be?(Y=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Re,className:We,"aria-label":He,"aria-expanded":h,children:Be})}),e[173]=h,e[174]=Re,e[175]=We,e[176]=He,e[177]=Be,e[178]=Y):Y=e[178];let Me;e[179]!==s?(Me=s("sessions.sidebar.header.actions.searchSessions"),e[179]=s,e[180]=Me):Me=e[180];let Ge;e[181]!==Me?(Ge=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Me})}),e[181]=Me,e[182]=Ge):Ge=e[182];let Ve;e[183]!==Y||e[184]!==Ge?(Ve=n.jsxs(Ot,{children:[Y,Ge]}),e[183]=Y,e[184]=Ge,e[185]=Ve):Ve=e[185];let dt;e[186]!==f?(dt=ke(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[186]=f,e[187]=dt):dt=e[187];let et;e[188]!==s?(et=s("sessions.sidebar.header.actions.addProject"),e[188]=s,e[189]=et):et=e[189];let ct;e[190]!==u?(ct=n.jsx(Z,{name:"folder-add",className:u}),e[190]=u,e[191]=ct):ct=e[191];let me;e[192]!==a||e[193]!==dt||e[194]!==et||e[195]!==ct?(me=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,className:dt,"aria-label":et,children:ct})}),e[192]=a,e[193]=dt,e[194]=et,e[195]=ct,e[196]=me):me=e[196];let Ne;e[197]!==s?(Ne=s("sessions.sidebar.header.actions.addProject"),e[197]=s,e[198]=Ne):Ne=e[198];let qe;e[199]!==Ne?(qe=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Ne})}),e[199]=Ne,e[200]=qe):qe=e[200];let Ye;e[201]!==me||e[202]!==qe?(Ye=n.jsxs(Ot,{children:[me,qe]}),e[201]=me,e[202]=qe,e[203]=Ye):Ye=e[203];let $e;e[204]!==f?($e=ke(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[204]=f,e[205]=$e):$e=e[205];let tt;e[206]!==s?(tt=s("sessions.sidebar.header.displayMode.label"),e[206]=s,e[207]=tt):tt=e[207];let ht;e[208]!==u?(ht=n.jsx(Z,{name:"equalizer-2",className:u}),e[208]=u,e[209]=ht):ht=e[209];let wt;e[210]!==$e||e[211]!==tt||e[212]!==ht?(wt=n.jsx(At,{asChild:!0,children:n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:$e,"aria-label":tt,children:ht})})}),e[210]=$e,e[211]=tt,e[212]=ht,e[213]=wt):wt=e[213];let Bt;e[214]!==s?(Bt=s("sessions.sidebar.header.displayMode.label"),e[214]=s,e[215]=Bt):Bt=e[215];let kt;e[216]!==Bt?(kt=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:Bt})}),e[216]=Bt,e[217]=kt):kt=e[217];let St;e[218]!==wt||e[219]!==kt?(St=n.jsxs(Ot,{children:[wt,kt]}),e[218]=wt,e[219]=kt,e[220]=St):St=e[220];let xt;e[221]!==Ee?(xt=n.jsx(Ps,{align:"end",className:"min-w-[200px]",children:Ee.map(x2)}),e[221]=Ee,e[222]=xt):xt=e[222];let Mt;e[223]!==St||e[224]!==xt?(Mt=n.jsxs(js,{children:[St,xt]}),e[223]=St,e[224]=xt,e[225]=Mt):Mt=e[225];let jt;e[226]!==Ve||e[227]!==Ye||e[228]!==Mt?(jt=n.jsxs("div",{ref:P,className:"flex min-w-0 items-center gap-1.5",children:[Ve,Ye,Mt]}),e[226]=Ve,e[227]=Ye,e[228]=Mt,e[229]=jt):jt=e[229];let $t;e[230]!==se||e[231]!==jt?($t=n.jsxs("div",{ref:j,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[se,jt]}),e[230]=se,e[231]=jt,e[232]=$t):$t=e[232];let Kt;e[233]!==g||e[234]!==S||e[235]!==h||e[236]!==p||e[237]!==b||e[238]!==v||e[239]!==x||e[240]!==s?(Kt=h?n.jsx("div",{className:"pb-1",children:n.jsx(zl,{inputRef:b,value:v,onSearch:x,onClose:g,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:S?p===1?s("sessions.sidebar.header.search.matchCountSingle",{count:p}):s("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,trailingHint:s("sessions.sidebar.header.search.escapeHint")})}):null,e[233]=g,e[234]=S,e[235]=h,e[236]=p,e[237]=b,e[238]=v,e[239]=x,e[240]=s,e[241]=Kt):Kt=e[241];let Wt;return e[242]!==$t||e[243]!==Kt?(Wt=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:[$t,Kt]})}),e[242]=$t,e[243]=Kt,e[244]=Wt):Wt=e[244],Wt}function x2(t,e){return n.jsxs(c.Fragment,{children:[e>0?n.jsx(bn,{}):null,t]},e)}function S2(t){return n.jsxs(qt,{onSelect:()=>ue.getState().setOpenGuestPage(t.id),children:[n.jsx(sr,{icon:tf(t.icon),iconSrc:ef(t.id,t.icon,Zd().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function v2(t){return t.setProjectDisplayMode}function w2(t){return t.projectDisplayMode}function k2(t){return t.setSidebarViewMode}function j2(t){return t.sidebarViewMode}function C2(t){return t.setWorktreeSortOrder}function P2(t){return t.worktreeSortOrder}function E2(t){return t.setProjectSortOrder}function N2(t){return t.projectSortOrder}function R2(t){return t.sessionWorkEnabled}function D2(t){return t.setShowWorkSection}function I2(t){return t.showWorkSection}function T2(t){return t.setShowChatsSection}function M2(t){return t.showChatsSection}function A2(t){return t.openGuestPageId}function O2(t){return t.isArchivePageOpen}function B2(t){return t.isScheduledTasksDialogOpen}function F2(t){return t.isSourceBoardOpen}function _2(t){return t.toggleMode}function L2(t){return t.enabled}function $2(t){const e=Ke.c(2),{className:s}=t,[r]=c.useState(z2);if(!r)return null;let o;return e[0]!==s?(o=n.jsx(K2,{className:s}),e[0]=s,e[1]=o):o=e[1],o}function z2(){return pn()}function K2({className:t}){const{t:e}=vt(),s=ue(k=>k.shortcutOverrides),[r,o]=c.useState(!1),[i,l]=c.useState("Local"),[a,d]=c.useState(!0),[u,f]=c.useState(!1),[h,m]=c.useState(null),[g,b]=c.useState(!1),[v,x]=c.useState(null),S=c.useCallback(async()=>{try{if(Lo()){l("Local"),d(!0);return}d(!1);const k=await $o(),P=xm(Sm(k.hosts,k.localOrigin));if(P.id===vm){l("Local"),d(!0);return}l(Jd(P.label.trim()||"Instance"))}catch{l("Local"),d(!0)}},[]);c.useEffect(()=>(S(),Bo(()=>{S()})),[S]);const p=c.useCallback(async()=>{if(a){m(null),x(null);return}b(!0),x(null);try{const k=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),P=await an(`/api/openchamber/update-check?${k.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!P.ok)throw new Error(`Server responded with ${P.status}`);m(Cg(await P.json()))}catch(k){m(null),x(k instanceof Error?k.message:e("header.services.remoteUpdate.error"))}finally{b(!1)}},[a,e]);c.useEffect(()=>{m(null),x(null),f(!1)},[a,i]),c.useEffect(()=>{if(a)return;const k=3e3,P=3600*1e3;let A=!1,F=null;const D=E=>{F=window.setTimeout(()=>{if(A||typeof document<"u"&&document.visibilityState!=="visible"){D(P);return}p().finally(()=>{A||D(P)})},E)};return D(k),()=>{A=!0,F!==null&&window.clearTimeout(F)}},[p,a,i]);const y=c.useCallback(()=>{if(h?.available){f(!0);return}p()},[p,h?.available]),w=c.useCallback(k=>{o(k),k&&S()},[S]);Tu({toggle_services_menu:()=>{if(r){o(!1);return}const k=ue.getState();k.isSidebarOpen||k.setSidebarOpen(!0),w(!0)}});const j=Au(Ou("toggle_services_menu",s));return n.jsxs(n.Fragment,{children:[n.jsxs(js,{open:r,onOpenChange:w,children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Cs,{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(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:e("header.services.tooltip.currentInstance",{current:i,toggle:j})})})]}),n.jsxs(Ps,{side:"top",align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:[a?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:h?.available?e("header.services.remoteUpdate.available",{version:h.version||""}):g?e("header.services.remoteUpdate.checking"):v||e("header.services.remoteUpdate.upToDate")})]}),h?.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:y,children:e("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(By,{embedded:!0,open:r,onOpenChange:()=>{},onHostSwitched:()=>o(!1)})]})]}),n.jsx(Ca,{open:u,onOpenChange:f,info:h,downloading:!1,downloaded:!1,progress:null,error:v,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",W2="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function H2(t){const e=Ke.c(28),{onOpenSettings:s,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:l,showUpdateButton:a}=t,d=l===void 0?!0:l,u=a===void 0?!0:a,{t:f}=vt(),h=Pg(),m=ue(V2);if(!d&&!u)return null;let g;e[0]!==h||e[1]!==f?(g=f(h?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update"),e[0]=h,e[1]=f,e[2]=g):g=e[2];const b=g;let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=ke(cr,"text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]"),e[3]=v):v=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Z,{name:"download",className:"h-4 w-4"}),e[4]=x):x=e[4];let S;e[5]!==i||e[6]!==b?(S=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:i,className:v,"aria-label":b,children:x})}),e[5]=i,e[6]=b,e[7]=S):S=e[7];let p;e[8]!==b?(p=n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:b})}),e[8]=b,e[9]=p):p=e[9];let y;e[10]!==S||e[11]!==p?(y=n.jsxs(Ot,{children:[S,p]}),e[10]=S,e[11]=p,e[12]=y):y=e[12];const w=y;let j;e[13]!==m||e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==d||e[18]!==u||e[19]!==f||e[20]!==w?(j=d?n.jsxs(n.Fragment,{children:[n.jsxs(Ot,{children:[n.jsx(At,{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(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>ue.getState().setUsageStatsPageOpen(!m),className:ke(cr,m&&W2),"aria-label":f("usageStats.openAction"),"aria-pressed":m,children:n.jsx(Z,{name:"bar-chart",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Ot,{children:[n.jsx(At,{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(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),u?w:n.jsxs(Ot,{children:[n.jsx(At,{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(Tt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[13]=m,e[14]=o,e[15]=s,e[16]=r,e[17]=d,e[18]=u,e[19]=f,e[20]=w,e[21]=j):j=e[21];const k=!d&&u?w:null;let P;e[22]!==d?(P=d?n.jsx($2,{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]=d,e[23]=P):P=e[23];let A;return e[24]!==k||e[25]!==P||e[26]!==j?(A=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[j,k,P]}),e[24]=k,e[25]=P,e[26]=j,e[27]=A):A=e[27],A}function V2(t){return t.isUsageStatsPageOpen}function G2(t){const e=Ke.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=vt();let l;e[0]!==s||e[1]!==o?(l=()=>{ue.getState().setArchivePageOpen(!0,s),o()},e[0]=s,e[1]=o,e[2]=l):l=e[2];const a=l;let d;e[3]!==i?(d=i("sessions.sidebar.empty.noMatches.title"),e[3]=i,e[4]=d):d=e[4];let u;e[5]!==d?(u=n.jsx("p",{className:"typography-ui-label font-semibold",children:d}),e[5]=d,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 h;e[9]!==f?(h=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==a||e[12]!==r||e[13]!==i?(m=r?n.jsx(Ct,{variant:"link",size:"xs",className:"mt-2 h-auto p-0 typography-meta",onClick:a,children:i("sessions.sidebar.empty.noMatches.searchArchive")}):null,e[11]=a,e[12]=r,e[13]=i,e[14]=m):m=e[14];let g;return e[15]!==u||e[16]!==h||e[17]!==m?(g=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,h,m]}),e[15]=u,e[16]=h,e[17]=m,e[18]=g):g=e[18],g}const U2=t=>{for(const e of t.sessions.values())if(e.tabs.some(eu))return!0;return!1},q2=()=>{const t=Ke.c(4),{terminal:e}=Ws(),s=zo(U2);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=Y2,l=X2;if(s)return sc(e,"",l,i);let a=Q2;return a=sc(e,"",l,d=>{i(d),a()}),()=>a()},o=[e,s],t[0]=s,t[1]=e,t[2]=r,t[3]=o):(r=t[2],o=t[3]),c.useEffect(r,o),null};function Y2(t){const e=zo.getState(),s=Fy(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 X2(){return new Map(zo.getState().actionMutationRevisions)}function Q2(){}const Z2=50,J2=t=>{const e=new Map;for(const s of t){const r=ot(s.directory),o=s.branch.trim();if(!(!r||!o||e.has(r))&&(e.set(r,{directory:r,branch:o}),e.size===Z2))break}return[...e.values()]},eC=t=>{const e=Ke.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:h}=t,m=r===void 0?!0:r;let g,b;e[0]!==h||e[1]!==f||e[2]!==m||e[3]!==u||e[4]!==l||e[5]!==i||e[6]!==a||e[7]!==s||e[8]!==o||e[9]!==d?(g=()=>{!m||i||!l||a||s.forEach(v=>{if(d.has(v.normalizedPath))return;const x=of(v.normalizedPath),S=o.archivedSessionsByProject.get(v.id)??[],p=u[x]??[],y=new Map(p.map(tC));S.forEach(w=>{const j=_y(w,v.normalizedPath),k=j.toLowerCase();let P=y.get(k);P||(P=f(x,j),y.set(k,P)),P.sessionIds.includes(w.id)||h(x,P.id,w.id)})})},b=[s,m,o,i,l,a,d,u,f,h],e[0]=h,e[1]=f,e[2]=m,e[3]=u,e[4]=l,e[5]=i,e[6]=a,e[7]=s,e[8]=o,e[9]=d,e[10]=g,e[11]=b):(g=e[10],b=e[11]),c.useEffect(g,b)};function tC(t){return[t.name.toLowerCase(),t]}function sC({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:s,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:l}){if(e&&s===t)return{kind:"preserve-current"};if(s==null){const u=!!(e&&Array.from(o.entries()).some(([f,h])=>f!==t&&h.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(i&&r.has(i)?i:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const nC=t=>{const e=Ke.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:h,setSessionSwitcherOpen:m}=t;let g,b;if(e[0]!==s){b=new Map,g=new Map;const k=(P,A,F,D)=>{b.has(P)||b.set(P,new Map);const E=b.get(P);D.forEach(T=>{const $=ot(T.worktree?.path??T.session.directory??F??A);E.set(T.session.id,{directory:$}),g.has(P)||g.set(P,{id:T.session.id,directory:$}),T.children.length>0&&k(P,A,$,T.children)})};s.forEach(P=>{P.groups.forEach(A=>{k(P.project.id,P.project.normalizedPath,A.directory,A.sessions)})}),e[0]=s,e[1]=g,e[2]=b}else g=e[1],b=e[2];let v;e[3]!==g||e[4]!==b?(v={metaByProject:b,firstSessionByProject:g},e[3]=g,e[4]=b,e[5]=v):v=e[5];const x=v,S=c.useRef(null);let p,y;e[6]!==r||e[7]!==o||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==f||e[12]!==u||e[13]!==h||e[14]!==s||e[15]!==x||e[16]!==i||e[17]!==m?(p=()=>{if(!r||u||ue.getState().isNewWorktreeDialogOpen||S.current===r)return;const k=s.find(D=>D.project.id===r);if(!k)return;if(S.current===null){S.current=r;return}const P=x.metaByProject.get(r);if(l&&P&&P.has(l)){S.current=r,i(D=>{if(D.get(r)===l)return D;const E=new Map(D);return E.set(r,l),E});return}const A=sC({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:P,metaByProject:x.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:x.firstSessionByProject.get(r)?.id??null});if(A.kind==="preserve-current"){a===r&&(S.current=r);return}if(S.current=r,A.kind==="open-draft"){f&&m(!1),h({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(A.kind!=="select-session")return;const F=P?.get(A.sessionId)?.directory??null;d(A.sessionId,F)},y=[r,o,l,a,d,u,f,h,s,x,m,i],e[6]=r,e[7]=o,e[8]=l,e[9]=a,e[10]=d,e[11]=f,e[12]=u,e[13]=h,e[14]=s,e[15]=x,e[16]=i,e[17]=m,e[18]=p,e[19]=y):(p=e[18],y=e[19]),c.useLayoutEffect(p,y);let w,j;e[20]!==r||e[21]!==l||e[22]!==x||e[23]!==i?(w=()=>{if(!r||!l)return;const k=x.metaByProject.get(r);!k||!k.has(l)||i(P=>{if(P.get(r)===l)return P;const A=new Map(P);return A.set(r,l),A})},j=[r,l,x,i],e[20]=r,e[21]=l,e[22]=x,e[23]=i,e[24]=w,e[25]=j):(w=e[24],j=e[25]),c.useEffect(w,j)},rC=t=>{const e=Ke.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 l=nt(oC),a=nt(iC);let d;e[5]!==l||e[6]!==i?(d=l?i?.get(l)?.projectId??null:null,e[5]=l,e[6]=i,e[7]=d):d=e[7];const u=d;let f;e[8]!==r?(f=()=>new Map(r),e[8]=r,e[9]=f):f=e[9];const[h,m]=c.useState(f);let g;e[10]!==h||e[11]!==s||e[12]!==l||e[13]!==u||e[14]!==a?(g={...s,activeSessionByProject:h,setActiveSessionByProject:m,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=h,e[11]=s,e[12]=l,e[13]=u,e[14]=a,e[15]=g):g=e[15],nC(g);let b,v;return e[16]!==h||e[17]!==o?(b=()=>{o(h)},v=[h,o],e[16]=h,e[17]=o,e[18]=b,e[19]=v):(b=e[18],v=e[19]),c.useEffect(b,v),null};function oC(t){return t.currentSessionId}function iC(t){return!!t.newSessionDraft?.open}const aC=t=>{const e=Ke.c(7),{ownership:s}=t;let r;e[0]!==s?(r=d=>s.sessionsByProject.get(d)??[],e[0]=s,e[1]=r):r=e[1];const o=r;let i;e[2]!==s?(i=d=>s.archivedSessionsByProject.get(d)??[],e[2]=s,e[3]=i):i=e[3];const l=i;let a;return e[4]!==l||e[5]!==o?(a={getSessionsForProject:o,getArchivedSessionsForProject:l},e[4]=l,e[5]=o,e[6]=a):a=e[6],a},lC=(t,e)=>t.map(s=>{const r=ot(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
1045
+ `),cC=(t,e,s)=>e.length===0?"":t.map(r=>s.get(r.id)??"").join(","),dC=[],uC=new WeakMap,fC=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:l,gitBranches:a,sessionOrderRanks:d,lastRepoStatus:u,buildGroupedSessions:f,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:g,buildGroupSearchText:b,foldersMap:v,standaloneGroups:x}=t,S=c.useRef(new Map),p=c.useMemo(()=>{const D=S.current,E=new Map;let T=0,$=0;const O=(I,X)=>I.length===X.length&&I.every((N,C)=>N===X[C]),K=e.map(I=>{const X=s(I.id),N=r(I.id),C=o.get(I.normalizedPath)??dC,R=i.has(I.id)?!!i.get(I.id):u,H=l.get(I.id)??null,M=lC(C,a),_=cC(X,C,d),B=D.get(I.id);if(B&&B.project===I&&O(B.activeSessions,X)&&O(B.archivedSessions,N)&&B.availableWorktrees===C&&B.rootBranch===H&&B.worktreeBranchesKey===M&&B.worktreeRanksKey===_&&B.isRepo===R&&B.buildGroupedSessions===f)return T+=1,E.set(I.id,B),B.section;if($+=1,B){const te=B.project!==I?"project":O(B.activeSessions,X)?O(B.archivedSessions,N)?B.availableWorktrees!==C?"worktrees":B.rootBranch!==H?"branch":B.worktreeBranchesKey!==M?"worktreeBranches":B.worktreeRanksKey!==_?"worktreeRanks":B.isRepo!==R?"repo":"builder":"archived":"sessions";Ss(`ui.sidebar.project_section.rebuilt_reason.${te}`)}const ee=af([...X,...N]),ne=f(ee,I.normalizedPath,C,H,R),re={project:I,groups:ne};return E.set(I.id,{project:I,activeSessions:X,archivedSessions:N,availableWorktrees:C,rootBranch:H,worktreeBranchesKey:M,worktreeRanksKey:_,isRepo:R,buildGroupedSessions:f,section:re}),re});return S.current=E,T>0&&Ss("ui.sidebar.project_section.reused",T),$>0&&Ss("ui.sidebar.project_section.rebuilt",$),K},[e,s,r,o,i,u,f,l,a,d]),y=c.useMemo(()=>p,[p]),w=c.useMemo(()=>{if(!h)return uC;const D=new WeakMap,T=m.trim().toLowerCase().startsWith("ses_"),$=O=>{const K=g(O.sessions,m),I=Bh(K,m),X=!T&&wo([b(O)],m),N=er(O).flatMap(({scopeKey:R})=>v[R]??[]),C=T?0:N.filter(R=>wo([R.name],m)).length;D.set(O,{filteredNodes:K,matchedSessionCount:I,folderNameMatchCount:C,groupMatches:X,hasMatch:X||I>0||C>0})};return y.forEach(O=>{O.groups.forEach($)}),x.forEach($),D},[h,y,x,g,m,b,v]),j=c.useMemo(()=>h?y.map(D=>({...D,groups:D.groups.filter(E=>w.get(E)?.hasMatch===!0)})).filter(D=>D.groups.length>0):y,[h,y,w]),k=h?j:y,P=c.useRef(new WeakMap),A=c.useMemo(()=>{const D=P.current;return k.map(E=>{const T=D.get(E);if(T&&T.query===m)return T.section;const $=E.groups.filter(R=>!R.isArchivedBucket),O=E.groups.filter(R=>R.isArchivedBucket),K=$.flatMap(R=>h?w.get(R)?.filteredNodes??[]:R.sessions),I=$.map(R=>({scopeKey:R.folderScopeKey??ot(R.directory??null),directory:R.directory??null})).filter(R=>!!R.scopeKey),X=$.find(R=>R.isMain)??null,N={id:"flat",label:X?.label??"",branch:X?.branch??null,description:X?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:X?.directory??E.project.normalizedPath,folderScopeKey:X?.folderScopeKey??E.project.normalizedPath,folderScopes:I,sessions:K};if(h){const R=$.map(H=>w.get(H)).filter(H=>!!H);w.set(N,{filteredNodes:K,matchedSessionCount:R.reduce((H,M)=>H+M.matchedSessionCount,0),folderNameMatchCount:R.reduce((H,M)=>H+M.folderNameMatchCount,0),groupMatches:R.some(H=>H.groupMatches),hasMatch:R.some(H=>H.hasMatch)})}const C={project:E.project,groups:[N,...O]};return D.set(E,{query:m,section:C}),C})},[w,h,m,k]),F=c.useMemo(()=>{if(!h)return 0;const D=(T,$)=>{const O=w.get($);if(!O)return T;const K=O.folderNameMatchCount+(O.groupMatches?1:0);return T+O.matchedSessionCount+K},E=k.reduce((T,$)=>$.groups.reduce(D,T),0);return x.reduce(D,E)},[h,k,x,w]);return{projectSections:p,visibleProjectSections:y,groupSearchDataByGroup:w,searchableProjectSections:j,sectionsForRender:k,flatSectionsForRender:A,searchMatchCount:F}},hC=180,dd=150,pC=2,mC=8,ud=[-1,1],Qr=t=>`${t.directory}
1046
+ ${t.sessionId}`,fd=t=>t?.directory?.trim()||null,$h=c.createContext(null),gC=()=>c.useContext($h),bC=({enabled:t=!0,currentSessionId:e,sortedSessions:s,workSessions:r=[],prefetchSession:o})=>{const i=c.useRef(new Map),l=c.useRef(new Set),a=c.useRef([]),d=c.useRef(new Set),u=c.useRef(0),f=c.useMemo(()=>Sn(),[]),h=c.useCallback(()=>{u.current+=1,a.current=[],i.current.forEach(S=>window.clearTimeout(S)),i.current.clear(),l.current.clear()},[]),m=c.useCallback(()=>{if(!(!t||f))for(;d.current.size<pC&&a.current.length>0;){const S=a.current.shift();if(!S)break;if(S.generation!==u.current||nt.getState().currentSessionId===S.sessionId||zi(S.sessionId,S.directory).renderable)continue;const y=Qr(S);d.current.add(y),o({directory:S.directory,sessionID:S.sessionId}).catch(()=>{}).finally(()=>{d.current.delete(y),m()})}},[t,f,o]),g=c.useCallback((S,p="neighbor")=>{const y=S?.id,w=fd(S);if(!t||f||!y||!w||y===e)return;const j={sessionId:y,directory:w,generation:u.current},k=Qr(j);if(zi(y,w).renderable||d.current.has(k)||a.current.some(F=>Qr(F)===k))return;const P=i.current.get(k);if(P!==void 0){if(p==="hover"&&!l.current.has(k))return;window.clearTimeout(P)}p==="hover"?l.current.add(k):l.current.delete(k);const A=window.setTimeout(()=>{if(i.current.delete(k),l.current.delete(k),j.generation!==u.current)return;const F=a.current;F.length>=mC&&F.shift(),F.push(j),m()},hC);i.current.set(k,A)},[e,t,f,m]),b=c.useCallback(S=>{const p=fd(S);if(!p)return;const y=Qr({sessionId:S.id,directory:p}),w=i.current.get(y);w===void 0||!l.current.has(y)||(window.clearTimeout(w),i.current.delete(y),l.current.delete(y))},[]),v=c.useRef(g);v.current=g;const[x]=c.useState(()=>({schedule:S=>v.current(S,"hover"),cancel:b}));return c.useEffect(()=>{h()},[h,e,t,f]),c.useEffect(()=>{if(!t||f||!e||s.length===0)return;const S=window.setTimeout(()=>{const p=s.findIndex(y=>y.id===e);if(!(p<0))for(const y of ud)g(s[p+y])},dd);return()=>window.clearTimeout(S)},[e,t,f,g,s]),c.useEffect(()=>{if(!t||f||!e||r.length===0)return;const S=window.setTimeout(()=>{const p=r.findIndex(y=>y.id===e);if(!(p<0))for(const y of ud)g(r[p+y])},dd);return()=>window.clearTimeout(S)},[e,t,f,r,g]),c.useEffect(()=>h,[h]),x},yC=t=>{const e=Ke.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=nt(xC);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 l=bC(i);let a;if(e[6]!==r||e[7]!==l){let d;e[9]!==l?(d={value:l},e[9]=l,e[10]=d):d=e[10],a=c.createElement($h.Provider,d,r),e[6]=r,e[7]=l,e[8]=a}else a=e[8];return a};function xC(t){return t.currentSessionId}const SC=6,tr=t=>ja(t,SC),hd=t=>`calc(${tr(t)} + 20px)`,vC=t=>{const e=Ke.c(92),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:f,children:h,renderBody:m,mobileVariant:g,alwaysShowActions:b,isRenaming:v,renameDraft:x,onRenameDraftChange:S,onRenameSave:p,onRenameCancel:y,droppableRef:w,isDropTarget:j,onNewSession:k,depth:P,canExpand:A,hideActions:F,archivedBucket:D}=t,E=a===void 0?null:a,T=m===void 0?!0:m,O=b===void 0?g===void 0?!1:g:b,K=v===void 0?!1:v,I=x===void 0?"":x,X=j===void 0?!1:j,N=P===void 0?0:P,C=A===void 0?!0:A,R=F===void 0?!1:F,H=D===void 0?!1:D,{t:M}=vt(),[_,B]=c.useState(!1),[ee,ne]=c.useState(""),re=c.useRef(null),te=K||_,W=K?I:ee;let q;e[0]!==s.name?(q=()=>{ne(s.name),B(!0)},e[0]=s.name,e[1]=q):q=e[1];const oe=q;let de;e[2]!==W||e[3]!==s.name||e[4]!==K||e[5]!==u||e[6]!==p?(de=()=>{const et=W.trim();et&&et!==s.name&&u(et),K&&p&&p(),B(!1),ne("")},e[2]=W,e[3]=s.name,e[4]=K,e[5]=u,e[6]=p,e[7]=de):de=e[7];const ce=de;let je;e[8]!==K||e[9]!==y?(je=()=>{K&&y&&y(),B(!1),ne("")},e[8]=K,e[9]=y,e[10]=je):je=e[10];const be=je;let pe;e[11]!==K||e[12]!==S?(pe=et=>{K&&S?S(et):ne(et)},e[11]=K,e[12]=S,e[13]=pe):pe=e[13];const U=pe;let Pe,xe;e[14]!==K?(Pe=()=>{if(!K)return;const et=()=>{const Ne=re.current;Ne&&(Ne.focus(),Ne.select())},ct=requestAnimationFrame(et),me=window.setTimeout(et,0);return()=>{cancelAnimationFrame(ct),window.clearTimeout(me)}},xe=[K],e[14]=K,e[15]=Pe,e[16]=xe):(Pe=e[15],xe=e[16]),c.useEffect(Pe,xe);const Ee=l?"folder":"folder-open",L=!te&&C;let ie;e[17]!==N?(ie=tr(N),e[17]=N,e[18]=ie):ie=e[18];let G;e[19]!==ie?(G={paddingInlineStart:ie},e[19]=ie,e[20]=G):G=e[20];const ae=X?"bg-primary/10 ring-1 ring-inset ring-primary/30":"hover:bg-interactive-hover/60";let ye;e[21]!==ae?(ye=ke("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ae),e[21]=ae,e[22]=ye):ye=e[22];let ge;e[23]!==d||e[24]!==L?(ge=L?et=>{et.currentTarget.blur(),d()}:void 0,e[23]=d,e[24]=L,e[25]=ge):ge=e[25];const Se=L?"button":void 0,ve=L?0:void 0;let Te;e[26]!==d||e[27]!==L?(Te=L?et=>{(et.key==="Enter"||et.key===" ")&&(et.preventDefault(),d())}:void 0,e[26]=d,e[27]=L,e[28]=Te):Te=e[28];let z;e[29]!==s.name||e[30]!==l||e[31]!==M||e[32]!==L?(z=L?l?M("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):M("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}):void 0,e[29]=s.name,e[30]=l,e[31]=M,e[32]=L,e[33]=z):z=e[33];const he=H?O?"pe-7":"group-hover/folder:pe-7 group-focus-within/folder:pe-7":O?"pe-20":"group-hover/folder:pe-20 group-focus-within/folder:pe-20";let se;e[34]!==he?(se=ke("min-w-0 flex items-center gap-0.5 flex-1",he),e[34]=he,e[35]=se):se=e[35];let Re;e[36]!==C||e[37]!==l?(Re=C?n.jsx(Cr,{expanded:!l}):n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}),e[36]=C,e[37]=l,e[38]=Re):Re=e[38];const Ue=X?"text-primary":"text-muted-foreground";let We;e[39]!==Ue?(We=ke("mx-px h-3 w-3 flex-shrink-0",Ue),e[39]=Ue,e[40]=We):We=e[40];let He;e[41]!==Ee||e[42]!==We?(He=n.jsx(Z,{name:Ee,className:We}),e[41]=Ee,e[42]=We,e[43]=He):He=e[43];let Be;e[44]!==E||e[45]!==r||e[46]!==W||e[47]!==s.name||e[48]!==be||e[49]!==U||e[50]!==ce||e[51]!==X||e[52]!==te||e[53]!==o||e[54]!==M?(Be=te?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:wC,onMouseDown:kC,onSubmit:et=>{et.preventDefault(),ce()},children:[n.jsx("input",{ref:re,value:W,onChange:et=>U(et.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:M("sessions.sidebar.folderItem.namePlaceholder"),onClick:jC,onPointerDown:CC,onMouseDown:PC,onKeyDown:et=>{if(et.key==="Escape"){et.stopPropagation(),be();return}(et.key===" "||et.key==="Enter")&&et.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:EC,onPointerDown:NC,onMouseDown:RC,children:n.jsx(Z,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),be()},onPointerDown:DC,onMouseDown:IC,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(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("span",{className:ke("typography-ui-label font-medium truncate",X?"text-primary":"text-foreground"),children:r??s.name})}),n.jsx(Tt,{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]}),E?n.jsx(Eg,{state:E}):null]}),e[44]=E,e[45]=r,e[46]=W,e[47]=s.name,e[48]=be,e[49]=U,e[50]=ce,e[51]=X,e[52]=te,e[53]=o,e[54]=M,e[55]=Be):Be=e[55];let Y;e[56]!==se||e[57]!==Re||e[58]!==He||e[59]!==Be?(Y=n.jsxs("div",{className:se,children:[Re,He,Be]}),e[56]=se,e[57]=Re,e[58]=He,e[59]=Be,e[60]=Y):Y=e[60];let Me;e[61]!==O||e[62]!==H||e[63]!==s.name||e[64]!==oe||e[65]!==R||e[66]!==f||e[67]!==k||e[68]!==te||e[69]!==M?(Me=!te&&(!R||H)?n.jsx("div",{className:ke("absolute inset-e-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",O?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:n.jsxs("div",{className:"flex items-center gap-0.5",children:[!H&&k?n.jsx("button",{type:"button",onClick:et=>{et.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":M("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:M("sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-3.5 w-3.5"})}):null,H?null:n.jsx("button",{type:"button",onClick:et=>{et.stopPropagation(),oe()},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":M("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:et=>{et.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":H?M("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):M("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx(Z,{name:"delete-bin",className:"h-3 w-3"})})]})}):null,e[61]=O,e[62]=H,e[63]=s.name,e[64]=oe,e[65]=R,e[66]=f,e[67]=k,e[68]=te,e[69]=M,e[70]=Me):Me=e[70];let Ge;e[71]!==w||e[72]!==G||e[73]!==ye||e[74]!==ge||e[75]!==Se||e[76]!==ve||e[77]!==Te||e[78]!==z||e[79]!==Y||e[80]!==Me?(Ge=n.jsxs("div",{ref:w,style:G,className:ye,onClick:ge,role:Se,tabIndex:ve,onKeyDown:Te,"aria-label":z,children:[Y,Me]}),e[71]=w,e[72]=G,e[73]=ye,e[74]=ge,e[75]=Se,e[76]=ve,e[77]=Te,e[78]=z,e[79]=Y,e[80]=Me,e[81]=Ge):Ge=e[81];let Ve;e[82]!==h||e[83]!==l||e[84]!==T||e[85]!==o||e[86]!==i||e[87]!==M?(Ve=!l&&T?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?h:i?null:n.jsx("div",{className:"py-1 ps-1.5 text-start typography-micro text-muted-foreground/70",children:M("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[82]=h,e[83]=l,e[84]=T,e[85]=o,e[86]=i,e[87]=M,e[88]=Ve):Ve=e[88];let dt;return e[89]!==Ge||e[90]!==Ve?(dt=n.jsxs("div",{className:"oc-folder",children:[Ge,Ve]}),e[89]=Ge,e[90]=Ve,e[91]=dt):dt=e[91],dt},zh=c.memo(vC);function wC(t){return t.stopPropagation()}function kC(t){return t.stopPropagation()}function jC(t){return t.stopPropagation()}function CC(t){return t.stopPropagation()}function PC(t){return t.stopPropagation()}function EC(t){return t.stopPropagation()}function NC(t){return t.stopPropagation()}function RC(t){return t.stopPropagation()}function DC(t){return t.stopPropagation()}function IC(t){return t.stopPropagation()}function TC(t){const e=Ke.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 l;e[4]!==s||e[5]!==r||e[6]!==i?(l={nodes:s,includeUnreadSubtasks:r,enabled:i},e[4]=s,e[5]=r,e[6]=i,e[7]=l):l=e[7];const a=uu(l);let d;return e[8]!==a||e[9]!==o?(d=n.jsx(zh,{...o,collapsedActivityState:a}),e[8]=a,e[9]=o,e[10]=d):d=e[10],d}const Io=t=>{const e=Ke.c(16),{directory:s,className:r}=t,{t:o}=vt();let i;e[0]!==s?(i=wm(s),e[0]=s,e[1]=i):i=e[1];const l=i;let a;if(e[2]!==l?(a=x=>x.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!zo(a)?.tabs.some(eu))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const h=f;let m;e[6]!==r?(m=ke("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=m):m=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]!==l||e[10]!==h||e[11]!==m?(b=n.jsx("span",{className:m,role:"img","aria-label":h,"data-action-directory":l,children:g}),e[9]=l,e[10]=h,e[11]=m,e[12]=b):b=e[12];let v;return e[13]!==h||e[14]!==b?(v=n.jsx(Dn,{label:h,children:b}),e[13]=h,e[14]=b,e[15]=v):v=e[15],v},MC=t=>{const e=Ke.c(19),{sessionId:s,dragKey:r,ownerKey:o,sessionDirectory:i,sessionTitle:l,archivedBucket:a,children:d}=t,u=o===void 0?null:o,f=a===void 0?!1:a,h=`session-drag:${r??s}`;let m;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==l?(m={type:"session",sessionId:s,ownerKey:u,sessionDirectory:i,sessionTitle:l,archivedBucket:f},e[0]=f,e[1]=u,e[2]=i,e[3]=s,e[4]=l,e[5]=m):m=e[5];let g;e[6]!==f||e[7]!==h||e[8]!==m?(g={id:h,disabled:f,data:m},e[6]=f,e[7]=h,e[8]=m,e[9]=g):g=e[9];const{attributes:b,listeners:v,setNodeRef:x,isDragging:S}=x1(g);let p;e[10]!==v?(p=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=p):p=e[11];const y=p,w=`touch-pan-y select-none${S?" opacity-30":""}`;let j;return e[12]!==b||e[13]!==d||e[14]!==y||e[15]!==v||e[16]!==x||e[17]!==w?(j=n.jsx("div",{ref:x,...b,...v,onPointerDown:y,className:w,children:d}),e[12]=b,e[13]=d,e[14]=y,e[15]=v,e[16]=x,e[17]=w,e[18]=j):j=e[18],j},Kh=t=>{const e=Ke.c(20),{folderId:s,scopeKey:r,ownerKey:o,disabled:i,children:l}=t,a=i===void 0?!1:i;let d;e[0]!==s||e[1]!==r?(d=Rn(r,s),e[0]=s,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let f;e[3]!==a||e[4]!==r?(f=a||ll(r),e[3]=a,e[4]=r,e[5]=f):f=e[5];let h;e[6]!==s||e[7]!==o||e[8]!==r?(h={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=h):h=e[9];let m;e[10]!==u||e[11]!==f||e[12]!==h?(m={id:u,disabled:f,data:h},e[10]=u,e[11]=f,e[12]=h,e[13]=m):m=e[13];const{setNodeRef:g,isOver:b}=S1(m);let v;e[14]!==l||e[15]!==b||e[16]!==g?(v=l(g,b),e[14]=l,e[15]=b,e[16]=g,e[17]=v):v=e[17];let x;return e[18]!==v?(x=n.jsx(n.Fragment,{children:v}),e[18]=v,e[19]=x):x=e[19],x},AC=t=>{const e=Ke.c(22),{scopeKey:s,ownerKey:r,hasFolders:o,onSessionDroppedOnFolder:i,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const f=Rr(Bs(Ir,d),Bs(Dr,u)),[h,m]=c.useState(null),[g,b]=c.useState("Session"),[v,x]=c.useState(null),[S,p]=c.useState(null);if(!s){let D;return e[2]!==l?(D=n.jsx(n.Fragment,{children:l}),e[2]=l,e[3]=D):D=e[3],D}let y;e[4]!==i||e[5]!==a?(y=D=>{m(null),x(null),p(null);const{active:E,over:T}=D;if(!T)return;const $=E.data.current,O=T.data.current;$?.type!=="session"||!$.sessionId||!$.ownerKey||$.archivedBucket===!0||a&&$.ownerKey!==a||O?.type!=="folder"||!O.folderId||!O.scopeKey||!O.ownerKey||ll(O.scopeKey)||O.ownerKey!==$.ownerKey||i($.sessionId,{folderId:O.folderId,scopeKey:O.scopeKey,ownerKey:O.ownerKey},$.ownerKey)},e[4]=i,e[5]=a,e[6]=y):y=e[6];const w=y;let j,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=D=>{const E=D.active.data.current;if(E?.type==="session"&&E.sessionId){m(E.sessionId),b(E.sessionTitle??"Session");const T=D.active.rect.current.initial?.width,$=D.active.rect.current.initial?.height;x(T??null),p($??null)}},k=()=>{m(null),x(null),p(null)},e[7]=j,e[8]=k):(j=e[7],k=e[8]);let P;e[9]!==S||e[10]!==h||e[11]!==g||e[12]!==v||e[13]!==o?(P=h&&o?n.jsxs("div",{style:{width:v?`${v}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]=h,e[11]=g,e[12]=v,e[13]=o,e[14]=P):P=e[14];let A;e[15]!==P?(A=n.jsx(v1,{children:P}),e[15]=P,e[16]=A):A=e[16];let F;return e[17]!==l||e[18]!==w||e[19]!==f||e[20]!==A?(F=n.jsxs(Tr,{sensors:f,collisionDetection:Mr,onDragStart:j,onDragCancel:k,onDragEnd:w,children:[l,A]}),e[17]=l,e[18]=w,e[19]=f,e[20]=A,e[21]=F):F=e[21],F},Wh=c.createContext(null),OC=({entries:t,descendantIds:e,sessionsById:s,children:r})=>{const o=c.useRef(t),i=c.useRef(e),l=c.useRef(s);o.current=t,i.current=e,l.current=s;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>o.current,getDescendantIds:()=>i.current,getSessionsById:()=>l.current}),n.jsx(Wh.Provider,{value:a.current,children:r})},Hh=()=>c.useContext(Wh),BC=(t,e,s)=>{const r=t[0];if(!r)return null;const o=s??r.scopeKey,i=[],l=new Set;for(const a of t){if(o&&a.scopeKey!==o)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const f of u)l.has(f)||(l.add(f),i.push(f))}return i.length>0?{ids:i,scopeKey:o}:null},Vh=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},FC=({menuInstanceKey:t,contextMenuInstanceKey:e,openSidebarMenuKey:s,setOpenSidebarMenuKey:r,hasDeferredCloseWork:o,onCloseComplete:i})=>{const[l,a]=c.useState(!1),[d,u]=c.useState(!1),f=s===t&&!d,h=e?s===e&&!d:l,m=p=>{if(s===p){if(o()){u(!0);return}r(null)}},g=p=>{if(p){a(!1),u(!1),r(t);return}m(t)},b=p=>{if(!e){a(p);return}if(p){u(!1),r(e);return}m(e)},v=p=>{p||(i(),u(!1),(s===t||s===e)&&r(null))},x=()=>{u(!1),r(f?null:t)},S=c.useRef({menu:g,contextMenu:b});return S.current={menu:g,contextMenu:b},c.useEffect(()=>{if(!f&&!h)return;const p=()=>{h&&S.current.contextMenu(!1),f&&S.current.menu(!1)};return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[f,h]),{isMenuOpen:f,isContextMenuOpen:h,handleMenuOpenChange:g,handleContextMenuOpenChange:b,handleMenuOpenChangeComplete:v,toggleMenu:x}},_C=t=>{const e=Ke.c(10),{project:s,fallback:r}=t,{currentTheme:o}=Pr(),i=s.iconImage??null;let l;e[0]!==s.id||e[1]!==i?(l={id:s.id,iconImage:i},e[0]=s.id,e[1]=i,e[2]=l):l=e[2];let a;e[3]!==o.colors.surface.foreground||e[4]!==o.metadata.variant?(a={themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},e[3]=o.colors.surface.foreground,e[4]=o.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=n.jsx(Na,{project:l,options:a,className:"h-full w-full object-contain",fallback:r}),e[6]=r,e[7]=l,e[8]=a,e[9]=d):d=e[9],d},LC=t=>{const e=Ke.c(14),{project:s,label:r}=t,o=s.icon?Pa[s.icon]:null;let i;e[0]!==s.color?(i=Ea(s.color),e[0]=s.color,e[1]=i):i=e[1];const l=i;let a;e[2]!==l||e[3]!==o?(a=o?n.jsx(Z,{name:o,className:ke("h-3 w-3",!l&&"text-muted-foreground/75"),style:l?{color:l}:void 0}):n.jsx(Z,{name:"folder",className:"h-3 w-3 text-muted-foreground/75",style:l?{color:l}:void 0}),e[2]=l,e[3]=o,e[4]=a):a=e[4];const d=a;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 h;e[7]!==d||e[8]!==f||e[9]!==s?(h=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(_C,{project:s,fallback:d})}):n.jsx("span",{className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center",...f,children:d}),e[7]=d,e[8]=f,e[9]=s,e[10]=h):h=e[10];const m=h;let g;return e[11]!==r||e[12]!==m?(g=r?n.jsx(Dn,{label:r,children:m}):m,e[11]=r,e[12]=m,e[13]=g):g=e[13],g},ua=t=>{const e=Ke.c(53),{compact:s,project:r,projectLabel:o,title:i,titleClassName:l,branchLabel:a,spaceMark:d,metaLineLead:u,statusDot:f,pinnedMarker:h,timeSlot:m,directoryIndicator:g,prBadge:b,zombieIndicator:v,goal:x,badges:S,doneHint:p,providerId:y,metaPaddingClass:w,hideMetaOnHoverClass:j,actionsReserveClass:k,actionsMaskClass:P}=t,A=s===void 0?!1:s,F=d===void 0?null:d,D=u===void 0?null:u,E=x===void 0?null:x,T=p===void 0?null:p;let $;e[0]!==j||e[1]!==w?($=ke("ms-auto flex flex-shrink-0 items-center gap-1 transition-opacity",w,j),e[0]=j,e[1]=w,e[2]=$):$=e[2];const O=A?E:null,K=A?S:null;let I;e[3]!==m?(I=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:m}),e[3]=m,e[4]=I):I=e[4];let X;e[5]!==g||e[6]!==T||e[7]!==h||e[8]!==f||e[9]!==$||e[10]!==O||e[11]!==K||e[12]!==I?(X=n.jsxs("span",{className:$,children:[O,K,g,h,T,f,I]}),e[5]=g,e[6]=T,e[7]=h,e[8]=f,e[9]=$,e[10]=O,e[11]=K,e[12]=I,e[13]=X):X=e[13];const N=X;let C;e[14]!==P||e[15]!==l?(C=ke("oc-ui-start-align min-w-0 flex-1 truncate typography-ui-label font-normal",P,l),e[14]=P,e[15]=l,e[16]=C):C=e[16];let R;e[17]!==C||e[18]!==i?(R=n.jsx("div",{dir:"auto",className:C,children:i}),e[17]=C,e[18]=i,e[19]=R):R=e[19];const H=R;if(A){let oe;e[20]!==k?(oe=ke("@container relative flex w-full min-w-0 items-center gap-1",k),e[20]=k,e[21]=oe):oe=e[21];let de;return e[22]!==N||e[23]!==oe||e[24]!==H?(de=n.jsxs("div",{className:oe,children:[H,N]}),e[22]=N,e[23]=oe,e[24]=H,e[25]=de):de=e[25],de}let M;e[26]!==k?(M=ke("@container relative flex h-5 w-full min-w-0 items-center gap-1",k),e[26]=k,e[27]=M):M=e[27];let _;e[28]!==N||e[29]!==M||e[30]!==H?(_=n.jsxs("div",{className:M,children:[H,N]}),e[28]=N,e[29]=M,e[30]=H,e[31]=_):_=e[31];let B;e[32]!==r||e[33]!==o?(B=r?n.jsx(LC,{project:r,label:o}):null,e[32]=r,e[33]=o,e[34]=B):B=e[34];let ee;e[35]!==a||e[36]!==D||e[37]!==F?(ee=D??(a?n.jsxs(n.Fragment,{children:[F?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":F}):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:a})]}):null),e[35]=a,e[36]=D,e[37]=F,e[38]=ee):ee=e[38];const ne=v??b;let re;e[39]!==y?(re=y?n.jsx(lf,{providerId:y,className:"h-3 w-3 flex-shrink-0 opacity-45"}):null,e[39]=y,e[40]=re):re=e[40];let te;e[41]!==S||e[42]!==E||e[43]!==ne||e[44]!==re?(te=n.jsxs("span",{className:"ms-auto flex flex-shrink-0 items-center gap-1",children:[E,ne,S,re]}),e[41]=S,e[42]=E,e[43]=ne,e[44]=re,e[45]=te):te=e[45];let W;e[46]!==B||e[47]!==ee||e[48]!==te?(W=n.jsxs("div",{className:"flex h-4 w-full min-w-0 items-center gap-1",children:[B,ee,te]}),e[46]=B,e[47]=ee,e[48]=te,e[49]=W):W=e[49];let q;return e[50]!==_||e[51]!==W?(q=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[_,W]}),e[50]=_,e[51]=W,e[52]=q):q=e[52],q},Gh=750,To=t=>{const e=Ke.c(9),{items:s,directory:r}=t,o=Ha();let i;if(e[0]!==r||e[1]!==s||e[2]!==o){let a;e[4]!==r||e[5]!==o?(a=d=>n.jsxs("button",{type:"button",className:ke("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",!d.color&&"text-muted-foreground"),style:d.color?{color:d.color}:void 0,disabled:!d.url,onPointerDown:$C,onMouseDown:zC,onKeyDown:KC,onClick:u=>{u.stopPropagation(),d.url&&o(d.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:d.icon,className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:d.text})]}),d.title?n.jsx("span",{className:"min-w-0 truncate ps-[18px] text-muted-foreground",children:d.title}):null]},d.key),e[4]=r,e[5]=o,e[6]=a):a=e[6],i=s.map(a),e[0]=r,e[1]=s,e[2]=o,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=n.jsx("div",{className:"flex min-w-0 flex-col gap-1",children:i}),e[7]=i,e[8]=l):l=e[8],l};function $C(t){return t.stopPropagation()}function zC(t){return t.stopPropagation()}function KC(t){return t.stopPropagation()}const WC=150,Ci={capture:!0,passive:!0};let po=null;const pd=new WeakSet,HC=t=>{po={target:t.target,at:performance.now()}},md=(t,e)=>t instanceof Node&&t.contains(e);function VC(){const t=Ke.c(4),e=c.useRef(null),s=c.useRef(null);let r,o;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>(pd.has(document)||(pd.add(document),document.addEventListener("scroll",HC,Ci)),()=>s.current?.()),o=[],t[0]=r,t[1]=o):(r=t[0],o=t[1]),c.useEffect(r,o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(d,u)=>{s.current?.(),s.current=null;const f=u.trigger;if(!d||!f)return;if(po&&performance.now()-po.at<WC&&md(po.target,f)){u.cancel();return}const h=m=>{md(m.target,f)&&e.current?.close()};document.addEventListener("scroll",h,Ci),s.current=()=>document.removeEventListener("scroll",h,Ci)},t[2]=i):i=t[2];const l=i;let a;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a={actionsRef:e,onOpenChange:l},t[3]=a):a=t[3],a}let fa=!1;const ha=new Set;let gd=!1;function GC(){for(const t of ha)t()}function Uh(t){fa!==t&&(fa=t,GC())}function Zr(t){Uh(t.shiftKey)}function UC(){Uh(!1)}function qC(){if(gd||typeof window>"u")return;gd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",Zr,t),window.addEventListener("keyup",Zr,t),window.addEventListener("pointermove",Zr,t),window.addEventListener("pointerdown",Zr,t),window.addEventListener("blur",UC)}function YC(t){return qC(),ha.add(t),()=>{ha.delete(t)}}function XC(){return fa}function QC(){return!1}function qh(){return ds.useSyncExternalStore(YC,XC,QC)}const Yh=async(t,e,s)=>{const r=s.getRuntimeKey(),o=ot(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 l=s.getCurrentProjects(),a=l.find(b=>b.id===t.id)??null;if(!a||ot(a.path??null)!==o)throw new Error("Project removed during worktree refresh");const d=dl({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(b=>Mo(b));u.sort((b,v)=>Xh({metadata:b},{metadata:v}));const f=Ly(d.worktreesByProject,o,u,e?.projectDirectory);ZC(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const h=s.getPublishedWorktreesByProject(),m=$y(s.partitionWorktreesByRegisteredProject(l,f),h),g=[...m.values()].flat();return s.recordWorktreesSeen(g.map(b=>b.path),s.now()),s.worktreeMapsEqual(m,h)||s.publishTopology({availableWorktrees:g,availableWorktreesByProject:m}),u},ZC=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),JC=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Mo(r))])),dl=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:JC(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Xh=(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"})},bd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Mo=t=>({...t,path:ot(t.path)??t.path,projectDirectory:ot(t.projectDirectory)??t.projectDirectory,worktreeRoot:ot(t.worktreeRoot??t.path)??t.worktreeRoot}),yd=t=>{const{currentWorktree:e,path:s,projectDirectory:r,projectRootBranch:o}=t,l=ot(e?.path??null)===s,a=l?e?.branch??"":o??"",d={path:s,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||bd(s):o||bd(s),name:l?e?.name:void 0,worktreeRoot:l?ot(e?.worktreeRoot??s)??s:s,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:o?"branch":void 0};return l&&e?{...e,...d}:d},xd=t=>{const e=ot(t.projectPath??null),s=ot(t.sourceDirectory??null)??ot(t.currentWorktree?.path??null),r=ot(t.discoveredWorktrees.find(f=>ot(f.projectDirectory??null))?.projectDirectory??null),o=ot(t.currentWorktree?.projectDirectory??null),i=r??o??e,l=new Map,a=f=>{const h=ot(f.metadata.path??null);!h||l.has(h)||e&&h!==s&&zy(h,e)||l.set(h,{...f,metadata:Mo({...f.metadata,path:h})})};for(const f of t.discoveredWorktrees){const h=ot(f.path??null);h&&a({metadata:Mo({...f,path:h,projectDirectory:ot(f.projectDirectory??null)??i??e??h}),isPrimary:i===h,isCurrent:s===h})}i&&!l.has(i)&&a({metadata:yd({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!l.has(s)&&a({metadata:yd({path:s,projectDirectory:i??e??s,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:i===s,isCurrent:!0});const d=[],u=[];for(const f of l.values()){if(f.isPrimary){d.push(f);continue}u.push(f)}return d.sort((f,h)=>f.metadata.path.localeCompare(h.metadata.path,void 0,{sensitivity:"base"})),u.sort(Xh),[...d,...u]},Qh=(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},e3=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=dl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=Qh(t,e),l=ot(i?.path??null);return{cachedTargets:xd({projectPath:l,discoveredWorktrees:l?o.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!i||!l)throw new Error("Unable to resolve worktree project");const d=await Yh(i,t.currentWorktree,e);return xd({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},t3=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},s3=t=>({refreshState:t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),n3=(t,e)=>ot(t.worktree?.path??null)===ot(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,r3=[],o3=[],i3=[],Sd=10,Pi=new WeakMap,a3=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Pi.get(s)?.();const r=e.getBoundingClientRect().top;let o=3,i=!1,l=null;const a=()=>{i=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Pi.delete(s),s.removeEventListener("wheel",a),s.removeEventListener("touchstart",a)},d=()=>{if(i||!e.isConnected||!s.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(s.scrollTop+=u,Ss("ui.sidebar.selection_scroll_anchor_adjustment")),o-=1,o<=0){a();return}l=window.requestAnimationFrame(d)};s.addEventListener("wheel",a,{passive:!0}),s.addEventListener("touchstart",a,{passive:!0}),Pi.set(s,a),l=window.requestAnimationFrame(d)},l3=c.memo(function(e){const s=Ke.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:f}=e,h=qh(),m=h?o:r;let g;s[0]!==u||s[1]!==f||s[2]!==h?(g=k=>{if(h||k.shiftKey){f(k);return}u(k)},s[0]=u,s[1]=f,s[2]=h,s[3]=g):g=s[3];const b=g,v=h?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;s[4]!==i||s[5]!==v?(x=ke("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",v,i),s[4]=i,s[5]=v,s[6]=x):x=s[6];const S=h?"delete-bin":"archive";let p;s[7]!==l||s[8]!==S?(p=n.jsx(Z,{name:S,className:l}),s[7]=l,s[8]=S,s[9]=p):p=s[9];let y;s[10]!==b||s[11]!==m||s[12]!==d||s[13]!==a||s[14]!==x||s[15]!==p?(y=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:x,"aria-label":m,onPointerDown:a,onMouseDown:d,onClick:b,onKeyDown:b3,children:p})}),s[10]=b,s[11]=m,s[12]=d,s[13]=a,s[14]=x,s[15]=p,s[16]=y):y=s[16];let w;s[17]!==m?(w=n.jsx(Tt,{side:"top",sideOffset:6,children:m}),s[17]=m,s[18]=w):w=s[18];let j;return s[19]!==y||s[20]!==w?(j=n.jsxs(Ot,{children:[y,w]}),s[19]=y,s[20]=w,s[21]=j):j=s[21],j});function c3(t){Ss("ui.sidebar_session_node.render");const{t:e}=vt(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:h,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:b,editingRowKey:v,setEditingId:x,setEditingRowKey:S,editTitle:p,setEditTitle:y,handleSaveEdit:w,handleCancelEdit:j,toggleParent:k,handleSessionSelect:P,handleSessionDoubleClick:A,handleCopySessionId:F,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,createFolderAndStartRename:T,handleDeleteSession:$,handleRestoreSession:O,startSessionWorktreeMenuLoad:K,mobileVariant:I,alwaysShowActions:X,secondaryMeta:N,renderContext:C="project",blockingBadgeSessionScopes:R,rowKey:H,dragKey:M,children:_}=t,B=Vo(J=>J.toggle),ee=Xt(J=>J.getFoldersForScope),ne=Xt(J=>J.getSessionFolderId),re=Xt(J=>J.removeSessionFromFolder),te=Xt(J=>J.addSessionToFolder),W=ue(J=>J.openContextPanelTab),q=c.useMemo(()=>Sn(),[]),oe=c.useMemo(()=>mo(),[]),de=c.useContext(Ky),ce=q?"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",je=q?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",be=q,pe=!d&&!I,U=ue(J=>J.sessionWorkEnabled),Pe=ue(J=>J.sessionRecapEnabled),xe=U&&!d&&!s.session.parentID&&!va(s.session.directory),Ee=xe&&!X,L=(Ee?1:0)+(pe?1:0)+(be?1:0),ie=["group-hover:pe-8","group-hover:pe-14","group-hover:pe-18","group-hover:pe-22"][L],G=pe?"pe-13":"pe-7",ae=c.useRef(!1),[ye,ge]=c.useState(!1),Se=c.useRef(b);Se.current=b;const ve=c.useRef(null),Te=c.useRef(!1),z=c.useRef(w);z.current=w;const he=p,se=c.useRef(he);se.current=he;const Re=c.useRef(null),Ue=c.useRef(!1),We=c.useRef(null),He=c.useRef(null),Be=VC(),Y=s.session,Me=Y,Ge=Zt(c.useCallback(J=>{if(N?.projectLabel||!i)return null;const Pt=J.projects.find(Gt=>Gt.id===i);return Pt?Pt.label?.trim()||Ko(ot(Pt.path)??Pt.path,null)||Pt.path:null},[i,N?.projectLabel])),Ve=Un(C)||C==="timeline-chat",dt=C==="timeline-chat",et=Zt(c.useCallback(J=>C!=="timeline-mixed"||!i?null:J.projects.find(Pt=>Pt.id===i)??null,[C,i])),ct=N?.projectLabel??(Ge?cf(Ge):null),me=Vj(N,s.worktree?.branch??null),Ne=N?.inSpace===!0,qe=c.useMemo(()=>Gj(s.worktree,q),[q,s.worktree]),Ye=df(qe?.directory??null,qe?.branch??null),$e=c.useMemo(()=>q?r3:uf(Y),[q,Y]),tt=c.useMemo(()=>$e.map(J=>({item:Sr("pull",J),url:J.url,title:J.title})),[$e]),ht=nc(tt),wt=c.useMemo(()=>ht.filter(J=>J!==null),[ht]),Bt=c.useMemo(()=>q?i3:Wy(Y),[q,Y]),kt=c.useMemo(()=>Bt.flatMap(J=>J.gitlab?[{item:vr("pull",J.gitlab),url:J.url,title:J.title}]:[]),[Bt]),St=nc(kt),xt=c.useMemo(()=>Hy(Ye,[...wt,...St.filter(J=>J!==null)]),[Ye,St,wt]),Mt=c.useMemo(()=>{let J=0;return Bt.filter(Pt=>{if(!Pt.gitlab)return!0;const Gt=St[J]!==null;return J+=1,!Gt})},[St,Bt]),jt=c.useMemo(()=>Vy($e,xt),[$e,xt]),$t=Ye?`var(--pr-${Ye.visualState})`:void 0,Kt=c.useMemo(()=>q?o3:Va(Y),[q,Y]),Wt=c.useMemo(()=>Kt.flatMap(J=>J.source==="github"?[Sr("issue",J)]:[]),[Kt]),rt=ko(Wt),ut=c.useMemo(()=>Kt.flatMap(J=>J.source==="gitlab"?[vr("issue",J.ref)]:[]),[Kt]),pt=ko(ut),fe=c.useMemo(()=>Kt.flatMap(J=>J.source==="linear"?[Ga(J.identifier)]:[]),[Kt]),lt=ff(fe),ft=c.useMemo(()=>{if(xt.length>0||jt.length>0||Mt.length>0){const J=xt.map(_t=>{const as=hf(_t,e),Ut=Aa(_t.provider,_t.number);return{key:`${_t.provider??""}:${_t.repo?.owner??""}/${_t.repo?.repo??""}#${_t.number}`,icon:"git-pull-request",label:Ut,color:`var(--pr-${_t.visualState})`,url:_t.url,title:_t.title,text:as?`${Ut} · ${as}`:Ut}}),Pt=jt.map(_t=>({key:`${_t.owner}/${_t.repo}#${_t.number}`,icon:"git-pull-request",label:`#${_t.number}`,url:_t.url,title:_t.title,text:`#${_t.number}`})),Gt=Mt.map(_t=>({key:_t.key,icon:"git-pull-request",label:_t.identifier,url:_t.url,title:_t.title,text:_t.identifier}));return[...J,...Pt,...Gt]}return pf(Kt,rt,lt,pt).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}))},[pt,rt,Kt,lt,jt,xt,e,Mt]),mt=ft[0]??null,Rt=Math.max(0,ft.length-1),we=Ha(),it=ft.map(J=>J.text).join(", "),Q=nt(J=>J.currentSessionId===Y.id),le=ot(Y.directory??null)??ot(o??null),Xe=a!==void 0?a:i??le??null,Ae=Cu(),Je=mf(),Fe=q,gt=gC(),bt=cs(J=>J.enabled),Et=cs(c.useCallback(J=>J.selectedIds.has(Y.id),[Y.id])),Ft=cs(J=>J.toggleSelected),es=cs(J=>J.setRange),Ie=Hh(),Ze=H??Y.id,at=b===Y.id&&v===Ze,Lt=c.useCallback(J=>{const Pt=[],Gt=_t=>{_t.children.forEach(as=>{Pt.push(as.session.id),Gt(as)})};return Gt(J),Pt},[]),Vt=c.useCallback(J=>{const Pt=[],Gt=_t=>{_t.children.forEach(as=>{Pt.push(as.session),Gt(as)})};return Gt(J),Pt},[]),[Ht,Oe]=c.useState(!1),[ze,st]=c.useState(!0),Nt=`${C}:${d?"archived":"active"}:${Y.id}`,It=H?`session-menu:${H}`:Nt,ts=H?`session-context:${H}`:null,fs=Gy(c.useCallback(J=>!!J.sessionMemoryState.get(Uy(Y.id))?.isZombie,[Y.id])),us=mu(Y.id),Ce=us!==null,V=qy(Y.id,Ce),De=Bf(Y.id),_e=ka(Y.id,le),Qe=De||_e,yt=s.worktree??nt.getState().getWorktreeMetadata(Y.id)??null,[Dt,zt]=c.useState([]),[Jt,Ds]=c.useState(!1),ys=c.useRef(!1),Is=c.useRef(0),Hs=Yy(Me),is=xe&&Ua(Me),Zo=is&&!Ce&&Xy(Me),_r=e(is?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),ul=async()=>{try{await lx(Y.id,le,is?"done":"open")}catch{Le.error(e("sessions.sidebar.session.work.updateFailed"))}},fl=Hs?e(Qy[Hs.status]):"",hl=Hs?n.jsx(Dn,{label:fl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":fl,children:n.jsx(Z,{name:"target",className:"h-3 w-3",style:{color:Zy[Hs.status]}})})}):null,ln=Me.title||e("sessions.sidebar.session.untitled"),pl=!Ve&&s.children.length>0,Lr=Wa(u,le,Y.id),Jo=Nt,An=h?!0:f.has(Jo),hp=c.useMemo(()=>R??ca(s,An,le),[An,s,le,R]),{hasPermission:ml,hasForm:gl}=Jy(hp),bl=!!Me.parentID,yl=gu(Y.id)>0&&(!bl||g),xl=ex(Me)||Date.now(),pp=tx(xl),ei=gf(xl),{isMenuOpen:Sl,isContextMenuOpen:vl,handleMenuOpenChange:mp,handleContextMenuOpenChange:gp,handleMenuOpenChangeComplete:wl,toggleMenu:bp}=FC({menuInstanceKey:It,contextMenuInstanceKey:ts,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,hasDeferredCloseWork:()=>ve.current!==null,onCloseComplete:()=>{if(!ve.current)return;const{id:J,title:Pt}=ve.current;ve.current=null,x(J),S(Ze),y(Pt)}}),rr=Sl||vl,kl=c.useMemo(()=>sx(Me)?.key??null,[Me]),ti=c.useMemo(()=>Lt(s).length,[Lt,s]),si=c.useCallback(async J=>{const Pt=[];let Gt=0;for(const _t of J)try{if(!le)throw new Error("Session directory is required for export");const as=await Ae({directory:le,sessionID:_t.session.id});if(!as)throw new Error("Session runtime changed during export");const Ut=_t.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Fs=_t.session.agent,xs=await si(_t.children);Gt+=xs.skipped,Pt.push({title:Ut,agent:Fs,records:as,children:xs.children})}catch{Gt+=Lt(_t).length+1}return{children:Pt,skipped:Gt}},[Lt,Ae,le,e]),ni=c.useCallback(J=>{J<=0||Le.warning(J===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:J}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:J}))},[e]),ri=c.useCallback(async J=>{if(!le){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Pt=await Ae({directory:le,sessionID:Y.id}).catch(()=>null);if(!Pt){Le.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Pt.length===0){Le.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Gt,_t=0;if(J&&s.children.length>0){const xs=await si(s.children);Gt=xs.children,_t=xs.skipped}const as=Pu(Pt,Me.title??null,Gt),Ut=Eu(Me.title??null),Fs=await Nu(as,Ut);if(Fs){Le.success(e("sessions.sidebar.session.export.success"),{action:{label:e(rx()),onClick:()=>{nx(Fs).then(xs=>{xs||Le.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),ni(_t);return}Ru(as,Ut),Le.success(e("sessions.sidebar.session.export.success")),ni(_t)},[si,Ae,s.children,Me.title,Y.id,le,ni,e]),jl=Du(),yp=c.useMemo(()=>Iu(jl),[jl]),xp=c.useCallback(J=>{Af({entry:J,t:e,session:{id:Y.id,title:Me.title,directory:le},loadRecords:()=>le?Ae({directory:le,sessionID:Y.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Le.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[Ae,Me.title,Y.id,le,e]),Sp=c.useCallback(async()=>{if(s.children.length>0){st(!0),Oe(!0);return}await ri(!1)},[ri,s.children.length]),vp=c.useCallback(()=>{le&&hn("desktop_open_session_mini_chat_window",{sessionId:Y.id,directory:le,apiBaseUrl:hr(),clientToken:to()}).catch(J=>{console.warn("[session-sidebar] failed to open mini chat window",J)})},[Y.id,le]),Cl=()=>{if(!le)return;const J=cx()??le;W(J,{mode:"chat",dedupeKey:`session:${Y.id}`,label:ln,sessionTitleFallback:ln,targetDirectory:le})};if(c.useEffect(()=>{if(!at)return;const J=Pt=>{const _t=(Pt.target instanceof HTMLElement?Pt.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ze)}"]`);He.current&&!_t&&z.current(se.current)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[at,Ze]),c.useLayoutEffect(()=>{if(!at){Re.current===Ze&&(Re.current=null);return}Re.current!==Ze&&(Re.current=Ze,Ue.current=!0)},[p,at,Ze]),c.useLayoutEffect(()=>{if(!at||!Ue.current)return;const J=We.current;!J||J.value!==p||(Ue.current=!1,J.focus(),J.select())},[p,at,he]),at){const J=n.jsxs("form",{ref:He,"data-session-rename-form":Ze,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Pt=>{Pt.preventDefault(),w(he)},children:[n.jsx("input",{ref:We,value:he,onChange:Pt=>y(Pt.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:Pt=>Mi(Pt,j)}),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:j,"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 Ve?n.jsx("div",{style:{paddingInlineStart:Sd},className:ke("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pe-2.5",dt?"py-1":"py-1.5",Q&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(ua,{compact:dt,project:et,projectLabel:ct,title:J,titleClassName:"text-foreground",branchLabel:me,spaceMark:Ne?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:ei,directoryIndicator:null,prBadge:mt?n.jsxs("span",{className:ke("inline-flex flex-shrink-0 items-center gap-1 typography-micro",mt.color?"oc-ref-tint":"text-muted-foreground"),style:mt.color?Wn(mt.color):void 0,children:[n.jsx(Z,{name:mt.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:mt.label}),Rt>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",Rt]}):null]}):null,zombieIndicator:null,goal:hl,badges:null,hideMetaOnHoverClass:""})},Y.id):n.jsxs("div",{style:{paddingInlineStart:tr(r)},className:"group relative my-0.5 flex items-center gap-1.5 rounded-md py-[3px] pe-2.5",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})]},Y.id)}const Pl=e("sessions.sidebar.session.status.questionPending"),El=!Qe&&!Ce&&yl&&!Q,wp=Ce||El,kp=n.jsx(xu,{state:us??"unread",tooltip:!0}),jp=(Ce||El)&&V,Cp=Ve&&!dt?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][L]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][L],Pp=X?void 0:rr?"oc-actions-mask":q?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",Ep=rr?"opacity-0":je,Nl=e("sessions.sidebar.session.status.pinned"),Np=n.jsx(Dn,{label:Nl,children:n.jsx("span",{className:"inline-flex flex-shrink-0 items-center","aria-label":Nl,children:n.jsx(Z,{name:"pushpin",className:"h-3 w-3 text-primary"})})}),Rp=n.jsx(Z,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(_e?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),Dp=Ve?null:pl?n.jsx("span",{role:"button",tabIndex:0,onClick:J=>{J.stopPropagation(),J.currentTarget.blur(),k(Jo)},onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),J.stopPropagation(),k(Jo))},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-label":e(An?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),"aria-expanded":An,children:n.jsx(Cr,{expanded:An})}):n.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 flex-shrink-0"}),oi=fs?n.jsx(Z,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Ip=J=>{J.preventDefault(),J.stopPropagation(),bp()},Tp=J=>{J.preventDefault(),J.stopPropagation()},Mp=J=>{J.preventDefault(),J.stopPropagation()},ii=J=>{J.preventDefault(),J.stopPropagation()},ai=J=>{J.preventDefault(),J.stopPropagation()},Ap=J=>{J.preventDefault(),J.stopPropagation(),E(null),$(Y,{archivedBucket:d})},Op=J=>{J.preventDefault(),J.stopPropagation(),E(null),$(Y,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Bp=J=>{J.preventDefault(),J.stopPropagation()},Fp=J=>{J.preventDefault(),J.stopPropagation()},_p=J=>{J.preventDefault(),J.stopPropagation(),de?.vscode?.executeCommand("openchamber.openSessionInEditor",Y.id,ln)},Rl=J=>{if(ae.current){ae.current=!1;return}if(bt){if(J?.preventDefault(),J?.stopPropagation(),J?.shiftKey){const Pt=Ie?.getEntries(),Gt=Pt??Array.from(document.querySelectorAll("[data-session-row]")).map(Ut=>Ut.getAttribute("data-session-row")).filter(Ut=>!!Ut).map(Ut=>({id:Ut,rowKey:Ut,scopeKey:Xe,archived:d})),_t=Pt?cs.getState().anchorRowKey:cs.getState().anchorId,as=new Map;as.set(Y.id,Lt(s)),es(_t,Ze,Gt,Ie?.getDescendantIds()??[],Xe,as);return}Ft(Y.id,Xe,Lt(s),Ze);return}if(J?.shiftKey&&!q&&le){Cl();return}J?.currentTarget&&a3(J.currentTarget),P(Y.id,le)},Lp=J=>{J.defaultPrevented||(J.target instanceof HTMLElement?J.target:null)?.closest('button, a, input, [data-session-row-main], [role="menuitem"], [role="menu"]')||Rl(J)},$p=J=>{(J.button===2||J.button===0&&J.ctrlKey&&!bt)&&(ae.current=!0),J.button===0&&J.shiftKey&&!bt&&J.preventDefault()},zp=J=>{I&&J.pointerType==="touch"&&ge(!0),J.button===0&&!Q&&!bt&&!Fe&&le&&!zi(Y.id,le).renderable&&Je({directory:le,sessionID:Y.id}).catch(()=>{})},On=!Q&&!bt&&le?{id:Y.id,directory:le}:null,Kp=J=>{J.pointerType!=="mouse"||!On||gt?.schedule(On)},Wp=()=>{On&&gt?.schedule(On)},Dl=()=>{On&&gt?.cancel(On)},Il=J=>{I&&J.pointerType==="touch"&&ge(!1)},Hp=J=>{ys.current=J,Is.current+=1;const Pt=Is.current;if(!J){Ds(!1);return}const Gt=K({projectId:i??null,sourceDirectory:le,currentWorktree:yt});zt(Gt.cachedTargets),Ds(!1),Gt.refreshTargets.then(_t=>{!ys.current||Is.current!==Pt||(zt(_t),Ds(!1))}).catch(()=>{!ys.current||Is.current!==Pt||Ds(!0)})},Tl=({Item:J,Separator:Pt,Sub:Gt,SubTrigger:_t,SubContent:as})=>n.jsxs(n.Fragment,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(J,{onClick:()=>{ve.current={id:Y.id,title:ln}},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(Yi,{sessionID:Y.id,directory:le,open:rr,Item:J}),n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(J,{onClick:()=>F(Y.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(Qt,{hint:e(Lr?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(J,{onClick:()=>le&&B({directory:le,sessionId:Y.id}),className:"[&>svg]:me-1",children:[Lr?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(Lr?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),xe?n.jsx(Qt,{hint:e(is?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(J,{onClick:()=>{ul()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:is?"check":"eye",className:"me-1 h-4 w-4"}),e(is?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(J,{onClick:()=>{Sp()},className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"download",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),yp.map(Ut=>n.jsxs(J,{onClick:()=>xp(Ut),className:"[&>svg]:me-1",children:[n.jsx(sr,{icon:Ut.icon,iconSrc:Ut.iconSrc,className:"me-1 size-4"}),Ut.action.label]},`${Ut.guest.id}:${Ut.action.id}`)),Kj({isSubtaskSession:bl,archivedBucket:!!d,isVSCode:q,sessionDirectory:le})?(()=>{const Ut=Wj({sessionDirectory:le,isStreaming:Ce,isMovingToWorktree:De}),Fs=s3({targets:Dt,loadFailed:Jt}),xs=n.jsxs(_t,{disabled:Ut,className:"w-full [&>svg]:me-1","data-session-worktree-submenu-trigger":Y.id,children:[n.jsx(Z,{name:"folder-shared",className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]}),Ts=De?e("sessions.sidebar.session.moveToWorktree.tooltipMoving"):Ce?e("sessions.sidebar.session.moveToWorktree.tooltipBusy"):null;return n.jsxs(Gt,{onOpenChange:Hp,children:[Ts?n.jsx(Qt,{hint:Ts,children:xs}):xs,n.jsxs(as,{className:"min-w-[220px]","data-session-worktree-submenu":Y.id,children:[Dt.map(ms=>{const hs=ot(ms.metadata.path??null)??ms.metadata.path,ps=ms.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):ms.metadata.label||ms.metadata.branch||ms.metadata.name||ms.metadata.path,Qs=ms.isCurrent||ms.metadata.worktreeStatus!=="ready";return n.jsxs(J,{disabled:Qs,title:ms.metadata.path,"data-session-worktree-target":hs,onClick:()=>{Qs||!le||Co({kind:"existing",root:Me,descendants:Vt(s),sourceDirectory:le,destination:ms.metadata,messages:jo(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:ps}),ms.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),ms.isCurrent?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},hs)}),Fs.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(Pt,{}),n.jsxs(J,{disabled:Ut,"data-session-worktree-new-action":"true",onClick:()=>{Ut||!le||Co({kind:"quick",root:Me,descendants:Vt(s),sourceDirectory:le,messages:jo(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,kl?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(J,{onClick:()=>ue.getState().setRunOverviewKey(kl),className:"[&>svg]:me-1",children:[n.jsx(Ki,{className:"me-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,le&&!d&&!Ve?(()=>{const Ut=[],Fs=hs=>{const ps=ot(hs??null);ps&&!Ut.includes(ps)&&Ut.push(ps)};if(i&&!q){const hs=Zt.getState().projects.find(Qs=>Qs.id===i),ps=ot(hs?.path??null);Fs(ps),ps&&(nt.getState().availableWorktreesByProject.get(ps)??[]).forEach(Qs=>Fs(Qs.path))}Fs(wa(le)),Fs(le);const xs=Ut.flatMap(hs=>ee(hs).map(ps=>({scope:hs,folder:ps}))),Ts=xs.find(({scope:hs,folder:ps})=>ne(hs,Y.id)===ps.id)??null,ms=Ut[0]??le;return n.jsxs(n.Fragment,{children:[n.jsx(Pt,{}),n.jsxs(Gt,{children:[n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(_t,{className:"[&>svg]:me-1",children:[n.jsx(Z,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(as,{className:"min-w-[180px]",children:[xs.length===0?n.jsx(J,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):xs.map(({scope:hs,folder:ps})=>{const Qs=Ts?.folder.id===ps.id;return n.jsxs(J,{onClick:()=>{if(Qs){re(hs,Y.id);return}Ts&&Ts.scope!==hs&&re(Ts.scope,Y.id),te(hs,ps.id,Y.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ps.name}),Qs?n.jsx(Z,{name:"check",className:"ms-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ps.id)}),n.jsx(Pt,{}),n.jsxs(J,{onClick:()=>{const hs=T(ms);hs&&(Te.current=!0,Ts&&Ts.scope!==ms&&re(Ts.scope,Y.id),te(ms,hs.id,Y.id))},children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Ts?n.jsxs(J,{onClick:()=>{re(Ts.scope,Y.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,q?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(J,{disabled:!le,onClick:Cl,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")})]})}),oe?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(J,{disabled:!le,onClick:vp,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(Pt,{}),d?null:n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>$(Y,{archivedBucket:d}),children:[n.jsx(Z,{name:"inbox-archive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),d?n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(J,{className:"[&>svg]:me-1",onClick:()=>O(Y),children:[n.jsx(Z,{name:"inbox-unarchive",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(Qt,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(J,{className:"text-destructive focus:text-destructive [&>svg]:me-1",onClick:()=>$(Y,{archivedBucket:d,hardDelete:!0}),children:[n.jsx(Z,{name:"delete-bin",className:"me-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),Vp=J=>{J.preventDefault(),J.stopPropagation(),ul()},li=X?"h-6 w-6":Ve&&!dt?"h-5 w-5":"h-4 w-4",$r=X?"h-3.5 w-3.5":Ve&&!dt?"h-3 w-3":"h-2.5 w-2.5",Gp=X?"h-4 w-4":Ve&&!dt?"h-3.5 w-3.5":"h-3 w-3",Ml=Pe&&!Ce&&ox(Me)?.recap||null,Al=e("sessions.sidebar.session.work.doneSuggested"),Up=J=>Zo?n.jsx(Dn,{label:Al,children:n.jsx("span",{className:ke("inline-flex flex-shrink-0 items-center text-muted-foreground/75",J),"aria-label":Al,children:n.jsx(Z,{name:"check",className:"h-3.5 w-3.5"})})}):null,Ol=e("sessions.sidebar.session.status.permissionRequired"),qp=ml||gl?n.jsxs(n.Fragment,{children:[ml?n.jsx(Dn,{label:Ol,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":Ol,children:n.jsx(Z,{name:"shield",className:"h-3 w-3"})})}):null,gl?n.jsx(Dn,{label:Pl,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":Pl,children:n.jsx(Z,{name:"question",className:"h-3 w-3"})})}):null]}):null,Yp=Ve&&mt?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,closeDelay:Gh,children:n.jsxs("button",{type:"button",className:ke("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",mt.color?"oc-ref-tint":"text-muted-foreground"),style:mt.color?Wn(mt.color):void 0,disabled:!mt.url,"aria-label":it,onPointerDown:ii,onMouseDown:ai,onClick:J=>{J.preventDefault(),J.stopPropagation(),!(J.target instanceof Element&&J.target.closest("[data-ref-more]"))&&mt.url&&we(mt.url,le,J)},onKeyDown:J=>J.stopPropagation(),children:[n.jsx(Z,{name:mt.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:mt.label}),Rt>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",Rt]}):null]})}),n.jsx(Tt,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(To,{items:ft,directory:le})})]}):null,Xp=n.jsx(ua,{compact:!Un(C),project:et,projectLabel:ct,title:no(ln,m),titleClassName:Q||Et?"text-interactive-selection-foreground":yl?"text-foreground":"text-foreground/80",branchLabel:me,spaceMark:Ne?e("sessions.sidebar.group.space"):null,statusDot:Qe?Rp:wp?kp:null,pinnedMarker:Lr&&!Qe?Np:null,timeSlot:jp?n.jsx(ix,{sessionId:Y.id,running:Ce,className:"typography-micro"}):ei,directoryIndicator:!d&&le&&C!=="project"?n.jsx(Io,{directory:le}):null,prBadge:Yp,zombieIndicator:Ve?oi:null,goal:hl,badges:qp,doneHint:Up(),providerId:Ve?Me.model?.providerID??null:null,metaPaddingClass:Ve&&X?pe?"pe-13":"pe-7":void 0,hideMetaOnHoverClass:X&&!q?"":Ep,actionsReserveClass:Cp,actionsMaskClass:Pp}),Qp=n.jsx(Ps,{align:"end",className:"min-w-[180px]",finalFocus:()=>Te.current?(Te.current=!1,!1):!Se.current,children:Tl({Item:qt,Separator:bn,Sub:sf,SubTrigger:nf,SubContent:rf})}),Zp=n.jsx(Vi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(Ui,{"data-slot":"dropdown-menu-content",finalFocus:()=>Te.current?(Te.current=!1,!1):!Se.current,style:{color:"var(--surface-elevated-foreground)"},className:ke(Ai,"min-w-[180px]"),children:Tl({Item:({className:J,...Pt})=>n.jsx(If,{className:ke(yu,J),...Pt}),Separator:({className:J,...Pt})=>n.jsx(Df,{className:ke(bu,J),...Pt}),Sub:j1,SubTrigger:({className:J,children:Pt,...Gt})=>n.jsxs(C1,{className:ke(ax,J),...Gt,children:[Pt,n.jsx(Z,{name:"arrow-right-s",className:"ms-auto size-3.5"})]}),SubContent:({className:J,children:Pt,...Gt})=>n.jsx(Vi,{children:n.jsx(Gi,{className:"app-region-no-drag z-50",children:n.jsx(Ui,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:ke(Ai,J),...Gt,children:Pt})})})})})})});return n.jsxs(c.Fragment,{children:[n.jsx(MC,{sessionId:Y.id,dragKey:M??Ze,ownerKey:l??Xe,sessionDirectory:le??null,sessionTitle:ln,archivedBucket:d,children:n.jsxs(Mf,{open:vl,onOpenChange:gp,onOpenChangeComplete:wl,children:[n.jsxs(Tf,{render:n.jsx("div",{"data-session-row":Y.id,"data-session-scope":Xe??"","data-session-archived":d?"1":"0","aria-current":Q?"page":void 0,onClick:Lp,style:{paddingInlineStart:Ve?Sd:tr(r)},className:ke("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pe-2.5",!Ve&&"gap-1.5",Ve?dt?"py-1":"py-1.5":"py-[3px]",!(Q||Et)&&"hover:bg-interactive-hover/60",(Q||Et)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Et&&"ring-1 ring-inset ring-border")}),children:[Dp,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Ot,{actionsRef:Be.actionsRef,onOpenChange:Be.onOpenChange,children:[n.jsx(At,{asChild:!0,closeDelay:0,disabled:q,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":bt?Et:void 0,onPointerDown:zp,onPointerUp:Il,onPointerCancel:Il,onPointerEnter:Kp,onPointerLeave:Dl,onFocus:Wp,onBlur:Dl,onMouseDown:$p,onClick:J=>Rl(J),onDoubleClick:J=>{J.stopPropagation(),A(Y.id,ln)},className:ke("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",ye&&"bg-interactive-hover/70",Ve||!X?void 0:q?ie:G),children:Xp})}),q?null:n.jsx(Tt,{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:ln}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:pp,children:ei})]}),ct?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:ct})]}):null,me?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[Ne?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:ke("h-3 w-3 flex-shrink-0",$t&&"oc-ref-tint"),style:$t?Wn($t):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:me})]}):null,ft.length>0?n.jsx(To,{items:ft,directory:le}):null,Ml?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Ml}):null]})})]})}),oi&&!I&&!Ve?n.jsx("div",{className:"absolute inset-e-1 top-1/2 -translate-y-1/2 z-10",children:oi}):null,n.jsx("div",{className:ke("absolute inset-e-1 z-10 flex items-center gap-0.5 transition-opacity",Ve&&!dt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",rr||X&&!q?"opacity-100":ke("opacity-0",ce)),children:n.jsxs(Go,{delayDuration:400,children:[Ee?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:ke("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",li,is?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":_r,onPointerDown:ii,onMouseDown:ai,onClick:Vp,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:is?"check":"eye",className:is?Gp:$r})})}),n.jsx(Tt,{side:"top",sideOffset:6,children:_r})]}):null,pe?n.jsx(l3,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:li,iconSizeClass:$r,onPointerDown:ii,onMouseDown:ai,onArchive:Ap,onDelete:Op}):null,be?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",className:ke("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",li),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Bp,onMouseDown:Fp,onClick:_p,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"external-link",className:$r})})}),n.jsx(Tt,{side:"top",sideOffset:6,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(js,{open:Sl,onOpenChange:mp,onOpenChangeComplete:wl,children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ke("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",X?"h-6 w-6 opacity-100":rr?"h-4 w-4 opacity-100":ke("h-4 w-4 opacity-0",ce)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Tp,onMouseDown:Mp,onClick:Ip,onKeyDown:J=>J.stopPropagation(),children:n.jsx(Z,{name:"more-2",className:$r})})}),Qp]})]})})]}),Zp]})}),pl&&An?_:null,n.jsx(Ks,{open:Ht,onOpenChange:Oe,children:n.jsxs(zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Ys,{children:[n.jsx(Us,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(qs,{children:ti===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:ti}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:ti})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:ze,onChange:J=>st(J.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(yn,{children:[n.jsx(Ct,{type:"button",onClick:()=>Oe(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{type:"button",onClick:()=>{Oe(!1),ri(ze)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},Y.id)}const vd=t=>ot(t.session.directory??null),d3=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),u3=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},wd=t=>t.menuOpenSessionId??u3(t),Jr=(t,e,s)=>e?s.has(t.node.session.id)?!0:Jn(t.node,e):!1,pa=(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 l=0;l<t.children.length;l+=1)if(pa(t.children[l],e.children[l],s,r,o))return!0;return!1},f3=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return pa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||pa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},h3=(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&&bf(t,e),p3=(t,e)=>{if(t.node.session.id!==e.node.session.id||!h3(t.node.session,e.node.session)||!n3(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(vd(t.node)!==vd(e.node))return"nodeDirectory";if(!d3(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&Th(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&f3(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(Jr(t,t.editingId,t.subtreeContainsEditing)||Jr(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&&(Jr(t,t.editingId,t.subtreeContainsEditing)||Jr(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=wd(t),o=wd(e);if(Jn(t.node,r)||Jn(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"},m3=(t,e)=>{const s=p3(t,e);return s===null?!0:(Ss(`ui.sidebar_session_node.props_changed.${s}`),!1)},g3=c.memo(c3,m3);function b3(t){return t.stopPropagation()}const y3=t=>{const{t:e}=vt(),s=c.useRef(t.editingId),r=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);s.current=t.editingId,r.current=t.editTitle,o.current=t.deleteSessionConfirm;const i=ue(N=>N.setSessionSwitcherOpen),l=nt(N=>N.setCurrentSession),a=nt(N=>N.updateSessionTitle),d=nt(N=>N.deleteSession),u=nt(N=>N.deleteSessions),f=nt(N=>N.archiveSession),h=nt(N=>N.archiveSessions),m=nt(N=>N.unarchiveSession),{mobileVariant:g,allowReselect:b,onSessionSelected:v,resetSessionSearch:x,descendantIds:S,showDeletionDialog:p,setDeleteSessionConfirm:y,setEditingId:w,setEditingRowKey:j,editingSessionId:k,editingOccurrenceKey:P,setEditTitle:A}=t,F=c.useCallback((N,C)=>{if(Ti("navigation.session_select"),ue.getState().closeMainSurfaces(),g&&i(!1),N===nt.getState().currentSessionId){b&&v?.(N),x();return}Ti("navigation.session_state_set"),l(N,C??null),v?.(N),x()},[b,g,v,x,l,i]),D=c.useCallback((N,C)=>{w(N),j(P),A(C)},[P,A,w,j]),E=c.useCallback(async N=>{if(!s.current)return;const R=(N??r.current).trim();if(R)try{await a(k,R)}catch(H){console.error("[session-actions] rename failed",H),Le.error(e("sessions.sidebar.session.rename.error",{detail:fu(H instanceof Error?H:new Error(String(H)),e)}))}w(null),j(null),A("")},[k,A,w,j,e,a]),T=c.useCallback(()=>{w(null),j(null),A("")},[A,w,j]),$=c.useCallback(N=>{Wo(N).then(C=>{if(C.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))},[e]),O=c.useCallback(async(N,C,R)=>{const H=C?.archivedBucket===!0||C?.hardDelete===!0,M=R?.descendantIds??S;await Ng(H?"delete":"archive",N,M,{archiveSession:f,archiveSessions:h,deleteSession:d,deleteSessions:u},e)},[f,h,d,u,S,e]),K=c.useCallback((N,C)=>{const R=C?.archivedBucket===!0||C?.hardDelete===!0,H=ou(N.id,S,R);if(!p||C?.skipConfirm===!0){O(N,C,{descendantIds:H});return}y({session:N,descendantCount:H.length,descendantIds:H,archivedBucket:R})},[S,O,y,p]),I=c.useCallback(async()=>{const N=o.current;if(!N)return;const{session:C,archivedBucket:R,descendantIds:H}=N;y(null),await O(C,{archivedBucket:R},{descendantIds:H})},[O,y]),X=c.useCallback(async N=>{await m(N.id)?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))},[e,m]);return c.useMemo(()=>({handleSessionSelect:F,handleSessionDoubleClick:D,handleSaveEdit:E,handleCancelEdit:T,handleCopySessionId:$,handleDeleteSession:K,handleRestoreSession:X,confirmDeleteSession:I}),[T,$,K,X,E,D,F,I])};function x3(t){const e=Ke.c(71),{t:s}=vt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,f,h,m,g,b,v,x,S;if(e[0]!==o||e[1]!==s||e[2]!==r){const C=s("sessions.sidebar.session.untitled");h=Ks,x=!!r,e[13]!==o?(S=H=>{H||o(null)},e[13]=o,e[14]=S):S=e[14],f=zs,b=!1,v="max-w-sm gap-5",u=Ys;let R;e[15]!==s||e[16]!==r?.archivedBucket?(R=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=R):R=e[17],e[18]!==R?(g=n.jsx(Us,{children:R}),e[18]=R,e[19]=g):g=e[19],d=qs,m=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||C,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||C,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||C,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||C,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||C}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||C}),e[0]=o,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=h,e[7]=m,e[8]=g,e[9]=b,e[10]=v,e[11]=x,e[12]=S}else d=e[3],u=e[4],f=e[5],h=e[6],m=e[7],g=e[8],b=e[9],v=e[10],x=e[11],S=e[12];let p;e[20]!==d||e[21]!==m?(p=n.jsx(d,{children:m}),e[20]=d,e[21]=m,e[22]=p):p=e[22];let y;e[23]!==u||e[24]!==g||e[25]!==p?(y=n.jsxs(u,{children:[g,p]}),e[23]=u,e[24]=g,e[25]=p,e[26]=y):y=e[26];let w;e[27]!==l||e[28]!==i?(w=()=>l(!i),e[27]=l,e[28]=i,e[29]=w):w=e[29];const j=!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 P;e[32]!==s?(P=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=P):P=e[33];let A;e[34]!==k||e[35]!==P||e[36]!==w||e[37]!==j?(A=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":j,children:[k,P]}),e[34]=k,e[35]=P,e[36]=w,e[37]=j,e[38]=A):A=e[38];let F;e[39]!==o?(F=()=>o(null),e[39]=o,e[40]=F):F=e[40];let D;e[41]!==s?(D=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=D):D=e[42];let E;e[43]!==F||e[44]!==D?(E=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:D}),e[43]=F,e[44]=D,e[45]=E):E=e[45];let T;e[46]!==a?(T=()=>{a()},e[46]=a,e[47]=T):T=e[47];let $;e[48]!==s||e[49]!==r?.archivedBucket?($=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=$):$=e[50];let O;e[51]!==T||e[52]!==$?(O=n.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:$}),e[51]=T,e[52]=$,e[53]=O):O=e[53];let K;e[54]!==E||e[55]!==O?(K=n.jsxs("div",{className:"flex items-center gap-2",children:[E,O]}),e[54]=E,e[55]=O,e[56]=K):K=e[56];let I;e[57]!==A||e[58]!==K?(I=n.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[A,K]}),e[57]=A,e[58]=K,e[59]=I):I=e[59];let X;e[60]!==f||e[61]!==b||e[62]!==I||e[63]!==v||e[64]!==y?(X=n.jsxs(f,{showCloseButton:b,className:v,children:[y,I]}),e[60]=f,e[61]=b,e[62]=I,e[63]=v,e[64]=y,e[65]=X):X=e[65];let N;return e[66]!==h||e[67]!==X||e[68]!==x||e[69]!==S?(N=n.jsx(h,{open:x,onOpenChange:S,children:X}),e[66]=h,e[67]=X,e[68]=x,e[69]=S,e[70]=N):N=e[70],N}function S3(t){const e=Ke.c(57),{t:s}=vt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let f;e[0]!==d||e[1]!==u||e[2]!==s?(f=s(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=s,e[3]=f):f=e[3];const h=f;let m;e[4]!==d||e[5]!==u||e[6]!==s?(m=d?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]=d,e[5]=u,e[6]=s,e[7]=m):m=e[7];const g=m,b=!!r;let v;e[8]!==o?(v=N=>{N||o(null)},e[8]=o,e[9]=v):v=e[9];let x;e[10]!==h?(x=n.jsx(Us,{children:h}),e[10]=h,e[11]=x):x=e[11];let S;e[12]!==g?(S=n.jsx(qs,{children:g}),e[12]=g,e[13]=S):S=e[13];let p;e[14]!==x||e[15]!==S?(p=n.jsxs(Ys,{children:[x,S]}),e[14]=x,e[15]=S,e[16]=p):p=e[16];let y;e[17]!==l||e[18]!==i?(y=()=>l(!i),e[17]=l,e[18]=i,e[19]=y):y=e[19];const w=!i;let j;e[20]!==i?(j=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]=j):j=e[21];let k;e[22]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=k):k=e[23];let P;e[24]!==k||e[25]!==y||e[26]!==w||e[27]!==j?(P=n.jsxs("button",{type:"button",onClick:y,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":w,children:[j,k]}),e[24]=k,e[25]=y,e[26]=w,e[27]=j,e[28]=P):P=e[28];let A;e[29]!==o?(A=()=>o(null),e[29]=o,e[30]=A):A=e[30];let F;e[31]!==s?(F=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=F):F=e[32];let D;e[33]!==A||e[34]!==F?(D=n.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:F}),e[33]=A,e[34]=F,e[35]=D):D=e[35];let E;e[36]!==a?(E=()=>{a()},e[36]=a,e[37]=E):E=e[37];let T;e[38]!==d||e[39]!==s?(T=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=T):T=e[40];let $;e[41]!==E||e[42]!==T?($=n.jsx("button",{type:"button",onClick:E,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[41]=E,e[42]=T,e[43]=$):$=e[43];let O;e[44]!==D||e[45]!==$?(O=n.jsxs("div",{className:"flex items-center gap-2",children:[D,$]}),e[44]=D,e[45]=$,e[46]=O):O=e[46];let K;e[47]!==P||e[48]!==O?(K=n.jsxs(yn,{className:"w-full sm:items-center sm:justify-between",children:[P,O]}),e[47]=P,e[48]=O,e[49]=K):K=e[49];let I;e[50]!==K||e[51]!==p?(I=n.jsxs(zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,K]}),e[50]=K,e[51]=p,e[52]=I):I=e[52];let X;return e[53]!==b||e[54]!==I||e[55]!==v?(X=n.jsx(Ks,{open:b,onOpenChange:v,children:I}),e[53]=b,e[54]=I,e[55]=v,e[56]=X):X=e[56],X}function Zh(t){const e=Ke.c(36),{t:s}=vt(),{value:r,setValue:o,onConfirm:i}=t,l=!!r;let a;e[0]!==o?(a=j=>{j||o(null)},e[0]=o,e[1]=a):a=e[1];let d;e[2]!==s?(d=s("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==d?(u=n.jsx(Us,{children:d}),e[4]=d,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 h;e[9]!==f?(h=n.jsx(qs,{children:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=n.jsxs(Ys,{children:[u,h]}),e[11]=u,e[12]=h,e[13]=m):m=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 v;e[18]!==g||e[19]!==b?(v=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]=v):v=e[20];let x;e[21]!==s?(x=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=x):x=e[22];let S;e[23]!==i||e[24]!==x?(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:x}),e[23]=i,e[24]=x,e[25]=S):S=e[25];let p;e[26]!==S||e[27]!==v?(p=n.jsxs(yn,{children:[v,S]}),e[26]=S,e[27]=v,e[28]=p):p=e[28];let y;e[29]!==p||e[30]!==m?(y=n.jsxs(zs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[m,p]}),e[29]=p,e[30]=m,e[31]=y):y=e[31];let w;return e[32]!==l||e[33]!==a||e[34]!==y?(w=n.jsx(Ks,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=w):w=e[35],w}const v3=new Set;function w3(t){const e=Ke.c(113),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:h,dragKey:m,renderExtras:g,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:S,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,toggleParent:F,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,allowReselect:T,onSessionSelected:$,resetSessionSearch:O,deleteSessionConfirm:K,setDeleteSessionConfirm:I,startFolderRename:X,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:R,renderChildren:H}=t,M=r===void 0?0:r,_=d===void 0?!1:d,B=f===void 0?"project":f,ee=H===void 0?!0:H;Ss("ui.sidebar_tree_item.render");const ne=h??`${B}:${_?"archived":"active"}:${s.session.id}`,re=Xt(P3),te=Xt(C3),W=ue(j3),q=ue(k3);let oe;if(e[0]!==s){oe=[];const Re=Ue=>Ue.children.forEach(We=>{oe.push(We.session.id),Re(We)});Re(s),e[0]=s,e[1]=oe}else oe=e[1];const de=oe.join(`
1047
+ `);let ce;e[2]!==de?(ce=de?de.split(`
1048
+ `):[],e[2]=de,e[3]=ce):ce=e[3];const je=ce;let be;e[4]!==re||e[5]!==X||e[6]!==te?(be=(Re,Ue)=>{if(!Re)return null;Ue&&Xt.getState().collapsedFolderIds.has(Ue)&&te(Ue);const We=re(Re,"New folder",Ue);return X(Re,We),We},e[4]=re,e[5]=X,e[6]=te,e[7]=be):be=e[7];const pe=be;let U;e[8]!==T||e[9]!==K||e[10]!==je||e[11]!==P||e[12]!==y||e[13]!==ne||e[14]!==C||e[15]!==s.session.id||e[16]!==$||e[17]!==O||e[18]!==I||e[19]!==A||e[20]!==j||e[21]!==k||e[22]!==W?(U={mobileVariant:C,allowReselect:T,onSessionSelected:$,resetSessionSearch:O,descendantIds:je,showDeletionDialog:W,setDeleteSessionConfirm:I,deleteSessionConfirm:K,editingId:y,setEditingId:j,setEditingRowKey:k,editingSessionId:s.session.id,editingOccurrenceKey:ne,editTitle:P,setEditTitle:A},e[8]=T,e[9]=K,e[10]=je,e[11]=P,e[12]=y,e[13]=ne,e[14]=C,e[15]=s.session.id,e[16]=$,e[17]=O,e[18]=I,e[19]=A,e[20]=j,e[21]=k,e[22]=W,e[23]=U):U=e[23];const Pe=y3(U),xe=g?.childRenderExtrasFor,Ee=s.session.directory??o;let L;e[24]!==_||e[25]!==i||e[26]!==B||e[27]!==Ee?(L={groupDirectory:Ee,projectId:i,archivedBucket:_,renderContext:B},e[24]=_,e[25]=i,e[26]=B,e[27]=Ee,e[28]=L):L=e[28];const ie=L,G=m??h??s.session.id,ae=g?.subtreeContainsEditing??v3,ye=g?.menuOpenSessionId??null,ge=g?.nodeStructureKey??"",Se=g?.blockingBadgeSessionScopes,ve=g?.relativeTimeTick;let Te;e[29]!==T||e[30]!==R||e[31]!==ie||e[32]!==xe||e[33]!==K||e[34]!==M||e[35]!==P||e[36]!==y||e[37]!==w||e[38]!==v||e[39]!==l||e[40]!==x||e[41]!==C||e[42]!==s.children||e[43]!==S||e[44]!==p||e[45]!==$||e[46]!==D||e[47]!==b||e[48]!==ee||e[49]!==O||e[50]!==a||e[51]!==I||e[52]!==A||e[53]!==j||e[54]!==k||e[55]!==E||e[56]!==X||e[57]!==N||e[58]!==F?(Te=ee?s.children.map(Re=>n.jsx(Ao,{node:Re,pinnedSessionIds:b,expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:S,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,toggleParent:F,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,allowReselect:T,onSessionSelected:$,resetSessionSearch:O,deleteSessionConfirm:K,setDeleteSessionConfirm:I,startFolderRename:X,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:R,depth:M+1,folderOwnerKey:l,selectionScopeKey:a,...ie,renderExtras:xe?.(Re)},Re.session.id)):null,e[29]=T,e[30]=R,e[31]=ie,e[32]=xe,e[33]=K,e[34]=M,e[35]=P,e[36]=y,e[37]=w,e[38]=v,e[39]=l,e[40]=x,e[41]=C,e[42]=s.children,e[43]=S,e[44]=p,e[45]=$,e[46]=D,e[47]=b,e[48]=ee,e[49]=O,e[50]=a,e[51]=I,e[52]=A,e[53]=j,e[54]=k,e[55]=E,e[56]=X,e[57]=N,e[58]=F,e[59]=Te):Te=e[59];let z;e[60]!==R||e[61]!==_||e[62]!==pe||e[63]!==M||e[64]!==P||e[65]!==y||e[66]!==w||e[67]!==ne||e[68]!==v||e[69]!==l||e[70]!==o||e[71]!==x||e[72]!==C||e[73]!==s||e[74]!==S||e[75]!==p||e[76]!==D||e[77]!==b||e[78]!==i||e[79]!==B||e[80]!==u||e[81]!==a||e[82]!==Pe.handleCancelEdit||e[83]!==Pe.handleCopySessionId||e[84]!==Pe.handleDeleteSession||e[85]!==Pe.handleRestoreSession||e[86]!==Pe.handleSaveEdit||e[87]!==Pe.handleSessionDoubleClick||e[88]!==Pe.handleSessionSelect||e[89]!==A||e[90]!==j||e[91]!==k||e[92]!==E||e[93]!==N||e[94]!==G||e[95]!==ae||e[96]!==ye||e[97]!==ge||e[98]!==Se||e[99]!==ve||e[100]!==Te||e[101]!==F?(z=n.jsx(g3,{expandedParents:v,hasSessionSearchQuery:x,normalizedSessionSearchQuery:S,notifyOnSubtasks:p,editingId:y,editingRowKey:w,setEditingId:j,setEditingRowKey:k,editTitle:P,setEditTitle:A,handleSaveEdit:Pe.handleSaveEdit,handleCancelEdit:Pe.handleCancelEdit,toggleParent:F,handleSessionSelect:Pe.handleSessionSelect,handleSessionDoubleClick:Pe.handleSessionDoubleClick,handleCopySessionId:Pe.handleCopySessionId,openSidebarMenuKey:D,setOpenSidebarMenuKey:E,createFolderAndStartRename:pe,handleDeleteSession:Pe.handleDeleteSession,handleRestoreSession:Pe.handleRestoreSession,startSessionWorktreeMenuLoad:N,mobileVariant:C,alwaysShowActions:R,pinnedSessionIds:b,node:s,depth:M,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:_,secondaryMeta:u,renderContext:B,rowKey:ne,dragKey:G,subtreeContainsEditing:ae,menuOpenSessionId:ye,nodeStructureKey:ge,blockingBadgeSessionScopes:Se,relativeTimeTick:ve,children:Te}),e[60]=R,e[61]=_,e[62]=pe,e[63]=M,e[64]=P,e[65]=y,e[66]=w,e[67]=ne,e[68]=v,e[69]=l,e[70]=o,e[71]=x,e[72]=C,e[73]=s,e[74]=S,e[75]=p,e[76]=D,e[77]=b,e[78]=i,e[79]=B,e[80]=u,e[81]=a,e[82]=Pe.handleCancelEdit,e[83]=Pe.handleCopySessionId,e[84]=Pe.handleDeleteSession,e[85]=Pe.handleRestoreSession,e[86]=Pe.handleSaveEdit,e[87]=Pe.handleSessionDoubleClick,e[88]=Pe.handleSessionSelect,e[89]=A,e[90]=j,e[91]=k,e[92]=E,e[93]=N,e[94]=G,e[95]=ae,e[96]=ye,e[97]=ge,e[98]=Se,e[99]=ve,e[100]=Te,e[101]=F,e[102]=z):z=e[102];let he;e[103]!==K||e[104]!==s.session.id||e[105]!==Pe.confirmDeleteSession||e[106]!==I||e[107]!==q||e[108]!==W?(he=K?.session.id===s.session.id?n.jsx(x3,{value:K,setValue:I,showDeletionDialog:W,setShowDeletionDialog:q,onConfirm:Pe.confirmDeleteSession}):null,e[103]=K,e[104]=s.session.id,e[105]=Pe.confirmDeleteSession,e[106]=I,e[107]=q,e[108]=W,e[109]=he):he=e[109];let se;return e[110]!==z||e[111]!==he?(se=n.jsxs(n.Fragment,{children:[z,he]}),e[110]=z,e[111]=he,e[112]=se):se=e[112],se}function k3(t){return t.setShowDeletionDialog}function j3(t){return t.showDeletionDialog}function C3(t){return t.toggleFolderCollapse}function P3(t){return t.createFolder}const E3=(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&&bf(t.session,e.session)&&ot(t.worktree?.path??null)===ot(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,N3=(t,e)=>{if(t.node!==e.node&&!E3(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},Ao=c.memo(w3,N3),R3=10,D3=4;function kd(t){const e=Ke.c(7),{providerIDs:s,ringClass:r}=t;let o;if(e[0]!==s||e[1]!==r){let l;e[3]!==r?(l=a=>n.jsx("span",{className:ke("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(lf,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=l):l=e[4],o=s.slice(0,D3).map(l),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 I3(t){const e=Ke.c(95),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:l,projectId:a,projectLabel:d,expansionKey:u,expanded:f,forceExpanded:h,notifyOnSubtasks:m,toggleParent:g}=t,{t:b}=vt();let v;e[0]!==s.key?(v=je=>je.runOverviewKey===s.key,e[0]=s.key,e[1]=v):v=e[1];const x=ue(v),S=Un(l);let p;e[2]!==a||e[3]!==l?(p=je=>l==="timeline-mixed"&&a?je.projects.find(be=>be.id===a)??null:null,e[2]=a,e[3]=l,e[4]=p):p=e[4];const y=Zt(p),w=s.lanes.length;let j;e[5]!==w||e[6]!==b?(j=w===1?b("sessions.sidebar.run.laneCountSingle",{count:w}):b("sessions.sidebar.run.laneCountPlural",{count:w}),e[5]=w,e[6]=b,e[7]=j):j=e[7];const k=j;let P;e[8]!==o?(P=[...o],e[8]=o,e[9]=P):P=e[9];const A=P;let F;e[10]!==A||e[11]!==i||e[12]!==m?(F=n.jsx(hu,{nodes:A,blockingSessionIds:i,includeUnreadSubtasks:m}),e[10]=A,e[11]=i,e[12]=m,e[13]=F):F=e[13];const D=F,E=x?"text-interactive-selection-foreground":"text-foreground/80";let T;e[14]!==s.key?(T=()=>ue.getState().setRunOverviewKey(s.key),e[14]=s.key,e[15]=T):T=e[15];const $=T;if(S){const je=s.key,be=x?"page":void 0;let pe;e[16]!==s.title||e[17]!==b?(pe=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[16]=s.title,e[17]=b,e[18]=pe):pe=e[18];let U;e[19]===Symbol.for("react.memo_cache_sentinel")?(U={paddingInlineStart:R3},e[19]=U):U=e[19];const Pe=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let xe;e[20]!==Pe?(xe=ke("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pe-2.5 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Pe),e[20]=Pe,e[21]=xe):xe=e[21];const Ee=s.title;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Ki,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[22]=L):L=e[22];let ie;e[23]!==k?(ie=n.jsxs(n.Fragment,{children:[L,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:k})]}),e[23]=k,e[24]=ie):ie=e[24];let G;e[25]!==s.lastActivity?(G=gf(s.lastActivity),e[25]=s.lastActivity,e[26]=G):G=e[26];let ae;e[27]!==s.providerIDs?(ae=n.jsx(kd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[27]=s.providerIDs,e[28]=ae):ae=e[28];let ye;e[29]!==D||e[30]!==d||e[31]!==s.title||e[32]!==ie||e[33]!==G||e[34]!==ae||e[35]!==y||e[36]!==E?(ye=n.jsx(ua,{project:y,projectLabel:d,title:Ee,titleClassName:E,branchLabel:null,metaLineLead:ie,statusDot:D,pinnedMarker:null,timeSlot:G,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:ae,hideMetaOnHoverClass:""}),e[29]=D,e[30]=d,e[31]=s.title,e[32]=ie,e[33]=G,e[34]=ae,e[35]=y,e[36]=E,e[37]=ye):ye=e[37];let ge;return e[38]!==$||e[39]!==s.key||e[40]!==xe||e[41]!==ye||e[42]!==be||e[43]!==pe?(ge=n.jsx("button",{type:"button","data-run-row":je,"aria-current":be,"aria-label":pe,onClick:$,style:U,className:xe,children:ye}),e[38]=$,e[39]=s.key,e[40]=xe,e[41]=ye,e[42]=be,e[43]=pe,e[44]=ge):ge=e[44],ge}let O;e[45]!==u||e[46]!==h||e[47]!==g?(O=je=>{je.stopPropagation(),h||g(u)},e[45]=u,e[46]=h,e[47]=g,e[48]=O):O=e[48];const K=O,I=s.key,X=x?"page":void 0;let N;e[49]!==r?(N=tr(r),e[49]=r,e[50]=N):N=e[50];let C;e[51]!==N?(C={paddingInlineStart:N},e[51]=N,e[52]=C):C=e[52];const R=x?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let H;e[53]!==R?(H=ke("group relative my-0.5 flex cursor-pointer items-center gap-1.5 rounded-md py-[3px] pe-2.5",R),e[53]=R,e[54]=H):H=e[54];let M;e[55]!==K?(M=je=>{(je.key==="Enter"||je.key===" ")&&(je.preventDefault(),K(je))},e[55]=K,e[56]=M):M=e[56];let _;e[57]!==f||e[58]!==b?(_=b(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[57]=f,e[58]=b,e[59]=_):_=e[59];let B;e[60]!==f?(B=n.jsx(Cr,{expanded:f}),e[60]=f,e[61]=B):B=e[61];let ee;e[62]!==f||e[63]!==M||e[64]!==_||e[65]!==B||e[66]!==K?(ee=n.jsx("button",{type:"button",onClick:K,onKeyDown:M,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":_,children:B}),e[62]=f,e[63]=M,e[64]=_,e[65]=B,e[66]=K,e[67]=ee):ee=e[67];let ne;e[68]!==$?(ne=je=>{je.stopPropagation(),$()},e[68]=$,e[69]=ne):ne=e[69];let re;e[70]!==s.title||e[71]!==b?(re=b("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[70]=s.title,e[71]=b,e[72]=re):re=e[72];let te;e[73]===Symbol.for("react.memo_cache_sentinel")?(te=n.jsx(Ki,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[73]=te):te=e[73];let W;e[74]!==E?(W=ke("oc-ui-start-align block min-w-0 flex-1 truncate typography-ui-label font-normal",E),e[74]=E,e[75]=W):W=e[75];let q;e[76]!==s.title||e[77]!==W?(q=n.jsx("span",{dir:"auto",className:W,children:s.title}),e[76]=s.title,e[77]=W,e[78]=q):q=e[78];let oe;e[79]!==s.providerIDs?(oe=n.jsx(kd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[79]=s.providerIDs,e[80]=oe):oe=e[80];let de;e[81]!==D||e[82]!==ne||e[83]!==re||e[84]!==q||e[85]!==oe?(de=n.jsxs("button",{type:"button",onClick:ne,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":re,children:[te,q,oe,D]}),e[81]=D,e[82]=ne,e[83]=re,e[84]=q,e[85]=oe,e[86]=de):de=e[86];let ce;return e[87]!==$||e[88]!==s.key||e[89]!==C||e[90]!==H||e[91]!==ee||e[92]!==de||e[93]!==X?(ce=n.jsxs("div",{"data-run-row":I,"aria-current":X,onClick:$,style:C,className:H,children:[ee,de]}),e[87]=$,e[88]=s.key,e[89]=C,e[90]=H,e[91]=ee,e[92]=de,e[93]=X,e[94]=ce):ce=e[94],ce}const T3=c.memo(I3),M3=24,A3=t=>Array.from({length:Math.min(t,M3)},(e,s)=>s),O3=(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)},B3=(t,e)=>t.find(s=>s.end>e)?.index??0,F3={"pb-2":8,"pb-1.5":6},jd=t=>`${t.kind}:${"renderContext"in t?t.renderContext:""}`,_3=(t,e)=>`${t.key}|${zn(t,e)??""}`,L3=(t,e,s={})=>{const r=zn(t,e),o=r?s.gapBySpacing?.get(r)??F3[r]:0;return(s.height??t.estimateSize)+o},zn=(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,$3=()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;function z3({model:t,scrollElement:e,pinnedRowIndexes:s,renderRow:r,onFirstVisibleIndexChange:o}){const i=t.rows,l=c.useCallback(()=>e,[e]),a=c.useRef(new Map),d=c.useRef(new Map),u=c.useCallback(D=>{const E=i[D];if(!E)return 32;const T=i[D+1];return L3(E,T,{height:a.current.get(jd(E)),gapBySpacing:d.current})},[i]),f=c.useCallback((D,E,T)=>{const $=M1(D,E,T),O=T.indexFromElement(D),K=i[O];if(K){const I=zn(K,i[O+1]),X=I&&Number.parseFloat(getComputedStyle(D).paddingBottom)||0;I&&d.current.set(I,X),a.current.set(jd(K),$-X)}return $},[i]),h=c.useCallback(D=>{const E=i[D];return E?_3(E,i[D+1]):D},[i]),m=c.useRef(0),[g,b]=c.useState(null),v=g?.slidingIndexes,x=c.useCallback(D=>{const E=A1(D),T=v?.length?new Set([...s,...v]):s;return O3(E,T,i.length)},[s,i.length,v]),S=T1({count:i.length,enabled:e!==null,getScrollElement:l,estimateSize:u,measureElement:f,getItemKey:h,overscan:8,rangeExtractor:x}),p=S.getVirtualItems(),y=e?S.getTotalSize():0,w=e?Math.max(y-e.clientHeight,0):0,j=e?Math.min(e.scrollTop,w):0,k=B3(p,j);c.useLayoutEffect(()=>{o(k)},[k,o]);const P=c.useRef(null),A=c.useRef(null);if(c.useLayoutEffect(()=>{const D=A.current;if(!D||D.rows===i||!e||$3())return;const E=Rg(D.rows,i);if(!E)return;const T=D.measurements,$=S.measurementsCache,O=T[E.previousHeaderIndex],K=$[E.nextHeaderIndex];if(!O||!K)return;const I=K.start-O.start,X=E.opened?T[E.previousHeaderIndex+1]:T[E.blockEnd],N=E.opened?E.blockEnd:E.nextHeaderIndex+1,C=$[N],R=(X?.start??O.end)+I,H=C?.start??K.end,M=e.scrollTop-e.clientHeight,_=e.scrollTop+e.clientHeight*2,B=new Set,ee=[],ne=[];if(E.opened){for(let re=E.blockStart;re<E.blockEnd;re+=1)B.add(i[re].key);for(let re=N;re<$.length&&$[re].start+R-H<_;re+=1)ne.push(re)}else for(let re=E.blockStart;re<E.blockEnd;re+=1){const te=T[re];!te||te.end+I<M||te.start+I>_||ee.push({row:D.rows[re],nextRow:D.rows[re+1],start:te.start+I,end:te.end+I})}m.current+=1,b({id:m.current,revealKeys:B,ghosts:ee,followingIndex:N,from:R,to:H,slidingIndexes:ne})},[i,e,S]),c.useLayoutEffect(()=>{A.current={rows:i,measurements:S.measurementsCache}}),c.useLayoutEffect(()=>{const D=P.current;if(!g||!D)return;const E={duration:Ig,easing:Dg},T=g.from-g.to,$=[];for(const K of D.children){if(!(K instanceof HTMLElement))continue;const I=K.dataset.sidebarRowKey??"",X=Number(K.dataset.sidebarVirtualStart);K.dataset.sidebarGhost==="true"?$.push(K.animate(Kl(X,K.offsetHeight,g.from,g.to),{...E,fill:"forwards"})):g.revealKeys.has(I)?$.push(K.animate(Kl(X,K.offsetHeight,g.from,g.to),E)):Number(K.dataset.index)>=g.followingIndex&&T!==0&&$.push(K.animate([{transform:`translateY(${X+T}px)`},{transform:`translateY(${X}px)`}],E))}let O=!1;return Promise.all($.map(K=>K.finished)).then(()=>{O||b(K=>K?.id===g.id?null:K)},()=>{}),()=>{O=!0;for(const K of $)K.cancel()}},[g]),!e){const D=A3(i.length),E=D.reduce(($,O)=>$+(i[O]?.estimateSize??0),0),T=i.reduce(($,O)=>$+O.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[D.map($=>{const O=i[$];return O?n.jsx("div",{className:zn(O,i[$+1]),children:r(O,$)},O.key):null}),T>E?n.jsx("div",{"aria-hidden":"true",style:{height:T-E}}):null]})}const F=g?.ghosts.reduce((D,E)=>Math.max(D,E.end),0)??0;return n.jsxs("div",{ref:P,"data-sidebar-virtual-ready":"true",style:{height:Math.max(y,F),position:"relative"},children:[g?.ghosts.map(D=>n.jsx("div",{"aria-hidden":"true",inert:!0,className:`[&_[data-session-row]]:my-px ${zn(D.row,D.nextRow)??""}`,"data-sidebar-ghost":"true","data-sidebar-row-key":D.row.key,"data-sidebar-virtual-start":D.start,style:{position:"absolute",top:0,left:0,width:"100%",pointerEvents:"none",transform:`translateY(${D.start}px)`},children:r(D.row,-1)},D.row.key)),p.map(D=>{const E=i[D.index];return E?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${zn(E,i[D.index+1])??""}`,"data-index":D.index,"data-sidebar-row-key":E.key,"data-sidebar-virtual-start":D.start,ref:S.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${D.start}px)`},children:r(E,D.index)},E.key):null})]})}const K3={work:"eye",chats:"chat-4"},W3={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle"},H3=t=>{const e=Ke.c(33),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:l,onNewChat:a}=t,{t:d}=vt(),u=s==="chats",f=o?void 0:l,h=u?"pe-10":"pe-3.5";let m;e[0]!==h?(m=ke("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",h),e[0]=h,e[1]=m):m=e[1];const g=!r,b=K3[s],v=!o&&"group-hover:hidden";let x;e[2]!==v?(x=ke("h-3.5 w-3.5 text-muted-foreground/80",v),e[2]=v,e[3]=x):x=e[3];let S;e[4]!==b||e[5]!==x?(S=n.jsx(Z,{name:b,className:x}),e[4]=b,e[5]=x,e[6]=S):S=e[6];let p;e[7]!==r||e[8]!==o?(p=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]=p):p=e[9];let y;e[10]!==S||e[11]!==p?(y=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[S,p]}),e[10]=S,e[11]=p,e[12]=y):y=e[12];const w=W3[s];let j;e[13]!==d||e[14]!==w?(j=d(w),e[13]=d,e[14]=w,e[15]=j):j=e[15];let k;e[16]!==j?(k=n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:j}),e[16]=j,e[17]=k):k=e[17];let P;e[18]!==o||e[19]!==f||e[20]!==y||e[21]!==k||e[22]!==m||e[23]!==g?(P=n.jsxs("button",{type:"button",onClick:f,disabled:o,className:m,"aria-expanded":g,children:[y,k]}),e[18]=o,e[19]=f,e[20]=y,e[21]=k,e[22]=m,e[23]=g,e[24]=P):P=e[24];let A;e[25]!==i||e[26]!==u||e[27]!==a||e[28]!==d?(A=u?n.jsx("button",{type:"button",onClick:D=>{D.stopPropagation(),a()},className:ke("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-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":d("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]=a,e[28]=d,e[29]=A):A=e[29];let F;return e[30]!==P||e[31]!==A?(F=n.jsxs("div",{className:"relative group/chats -ms-2.5 -me-2",children:[P,A]}),e[30]=P,e[31]=A,e[32]=F):F=e[32],F},Jh=c.createContext(null);function Cd(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 V3(t){const e=Ke.c(11),{suspended:s,layoutKey:r,scrollRef:o,children:i}=t,l=s===void 0?!1:s,a=r===void 0?"":r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[0]=d):d=e[0];const u=c.useRef(d),f=c.useRef(null);let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=x=>(u.current.add(x),f.current?.(),()=>{u.current.delete(x),f.current?.()}),e[1]=h):h=e[1];const m=h;let g;e[2]!==o||e[3]!==l?(g=()=>{const x=o.current;if(l||!x)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",x.prepend(S);let p=null,y=null,w=null,j=0;const k=new Set;let P=[];const A=window.matchMedia("(prefers-reduced-motion: reduce)"),F=(I,X)=>{const N=document.activeElement,C=N instanceof HTMLElement&&I.host.contains(N),R=C?x.scrollTop:null;X.moveBefore&&X.isConnected&&I.host.isConnected?X.moveBefore(I.host,null):X.append(I.host),C&&N.focus({preventScroll:!0}),R!==null&&x.scrollTop!==R&&(x.scrollTop=R)},D=()=>{w?.cancel(),w=null,y?.remove(),y=null},E=()=>{let I=null,X=-1/0;for(const{entry:N,top:C}of P)C<=x.scrollTop&&C>=X&&(X=C,I=N);if(p!==I){if(D(),p&&I&&!A.matches){const N=p.host.cloneNode(!0);N instanceof HTMLElement&&(N.inert=!0,N.setAttribute("aria-hidden","true"),N.querySelectorAll("[id]").forEach(G3),N.className="pointer-events-none absolute inset-x-0 top-0 z-30",y=N)}p&&(F(p,p.slot),p.slot.style.removeProperty("height")),p=I,S.hidden=!I,I&&(I.slot.style.height=`${I.host.getBoundingClientRect().height}px`,F(I,S),y&&(S.append(y),w=y.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),w.onfinish=D))}},T=()=>{p&&(p.slot.style.height=`${p.host.getBoundingClientRect().height}px`);const I=Cd(x)+x.clientTop;P=Array.from(u.current,X=>({entry:X,top:Cd(X.slot)-I})),E()},$=new ResizeObserver(T),O=new MutationObserver(()=>{cancelAnimationFrame(j),j=requestAnimationFrame(T)});$.observe(x);const K=()=>{O.disconnect();for(const I of k)u.current.has(I)||($.unobserve(I.host),I.slot.parentElement&&$.unobserve(I.slot.parentElement),k.delete(I));for(const I of u.current){const X=I.slot.closest("[data-sidebar-virtual-start]");X&&O.observe(X,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),k.has(I)||($.observe(I.host),I.slot.parentElement&&$.observe(I.slot.parentElement),k.add(I))}cancelAnimationFrame(j),j=requestAnimationFrame(T)};return f.current=K,x.addEventListener("scroll",E,{passive:!0}),K(),T(),()=>{f.current=null,cancelAnimationFrame(j),x.removeEventListener("scroll",E),$.disconnect(),O.disconnect(),D(),S.hidden=!0,p&&(F(p,p.slot),p.slot.style.removeProperty("height")),S.remove()}},e[2]=o,e[3]=l,e[4]=g):g=e[4];let b;e[5]!==a||e[6]!==o||e[7]!==l?(b=[l,a,o],e[5]=a,e[6]=o,e[7]=l,e[8]=b):b=e[8],c.useLayoutEffect(g,b);let v;return e[9]!==i?(v=n.jsx(Jh.Provider,{value:m,children:i}),e[9]=i,e[10]=v):v=e[10],v}function G3(t){return t.removeAttribute("id")}function U3(t){const e=Ke.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=c.useRef(null),[i]=c.useState(q3);let l,a;e[3]!==i||e[4]!==r?(l=()=>{const m=o.current;if(!m)return;m.append(i);const g=r({slot:m,host:i});return()=>{g(),i.remove()}},a=[i,r],e[3]=i,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{ref:o}),e[7]=d):d=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=ya.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let h;return e[13]!==f?(h=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=h):h=e[14],h}function q3(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function ep(t){const e=Ke.c(3),s=c.useContext(Jh);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(U3,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const Y3=t=>{const e=Ke.c(3),[s,r]=c.useState(!1);let o,i;return e[0]!==t?(o=()=>{if(!t){r(!1);return}let l=!0;const a=()=>{yo.getDirectoryAvailability(t).then(d=>{l&&d!=="unknown"&&r(d==="missing")})};return a(),window.addEventListener("focus",a),()=>{l=!1,window.removeEventListener("focus",a)}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),c.useEffect(o,i),s},Ei=t=>{const e=Ke.c(27),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u,labelClassName:f}=t,h=u===void 0?!1:u,{currentTheme:m}=Pr(),g=o?Pa[o]:null;let b;e[0]!==i?(b=Ea(i),e[0]=i,e[1]=b):b=e[1];const v=b,x=d!==void 0,S=x?h?"hidden":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0":void 0;let p;e[2]!==h||e[3]!==x||e[4]!==d?(p=x?n.jsx("span",{className:ke("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/project:opacity-100 group-focus-within/project:opacity-100"),children:n.jsx(Z,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[2]=h,e[3]=x,e[4]=d,e[5]=p):p=e[5];let y;e[6]!==h||e[7]!==m||e[8]!==x||e[9]!==v||e[10]!==S||e[11]!==s||e[12]!==a||e[13]!==l||e[14]!==g?(y=l?n.jsx("span",{className:ke("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",x&&h?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:n.jsx(Na,{project:{id:s,iconImage:l},options:{themeVariant:m.metadata.variant,iconColor:m.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:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:v?{color:v}:void 0})})}):g?n.jsx(Z,{name:g,className:ke("h-3.5 w-3.5",S),style:v?{color:v}:void 0}):n.jsx(Z,{name:"folder",className:ke("h-3.5 w-3.5 text-muted-foreground/80",S),style:v?{color:v}:void 0}),e[6]=h,e[7]=m,e[8]=x,e[9]=v,e[10]=S,e[11]=s,e[12]=a,e[13]=l,e[14]=g,e[15]=y):y=e[15];let w;e[16]!==p||e[17]!==y?(w=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[p,y]}),e[16]=p,e[17]=y,e[18]=w):w=e[18];let j;e[19]!==f?(j=ke("truncate typography-ui-header font-semibold text-foreground",f),e[19]=f,e[20]=j):j=e[20];let k;e[21]!==r||e[22]!==j?(k=n.jsx("span",{className:j,children:r}),e[21]=r,e[22]=j,e[23]=k):k=e[23];let P;return e[24]!==w||e[25]!==k?(P=n.jsxs(n.Fragment,{children:[w,k]}),e[24]=w,e[25]=k,e[26]=P):P=e[26],P},X3=t=>{const e=Ke.c(67),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:h,isRepo:m,hideDirectoryControls:g,alwaysShowActions:b,onToggle:v,onNewSession:x,onNewWorktreeSession:S,onManageWorktrees:p,onManageSpaces:y,onOpenFolder:w,onRenameStart:j,onArchiveAll:k,onClose:P,children:A,showCreateButtons:F,hideHeader:D,statusIndicator:E,openSidebarMenuKey:T,setOpenSidebarMenuKey:$,projectPickerOptions:O,onProjectSelect:K}=t,I=r===void 0?!1:r,X=F===void 0?!0:F,N=D===void 0?!1:D,C=E===void 0?null:E,{t:R}=vt(),H=Y3(l);let M;e[0]!==I||e[1]!==s?(M={id:s,disabled:I},e[0]=I,e[1]=s,e[2]=M):M=e[2];const{attributes:_,listeners:B,setNodeRef:ee,transform:ne,transition:re,isDragging:te}=Ar(M),W=c.useRef(!1),q=`project:${s}`,oe=T===q,[de,ce]=c.useState(!1),je=!!(O&&K);let be;e[3]!==q||e[4]!==$?(be=Be=>{Be&&ce(!1),$(Be?q:null)},e[3]=q,e[4]=$,e[5]=be):be=e[5];const pe=be;let U;e[6]!==g||e[7]!==m||e[8]!==k||e[9]!==P||e[10]!==y||e[11]!==p||e[12]!==x||e[13]!==w||e[14]!==j||e[15]!==X||e[16]!==R?(U=Be=>n.jsxs(n.Fragment,{children:[X&&!m&&!g&&x&&n.jsxs(Be,{onClick:x,children:[n.jsx(Z,{name:"add",className:"me-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.newSession")]}),m&&!g&&p&&n.jsxs(Be,{onClick:p,children:[n.jsx(Z,{name:"node-tree",className:"me-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.manageWorktrees")]}),m&&!g&&y&&n.jsxs(Be,{onClick:y,children:[n.jsx(Z,{name:"box-3",className:"me-1.5 h-4 w-4"}),R("spaces.page.menuItem")]}),w&&n.jsxs(Be,{onClick:w,children:[n.jsx(Z,{name:"folder-received",className:"me-1.5 h-4 w-4"}),R(Yu())]}),n.jsxs(Be,{onClick:j,children:[n.jsx(Z,{name:"pencil-ai",className:"me-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.edit")]}),k&&n.jsxs(Be,{onClick:k,children:[n.jsx(Z,{name:"archive",className:"me-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Be,{onClick:P,className:"text-destructive focus:text-destructive",children:[n.jsx(Z,{name:"close",className:"me-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=g,e[7]=m,e[8]=k,e[9]=P,e[10]=y,e[11]=p,e[12]=x,e[13]=w,e[14]=j,e[15]=X,e[16]=R,e[17]=U):U=e[17];const Pe=U,xe=J3,Ee=e4,L=t4;let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=Be=>{(Be.button===2||Be.button===0&&Be.ctrlKey)&&(W.current=!0)},e[18]=ie):ie=e[18];const G=ie;let ae;e[19]!==v?(ae=Be=>{if(Be.currentTarget.blur(),W.current){W.current=!1;return}v()},e[19]=v,e[20]=ae):ae=e[20];const ye=ae,Se=(X&&m&&!g&&!!S?1:0)+(g?0:1),ve=Se===2?"[--oc-actions-reserve:66px]":Se===1&&X?"[--oc-actions-reserve:38px]":X||Se===1?"[--oc-actions-reserve:12px]":void 0,Te=b?void 0:oe?"oc-actions-mask":"group-hover/project:oc-actions-mask group-focus-within/project:oc-actions-mask",z=b?void 0:oe?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0";let he;e[21]!==ne?(he=Or.Transform.toString(ne),e[21]=ne,e[22]=he):he=e[22];let se;e[23]!==he||e[24]!==re?(se={transform:he,transition:re},e[23]=he,e[24]=re,e[25]=se):se=e[25];const Re=te&&"opacity-30";let Ue;e[26]!==Re?(Ue=ke("relative",Re),e[26]=Re,e[27]=Ue):Ue=e[27];let We;e[28]!==b||e[29]!==_||e[30]!==H||e[31]!==pe||e[32]!==ye||e[33]!==ve||e[34]!==z||e[35]!==Te||e[36]!==g||e[37]!==N||e[38]!==s||e[39]!==h||e[40]!==de||e[41]!==oe||e[42]!==je||e[43]!==m||e[44]!==B||e[45]!==x||e[46]!==S||e[47]!==K||e[48]!==d||e[49]!==i||e[50]!==l||e[51]!==a||e[52]!==f||e[53]!==u||e[54]!==o||e[55]!==O||e[56]!==Pe||e[57]!==X||e[58]!==C||e[59]!==R?(We=N?null:n.jsx(n.Fragment,{children:n.jsxs(za,{open:de,onOpenChange:ce,children:[n.jsx($a,{render:n.jsx(ep,{className:ke("-ms-2.5 -me-2 text-start group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Be=>{g||(Be.preventDefault(),ce(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 ps-4 pe-3.5",..._,children:[je?n.jsxs(js,{children:[n.jsx(Cs,{asChild:!0,children:n.jsxs("button",{type:"button",className:ke("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",m&&!g?b||oe?"pe-20":"pe-0 group-hover/project:pe-20 group-focus-within/project:pe-20":b||oe?"pe-14":"pe-0 group-hover/project:pe-14 group-focus-within/project:pe-14"),"aria-label":R("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(Ei,{id:s,projectLabel:o,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx(Z,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?n.jsx(Io,{directory:l,className:"ms-auto"}):null]})}),n.jsx(Ps,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:O?.map(Be=>n.jsxs(qt,{onClick:()=>K?.(Be.id),className:"flex items-center justify-between gap-3",title:Be.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Ei,{...Be})}),Be.id===s?n.jsx(Z,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Be.id))})]}):n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:G,onClick:ye,...B,className:ke("@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?m&&!g?"pe-20":"pe-14":ve),children:[n.jsx(Ei,{id:s,projectLabel:o,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:h,alwaysShowActions:b,labelClassName:ke("[--oc-actions-inset:20px]",Te)}),H?n.jsx("span",{className:ke("inline-flex flex-shrink-0 items-center text-status-warning",z),title:R("sessions.sidebar.project.folderMissing"),"aria-label":R("sessions.sidebar.project.folderMissing"),children:n.jsx(Z,{name:"alert",className:"h-3 w-3"})}):null,C?n.jsx("span",{className:ke("ms-1 inline-flex flex-shrink-0 items-center",z),children:C}):null,l?n.jsx(Io,{directory:l,className:ke("ms-auto",z)}):null]})}),n.jsx(Tt,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:ke("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",X?"inset-e-7":"inset-e-0.5"),children:[X&&m&&!g&&S?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),S()},className:ke("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-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":R("sessions.sidebar.project.actions.newWorktree"),children:n.jsx(Z,{name:"node-tree",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:R("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,g?null:n.jsxs(js,{open:oe,onOpenChange:pe,children:[n.jsx(Cs,{asChild:!0,children:n.jsx("button",{type:"button",className:ke("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",oe?"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-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":R("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Ee,onMouseDown:L,onClick:xe,children:n.jsx(Z,{name:"more-2",className:"h-3 w-3"})})}),n.jsx(Ps,{align:"end",className:"min-w-[180px]",children:Pe(qt)})]})]}),X&&x?n.jsx("div",{className:"absolute inset-e-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Be=>{Be.stopPropagation(),x()},className:ke("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-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":R(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:R(m?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(La,{className:"min-w-[180px]",children:Pe(In)})]})}),e[28]=b,e[29]=_,e[30]=H,e[31]=pe,e[32]=ye,e[33]=ve,e[34]=z,e[35]=Te,e[36]=g,e[37]=N,e[38]=s,e[39]=h,e[40]=de,e[41]=oe,e[42]=je,e[43]=m,e[44]=B,e[45]=x,e[46]=S,e[47]=K,e[48]=d,e[49]=i,e[50]=l,e[51]=a,e[52]=f,e[53]=u,e[54]=o,e[55]=O,e[56]=Pe,e[57]=X,e[58]=C,e[59]=R,e[60]=We):We=e[60];let He;return e[61]!==A||e[62]!==ee||e[63]!==se||e[64]!==Ue||e[65]!==We?(He=n.jsxs("div",{ref:ee,style:se,className:Ue,children:[We,A]}),e[61]=A,e[62]=ee,e[63]=se,e[64]=Ue,e[65]=We,e[66]=He):He=e[66],He},Q3=t=>{const e=Ke.c(21),{id:s,disabled:r,children:o}=t,i=r===void 0?!1:r;let l;e[0]!==i||e[1]!==s?(l={id:s,disabled:i},e[0]=i,e[1]=s,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:h,isDragging:m}=Ar(l);let g;e[3]!==a||e[4]!==u?(g={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=g):g=e[5];const b=g;let v;e[6]!==f?(v=Or.Transform.toString(f),e[6]=f,e[7]=v):v=e[7];let x;e[8]!==v||e[9]!==h?(x={transform:v,transition:h},e[8]=v,e[9]=h,e[10]=x):x=e[10];const S=m&&"opacity-50";let p;e[11]!==S?(p=ke("space-y-0.5 rounded-md",S),e[11]=S,e[12]=p):p=e[12];let y;e[13]!==o||e[14]!==b?(y=o(b),e[13]=o,e[14]=b,e[15]=y):y=e[15];let w;return e[16]!==d||e[17]!==x||e[18]!==p||e[19]!==y?(w=n.jsx("div",{ref:d,style:x,className:p,children:y}),e[16]=d,e[17]=x,e[18]=p,e[19]=y,e[20]=w):w=e[20],w},Z3=c.memo(Q3);function J3(t){t.stopPropagation()}function e4(t){t.stopPropagation()}function t4(t){t.stopPropagation()}const Pd=[],s4=t=>{const e=Ke.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 l=uu(i);let a;return e[3]!==o||e[4]!==l?(a=o(l),e[3]=o,e[4]=l,e[5]=a):a=e[5],a},Ni=(t,e)=>e?t.sessions.some(s=>Jn(s,e)):!1,n4=(t,e,s)=>t.sessions.some(r=>Th(r,r,e,s,t.directory,t.directory)),r4=(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)},o4=(t,e,s)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const l=`project:${r}:${i.session.id}`;return e.has(l)!==s.has(l)?!0:i.children.some(o)};return t.sessions.some(o)},i4=(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&&n4(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&r4(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&o4(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Ni(e.group,t.editingId)||Ni(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Ni(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=Do(e.group.sessions,t.openSidebarMenuKey,"project",s),o=Do(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??ot(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},a4=c.memo(function(e){const s=Ke.c(23),{label:r,sessions:o,worktree:i}=e,{t:l}=vt(),a=qh();let d;s[0]!==o||s[1]!==a||s[2]!==i?(d=S=>{S.stopPropagation(),xn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:a||S.shiftKey})},s[0]=o,s[1]=a,s[2]=i,s[3]=d):d=s[3];const u=a?"text-destructive":"text-muted-foreground";let f;s[4]!==u?(f=ke("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 h;s[6]!==r||s[7]!==a||s[8]!==l?(h=a?l("sessions.sidebar.group.actions.deleteGroupAndBranchAria",{label:r}):l("sessions.sidebar.group.actions.deleteGroupAria",{label:r}),s[6]=r,s[7]=a,s[8]=l,s[9]=h):h=s[9];let m;s[10]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"}),s[10]=m):m=s[10];let g;s[11]!==d||s[12]!==f||s[13]!==h?(g=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":h,children:m})}),s[11]=d,s[12]=f,s[13]=h,s[14]=g):g=s[14];let b;s[15]!==a||s[16]!==l?(b=l(a?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=a,s[16]=l,s[17]=b):b=s[17];let v;s[18]!==b?(v=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b})}),s[18]=b,s[19]=v):v=s[19];let x;return s[20]!==g||s[21]!==v?(x=n.jsxs(Ot,{children:[g,v]}),s[20]=g,s[21]=v,s[22]=x):x=s[22],x}),Ed=[];function l4(t){const{t:e}=vt(),s=Ha(),r=km(t.group.space?.id),{group:o,groupKey:i,projectId:l,hideGroupLabel:a,renderBody:d=!0,isEmpty:u=!1,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,groupSearchDataByGroup:m,visibleSessionCount:g,sessionBatchSize:b,collapsedGroups:v,hideDirectoryControls:x,showMoreGroupSessions:S,resetGroupSessionLimit:p,mobileVariant:y,alwaysShowActions:w,activeProjectId:j,setActiveProjectIdOnly:k,setSessionSwitcherOpen:P,openNewSessionDraft:A,pinnedSessionIds:F,sessionOrderIndex:D,notifyOnSubtasks:E,onToggleCollapsedGroup:T,dragHandleProps:$,compactBodyPadding:O=!1,expandedParents:K,editingId:I,editingRowKey:X,openSidebarMenuKey:N,editTitle:C,folderRename:R,setFolderRenameDraft:H,clearFolderRename:M}=t,_=Xt(Ce=>Ce.toggleFolderCollapse),B=Xt(Ce=>Ce.renameFolder),ee=Xt(Ce=>Ce.deleteFolder),ne=Xt(Ce=>Ce.addSessionToFolder),re=ue(Ce=>Ce.showDeletionDialog),[te,W]=c.useState(null),q=c.useCallback((Ce,V)=>{const De=D.get(Ce.session.id),_e=D.get(V.session.id);if(De!==void 0||_e!==void 0){if(De===void 0)return 1;if(_e===void 0)return-1;if(De!==_e)return De-_e}return Ka(Ce.session,V.session,F,Zu)},[F,D]),oe=f?m.get(o):null,de=f?!1:v.has(i),ce=dx(!o.isMain&&o.worktree?o.worktree.path:null),je=o.isMain||o.isArchivedBucket||a?null:ot(o.directory??null),be=o.isMain||o.isArchivedBucket||a?null:o.branch?.trim()||null,pe=df(je,be),U=pe?`var(--pr-${pe.visualState})`:void 0,Pe=hf(pe,e),xe=pe?Aa(pe.provider,pe.number):"",Ee=pe?Pe?`${xe} · ${Pe}`:xe:void 0,L=Nr(),ie=c.useMemo(()=>{const Ce=o.folderScopes?.map(V=>ot(V.directory))??[ot(o.directory??null)];return[...new Set(Ce.filter(V=>!!V))]},[o.directory,o.folderScopes]);c.useSyncExternalStore(c.useCallback(Ce=>ie.length>0?L.subscribeBootstrap(Ce):()=>{},[ie.length,L]),c.useCallback(()=>ie.map(Ce=>`${Ce}\0${L.getBootstrapState(Ce)??""}\0${L.getBootstrapFailure(Ce)??""}\0${L.getInitializationState(Ce)??""}\0${L.getInitializationFailure(Ce)??""}`).join(""),[ie,L]),c.useCallback(()=>"",[]));const G=ie.some(Ce=>{const V=L.getBootstrapState(Ce);return V==="queued"||V==="running"}),ae=ie.find(Ce=>L.getBootstrapState(Ce)==="failed"||L.getInitializationState(Ce)==="failed")??null,ye=ae!==null&&L.getBootstrapState(ae)==="failed",ge=ae?ye?L.getBootstrapFailure(ae):L.getInitializationFailure(ae):void 0,Se=ge==="os-permission"&&tu(),[ve,Te]=c.useState(!1),z=c.useCallback(()=>{ae&&L.requestBootstrap({directory:ae,priority:de?"visible":"expanded",reason:o.isMain?"project-expanded":"worktree-expanded",force:!0})},[L,ae,o.isMain,de]),he=c.useCallback(async()=>{if(!(!ae||!Se||ve)){Te(!0);try{(await su(ae)).success&&z()}finally{Te(!1)}}},[Se,ae,ve,z]),se=b??(x?10:7),Re=Math.max(se,g??se),Ue=f?oe?.groupMatches===!0:!1,We=f,He=c.useMemo(()=>[...We?oe?.filteredNodes??[]:o.sessions].sort(q),[q,o.sessions,oe?.filteredNodes,We]),Be=o.folderScopeKey??ot(o.directory??null),Y=Gn(l,o.directory),Me=c.useMemo(()=>o.folderScopes&&o.folderScopes.length>0?o.folderScopes:Be?[{scopeKey:Be,directory:o.directory??null}]:[],[Be,o.directory,o.folderScopes]),Ge=Xt(Zn(c.useCallback(Ce=>Me.map(({scopeKey:V})=>Ce.foldersMap[V]??Pd),[Me]))),Ve=c.useMemo(()=>Me.flatMap(({scopeKey:Ce,directory:V},De)=>(Ge[De]??Pd).map(Qe=>({folder:Qe,scopeKey:Ce,scopeDirectory:V}))),[Ge,Me]),dt=Xt(Zn(c.useCallback(Ce=>new Set(Ge.flatMap(V=>V.filter(De=>Ce.collapsedFolderIds.has(De.id)).map(De=>De.id))),[Ge]))),et=c.useMemo(()=>{const Ce=new Map,V=De=>{De.forEach(_e=>{Ce.set(_e.session.id,_e),_e.children.length>0&&V(_e.children)})};return V(He),Ce},[He]),ct=c.useMemo(()=>Ve.map(({folder:Ce,scopeKey:V,scopeDirectory:De})=>{const _e=da(Ce.sessionIds,et).sort(q);return{folder:Ce,scopeKey:V,scopeDirectory:De,nodes:_e}}),[Ve,et,q]),me=c.useMemo(()=>{const Ce=Ih(ct.map(({folder:V,nodes:De})=>({id:V.id,name:V.name,parentId:V.parentId,nodeCount:De.length})),{archivedBucket:o.isArchivedBucket===!0,searchQuery:f?h:""});return ct.filter(({folder:V})=>Ce.has(V.id))},[ct,o.isArchivedBucket,f,h]),Ne=I,qe=N,Ye=c.useMemo(()=>new Set(me.flatMap(Ce=>Ce.folder.sessionIds)),[me]),$e=c.useMemo(()=>He.filter(Ce=>!Ye.has(Ce.session.id)),[He,Ye]),tt=c.useMemo(()=>{const Ce=new Map(me.map(V=>[V.folder.id,V]));return Dh(me.map(V=>V.folder)).map(V=>Ce.get(V.id)).filter(V=>!!V)},[me]),ht=c.useMemo(()=>{const Ce=new Map;return me.forEach(V=>{if(!V.folder.parentId)return;const De=Ce.get(V.folder.parentId)??[];De.push(V),Ce.set(V.folder.parentId,De)}),Ce},[me]),wt=c.useMemo(()=>{const Ce=new Map(me.map(_e=>[_e.folder.id,_e])),V=new Map,De=(_e,Qe)=>{const yt=V.get(_e);if(yt!==void 0)return yt;if(Qe.has(_e))return[];Qe.add(_e);const Dt=Ce.get(_e),zt=Dt?[...Dt.nodes]:[];for(const Jt of ht.get(_e)??[])zt.push(...De(Jt.folder.id,Qe));return V.set(_e,zt),zt};return me.forEach(({folder:_e})=>De(_e.id,new Set)),V},[me,ht]),Bt="project",kt=c.useMemo(()=>{const Ce=new Set;return Qc(He,Ne,Ce),me.forEach(({nodes:V})=>{Qc(V,Ne,Ce)}),Ce},[He,me,Ne]),St=c.useMemo(()=>{if(!qe)return null;const Ce=Do(He,qe,Bt,!!o.isArchivedBucket);if(Ce)return Ce;for(const{nodes:V}of me){const De=Do(V,qe,Bt,!!o.isArchivedBucket);if(De)return De}return null},[qe,He,me,o.isArchivedBucket]),xt=c.useCallback(Ce=>{const V=new WeakMap,De=_e=>{V.set(_e,jr(_e));for(const Qe of _e.children)De(Qe)};return Ce.forEach(De),V},[]),Mt=c.useMemo(()=>xt(He),[xt,He]),jt=c.useMemo(()=>{const Ce=new WeakMap;return me.forEach(({nodes:V})=>{V.forEach(De=>Ce.set(De,jr(De)))}),Ce},[me]),$t=c.useCallback(Ce=>Mt.get(Ce)??jt.get(Ce)??"",[Mt,jt]),Kt=c.useCallback(Ce=>({subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(Ce)}),[kt,St,$t]),Wt=$e.length,rt=o.isArchivedBucket||f?$e:$e.slice(0,Re),ut=Wt-rt.length,pt=!o.isArchivedBucket&&!f&&Wt>se&&ut===0,fe=c.useCallback(Ce=>{const V=[],De=_e=>{_e.forEach(Qe=>{V.push(Qe.session),Qe.children.length>0&&De(Qe.children)})};return De(Ce),V},[]),lt=c.useMemo(()=>fe(He),[fe,He]),ft=c.useMemo(()=>{if(pe||o.isMain||o.isArchivedBucket||a)return Ed;const Ce=new Map;for(const V of lt)for(const De of Va(V))Ce.has(De.key)||Ce.set(De.key,De);return Ce.size>0?[...Ce.values()]:Ed},[lt,o.isArchivedBucket,o.isMain,pe,a]),mt=c.useMemo(()=>ft.flatMap(Ce=>Ce.source==="github"?[Sr("issue",Ce)]:[]),[ft]),Rt=ko(mt),we=c.useMemo(()=>ft.flatMap(Ce=>Ce.source==="linear"?[Ga(Ce.identifier)]:[]),[ft]),it=ff(we),Q=c.useMemo(()=>ft.flatMap(Ce=>Ce.source==="gitlab"?[vr("issue",Ce.ref)]:[]),[ft]),le=ko(Q),Xe=c.useMemo(()=>pf(ft,Rt,it,le).map(Ce=>({...Ce,text:Ce.statusKey?`${Ce.label} · ${e(Ce.statusKey)}`:Ce.statusText?`${Ce.label} · ${Ce.statusText}`:Ce.label})),[le,Rt,ft,it,e]),Ae=Xe[0]??null,Je=c.useMemo(()=>{if(!o.isArchivedBucket)return new Map;const Ce=new Map,V=new Map;for(const{folder:_e}of me){if(!_e.parentId)continue;const Qe=V.get(_e.parentId)??[];Qe.push(_e.id),V.set(_e.parentId,Qe)}const De=(_e,Qe)=>{if(Qe.has(_e))return[];Qe.add(_e);const yt=me.find(({folder:Jt})=>Jt.id===_e),Dt=yt?fe(yt.nodes):[],zt=V.get(_e)??[];for(const Jt of zt)Dt.push(...De(Jt,Qe));return Dt};for(const{folder:_e}of me)Ce.set(_e.id,De(_e.id,new Set));return Ce},[me,fe,o.isArchivedBucket]);if(f&&!Ue&&tt.length===0&&$e.length===0)return null;const Fe=!o.isMain&&!!o.branch,gt=o.branch&&ux(o.branch,o.label)?{label:o.branch}:null,bt=de?n.jsx(hu,{nodes:He,includeUnreadSubtasks:E}):null,Et=(Ce,V)=>{const{folder:De,scopeKey:_e,scopeDirectory:Qe,nodes:yt}=Ce,Dt=Je.get(De.id)??[],zt=R?.folderId===De.id&&R?.scopeKey===_e,Jt=f?!1:dt.has(De.id),Ds=ys=>n.jsx(Kh,{folderId:De.id,scopeKey:_e,ownerKey:Y,children:(Is,Hs)=>n.jsx(zh,{folder:De,displayName:V,sessions:yt,isCollapsed:Jt,collapsedActivityState:ys,onToggle:()=>_(De.id),onRename:is=>{B(_e,De.id,is)},onDelete:()=>{if(o.isArchivedBucket){xn.requestDelete({sessions:Dt,mode:"session"});return}if(!re){ee(_e,De.id);return}const is=me.filter(({folder:_r})=>_r.parentId===De.id).length,Zo=yt.length;W({scopeKey:_e,folderId:De.id,folderName:De.name,subFolderCount:is,sessionCount:Zo})},groupDirectory:Qe??o.directory,projectId:l,mobileVariant:y,alwaysShowActions:w,isRenaming:zt,renameDraft:zt?R?.draft:void 0,onRenameDraftChange:H,onRenameSave:()=>{const is=R?.draft.trim()??"";is&&B(_e,De.id,is),M()},onRenameCancel:M,droppableRef:Is,isDropTarget:Hs,depth:0,onNewSession:()=>{l&&l!==j&&k(l),y&&P(!1),A({selectedProjectId:l,directoryOverride:Qe??o.directory,targetFolderId:De.id,target:o.draftTarget})},hideActions:!1,archivedBucket:o.isArchivedBucket===!0,children:yt.map(is=>n.jsx(Ao,{node:is,pinnedSessionIds:F,expandedParents:K,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,notifyOnSubtasks:E,editingId:I,editingRowKey:X,editTitle:C,openSidebarMenuKey:N,mobileVariant:y,alwaysShowActions:w,groupDirectory:Qe??o.directory,projectId:l,folderOwnerKey:Y,selectionScopeKey:Y,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(is),childRenderExtrasFor:Kt},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},is.session.id))})},De.id);return Jt?n.jsx(s4,{nodes:wt.get(De.id)??yt,includeUnreadSubtasks:E,children:Ds},De.id):Ds(null)},Ft=()=>{const Ce=new Map;for(const Qe of me){const yt=Qe.folder.parentId;if(!yt)continue;const Dt=Ce.get(yt);Dt?Dt.push(Qe):Ce.set(yt,[Qe])}const V=[],De=new Set,_e=(Qe,yt)=>{if(De.has(Qe.folder.id))return;De.add(Qe.folder.id);const Dt=yt?`${yt} / ${Qe.folder.name}`:Qe.folder.name;V.push(Et(Qe,Dt)),!(!f&&dt.has(Qe.folder.id))&&(Ce.get(Qe.folder.id)??[]).forEach(Jt=>_e(Jt,Dt))};return tt.forEach(Qe=>_e(Qe,"")),V},es=!!(!o.isMain&&o.worktree&&!ce),Ie=o.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,Ze=o.space&&o.space.state!=="complete"?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,at=es||!!o.space,Lt=!!o.space,Vt=w?Lt?"pe-20":at?"pe-14":"pe-7":ke("pe-2",Lt?"[--oc-actions-reserve:68px]":at?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),Ht=w?void 0:"group-hover/gh:oc-actions-mask group-focus-within/gh:oc-actions-mask",Oe=w?void 0:"transition-opacity group-hover/gh:opacity-0 group-focus-within/gh:opacity-0",ze=u?n.jsx("span",{"aria-hidden":!0,className:"size-3.5 flex-shrink-0"}):n.jsx(Cr,{expanded:!de}),st=pe&&Pe?[{key:`pr:${pe.number}`,icon:"git-pull-request",text:`${xe} · ${Pe}`,title:pe.title,color:U,url:pe.url}]:[],Nt=ae?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(ge==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ye?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),Se?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ve,onClick:()=>{he()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:z,children:e("sessions.sidebar.group.empty.retry")})]}):null,It=Ce=>n.jsx(Ao,{node:Ce,pinnedSessionIds:F,expandedParents:K,hasSessionSearchQuery:f,normalizedSessionSearchQuery:h,notifyOnSubtasks:E,editingId:I,editingRowKey:X,editTitle:C,openSidebarMenuKey:N,mobileVariant:y,alwaysShowActions:w,groupDirectory:o.directory,projectId:l,folderOwnerKey:Y,selectionScopeKey:Y,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:kt,menuOpenSessionId:St,nodeStructureKey:$t(Ce),childRenderExtrasFor:Kt},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},Ce.session.id),ts=n.jsxs(AC,{scopeKey:Me[0]?.scopeKey??Be,ownerKey:Y,hasFolders:me.length>0,onSessionDroppedOnFolder:(Ce,V)=>{const De=me.find(({folder:Qe,scopeKey:yt})=>Qe.id===V.folderId&&yt===V.scopeKey);if(!De)return;const _e=Xt.getState();for(const{scopeKey:Qe}of Me)Qe!==De.scopeKey&&_e.getSessionFolderId(Qe,Ce)&&_e.removeSessionFromFolder(Qe,Ce);ne(De.scopeKey,V.folderId,Ce)},children:[Ft(),rt.map(It),Wt===0&&me.length===0&&!r?!o.isArchivedBucket&&!G&&!Nt&&o.directory&&!o.emptyMessage?n.jsx(Ct,{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:()=>{l&&l!==j&&k(l),y&&P(!1),A({selectedProjectId:l,directoryOverride:o.directory,target:o.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-muted-foreground",children:o.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):G?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Nt||(o.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Wt>0&&Nt?n.jsx("div",{className:"py-1 ps-[26px] text-start typography-micro text-status-error",children:Nt}):null,ut>0?n.jsx("button",{type:"button",onClick:()=>S(i,rt.length,b??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,pt?n.jsx("button",{type:"button",onClick:()=>p(i),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]}),fs="pb-2",us=n.jsx(Zh,{value:te,setValue:W,onConfirm:()=>{const Ce=te;Ce&&(ee(Ce.scopeKey,Ce.folderId),W(null))}});return a?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:ke("oc-group-body",fs),children:ts})}),us]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:ke("oc-group",ce&&"opacity-60"),"aria-busy":ce||void 0,children:[n.jsxs("div",{className:ke("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md hover:bg-interactive-hover/60","cursor-pointer"),children:[n.jsxs(Ot,{disabled:pe?!Pe:!Ae,children:[n.jsx(At,{asChild:!0,closeDelay:Gh,children:n.jsx("div",{className:"min-w-0 flex-1",...u?{}:{onClick:()=>T(i),role:"button",tabIndex:0,onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),T(i))},"aria-label":de?e("sessions.sidebar.group.expandAria",{label:o.label}):e("sessions.sidebar.group.collapseAria",{label:o.label}),"aria-expanded":!de},children:n.jsxs("div",{ref:$?.setActivatorNodeRef,style:{paddingInlineStart:tr(0)},className:ke("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden",Vt),...$?.listeners??{},children:[n.jsxs("div",{className:ke("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",Ht),children:[n.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:o.isArchivedBucket?n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-0.5",children:[ze,n.jsx(Z,{name:"archive",className:"mx-px h-3 w-3 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:no(o.label,h)}),Ie,bt]}):!o.isMain||o.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-0.5",children:[ze,ce?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(Z,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):n.jsx(Z,{name:o.space?"box-3":"git-branch",className:ke("mx-px h-3 w-3 shrink-0",U?"oc-ref-tint":"text-muted-foreground"),style:U?Wn(U):void 0,"aria-label":o.space?e("sessions.sidebar.group.space"):void 0}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-medium text-foreground",children:no(o.label,h)}),Ie,Ze,bt,pe?n.jsx("button",{type:"button",className:ke("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",U&&"oc-ref-tint",Oe),style:U?Wn(U):void 0,disabled:!pe.url,"aria-label":Ee,onPointerDown:Ce=>Ce.stopPropagation(),onKeyDown:Ce=>Ce.stopPropagation(),onClick:Ce=>{Ce.stopPropagation(),pe.url&&s(pe.url,o.directory??null,Ce)},children:xe}):Ae?n.jsxs("button",{type:"button",className:ke("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",Ae.color?"oc-ref-tint":"text-muted-foreground",Oe),style:Ae.color?Wn(Ae.color):void 0,"aria-label":Xe.map(Ce=>Ce.text).join(", "),onPointerDown:Ce=>Ce.stopPropagation(),onKeyDown:Ce=>Ce.stopPropagation(),onClick:Ce=>{Ce.stopPropagation(),!(Ce.target instanceof Element&&Ce.target.closest("[data-ref-more]"))&&s(Ae.url,o.directory??null,Ce)},children:[n.jsx(Z,{name:Ae.icon,className:"h-3 w-3"}),Ae.label,Xe.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",Xe.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[ze,n.jsx("span",{className:"min-w-0 truncate",children:no(o.label,h)}),bt]})}),Fe&&gt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[o.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:gt.label})]}):null]}),!o.isArchivedBucket&&o.directory?n.jsx(Io,{directory:o.directory,className:ke("self-center",Oe)}):null]})})}),st.length>0?n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(To,{items:st,directory:o.directory??null})}):!pe&&Ae?n.jsx(Tt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(To,{items:Xe,directory:o.directory??null})}):null]}),n.jsxs(Go,{delayDuration:400,children:[o.isArchivedBucket&&lt.length>0?n.jsx("div",{className:ke("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),xn.requestDelete({sessions:lt,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:o.label}),children:n.jsx(Z,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,o.directory&&!o.isMain&&o.worktree&&!ce?n.jsx("div",{className:ke("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsx(a4,{label:o.label,sessions:lt,worktree:o.worktree})}):null,o.space?n.jsx("div",{className:ke("absolute inset-e-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),o.space&&$s.getState().openAccessDialog(o.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:o.label}),children:n.jsx(Z,{name:"key",className:"h-3.5 w-3.5"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,o.space?n.jsx("div",{className:ke("absolute inset-e-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(Tg,{spaceId:o.space.id,label:o.label})}):null,o.directory?n.jsx("div",{className:ke("absolute inset-e-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",w?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),l&&l!==j&&k(l),y&&P(!1),A({selectedProjectId:l,directoryOverride:o.directory,preserveDirectoryOverride:!!o.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:o.label}),children:n.jsx(Z,{name:"add",className:"h-4 w-4"})})}),n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),o.space?n.jsx(Mg,{spaceId:o.space.id,className:"pb-1 ps-5"}):null,!de&&d?n.jsx("div",{className:ke("oc-group-body",fs),children:ts}):null]}),us]})}const c4=c.memo(l4,i4),Ri=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},d4=(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]},Nd=10,Rd=(t,e)=>cf(t.label?.trim()||Ko(t.normalizedPath,e)||t.normalizedPath);function u4(t){const e=Ke.c(103),{model:s,view:r,actions:o}=t;Ss("ui.sidebar_projects_list.render");const{t:i}=vt(),l=Nr(),{files:a}=Ws(),d=Xt(w4),u=Xt(v4),f=Xt(S4),h=Xt(x4),m=ue(y4),g=ue(b4)&&!Sn(),[b,v]=c.useState(null),[x,S]=c.useState(null),[p,y]=c.useState(null),[w,j]=c.useState(null),[k,P]=c.useState(null),A=k?.kind==="project",F=c.useRef(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[0]=D):D=e[0];let E;e[1]===Symbol.for("react.memo_cache_sentinel")?(E={activationConstraint:{delay:200,tolerance:6}},e[1]=E):E=e[1];let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:Rf},e[2]=T):T=e[2];const $=Rr(Bs(Ir,D),Bs(Dr,E),Bs(Nf,T));let O;e[3]===Symbol.for("react.memo_cache_sentinel")?(O=z=>{F.current=z,j(z)},e[3]=O):O=e[3];const K=O;let I;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let z;e[7]!==r.homeDirectory?(z=he=>({id:he.project.id,projectLabel:Rd(he.project,r.homeDirectory),projectDescription:Qn(he.project.normalizedPath,r.homeDirectory),projectIcon:he.project.icon,projectColor:he.project.color,projectIconImage:he.project.iconImage,projectIconBackground:he.project.iconBackground}),e[7]=r.homeDirectory,e[8]=z):z=e[8],I=s.projectSections.map(z),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=I}else I=e[6];const X=I,N=fx(),{confirm:C}=N;let R;e[9]!==C||e[10]!==i?(R=async(z,he)=>{const se=Vo.getState().ids,Re=d4(he,Be=>Wa(se,Be.directory,Be.id)||vu(Be.id)||Ua(Be));if(Re.length===0){Le.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await C({title:i("sessions.sidebar.project.archiveAll.title",{project:z}),message:Re.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Re.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Re.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:We,failedIds:He}=await nt.getState().archiveSessions(Re);We.length>0&&Le.success(We.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:We.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:We.length})),He.length>0&&Le.error(He.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:He.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:He.length}))},e[9]=C,e[10]=i,e[11]=R):R=e[11];const H=R;let M;e[12]!==a||e[13]!==i?(M=z=>{a.revealPath&&a.revealPath(z).catch(()=>{Le.error(i("sidebarFilesTree.toast.revealFailed"))})},e[12]=a,e[13]=i,e[14]=M):M=e[14];const _=M;let B;e[15]!==x?(B=z=>`${z.kind}:${z.id}`===x,e[15]=x,e[16]=B):B=e[16];const ee=s.rowModel.stickyHeaders.findIndex(B);let ne;if(e[17]!==p||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(ne=new Set,p){let z;e[25]!==p||e[26]!==s.rowModel.rowIndexByKey?(z=s.rowModel.rowIndexByKey.get(p),e[25]=p,e[26]=s.rowModel.rowIndexByKey,e[27]=z):z=e[27];const he=z;he!==void 0&&ne.add(he)}for(let z=0;z<s.rowModel.rows.length;z=z+1,z){const he=s.rowModel.rows[z];he?.kind==="session"&&(s.groupProps.editingRowKey===he.key||s.state.openSidebarMenuKey===`session-menu:${he.key}`||s.state.openSidebarMenuKey===`session-context:${he.key}`)&&ne.add(z)}if(ee>=0){const z=Math.max(0,ee-1),he=Math.min(s.rowModel.stickyHeaders.length-1,ee+1);for(let se=z;se<=he;se=se+1,se){const Re=s.rowModel.stickyHeaders[se];Re&&ne.add(Re.rowIndex)}}e[17]=p,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]=ne}else ne=e[24];const re=ne;let te;e[28]!==s.rowModel.stickyHeaders?(te=z=>{const he=Zj(s.rowModel.stickyHeaders,z),se=he?`${he.kind}:${he.id}`:null;S(Re=>Re===se?Re:se)},e[28]=s.rowModel.stickyHeaders,e[29]=te):te=e[29];const W=te;let q;e[30]!==l||e[31]!==i?(q=z=>{const he=()=>{if(!z.status.directory){yf();return}l.requestBootstrap({directory:z.status.directory,priority:"expanded",reason:z.group.isMain?"project-expanded":"worktree-expanded",force:!0})},se=async()=>{if(!z.status.directory)return;(await su(z.status.directory)).success&&he()};let Re;e:switch(z.status.state){case"permission-denied":{Re=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Re=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Re=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Re=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"relative py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:z.flat?Nd:hd(z.depth??0)},children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[z.status.state==="loading"?n.jsx(Z,{name:"loader-4",className:"size-3 animate-spin"}):null,Re,z.status.canGrantAccess?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{se()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,z.status.state!=="loading"?n.jsx(Ct,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:he,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[30]=l,e[31]=i,e[32]=q):q=e[32];const oe=q;let de;e[33]!==o||e[34]!==f||e[35]!==a||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]!==_||e[43]!==X||e[44]!==u||e[45]!==oe||e[46]!==H||e[47]!==m||e[48]!==g||e[49]!==i||e[50]!==d||e[51]!==r?(de=z=>{if(z.kind==="activity-header")return n.jsx(ep,{className:"sticky top-0 z-20 bg-sidebar","data-sidebar-sticky-header":"true",children:n.jsx(H3,{activityKey:z.activityKey,collapsed:z.collapsed,forceExpanded:z.forceExpanded,alwaysShowActions:r.alwaysShowActions,onToggle:()=>{if(!z.collapsed){const se=`activity:${z.activityKey}`;o.group.resetGroupSessionLimit(se),s.state.setVisibleActivityCountByKey(Re=>{if(!Re.has(se))return Re;const Ue=new Map(Re);return Ue.delete(se),Ue})}s.state.setCollapsedActivityKeys(se=>{const Re=new Set(se);return Re.has(z.activityKey)?Re.delete(z.activityKey):Re.add(z.activityKey),Re})},onNewChat:()=>{ue.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:jm,directoryOverride:null})}})});if(z.kind==="project-header"){const se=z.section.project,Re=Rd(se,r.homeDirectory);return n.jsx(X3,{id:se.id,disabled:s.singleProjectMode||z.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:Re,projectDescription:Qn(se.normalizedPath,r.homeDirectory),projectDirectory:se.normalizedPath,projectIcon:se.icon,projectColor:se.color,projectIconImage:se.iconImage,projectIconBackground:se.iconBackground,isCollapsed:z.collapsed,isRepo:!!s.projectRepoStatus.get(se.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:z.collapsed?o.renderProjectStatusIndicator?.(se.id,z.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?X:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!z.forceExpanded&&!s.singleProjectMode&&o.toggleProject(se.id)},onNewSession:()=>{Ri({projectId:se.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:se.id,directoryOverride:se.normalizedPath})},onNewWorktreeSession:()=>{Ri({projectId:se.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(se.id),onManageSpaces:g?()=>ue.getState().setSpacesPageProjectId(se.id):void 0,onOpenFolder:se.normalizedPath&&a.revealPath?()=>_(se.normalizedPath):void 0,onRenameStart:()=>o.openProjectEditDialog(se.id),onArchiveAll:()=>{H(Re,z.section.groups)},onClose:()=>o.removeProject(se.id),showCreateButtons:!0})}if(z.kind==="group-header")return n.jsx(Z3,{id:z.groupKey,disabled:z.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:se=>n.jsx(c4,{...s.groupProps,...o.group,group:z.group,groupKey:z.groupKey,projectId:z.projectId,isEmpty:z.empty,visibleSessionCount:s.state.visibleSessionCountByGroup.get(z.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:se,renderBody:!1})});if(z.kind==="folder-header"){const se=s.groupProps.folderRename?.folderId===z.folder.id&&s.groupProps.folderRename.scopeKey===z.scopeKey;return n.jsx(Kh,{folderId:z.folder.id,scopeKey:z.scopeKey,ownerKey:z.ownerKey,disabled:!z.dropEnabled,children:(Re,Ue)=>n.jsx(TC,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:z.activityNodes,folder:z.folder,displayName:z.displayName,sessions:z.nodes,depth:z.depth,canExpand:z.nodes.length>0||z.subFolderCount>0,isCollapsed:z.collapsed,onToggle:z.forceExpanded?g4:()=>d(z.folder.id),onRename:We=>u(z.scopeKey,z.folder.id,We),onDelete:()=>{z.archived?xn.requestDelete({sessions:[...z.deleteSessions],mode:"session"}):m?v({scopeKey:z.scopeKey,folderId:z.folder.id,folderName:z.folder.name,subFolderCount:z.subFolderCount,sessionCount:z.nodes.length}):f(z.scopeKey,z.folder.id)},renderBody:!1,groupDirectory:z.scopeDirectory??z.group.directory,projectId:z.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:se,renameDraft:se?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const We=s.groupProps.folderRename?.draft.trim();We&&u(z.scopeKey,z.folder.id,We),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:Re,isDropTarget:Ue,onNewSession:()=>{Ri({projectId:z.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:z.scopeDirectory??z.group.directory,targetFolderId:z.folder.id,target:z.group.draftTarget})},archivedBucket:z.archived})})}if(z.kind==="session"){const se=new Set;return Jn(z.node,s.state.editingId)&&se.add(z.node.session.id),n.jsx("div",{onFocusCapture:()=>y(z.key),onBlurCapture:()=>y(Re=>Re===z.key?null:Re),children:n.jsx(Ao,{...s.groupProps,node:z.node,depth:z.depth,groupDirectory:z.groupDirectory,projectId:z.projectId,folderOwnerKey:z.ownerKey,selectionScopeKey:z.selectionScopeKey,archivedBucket:z.archived,renderContext:z.renderContext,rowKey:z.key,dragKey:z.key,secondaryMeta:z.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:se,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${z.key}`||s.state.openSidebarMenuKey===`session-context:${z.key}`?z.node.session.id:null,nodeStructureKey:z.blockingBadgeSessionScopes?`${jr(z.node)}:${JSON.stringify(z.blockingBadgeSessionScopes)}`:jr(z.node),blockingBadgeSessionScopes:z.blockingBadgeSessionScopes}})})}if(z.kind==="run")return n.jsx(T3,{run:z.run,depth:z.depth,laneNodes:z.laneNodes,blockingSessionIds:z.blockingSessionIds,renderContext:z.renderContext,projectId:z.projectId,projectLabel:z.projectLabel,expansionKey:z.expansionKey,expanded:z.expanded,forceExpanded:z.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});const he=z.kind==="show-control"&&z.flat===!0?Nd:hd(z.kind==="show-control"||z.kind==="empty"?z.depth??0:0);return z.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:he},onClick:()=>{z.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(se=>{const Re=new Map(se);return z.control==="more"?Re.set(z.containerKey,z.currentCount+z.increment):Re.delete(z.containerKey),Re}):z.control==="more"?o.group.showMoreGroupSessions(z.containerKey,z.currentCount,z.increment):o.group.resetGroupSessionLimit(z.containerKey)},children:i(z.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")})}):z.kind==="status"?oe(z):z.emptyKind==="sidebar"?s.emptyState:z.emptyKind==="search"?s.searchEmptyState:n.jsx("div",{className:"py-1 text-start typography-micro text-muted-foreground",style:{paddingInlineStart:he},children:i("sessions.sidebar.group.empty.noArchivedSessions")})},e[33]=o,e[34]=f,e[35]=a,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]=_,e[43]=X,e[44]=u,e[45]=oe,e[46]=H,e[47]=m,e[48]=g,e[49]=i,e[50]=d,e[51]=r,e[52]=de):de=e[52];const ce=de;let je;if(e[53]!==k||e[54]!==s.rowModel.rows){let z;e[56]!==k?(z=he=>he.kind==="project-header"?k?.kind==="group"?[]:[he.section.project.id]:he.kind!=="group-header"?[]:k?.kind==="project"?[]:k?.kind==="group"&&he.projectId!==k.projectId?[]:[he.groupKey],e[56]=k,e[57]=z):z=e[57],je=s.rowModel.rows.flatMap(z),e[53]=k,e[54]=s.rowModel.rows,e[55]=je}else je=e[55];const be=je;let pe;e[58]!==s.sectionsForRender?(pe=new Set(s.sectionsForRender.map(m4)),e[58]=s.sectionsForRender,e[59]=pe):pe=e[59];const U=pe;let Pe;e[60]!==s.rowModel.stickyHeaders?(Pe=s.rowModel.stickyHeaders.map(p4).join(""),e[60]=s.rowModel.stickyHeaders,e[61]=Pe):Pe=e[61];const xe=Pe;let Ee;e[62]!==s.rowModel.rows||e[63]!==U?(Ee=z=>{const he=String(z.active.id);if(U.has(he)){P({kind:"project"});return}const se=s.rowModel.rows.find(Re=>Re.kind==="group-header"&&Re.groupKey===he);P(se?{kind:"group",projectId:se.projectId}:null)},e[62]=s.rowModel.rows,e[63]=U,e[64]=Ee):Ee=e[64];let L;e[65]===Symbol.for("react.memo_cache_sentinel")?(L=()=>P(null),e[65]=L):L=e[65];let ie;e[66]!==o||e[67]!==h||e[68]!==s.rowModel.folderAuthorityByOwner||e[69]!==s.rowModel.folderDropTargets||e[70]!==s.rowModel.rows||e[71]!==s.sectionsForRender||e[72]!==s.state||e[73]!==r?(ie=z=>{if(P(null),!z.over)return;const he=z.active.data.current,se=z.over.data.current;if(he?.type==="session"&&he.sessionId&&he.ownerKey&&he.archivedBucket!==!0&&se?.type==="folder"&&se.folderId&&se.scopeKey&&se.ownerKey===he.ownerKey){const ct=s.rowModel.folderDropTargets.find(qe=>qe.folderId===se.folderId&&qe.scopeKey===se.scopeKey&&qe.ownerKey===he.ownerKey),me=s.rowModel.folderAuthorityByOwner.get(he.ownerKey);if(!ct?.enabled||me?.complete!==!0)return;const Ne=Xt.getState();for(const qe of me.scopeKeys)qe!==se.scopeKey&&Ne.removeSessionFromFolder(qe,he.sessionId);h(se.scopeKey,se.folderId,he.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||z.active.id===z.over.id)return;const Re=String(z.active.id),Ue=String(z.over.id),We=s.sectionsForRender.map(h4),He=We.indexOf(Re),Be=We.indexOf(Ue);if(He>=0&&Be>=0&&r.projectSortOrder==="manual"){o.reorderProjects(He,Be);return}const Y=s.rowModel.rows.find(ct=>ct.kind==="group-header"&&ct.groupKey===Re),Me=s.rowModel.rows.find(ct=>ct.kind==="group-header"&&ct.groupKey===Ue);if(!Y||!Me||Y.projectId!==Me.projectId||!Y.projectId)return;const Ge=Y.projectId,Ve=s.sectionsForRender.find(ct=>ct.project.id===Ge);if(!Ve)return;const dt=Ve.groups.findIndex(ct=>ct.id===Y.group.id),et=Ve.groups.findIndex(ct=>ct.id===Me.group.id);dt<0||et<0||o.setGroupOrderByProject(ct=>new Map(ct).set(Ge,qa(Ve.groups,dt,et).map(f4)))},e[66]=o,e[67]=h,e[68]=s.rowModel.folderAuthorityByOwner,e[69]=s.rowModel.folderDropTargets,e[70]=s.rowModel.rows,e[71]=s.sectionsForRender,e[72]=s.state,e[73]=r,e[74]=ie):ie=e[74];let G;e[75]!==W||e[76]!==s.rowModel||e[77]!==re||e[78]!==ce||e[79]!==w?(G=n.jsx(z3,{model:s.rowModel,scrollElement:w,pinnedRowIndexes:re,renderRow:ce,onFirstVisibleIndexChange:W}),e[75]=W,e[76]=s.rowModel,e[77]=re,e[78]=ce,e[79]=w,e[80]=G):G=e[80];let ae;e[81]!==be||e[82]!==G?(ae=n.jsx(Uo,{items:be,strategy:Ya,children:G}),e[81]=be,e[82]=G,e[83]=ae):ae=e[83];let ye;e[84]!==$||e[85]!==Ee||e[86]!==ie||e[87]!==ae?(ye=n.jsx(Er,{ref:K,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(Tr,{sensors:$,collisionDetection:Mr,onDragStart:Ee,onDragCancel:L,onDragEnd:ie,children:ae})}),e[84]=$,e[85]=Ee,e[86]=ie,e[87]=ae,e[88]=ye):ye=e[88];let ge;e[89]!==A||e[90]!==ye||e[91]!==xe?(ge=n.jsx(V3,{suspended:A,layoutKey:xe,scrollRef:F,children:ye}),e[89]=A,e[90]=ye,e[91]=xe,e[92]=ge):ge=e[92];let Se;e[93]!==f||e[94]!==b?(Se=()=>{b&&(f(b.scopeKey,b.folderId),v(null))},e[93]=f,e[94]=b,e[95]=Se):Se=e[95];let ve;e[96]!==b||e[97]!==Se?(ve=n.jsx(Zh,{value:b,setValue:v,onConfirm:Se}),e[96]=b,e[97]=Se,e[98]=ve):ve=e[98];let Te;return e[99]!==N.dialog||e[100]!==ge||e[101]!==ve?(Te=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ge,ve,N.dialog]}),e[99]=N.dialog,e[100]=ge,e[101]=ve,e[102]=Te):Te=e[102],Te}function f4(t){return t.id}function h4(t){return t.project.id}function p4(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function m4(t){return t.project.id}function g4(){}function b4(t){return t.isolatedSpacesEnabled}function y4(t){return t.showDeletionDialog}function x4(t){return t.addSessionToFolder}function S4(t){return t.deleteFolder}function v4(t){return t.renameFolder}function w4(t){return t.toggleFolderCollapse}const k4=c.memo(u4),ma=new Map,Dd=(t,e)=>{for(const s of t){const r=ot(s??null);r&&!ma.has(r)&&ma.set(r,e)}},Id=t=>{const e=ot(t??null);return e?ma.get(e)??0:0},dr=t=>!!t.time?.archived,j4=(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},C4=t=>{const{t:e}=vt(),s=c.useRef(t.gitBranches);s.current=t.gitBranches;const r=c.useRef(t.sessionOrderRanks);r.current=t.sessionOrderRanks;const o=c.useRef(t.sessionOwners),i=c.useMemo(()=>(j4(o.current,t.sessionOwners)||(o.current=t.sessionOwners),o.current),[t.sessionOwners]),l=c.useCallback(f=>[f.label,f.branch??"",f.description??"",f.directory??""].join(" ").toLowerCase(),[]),a=c.useCallback(f=>{const h=ot(f.directory??null)??"";return`${(f.title||e("sessions.sidebar.session.untitled")).trim()} ${h}`.toLowerCase()},[e]),d=c.useCallback((f,h)=>{if(!h)return f;const m=h.trim().toLowerCase(),g=m.startsWith("ses_");return f.flatMap(b=>{if(g&&dr(b.session))return[];if(g?b.session.id.toLowerCase()===m:wo([a(b.session)],h))return[b];const x=d(b.children,h);return x.length===0?[]:[{...b,children:x}]})},[a]),u=c.useCallback((f,h,m,g,b)=>{const v=ot(h??null),x=af(f),S=new Map(x.map(_=>[_.id,_])),p=new Map;x.forEach(_=>{const B=_.parentID;if(!B)return;const ee=S.get(B);if(!ee||dr(ee)||dr(_))return;const ne=p.get(B)??[];ne.push(_),p.set(B,ne)});const y=hx(m,v),w=(v&&!t.isVSCode?t.spacesByProject?.get(v):void 0)??[],j=new Map;for(const _ of w){const B=ot(_.directory);B&&j.set(B,_)}const k=_=>{const B=ot(_.directory??null),ee=t.worktreeMetadata.get(_.id)??null;if(ee)return ee;if(B){const ne=y.get(B)??null;if(ne&&B!==v)return ne}return null},P=new Set,A=_=>{P.add(_.id);const B=p.get(_.id)??[],ee=[];for(const ne of B)P.has(ne.id)||ee.push(A(ne));return{session:_,children:ee,worktree:k(_)}},F=_=>{const B=_.parentID;if(!B)return!1;if(dr(_))return!0;const ee=S.get(B);return!!(ee&&dr(ee))},D=x.filter(_=>{const B=_.parentID;return B?!S.has(B)&&!F(_):!0}),E=[],T=_=>{P.has(_.id)||E.push(A(_))};D.forEach(T),x.forEach(_=>{F(_)||T(_)});const $=new Map,O="__archived__",K=_=>{if(_.time?.archived)return O;if(t.isVSCode||t.runKeyBySessionId?.has(_.id))return v??"__project_root__";const B=i?.get(_.id)?.scopeDirectory;if(B){if(B===v)return v??"__project_root__";if(y.has(B)||j.has(B))return B}const ne=ot(t.worktreeMetadata.get(_.id)?.path??null)??Xn(_);return ne&&ne!==v&&y.has(ne)?ne:v??"__project_root__"};E.forEach(_=>{const B=K(_.session);$.has(B)||$.set(B,[]),$.get(B)?.push(_)});const I=v??"__project_root__",X=[{id:"root",label:b&&g&&g!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:g}):e("sessions.sidebar.grouping.projectRoot"),branch:g??null,description:v?Qn(v,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:v,folderScopeKey:v,sessions:$.get(I)??[]}],N=new Map;m.forEach(_=>{const B=ot(_.path)??_.path,ee=$.get(B)??[],ne=ee.length>0,re=ee.reduce((te,W)=>{const q=px(W.session,r.current);return Number.isFinite(q)?Math.max(te,q):te},0);N.set(B,{hasActiveSession:ne,lastUpdatedAt:re})});const C=(_,B)=>{const ee=(_.label||_.branch||_.name||_.path||"").toLowerCase(),ne=(B.label||B.branch||B.name||B.path||"").toLowerCase();return ee.localeCompare(ne)},R=t.worktreeSortOrder!=="recent"?[...m].sort(C):[...m].sort((_,B)=>{const ee=ot(_.path)??_.path,ne=ot(B.path)??B.path,re=N.get(ee)??{hasActiveSession:!1,lastUpdatedAt:0},te=N.get(ne)??{hasActiveSession:!1,lastUpdatedAt:0};if(re.hasActiveSession!==te.hasActiveSession)return re.hasActiveSession?-1:1;if(re.hasActiveSession&&te.hasActiveSession)return te.lastUpdatedAt-re.lastUpdatedAt;const W=Id(_.path),q=Id(B.path);return W!==q?q-W:C(_,B)});(t.isVSCode?[]:R).forEach(_=>{const B=ot(_.path)??_.path,ee=s.current.get(B)?.trim()||null,ne=_.branch?.trim()||null,te=!!(ee&&ne&&_.label&&rc(_.label)===rc(ne))?ee:_.label||_.name||Ko(B,t.homeDirectory)||B;X.push({id:`worktree:${B}`,label:te,branch:ee||ne,description:Qn(B,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:_,directory:B,folderScopeKey:B,sessions:$.get(B)??[]})});for(const[_,B]of j)X.push({id:`space:${B.id}`,label:B.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:B,directory:_,folderScopeKey:_,sessions:$.get(_)??[]});const M=$.get(O)??[];return M.length>0&&X.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&&v?of(v):null,sessions:M}),X},[t.homeDirectory,t.worktreeMetadata,t.isVSCode,t.worktreeSortOrder,i,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:l,buildSessionSearchText:a,filterSessionNodesForSearch:d,buildGroupedSessions:u}},P4=t=>{const e=Ke.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:h,onDelete:m,onDone:g}=t,{t:b}=vt(),v=s>0,x=v&&!!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 p;e[3]!==S?(p=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:S}),e[3]=S,e[4]=p):p=e[4];let y;e[5]!==x||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==o||e[11]!==b?(y=x?n.jsxs(js,{children:[n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx(Cs,{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(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(Ps,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(qt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):o.map(M=>n.jsx(qt,{onClick:()=>l(M.id),children:n.jsx("span",{className:"flex-1 truncate",children:M.name})},M.id)),n.jsx(bn,{}),n.jsxs(qt,{onClick:a,children:[n.jsx(Z,{name:"add",className:"me-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(qt,{onClick:d,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]=x,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=o,e[11]=b,e[12]=y):y=e[12];let w;e[13]!==i||e[14]!==v||e[15]!==f||e[16]!==b?(w=i?n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!v,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(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=v,e[15]=f,e[16]=b,e[17]=w):w=e[17];let j;e[18]!==i||e[19]!==v||e[20]!==h||e[21]!==b?(j=i?null:n.jsxs(Ot,{children:[n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,disabled:!v,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(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=v,e[20]=h,e[21]=b,e[22]=j):j=e[22];const k=!v;let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=ke("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]=P):P=e[23];let A;e[24]!==b?(A=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=A):A=e[25];let F;e[26]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(Z,{name:"delete-bin",className:"h-4 w-4"}),e[26]=F):F=e[26];let D;e[27]!==m||e[28]!==k||e[29]!==A?(D=n.jsx(At,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:k,className:P,"aria-label":A,children:F})}),e[27]=m,e[28]=k,e[29]=A,e[30]=D):D=e[30];let E;e[31]!==b?(E=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=E):E=e[32];let T;e[33]!==E?(T=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:E})}),e[33]=E,e[34]=T):T=e[34];let $;e[35]!==D||e[36]!==T?($=n.jsxs(Ot,{children:[D,T]}),e[35]=D,e[36]=T,e[37]=$):$=e[37];let O;e[38]!==b?(O=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=O):O=e[39];let K;e[40]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Z,{name:"close",className:"h-4 w-4"}),e[40]=K):K=e[40];let I;e[41]!==g||e[42]!==O?(I=n.jsx(At,{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":O,children:K})}),e[41]=g,e[42]=O,e[43]=I):I=e[43];let X;e[44]!==b?(X=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=X):X=e[45];let N;e[46]!==X?(N=n.jsx(Tt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:X})}),e[46]=X,e[47]=N):N=e[47];let C;e[48]!==I||e[49]!==N?(C=n.jsxs(Ot,{children:[I,N]}),e[48]=I,e[49]=N,e[50]=C):C=e[50];let R;e[51]!==$||e[52]!==C||e[53]!==y||e[54]!==w||e[55]!==j?(R=n.jsxs("div",{className:"ms-auto flex items-center gap-0.5",children:[y,w,j,$,C]}),e[51]=$,e[52]=C,e[53]=y,e[54]=w,e[55]=j,e[56]=R):R=e[56];let H;return e[57]!==p||e[58]!==R?(H=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[p,R]}),e[57]=p,e[58]=R,e[59]=H):H=e[59],H},Td=new Map,E4=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},N4=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||Vh(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},R4=t=>{const e=Ke.c(89),{t:s}=vt();let r;e[0]!==s?(r=ge=>{const Se=mx(ge);return Se?{description:fu(Se,s)}:void 0},e[0]=s,e[1]=r):r=e[1];const o=r,{isInlineEditing:i,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:f,createFolderAndStartRename:h,archiveSessions:m,unarchiveSessions:g,deleteSessions:b,bulkDeleteConfirm:v,setBulkDeleteConfirm:x}=t,S=cs(D4),p=cs(I4),y=p>0,w=cs(T4),j=cs(M4),k=Hh(),P=A4,A=O4;let F;e[2]!==y||e[3]!==k||e[4]!==w?(F=y&&Vh(w,k?.getSessionsById()??Td),e[2]=y,e[3]=k,e[4]=w,e[5]=F):F=e[5];const D=F;let E;e:{if(j){E=j;break e}E=null}const T=E;let $;e[6]!==T||e[7]!==d?($=E4(T,d),e[6]=T,e[7]=d,e[8]=$):$=e[8];const O=$;let K;if(e[9]!==a||e[10]!==O){let ge;e[12]!==a?(ge=Se=>a[Se]??[],e[12]=a,e[13]=ge):ge=e[13],K=O.flatMap(ge),e[9]=a,e[10]=O,e[11]=K}else K=e[11];const I=K;let X;e[14]!==a||e[15]!==O?(X=ge=>{for(const Se of O)if((a[Se]??[]).some(ve=>ve.id===ge))return Se;return null},e[14]=a,e[15]=O,e[16]=X):X=e[16];const N=X;let C;e:{if(!y){C=!1;break e}for(const ge of O)for(const Se of a[ge]??[])for(const ve of Se.sessionIds)if(w.has(ve)){C=!0;break e}C=!1}const R=C;let H;e[17]!==u||e[18]!==f||e[19]!==w||e[20]!==O?(H=(ge,Se)=>{const ve=Array.from(w);for(const Te of O)Te!==ge&&f(Te,ve);u(ge,Se,ve)},e[17]=u,e[18]=f,e[19]=w,e[20]=O,e[21]=H):H=e[21];const M=H;let _;e[22]!==y||e[23]!==M||e[24]!==N?(_=ge=>{if(!y)return;const Se=N(ge);Se&&M(Se,ge)},e[22]=y,e[23]=M,e[24]=N,e[25]=_):_=e[25];const B=_;let ee;e[26]!==h||e[27]!==y||e[28]!==M||e[29]!==O?(ee=()=>{const ge=O[0];if(!ge||!y)return;const Se=h(ge);Se&&M(ge,Se.id)},e[26]=h,e[27]=y,e[28]=M,e[29]=O,e[30]=ee):ee=e[30];const ne=ee;let re;e[31]!==y||e[32]!==f||e[33]!==w||e[34]!==O?(re=()=>{if(!y)return;const ge=Array.from(w);for(const Se of O)f(Se,ge)},e[31]=y,e[32]=f,e[33]=w,e[34]=O,e[35]=re):re=e[35];const te=re;let W;e[36]!==m||e[37]!==b||e[38]!==o||e[39]!==s?(W=async(ge,Se)=>{if(ge.length!==0)if(Se){const{deletedIds:ve,failedIds:Te}=await b(ge);ve.length>0&&Le.success(ve.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:ve.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:ve.length})),Te.length>0&&Le.error(Te.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:Te.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:Te.length}),o(Te)),cs.getState().removeMany(ve)}else{const{archivedIds:ve,failedIds:Te}=await m(ge);ve.length>0&&Le.success(ve.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:ve.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:ve.length})),Te.length>0&&Le.error(Te.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Te.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:Te.length}),o(Te)),cs.getState().removeMany(ve)}},e[36]=m,e[37]=b,e[38]=o,e[39]=s,e[40]=W):W=e[40];const q=W;let oe;e[41]!==q||e[42]!==y||e[43]!==w||e[44]!==x||e[45]!==l?(oe=ge=>{if(!y)return;const Se=Array.from(w);if(!l){q(Se,ge);return}x({sessionIds:Se,sessionCount:Se.length,archivedBucket:ge})},e[41]=q,e[42]=y,e[43]=w,e[44]=x,e[45]=l,e[46]=oe):oe=e[46];const de=oe;let ce;e[47]!==D||e[48]!==de?(ce=()=>de(D),e[47]=D,e[48]=de,e[49]=ce):ce=e[49];const je=ce;let be;e[50]!==de?(be=()=>de(!1),e[50]=de,e[51]=be):be=e[51];const pe=be;let U;e[52]!==de?(U=()=>de(!0),e[52]=de,e[53]=U):U=e[53];const Pe=U;let xe;e[54]!==D||e[55]!==o||e[56]!==y||e[57]!==w||e[58]!==s||e[59]!==g?(xe=async()=>{if(!y||!D)return;const ge=Array.from(w),{restoredIds:Se,failedIds:ve}=await g(ge);Se.length>0&&Le.success(Se.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:Se.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:Se.length})),ve.length>0&&Le.error(ve.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:ve.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:ve.length}),o(ve)),cs.getState().removeMany(Se)},e[54]=D,e[55]=o,e[56]=y,e[57]=w,e[58]=s,e[59]=g,e[60]=xe):xe=e[60];const Ee=xe;let L;e[61]!==v||e[62]!==q||e[63]!==k||e[64]!==x?(L=async()=>{if(!v)return;const ge=k?.getSessionsById()??Td,Se=N4(v,ge);if(!Se.ready){x(Se.value);return}x(null),await q(Se.value.sessionIds,Se.value.archivedBucket)},e[61]=v,e[62]=q,e[63]=k,e[64]=x,e[65]=L):L=e[65];const ie=L;let G,ae;e[66]!==v||e[67]!==je||e[68]!==i||e[69]!==k||e[70]!==S?(G=()=>{if(!S)return;const ge=/Macintosh|Mac OS X/.test(navigator.userAgent||""),Se=ve=>{if(v||i)return;const Te=ve.target instanceof HTMLElement?ve.target:null;if(Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable))return;const z=ge?ve.metaKey:ve.ctrlKey;if(ve.key==="Escape"){ve.preventDefault(),cs.getState().disable();return}if(z&&ve.key==="Backspace"){ve.preventDefault(),je();return}if(z&&(ve.key==="a"||ve.key==="A")){const he=BC(k?.getEntries()??[],k?.getDescendantIds()??[],cs.getState().scopeKey);if(!he)return;ve.preventDefault(),cs.getState().replaceAll(he.ids,he.scopeKey)}};return window.addEventListener("keydown",Se),()=>window.removeEventListener("keydown",Se)},ae=[v,je,i,k,S],e[66]=v,e[67]=je,e[68]=i,e[69]=k,e[70]=S,e[71]=G,e[72]=ae):(G=e[71],ae=e[72]),c.useEffect(G,ae);let ye;return e[73]!==R||e[74]!==I||e[75]!==D||e[76]!==ie||e[77]!==T||e[78]!==pe||e[79]!==ne||e[80]!==je||e[81]!==Pe||e[82]!==B||e[83]!==te||e[84]!==Ee||e[85]!==y||e[86]!==p||e[87]!==S?(ye={selectionModeEnabled:S,hasSelection:y,selectedIdsSize:p,bulkScopeIsArchived:D,derivedSelectionScope:T,bulkScopeFolders:I,bulkCanRemoveFromFolder:R,handleToggleSelectionMode:P,handleExitSelectionMode:A,handleBulkMoveToFolder:B,handleBulkCreateFolderAndMove:ne,handleBulkRemoveFromFolder:te,handleBulkDelete:je,handleBulkArchive:pe,handleBulkHardDelete:Pe,handleBulkRestore:Ee,confirmBulkDelete:ie},e[73]=R,e[74]=I,e[75]=D,e[76]=ie,e[77]=T,e[78]=pe,e[79]=ne,e[80]=je,e[81]=Pe,e[82]=B,e[83]=te,e[84]=Ee,e[85]=y,e[86]=p,e[87]=S,e[88]=ye):ye=e[88],ye};function D4(t){return t.enabled}function I4(t){return t.selectedIds.size}function T4(t){return t.selectedIds}function M4(t){return t.scopeKey}function A4(){cs.getState().toggleMode()}function O4(){cs.getState().disable()}function B4(t){const e=Ke.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,l]=c.useState(null),a=ue(V4),d=ue(H4),u=Xt(W4),f=Xt(K4),h=Xt(z4),m=Xt($4),g=nt(L4),b=nt(_4),v=nt(F4);let x;e[0]!==f||e[1]!==o?(x=k=>{const P=f(k,"New folder");return o(k,P),P},e[0]=f,e[1]=o,e[2]=x):x=e[2];let S;e[3]!==h||e[4]!==g||e[5]!==i||e[6]!==v||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==m||e[11]!==a||e[12]!==x||e[13]!==b?(S={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:h,removeSessionsFromFolders:m,createFolderAndStartRename:x,archiveSessions:g,unarchiveSessions:b,deleteSessions:v,bulkDeleteConfirm:i,setBulkDeleteConfirm:l},e[3]=h,e[4]=g,e[5]=i,e[6]=v,e[7]=u,e[8]=s,e[9]=r,e[10]=m,e[11]=a,e[12]=x,e[13]=b,e[14]=S):S=e[14];const p=R4(S);let y;e[15]!==p.bulkCanRemoveFromFolder||e[16]!==p.bulkScopeFolders||e[17]!==p.bulkScopeIsArchived||e[18]!==p.derivedSelectionScope||e[19]!==p.handleBulkArchive||e[20]!==p.handleBulkCreateFolderAndMove||e[21]!==p.handleBulkHardDelete||e[22]!==p.handleBulkMoveToFolder||e[23]!==p.handleBulkRemoveFromFolder||e[24]!==p.handleBulkRestore||e[25]!==p.handleExitSelectionMode||e[26]!==p.selectedIdsSize||e[27]!==p.selectionModeEnabled?(y=p.selectionModeEnabled?n.jsx(P4,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onArchive:p.handleBulkArchive,onDelete:p.handleBulkHardDelete,onDone:p.handleExitSelectionMode}):null,e[15]=p.bulkCanRemoveFromFolder,e[16]=p.bulkScopeFolders,e[17]=p.bulkScopeIsArchived,e[18]=p.derivedSelectionScope,e[19]=p.handleBulkArchive,e[20]=p.handleBulkCreateFolderAndMove,e[21]=p.handleBulkHardDelete,e[22]=p.handleBulkMoveToFolder,e[23]=p.handleBulkRemoveFromFolder,e[24]=p.handleBulkRestore,e[25]=p.handleExitSelectionMode,e[26]=p.selectedIdsSize,e[27]=p.selectionModeEnabled,e[28]=y):y=e[28];let w;e[29]!==p.confirmBulkDelete||e[30]!==i||e[31]!==d||e[32]!==a?(w=n.jsx(S3,{value:i,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[29]=p.confirmBulkDelete,e[30]=i,e[31]=d,e[32]=a,e[33]=w):w=e[33];let j;return e[34]!==y||e[35]!==w?(j=n.jsxs(n.Fragment,{children:[y,w]}),e[34]=y,e[35]=w,e[36]=j):j=e[36],j}function F4(t){return t.deleteSessions}function _4(t){return t.unarchiveSessions}function L4(t){return t.archiveSessions}function $4(t){return t.removeSessionsFromFolders}function z4(t){return t.addSessionsToFolder}function K4(t){return t.createFolder}function W4(t){return t.foldersMap}function H4(t){return t.setShowDeletionDialog}function V4(t){return t.showDeletionDialog}const tp="oc.sessions.expandedParents.v3",G4=qo(rn()),U4=()=>{try{const t=globalThis.localStorage.getItem(tp);if(t===null)return new Set;const e=G4.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},q4=()=>{const[t,e]=c.useState(U4),s=c.useRef(t);s.current=t;const r=c.useCallback(o=>{const i=gx(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(tp,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},Y4=t=>{const e=Ke.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,l=ws(X4),a=ws(Q4);let d;e[0]!==o||e[1]!==r?(d=[...r.flatMap(Z4),...o?[{key:"activity:chats",group:o}]:[]].map(t5),e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]!==u?(f=new Set(u.flatMap(s5)),e[3]=u,e[4]=f):f=e[4];let h;e[5]!==f?(h=[...f],e[5]=f,e[6]=h):h=e[6];const m=h;let g;e[7]!==s||e[8]!==m.length?(g=y=>m.length>0?s.subscribeBootstrap(y):n5,e[7]=s,e[8]=m.length,e[9]=g):g=e[9];let b;e[10]!==s||e[11]!==m?(b=()=>m.map(y=>`${y}\0${s.getBootstrapState(y)??""}\0${s.getBootstrapFailure(y)??""}\0${s.getInitializationState(y)??""}\0${s.getInitializationFailure(y)??""}`).join(""),e[10]=s,e[11]=m,e[12]=b):b=e[12];const v=c.useSyncExternalStore(g,b,r5);let x;if(e[13]!==i||e[14]!==s||e[15]!==l||e[16]!==u||e[17]!==a){x=new Map;for(const{key:y,archived:w,directories:j}of u){const k=j.find(P=>s.getBootstrapState(P)==="failed"||s.getInitializationState(P)==="failed");if(k){const P=s.getBootstrapState(k)==="failed",A=P?s.getBootstrapFailure(k):s.getInitializationFailure(k);x.set(y,{state:A==="os-permission"?"permission-denied":P?"load-failed":"initialization-failed",directory:k,canGrantAccess:A==="os-permission"&&i})}else{const P=a||!w&&j.length>0&&j.every(A=>s.getBootstrapState(A)==="complete");x.set(y,{state:P?"ready":l==="error"?"load-failed":"loading",directory:P?j[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=l,e[16]=u,e[17]=a,e[18]=x}else x=e[18];const S=x;let p;return e[19]!==v||e[20]!==S?(p={groupStatusByKey:S,bootstrapSnapshot:v},e[19]=v,e[20]=S,e[21]=p):p=e[21],p};function X4(t){return t.status}function Q4(t){return t.hasLoaded}function Z4(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function J4(t){return ot(t.directory)}function e5(t){return!!t}function t5(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:er(s).map(J4).filter(e5)}}function s5(t){return t.directories}function n5(){}function r5(){return""}const o5=6e4,i5=[],Md=[],Ad=[],a5=t=>!t.parentID,l5=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:l,...a}=s,d=Xt(Ie=>Ie.foldersMap),u=Xt(Ie=>Ie.collapsedFolderIds),f=Xt(Ie=>Ie.createFolder),h=Xt(Ie=>Ie.addSessionToFolder),m=e.projectView,{getOrderedGroups:g,setGroupOrderByProject:b,toggleGroup:v,toggleProject:x,setCollapsedActivities:S}=i,p=Ag({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),y=bx(Ie=>Ie.projects),w=Cm(),j=c.useMemo(()=>new Map(w.map(Ie=>[Ie.id,Ie.name])),[w]),k=c.useMemo(()=>{const Ie=new Map;for(const Ze of w){const at=ot(Ze.projectDirectory);if(!at)continue;const Lt=Ie.get(at);Lt?Lt.push(Ze):Ie.set(at,[Ze])}return Ie},[w]),P=c.useMemo(()=>I1(p.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,p.archivedSessions,y,w),[y,p.archivedSessions,p.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[A,F]=c.useState(new Map),[D,E]=c.useState(new Map),T=c.useCallback((Ie,Ze,at=7)=>{F(Lt=>new Map(Lt).set(Ie,Ze+at))},[]),$=c.useCallback(Ie=>{F(Ze=>{if(!Ze.has(Ie))return Ze;const at=new Map(Ze);return at.delete(Ie),at})},[]);c.useEffect(()=>{F(Ie=>{if(Ie.size===0)return Ie;const Ze=Vt=>m.collapsedGroups.has(Vt)||[...m.collapsedProjects].some(Ht=>Vt===Fh(Ht)||Vt.startsWith(`${Ht}:`)),at=[...Ie.keys()].filter(Ze);if(at.length===0)return Ie;const Lt=new Map(Ie);for(const Vt of at)Lt.delete(Vt);return Lt})},[m.collapsedGroups,m.collapsedProjects]);const O=os(Ie=>Ie.showChatsSection),K=os(Ie=>Ie.projectDisplayMode),I=os(Ie=>Ie.singleProjectId),X=os(Ie=>Ie.setSingleProjectId),C=!t.isVSCode&&!Pm()&&K==="single",R=e.sidebarViewMode==="timeline"&&!t.isVSCode,H=c.useMemo(()=>yx(p.rootSessions,Ie=>ot(t.worktreeMetadata.get(Ie.id)?.projectDirectory??Ie.directory??null)),[p.rootSessions,t.worktreeMetadata]),M=c.useRef(null),_=c.useMemo(()=>{const Ie=Array.from(H.runKeyBySessionId,([Ze,at])=>`${Ze}\0${at}`).sort().join("");return M.current?.signature!==Ie&&(M.current={signature:Ie,map:H.runKeyBySessionId}),M.current.map},[H]),[B,ee]=c.useState(null),[ne,re]=c.useState(null),[te,W]=c.useState(""),[q,oe]=c.useState(null),[de,ce]=c.useState(null),[je,be]=c.useState(null),pe=c.useCallback((Ie,Ze)=>{be({scopeKey:Ie,folderId:Ze.id,draft:Ze.name})},[]),U=c.useCallback(Ie=>{be(Ze=>Ze?{...Ze,draft:Ie}:null)},[]),Pe=c.useCallback(()=>be(null),[]),{expandedParents:xe,toggleParent:Ee}=q4(),L=nt(Ie=>Ie.setCurrentSession),ie=c.useCallback((Ie,Ze)=>{Ie!==nt.getState().currentSessionId&&L(Ie,Ze)},[L]),G=mf(),ae=os(Ie=>Ie.worktreeSortOrder),{buildGroupedSessions:ye,filterSessionNodesForSearch:ge,buildGroupSearchText:Se}=C4({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:ae,sessionOwners:P.bySessionId,spacesByProject:k,runKeyBySessionId:_}),{getSessionsForProject:ve,getArchivedSessionsForProject:Te}=aC({ownership:P}),z=xx(),he=c.useMemo(()=>{if(t.isVSCode)return null;const Ie=z??p.chatSessions.map(at=>wa(at.directory)).find(Boolean)??null;if(!Ie)return null;const Ze=Array.from(new Set([Ie,...p.chatSessions.map(at=>ot(at.directory??null)).filter(Boolean)])).filter(at=>!!at).map(at=>({scopeKey:at,directory:at}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Ie,folderScopeKey:Ie,folderScopes:Ze,draftTarget:"chat",sessions:p.chatSessions.filter(at=>!at.time?.archived&&a5(at)).map(at=>or(p.childrenMap,at))}},[p.chatSessions,p.childrenMap,z,t.isVSCode]),se=c.useMemo(()=>he?[he]:i5,[he]),{projectSections:Re,groupSearchDataByGroup:Ue,sectionsForRender:We,flatSectionsForRender:He}=fC({normalizedProjects:t.projects,getSessionsForProject:ve,getArchivedSessionsForProject:Te,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,sessionOrderRanks:p.sessionOrderRanks,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:ye,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:ge,buildGroupSearchText:Se,foldersMap:d,standaloneGroups:se}),Be=e.onSearchMatchCountChange;c.useEffect(()=>()=>Be(0),[Be]);const Y=Nr(),Me=e.useGroupedSections?We:He,Ge=c.useMemo(()=>e.showInlineArchived?Me:Me.map(Ie=>Ie.groups.some(Ze=>Ze.isArchivedBucket)?{...Ie,groups:Ie.groups.filter(Ze=>!Ze.isArchivedBucket)}:Ie),[Me,e.showInlineArchived]),Ve=c.useCallback(Ie=>He.find(at=>at.project.id===Ie)?.groups.find(at=>!at.isArchivedBucket)?.folderScopes??[],[He]);eC({enabled:!0,normalizedProjects:t.projects,ownership:P,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:p.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:h});const{sourceControl:dt}=Ws(),et=ls(Ie=>Ie.ensureEntry),ct=ls(Ie=>Ie.setParams),me=ls(Ie=>Ie.refreshTargets),Ne=ls(Ie=>Ie.clearDirectoryStatus),qe=ls(Ie=>Ie.beginActiveContextsLoad),Ye=ls(Ie=>Ie.commitActiveContexts),$e=ls(Ie=>Ie.releaseActiveContexts),tt=ls(Ie=>Ie.activeContextRegistrations),ht=c.useId(),wt=c.useRef(new Set),Bt=c.useMemo(()=>new Map(p.orderedSessions.map((Ie,Ze)=>[Ie.id,Ze])),[p.orderedSessions]),[kt,St]=c.useState(null),xt=c.useRef([]),Mt=e.projectSortOrder==="recent";c.useEffect(()=>{Mt||St(null)},[Mt]);const jt=c.useMemo(()=>{const Ie=ae!=="manual"?Ge:Ge.map(at=>{const Lt=g(at.project.id,at.groups);return Lt===at.groups?at:{...at,groups:Lt}}),Ze=Og(Ie,e.projectSortOrder,at=>at.project.id,P.sessionsByProject);return[...kt&&Mt?Bg(Ze,kt,at=>at.project.id):Ze]},[g,kt,Mt,P.sessionsByProject,Ge,e.projectSortOrder,ae]);c.useEffect(()=>{xt.current=jt.map(Ie=>Ie.project.id)},[jt]);const $t=c.useMemo(()=>{if(!R)return Md;const Ie=new Set(p.rootSessions.map(Ht=>Ht.id)),Ze=p.orderedSessions.filter(Ht=>Ie.has(Ht.id)&&!Ht.time?.archived),at=new Map,Lt=Wl({sessions:Ze,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return ed({sessions:Ze,getSessionLocation:Ht=>Lt.get(Ht)??null,getSessionNode:Ht=>{const Oe=or(p.childrenMap,Ht),ze=Lt.get(Ht.id);return at.set(Ht.id,ca(Oe,!1,ze?.groupDirectory??Ht.directory??null)),{...Oe,children:[],worktree:ze?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(Ht=>({...Ht,blockingBadgeSessionScopes:at.get(Ht.node.session.id)}))},[p.childrenMap,p.orderedSessions,p.rootSessions,P.bySessionId,j,R,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Kt=ue(Ie=>Ie.sessionWorkEnabled),Wt=os(Ie=>Ie.showWorkSection),rt=c.useMemo(()=>{if(!Kt||!Wt)return Ad;const Ie=p.orderedSessions.filter(Ze=>!Ze.parentID&&!Ze.time?.archived&&!va(Ze.directory)&&Ua(Ze));return Ie.length>0?Ie:Ad},[p.orderedSessions,Kt,Wt]),ut=c.useMemo(()=>new Set(rt.map(Ie=>Ie.id)),[rt]),pt=c.useMemo(()=>{if(rt.length===0)return Md;const Ie=Wl({sessions:[...rt],projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1}),Ze=new Map,at=new Map(rt.map(ze=>[ze.id,or(p.childrenMap,ze)])),Lt=new Map(rt.map(ze=>{const st=at.get(ze.id)??or(p.childrenMap,ze);Ze.set(ze.id,ca(st,!1,Ie.get(ze.id)?.groupDirectory??ze.directory??null));const Nt={...st,children:[],worktree:Ie.get(ze.id)?.worktree??null};return[ze.id,Nt]})),Vt=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ht=Vt?rt.filter(ze=>{const st=at.get(ze.id);return st?Mh(st,Vt):!1}):[...rt];return ed({sessions:Ht,getSessionLocation:ze=>Ie.get(ze)??null,getSessionNode:ze=>Lt.get(ze.id)??or(p.childrenMap,ze),query:""}).map(ze=>({...ze,blockingBadgeSessionScopes:Ze.get(ze.node.session.id)}))},[p.childrenMap,P.bySessionId,j,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,rt]),fe=c.useMemo(()=>{const Ie=new Map,Ze=new Map,at=new Map,Lt=new Map,Vt=new Set,Ht=(ze,st)=>{const Nt=st?.trim();ze&&Nt&&Ie.set(wx(ze,Nt),{directory:ze,branch:Nt})},Oe=ze=>{if(Ht(ot(ze.worktree?.path??null),ze.worktree?.branch),!t.isVSCode){for(const st of uf(ze.session))Ze.set(`${st.owner.toLowerCase()}/${st.repo.toLowerCase()}#${st.number}`,{owner:st.owner,repo:st.repo,number:st.number});for(const st of Va(ze.session))st.source==="github"?at.set(`${st.owner.toLowerCase()}/${st.repo.toLowerCase()}#${st.number}`,{owner:st.owner,repo:st.repo,number:st.number}):st.source==="linear"&&Vt.add(st.identifier.toUpperCase());for(const st of vx(ze.session))Lt.set(st.key,st)}ze.children.forEach(Oe)};return pt.forEach(ze=>Oe(ze.node)),R?($t.forEach(ze=>{(!ze.projectId||!m.collapsedProjects.has(ze.projectId))&&Oe(ze.node)}),{targets:Ie,linkedRefs:[...Ze.values()],linkedIssueRefs:[...at.values()],linearIdentifiers:[...Vt],gitlabRefs:[...Lt.values()]}):(Re.forEach(ze=>{m.collapsedProjects.has(ze.project.id)||ze.groups.forEach(st=>{if(st.isArchivedBucket||(st.sessions.forEach(Oe),st.isMain))return;const Nt=ot(st.directory??null);Ht(Nt,st.branch?.trim()||t.gitBranches.get(Nt||""))})}),{targets:Ie,linkedRefs:[...Ze.values()],linkedIssueRefs:[...at.values()],linearIdentifiers:[...Vt],gitlabRefs:[...Lt.values()]})},[Re,m.collapsedProjects,$t,R,t.gitBranches,t.isVSCode,pt]),lt=fe.targets,ft=c.useRef(null),mt=c.useMemo(()=>{const Ie=J2(lt.values()),Ze=JSON.stringify(Ie);return ft.current?.signature!==Ze&&(ft.current={signature:Ze,candidates:Ie}),ft.current.candidates},[lt]);c.useEffect(()=>{const Ie=mt;if(Ie.length===0)return;let Ze=!1;const at=Yt(),Lt=async(It,ts=o5)=>{const fs=Date.now(),us=new Map,Ce=Qe=>{const yt=us.get(Qe);if(yt)return yt;const Dt=qe(at,Qe,ht),zt=kn.scope(Qe),Jt=gr(()=>kn.read(zt,dt)).then(Ds=>{if(Ze||at!==Yt())return null;const ys=Ds.contexts[0],Is=ys&&_i(mn.getState().entries[Ln(ys)],ys).connected?[ys]:[];return Ye(at,Qe,ht,Dt,Is)?(Is.length===0&&Ne(Qe),Is):null});return us.set(Qe,Jt),Jt},V=await Promise.all(Ie.filter(Qe=>!It||Qe.directory===It).map(async Qe=>(await Ce(Qe.directory)??[]).map(Dt=>({...Qe,context:Dt}))));if(Ze||at!==Yt())return;const De=new Map,_e=new Map;for(const Qe of V.flat()){const yt=$u(Qe.context,Qe.branch);_e.set(yt,{context:Qe.context,branch:Qe.branch});const Dt=ls.getState().entries[yt],zt=Dt?.status?.changeRequest??Dt?.status?.pr,Jt=zt?.state,ys=!!zt&&!(Jt==="closed"||Jt==="merged"),Is=Math.max(Dt?.lastRefreshAt??0,Dt?.lastDiscoveryPollAt??0),Hs=!!(Dt?.isInitialStatusResolved&&!ys&&(!wt.current.has(yt)||fs-Is>=ts));(!Dt||!Dt.isInitialStatusResolved||Hs)&&(Hs&&wt.current.add(yt),De.has(yt)||De.set(yt,{context:Qe.context,branch:Qe.branch}))}_e.forEach((Qe,yt)=>{et(yt),ct(yt,{directory:Qe.context.directory,branch:Qe.branch,remoteName:Qe.context.primaryRemote,canShow:!0,identity:Qe.context,readContext:Qe.context,sourceControl:dt,authChecked:!0,connected:!0})}),De.size!==0&&await me([...De.values()],{silent:!0,markInitialResolved:!0})},Vt=[...new Set(Ie.map(It=>It.directory))].map(It=>kn.scope(It)),Ht=Vt.map(It=>{let ts=kn.snapshot(It);return kn.subscribe(It,()=>{const fs=kn.snapshot(It),us=ts.read!==null&&ts!==fs;ts=fs,us&&!Ze&&Lt(It.directory)})}),Oe=mn.subscribe((It,ts)=>{if(!(Ze||at!==Yt()||It.entries===ts.entries))for(const fs of Vt){const us=kn.snapshot(fs).contexts[0];if(!us)continue;const Ce=Ln(us);It.entries[Ce]!==ts.entries[Ce]&&Lt(fs.directory)}});Lt();const ze=new Set(Ie.map(It=>It.directory)),st=wn(It=>{!Ze&&It.type==="source-control-activity"&&ze.has(It.directory)&&Lt(It.directory,0)}),Nt=()=>{!Ze&&document.visibilityState==="visible"&&Lt()};return document.addEventListener("visibilitychange",Nt),()=>{Ze=!0,Oe(),Ht.forEach(It=>It()),st(),document.removeEventListener("visibilitychange",Nt);for(const It of Ie)$e(at,It.directory,ht)}},[qe,Ne,Ye,mt,et,me,$e,ct,dt,ht]);const Rt=c.useMemo(()=>Sx(tt,lt.values()),[tt,lt]),we=Ku(Rt),it=c.useMemo(()=>[...we,...fe.linkedRefs.map(Ie=>Sr("pull",Ie)),...fe.linkedIssueRefs.map(Ie=>Sr("issue",Ie)),...fe.gitlabRefs.map(Ie=>Ie.thread==="pull"?vr("pull",Ie):vr("issue",Ie)),...fe.linearIdentifiers.map(Ga)],[we,fe]);zu(it);const{groupStatusByKey:Q,bootstrapSnapshot:le}=Y4({childStores:Y,sections:jt,chatGroup:he,canGrantAccess:tu()});let Xe=null;C&&(Re.some(Ie=>Ie.project.id===I)?Xe=I:Re.some(Ie=>Ie.project.id===e.activeProjectId)?Xe=e.activeProjectId:Xe=Re[0]?.project.id??null);const Ae=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ue,collapsedGroups:m.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:Bt,expandedParents:xe,editingId:B,editingRowKey:ne,editTitle:te,sessionBatchSize:C&&!e.useGroupedSections?20:void 0,setEditingId:ee,setEditingRowKey:re,setEditTitle:W,toggleParent:Ee,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:de,setDeleteSessionConfirm:ce,startFolderRename:pe,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,folderRename:je,setFolderRenameDraft:U,clearFolderRename:Pe}),[p.pinnedSessionIds,r,o,m.collapsedGroups,Ue,Bt,te,B,ne,xe,je,U,Pe,pe,de,s.startSessionWorktreeMenuLoad,l,Ee,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,C]),Je=c.useMemo(()=>({showMoreGroupSessions:T,resetGroupSessionLimit:$,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:v}),[$,T,v,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),Fe=c.useMemo(()=>{const Ie=new Map;for(const Ze of jt)for(const at of Ze.groups){const Lt=Gn(Ze.project.id,at.directory);if(!Lt)continue;const Vt=er(at),Ht=Ie.get(Lt),Oe=[...new Set([...Ht?.scopeKeys??[],...Vt.map(st=>st.scopeKey)])],ze=p.hasAuthoritativeGlobalSessions&&Vt.every(st=>{const Nt=ot(st.directory);return!Nt||Y.getBootstrapState(Nt)==="complete"});Ie.set(Lt,{scopeKeys:Oe,complete:(Ht?.complete??!0)&&ze})}if(he){const Ze=Gn(null,he.directory);Ze&&Ie.set(Ze,{scopeKeys:er(he).map(at=>at.scopeKey),complete:p.hasAuthoritativeGlobalSessions})}return Ie},[le,he,Y,p.hasAuthoritativeGlobalSessions,jt]),gt=c.useMemo(()=>new Map([...A,...D]),[D,A]),bt=c.useMemo(()=>Jj({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:R?"timeline":"projects",sections:jt,authoritativeSections:Re,chatGroup:O?he:null,timelineItems:$t,workItems:pt,workSessionIds:ut,foldersMap:d,groupSearchDataByGroup:Ue,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:m.collapsedProjects,collapsedGroups:m.collapsedGroups,collapsedFolders:u,collapsedActivities:m.collapsedActivities,expandedParents:xe,visibleCountByContainer:gt,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:Bt,groupStatusByKey:Q,folderAuthorityByOwner:Fe,activeProjectId:e.activeProjectId,singleProjectMode:C&&!R,singleProjectId:Xe,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:C&&!e.useGroupedSections?20:void 0,runIndex:H}),[H,he,O,m.collapsedActivities,$t,R,pt,ut,u,p.pinnedSessionIds,xe,Fe,d,Ue,Q,jt,Re,m.collapsedGroups,m.collapsedProjects,Xe,Bt,C,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,gt]);c.useEffect(()=>{Be(bt.searchMatchCount)},[Be,bt.searchMatchCount]),c.useEffect(()=>{if(e.hasSessionSearchQuery)return;const Ie=Xt.getState().toggleFolderCollapse;for(const Ze of bt.rows)Ze.kind==="group-header"&&Ze.empty&&m.collapsedGroups.has(Ze.groupKey)?v(Ze.groupKey):Ze.kind==="folder-header"&&Ze.nodes.length===0&&Ze.subFolderCount===0&&u.has(Ze.folder.id)&&Ie(Ze.folder.id)},[u,m.collapsedGroups,bt.rows,v,e.hasSessionSearchQuery]);const Et=c.useMemo(()=>({rowModel:bt,sectionsForRender:jt,projectSections:Re,singleProjectMode:C,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:B,openSidebarMenuKey:q,setOpenSidebarMenuKey:oe,visibleSessionCountByGroup:A,collapsedActivityKeys:m.collapsedActivities,setCollapsedActivityKeys:S,visibleActivityCountByKey:D,setVisibleActivityCountByKey:E},groupProps:Ae}),[Ae,B,q,Re,jt,bt,t.projectRepoStatus,e.emptyState,e.searchEmptyState,A,D,m.collapsedActivities,S,C]),Ft=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:ae}),[ae,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder]),es=c.useMemo(()=>({group:Je,toggleProject:x,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,openNewWorktreeDialog:a.openNewWorktreeDialog,openWorktreesPage:a.openWorktreesPage,openProjectEditDialog:a.openProjectEditDialog,removeProject:a.removeProject,reorderProjects:a.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:X}),[Je,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,b,x,a.renderProjectStatusIndicator,X]);return n.jsxs(n.Fragment,{children:[n.jsx(q2,{}),n.jsx(rC,{projectSections:Re,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:P.bySessionId,handleSessionSelect:ie}),n.jsx(yC,{sortedSessions:p.orderedSessions,workSessions:rt,prefetchSession:G,children:n.jsxs(OC,{entries:bt.selectionEntries,descendantIds:bt.selectionDescendantIds,sessionsById:bt.sessionById,children:[n.jsx(B4,{getFolderScopesForProject:Ve,isInlineEditing:B!==null,startFolderRename:pe}),n.jsx("div",{className:"contents",onPointerEnter:Ie=>{Mt&&Ie.pointerType==="mouse"&&St(xt.current)},onPointerLeave:()=>St(null),children:n.jsx(k4,{model:Et,view:Ft,actions:es})})]})})]})},c5=t=>{const e=Ke.c(3),[s,r]=c.useState(t.view.isVisible);t.view.isVisible&&!s&&r(!0);let o;return e[0]!==t||e[1]!==s?(o=s?n.jsx(l5,{...t}):null,e[0]=t,e[1]=s,e[2]=o):o=e[2],o},sp=(t,e,s)=>{const r=new Set;for(const o of t){const i=ot(o.path);i&&r.add(i)}if(s?.includeWorktrees===!1)return r;for(const o of e.values())for(const i of o){const l=ot(i.path);l&&r.add(l)}return r},Od="oc.sessions.activeSessionByProject",d5=Xa(rn(),rn().min(1).catch("")),u5=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{Ti("react.session_sidebar_render"),Ss("ui.session_sidebar.render"),Ss(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Ss(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=vt(),[a,d]=c.useState(!1),[u,f]=c.useState(""),h=c.useCallback(()=>d(!0),[]),m=c.useCallback(()=>{f(""),d(!1)},[]),[g,b]=c.useState(0),v=c.useRef(null),x=c.useRef(null),[S,p]=c.useState(null),y=c.useMemo(()=>So(),[]),[w,j]=c.useState(new Map),k=ue(fe=>fe.isNewWorktreeDialogOpen),P=ue(fe=>fe.setNewWorktreeDialogOpen),[A,F]=c.useState(!1),D=c.useMemo(()=>{try{const fe=y.getItem(Od);if(!fe)return new Map;const lt=d5.safeParse(JSON.parse(fe));if(!lt.success)return new Map;const ft=new Map;return Object.entries(lt.data).forEach(([mt,Rt])=>{Rt&&ft.set(mt,Rt)}),ft}catch{return new Map}},[y]),E=c.useCallback(fe=>{try{y.setItem(Od,JSON.stringify(Object.fromEntries(fe.entries())))}catch{}},[y]),[T,$]=c.useState(new Map),O=gs(fe=>fe.homeDirectory),K=Zt(fe=>fe.projects),I=Zt(fe=>fe.activeProjectId),X=Zt(fe=>fe.removeProject),N=Zt(fe=>fe.setActiveProjectIdOnly),C=Zt(fe=>fe.updateProjectMeta),R=Zt(fe=>fe.reorderProjects),H=ue(fe=>fe.setSettingsDialogOpen),M=ue(fe=>fe.toggleHelpDialog),_=ue(fe=>fe.setAboutDialogOpen),B=ue(fe=>fe.setSessionSwitcherOpen),ee=ue(fe=>fe.setWorktreesPageProjectId),ne=ue(fe=>fe.notifyOnSubtasks),re=c.useMemo(()=>u.trim().toLowerCase(),[u]),te=re.length>0;_j({enabled:t,isSessionSearchOpen:a,openSessionSearch:h,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchContainerRef:v});const W=kx(t),q=c.useMemo(()=>Sn(),[]),oe=nt(fe=>fe.worktreeMetadata),de=nt(fe=>fe.availableWorktreesByProject),ce=nt(fe=>fe.openNewSessionDraft),je=c.useMemo(()=>sp(K,de,{includeWorktrees:!q}),[de,q,K]),be=c.useCallback(fe=>{ue.getState().closeMainSurfaces(),ce(fe),q&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[q,ce]),pe=mr(Zn(fe=>({checkForUpdates:fe.checkForUpdates,available:fe.available,runtimeType:fe.runtimeType,info:fe.info,downloading:fe.downloading,downloaded:fe.downloaded,installing:fe.installing,progress:fe.progress,error:fe.error,downloadUpdate:fe.downloadUpdate,restartToUpdate:fe.restartToUpdate}))),U=Yt(),Pe=c.useMemo(()=>`${U}|${K.map(fe=>`${fe.id}:${ot(fe.path)??""}`).join("|")}`,[K,U]),[xe,Ee]=c.useState(q?Pe:null),[L,ie]=c.useReducer(fe=>fe+1,0),G=!q&&xe!==Pe,[ae,ye]=c.useState(new Set),ge=c.useRef(ae);ge.current=ae;const Se=ns(fe=>fe.isConnected),ve=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let fe=!1;return(async()=>{const ft=U,mt=ns.getState().isConnected,Rt=Zt.getState().projects;if(nt.setState({worktreeDiscoveryByProject:new Map(Rt.map(Fe=>[ot(Fe.path)??Fe.path,"loading"]))}),Rt.length===0||q){fe||(ve.current={runtimeKey:null,revision:0,worktreesByProject:new Map},ye(new Set),Ee(Pe));return}const we=nt.getState().availableWorktreesByProject,it=dl({rawWorktreesByProjectRef:ve,publishedWorktreesByProject:we,runtimeKey:ft}),Q=it.revision,le=new Map(it.worktreesByProject),Xe=new Set;if(await gr(()=>Promise.all(Rt.map(async Fe=>{const gt=ot(Fe.path);if(gt)try{if(!(gn.getState().directories.get(gt)?.isGitRepo??await wu(gt))){le.delete(gt);return}const Ft=await ac({id:Fe.id,path:gt});if(fe)return;Ft.length===0?le.delete(gt):le.set(gt,Ft)}catch{Xe.add(gt)}}))),fe||Yt()!==ft)return;const Ae=new Set(Rt.map(Fe=>ot(Fe.path)).filter(Boolean));for(const Fe of le.keys())Ae.has(Fe)||le.delete(Fe);t3({rawWorktreesByProjectRef:ve,runtimeKey:ft,capturedRevision:Q,nextRawWorktreesByProject:le,publishedWorktreesByProject:we,partitionWorktreesByRegisteredProject:ic,projects:Rt,worktreeMapsEqual:oc,recordWorktreesSeen:Dd,publishTopology:Fe=>{nt.setState(Fe)},requestRediscovery:()=>{ie()},now:()=>Date.now()})&&(ye(Xe),nt.setState({worktreeDiscoveryByProject:new Map(Rt.map(Fe=>{const gt=ot(Fe.path)??Fe.path;return[gt,Xe.has(gt)?"error":"ready"]}))}),Ee(Pe),Xe.size>0&&!mt&&ns.getState().isConnected&&ie())})(),()=>{fe=!0}},[q,Pe,U,L]),c.useEffect(()=>{Se&&ge.current.size>0&&ie()},[Se]);const Te=c.useMemo(()=>pn(),[]),{isTablet:z}=Mn(),he=e||z,se=c.useMemo(()=>n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[n.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),n.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),Re=c.useMemo(()=>K.find(fe=>fe.id===S)??null,[K,S]),Ue=c.useCallback(fe=>{S&&C(S,{label:fe.label,icon:fe.icon,color:fe.color,iconBackground:fe.iconBackground,defaultAgent:fe.defaultAgent??null,defaultModel:fe.defaultModel??null,defaultVariant:fe.defaultVariant??null})},[S,C]),We=c.useCallback(()=>{P(!0)},[P]),He=c.useCallback(()=>{const fe=mr.getState();if(fe.available&&fe.info){F(!0);return}pe.checkForUpdates().then(()=>{const{available:lt,error:ft}=mr.getState();if(ft){Le.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:ft});return}if(!lt){Le.success(l("sessions.sidebar.updateCheck.latestVersion"));return}F(!0)})},[l,pe]),Be=c.useCallback(()=>{e&&B(!1),H(!0)},[e,B,H]),Y=pe.available&&(pe.runtimeType==="desktop"||pe.runtimeType==="web"),Me=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),Ge=c.useMemo(()=>K.flatMap(fe=>{const lt=ot(fe.path);return lt?[{id:fe.id,path:fe.path,label:fe.label,normalizedPath:lt,icon:fe.icon??void 0,color:fe.color??void 0,iconImage:fe.iconImage??void 0,iconBackground:fe.iconBackground??void 0,addedAt:fe.addedAt,lastOpenedAt:fe.lastOpenedAt,sidebarCollapsed:fe.sidebarCollapsed}]:[]}),[K]),Ve=c.useMemo(()=>Ge.map(fe=>fe.normalizedPath),[Ge]),dt=jx(Ve,t);l2({enabled:t,normalizedProjects:Ge,gitRepoStatus:dt,setProjectRepoStatus:j,setProjectRootBranches:$});const et=nt(fe=>fe.isLoading),ct=c.useRef(!1);I&&w.has(I)&&(ct.current=!!w.get(I));const me=os(fe=>fe.showArchivedSessions),Ne=os(fe=>fe.projectSortOrder),qe=os(fe=>fe.sidebarViewMode),Ye=q?"projects":qe,$e=Ye==="timeline"?"manual":Ne,tt=Zt(fe=>fe.manualProjectOrder),ht={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:l,isTablet:z,projects:K,activeProjectId:I,manualProjectOrder:tt,worktreeMetadata:oe,availableWorktreesByProject:de,gitBranches:W,gitRepoStatus:dt,updateStore:pe,showArchivedSessions:me,projectSortOrder:$e,projectRepoStatus:w,projectRootBranches:T,resolvedWorktreeTopologyKey:xe,unresolvedWorktreeProjectPaths:ae,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:S,updateDialogOpen:A},wt=c.useRef(null),Bt=wt.current;if(Bt){let fe=!1;for(const lt of Object.keys(ht))Object.is(Bt[lt],ht[lt])||(Ss(`ui.session_sidebar.source.${lt}`),fe=!0);fe||Ss("ui.session_sidebar.source.parent_or_context")}wt.current=ht;const kt=c.useMemo(()=>Fg(Ge,$e,tt),[Ge,$e,tt]),St=t2({isVSCode:q,projects:kt}),xt=c.useMemo(()=>n.jsx(G2,{query:u,showArchive:!q,resetSessionSearch:m}),[q,m,u]),Mt=q&&me,jt=!q,Wt=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-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",rt="h-4 w-4",ut=c.useMemo(()=>({projects:K,getCurrentProjects:()=>Zt.getState().projects,rawWorktreesByProjectRef:ve,getPublishedWorktreesByProject:()=>nt.getState().availableWorktreesByProject,resolveProject:fe=>Oi(fe),listProjectWorktrees:ac,partitionWorktreesByRegisteredProject:ic,worktreeMapsEqual:oc,recordWorktreesSeen:Dd,publishTopology:fe=>{nt.setState(fe)},getRuntimeKey:Yt,now:()=>Date.now()}),[K]),pt=c.useCallback(fe=>{const lt=Qh(fe,{projects:K,resolveProject:Oi});return e3(fe,{...ut,projectRootBranch:lt?T.get(lt.id)??null:null})},[T,K,ut]);return c.useEffect(()=>{if(q)return;const fe=lt=>{for(const ft of lt){const mt=ot(ft.path),Rt=Yt(),we=it=>{!mt||Yt()!==Rt||nt.setState(Q=>({worktreeDiscoveryByProject:new Map(Q.worktreeDiscoveryByProject).set(mt,it)}))};we("loading"),Yh(ft,null,ut).then(()=>{!mt||Yt()!==Rt||(we("ready"),ye(it=>{if(!it.has(mt))return it;const Q=new Set(it);return Q.delete(mt),Q}))}).catch(()=>{!mt||Yt()!==Rt||(we("error"),ye(it=>new Set(it).add(mt)))})}};return wn(lt=>{if(lt.type==="session-created"){const ft=Cx(lt.directory,Zt.getState().projects);if(!ft){ie();return}fe([ft]);return}lt.type==="worktree-changed"&&fe(Px(lt.directories))})},[q,ut]),n.jsx(Go,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:v,className:ke("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(y2,{hideDirectoryControls:o,showProjectDisplayControls:!q,showSectionControls:!q,handleOpenDirectoryDialog:Me,showSourceBoard:!e&&!q,headerActionIconClass:rt,headerActionButtonClass:Wt,isSessionSearchOpen:a,openSessionSearch:h,closeSessionSearch:m,sessionSearchInputRef:x,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:te,searchMatchCount:g,collapseAll:St.actions.collapseAll,expandAll:St.actions.expandAll}),n.jsx(c5,{topology:{projects:kt,availableWorktreesByProject:de,knownDirectories:je,isVSCode:q,worktreeMetadata:oe,gitBranches:W,projectRepoStatus:w,projectRootBranches:T,lastRepoStatus:ct.current},view:{isVisible:t,hasSessionSearchQuery:te,normalizedSessionSearchQuery:re,activeProjectId:I,showInlineArchived:Mt,useGroupedSections:jt,homeDirectory:O,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:Te,projectSortOrder:$e,sidebarViewMode:Ye,emptyState:se,searchEmptyState:xt,isSessionsLoading:et,isWorktreeTopologyLoading:G,unresolvedWorktreeProjectPaths:ae,projectView:St.state,onSearchMatchCountChange:b},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:m},alwaysShowActions:he,notifyOnSubtasks:ne,setActiveProjectIdOnly:N,setSessionSwitcherOpen:B,openNewSessionDraft:be,openNewWorktreeDialog:We,openWorktreesPage:fe=>{e&&B(!1),ee(fe)},openProjectEditDialog:p,removeProject:X,reorderProjects:R,startSessionWorktreeMenuLoad:pt,initialActiveSessionByProject:D,persistActiveSessionByProject:E,projectViewActions:St.actions}}),n.jsx(H2,{onOpenSettings:Be,onOpenShortcuts:M,onOpenAbout:()=>_(!0),onOpenUpdate:He,showRuntimeButtons:!q,showUpdateButton:Y}),n.jsx(Ca,{open:A,onOpenChange:F,info:pe.info,downloading:pe.downloading,downloaded:pe.downloaded,installing:pe.installing,progress:pe.progress,error:pe.error,onDownload:pe.downloadUpdate,onRestart:pe.restartToUpdate,runtimeType:pe.runtimeType}),n.jsx(m2,{open:!!Re,onOpenChange:fe=>{fe||p(null)},project:Re,onSave:Ue}),n.jsx(Ex,{open:k,onOpenChange:P,onWorktreeCreated:fe=>{ue.getState().closeMainSurfaces(),e&&B(!1),ce({directoryOverride:fe,preserveDirectoryOverride:!0})}})]})})},f5=c.memo(u5),Zs=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Os=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},h5=()=>{const{t}=vt(),{git:e,sourceControl:s}=Ws(),[r,o]=c.useState(!1),[i,l]=c.useState(null),[a,d]=c.useState([]),[u,f]=c.useState(!1),[h,m]=c.useState(!1),[g,b]=c.useState(!1),[v,x]=c.useState(!1),[S,p]=c.useState(new Set),y=nt(G=>G.getWorktreeMetadata),w=nt(G=>G.newSessionDraft),j=nt(G=>G.setNewSessionDraftTarget),k=nt(G=>G.setDraftBootstrapPendingDirectory),P=Nx,A=Dx,F=nt(G=>G.deleteSessions),D=nt(G=>G.archiveSessions),E=ue(G=>G.showDeletionDialog),T=ue(G=>G.setShowDeletionDialog),$=gs(G=>G.currentDirectory),O=gs(G=>G.homeDirectory),K=Zt(G=>G.projects),I=Zt(G=>G.activeProjectId),{isMobile:X,isTablet:N,hasTouchInput:C}=Mn(),R=X||N||C,H=c.useMemo(()=>{const ae=(I?K.find(ye=>ye.id===I)??null:null)?.path??$;return Os(ae)},[I,$,K]),M=c.useCallback(G=>{const ye=Os(G.projectDirectory)||H;return{id:(K.find(Se=>Os(Se.path)===ye)??null)?.id??`path:${ye}`,path:ye}},[H,K]),_=v&&S.size>0,B=c.useMemo(()=>{const G=i?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!!G.status?.upstream?.split("/")[0]?.trim():a.length>0&&a.every(({metadata:ae})=>typeof ae.branch=="string"&&ae.branch.trim().length>0&&!!ae.status?.upstream?.split("/")[0]?.trim())},[i?.worktree,a]),ee=i?.mode==="worktree",ne=g||!ee||!B,re=g||!ee,te=c.useCallback(G=>{l({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),W=c.useCallback(()=>{l(null),d([]),f(!1),m(!1),b(!1),x(!1),p(new Set)},[]),q=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const Se=G.sessions[0];await P(Se.id)?Le.success(t("sessions.sidebar.session.delete.success")):Le.error(t("sessions.sidebar.session.delete.error"));return}const ae=G.sessions.map(Se=>Se.id),{deletedIds:ye,failedIds:ge}=await F(ae);if(ye.length>0){const Se=ge.length>0?ge.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ge.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ge.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;Le.success(ye.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ye.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ye.length}),{description:Zs(Se)})}ge.length>0&&Le.error(ge.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ge.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ge.length}),{description:Zs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[P,F,t]);c.useEffect(()=>xn.onDirectoryRequest(()=>{o(!0)}),[]),c.useEffect(()=>{if(!i){d([]),f(!1),m(!1),x(!1),p(new Set);return}const G=i.sessions.map(ge=>{const Se=y(ge.id);return Se?{session:ge,metadata:Se}:null}).filter(ge=>!!ge);d(G),f(!1),x(!1),p(new Set);const ae=new Map;if(i.worktree?.path&&ae.set(Os(i.worktree.path),i.worktree),G.forEach(({metadata:ge})=>{ge.path&&ae.set(Os(ge.path),ge)}),ae.size===0){x(!0);return}let ye=!1;return(async()=>{const ge=new Map,Se=new Set;await Promise.all(Array.from(ae.entries()).map(async([ve,Te])=>{try{const z=await lc(Te.path);ge.set(ve,z),z?.isDirty&&Se.add(ve)}catch{Te.status&&(ge.set(ve,Te.status),Te.status.isDirty&&Se.add(ve))}})).catch(ve=>{console.warn("Failed to inspect worktree status before deletion:",ve)}),!ye&&(p(Se),x(!0),l(ve=>{if(!ve?.worktree?.path)return ve;const Te=Os(ve.worktree.path),z=ge.get(Te);if(!z)return ve;const he=ve.worktree.status;return he?.isDirty===z.isDirty&&he?.ahead===z.ahead&&he?.behind===z.behind&&he?.upstream===z.upstream?ve:{...ve,worktree:{...ve.worktree,status:z}}}),d(ve=>ve.map(Te=>{const z=Os(Te.metadata.path),he=ge.get(z);return he?{session:Te.session,metadata:{...Te.metadata,status:he}}:Te})))})(),()=>{ye=!0}},[i,y]),c.useEffect(()=>{B||f(!1)},[B]);const oe=c.useCallback(async(G,ae,ye)=>{const ge=u&&B,Se=M(G),ve=Os(G.path),Te=Os(Se.path);try{await ku(Se,G,{deleteRemoteBranch:ge,deleteLocalBranch:ae,remoteName:G.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const z=Os(w?.directoryOverride);return w?.open&&ve&&z===ve&&Te&&(k(null),j({projectId:Se.id,directoryOverride:Te},{force:!0})),Os($)===ve&&Te&&gs.getState().setDirectory(Te,{showOverlay:!1}),!0}catch(z){return Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:fi(G)}),{id:ye,description:Zs(z instanceof Error?z.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[B,$,u,M,e,w?.directoryOverride,w?.open,k,j,s,t]),de=c.useCallback((G,ae,ye)=>{const ge=u&&B,Se=Le.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:fi(G)}));return Rx(G.path),(async()=>{try{const ve=await _g({sessionIds:ae,removeWorktree:()=>oe(G,ye,Se),archiveSessions:async he=>he.length===1?await A(he[0])?{archivedIds:he,failedIds:[]}:{archivedIds:[],failedIds:he}:D(he)});if(!ve.removed)return;const Te=t(ge?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Le.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:fi(G)}),{id:Se,description:Zs(Te)});const{failedIds:z}=ve.archive;z.length>0&&Le.error(z.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:z.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:z.length}),{description:Zs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(ve){Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:Se,description:Zs(ve instanceof Error?ve.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{Ix(G.path)}})()},[A,D,B,u,oe,t]),ce=c.useRef(new Set),je=c.useCallback(async(G,ae)=>{const ye=Os(G.path);if(!ce.current.has(ye)){ce.current.add(ye);try{const ge=await lc(G.path).catch(()=>{});if(!Tx(ge)){te({sessions:ae,mode:"worktree",worktree:G});return}await de(G,ae.map(Se=>Se.id),!0)}finally{ce.current.delete(ye)}}},[te,de]);c.useEffect(()=>xn.onDeleteRequest(G=>{if(!E&&(G.mode??"session")==="session"){q(G);return}if(G.mode==="worktree"&&G.skipDialogIfSafe&&G.worktree){je(G.worktree,G.sessions);return}te(G)}),[te,E,q,je]);const be=c.useCallback(async()=>{if(i){b(!0);try{if(ee){const G=i.worktree??a[0]?.metadata;if(!G){Le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:Zs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),b(!1);return}de(G,i.sessions.map(ae=>ae.id),h),W();return}if(i.sessions.length===1){const G=i.sessions[0];if(!await P(G.id)){Le.error(t("sessions.sidebar.session.delete.error")),b(!1);return}Le.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const G=i.sessions.map(ge=>ge.id),{deletedIds:ae,failedIds:ye}=await F(G);if(ae.length>0){const ge=ye.length>0?ye.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ye.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ye.length}):i.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:i.dateLabel}):void 0;Le.success(ae.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:ae.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:ae.length}),{description:Zs(ge),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(ye.length>0&&(Le.error(ye.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ye.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ye.length}),{description:Zs(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),ae.length===0)){b(!1);return}}W()}finally{b(!1)}}},[i,a,h,P,F,W,ee,de,t]),pe=i?.worktree??a[0]?.metadata??null;let U="";if(i?.mode==="worktree"){const G=i.sessions.length;G===0?U=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):G===1?U=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:G}):U=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:G})}else if(i){const G=i.sessions.length;G===1?U=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):U=i.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:G,dateLabel:i.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:G})}const Pe=i?n.jsxs("div",{className:ke(ee?"space-y-3":"space-y-2"),children:[i.sessions.length>0&&n.jsxs("div",{className:ke(ee?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ee&&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:ke(ee?"mt-2 space-y-1":"space-y-0.5"),children:[i.sessions.slice(0,5).map(G=>n.jsxs("li",{className:ke(ee?"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:ke(!ee&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"oc-ui-start-align truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),i.sessions.length>5&&n.jsx("li",{className:ke(ee?"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})})]})]}),ee?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")}),pe?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:pe.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:pe?Qn(pe.path,O):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),_&&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,xe=ee?B?n.jsxs("button",{type:"button",onClick:()=>{ne||f(G=>!G)},disabled:ne,"aria-pressed":u,className:ke("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ne?"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,Ee=ee?n.jsxs("button",{type:"button",onClick:()=>{re||m(G=>!G)},disabled:re,"aria-pressed":h,className:ke("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",re?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[h?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,L=ee?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:[Ee,xe]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ct,{variant:"ghost",onClick:W,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",onClick:be,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:()=>T(!E),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":!E,children:[E?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(Ct,{variant:"ghost",onClick:W,disabled:g,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(Ct,{variant:"destructive",onClick:be,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")})]})]}),ie=ee?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:[R?n.jsx(Mx,{open:!!i,onClose:()=>{g||W()},title:ie,footer:n.jsx("div",{className:"flex justify-end gap-2",children:L}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[U&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:U}),Pe]})}):n.jsx(Ks,{open:!!i,onOpenChange:G=>{if(!G){if(g)return;W()}},children:n.jsxs(zs,{className:ke(ee?"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(Ys,{children:[n.jsxs(Us,{className:ke(ee&&"flex items-center gap-2"),children:[ee&&n.jsx(Z,{name:"delete-bin",className:"h-5 w-5"}),ie]}),U&&n.jsx(qs,{children:U})]}),n.jsx("div",{className:ke(ee&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Pe}),n.jsx(yn,{className:"mt-2 gap-2 pt-1 pb-1",children:L})]})}),n.jsx(Lg,{open:r,onOpenChange:o})]})};function Qo(t,e,s){const[r,o]=c.useState(null),i=c.useRef(s);return i.current=s,c.useEffect(()=>{if(!t||r)return;let l=!1;return Ax(e).then(a=>{l||o(()=>a)},a=>{console.error("[on-demand] failed to load component",a),l||i.current()}),()=>{l=!0}},[r,e,t]),r}function p5(t){const e=[],s=(r,o)=>{const i=ot(r);!i||e.some(l=>l.directory===i)||e.push({directory:i,priority:"selected",reason:o})};return s(t.currentDirectory,"current-directory"),s(t.currentSessionDirectory,"selected-session"),e}const m5=new Map,g5=t=>{const e=Ke.c(23),{isVSCode:s}=t,r=Nr(),o=Zt(b5),i=gs(y5),l=nt(x5);let a;e[0]!==s?(a=F=>s?m5:F.availableWorktreesByProject,e[0]=s,e[1]=a):a=e[1];const d=nt(a),u=!s;let f;e[2]!==d||e[3]!==o||e[4]!==u?(f=sp(o,d,{includeWorktrees:u}),e[2]=d,e[3]=o,e[4]=u,e[5]=f):f=e[5];const h=f,m=ws(S5),g=ws(v5),b=ws(w5),v=`session-list-sync:${c.useId()}`;let x,S;e[6]!==v||e[7]!==r||e[8]!==i||e[9]!==l?(x=()=>(r.setBootstrapDemand(v,p5({currentDirectory:i,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(v)),S=[v,r,i,l],e[6]=v,e[7]=r,e[8]=i,e[9]=l,e[10]=x,e[11]=S):(x=e[10],S=e[11]),c.useEffect(x,S);const p=c.useRef(null);let y,w;e[12]!==s||e[13]!==h?(y=()=>{const F=new Set(h),D=p.current;p.current=F;const E=D?[...F].filter(T=>!D.has(T)):s?[...F]:[];E.length&&Ra(E,Wi())},w=[s,h],e[12]=s,e[13]=h,e[14]=y,e[15]=w):(y=e[14],w=e[15]),c.useEffect(y,w);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],c.useEffect(k5,j);let k;e[17]!==g||e[18]!==m?(k=[...m,...g],e[17]=g,e[18]=m,e[19]=k):k=e[19];const P=k;let A;e[20]!==P||e[21]!==b?(A={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:P},e[20]=P,e[21]=b,e[22]=A):A=e[22],$g(A)};function b5(t){return t.projects}function y5(t){return t.currentDirectory}function x5(t){return t.currentSessionDirectory}function S5(t){return t.activeSessions}function v5(t){return t.archivedSessions}function w5(t){return t.status==="ready"}function k5(){let t=null,e=!1;const s=new Set,r=wn(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(),yf(Wi());return}const i=[...s];s.clear(),i.length&&Ra(i,Wi())},500)});return()=>{t&&clearTimeout(t),r()}}const j5=()=>ss(()=>import("./SettingsWindow-Dfb_RFpD.js"),__vite__mapDeps([144,1,2,9,3,4,5,6,7,8,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,145,84,146,126,127,128,129,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,140,133,149])).then(t=>t.SettingsWindow),C5=()=>ss(()=>import("./CommandPalette-B6r6DPF9.js"),__vite__mapDeps([150,1,2,9,3,4,5,6,7,8,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,149,84,122,123,124])).then(t=>t.CommandPalette),P5=()=>ss(()=>import("./HelpDialog-Dxc2yneu.js"),__vite__mapDeps([151,1,2,9,3,4,5,6,7,8,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),E5=()=>ss(()=>import("./OpenCodeStatusDialog-DH7dJ6MH.js"),__vite__mapDeps([152,1,2,9,3,4,5,6,7,8,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),N5=()=>ss(()=>import("./RunOverview-ZuFZvDcu.js"),__vite__mapDeps([153,1,2,9,3,4,5,6,7,8,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),R5=()=>ss(()=>import("./ScheduledTasksDialog-UKXFFI91.js"),__vite__mapDeps([154,1,2,9,3,4,5,6,7,8,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,142,155,156])).then(t=>t.ScheduledTasksDialog),D5=()=>ss(()=>import("./ArchiveView-DJo1Bpw_.js"),__vite__mapDeps([157,1,2,9,3,4,5,6,7,8,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),I5=()=>ss(()=>import("./UsageStatsView-C63Emjfj.js"),__vite__mapDeps([158,1,2,9,3,4,5,6,7,8,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),T5=()=>ss(()=>import("./SourceBoardView-BjaL0nKs.js"),__vite__mapDeps([159,1,2,9,3,4,5,6,7,8,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),M5=()=>ss(()=>import("./WorktreesView-hcm8Eb_C.js"),__vite__mapDeps([160,1,2,9,3,4,5,6,7,8,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),A5=()=>ss(()=>import("./SpacesView-D3a9bCzn.js"),__vite__mapDeps([161,1,2,9,3,4,5,6,7,8,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,162,84])).then(t=>t.SpacesView),O5=()=>ss(()=>import("./SpaceAccessDialog-XzHRmIdT.js"),__vite__mapDeps([163,1,2,9,3,4,5,6,7,8,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,164])).then(t=>t.SpaceAccessDialog),B5=()=>ss(()=>import("./SpaceApplyDialog-CxX9mrzT.js"),__vite__mapDeps([165,1,2,9,3,4,5,6,7,8,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,166])).then(t=>t.SpaceApplyDialog),F5=()=>ss(()=>import("./SpaceSetupOutput-CDZvJCf_.js"),__vite__mapDeps([167,1,2,9,3,4,5,6,7,8,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,164])).then(t=>t.SpaceSetupOutputDialog),Pn=()=>ue.getState().closeMainSurfaces(),Es=t=>{const e=Ke.c(2),{needed:s,load:r,onFailure:o}=t,i=Qo(s,r,o);let l;return e[0]!==i?(l=i?n.jsx(i,{}):null,e[0]=i,e[1]=l):l=e[1],l},np=c.memo(t=>{const e=Ke.c(7),{isMobile:s}=t,r=ue(L5);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(wS,{}),e[0]=o):o=e[0];let i;e[1]!==r?(i=n.jsx(f5,{isVisible:r}),e[1]=r,e[2]=i):i=e[2];let l;return e[3]!==s||e[4]!==r||e[5]!==i?(l=n.jsx(vS,{isOpen:r,isMobile:s,className:"border-border",topBar:o,children:i}),e[3]=s,e[4]=r,e[5]=i,e[6]=l):l=e[6],l});np.displayName="LeftSidebar";const _5=()=>{const t=Ke.c(101);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],g5(e),zg();const s=ue($5),r=ue(z5),o=ue(K5),i=ue(W5);let l;t[1]!==i?(l=()=>i(!1),t[1]=i,t[2]=l):l=t[2];const a=Qo(o,j5,l),d=ue(H5),u=ue(V5),f=ue(G5),h=ue(U5),m=ue(q5),g=ue(Y5),b=ue(X5),v=ue(Q5),x=ue(Z5),S=ue(J5),p=$s(eP),y=$s(tP),w=$s(sP),j=ue(nP),k=Ju();let P;if(t[3]!==k||t[4]!==j){let Me;t[6]!==j?(Me=Ge=>Ge.id===j,t[6]=j,t[7]=Me):Me=t[7],P=k.find(Me),t[3]=k,t[4]=j,t[5]=P}else P=t[5];const A=P;let F,D;t[8]!==A||t[9]!==j?(F=()=>{j&&!A&&ue.getState().setOpenGuestPage(null)},D=[j,A],t[8]=A,t[9]=j,t[10]=F,t[11]=D):(F=t[10],D=t[11]),c.useEffect(F,D);let E;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=[],t[12]=E):E=t[12],c.useEffect(oP,E);let T;t[13]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[13]=T):T=t[13],c.useEffect(iP,T);const $=u||f||h||m||!!g||b||d||!!A;let O,K;t[14]!==$?(O=()=>{xf($)},K=[$],t[14]=$,t[15]=O,t[16]=K):(O=t[15],K=t[16]),c.useLayoutEffect(O,K);let I;t[17]===Symbol.for("react.memo_cache_sentinel")?(I=[],t[17]=I):I=t[17],c.useEffect(lP,I);let X;t[18]===Symbol.for("react.memo_cache_sentinel")?(X=[],t[18]=X):X=t[18],c.useEffect(dP,X);const{isMobile:N}=Mn();Kg();let C,R;t[19]!==N||t[20]!==r?(C=()=>{ue.getState().isMobile!==N&&r(N)},R=[N,r],t[19]=N,t[20]=r,t[21]=C,t[22]=R):(C=t[21],R=t[22]),c.useEffect(C,R);let H;t[23]!==v?(H=n.jsx(Es,{needed:v,load:C5,onFailure:uP}),t[23]=v,t[24]=H):H=t[24];let M;t[25]!==x?(M=n.jsx(Es,{needed:x,load:P5,onFailure:fP}),t[25]=x,t[26]=M):M=t[26];let _;t[27]!==S?(_=n.jsx(Es,{needed:S,load:E5,onFailure:hP}),t[27]=S,t[28]=_):_=t[28];let B,ee;t[29]===Symbol.for("react.memo_cache_sentinel")?(B=n.jsx(Wg,{}),ee=n.jsx(h5,{}),t[29]=B,t[30]=ee):(B=t[29],ee=t[30]);let ne;t[31]!==p||t[32]!==y||t[33]!==w||t[34]!==s?(ne=s?n.jsxs(n.Fragment,{children:[n.jsx(Es,{needed:p,load:O5,onFailure:pP}),n.jsx(Hg,{}),n.jsx(Es,{needed:y,load:B5,onFailure:mP}),n.jsx(Vg,{}),n.jsx(Es,{needed:w,load:F5,onFailure:gP})]}):null,t[31]=p,t[32]=y,t[33]=w,t[34]=s,t[35]=ne):ne=t[35];let re;t[36]===Symbol.for("react.memo_cache_sentinel")?(re=n.jsx(kS,{}),t[36]=re):re=t[36];let te;t[37]!==N?(te=n.jsx(np,{isMobile:N}),t[37]=N,t[38]=te):te=t[38];let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(SS,{}),t[39]=W):W=t[39];let q;t[40]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(Si,{zone:"left"}),t[40]=q):q=t[40];const oe=$&&"invisible";let de;t[41]!==oe?(de=ke("absolute inset-0",oe),t[41]=oe,t[42]=de):de=t[42];const ce=!o&&!$;let je;t[43]!==ce?(je=n.jsx(bs,{children:n.jsx(du,{active:ce})}),t[43]=ce,t[44]=je):je=t[44];let be;t[45]!==de||t[46]!==je?(be=n.jsx("div",{className:de,children:je}),t[45]=de,t[46]=je,t[47]=be):be=t[47];let pe;t[48]!==d?(pe=n.jsx(bs,{children:n.jsx(Es,{needed:d,load:N5,onFailure:Pn})}),t[48]=d,t[49]=pe):pe=t[49];let U;t[50]!==u?(U=n.jsx(bs,{children:n.jsx(Es,{needed:u,load:R5,onFailure:Pn})}),t[50]=u,t[51]=U):U=t[51];let Pe;t[52]!==f?(Pe=n.jsx(bs,{children:n.jsx(Es,{needed:f,load:D5,onFailure:Pn})}),t[52]=f,t[53]=Pe):Pe=t[53];let xe;t[54]!==h?(xe=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(bs,{children:n.jsx(Es,{needed:!0,load:I5,onFailure:Pn})})}),t[54]=h,t[55]=xe):xe=t[55];let Ee;t[56]!==m?(Ee=n.jsx(Es,{needed:m,load:T5,onFailure:Pn}),t[56]=m,t[57]=Ee):Ee=t[57];const L=!!g;let ie;t[58]!==L?(ie=n.jsx(bs,{children:n.jsx(Es,{needed:L,load:M5,onFailure:Pn})}),t[58]=L,t[59]=ie):ie=t[59];let G;t[60]!==b?(G=b?n.jsx(bs,{children:n.jsx(Es,{needed:!0,load:A5,onFailure:Pn})}):null,t[60]=b,t[61]=G):G=t[61];let ae;t[62]!==A?(ae=A&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(bs,{children:n.jsx(Ox,{mode:`plugin:${A.id}`,surface:"page",item:null,onDismiss:bP})})}),t[62]=A,t[63]=ae):ae=t[63];let ye;t[64]!==be||t[65]!==pe||t[66]!==U||t[67]!==Pe||t[68]!==xe||t[69]!==Ee||t[70]!==ie||t[71]!==G||t[72]!==ae?(ye=n.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[be,pe,U,Pe,xe,Ee,ie,G,ae]}),t[64]=be,t[65]=pe,t[66]=U,t[67]=Pe,t[68]=xe,t[69]=Ee,t[70]=ie,t[71]=G,t[72]=ae,t[73]=ye):ye=t[73];let ge;t[74]===Symbol.for("react.memo_cache_sentinel")?(ge=n.jsx(Si,{zone:"bottom"}),t[74]=ge):ge=t[74];let Se;t[75]!==ye?(Se=n.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden","data-workspace-chat":"true",children:[ye,ge]}),t[75]=ye,t[76]=Se):Se=t[76];let ve,Te,z,he;t[77]===Symbol.for("react.memo_cache_sentinel")?(ve=n.jsx(Si,{zone:"right"}),Te=n.jsx(qk,{}),z=n.jsx(Qk,{}),he=n.jsx(tj,{}),t[77]=ve,t[78]=Te,t[79]=z,t[80]=he):(ve=t[77],Te=t[78],z=t[79],he=t[80]);let se;t[81]!==Se?(se=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:[q,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:[Se,ve,Te,z,he]})]})}),t[81]=Se,t[82]=se):se=t[82];let Re;t[83]===Symbol.for("react.memo_cache_sentinel")?(Re=n.jsx("div",{"data-page-scroll-lock":"true",children:n.jsx(bs,{children:n.jsx(vj,{})})}),t[83]=Re):Re=t[83];let Ue;t[84]===Symbol.for("react.memo_cache_sentinel")?(Ue=n.jsx(bs,{children:n.jsx(g1,{})}),t[84]=Ue):Ue=t[84];let We;t[85]!==se?(We=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[W,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[se,Re,Ue]})]}),t[85]=se,t[86]=We):We=t[86];let He;t[87]!==te||t[88]!==We?(He=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[te,We]}),t[87]=te,t[88]=We,t[89]=He):He=t[89];let Be;t[90]!==a||t[91]!==o||t[92]!==i?(Be=a?n.jsx(a,{open:o,onOpenChange:i}):null,t[90]=a,t[91]=o,t[92]=i,t[93]=Be):Be=t[93];let Y;return t[94]!==H||t[95]!==M||t[96]!==_||t[97]!==ne||t[98]!==He||t[99]!==Be?(Y=n.jsx(Gg,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[H,M,_,B,ee,ne,re,He,Be]})}),t[94]=H,t[95]=M,t[96]=_,t[97]=ne,t[98]=He,t[99]=Be,t[100]=Y):Y=t[100],Y};function L5(t){return t.isSidebarOpen}function $5(t){return t.isolatedSpacesEnabled}function z5(t){return t.setIsMobile}function K5(t){return t.isSettingsDialogOpen}function W5(t){return t.setSettingsDialogOpen}function H5(t){return t.runOverviewKey!==null}function V5(t){return t.isScheduledTasksDialogOpen}function G5(t){return t.isArchivePageOpen}function U5(t){return t.isUsageStatsPageOpen}function q5(t){return t.isSourceBoardOpen}function Y5(t){return t.worktreesPageProjectId}function X5(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function Q5(t){return t.isCommandPaletteOpen}function Z5(t){return t.isHelpDialogOpen}function J5(t){return t.isOpenCodeStatusDialogOpen}function eP(t){return t.accessDialog!==null}function tP(t){return t.applyDialog!==null}function sP(t){return t.setupOutputDialog!==null}function nP(t){return t.openGuestPageId}function rP(){return ue.getState().setOpenGuestPage(null)}function oP(){return Bo(rP)}function iP(){return m1()}function aP(){return xf(!1)}function lP(){return aP}function cP(){return ue.getState().closeMainSurfaces()}function dP(){const t=cP,e=nt.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 uP(){return ue.getState().setCommandPaletteOpen(!1)}function fP(){return ue.getState().setHelpDialogOpen(!1)}function hP(){return ue.getState().setOpenCodeStatusDialogOpen(!1)}function pP(){return $s.getState().closeAccessDialog()}function mP(){return $s.getState().closeApplyDialog()}function gP(){return $s.getState().closeSetupOutputDialog()}function bP(){return ue.getState().setOpenGuestPage(null)}const rp=12,yP=[{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"}],xP=t=>{const e=Ke.c(18),{isActive:s,burstKey:r,className:o,durationMs:i,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=i===void 0?900:i,f=l===void 0?yP:l,h=ds.useRef(!1);let m,g;e[0]!==s||e[1]!==a?(m=()=>{!s&&h.current&&a?.(),s&&(h.current=!0)},g=[s,a],e[0]=s,e[1]=a,e[2]=m,e[3]=g):(m=e[2],g=e[3]),ds.useEffect(m,g);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:rp},SP),e[4]=b):b=e[4];const v=b;if(!s)return null;let x;e[5]!==o?(x=ke("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=x):x=e[6];let S;if(e[7]!==d||e[8]!==f||e[9]!==u){let y;e[11]!==d||e[12]!==u?(y=w=>{const j={"--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:j,children:v.map((k,P)=>{const A=k.x*w.radius,F=k.y*w.radius,D={"--translate-x":`${A}px`,"--translate-y":`${F}px`,"--particle-delay":`${k.delay}ms`,color:`var(${w.colorVar})`};return n.jsx("span",{className:"firework-particle",style:D},`${w.id}-${P}-${d}`)})},`${w.id}-${d}`)},e[11]=d,e[12]=u,e[13]=y):y=e[13],S=f.map(y),e[7]=d,e[8]=f,e[9]=u,e[10]=S}else S=e[10];let p;return e[14]!==d||e[15]!==x||e[16]!==S?(p=n.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:S}),e[14]=d,e[15]=x,e[16]=S,e[17]=p):p=e[17],p};function SP(t,e){const s=Math.PI*2*e/rp;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const vP=t=>{const e=Ke.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[l,a]=ds.useState(i),d=ds.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const f=u;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{f(),a(wP)},e[4]=h):h=e[4];const m=h;let g;e[5]!==o?(g=()=>{f(),a(kP),d.current=window.setTimeout(()=>{a(jP),d.current=null},o)},e[5]=o,e[6]=g):g=e[6];const b=g;let v,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>f(),x=[f],e[7]=v,e[8]=x):(v=e[7],x=e[8]),ds.useEffect(v,x);let S;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(S={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:m},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=S):S=e[12],S};function wP(t){return t.isActive?{...t,isActive:!1}:t}function kP(t){return{isActive:!0,cycle:t.cycle+1}}function jP(t){return t.isActive?{...t,isActive:!1}:t}const op=c.createContext(void 0),CP=t=>{const e=Ke.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:l}=vP();let a;e[0]!==l||e[1]!==i?(a={triggerFireworks:i,dismissFireworks:l},e[0]=l,e[1]=i,e[2]=a):a=e[2];const d=a;let u;e[3]!==o||e[4]!==r?(u=n.jsx(xP,{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]!==d?(f=n.jsxs(op.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},tN=()=>{const t=c.useContext(op);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ga="openchamber_requests_in_flight",ip=1e3,PP=300*1e3,Oo=Math.ceil(PP/ip),EP=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ga)==="1"}catch{return!1}},ap=()=>({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 NP=1;const RP=(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))},DP=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},lp=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},qn=(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)},IP=()=>{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=NP++;RP(i,Date.now());try{return await e(r,o)}finally{DP(i)}};window.fetch=s},Bd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},ur=t=>{t.length>Oo&&t.splice(0,t.length-Oo)},TP=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=lp(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(qn(e,50)),t.p90Samples.push(qn(e,90)),t.p99Samples.push(qn(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,ur(t.samples),ur(t.p50Samples),ur(t.p90Samples),ur(t.p99Samples),ur(t.maxSamples),t.lastSampleAt=Date.now()},MP=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(TP,ip))},Fd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},_d=t=>{if(!(typeof window>"u"))try{if(t){Fd(),Bd(),window.localStorage.setItem(ga,"1"),window.__openchamberRequestsInFlight__=ap(),IP(),MP();return}window.localStorage.removeItem(ga),Fd(),Bd(),delete window.__openchamberRequestsInFlight__}catch{}},sN=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=ap();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},nN=()=>{if(typeof window>"u")return Ld();const t=window.__openchamberRequestsInFlight__;if(!EP()||!t)return Ld();const e=lp(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:qn(e,50),ageP90:qn(e,90),ageP99:qn(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:Oo}},Ld=()=>({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:Oo}),AP=()=>{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()??"":""},OP=async()=>{const t=AP()||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")},$d="openchamber:menu-action",Di="openchamber:check-for-updates",BP=t=>{const e=nt(S=>S.openNewSessionDraft),s=ue(S=>S.toggleCommandPalette),r=ue(S=>S.setCommandPaletteOpen),o=ue(S=>S.toggleHelpDialog),i=ue(S=>S.toggleSidebar),l=ue(S=>S.setSessionSwitcherOpen),a=ue(S=>S.setSettingsDialogOpen),d=ue(S=>S.setAboutDialogOpen),u=mr(S=>S.checkForUpdates),{setThemeMode:f}=Pr(),h=c.useRef(!1),m=c.useCallback(()=>{h.current||(h.current=!0,u().then(()=>{const{available:S,error:p}=mr.getState();if(p){Le.error("Failed to check for updates",{description:p});return}S||Le.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[u]),g=c.useCallback(()=>{xn.requestDirectoryDialog()},[]),b=c.useCallback(S=>{const p=Bx();if(p.length===0)return;const y=nt.getState().currentSessionId,w=p.findIndex(P=>P.id===y);let j=S>0?0:p.length-1;w>=0&&(j=(w+S+p.length)%p.length);const k=p[j];k&&(l(!1),nt.getState().setCurrentSession(k.id))},[l]),v=c.useCallback(S=>{const{activeProjectId:p,projects:y,setActiveProject:w}=Zt.getState();if(y.length===0)return;const j=y.findIndex(A=>A.id===p);let k=S>0?0:y.length-1;j>=0&&(k=(j+S+y.length)%y.length);const P=y[k];P&&w(P.id)},[]),x=c.useCallback(S=>{switch(S){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":s();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=nt.getState(),y=gs.getState().currentDirectory;e(p.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Lx();break;case"change-workspace":g();break;case"toggle-right-sidebar":{const p=gs.getState().currentDirectory;if(!p)break;const y=ue.getState(),w=vs(p),j=y.contextPanelByDirectory[w],k=j?Em(j.tabs,y.contextSurfaceZones,"right",Fo(j,"right").activeTabId):null;j?.isOpen?y.closeContextPanel(w):k?y.setActiveContextPanelTab(w,k):y.openContextSurface(w,"git");break}case"open-right-sidebar-git":{const p=gs.getState().currentDirectory;if(!p)break;ue.getState().openContextSurface(vs(p),"git");break}case"open-right-sidebar-files":{const p=gs.getState().currentDirectory;if(!p)break;ue.getState().openContextSurface(vs(p),"file");break}case"toggle-terminal":{const p=gs.getState().currentDirectory;if(!p)break;ue.getState().openContextSurface(vs(p),"terminal");break}case"toggle-terminal-expanded":{const p=gs.getState().currentDirectory;if(!p)break;const y=vs(p),w=ue.getState(),j=w.contextPanelByDirectory[y];Sa(j,w.contextSurfaceZones).has("terminal")||w.openContextSurface(y,"terminal"),w.toggleContextPanelExpanded(y,xo(w.contextSurfaceZones,"terminal"));break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||OP();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":_x();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":cc(-1);break;case"go-forward":cc(1);break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":o();break;case"download-logs":{Fx().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[g,v,b,t,e,d,l,r,a,f,s,o,i]);c.useEffect(()=>{const S=y=>{const w=y.detail;w&&x(w)},p=()=>{m()};return window.addEventListener($d,S),window.addEventListener(Di,p),()=>{window.removeEventListener($d,S),window.removeEventListener(Di,p)}},[x,m]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let y=null,w=null;return p("openchamber:menu-action",j=>{const k=j?.payload;typeof k=="string"&&x(k)}).then(j=>{y=j}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Di))}).then(j=>{w=j}).catch(()=>{}),()=>{(async()=>{try{const k=y?.();k instanceof Promise&&await k}catch{}try{const k=w?.();k instanceof Promise&&await k}catch{}})()}},[x])},FP="openchamber:tray-action",_P=5e3,LP=500,$P=20,zd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Kd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,cp=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},dp=t=>t.title.trim()||"Question",zP=(t,e)=>Ka(t,e,Vo.getState().ids,kf.getState().rankById),KP=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},WP=(t,e,s,r,o)=>{if(!t)return"";const i=pu(s,r,t),l=e.project?.name,a=i?.label?.trim()||l?.trim()||KP(t),d=ro(t);let u=d&&o.get(d)||"";if(!u){for(const[f,h]of gn.getState().directories)if(ro(f)===d){u=h.status?.current??"";break}}if(!u)for(const f of r.values()){const h=f.find(m=>ro(m.path)===d);if(h?.branch){u=h.branch;break}}return u?`${a} · ${u}`:a},HP=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=_n.getState(),r=s==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(l=>[l.providerId,l])),i=[];for(const l of zx){if(!e.includes(l.id))continue;const a=o.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[f,h]of Object.entries(a.usage?.windows??{})){const m=r==="remaining"?h.remainingPercent:h.usedPercent;d.push({label:Wx(f),value:Kx(h.valueLabel,m)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;i.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:i}},VP=async()=>{try{if(Lo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=hr();if(e&&Bl(e,t))return"Local OpenChamber";const r=(await $o()).hosts.find(o=>e?Bl(e,nu(o)):!1);return r?.label?.trim()?Jd(r.label.trim()):"Instance"}catch{return""}},GP=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=Hi()}catch{return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}}for(const[i,l]of o.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(ro(i)??i,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const f=u?.type,h=f==="busy"?"busy":f==="retry"?"retry":"idle",m=t.get(d);(!m||m==="idle")&&t.set(d,h)}for(const[d,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:h,sessionTitle:"",label:cp(f),directory:i,canSave:jf(f.save)})}for(const[d,u]of Object.entries(a.form??{}))for(const f of u??[]){if(!f?.id)continue;const h=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:h,sessionTitle:"",label:dp(f),directory:i,canSave:!1})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},UP=(t,e)=>{const s=Sf.getState().index.session,r=ws.getState().activeSessions,o=new Map;for(const p of r)if(p?.id&&p.parentID){const y=o.get(p.parentID)??[];y.push(p.id),o.set(p.parentID,y)}const i=p=>{const y=[],w=[...o.get(p)??[]],j=new Set;for(;w.length;){const k=w.pop();j.has(k)||(j.add(k),y.push(k),w.push(...o.get(k)??[]))}return y},l=ue.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let y=s.unseenCount[p.id]??0;y===0&&l.notifyOnSubtasks&&(y=i(p.id).reduce((w,j)=>w+(s.unseenCount[j]??0),0)),y>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=GP(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const f=vf.getState().statusById,h=p=>{const y=d.statusById.get(p);return y&&y!=="idle"?y:f.get(p)?.status.type??y??"idle"},m=p=>{const y=p.map(w=>h(w));return y.includes("busy")?"busy":y.includes("retry")?"retry":"idle"},g=Zt.getState().projects,b=nt.getState().availableWorktreesByProject,v=r.filter(p=>p?.id&&!p.parentID).slice().sort(zP).slice(0,$P).map(p=>{const y=[p.id,...i(p.id)],w=Xn(p)??"";return{id:p.id,title:p.title||"Untitled session",status:m(y),branch:w?d.branchByDirectory.get(w)??"":"",unseen:y.reduce((j,k)=>j+(s.unseenCount[k]??0),0),hasError:y.some(j=>s.unseenHasError[j]??!1),directory:w,subtitle:WP(w,p,g,b,d.branchByDirectory)}}),x=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),S=new Set(x.map(p=>p.id));for(const[p,y]of wf.getState().bySession){const w=u.get(p)||"";for(const j of y.permissions)S.has(j.id)||(S.add(j.id),x.push({kind:"permission",id:j.id,sessionId:p,sessionTitle:w,label:cp(j),directory:y.directory,canSave:jf(j.save)}));for(const j of y.forms)S.has(j.id)||(S.add(j.id),x.push({kind:"form",id:j.id,sessionId:p,sessionTitle:w,label:dp(j),directory:y.directory,canSave:!1}))}return{sessions:v,approvals:x,instanceName:t,usage:HP(),dockBadgeCount:a}},qP=()=>{c.useEffect(()=>{if(!zd()||!mo())return;const t=Kd();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const P=UP(o,t),A=JSON.stringify(P);A!==s&&(s=A,hn("desktop_tray_update",P))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},LP))},a=Sf.subscribe(()=>l()),d=ws.subscribe(()=>l()),u=ue.subscribe((P,A)=>{(P.dockBadgeEnabled!==A.dockBadgeEnabled||P.notifyOnSubtasks!==A.notifyOnSubtasks)&&l()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return i(),f;VP().then(P=>{e||(o=P,i())});const h=new Map,m=()=>{if(e)return;let P;try{P=Hi()}catch{return}const A=new Set;for(const[F,D]of P.children.entries())A.add(F),h.has(F)||h.set(F,D.subscribe(()=>l()));for(const[F,D]of h)A.has(F)||(D(),h.delete(F))};let g=null;try{g=Hi().subscribeRegistry(()=>{m(),l()})}catch{}m();const b=Zt.subscribe(()=>l()),v=nt.subscribe(()=>l()),x=gn.subscribe(()=>l()),S=vf.subscribe(()=>l()),p=wf.subscribe(()=>l()),y=kf.subscribe(()=>l()),w=Vo.subscribe(()=>l()),j=_n.subscribe(()=>l());_n.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:P,results:A}=_n.getState();P.length>0&&P.some(D=>!A.some(E=>E.providerId===D))&&_n.getState().fetchQuotas(P)});const k=window.setInterval(()=>{m(),i()},_P);return i(),()=>{f(),window.clearInterval(k),b(),v(),x(),S(),p(),y(),w(),j(),g?.();for(const P of h.values())P();h.clear()}},[]),c.useEffect(()=>{if(!zd()||!Kd()||!mo())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&$x(o.sessionId,o.id,o.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(FP,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{}}},[])},YP=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,XP=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,QP=t=>{t.kind!=="plugin"||!t.title||Le.info(t.title,{id:XP(t.kind,t.title,t.body,t.tag),description:t.body})},ZP=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,JP=t=>{const e=Ke.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(pn()||!ru()||!globalThis.window))return wn(eE)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function eE(t){if(t.type!=="notification")return;const e=ue.getState();if(!e.nativeNotificationsEnabled)return;const s=YP();if(ZP(t.payload,s)){QP(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;Nm()?.notifications?.notifyAgentCompletion(t.payload)}const tE=6e4,sE=t=>{const e=Ke.c(10),s=ue(nE),r=Hx(rE),i=Ug(t)?.path??null;let l,a;e[0]!==s||e[1]!==r||e[2]!==i?(l=()=>{s&&r(i,{maxAgeMs:tE})},a=[s,r,i],e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==s||e[6]!==r||e[7]!==i?(d=()=>{if(s)return wn(f=>{f.type==="agent-memory-changed"&&r(i)})},u=[s,r,i],e[5]=s,e[6]=r,e[7]=i,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function nE(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function rE(t){return t.load}const oE=()=>{const t=Ke.c(4),{t:e}=vt(),s=ue(iE);let r,o;t[0]!==s||t[1]!==e?(r=()=>wn(i=>{i.type==="browser-provider-reset"&&(s("builtin"),Le.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]),c.useEffect(r,o)};function iE(t){return t.setBrowserProvider}const Wd=()=>{Rm()||(qg(),Vx(Yg.map(t=>t.id)))},aE=(t,e)=>{const s=Ke.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const l=window.requestIdleCallback(Wd,{timeout:1e4});return()=>window.cancelIdleCallback(l)}const i=setTimeout(Wd,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],c.useEffect(r,o)},Hd="pwa-install-toast-shown",Vd="pwa-install-toast-dismissed",lE=()=>{const t=Ke.c(6),{browserTab:e}=Xg(),{t:s}=vt(),r=c.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]),c.useEffect(o,i);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!ru()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(Le.dismiss(u),u=null)},h=async()=>{if(!d)return;const b=d;d=null,f(),await b.prompt();const{outcome:v}=await b.userChoice;v==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},m=b=>{const v=b;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const x=So(),S=Dm();Qg({dismissed:x.getItem(Vd),sessionShown:S.getItem(Hd),hasActiveToast:u!==null})&&(S.setItem(Hd,"true"),u=Le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{h()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{So().setItem(Vd,"true"),f()}}}))},g=()=>{d=null,f(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",m),window.addEventListener("appinstalled",g),()=>{f(),window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",g)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},cE=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",up=async(t,e)=>{const s=(await $o()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await Am(s.id,e);return}const r=Om(nu(s));if(!r)throw new Error("host-not-found");Bm({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:Fm(s),sshForwarded:s.sshForwarded===!0})},dE=async t=>{const e=await $o(),s=await Tm(t,e.hosts);await Mm({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await up(s.hostId,{reconnectActive:!0})},uE=async t=>{const e=await Im();for(const s of e)try{s.type==="pairing"?await dE(s.link):await up(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(cE(o))}},ba="project-config-invalid",fE=()=>{const t=Ke.c(9),{t:e}=vt(),s=ns(hE);let r;t[0]!==s?(r=m=>m.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ns(r),[i,l]=ds.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const m=ns.getState(),g=m.activeDirectoryKey;l(!0),Promise.all([m.loadProviders({directory:g,source:"projectConfigError:retry"}),m.loadAgents({directory:g,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,f;t[3]!==o||t[4]!==i||t[5]!==e?(u=()=>{if(!o){Le.dismiss(ba);return}Le.error(e("projectConfigError.toast.title"),{id:ba,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:m=>{m.preventDefault(),i||d()}}})},f=[o,i,d,e],t[3]=o,t[4]=i,t[5]=e,t[6]=u,t[7]=f):(u=t[6],f=t[7]),ds.useEffect(u,f);let h;return t[8]===Symbol.for("react.memo_cache_sentinel")?(h=[],t[8]=h):h=t[8],ds.useEffect(mE,h),null};function hE(t){return t.activeDirectoryKey}function pE(){Le.dismiss(ba)}function mE(){return pE}const gE="\x1B",bE=new RegExp(`${gE}\\[[0-9;?]*[ -/]*[@-~]`,"g"),eo=rn().transform(t=>t.replace(bE,"").trim()).nullish(),yE=qi({isOpenCodeReady:fc().optional(),openCodeRunning:fc().optional(),lastOpenCodeError:eo,opencodeBinaryResolved:eo,lastOpenCodeLaunchDiagnostics:qi({sourceBinary:eo,binary:eo}).nullish()}),xE=async(t,e=an)=>{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=yE.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}},SE=(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"}},vE=qi({openchamberVersion:rn()}),wE=async(t,e=an)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=vE.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},kE=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function jE({version:t}){const{t:e}=vt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const a=await Zg();r(a.available&&!a.installBlocked?{kind:"available",info:a}:{kind:"manual",info:a,error:null})}catch(a){r({kind:"manual",info:null,error:a instanceof Error?a.message:null})}},i=s.kind==="manual"?s:null,l=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-title text-foreground",children:e("startup.serverOutdated.title")}),n.jsx("p",{className:"typography-body text-muted-foreground",children:e("startup.serverOutdated.description",{version:t})})]}),n.jsxs(Ct,{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}),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:l})]}),n.jsx(Ca,{open:s.kind==="available",onOpenChange:a=>{a||r({kind:"idle"})},info:s.kind==="available"?s.info:null,downloading:!1,downloaded:!1,progress:null,error:null,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})}const Gd=nr(()=>ss(()=>import("./OnboardingScreen-vBEhpU3q.js"),__vite__mapDeps([168,1,2,9,3,4,5,6,7,8,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}))),CE=()=>ss(()=>import("./AboutDialog-C1ulAXh5.js"),__vite__mapDeps([169,1,2,9,3,4,5,6,7,8,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),PE=()=>ss(()=>import("./MemoryDebugPanel-b116r1SF.js"),__vite__mapDeps([170,1,2,9,3,4,5,6,7,8,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,124])).then(t=>t.MemoryDebugPanel),EE=()=>{const t=Ke.c(6),e=ue(TE),s=ue(ME);let r;t[0]!==s?(r=()=>s(!1),t[0]=s,t[1]=r):r=t[1];const o=Qo(e,CE,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},NE=t=>{const e=Ke.c(3),{onClose:s}=t,r=Qo(!0,PE,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},RE=t=>{const e=Ke.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=vt(),[i,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const F=new AbortController,D=Yt(),E=setTimeout(()=>F.abort(),5e3);return xE(F.signal).then(T=>{!F.signal.aborted&&Yt()===D&&l(T)}).catch(AE).finally(()=>clearTimeout(E)),()=>{F.abort(),clearTimeout(E)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const[u,f]=c.useState(null);let h,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const F=new AbortController,D=Yt(),E=setTimeout(()=>F.abort(),5e3);return wE(F.signal).then(T=>{F.signal.aborted||Yt()!==D||f(T&&kE(T)?T:null)}).catch(OE).finally(()=>clearTimeout(E)),()=>{F.abort(),clearTimeout(E)}},m=[],e[2]=h,e[3]=m):(h=e[2],m=e[3]),c.useEffect(h,m);const g=ns(BE),b=i?null:g?.message??null;if(u){let F;e[4]!==u?(F=n.jsx(jE,{version:u}),e[4]=u,e[5]=F):F=e[5];let D;e[6]!==r||e[7]!==o?(D=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=D):D=e[8];let E;e[9]!==r||e[10]!==s||e[11]!==D?(E=n.jsx(Ct,{type:"button",variant:"outline",onClick:s,disabled:r,children:D}),e[9]=r,e[10]=s,e[11]=D,e[12]=E):E=e[12];let T;return e[13]!==F||e[14]!==E?(T=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:[F,E]})}),e[13]=F,e[14]=E,e[15]=T):T=e[15],T}let v;e[16]!==o?(v=o("startup.initRecovery.title"),e[16]=o,e[17]=v):v=e[17];let x;e[18]!==v?(x=n.jsx("h1",{className:"typography-title text-foreground",children:v}),e[18]=v,e[19]=x):x=e[19];let S;e[20]!==i||e[21]!==g||e[22]!==o?(S=o(SE(i,g)),e[20]=i,e[21]=g,e[22]=o,e[23]=S):S=e[23];let p;e[24]!==S?(p=n.jsx("p",{className:"typography-body text-muted-foreground",children:S}),e[24]=S,e[25]=p):p=e[25];let y;e[26]!==x||e[27]!==p?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[x,p]}),e[26]=x,e[27]=p,e[28]=y):y=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 j;e[32]!==i||e[33]!==o?(j=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]=j):j=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 P;e[38]!==r||e[39]!==s||e[40]!==k?(P=n.jsx(Ct,{type:"button",onClick:s,disabled:r,children:k}),e[38]=r,e[39]=s,e[40]=k,e[41]=P):P=e[41];let A;return e[42]!==w||e[43]!==j||e[44]!==P||e[45]!==y?(A=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:[y,w,j,P]})}),e[42]=w,e[43]=j,e[44]=P,e[45]=y,e[46]=A):A=e[46],A};function DE({apis:t}){c.useEffect(()=>{_m("App:mounted"),Lm()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ns(W=>W.initializeApp),s=ns(W=>W.isInitialized),r=ns(W=>W.isConnected),o=ns(W=>W.providersLoaded),i=ns(W=>W.agentsLoaded),l=ns(W=>W.loadProviders),a=ns(W=>W.loadAgents),d=nt(W=>W.error),u=nt(W=>W.clearError),f=gs(W=>W.currentDirectory),h=gs(W=>W.isSwitchingDirectory),[m,g]=c.useState(!1),b=mn(W=>W.refreshAll),v=Gx(W=>W.refreshStatus),[x,S]=c.useState(()=>t.runtime.isVSCode),[p,y]=c.useState(!1),[w,j]=c.useState(0),[k,P]=c.useState(0),[A,F]=c.useState(!1),D=ue(W=>W.wideChatLayoutEnabled),E=ue(W=>W.mobileKeyboardMode),T=c.useMemo(()=>pn(),[]),$=Ta(W=>W.setPlanModeEnabled),[O,K]=c.useState(()=>Fl()),[I,X]=c.useState(()=>{const W=ci();return W!==null?_l({isDesktopShell:!0,bootOutcome:W}):null}),N=c.useRef(!1),{t:C}=vt(),R=c.useRef(!1);c.useEffect(()=>{if(!s||O!=="valid"||R.current)return;const W=ci();W?.target!=="local"||W.status!=="ok"||!W.sshStartupFallbackHostId||(R.current=!0,Le.error(C("desktopHostSwitcher.startup.title"),{description:C("desktopHostSwitcher.startup.fellBackToLocal")}))},[O,s,C]),c.useEffect(()=>(Ll(m),_d(m),()=>{Ll(!1),_d(!1)}),[m]),c.useEffect(()=>{$m(E)},[E]),c.useEffect(()=>{S(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Bo(W=>{eb(W)&&tb(W),P(q=>q+1),y(!1),j(q=>q+1)}),[]);const H=dc(W=>{const q=Yt();return Object.values(W.runsByOriginalSessionID).filter(oe=>oe.status==="running"&&oe.runtimeKey===q).map(oe=>`${oe.originalSessionID}:${oe.phase}:${oe.lastForwardedMessageID??""}:${oe.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{const W=Yt(),q=Object.values(dc.getState().runsByOriginalSessionID).filter(oe=>oe.status==="running"&&oe.runtimeKey===W);for(const oe of q)Ux(oe.originalSessionID)},[H,k]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",D),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[D]),c.useEffect(()=>($l(t),()=>$l(null)),[t]),c.useEffect(()=>{r&&(b(t.sourceControl,{force:!0}),v(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,b,v,k]),qx();const M=O==="valid",_=I?.screen==="main";c.useEffect(()=>{if(!zm({isDesktopShell:T,bootOutcomeKnown:M}))return;Yx();const W=setTimeout(()=>{const q=document.getElementById("initial-loading");q&&(q.classList.add("fade-out"),setTimeout(()=>{q.remove()},300))},150);return()=>clearTimeout(W)},[T,M]),c.useEffect(()=>{if(!T||O!=="malformed")return;const W=document.getElementById("initial-loading");W&&(W.textContent="Desktop startup failed — please restart the app.")},[T,O]),c.useEffect(()=>{let W=!1;return(async()=>{const oe=await an("/health",{method:"GET"}).catch(()=>null);if(!oe||!oe.ok||W)return;const de=await oe.json().catch(()=>null);if(!de||W)return;const ce=de.planModeExperimentalEnabled;$(ce===!0||ce===1||ce==="1"||ce==="true")})(),()=>{W=!0}},[$]),c.useEffect(()=>{x||e()},[e,x]),c.useEffect(()=>{if(x||s)return;let W=!0,q,oe=0;const de=10,ce=1e3,je=async()=>{if(!W)return;if(oe>=de){y(!0);return}const be=ns.getState();if(be.isInitialized){y(!1);return}oe+=1,await be.initializeApp();const pe=ns.getState();if(!W)return;if(pe.isInitialized){y(!1);return}if(oe>=de){y(!0);return}const U=Math.min(ce*Math.pow(2,oe-1),4e3);q=setTimeout(je,U)};return q=setTimeout(je,ce),()=>{W=!1,q&&clearTimeout(q)}},[w,s,x]),c.useEffect(()=>{s&&y(!1)},[s]),c.useEffect(()=>{if(!p)return;const W=document.getElementById("initial-loading");W&&(W.classList.add("fade-out"),setTimeout(()=>{W.remove()},300))},[p]),c.useEffect(()=>{if(x||!r||o&&i)return;let W=!0,q=0;const oe=15,de=async()=>{const je=ns.getState();if(!(je.providersLoaded&&je.agentsLoaded))try{je.providersLoaded||await l({source:"startupRecovery"}),ns.getState().agentsLoaded||await a({source:"startupRecovery"})}catch{}};de();const ce=setInterval(()=>{if(W){if(++q>=oe){clearInterval(ce);return}de()}},2e3);return()=>{W=!1,clearInterval(ce)}},[r,x,a,l,o,i]),c.useEffect(()=>{h||x||r&&yo.setDirectory(f)},[f,h,r,x]),c.useEffect(()=>{if(typeof window>"u")return;const W=q=>{const oe=q.detail,de=typeof oe?.sessionId=="string"?oe.sessionId.trim():"";if(!de)return;const ce=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,je=String(oe?.runtimeKey??"").trim();if(!(je&&je!==Yt()&&Vm(je,de))){if(!ce){uc(de,typeof oe?.messageId=="string"?oe.messageId.trim():null);return}nt.getState().setCurrentSession(de,ce)}};return window.addEventListener("openchamber:open-session",W),Km().then(q=>{for(const oe of q)uc(oe.sessionId,oe.messageId)}),()=>window.removeEventListener("openchamber:open-session",W)},[]),c.useEffect(()=>{if(!pn())return;const W=()=>{uE(q=>{Le.error(C(q==="invalid-link"?"settings.remoteInstances.direct.error.invalidConnectLink":q==="unreachable"?"mobile.connect.error.unreachable":"onboarding.remoteConnection.errors.failedToSaveConnection"))})};return window.addEventListener("openchamber:host-actions-ready",W),W(),()=>window.removeEventListener("openchamber:host-actions-ready",W)},[C]);const B=c.useRef({attempt:null,running:!1,done:!1});c.useLayoutEffect(()=>{const W=B.current;W.attempt||(W.attempt=sb({selectNow:!nb().sessionId}))},[]),c.useEffect(()=>{const W=B.current,q=()=>{const oe=W.attempt;if(!oe||W.running||W.done)return;const de=ns.getState().isInitialized;W.running=!0,oe().then(ce=>{if(W.running=!1,ce!=="failed"||de){W.done=!0;return}ns.getState().isInitialized&&q()})};q()},[s]),c.useEffect(()=>{if(typeof window>"u")return;const W=()=>{hn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",W),()=>window.removeEventListener("openchamber:open-mini-chat",W)},[]),c.useEffect(()=>{if(typeof window>"u")return;const W=()=>{const q=nt.getState().currentSessionId;q&&Xu(q)};return window.addEventListener("focus",W),()=>window.removeEventListener("focus",W)},[]),c.useEffect(()=>{if(typeof window>"u")return;const W=q=>{const oe=q.detail,de=typeof oe?.directory=="string"&&oe.directory.trim().length>0?oe.directory.trim():null,ce=typeof oe?.projectId=="string"&&oe.projectId.trim().length>0?oe.projectId.trim():null,je=!!(de||ce);ue.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?ce:null,directoryOverride:je?de:null,preserveDirectoryOverride:!!de})};return window.addEventListener("openchamber:open-draft-session",W),()=>window.removeEventListener("openchamber:open-draft-session",W)},[]),c.useEffect(()=>{typeof window>"u"||!s||h||N.current||(N.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,h]),Xx(),JP(),sE(f||null),oE(),Qx(),rb(),aE(s&&r,k),lE(),Zx(),b1(),ob();const ee=c.useCallback(()=>{g(W=>!W)},[]);BP(ee),qP(),y1(!0),c.useEffect(()=>{const W=()=>g(q=>!q);return window.addEventListener("openchamber:memory-debug-toggle",W),()=>window.removeEventListener("openchamber:memory-debug-toggle",W)},[]),c.useEffect(()=>{d&&setTimeout(()=>u(),5e3)},[u,d]),c.useEffect(()=>{if(!T||O!=="not-injected")return;let W=!1,q=0;const oe=200,de=2e3,ce=50,je=()=>{if(W)return;q++;const be=Fl();if(be!=="not-injected"){if(W=!0,K(be),be==="valid"){const U=ci();U&&X(_l({isDesktopShell:!0,bootOutcome:U}))}return}const pe=Math.min(oe*Math.pow(1.1,q),de);if(q>=ce){const U=document.getElementById("initial-loading");U&&!U.textContent?.includes("taking longer")&&(U.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,pe)};return window.setTimeout(je,oe),()=>{W=!0}},[T,O]);const ne=c.useCallback(async()=>{if(Wm({isDesktopShell:pn(),isDesktopLocalOriginActive:Lo()})){await Hm();return}window.location.reload()},[]),re=c.useCallback(async()=>{if(!A){y(!1),F(!0);try{await ns.getState().initializeApp()}finally{F(!1)}ns.getState().isInitialized||j(W=>W+1)}},[A]),te=W=>{if(W.screen==="recovery")return W.variant};if(T&&I&&I.screen!=="main"){if(I.screen==="chooser")return n.jsx(bs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Gd,{mode:"first-launch",localAvailable:I.localAvailable!==!1,onCliAvailable:ne,onChooseRemote:()=>{}})})})});const W=te(I),q=I.screen==="recovery"&&"url"in I?I.url:void 0,oe=I.screen==="recovery"&&"hostId"in I?I.hostId:void 0;return n.jsx(bs,{children:n.jsx("div",{className:"h-full text-foreground bg-background",children:n.jsx(c.Suspense,{fallback:n.jsx("div",{className:"h-full"}),children:n.jsx(Gd,{mode:"recovery",recoveryVariant:W,recoveryHostUrl:q,recoveryHostLabel:void 0,recoveryHostId:oe,localAvailable:I.localAvailable!==!1,onCliAvailable:ne})})})})}return p&&!s&&!x?n.jsx(bs,{children:n.jsx(RE,{onRetry:()=>{re()},isRetrying:A},k)}):n.jsx(bs,{children:n.jsx(Jx,{sdk:yo.getSdkClient(),directory:f||"",children:n.jsx(e1,{apis:t,children:n.jsx(CP,{children:n.jsx(Go,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:T?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(t1,{backgroundWorkEnabled:!0}),n.jsx(ib,{}),n.jsx(fE,{}),n.jsx(_5,{}),T?n.jsx(ab,{ready:M&&_}):null,n.jsx(s1,{}),n.jsx(n1,{}),n.jsx(r1,{}),n.jsx(lb,{}),n.jsx(EE,{}),m&&n.jsx(NE,{onClose:()=>g(!1)})]})})})})},k)})}function IE(t){const e=Ke.c(2);let s;return e[0]!==t?(s=n.jsx(Jg,{children:n.jsx(DE,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function TE(t){return t.isAboutDialogOpen}function ME(t){return t.setAboutDialogOpen}function AE(){}function OE(){}function BE(t){return t.lastInitFailure}const FE=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Gm();cb();db();Um().then(()=>{o1().catch(t=>{console.error("[main] settings init failed:",t)}),i1(),a1(),l1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const fp=document.getElementById("root");if(!fp)throw new Error("Root element not found");c1();Jp.createRoot(fp).render(n.jsx(ds.StrictMode,{children:n.jsx(d1,{children:n.jsx(u1,{children:n.jsx(f1,{children:n.jsx(h1,{children:n.jsx(IE,{apis:FE})})})})})}));const rN=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{AS as W,Ek as a,tN as b,nN as g,rN as m,sN as r,RS as u,Pk as v};