@vantran-se/openchamber-web 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/README.md +32 -24
  2. package/bin/cli.js +1 -3
  3. package/bin/cli.test.js +40 -16
  4. package/bin/lib/DOCUMENTATION.md +6 -5
  5. package/bin/lib/cli-args.js +6 -1
  6. package/bin/lib/cli-args.test.js +34 -0
  7. package/bin/lib/cli-lifecycle.js +0 -1
  8. package/bin/lib/cli-network.js +8 -2
  9. package/bin/lib/cli-process.js +1 -1
  10. package/bin/lib/cli-settings-accessors.test.js +21 -13
  11. package/bin/lib/cli-startup.js +17 -11
  12. package/bin/lib/cli-startup.test.js +92 -2
  13. package/bin/lib/commands-connect-url.js +8 -1
  14. package/bin/lib/commands-schedule.js +8 -2
  15. package/bin/lib/commands-serve.js +15 -21
  16. package/bin/lib/commands-update.js +12 -24
  17. package/bin/lib/commands-update.test.js +14 -46
  18. package/dist/assets/DiffView-Cv9MSXl1.js +4 -0
  19. package/dist/assets/FilePreviewCommentMenu-D4kLseHj.js +4 -0
  20. package/dist/assets/FilesView-BVoD8I2x.js +14 -0
  21. package/dist/assets/{GitView-DzuzhIPx.js → GitView-Bzb8p-ew.js} +4 -4
  22. package/dist/assets/GuestSurfacePane-Crdbvsxo.js +1 -0
  23. package/dist/assets/InProgressOperationBanner-CwMjNQgk.js +2 -0
  24. package/dist/assets/{JsonTreeView-B_EPRjzy.js → JsonTreeView-DRKHZfsn.js} +1 -1
  25. package/dist/assets/MarkdownImageGallery-DZtqT1Zn.js +1 -0
  26. package/dist/assets/MarkdownRendererImpl-CqG7HCNd.js +10 -0
  27. package/dist/assets/OnboardingScreen-DMIxwYK5.js +1 -0
  28. package/dist/assets/{PatchDiff-6yh1csza.js → PatchDiff-CUcCg1jk.js} +1 -1
  29. package/dist/assets/PierreDiffViewer-CnnR-dnD.js +228 -0
  30. package/dist/assets/PlanView-RCBadcY7.js +5 -0
  31. package/dist/assets/SettingsView-CjBjZFRO.js +30 -0
  32. package/dist/assets/SettingsWindow-DyM7QuhI.js +1 -0
  33. package/dist/assets/SubmoduleDiffSummary-BWIfgMED.js +1 -0
  34. package/dist/assets/ToolOutputDialog-Q0P3FuAi.js +15 -0
  35. package/dist/assets/ToolPartDiffPreview-p7qR9FpU.js +8 -0
  36. package/dist/assets/{VirtualizedFileDiff-BTJVRkyo.js → VirtualizedFileDiff-CFpjL8Ns.js} +3 -3
  37. package/dist/assets/{Virtualizer-xCEYz34p.js → Virtualizer-C0IsclZn.js} +1 -1
  38. package/dist/assets/WalkthroughView-DI31zD02.js +4 -0
  39. package/dist/assets/appThemeRegistry-B9gkFq9i.js +1 -0
  40. package/dist/assets/{computeVirtualFileMetrics-CmPe29DM.js → computeVirtualFileMetrics-C2WM6JC2.js} +2 -2
  41. package/dist/assets/de-YKfk5MmC.js +14 -0
  42. package/dist/assets/es-_gwT0kr-.js +20 -0
  43. package/dist/assets/fileTreeStatus-D438yi8M.js +1 -0
  44. package/dist/assets/fr-DqzvXmIm.js +18 -0
  45. package/dist/assets/index-BLaHKdtx.js +1 -0
  46. package/dist/assets/index-BkMXRrVQ.css +1 -0
  47. package/dist/assets/index-DxNa7xYB.js +65 -0
  48. package/dist/assets/initializeSharedPreferences-Bck5EAWP.js +1 -0
  49. package/dist/assets/{isDiffPlainText-CQmDCnEv.js → isDiffPlainText-Dgbw8VKk.js} +1 -1
  50. package/dist/assets/{isFilePlainText-CYBUzW4I.js → isFilePlainText-_ZS5UYRj.js} +1 -1
  51. package/dist/assets/ja-B-GFYhQE.js +20 -0
  52. package/dist/assets/ko-mzksfqDC.js +20 -0
  53. package/dist/assets/main-C5Xx8dn_.js +2 -0
  54. package/dist/assets/main-CfBSQM1H.js +990 -0
  55. package/dist/assets/markdownCore-BmWwW1ll.js +7 -0
  56. package/dist/assets/miniChat-mnKwy4vQ.js +2 -0
  57. package/dist/assets/mobile-DeEQd0wZ.js +2 -0
  58. package/dist/assets/nl-CWQr6NSq.js +20 -0
  59. package/dist/assets/{parseDiffFromFile-Cy0PNxun.js → parseDiffFromFile-BUgn-T9p.js} +2 -2
  60. package/dist/assets/patchFileDiff-Dt8LhgBh.js +13 -0
  61. package/dist/assets/pl-UmRcDUX2.js +20 -0
  62. package/dist/assets/pt-BR-BSLybvVF.js +20 -0
  63. package/dist/assets/relocateRestoredSession-B5E9xb3T.js +1 -0
  64. package/dist/assets/renderElectronMiniChatApp-C0a9A5_J.js +2 -0
  65. package/dist/assets/renderMobileApp-BNncg3Pk.js +25 -0
  66. package/dist/assets/runtimeEndpointReset-CZ5aafpl.js +62 -0
  67. package/dist/assets/{selectionMarkdown-TkYk5h9l.js → selectionMarkdown-CUN3wUld.js} +9 -9
  68. package/dist/assets/{sessionOwnership-Bs1xbRfB.js → sessionOwnership-BSuxCEhb.js} +1 -1
  69. package/dist/assets/shikiHighlight-DHDx-6eM.js +1 -0
  70. package/dist/assets/space-apply-DM_2pRW7.js +1 -0
  71. package/dist/assets/space-close-Bpomt8z0.js +1 -0
  72. package/dist/assets/{surface-B6n7wJtt.js → surface-C-jQaGnL.js} +1 -1
  73. package/dist/assets/{textMateThemeFromAppTheme-CDlKffWz.js → textMateThemeFromAppTheme-DlsTphbY.js} +1 -1
  74. package/dist/assets/tr-gaTrX_HK.js +11 -0
  75. package/dist/assets/uk-CnJF6ykl.js +20 -0
  76. package/dist/assets/{useAppFontEffects-DCqCVGlT.js → useAppFontEffects-DGlvOqP_.js} +194 -233
  77. package/dist/assets/useInlineCommentController-kMN4Wg_D.js +2 -0
  78. package/dist/assets/{useRootScrollLock-BowwS8kq.js → useRootScrollLock-DMPpvpNP.js} +2 -2
  79. package/dist/assets/{vendor-base-ui-DX96QhTP.js → vendor-base-ui-Det7U81h.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-autocomplete-DW1FQz9_.js → vendor-codemirror-autocomplete-BSHQHbKu.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-commands-DpmhalwN.js → vendor-codemirror-commands-C4G_dPWe.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-angular-BqExbN1M.js → vendor-codemirror-lang-angular-B6LbBGHB.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-cpp-DZA36HfS.js → vendor-codemirror-lang-cpp-BWWXBx7W.js} +1 -1
  84. package/dist/assets/{vendor-codemirror-lang-css-B07blnnZ.js → vendor-codemirror-lang-css-Cayfb29q.js} +1 -1
  85. package/dist/assets/{vendor-codemirror-lang-go-BM8K9D1-.js → vendor-codemirror-lang-go-BoKlCNKw.js} +1 -1
  86. package/dist/assets/{vendor-codemirror-lang-html-DaH9adfE.js → vendor-codemirror-lang-html-BQWerHsJ.js} +1 -1
  87. package/dist/assets/{vendor-codemirror-lang-java-CsdC0viz.js → vendor-codemirror-lang-java-DWX7Fq_K.js} +1 -1
  88. package/dist/assets/{vendor-codemirror-lang-javascript-CpGYXGuo.js → vendor-codemirror-lang-javascript-DbpEcZM0.js} +2 -2
  89. package/dist/assets/{vendor-codemirror-lang-jinja-BBeGzXw5.js → vendor-codemirror-lang-jinja-D1JIJRA7.js} +1 -1
  90. package/dist/assets/{vendor-codemirror-lang-json-58T70Hqs.js → vendor-codemirror-lang-json-BzgckzmB.js} +1 -1
  91. package/dist/assets/{vendor-codemirror-lang-less-BI-xCA59.js → vendor-codemirror-lang-less-B9EpDXFi.js} +1 -1
  92. package/dist/assets/{vendor-codemirror-lang-liquid-zEcMa-zy.js → vendor-codemirror-lang-liquid-9U7kRbSf.js} +1 -1
  93. package/dist/assets/{vendor-codemirror-lang-markdown-BLKnlLP4.js → vendor-codemirror-lang-markdown-D2TEBIvZ.js} +1 -1
  94. package/dist/assets/{vendor-codemirror-lang-php-9f35M83-.js → vendor-codemirror-lang-php-BT6sDVzE.js} +1 -1
  95. package/dist/assets/vendor-codemirror-lang-python-jAMtYiA9.js +3 -0
  96. package/dist/assets/{vendor-codemirror-lang-rust-MNDL_jZQ.js → vendor-codemirror-lang-rust-CVO56EiL.js} +1 -1
  97. package/dist/assets/{vendor-codemirror-lang-sass-p9epsSNm.js → vendor-codemirror-lang-sass-DZlOoUWu.js} +1 -1
  98. package/dist/assets/{vendor-codemirror-lang-sql-Bqzh0EXX.js → vendor-codemirror-lang-sql-fZ6t1DPw.js} +1 -1
  99. package/dist/assets/{vendor-codemirror-lang-vue-BnNUWV-p.js → vendor-codemirror-lang-vue-DxbqrLiE.js} +1 -1
  100. package/dist/assets/{vendor-codemirror-lang-wast-C2a-oLmk.js → vendor-codemirror-lang-wast-DyU1Gt-I.js} +1 -1
  101. package/dist/assets/vendor-codemirror-lang-xml-C9a_K5_p.js +1 -0
  102. package/dist/assets/{vendor-codemirror-lang-yaml-C0sjswB0.js → vendor-codemirror-lang-yaml-Cptq8l0e.js} +1 -1
  103. package/dist/assets/{vendor-codemirror-language-ByBn5zIW.js → vendor-codemirror-language-DufXoQvE.js} +2 -2
  104. package/dist/assets/vendor-codemirror-language-data-CtwSWKtX.js +2 -0
  105. package/dist/assets/{vendor-codemirror-search-ib-sHD5W.js → vendor-codemirror-search-CvXM_pZg.js} +1 -1
  106. package/dist/assets/{vendor-codemirror-state-G3UuR-be.js → vendor-codemirror-state-Dek9sMtw.js} +1 -1
  107. package/dist/assets/{vendor-codemirror-view-Bniqp7p5.js → vendor-codemirror-view-1e0FQ6Wn.js} +1 -1
  108. package/dist/assets/vendor-framer-motion-DxDVhOLc.js +9 -0
  109. package/dist/assets/vendor-katex-CuQvj9-L.js +257 -0
  110. package/dist/assets/vendor-katex-DdZNUVNG.css +1 -0
  111. package/dist/assets/{vendor-motion-dom-DcCgeG69.js → vendor-motion-dom-HXPOMxb7.js} +1 -1
  112. package/dist/assets/{vendor-opencode-client-DHzhmLwV.js → vendor-opencode-client-BmFcUkbQ.js} +1 -1
  113. package/dist/assets/{vendor-replit-codemirror-vim-DkzqxN2H.js → vendor-replit-codemirror-vim-BlJRn-cW.js} +2 -2
  114. package/dist/assets/{vendor-tanstack-react-virtual-H_JmXOFV.js → vendor-tanstack-react-virtual-CvuLsk7D.js} +1 -1
  115. package/dist/assets/{vendor-tanstack-virtual-core-Dxc8hSTB.js → vendor-tanstack-virtual-core-DPaNcJcT.js} +1 -1
  116. package/dist/assets/zh-CN-t2vigSB1.js +20 -0
  117. package/dist/assets/zh-TW-jAgqBokB.js +20 -0
  118. package/dist/index.html +6 -6
  119. package/dist/mini-chat.html +6 -6
  120. package/dist/mobile.html +6 -6
  121. package/package.json +8 -5
  122. package/server/index.js +80 -36
  123. package/server/lib/agent-memory/actions.js +1 -6
  124. package/server/lib/agent-memory/routes.js +1 -2
  125. package/server/lib/agent-memory/runtime.js +1 -8
  126. package/server/lib/agent-tool/DOCUMENTATION.md +7 -3
  127. package/server/lib/agent-tool/runtime.js +3 -6
  128. package/server/lib/agent-tool/runtime.test.js +0 -2
  129. package/server/lib/browser-control/DOCUMENTATION.md +6 -0
  130. package/server/lib/changelog/update-notes.js +1 -1
  131. package/server/lib/context-obligatory/runtime.js +1 -2
  132. package/server/lib/dev-tunnel/DOCUMENTATION.md +8 -0
  133. package/server/lib/dev-tunnel/client.js +21 -10
  134. package/server/lib/dev-tunnel/tunnel.test.js +34 -0
  135. package/server/lib/dispatch-results/runtime.js +1 -1
  136. package/server/lib/enterprise-mode.d.ts +1 -0
  137. package/server/lib/enterprise-mode.js +13 -2
  138. package/server/lib/enterprise-mode.test.js +21 -0
  139. package/server/lib/event-stream/DOCUMENTATION.md +2 -2
  140. package/server/lib/event-stream/index.js +1 -3
  141. package/server/lib/event-stream/translate-v2.js +1 -9
  142. package/server/lib/event-stream/translate-v2.test.js +0 -11
  143. package/server/lib/fs/DOCUMENTATION.md +5 -2
  144. package/server/lib/fs/routes.js +62 -15
  145. package/server/lib/fs/routes.test.js +278 -48
  146. package/server/lib/fs/workspace-file-names.js +104 -0
  147. package/server/lib/fs/workspace-file-names.test.js +62 -0
  148. package/server/lib/git/DOCUMENTATION.md +17 -5
  149. package/server/lib/git/contributor-provenance-storage.js +9 -6
  150. package/server/lib/git/contributor-provenance-storage.test.js +29 -0
  151. package/server/lib/git/credential-broker.js +1 -1
  152. package/server/lib/git/credential-resolver.js +1 -4
  153. package/server/lib/git/credentials.js +1 -0
  154. package/server/lib/git/discovery-endpoint.js +1 -1
  155. package/server/lib/git/identity-provisioning.js +2 -1
  156. package/server/lib/git/identity-storage.js +3 -4
  157. package/server/lib/git/lfs-discovery.js +14 -14
  158. package/server/lib/git/lfs-discovery.test.js +16 -6
  159. package/server/lib/git/network-operation-plan.js +50 -62
  160. package/server/lib/git/network-operation-plan.test.js +103 -1
  161. package/server/lib/git/network-operation-registry.js +4 -6
  162. package/server/lib/git/network-operation-storage.js +4 -6
  163. package/server/lib/git/network-operations.js +12 -4
  164. package/server/lib/git/network-operations.test.js +19 -6
  165. package/server/lib/git/redaction.js +2 -1
  166. package/server/lib/git/repository-credential-runtime.js +5 -3
  167. package/server/lib/git/repository-credential-runtime.test.js +22 -0
  168. package/server/lib/git/routes.js +31 -137
  169. package/server/lib/git/routes.test.js +2 -2
  170. package/server/lib/git/service.js +143 -27
  171. package/server/lib/git/service.test.js +215 -1
  172. package/server/lib/git/ssh-credential-storage.js +1 -4
  173. package/server/lib/git/submodule-discovery.js +1 -1
  174. package/server/lib/git/worktree-bootstrap-storage.js +3 -4
  175. package/server/lib/git/worktree-bootstrap-storage.test.js +15 -0
  176. package/server/lib/git/worktree-creation.js +194 -0
  177. package/server/lib/git/worktree-creation.test.js +155 -0
  178. package/server/lib/github/DOCUMENTATION.md +11 -6
  179. package/server/lib/github/auth.js +2 -4
  180. package/server/lib/github/device-flow.js +2 -2
  181. package/server/lib/github/gh-cli-credential.js +1 -0
  182. package/server/lib/github/octokit.js +31 -0
  183. package/server/lib/github/pr-status.js +35 -18
  184. package/server/lib/github/pr-status.test.js +271 -3
  185. package/server/lib/github/reference-search.js +102 -13
  186. package/server/lib/github/reference-search.test.js +48 -7
  187. package/server/lib/github/routes.auth.test.js +18 -0
  188. package/server/lib/github/routes.js +360 -6
  189. package/server/lib/github/routes.mutations.test.js +239 -0
  190. package/server/lib/github/routes.test.js +134 -2
  191. package/server/lib/gitlab/DOCUMENTATION.md +5 -1
  192. package/server/lib/gitlab/auth-storage.test.js +1 -0
  193. package/server/lib/gitlab/mappers.js +30 -1
  194. package/server/lib/gitlab/resources.js +230 -6
  195. package/server/lib/gitlab/resources.test.js +179 -0
  196. package/server/lib/gitlab/routes.js +200 -6
  197. package/server/lib/gitlab/routes.test.js +186 -2
  198. package/server/lib/gitlab/validation.js +1 -5
  199. package/server/lib/guests/DOCUMENTATION.md +1 -1
  200. package/server/lib/guests/oauth.js +2 -2
  201. package/server/lib/guests/service.js +1 -1
  202. package/server/lib/guests/sockets.js +1 -1
  203. package/server/lib/injected-env.d.ts +8 -0
  204. package/server/lib/injected-env.js +50 -0
  205. package/server/lib/injected-env.test.js +56 -0
  206. package/server/lib/linear/DOCUMENTATION.md +5 -6
  207. package/server/lib/linear/issues.js +62 -4
  208. package/server/lib/linear/issues.test.js +68 -0
  209. package/server/lib/linear/oauth.js +5 -5
  210. package/server/lib/linear/parse.js +2 -9
  211. package/server/lib/message-queue/DOCUMENTATION.md +23 -1
  212. package/server/lib/message-queue/runtime.js +85 -12
  213. package/server/lib/message-queue/runtime.test.js +172 -2
  214. package/server/lib/notifications/apns-runtime.js +5 -6
  215. package/server/lib/notifications/apns-runtime.test.js +20 -4
  216. package/server/lib/openchamber-control/DOCUMENTATION.md +19 -1
  217. package/server/lib/openchamber-control/actions.js +2 -1
  218. package/server/lib/openchamber-control/service.js +119 -20
  219. package/server/lib/openchamber-control/service.test.js +166 -0
  220. package/server/lib/openchamber-sessions/archive-store.js +1 -6
  221. package/server/lib/openchamber-sessions/routes.js +47 -12
  222. package/server/lib/openchamber-sessions/routes.test.js +65 -2
  223. package/server/lib/openchamber-sessions/session-metadata-store.js +1 -6
  224. package/server/lib/opencode/DOCUMENTATION.md +22 -8
  225. package/server/lib/opencode/agents.js +62 -0
  226. package/server/lib/opencode/auth-state-runtime.js +3 -1
  227. package/server/lib/opencode/auth.d.ts +1 -1
  228. package/server/lib/opencode/auth.js +8 -0
  229. package/server/lib/opencode/auth.test.js +31 -0
  230. package/server/lib/opencode/config-entity-routes.js +16 -0
  231. package/server/lib/opencode/config-entity-v2.test.js +16 -1
  232. package/server/lib/opencode/config-paths.test.js +2 -2
  233. package/server/lib/opencode/config-v2.js +2 -4
  234. package/server/lib/opencode/feature-routes-runtime.js +89 -49
  235. package/server/lib/opencode/lifecycle.js +41 -21
  236. package/server/lib/opencode/lifecycle.test.js +50 -2
  237. package/server/lib/opencode/model-discovery.js +1 -1
  238. package/server/lib/opencode/model-discovery.test.js +17 -0
  239. package/server/lib/opencode/models-metadata.js +0 -2
  240. package/server/lib/opencode/openchamber-routes.test.js +3 -3
  241. package/server/lib/opencode/plugins.js +6 -9
  242. package/server/lib/opencode/provider-source-route.test.js +101 -3
  243. package/server/lib/opencode/providers-disabled.test.js +59 -0
  244. package/server/lib/opencode/providers.js +34 -0
  245. package/server/lib/opencode/proxy.js +11 -3
  246. package/server/lib/opencode/routes.js +40 -2
  247. package/server/lib/opencode/settings-helpers.js +27 -1
  248. package/server/lib/opencode/settings-helpers.test.js +19 -7
  249. package/server/lib/opencode/settings-registry.json +27 -16
  250. package/server/lib/opencode/settings-runtime.test.js +18 -0
  251. package/server/lib/opencode/shared-service-runtime.js +23 -104
  252. package/server/lib/opencode/shared.js +77 -46
  253. package/server/lib/opencode/shared.test.js +12 -12
  254. package/server/lib/opencode/shutdown-runtime.test.js +2 -3
  255. package/server/lib/opencode/skill-routes.js +123 -38
  256. package/server/lib/opencode/skill-routes.test.js +201 -0
  257. package/server/lib/opencode/skills.js +81 -34
  258. package/server/lib/opencode/skills.test.js +176 -21
  259. package/server/lib/opencode/startup-pipeline-runtime.js +6 -3
  260. package/server/lib/opencode/startup-pipeline-runtime.test.js +2 -1
  261. package/server/lib/opencode/watcher.test.js +0 -54
  262. package/server/lib/outbound-proxy.js +52 -0
  263. package/server/lib/outbound-proxy.test.js +55 -0
  264. package/server/lib/package-manager.js +23 -17
  265. package/server/lib/package-manager.test.js +5 -18
  266. package/server/lib/permission-auto-accept/DOCUMENTATION.md +1 -1
  267. package/server/lib/permission-auto-accept/runtime.js +19 -47
  268. package/server/lib/permission-auto-accept/runtime.test.js +2 -2
  269. package/server/lib/project-context/DOCUMENTATION.md +7 -1
  270. package/server/lib/project-context/routes.js +1 -2
  271. package/server/lib/project-context/runtime.js +12 -14
  272. package/server/lib/project-context/runtime.test.js +78 -2
  273. package/server/lib/projects/project-config.js +30 -15
  274. package/server/lib/projects/project-config.test.js +30 -0
  275. package/server/lib/projects/project-setup.js +1 -2
  276. package/server/lib/projects/routes.js +1 -2
  277. package/server/lib/quota/DOCUMENTATION.md +35 -7
  278. package/server/lib/quota/index.js +1 -0
  279. package/server/lib/quota/providers/claude/index.js +1 -1
  280. package/server/lib/quota/providers/cline-pass.js +1 -1
  281. package/server/lib/quota/providers/exe-dev.js +1 -1
  282. package/server/lib/quota/providers/google/index.js +1 -1
  283. package/server/lib/quota/providers/hyper.js +1 -1
  284. package/server/lib/quota/providers/kimi.js +116 -36
  285. package/server/lib/quota/providers/kimi.test.js +128 -3
  286. package/server/lib/quota/providers/opencode-go.js +144 -21
  287. package/server/lib/quota/providers/opencode-go.test.js +229 -6
  288. package/server/lib/quota/providers/openrouter.js +1 -1
  289. package/server/lib/quota/providers/zenmux.js +1 -1
  290. package/server/lib/quota/utils/auth.js +1 -0
  291. package/server/lib/quota/utils/transformers.js +2 -6
  292. package/server/lib/relay/DOCUMENTATION.md +18 -3
  293. package/server/lib/relay/e2ee.js +7 -7
  294. package/server/lib/relay/host-client.js +84 -13
  295. package/server/lib/relay/host-client.test.js +201 -1
  296. package/server/lib/relay/identity.js +6 -29
  297. package/server/lib/relay/identity.test.js +18 -28
  298. package/server/lib/relay/key-store.js +141 -0
  299. package/server/lib/relay/key-store.test.js +138 -0
  300. package/server/lib/relay/service.js +8 -8
  301. package/server/lib/relay/service.test.js +10 -5
  302. package/server/lib/relay/signing-key.js +13 -36
  303. package/server/lib/relay/tunnel-codec.js +10 -10
  304. package/server/lib/route-module-exports.test.js +22 -0
  305. package/server/lib/routing/DOCUMENTATION.md +23 -3
  306. package/server/lib/routing/cache.js +87 -0
  307. package/server/lib/routing/defaults.js +11 -0
  308. package/server/lib/routing/history.js +12 -4
  309. package/server/lib/routing/runtime.js +39 -3
  310. package/server/lib/routing/runtime.test.js +81 -2
  311. package/server/lib/routing/store.js +12 -1
  312. package/server/lib/routing/store.test.js +13 -0
  313. package/server/lib/scheduled-tasks/DOCUMENTATION.md +59 -1
  314. package/server/lib/scheduled-tasks/existing-session.js +119 -0
  315. package/server/lib/scheduled-tasks/existing-session.test.js +350 -0
  316. package/server/lib/scheduled-tasks/loops.js +1 -8
  317. package/server/lib/scheduled-tasks/routes.js +8 -8
  318. package/server/lib/scheduled-tasks/runtime.js +103 -13
  319. package/server/lib/scheduled-tasks/runtime.test.js +48 -0
  320. package/server/lib/scheduled-tasks/service.js +33 -11
  321. package/server/lib/scheduled-tasks/service.test.js +128 -2
  322. package/server/lib/scheduled-tasks/session-defaults.js +27 -0
  323. package/server/lib/scheduled-tasks/session-defaults.test.js +19 -0
  324. package/server/lib/session-assist/context.js +1 -0
  325. package/server/lib/session-folders/routes.js +2 -2
  326. package/server/lib/session-goal/objectives.js +1 -1
  327. package/server/lib/session-knowledge/routes.js +2 -2
  328. package/server/lib/session-knowledge/runtime.js +1 -2
  329. package/server/lib/session-work/DOCUMENTATION.md +39 -14
  330. package/server/lib/session-work/questions.js +31 -2
  331. package/server/lib/session-work/runtime.js +22 -13
  332. package/server/lib/session-work/runtime.test.js +43 -26
  333. package/server/lib/session-work/state.js +10 -4
  334. package/server/lib/session-work/state.test.js +8 -1
  335. package/server/lib/shared/DOCUMENTATION.md +89 -0
  336. package/server/lib/shared/guards.js +53 -0
  337. package/server/lib/shared/guards.test.js +112 -0
  338. package/server/lib/skills-catalog/DOCUMENTATION.md +10 -8
  339. package/server/lib/skills-catalog/cache.js +3 -2
  340. package/server/lib/skills-catalog/curated-sources.js +5 -1
  341. package/server/lib/skills-catalog/git.js +107 -20
  342. package/server/lib/skills-catalog/git.test.js +78 -0
  343. package/server/lib/skills-catalog/install.js +21 -12
  344. package/server/lib/skills-catalog/scan.js +25 -15
  345. package/server/lib/skills-catalog/source.js +26 -1
  346. package/server/lib/skills-catalog/source.test.js +27 -0
  347. package/server/lib/source-control/DOCUMENTATION.md +2 -1
  348. package/server/lib/source-control/audit-storage.js +7 -6
  349. package/server/lib/source-control/audit-storage.test.js +11 -0
  350. package/server/lib/source-control/binding-service.js +2 -5
  351. package/server/lib/source-control/change-request-worktree.js +90 -0
  352. package/server/lib/source-control/change-request-worktree.test.js +121 -0
  353. package/server/lib/source-control/mutation-executor.js +1 -1
  354. package/server/lib/source-control/mutation-storage.js +11 -5
  355. package/server/lib/source-control/provider-instance.js +1 -2
  356. package/server/lib/source-control/repository-identity.js +1 -1
  357. package/server/lib/source-control/routes.js +14 -2
  358. package/server/lib/spaces/DOCUMENTATION.md +42 -17
  359. package/server/lib/spaces/command-stream.test.js +15 -0
  360. package/server/lib/spaces/dispatcher.js +7 -0
  361. package/server/lib/spaces/dispatcher.test.js +17 -0
  362. package/server/lib/spaces/hardening.js +2 -2
  363. package/server/lib/spaces/hardening.test.js +1 -1
  364. package/server/lib/spaces/host.js +2 -0
  365. package/server/lib/spaces/journey.js +66 -5
  366. package/server/lib/spaces/journey.test.js +95 -4
  367. package/server/lib/spaces/layout.js +1 -1
  368. package/server/lib/spaces/places/docker-disk.js +38 -14
  369. package/server/lib/spaces/places/docker-disk.test.js +80 -1
  370. package/server/lib/spaces/places/docker.js +35 -11
  371. package/server/lib/spaces/places/fake-docker.js +22 -3
  372. package/server/lib/spaces/places/memory-place.js +3 -0
  373. package/server/lib/spaces/places/packed.docker.live.test.js +1 -1
  374. package/server/lib/spaces/routes.js +5 -0
  375. package/server/lib/spaces/routes.test.js +4 -2
  376. package/server/lib/spaces/run-command.js +9 -2
  377. package/server/lib/spaces/tools.js +4 -5
  378. package/server/lib/spaces/tools.test.js +2 -2
  379. package/server/lib/terminal/runtime.js +18 -6
  380. package/server/lib/terminal/runtime.test.js +66 -0
  381. package/server/lib/tts/index.js +3 -0
  382. package/server/lib/tts/service.js +4 -2
  383. package/server/lib/walkthrough/DOCUMENTATION.md +3 -1
  384. package/server/lib/walkthrough/index.js +2 -3
  385. package/server/lib/walkthrough/pr-source.test.js +22 -0
  386. package/server/lib/walkthrough/sources.js +6 -1
  387. package/server/opencode-proxy.test.js +127 -0
  388. package/bin/lib/commands-startup.test.js +0 -15
  389. package/dist/assets/CodeMirrorCommentWidgets-CVDSjcrP.js +0 -1
  390. package/dist/assets/DiffView-Ct7vL3fD.js +0 -4
  391. package/dist/assets/FilesView-DT0uEYgT.js +0 -17
  392. package/dist/assets/GuestSurfacePane-DVvk1VPu.js +0 -1
  393. package/dist/assets/LinearIssuesView-C10MwA9h.js +0 -1
  394. package/dist/assets/MarkdownImageGallery-BbN_K_3d.js +0 -1
  395. package/dist/assets/MarkdownRendererImpl-BLt2Tkk9.js +0 -10
  396. package/dist/assets/OnboardingScreen-Bgp5A3WB.js +0 -1
  397. package/dist/assets/PierreDiffViewer-CWJLj-S-.js +0 -210
  398. package/dist/assets/PlanView-DsRWnsOI.js +0 -5
  399. package/dist/assets/PublishDialog-CCeKloRu.js +0 -2
  400. package/dist/assets/SettingsView-BuPPsNPp.js +0 -30
  401. package/dist/assets/SettingsWindow-CM5fL8Ot.js +0 -1
  402. package/dist/assets/SubmoduleDiffSummary-CfsMcfiQ.js +0 -1
  403. package/dist/assets/ToolOutputDialog-mZrfSofz.js +0 -15
  404. package/dist/assets/ToolPartDiffPreview-BUGCRYEL.js +0 -8
  405. package/dist/assets/WalkthroughView-ClBo7PPd.js +0 -4
  406. package/dist/assets/appThemeRegistry-CxzMxR-H.js +0 -1
  407. package/dist/assets/de-CBla4hjd.js +0 -14
  408. package/dist/assets/es-BmnZtxTD.js +0 -20
  409. package/dist/assets/fileTreeStatus-BSHFIGEg.js +0 -1
  410. package/dist/assets/fr-OVKIBUZO.js +0 -18
  411. package/dist/assets/index-CKCFKmjF.js +0 -1
  412. package/dist/assets/index-Dbx4V4GN.css +0 -1
  413. package/dist/assets/index-vQ1Pg1cr.js +0 -61
  414. package/dist/assets/ja-6v-yr-gE.js +0 -20
  415. package/dist/assets/ko-I_ZLvgQ9.js +0 -20
  416. package/dist/assets/main-CmO4dRtR.js +0 -2
  417. package/dist/assets/main-b9vqhlYM.js +0 -999
  418. package/dist/assets/markdownCore-BPEZRQfP.js +0 -7
  419. package/dist/assets/miniChat-B5Oi7B-6.js +0 -2
  420. package/dist/assets/mobile-CVtShif9.js +0 -2
  421. package/dist/assets/nl-DcvIJf46.js +0 -20
  422. package/dist/assets/patchFileDiff-CW3wCH1O.js +0 -13
  423. package/dist/assets/pl-JxCUl0sd.js +0 -20
  424. package/dist/assets/pt-BR-L89mjja2.js +0 -20
  425. package/dist/assets/relocateRestoredSession-DYh_9oBa.js +0 -1
  426. package/dist/assets/renderElectronMiniChatApp-BD-1JHSg.js +0 -2
  427. package/dist/assets/renderMobileApp-7s5InXt1.js +0 -25
  428. package/dist/assets/runtimeEndpointReset-DqLJC6L1.js +0 -53
  429. package/dist/assets/shikiHighlight-CXgZnvHh.js +0 -1
  430. package/dist/assets/space-apply-1trGVIl8.js +0 -1
  431. package/dist/assets/space-close-y7j-NuBv.js +0 -1
  432. package/dist/assets/tr-ka5J1flt.js +0 -11
  433. package/dist/assets/uk-PyGe6Q_u.js +0 -20
  434. package/dist/assets/useInlineCommentController-CrjSGCpi.js +0 -2
  435. package/dist/assets/vendor-codemirror-lang-python-B7ClrMIT.js +0 -3
  436. package/dist/assets/vendor-codemirror-lang-xml-C8tGnS64.js +0 -1
  437. package/dist/assets/vendor-codemirror-language-data-q2bKO1EM.js +0 -2
  438. package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +0 -1
  439. package/dist/assets/vendor-katex-CHD9BdDO.js +0 -257
  440. package/dist/assets/vendor-katex-Cp579UoJ.css +0 -1
  441. package/dist/assets/zh-CN-B0P2tybJ.js +0 -20
  442. package/dist/assets/zh-TW-Bs9C5cN8.js +0 -20
@@ -0,0 +1,990 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-DI31zD02.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DGlvOqP_.js","assets/index-DxNa7xYB.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-BmFcUkbQ.js","assets/index-BkMXRrVQ.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-Det7U81h.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-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-C4G_dPWe.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-1e0FQ6Wn.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DufXoQvE.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DbpEcZM0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BSHQHbKu.js","assets/vendor-codemirror-lang-json-BzgckzmB.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Cayfb29q.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-BQWerHsJ.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-D2TEBIvZ.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CtwSWKtX.js","assets/vendor-codemirror-lang-python-jAMtYiA9.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-DViGR95I.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-CZ5aafpl.js","assets/space-apply-DM_2pRW7.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/patchFileDiff-Dt8LhgBh.js","assets/parseDiffFromFile-BUgn-T9p.js","assets/computeVirtualFileMetrics-C2WM6JC2.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-CnnR-dnD.js","assets/isDiffPlainText-Dgbw8VKk.js","assets/VirtualizedFileDiff-CFpjL8Ns.js","assets/Virtualizer-C0IsclZn.js","assets/useInlineCommentController-kMN4Wg_D.js","assets/appThemeRegistry-B9gkFq9i.js","assets/textMateThemeFromAppTheme-DlsTphbY.js","assets/vendor-katex-CuQvj9-L.js","assets/vendor-katex-DdZNUVNG.css","assets/useRootScrollLock-DMPpvpNP.js","assets/fileTreeStatus-D438yi8M.js","assets/sessionOwnership-BSuxCEhb.js","assets/DiffView-Cv9MSXl1.js","assets/SubmoduleDiffSummary-BWIfgMED.js","assets/changesTree-CePHbFcj.js","assets/FilesView-BVoD8I2x.js","assets/shikiHighlight-DHDx-6eM.js","assets/vendor-codemirror-search-CvXM_pZg.js","assets/vendor-replit-codemirror-vim-BlJRn-cW.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-DRKHZfsn.js","assets/Virtualizer-CGNyscoc.js","assets/isFilePlainText-_ZS5UYRj.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/FilePreviewCommentMenu-D4kLseHj.js","assets/GitView-Bzb8p-ew.js","assets/InProgressOperationBanner-CwMjNQgk.js","assets/PlanView-RCBadcY7.js","assets/GuestSurfacePane-Crdbvsxo.js","assets/SettingsWindow-DyM7QuhI.js","assets/SettingsView-CjBjZFRO.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-DMIxwYK5.js"])))=>i.map(i=>d[i]);
2
+ import{f as Ve,R as c,j as n,r as us,c as Sm,h as wm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CuQvj9-L.js";import{O as cn,P as $r,Q as jm,R as Qd,h as Fs,I as Xd,u as be,S as Ot,T as Tl,U as rn,B as ur,V as qs,q as Ss,a as Jt,J as Wr,t as ot,W as Os,X as Tr,Y as Vo,Z as km,_ as Cm,$ as Nm,a0 as Am,a1 as Jd,a2 as Pm,a3 as On,a4 as Wi,e as Co,a5 as Im,a6 as Dm,a7 as Em,a8 as Rm,a9 as Tm,F as Mm,aa as Zd,H as an,M as Mr,ab as fr,ac as Om,ad as Go,ae as eu,af as Bm,ag as Fm,ah as Dn,ai as En,aj as Lm,ak as tu,al as _m,am as $m,an as su,ao as Wm,ap as Yn,aq as No,ar as Ki,as as Ea,z as Ra,at as Ta,d as Ao,D as In,y as ms,au as nu,av as ru,aw as Km,ax as zi,ay as zm,az as ou,aA as iu,C as Um,aB as Hm,A as Vm,i as Gm,aC as qm,v as Ym,x as Qm,aD as bo,aE as yo,aF as Xm,aG as Ml,aH as au,f as Jm,aI as Zm,aJ as eh,aK as th,aL as sh,aM as nh,aN as rh,s as oh,aO as ih,aP as ah,aQ as lh,aR as Ol,aS as yi,aT as Bl,aU as Fl,aV as ch,L as Ll,aW as dh,aX as uh,aY as fh,aZ as ph,a_ as mh,a$ as hh,b0 as gh,b1 as bh}from"./index-DxNa7xYB.js";import{_ as kn}from"./vendor-vite-runtime-DD1OZmLC.js";import{ac as _l,ad as xi,ae as sn,af as Ui,ag as $l,ah as yh,ai as xh,aj as vh,ak as Sh,al as wh,am as jh,an as kh,ao as Wl,ap as Ch,aq as Nh,ar as Ah,as as Ma,c as Ph,m as lu,at as Ih,a as Dh,S as Eh,au as Oa,h as Hi,av as Rh,aw as Th,ax as Mh,ay as Oh,az as Bh,aA as Fh,aB as Lh,o as _h,q as $h,t as Wh,P as Kh,w as zh,aC as Uh,F as Hh,N as Vh,H as Gh,J as qh,K as Yh,aD as Qh,aE as cu,aF as rr,aG as Kl,aH as zl,aI as vi,aJ as Ul,L as Xh,a5 as du,T as Jh,aK as uu,aL as Zh,aM as eg,aN as tg,aO as sg,aP as ng,j as Hl,aQ as rg,aR as og,C as ig,b as fu,aS as pu,l as ag,aT as mu,aU as lg,k as cg,aV as dg,e as ug,aW as or,i as fg,aX as pg,f as Si,aY as mg,aZ as Vl,a_ as hg,u as Dr,s as gg,r as bg,D as yg,a$ as xg,d as vg,M as Sg,a4 as wg,V as jg,b0 as kg,_ as Cg,$ as Ng,a0 as Ag,a1 as Pg,a2 as Ig,a6 as Dg,b1 as Eg,b2 as Rg,a7 as Tg,b3 as Mg,ab as Og,b4 as Bg,b5 as Fg,b6 as Lg,b7 as _g,b8 as $g,b9 as Wg,O as Kg,ba as zg,R as Ug,U as Hg,W as Vg,X as Gg,Z as qg,Y as Yg,a3 as Qg,bb as Xg}from"./runtimeEndpointReset-CZ5aafpl.js";import{f as mt,h as xe,bH as Gt,I as $,g as Xn,t as Ke,aS as Ns,bI as Cs,aU as As,aR as Ps,_ as Kr,N as Qs,ay as Fn,bJ as Ln,o as qo,bK as Gl,bL as Jg,bM as Zg,at as Dt,au as Et,av as Pt,bN as eb,b as Xt,z as Ze,J as tb,bO as hu,bP as Jr,u as ws,r as dn,D as gu,C as bu,bQ as Vi,bR as sb,bS as yu,bT as xu,G as vu,bU as Xs,bV as Js,bW as Zs,bX as Yo,bY as gr,bZ as Ls,b_ as _s,b$ as nb,c0 as rb,c1 as ql,c2 as Yl,c3 as Su,c4 as ob,c5 as Ql,c6 as ib,c7 as wu,c8 as Ba,c9 as Gi,ca as ju,cb as ab,cc as lb,cd as cb,R as ku,ce as db,cf as ub,cg as fb,n as ar,ch as pb,ci as mb,cj as hb,p as gb,ck as Cu,cl as bb,cm as yb,cn as Nu,co as Au,cp as Pu,cq as Iu,cr as Du,cs as Eu,ct as Ru,cu as vr,cv as Fa,bd as La,cw as Qn,cx as zr,cy as xb,cz as Jn,B as ft,cA as Cn,b2 as Ts,cB as vb,cC as Sb,cD as Tu,cE as Mu,aE as Bn,cF as ir,cG as wb,cH as jb,cI as kb,cJ as Cb,cK as Nb,cL as Ab,X as Pb,V as Ib,W as Db,cM as Ou,aQ as Tn,cN as Eb,cO as hs,aI as Bu,cP as qi,cQ as lr,cR as Fu,cS as Lu,cT as _u,cU as Rb,cV as Tb,cW as Mb,cX as _a,cY as Ob,cZ as Bb,c_ as Fb,c$ as Lb,d0 as _b,a8 as Po,d1 as Xl,aV as $b,aW as Jl,d2 as Wb,d3 as Kb,d4 as zb,az as Ub,aA as $a,aB as Hb,K as Vb,L as xn,d5 as $u,al as Gb,d6 as qb,d7 as Yb,aZ as Qb,d8 as Xb,d9 as Wa,da as Jb,db as Wu,dc as Yi,dd as qn,b1 as Ka,de as Zb,df as Ku,dg as zu,dh as Uu,di as Nr,dj as Hu,dk as ey,l as ps,s as ty,dl as sy,dm as ny,dn as ry,bg as _n,dp as oy,O as Vu,dq as iy,dr as ay,ds as ly,dt as cy,du as Sr,dv as Gu,dw as dy,dx as uy,dy as fy,dz as wi,dA as py,dB as my,b4 as hy,dC as Ur,dD as qu,dE as gy,dF as za,dG as by,dH as Yu,dI as yy,dJ as Qi,dK as Zl,dL as xy,dM as ec,dN as Ar,dO as vy,dP as tc,dQ as Sy,dR as Nn,c as br,d as Ua,ac as Ha,dS as Qu,dT as wn,dU as wy,dV as Xu,dW as jy,dX as ky,dY as Cy,b3 as Ny,dZ as Ay,ag as Py,ae as Ju,d_ as Iy,b9 as Xi,d$ as Dy,e0 as Ey,e1 as Ry,e2 as Ty,e3 as Kn,e4 as My,e5 as Oy,e6 as sc,ai as Io,e as Va,e7 as By,ah as Ga,ak as Do,ax as Fy,e8 as Zu,e9 as bs,ea as ef,eb as tf,ec as sf,ed as Ly,ee as nf,ef as Ji,P as rf,$ as of,a0 as af,a1 as lf,eg as qa,eh as bn,ei as _y,ej as $y,ek as rs,el as Wy,em as cf,en as df,eo as uf,ep as Or,eq as nc,er as Ky,es as Br,et as zy,eu as Uy,ev as Ya,ew as Eo,ex as Qa,ey as ff,ez as pf,eA as mf,eB as hf,eC as gf,eD as Hy,E as Vy,a2 as Gy,a6 as Xa,ap as qy,a4 as Yy,a3 as rc,eE as Qy,eF as Xy,F as bf,eG as Jy,eH as Zy,eI as ex,eJ as tx,S as ji,eK as Er,bo as Qo,a7 as Zi,eL as sx,eM as nx,eN as rx,eO as ox,eP as ix,aq as ax,eQ as yf,ab as lx,eR as cx,eS as dx,H as Ja,eT as ux,eU as fx,eV as oc,eW as px,eX as mx,ad as hx,af as gx,eY as bx,eZ as zn,e_ as yx,e$ as xx,f0 as vx,f1 as Sx,bt as ic,ao as ac,an as lc,f2 as wx,f3 as jx,am as kx,f4 as Cx,Q as cc,T as ki,U as Nx,f5 as Ax,Y as Px,f6 as Ix,Z as Dx,f7 as Ex,f8 as Rx,f9 as Tx,fa as Mx,fb as Ox,fc as Ro,fd as Bx,fe as Fx,ff as dc,fg as Lx,fh as _x,fi as $x,fj as uc,fk as Wx,a as xf,fl as ea,fm as Za,a5 as vf,fn as Kx,fo as xo,fp as zx,i as Ux,fq as Hx,fr as Vx,fs as Gx,ft as qx,fu as Yx,q as Qx,fv as Xx,bc as Jx,fw as fc,fx as Zx,bh as e1,bi as t1,bk as s1,bj as n1,bm as r1,bn as o1,bp as i1,bs as a1,bq as l1,br as c1,fy as d1,fz as u1,fA as f1,fB as p1,bB as m1,bD as h1,bE as g1,bF as b1,bG as y1}from"./useAppFontEffects-DGlvOqP_.js";import{u as Sf,S as pc,C as x1,t as v1,W as wf,f as S1,G as w1,a as j1}from"./useRootScrollLock-DMPpvpNP.js";import{u as Un,O as mc,D as k1,a as C1,b as N1,G as A1}from"./fileTreeStatus-D438yi8M.js";import{f as Xo,h as vn,T as Jo,M as Zo,D as ei,j as ti,d as P1,b as I1,k as D1,i as E1}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as si,S as el,h as R1,a as jf,v as kf,s as T1}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ni}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Cf,M as Nf,C as Af,a as ta,b as sa,c as na,d as Pf,e as M1,f as O1}from"./vendor-base-ui-Det7U81h.js";import{c as tl,u as yr,p as B1}from"./vendor-zustand-BAGL70zf.js";import{r as sl,a as ri,n as F1,s as jn,o as ra,b as hc}from"./vendor-zod-CxRSdNoV.js";import{c as L1}from"./sessionOwnership-BSuxCEhb.js";import{u as _1}from"./vendor-tanstack-react-virtual-CvuLsk7D.js";import{m as $1,d as W1}from"./vendor-tanstack-virtual-core-DPaNcJcT.js";const K1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",z1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",Ci=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?K1:t.id==="terminal"?z1:void 0}),gc=t=>{const e=Ve.c(8),{label:s,iconDataUrl:r,fallbackIconDataUrl:o}=t,[i,l]=c.useState(!1);let a;e[0]!==s?(a=s.trim().slice(0,1).toUpperCase()||"?",e[0]=s,e[1]=a):a=e[1];const d=a,u=r||o;if(u&&!i){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>l(!0),e[2]=h):h=e[2];let b;return e[3]!==u?(b=n.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:h}),e[3]=u,e[4]=b):b=e[4],b}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=xe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let m;return e[6]!==d?(m=n.jsx("span",{className:f,children:d}),e[6]=d,e[7]=m):m=e[7],m},U1=t=>{const e=Ve.c(75),{directory:s,className:r}=t,{t:o}=mt(),i=Un(H1),l=Un(V1),a=Un(G1),d=Un(q1),u=Un(Y1),f=Un(Q1),m=Un(X1);let h,b;e[0]!==u?(h=()=>{u()},b=[u],e[0]=u,e[1]=h,e[2]=b):(h=e[1],b=e[2]),c.useEffect(h,b);const g=cn()&&$r();let w;e:{let Ae;e[3]!==l||e[4]!==i?(Ae=l.find(X=>X.id===i)??l.find(J1)??l[0]??mc[0],e[3]=l,e[4]=i,e[5]=Ae):Ae=e[5];const K=Ae;if(K){let X;e[6]!==K?(X=Ci(K),e[6]=K,e[7]=X):X=e[7],w=X;break e}let q;e[8]===Symbol.for("react.memo_cache_sentinel")?(q=Ci(mc[0]),e[8]=q):q=e[8],w=q}const S=w;if(!g||!s||l.length===0)return null;let x;e[9]!==s?(x=async Ae=>{await jm(s,Ae.id,Ae.appName)||await Qd(s,Ae.appName)},e[9]=s,e[10]=x):x=e[10];const p=x;let y;e[11]!==p||e[12]!==m?(y=async Ae=>{await m(Ae.id),await p(Ae)},e[11]=p,e[12]=m,e[13]=y):y=e[13];const v=y;let j;e[14]!==s||e[15]!==o?(j=async()=>{(await Xn(s)).ok&&Ke.success(o("openInApp.toast.pathCopied"))},e[14]=s,e[15]=o,e[16]=j):j=e[16];const C=j;let k;e[17]!==r?(k=xe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=k):k=e[18];let T;e[19]!==p||e[20]!==S?(T=()=>{p(S)},e[19]=p,e[20]=S,e[21]=T):T=e[21];const O=d&&"animate-pulse";let M;e[22]!==O?(M=xe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",O),e[22]=O,e[23]=M):M=e[23];let L;e[24]!==S.label||e[25]!==o?(L=o("openInApp.actions.openInAria",{app:S.label}),e[24]=S.label,e[25]=o,e[26]=L):L=e[26];let F;e[27]!==S.fallbackIconDataUrl||e[28]!==S.iconDataUrl||e[29]!==S.label?(F=n.jsx(gc,{label:S.label,iconDataUrl:S.iconDataUrl,fallbackIconDataUrl:S.fallbackIconDataUrl}),e[27]=S.fallbackIconDataUrl,e[28]=S.iconDataUrl,e[29]=S.label,e[30]=F):F=e[30];let D;e[31]!==M||e[32]!==L||e[33]!==F||e[34]!==T?(D=n.jsx("button",{type:"button",onClick:T,className:M,"aria-label":L,children:F}),e[31]=M,e[32]=L,e[33]=F,e[34]=T,e[35]=D):D=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=xe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=U):U=e[36];let N;e[37]!==o?(N=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=N):N=e[38];let A;e[39]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx($,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=A):A=e[39];let H;e[40]!==N?(H=n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:U,"aria-label":N,children:A})}),e[40]=N,e[41]=H):H=e[41];let I;e[42]!==C?(I=()=>{C()},e[42]=C,e[43]=I):I=e[43];let R;e[44]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx($,{name:"file-copy",className:"h-4 w-4"}),e[44]=R):R=e[44];let P;e[45]!==o?(P=o("openInApp.actions.copyPath"),e[45]=o,e[46]=P):P=e[46];let _;e[47]!==P?(_=n.jsx("span",{className:"typography-ui-label text-foreground",children:P}),e[47]=P,e[48]=_):_=e[48];let G;e[49]!==I||e[50]!==_?(G=n.jsxs(Gt,{className:"flex items-center gap-2",onClick:I,children:[R,_]}),e[49]=I,e[50]=_,e[51]=G):G=e[51];let ae;e[52]===Symbol.for("react.memo_cache_sentinel")?(ae=n.jsx(Cs,{}),e[52]=ae):ae=e[52];let Se;if(e[53]!==l||e[54]!==v||e[55]!==S.id){let Ae;e[57]!==v||e[58]!==S.id?(Ae=K=>{const q=Ci(K);return n.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{v(K)},children:[n.jsx(gc,{label:K.label,iconDataUrl:K.iconDataUrl,fallbackIconDataUrl:q.fallbackIconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:K.label}),S.id===K.id?n.jsx($,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},K.id)},e[57]=v,e[58]=S.id,e[59]=Ae):Ae=e[59],Se=l.map(Ae),e[53]=l,e[54]=v,e[55]=S.id,e[56]=Se}else Se=e[56];let J;e[60]!==a||e[61]!==f||e[62]!==o?(J=a?n.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{f(!0)},children:[n.jsx($,{name:"refresh",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=f,e[62]=o,e[63]=J):J=e[63];let re;e[64]!==G||e[65]!==Se||e[66]!==J?(re=n.jsxs(As,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[G,ae,Se,J]}),e[64]=G,e[65]=Se,e[66]=J,e[67]=re):re=e[67];let ie;e[68]!==H||e[69]!==re?(ie=n.jsxs(Ps,{children:[H,re]}),e[68]=H,e[69]=re,e[70]=ie):ie=e[70];let Be;return e[71]!==D||e[72]!==ie||e[73]!==k?(Be=n.jsxs("div",{className:k,children:[D,ie]}),e[71]=D,e[72]=ie,e[73]=k,e[74]=Be):Be=e[74],Be};function H1(t){return t.selectedAppId}function V1(t){return t.availableApps}function G1(t){return t.isCacheStale}function q1(t){return t.isScanning}function Y1(t){return t.initialize}function Q1(t){return t.loadInstalledApps}function X1(t){return t.selectApp}function J1(t){return t.id===k1}const To=new Map,oa=new Set,If=()=>{for(const t of oa)t()},Ni=(t,e)=>{const s=t.trim();s&&(e.length===0?To.delete(s):To.set(s,[...e]),If())},Z1=t=>{To.delete(t.trim())&&If()},Df=[],ev=t=>To.get(t.trim())??Df,tv=t=>(oa.add(t),()=>{oa.delete(t)}),sv=t=>{const e=Ve.c(2);let s;return e[0]!==t?(s=()=>ev(t),e[0]=t,e[1]=s):s=e[1],c.useSyncExternalStore(tv,s,nv)};function nv(){return Df}const rv=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],ov=["dev","start","preview","serve"];async function iv(t,e,s){if(!t)return null;const r=cv(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(s){const o=dv(s);if(o){const i=await uv(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await av(t)){const o=await lv(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function av(t){const e=`${t}/index.html`,s=await Mo(e,t);return typeof s=="string"&&s.trim().length>0}async function lv(){try{const t=await Fs("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),s=typeof e?.port=="number"?e.port:null;return s&&Number.isFinite(s)?s:null}catch{return null}}function cv(t){for(const e of t){const s=`${e.name} ${e.command}`.toLowerCase();if(ov.some(o=>s.includes(o)))return e}return null}function dv(t){for(const{pattern:e}of rv)for(const s of Object.keys(t))if(e.test(s))return s;return null}async function uv(t){const e=await Mo(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const s=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of s){const i=await Mo(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Mo(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await Fs(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const s=Xd()?.files;if(s?.readFile)try{const r=await s.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await Fs(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function fv(t){try{const e=await Mo(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const pv=/\{(worktree|branch)\}/g,Ai=63,mv=new Set(["main","master"]),Ef=t=>/\{(worktree|branch)\}/.test(t??""),hv=async t=>{const e=globalThis.crypto?.subtle;if(!e)return null;const s=await e.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(s).slice(0,3),r=>r.toString(16).padStart(2,"0")).join("")},Rf=async t=>{const e=t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"");if(e.length<=Ai)return e;const s=await hv(e);return s?`${e.slice(0,Ai-7).replace(/-+$/,"")}-${s}`:e.slice(0,Ai).replace(/-+$/,"")},gv=t=>{const e=t?.trim()??"";return e&&e!=="HEAD"?e:null},bv=async(t,e,s)=>{const r=s.includes("{branch}"),o=s.includes("{worktree}")?await t.isLinkedWorktree(e):!1;if(!r&&!o)return{branch:null,linkedWorktree:o};const i=await t.getGitStatus(e,{mode:"light"});return{branch:gv(i.current),linkedWorktree:o}},yv=async t=>!t.linkedWorktree||!t.branch||mv.has(t.branch)?"":Rf(t.branch.split("/").pop()??""),xv=t=>{const e=t.lastIndexOf("@"),s=e>=0?t.slice(0,e+1):"",r=t.slice(e+1);if(r.startsWith("["))return t;const o=r.lastIndexOf(":"),i=o>=0?r.slice(0,o):r,l=o>=0?r.slice(o):"",a=i.split(".").map(d=>d.replace(/^-+|-+$/g,"")).filter(Boolean);return`${s}${a.join(".")}${l}`},vv=async(t,e)=>{const s={worktree:await yv(e),branch:e.branch?await Rf(e.branch):""},r=t.replace(pv,(d,u)=>s[u]),o=/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/i.exec(r);if(!o)return r;const[,i="",l="",a=""]=o;return`${i}${xv(l)}${a}`},Sv=async(t,e,s)=>Ef(e)?vv(e,await bv(t,s,e)):e,nn="__openchamber_auto_discover_preview__",wv=15e3,jv=3e3,Pi=t=>t.id===nn?"scan-2":Nh.find(s=>s.key===t.icon)?.Icon??"play",kv=t=>{const e=(t||"").trim();if(!e)return null;const s=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(s);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Cv=({projectRef:t,directory:e,className:s,compact:r=!1,allowMobile:o=!1})=>{const{t:i}=mt(),{currentTheme:l}=Kr(),{terminal:a,runtime:d,git:u}=Qs(),f=Fn(),{isMobile:m}=Ln(),h=c.useMemo(()=>cn(),[]),b=_l(W=>W.instances),g=_l(W=>W.load),w=be(W=>W.terminalShell),S=be(W=>W.terminalLoginShells.includes(W.terminalShell)),x=be(W=>W.setSettingsPage),p=be(W=>W.setSettingsDialogOpen),y=be(W=>W.setSettingsProjectsSelectedId),v=be(W=>W.openContextPreview),j=Ot(W=>W.ensureDirectory),C=Ot(W=>W.reconcileServerSessions),k=Ot(W=>W.setTabLabel),T=Ot(W=>W.setTabIconKey),O=Ot(W=>W.setActiveTab),M=Ot(W=>W.setConnecting),L=Ot(W=>W.setTabSessionId),F=Ot(W=>W.setTabPurpose),D=Ot(W=>W.allocateActionExecution),U=Ot(W=>W.setTabLifecycle),N=Ot(W=>W.setTabPreviewUrl),A=Ot(W=>W.matchesActionExecution),H=Ot(W=>W.captureStartedActionMutationRevisions),[I,R]=c.useState([]),P=c.useRef(null),[_,G]=c.useState(null),[ae,Se]=c.useState(!1),J=c.useRef({}),re=c.useRef({}),ie=c.useRef({}),Be=c.useRef(new Set),Ae=c.useRef(0),[K,q]=c.useState({}),X=t?.id??null,me=t?.path??"",he=c.useMemo(()=>X?{id:X,path:me}:null,[X,me]);c.useEffect(()=>{h&&g().catch(()=>{})},[h,g]);const je=c.useCallback(async W=>{await qo(W)},[]),Y=c.useCallback(async()=>{if(!he)return;const W=Ae.current+1;Ae.current=W,Se(!0);try{const Z=await Gl(he);if(Ae.current!==W)return;P.current=Z;const ve=Z.projectActions;R(ve),G(E=>E===nn||E&&ve.some(V=>V.id===E)?E:null)}catch{if(Ae.current!==W)return}finally{Ae.current===W&&Se(!1)}},[he]),ue=c.useMemo(()=>xi(e||he?.path||""),[e,he?.path]),we=c.useMemo(()=>xi(he?.path||""),[he?.path]),ce=c.useMemo(()=>xi(f||"")||ue,[f,ue]),le=c.useRef(ce);c.useEffect(()=>{le.current=ce},[ce]);const Re=Ot(W=>ue?W.getDirectoryState(ue):void 0),Oe=Ot(W=>we&&we!==ue?W.getDirectoryState(we):void 0),Te=c.useMemo(()=>{const W=ue?[{directory:ue,state:Re}]:[];return we&&we!==ue&&W.push({directory:we,state:Oe}),W},[Re,ue,we,Oe]),De=c.useMemo(()=>{const W=ue?[ue]:[];return we&&we!==ue&&W.push(we),W},[ue,we]),te=c.useCallback(W=>W.id!==nn&&W.runIn==="parent"&&we||ue,[ue,we]),de=c.useCallback((W,Z,ve)=>`${W}::${Z}::${ve}`,[]),fe=c.useCallback((W,Z,ve=Ot.getState())=>W?ve.getDirectoryState(W)?.tabs.find(E=>E.purpose.type==="project-action"&&E.purpose.actionId===Z)??null:null,[]),ge=c.useMemo(()=>{const W={};for(const{directory:Z,state:ve}of Te)for(const E of ve?.tabs??[]){if(E.purpose.type!=="project-action"||!E.purpose.executionId||!E.terminalSessionId||E.lifecycle==="idle"||E.lifecycle==="exited")continue;const V=sn(Z,E.purpose.actionId),Ne=de(Z,E.purpose.actionId,E.purpose.executionId);W[V]={directory:Z,actionId:E.purpose.actionId,tabId:E.id,sessionId:E.terminalSessionId,executionId:E.purpose.executionId,status:E.lifecycle==="stopping"?"stopping":K[Ne]?"waiting-for-preview":"running"}}return W},[de,K,Te]),B=c.useCallback((W,Z,ve)=>{const E=sn(W,Z),V=de(W,Z,ve),We=J.current[E]?.executionId===ve,Ge=globalThis.window,qe=Pe=>{Ge?.clearTimeout(ie.current[Pe]),delete ie.current[Pe]};We&&(delete J.current[E],qe(E)),re.current[V]?.(),delete re.current[V],qe(V),q(Pe=>{if(!Pe[V])return Pe;const ze={...Pe};return delete ze[V],ze})},[de]),Q=c.useCallback(W=>{re.current[W]?.(),delete re.current[W]},[]),ke=c.useCallback(W=>{window.clearTimeout(ie.current[W]),delete ie.current[W]},[]);c.useEffect(()=>{const W=re.current,Z=ie.current;return()=>{for(const ve of Object.keys(W))Q(ve);for(const ve of Object.keys(Z))ke(ve)}},[ke,Q]),c.useEffect(()=>{const W=new Set(De);for(const Z of Object.values(J.current))W.has(Z.directory)||B(Z.directory,Z.actionId,Z.executionId);for(const Z of Object.keys(re.current)){const ve=Z.split("::",1)[0]??"";W.has(ve)||Q(Z)}},[B,Q,De]);const Ie=c.useCallback((W,Z)=>{be.getState().openContextPanelTab(W,{mode:"terminal",targetDirectory:Z===W?null:Z})},[]),oe=c.useMemo(()=>_?I.find(W=>W.id===_)??null:null,[I,_]),$e=c.useMemo(()=>({id:nn,name:i("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[i]),Fe=!m,Ce=c.useMemo(()=>Fe?[$e,...I]:I,[I,$e,Fe]);c.useEffect(()=>{Y()},[Y]),c.useEffect(()=>{const W=De.map(Z=>Ui(a,Z,H,ve=>C(Z,ve.sessions,{startedActionMutationRevisions:ve.startedActionMutationRevisions})));return()=>{for(const Z of W)Z()}},[H,C,a,De]),c.useEffect(()=>{for(const{directory:W,state:Z}of Te)if(W)for(const ve of Z?.tabs??[]){if(ve.purpose.type!=="project-action")continue;const E=ve.purpose.actionId,V=Ce.find(Ge=>Ge.id===E),Ne=V?.name??E,We=V?.icon||"play";ve.label!==Ne&&k(W,ve.id,Ne),ve.iconKey!==We&&T(W,ve.id,We)}},[Ce,T,k,Te]),c.useEffect(()=>{const W=globalThis.window;if(!W)return;const Z=ve=>{const E=ve.detail;X&&(E?.projectId&&E.projectId!==X||Y())};return W.addEventListener($l,Z),()=>{W.removeEventListener($l,Z)}},[Y,X]),c.useEffect(()=>{_&&(_===nn&&Fe||I.some(W=>W.id===_)||G(null))},[I,Fe,_]),c.useEffect(()=>{const W=ve=>{delete ie.current[ve];const E=J.current[ve];if(!E||E.openedUrl)return;const V=de(E.directory,E.actionId,E.executionId),Ne=E.announced;if(Ne.length!==0){if(window.clearTimeout(ie.current[V]),delete ie.current[V],E.openedUrl=!0,q(We=>{if(!We[V])return We;const Ge={...We};return delete Ge[V],Ge}),Ne.length===1){Ni(E.directory,[]),N(E.directory,E.tabId,Ne[0],{locked:!1,autoOpened:!0}),v(E.directory,Ne[0]);return}E.offering=!0,Ni(E.directory,Ne),be.getState().openContextSurface(E.directory,"browser"),Ke.info(i("projectActions.toast.multipleServers"))}},Z=()=>{const ve=Ot.getState(),E=ve.sessions,V=ge;for(const[Ne,We]of Object.entries(V)){const qe=E.get(We.directory)?.tabs.find(ct=>ct.id===We.tabId);if(!qe||qe.terminalSessionId!==We.sessionId){B(We.directory,We.actionId,We.executionId);continue}const Pe=J.current[Ne],ze=Pe?.executionId===We.executionId?Pe:{hostDirectory:le.current||We.directory,directory:We.directory,tabId:We.tabId,actionId:We.actionId,executionId:We.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1,proxiedPorts:[]};J.current[Ne]=ze;const Rt=Ce.find(ct=>ct.id===We.actionId),zt=ve.getBuffer(We.directory,We.tabId).chunks;if(!Rt||zt.length===0)continue;const Tt=zt.filter(ct=>ze.lastSeenChunkId===null||ct.id>ze.lastSeenChunkId);if(Tt.length===0)continue;const Ft=Tt.map(ct=>ct.data).join(""),gt=`${ze.tail}${Ft}`;for(const ct of jh(gt))ze.proxiedPorts.includes(ct)||ze.proxiedPorts.push(ct);if(ze.openInPreview&&(!ze.openedUrl||ze.offering)){const ct=kh(gt,{proxiedPorts:ze.proxiedPorts,namedAddressesReachable:!Wl()}),at=ze.announced.length;for(const $t of ct)ze.announced.includes($t)||ze.announced.push($t);const yt=ze.announced.length-at;ze.offering&&yt>0?Ni(We.directory,ze.announced):!ze.openedUrl&&at===0&&ze.announced.length>0&&(window.clearTimeout(ie.current[Ne]),ie.current[Ne]=window.setTimeout(()=>W(Ne),jv))}const vt=!ze.openedUrl&&Rt.autoOpenUrl===!0&&!ze.openInPreview?Ch(gt,{proxiedPorts:ze.proxiedPorts,namedAddressesReachable:!Wl()}):null,qt=Tt[Tt.length-1]?.id??ze.lastSeenChunkId;if(ze.lastSeenChunkId=qt,ze.tail=gt.slice(-512),vt)if(ze.openedUrl=!0,ze.openInPreview){const ct=V[Ne];ct&&(N(ct.directory,ct.tabId,vt,{locked:!1,autoOpened:!1,expectedExecutionId:ct.executionId}),ct.status==="waiting-for-preview"&&q(at=>{const yt=de(ct.directory,ct.actionId,ct.executionId);if(!at[yt])return at;const $t={...at};return delete $t[yt],$t}),window.clearTimeout(ie.current[Ne]),delete ie.current[Ne],v(ct.directory,vt))}else je(vt),Ke.success(i("projectActions.toast.openedUrlFromOutput"));J.current[Ne]=ze}for(const Ne of Object.keys(J.current))if(!V[Ne]){const We=J.current[Ne],Ge=We?E.get(We.directory)?.tabs.find(Pe=>Pe.id===We.tabId):void 0;if(Ge?.purpose.type==="project-action"&&Ge.purpose.executionId===We?.executionId&&!!Ge.terminalSessionId&&Ge.lifecycle!=="idle"&&Ge.lifecycle!=="exited")continue;delete J.current[Ne],window.clearTimeout(ie.current[Ne]),delete ie.current[Ne]}};return Z(),Ot.subscribe((ve,E)=>{(ve.sessions!==E.sessions||ve.buffers!==E.buffers)&&Z()})},[B,le,Ce,de,v,je,ge,N,i]),c.useEffect(()=>{for(const{directory:W,state:Z}of Te)for(const ve of Z?.tabs??[]){if(ve.purpose.type!=="project-action"||!ve.purpose.executionId||!ve.terminalSessionId||ve.lifecycle!=="running")continue;const E=ve.purpose.actionId,V=ve.purpose.executionId,Ne=de(W,E,V);if(re.current[Ne])continue;const We=a.connect(ve.terminalSessionId,{onEvent:Ge=>{if(!A(W,ve.id,V))return;Ge.type==="snapshot"&&(Ot.getState().replaceBuffer(W,ve.id,Ge.data??"",Ge.sequence??0,Tl(Ge)),Ge.status==="running"&&Ot.getState().setTabLifecycle(W,ve.id,"running",{expectedExecutionId:V}),Ge.status==="exited"&&(Ot.getState().setTabLifecycle(W,ve.id,"exited",{expectedExecutionId:V}),Ot.getState().setTabPurpose(W,ve.id,{type:"project-action",actionId:E,executionId:null}),B(W,E,V)));const qe=Ge.type==="data"?Ge.data??"":"";qe&&Ot.getState().appendToBuffer(W,ve.id,qe,Ge.sequence,Ge.replayData),Ge.type==="exit"&&(Ot.getState().setTabLifecycle(W,ve.id,"exited",{expectedExecutionId:V}),Ot.getState().setTabPurpose(W,ve.id,{type:"project-action",actionId:E,executionId:null}),B(W,E,V))},onError:(Ge,qe)=>{!qe||!A(W,ve.id,V)||(Ot.getState().setTabLifecycle(W,ve.id,"exited",{expectedExecutionId:V}),Ot.getState().setTabSessionId(W,ve.id,null,{expectedExecutionId:V}),Ot.getState().setTabPurpose(W,ve.id,{type:"project-action",actionId:E,executionId:null}),B(W,E,V))}},W);re.current[Ne]=We.close}},[B,de,A,a,Te]);const Ue=c.useCallback(async W=>{const Z=te(W);if(!Z)throw new Error(i("projectActions.error.noActiveDirectory"));const ve=sn(Z,W.id);j(Z);const E=Ot.getState(),V=fe(Z,W.id,E),Ne=V?.id??E.createTab(Z);k(Z,Ne,W.name),T(Z,Ne,W.icon||"play"),V||F(Z,Ne,{type:"project-action",actionId:W.id,executionId:null}),O(Z,Ne);const Ge=Ot.getState().getDirectoryState(Z)?.tabs.find(qe=>qe.id===Ne);return{executionDirectory:Z,key:ve,tabId:Ne,sessionId:Ge?.terminalSessionId??null,executionId:Ge?.purpose.type==="project-action"?Ge.purpose.executionId:null}},[j,te,fe,O,T,k,F,i]),pe=c.useCallback(async W=>{if(d.isVSCode||!o&&m)return;if(!ue){Ke.error(i("projectActions.error.noActiveDirectoryForAction"));return}const Z=sn(te(W),W.id),ve=ge[Z];if(ve&&ve.status==="running"||Be.current.has(Z))return;Be.current.add(Z);let E=null;try{const V=W.id===nn?await(async()=>{const[jt,kt]=await Promise.all([Jg({id:he?.id??"",path:ue}),fv(ue)]),Vt=await iv(ue,jt.actions,kt);if(!Vt)throw new Error(i("contextPanel.preview.noDevServer"));return{id:nn,name:i("projectActions.actions.autoDiscover"),command:Vt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Vt.previewUrlHint||""}})():W,Ne=V.autoOpenUrl===!0&&(V.openUrl||"").trim().length>0,We=!Ne&&W.id!==nn,Ge=le.current||ue,{executionDirectory:qe,key:Pe,tabId:ze}=await Ue(V),Rt=yh(V.command);if(!Rt)throw new Error(i("projectActions.error.failedToRunAction"));const zt=V.autoOpenUrl===!0&&h&&(V.desktopOpenSshForward||"").trim().length>0,Tt=V.autoOpenUrl&&V.openUrl||"";let Ft=!1;const gt=Ef(Tt)?await Sv(u,Tt,qe).catch(()=>(Ft=!0,"")):Tt,vt=V.autoOpenUrl?kv(gt):null,qt=V.autoOpenUrl&&h?xh(V.desktopOpenSshForward,b):null;if(a.listSessions){const jt=fe(qe,V.id);if(jt?.purpose.type==="project-action"&&jt.purpose.executionId===null){const kt=await vh(a,qe,{captureStartedActionMutationRevisions:H});kt&&C(qe,kt.sessions,{startedActionMutationRevisions:kt.startedActionMutationRevisions})}}const ct=fe(qe,V.id);let at,yt;if(ct?.lifecycle==="running"&&ct.terminalSessionId&&ct.purpose.type==="project-action"&&ct.purpose.executionId)at=ct.terminalSessionId,yt=ct.purpose.executionId;else{const jt=ct?.purpose.type==="project-action"?ct.purpose.executionId:null;jt&&B(qe,V.id,jt);const kt=D(qe,ze,V.id);if(!kt)throw new Error(i("projectActions.error.failedToCreateTerminalSession"));E={directory:qe,tabId:ze,id:kt},M(qe,ze,!0,{expectedExecutionId:kt});const Vt=await Sh({terminal:a,createOptions:{cwd:qe,shell:w,loginShell:S,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Rt,isRunStillExpected:()=>A(qe,ze,kt),purpose:{type:"project-action",actionId:V.id,executionId:kt}});if(!A(qe,ze,kt)){Vt.sessionId===kt&&await a.close(Vt.sessionId).catch(()=>{});return}yt=Vt.purpose?.type==="project-action"?Vt.purpose.executionId:kt,at=Vt.sessionId,F(qe,ze,{type:"project-action",actionId:V.id,executionId:yt}),L(qe,ze,at,{expectedExecutionId:yt}),M(qe,ze,!1,{expectedExecutionId:yt})}We&&Ge&&Ie(Ge,qe),J.current[Pe]={hostDirectory:Ge,directory:qe,tabId:ze,actionId:V.id,executionId:yt,lastSeenChunkId:null,openedUrl:!!qt||!!vt||Ne,tail:"",openInPreview:V.id===nn,announced:[],offering:!1,proxiedPorts:[]};const $t=de(qe,V.id,yt);M(qe,ze,!0,{expectedExecutionId:yt});const ls=a.connect(at,{onEvent:jt=>{if(!A(qe,ze,yt)||jt.purpose?.type==="project-action"&&jt.purpose.executionId!==yt)return;jt.type==="snapshot"&&(Ot.getState().replaceBuffer(qe,ze,jt.data??"",jt.sequence??0,Tl(jt)),Ot.getState().setConnecting(qe,ze,!1,{expectedExecutionId:yt}),jt.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(qe,ze,{type:"project-action",actionId:jt.purpose.actionId,executionId:jt.purpose.executionId}),jt.status==="running"&&Ot.getState().setTabLifecycle(qe,ze,"running",{expectedExecutionId:yt}),jt.status==="exited"&&(Ot.getState().setTabLifecycle(qe,ze,"exited",{expectedExecutionId:yt}),Ot.getState().setTabPurpose(qe,ze,{type:"project-action",actionId:V.id,executionId:null}),B(qe,V.id,yt)));const kt=jt.type==="data"?jt.data??"":"";kt&&Ot.getState().appendToBuffer(qe,ze,kt,jt.sequence,jt.replayData),jt.type==="exit"&&(Ot.getState().setTabLifecycle(qe,ze,"exited",{expectedExecutionId:yt}),Ot.getState().setConnecting(qe,ze,!1,{expectedExecutionId:yt}),Ot.getState().setTabPurpose(qe,ze,{type:"project-action",actionId:V.id,executionId:null}),B(qe,V.id,yt))},onError:(jt,kt)=>{A(qe,ze,yt)&&(Ot.getState().setConnecting(qe,ze,!1,{expectedExecutionId:yt}),kt&&(Ot.getState().setTabLifecycle(qe,ze,"exited",{expectedExecutionId:yt}),Ot.getState().setTabSessionId(qe,ze,null,{expectedExecutionId:yt}),Ot.getState().setTabPurpose(qe,ze,{type:"project-action",actionId:V.id,executionId:null}),B(qe,V.id,yt)))}},qe);if(!A(qe,ze,yt)){ls.close();return}re.current[$t]?.(),re.current[$t]=ls.close,window.clearTimeout(ie.current[$t]),delete ie.current[$t],V.id===nn&&!vt&&(q(jt=>({...jt,[$t]:!0})),ie.current[$t]=window.setTimeout(()=>{delete ie.current[$t];const jt=J.current[Pe];!jt||jt.executionId!==yt||jt.openedUrl||jt.offering||A(qe,ze,yt)&&(q(kt=>{if(!kt[$t])return kt;const Vt={...kt};return delete Vt[$t],Vt}),Ot.getState().setActiveTab(qe,ze),Ie(jt.hostDirectory,qe))},wv)),qt?(N(qe,ze,null,{locked:!0,expectedExecutionId:yt}),je(qt),Ke.success(i("projectActions.toast.openedForwardedUrl"))):vt?(N(qe,ze,vt,{locked:!0,autoOpened:!0,expectedExecutionId:yt}),v(Ge,vt),Ke.success(i("projectActions.toast.openedActionUrl"))):Ft?(N(qe,ze,null,{locked:!0,expectedExecutionId:yt}),Ke.error(i("projectActions.error.openUrlTemplateUnresolved"))):Ne?(N(qe,ze,null,{locked:!0,expectedExecutionId:yt}),Ke.error(i("projectActions.error.invalidCustomUrlFormat"))):zt?(N(qe,ze,null,{locked:!0,expectedExecutionId:yt}),Ke.error(i("projectActions.error.selectedDesktopSshForwardUnavailable"))):N(qe,ze,null,{locked:!1,autoOpened:!1,expectedExecutionId:yt})}catch(V){if(E&&A(E.directory,E.tabId,E.id)){const{directory:Ne,tabId:We,id:Ge}=E;B(Ne,W.id,Ge),U(Ne,We,"exited",{expectedExecutionId:Ge}),F(Ne,We,{type:"project-action",actionId:W.id,executionId:null})}if(V instanceof Error&&V.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(V instanceof Error&&(V.message==="COMMAND_MODE_UNSUPPORTED"||V.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Ke.error(i("projectActions.error.failedToCreateTerminalSession"));return}Ke.error(V instanceof Error?V.message:i("projectActions.error.failedToRunAction"))}finally{Be.current.delete(Z)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,le,b,Ue,u,o,m,h,ue,S,w,je,v,ge,Ie,d.isVSCode,te,A,B,de,fe,C,D,H,M,U,F,N,L,he?.id,i,a]),ne=c.useCallback(async W=>{const Z=sn(te(W),W.id),ve=ge[Z];ve&&await wh({terminal:a,sessionId:ve.sessionId,isExecutionStillCurrent:()=>A(ve.directory,ve.tabId,ve.executionId),markStopping:()=>{U(ve.directory,ve.tabId,"stopping",{expectedExecutionId:ve.executionId})},restoreRunning:()=>{U(ve.directory,ve.tabId,"running",{expectedExecutionId:ve.executionId})},clearSession:()=>{L(ve.directory,ve.tabId,null,{expectedExecutionId:ve.executionId})},finalizeExit:()=>{U(ve.directory,ve.tabId,"exited",{expectedExecutionId:ve.executionId}),F(ve.directory,ve.tabId,{type:"project-action",actionId:ve.actionId,executionId:null}),B(ve.directory,ve.actionId,ve.executionId)}})},[B,te,A,ge,U,F,L,a]),Me=c.useCallback(()=>{const W=oe??Ce[0];if(!W)return;const Z=sn(te(W),W.id),ve=ge[Z];if(ve?.status!=="stopping"){if(ve){ne(W);return}pe(W)}},[Ce,te,pe,ge,oe,ne]),He=c.useCallback(async W=>{if(W.source==="shared"&&he){const Z=P.current?.trust.trusted?P.current:await Gl(he);if(P.current=Z,!await Zg(he,Z))return;P.current={...Z,trust:{...Z.trust,trusted:!0}}}await pe(W)},[pe,he]),Ye=c.useCallback((W,Z=!1)=>{if(G(W.id),!Z){He(W);return}const ve=sn(te(W),W.id),E=ge[ve];if(E?.status!=="stopping"){if(E){ne(W);return}He(W)}},[te,He,ge,ne]),Xe=c.useCallback(()=>{he?.id&&(y(he.id),x("projects"),p(!0))},[p,x,y,he?.id]),Je=oe??Ce[0]??null,bt=Je?ge[sn(te(Je),Je.id)]:null,et=Ot(W=>bt?W.getDirectoryState(bt.directory)?.tabs.find(Z=>Z.id===bt.tabId)?.previewUrl??null:null);if(d.isVSCode||!o&&m||!he||!ue)return null;const lt=oe??Ce[0]??null;if(!lt)return null;const xt=Pi(lt),wt=sn(te(lt),lt.id),dt=ge[wt],It=dt?.status==="stopping",_t=dt?.status==="waiting-for-preview",Bt=!!(dt&&et),ye=()=>{!dt||!et||v(dt.directory,et)},z=lt.id===nn;return r?n.jsxs("div",{className:"inline-flex items-center",children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",disabled:ae||It,className:xe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",s),onClick:Me,"aria-label":dt?i("projectActions.actions.stopNamedAria",{name:lt.name}):i("projectActions.actions.runNamedAria",{name:lt.name}),children:It||_t?n.jsx($,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):dt?n.jsx($,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):n.jsx($,{name:xt,className:"h-5 w-5"})})}),z?n.jsx(Pt,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),Bt?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("projectActions.actions.openPreview"),onClick:ye,children:n.jsx($,{name:"global",className:"h-4 w-4"})})}),n.jsx(Pt,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("projectActions.actions.chooseActionAria"),children:n.jsx($,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),n.jsxs(As,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[n.jsxs(Gt,{className:"flex items-center gap-2",onClick:Xe,children:[n.jsx($,{name:"add",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),n.jsx(Cs,{}),Ce.map(W=>{const Z=Pi(W),ve=sn(te(W),W.id),E=ge[ve],V=!!E,Ne=E?.status==="stopping";return n.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Ye(W,!0)},children:[n.jsx($,{name:Z,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:W.name}),W.source==="shared"?n.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:i("projectActions.menu.sharedBadge")}):null,Ne||E?.status==="waiting-for-preview"?n.jsx($,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?n.jsx($,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},W.id)})]})]})]}):n.jsxs("div",{className:xe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",s),children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Me,disabled:ae||It,className:xe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":dt?i("projectActions.actions.stopNamedAria",{name:lt.name}):i("projectActions.actions.runNamedAria",{name:lt.name}),children:n.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:It||_t?n.jsx($,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):dt?n.jsx($,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):n.jsx($,{name:xt,className:"h-4 w-4"})})})}),z?n.jsx(Pt,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),Bt?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:ye,className:xe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":i("projectActions.actions.openPreview"),children:n.jsx($,{name:"global",className:"h-4 w-4"})})}),n.jsx(Pt,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:xe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":i("projectActions.actions.chooseActionAria"),children:n.jsx($,{name:"arrow-down-s",className:"h-4 w-4"})})}),n.jsxs(As,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[n.jsxs(Gt,{className:"flex items-center gap-2",onClick:Xe,children:[n.jsx($,{name:"add",className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),n.jsx(Cs,{}),Ce.map(W=>{const Z=Pi(W),ve=sn(te(W),W.id),E=ge[ve],V=!!E,Ne=E?.status==="stopping";return n.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Ye(W,!0)},children:[n.jsx($,{name:Z,className:"h-4 w-4"}),n.jsx("span",{className:"typography-ui-label text-foreground truncate",children:W.name}),W.source==="shared"?n.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:i("projectActions.menu.sharedBadge")}):null,Ne||E?.status==="waiting-for-preview"?n.jsx($,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?n.jsx($,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},W.id)})]})]})]})},Nv=t=>{const e=Ve.c(23),{directory:s,className:r,iconClassName:o}=t,{t:i}=mt(),l=be(Av);let a;e[0]!==s?(a=rn(s),e[0]=s,e[1]=a):a=e[1];const d=a;let u;e[2]!==d?(u=v=>eb(d?v.journey?.get(d):void 0),e[2]=d,e[3]=u):u=e[3];const f=ur(u);let m;e[4]!==d?(m=v=>d?v.actions.get(d)?.kind==="running":!1,e[4]=d,e[5]=m):m=e[5];const h=ur(m);if(!l||!d||!f||qs())return null;let b;e[6]!==i?(b=i("spaces.header.apply"),e[6]=i,e[7]=b):b=e[7];const g=b;let w;e[8]!==d?(w=()=>ur.getState().openApplyDialog(d),e[8]=d,e[9]=w):w=e[9];let S;e[10]!==o?(S=n.jsx($,{name:"git-merge",className:o}),e[10]=o,e[11]=S):S=e[11];let x;e[12]!==h||e[13]!==r||e[14]!==g||e[15]!==w||e[16]!==S?(x=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":g,disabled:h,onClick:w,className:r,children:S})}),e[12]=h,e[13]=r,e[14]=g,e[15]=w,e[16]=S,e[17]=x):x=e[17];let p;e[18]!==g?(p=n.jsx(Pt,{side:"bottom",children:g}),e[18]=g,e[19]=p):p=e[19];let y;return e[20]!==x||e[21]!==p?(y=n.jsxs(Dt,{children:[x,p]}),e[20]=x,e[21]=p,e[22]=y):y=e[22],y};function Av(t){return t.isolatedSpacesEnabled}const Pr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Pv=({projects:t,worktreesByProject:e,directory:s,activeProjectId:r})=>{const o=Pr(s??"");if(o){const i=hu(t,e,o);if(i)return i}return t.find(i=>i.id===r)??null};function Iv(){const t=Xt(g=>g.projects),e=Xt(g=>g.activeProjectId),s=Ze(g=>g.availableWorktreesByProject),r=Ze(g=>g.currentSessionId),o=tb(r??null),i=Ze(g=>r?g.worktreeMetadata.get(r)?.path??"":""),l=Ze(g=>g.newSessionDraft?.open?Pr(g.newSessionDraft.bootstrapPendingDirectory??g.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Pr(i||""),[i]),d=c.useMemo(()=>{const g=typeof o?.directory=="string"?o.directory:"";return Pr(g||"")},[o?.directory]),u=a||d||l,f=c.useMemo(()=>Pv({projects:t,worktreesByProject:s,directory:u,activeProjectId:e}),[e,u,t,s]),m=c.useMemo(()=>Pr(u||f?.path||""),[u,f?.path]),h=c.useMemo(()=>f?{id:f.id,path:f.path}:null,[f]),b=c.useRef(null);return c.useEffect(()=>{h&&m&&(b.current={projectRef:h,directory:m})},[m,h]),c.useMemo(()=>h&&m?{projectRef:h,directory:m}:b.current,[h,m])}const Dv=({transform:t})=>({...t,y:0}),Ev=16,Rv=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*Ev:t.deltaY;t.currentTarget.scrollLeft+=e},Tv={Item:Gt,Separator:Cs},Mv={Item:({className:t,...e})=>n.jsx(Nf,{className:xe(xu,t),...e}),Separator:({className:t,...e})=>n.jsx(Cf,{className:xe(yu,t),...e})},Ov=t=>{const e=Ve.c(63),{tab:s,isActive:r,suppressControls:o,onSelect:i,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:f}=t,{t:m}=mt(),[h,b]=c.useState(!1),[g,w]=c.useState(!1),[S,x]=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:v,setNodeRef:j,transform:C,transition:k,isDragging:T}=si(p);let O;e[2]!==m||e[3]!==s.session.title?(O=s.session.title?.trim()||m("sessions.sidebar.session.untitled"),e[2]=m,e[3]=s.session.title,e[4]=O):O=e[4];const M=O,L=!o&&(h||g),F=s.id;let D;e[5]!==s.session?(D=dn(s.session),e[5]=s.session,e[6]=D):D=e[6];const U=Ma(F,D),N=gu(s.id),A=N!==null,I=bu(s.id)>0&&!r&&!A,R=A||I;let P;e[7]!==d||e[8]!==S||e[9]!==r||e[10]!==h||e[11]!==i||e[12]!==s?(P=Y=>({session:s.session,open:h||S,isActive:r,select:()=>i(s),closeOtherTabs:()=>d(s.id),components:Y}),e[7]=d,e[8]=S,e[9]=r,e[10]=h,e[11]=i,e[12]=s,e[13]=P):P=e[13];const _=P;let G;e[14]!==C?(G=ni.Translate.toString(C),e[14]=C,e[15]=G):G=e[15];let ae;e[16]!==G||e[17]!==k?(ae={transform:G,transition:k},e[16]=G,e[17]=k,e[18]=ae):ae=e[18];const Se=T&&"z-10 opacity-60";let J;e[19]!==Se?(J=xe("app-region-no-drag session-tab-slot flex h-7 w-44 shrink-0 touch-none",Se),e[19]=Se,e[20]=J):J=e[20];const re=r?"true":"false";let ie;e[21]!==r?(ie=r?{"data-active-session-tab":!0}:{},e[21]=r,e[22]=ie):ie=e[22];let Be;e[23]!==u?(Be=Y=>u?.(Y),e[23]=u,e[24]=Be):Be=e[24];let Ae;e[25]!==f||e[26]!==r||e[27]!==U||e[28]!==_||e[29]!==h||e[30]!==l||e[31]!==u||e[32]!==i||e[33]!==L||e[34]!==a||e[35]!==R||e[36]!==o||e[37]!==m||e[38]!==s||e[39]!==M||e[40]!==N?(Ae=n.jsx(Af,{render:Y=>n.jsxs("div",{...Y,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>i(s),onKeyDown:r?void 0:ue=>{(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),i(s))},onAuxClick:ue=>{ue.button===1&&(ue.preventDefault(),l(s.id))},"data-controls-open":L?"true":"false",className:xe("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":xe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",L&&"bg-interactive-hover text-foreground")),children:[n.jsxs("div",{className:xe("flex min-w-0 flex-1 items-center",!o&&"group-hover/session-tab:pr-10",L&&"pr-10"),children:[n.jsx("div",{className:xe("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 text-left text-[13px] font-medium leading-4",children:M})})}),U?n.jsx($,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":m("sessions.aiRename.generating")}):R?n.jsx(vu,{state:N??"unread",className:xe("ml-1.5 shrink-0",!o&&"group-hover/session-tab:opacity-0",L&&"opacity-0")}):null]}),o?null:n.jsxs("div",{onClick:Fv,onPointerDown:Lv,className:xe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",L&&"flex opacity-100"),children:[n.jsxs(Ps,{open:h,onOpenChange:ue=>{b(ue),ue&&w(!0)},onOpenChangeComplete:ue=>{ue||w(!1),u?.(ue)},children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":m("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:n.jsx($,{name:"more",className:"size-4"})})}),n.jsx(As,{align:"start",className:"min-w-[190px]",children:a(_(Tv))})]}),n.jsx("button",{type:"button","aria-label":m("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($,{name:"close",className:"size-4"})})]})]})}),e[25]=f,e[26]=r,e[27]=U,e[28]=_,e[29]=h,e[30]=l,e[31]=u,e[32]=i,e[33]=L,e[34]=a,e[35]=R,e[36]=o,e[37]=m,e[38]=s,e[39]=M,e[40]=N,e[41]=Ae):Ae=e[41];let K,q;e[42]===Symbol.for("react.memo_cache_sentinel")?(K={color:"var(--surface-elevated-foreground)"},q=xe(Vi,"min-w-[190px]"),e[42]=K,e[43]=q):(K=e[42],q=e[43]);let X;e[44]!==_||e[45]!==a?(X=a(_(Mv)),e[44]=_,e[45]=a,e[46]=X):X=e[46];let me;e[47]!==X?(me=n.jsx(ta,{children:n.jsx(sa,{className:"app-region-no-drag z-50",children:n.jsx(na,{"data-slot":"dropdown-menu-content",style:K,className:q,children:X})})}),e[47]=X,e[48]=me):me=e[48];let he;e[49]!==S||e[50]!==Be||e[51]!==Ae||e[52]!==me?(he=n.jsxs(Pf,{open:S,onOpenChange:x,onOpenChangeComplete:Be,children:[Ae,me]}),e[49]=S,e[50]=Be,e[51]=Ae,e[52]=me,e[53]=he):he=e[53];let je;return e[54]!==y||e[55]!==v||e[56]!==j||e[57]!==re||e[58]!==ie||e[59]!==he||e[60]!==ae||e[61]!==J?(je=n.jsx("div",{ref:j,style:ae,className:J,"data-active":re,...ie,...y,...v,children:he}),e[54]=y,e[55]=v,e[56]=j,e[57]=re,e[58]=ie,e[59]=he,e[60]=ae,e[61]=J,e[62]=je):je=e[62],je},Bv=t=>{const e=Ve.c(65),{renderMenu:s,onMenuOpenChangeComplete:r,suppressActiveTabControls:o,children:i}=t,l=o===void 0?!1:o,{t:a}=mt(),d=Jr(_v),u=Jr($v),f=Jr(Wv),m=Jr(Kv),h=Ze(zv),b=Ze(Uv),g=ws(Hv),w=Ah(h);let S,x;e[0]!==w||e[1]!==h||e[2]!==u?(S=()=>{h&&u(h,w)},x=[h,w,u],e[0]=w,e[1]=h,e[2]=u,e[3]=S,e[4]=x):(S=e[3],x=e[4]),c.useEffect(S,x);let p;if(e[5]!==g){p=new Map;for(const le of g)p.set(le.id,le);e[5]=g,e[6]=p}else p=e[6];const y=p;let v;if(e[7]!==y||e[8]!==d){v=[];for(const le of d){const Re=y.get(le);Re&&v.push({id:le,session:Re})}e[7]=y,e[8]=d,e[9]=v}else v=e[9];const j=v;let C;e[10]!==b?(C=le=>{b(le.id,dn(le.session))},e[10]=b,e[11]=C):C=e[11];const k=C,T=Vv;let O;e[12]!==f||e[13]!==h||e[14]!==k||e[15]!==j?(O=le=>{if(f(le),h&&h!==le){const Re=j.find(Oe=>Oe.id===le);Re&&k(Re)}},e[12]=f,e[13]=h,e[14]=k,e[15]=j,e[16]=O):O=e[16];const M=O;let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L={activationConstraint:{distance:8}},e[17]=L):L=e[17];let F;e[18]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{delay:200,tolerance:6}},e[18]=F):F=e[18];const D=Xo(vn(Zo,L),vn(Jo,F));let U;e[19]!==m?(U=le=>{const{active:Re,over:Oe}=le;Oe&&Re.id!==Oe.id&&m(String(Re.id),String(Oe.id))},e[19]=m,e[20]=U):U=e[20];const N=U,A=c.useRef(null);let H;e[21]===Symbol.for("react.memo_cache_sentinel")?(H={left:!1,right:!1},e[21]=H):H=e[21];const[I,R]=c.useState(H);let P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const le=A.current;if(!le)return;const Re=le.scrollLeft>2,Oe=le.scrollLeft+le.clientWidth<le.scrollWidth-2;R(Te=>Te.left===Re&&Te.right===Oe?Te:{left:Re,right:Oe})},e[22]=P):P=e[22];const _=P;let G;e[23]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{_();const le=A.current;if(!le||!globalThis.ResizeObserver)return;const Re=new ResizeObserver(_);return Re.observe(le),()=>Re.disconnect()},e[23]=G):G=e[23];let ae;e[24]!==j.length?(ae=[_,j.length],e[24]=j.length,e[25]=ae):ae=e[25],c.useEffect(G,ae);let Se;e[26]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>{A.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=Se):Se=e[26];let J;e[27]!==h?(J=[h],e[27]=h,e[28]=J):J=e[28],c.useEffect(Se,J);const re=I.left&&I.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":I.left?"linear-gradient(to right, transparent, black 24px)":I.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let ie;e[29]!==j?(ie=j.map(Gv),e[29]=j,e[30]=ie):ie=e[30];const Be=ie;let Ae;e[31]!==h||e[32]!==j?(Ae=!h||!j.some(le=>le.id===h),e[31]=h,e[32]=j,e[33]=Ae):Ae=e[33];const K=Ae;let q;e[34]!==a?(q=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=q):q=e[35];let X;e[36]!==re?(X=re?{maskImage:re,WebkitMaskImage:re}:void 0,e[36]=re,e[37]=X):X=e[37];let me;e[38]===Symbol.for("react.memo_cache_sentinel")?(me=[Dv],e[38]=me):me=e[38];let he;e[39]!==i||e[40]!==h||e[41]!==M||e[42]!==k||e[43]!==r||e[44]!==s||e[45]!==l||e[46]!==j?(he=j.map(le=>n.jsx(Ov,{tab:le,isActive:le.id===h,suppressControls:le.id===h&&l,onSelect:k,onClose:T,renderMenu:s,closeOtherTabs:M,onMenuOpenChangeComplete:r,children:le.id===h?i:null},le.id)),e[39]=i,e[40]=h,e[41]=M,e[42]=k,e[43]=r,e[44]=s,e[45]=l,e[46]=j,e[47]=he):he=e[47];let je;e[48]!==he||e[49]!==Be?(je=n.jsx(el,{items:Be,strategy:R1,children:he}),e[48]=he,e[49]=Be,e[50]=je):je=e[50];let Y;e[51]!==N||e[52]!==D||e[53]!==je?(Y=n.jsx(ei,{sensors:D,collisionDetection:ti,modifiers:me,onDragEnd:N,children:je}),e[51]=N,e[52]=D,e[53]=je,e[54]=Y):Y=e[54];let ue;e[55]!==i||e[56]!==K?(ue=K?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[55]=i,e[56]=K,e[57]=ue):ue=e[57];let we;e[58]!==X||e[59]!==Y||e[60]!==ue?(we=n.jsxs("div",{ref:A,onScroll:_,onWheel:Rv,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:X,children:[Y,ue]}),e[58]=X,e[59]=Y,e[60]=ue,e[61]=we):we=e[61];let ce;return e[62]!==q||e[63]!==we?(ce=n.jsx("div",{className:"flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":q,children:we}),e[62]=q,e[63]=we,e[64]=ce):ce=e[64],ce};function Fv(t){return t.stopPropagation()}function Lv(t){return t.stopPropagation()}function _v(t){return t.tabIds}function $v(t){return t.ensureTab}function Wv(t){return t.closeOtherTabs}function Kv(t){return t.reorderTabs}function zv(t){return t.currentSessionId}function Uv(t){return t.setCurrentSession}function Hv(t){return t.activeSessions}function Vv(t){sb(t)}function Gv(t){return t.id}const qv=500;function ns(t){const e=Ve.c(9),{hint:s,children:r}=t,[o,i]=c.useState(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(f,m)=>{f&&m.reason==="trigger-focus"||i(f)},e[0]=l):l=e[0];let a;e[1]!==r?(a=n.jsx(Et,{asChild:!0,children:r}),e[1]=r,e[2]=a):a=e[2];let d;e[3]!==s?(d=n.jsx(Pt,{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(Dt,{delayDuration:qv,open:o,onOpenChange:l,children:[a,d]}),e[5]=o,e[6]=a,e[7]=d,e[8]=u):u=e[8],u}const Yv=t=>{const e=Ve.c(29),{open:s,onOpenChange:r,onPick:o}=t,{t:i}=mt(),l=Xt(Qv),a=Ss(Xv);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(Xs,{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 m;e[6]!==f?(m=n.jsx(Js,{children:f}),e[6]=f,e[7]=m):m=e[7];let h;e[8]!==u||e[9]!==m?(h=n.jsxs(Zs,{children:[u,m]}),e[8]=u,e[9]=m,e[10]=h):h=e[10];let b;if(e[11]!==a||e[12]!==r||e[13]!==o||e[14]!==l){let x;e[16]!==a||e[17]!==r||e[18]!==o?(x=p=>n.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] focus-visible:outline-none",onClick:()=>{r(!1),o(p.path)},children:[n.jsx($,{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()||Yo(p.path)}),n.jsx("span",{className:"min-w-0 max-w-[45%] truncate typography-micro text-muted-foreground",children:gr(p.path,a)})]},p.id),e[16]=a,e[17]=r,e[18]=o,e[19]=x):x=e[19],b=l.map(x),e[11]=a,e[12]=r,e[13]=o,e[14]=l,e[15]=b}else b=e[15];let g;e[20]!==b?(g=n.jsx("div",{className:"flex max-h-[50vh] flex-col gap-0.5 overflow-y-auto",children:b}),e[20]=b,e[21]=g):g=e[21];let w;e[22]!==h||e[23]!==g?(w=n.jsxs(Ls,{className:"max-w-md",children:[h,g]}),e[22]=h,e[23]=g,e[24]=w):w=e[24];let S;return e[25]!==r||e[26]!==s||e[27]!==w?(S=n.jsx(_s,{open:s,onOpenChange:r,children:w}),e[25]=r,e[26]=s,e[27]=w,e[28]=S):S=e[28],S};function Qv(t){return t.projects}function Xv(t){return t.homeDirectory}function bc(t){const e=Ve.c(28),{sessionId:s,onArchive:r,Item:o}=t,{t:i}=mt();let l;e[0]!==s?(l=C=>!!C.entityById.get(s)?.time.archived,e[0]=s,e[1]=l):l=e[1];const a=ws(l);let d;e[2]!==s?(d=C=>!!C.entityById.get(s)?.parentID,e[2]=s,e[3]=d):d=e[3];const u=ws(d),f=Ze(Jv);let m;e[4]!==s||e[5]!==i||e[6]!==f?(m=async()=>{await f(s)?Ke.success(i("sessions.sidebar.session.restore.success")):Ke.error(i("sessions.sidebar.session.restore.error"))},e[4]=s,e[5]=i,e[6]=f,e[7]=m):m=e[7];const h=m;if(a&&u)return null;const b=a?"sessions.sidebar.session.menuHint.restore":"sessions.sidebar.session.menuHint.archive";let g;e[8]!==i||e[9]!==b?(g=i(b),e[8]=i,e[9]=b,e[10]=g):g=e[10];let w;e[11]!==a||e[12]!==r||e[13]!==h?(w=a?()=>{h()}:r,e[11]=a,e[12]=r,e[13]=h,e[14]=w):w=e[14];const S=a?"inbox-unarchive":"inbox-archive";let x;e[15]!==S?(x=n.jsx($,{name:S,className:"mr-1 size-4"}),e[15]=S,e[16]=x):x=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 v;e[20]!==o||e[21]!==y||e[22]!==w||e[23]!==x?(v=n.jsxs(o,{onClick:w,children:[x,y]}),e[20]=o,e[21]=y,e[22]=w,e[23]=x,e[24]=v):v=e[24];let j;return e[25]!==v||e[26]!==g?(j=n.jsx(ns,{hint:g,children:v}),e[25]=v,e[26]=g,e[27]=j):j=e[27],j}function Jv(t){return t.unarchiveSession}const Tf=async t=>{const{entry:e,session:s}=t,r=Jt(),o={sessionId:s.id,sessionTitle:s.title,directory:s.directory};if(!(nb(e.action)&&rb(e.guest,"conversation"))){await ql(e,Yl(e.action.id,o),t.t,r);return}let l=!1;const a=Wr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await ql(e,Yl(e.action.id,o,d),t.t,r)}};function ia(t){const e=Ve.c(14),{sessionID:s,directory:r,open:o,Item:i}=t,{t:l}=mt(),{pending:a,disabled:d,hint:u,run:f}=Ph(s,r,o),m=a?"loader-4":"ai-generate-2",h=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==m||e[1]!==h?(b=n.jsx($,{name:m,className:h}),e[0]=m,e[1]=h,e[2]=b):b=e[2];let g;e[3]!==l?(g=l("sessions.aiRename.action"),e[3]=l,e[4]=g):g=e[4];let w;e[5]!==i||e[6]!==d||e[7]!==f||e[8]!==b||e[9]!==g?(w=n.jsx("span",{className:"block",children:n.jsxs(i,{disabled:d,onClick:f,className:"w-full",children:[b,g]})}),e[5]=i,e[6]=d,e[7]=f,e[8]=b,e[9]=g,e[10]=w):w=e[10];let S;return e[11]!==u||e[12]!==w?(S=n.jsx(ns,{hint:u,children:w}),e[11]=u,e[12]=w,e[13]=S):S=e[13],S}const Oo=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class Mf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const oi=tl(()=>({pendingSessionIds:new Set})),Of=t=>{const e=Ve.c(2);let s;return e[0]!==t?(s=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=s):s=e[1],oi(s)},yc=(t,e)=>{oi.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}})},Zv=async(t,e)=>{try{const d=(await cb(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const s=ot(t),r=ot(e)??e,o=Ze.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")},xc=t=>{for(const e of t){const s=ib(e.id);if(s==="unknown")throw new Error("Session status is unavailable");if(s==="active")throw new Error("Session is not idle")}};class eS extends Error{constructor(e,s){super(e,{cause:s}),this.name="IncompleteRollbackError"}}const tS=(t,e)=>{const s=e.map(({sessionId:r,error:o})=>`${r}: ${o.message}`).join(", ");return new eS(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${s}`,{moveError:t,rollbackFailures:e})},sS=async(t,e,s,r)=>{const o=[];for(const i of[...t].reverse()){if(wu(i.id)){o.push({sessionId:i.id,error:new Error("Session is not idle")});continue}try{await Su(i,s,e),Ze.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},vc=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},Sc=async(t,e)=>{const s=e?[t,e]:[t];try{await Ba(s)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},nl=async(t,e)=>{if(oi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");yc(t.root.id,!0);try{const s=[...t.descendants,t.root],r=new Map(s.map(a=>[a.id,Ze.getState().getWorktreeMetadata(a.id)]));xc(s);let o=null;const i=[];let l=!1;try{o=await e();for(const[a,d]of s.entries()){xc(s.slice(a));try{await Su(d,t.sourceDirectory,o.directory)}catch(u){throw ob(u)&&(l=!0),u}i.push(d),d.id!==t.root.id&&Ze.getState().setWorktreeMetadata(d.id,o.metadata?Ql(o.metadata):null)}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await sS(i,t.sourceDirectory,o?.directory??t.sourceDirectory,r);if(l&&await Sc(t.sourceDirectory,o?.directory),u.length>0)throw tS(d,u);if(o?.onMoveFailure&&!l)return o.onMoveFailure(d);throw o?.onMoveFailure&&l?new Mf(d):d}return Ze.getState().setWorktreeMetadata(t.root.id,o.metadata?Ql(o.metadata):null),await Sc(t.sourceDirectory,o.directory),o.directory}finally{yc(t.root.id,!1)}},nS=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 nl(t,async()=>({directory:t.destination.path,metadata:t.destination}))},rS=async t=>{if((ot(t.sourceDirectory)??t.sourceDirectory)===(ot(t.projectDirectory)??t.projectDirectory))throw new Error("Source and destination are the same");return nl(t,async()=>({directory:t.projectDirectory,metadata:null}))},oS=async t=>nl(t,async()=>{const e=Gi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const s=await ju(t.sourceDirectory)?await Zv(t.sourceDirectory,e.path):null,r=await ab(e,s?{startRef:s}:{});try{await lb(r.path)}catch(o){const i=o instanceof Error?o:new Error(String(o));return vc(e,r,i)}return{directory:r.path,metadata:r,onMoveFailure:async o=>vc(e,r,o)}}),iS=t=>{(t.kind==="existing"?nS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):t.kind==="project"?rS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,projectDirectory:t.projectDirectory}):oS({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Ke.success(t.messages.success)).catch(s=>{const r=s instanceof Error?s:new Error(String(s));Ke.error(t.messages.failure,{description:r instanceof Mf?t.messages.outcomeUnknown:r.message})})},Bo=t=>{oi.getState().pendingSessionIds.has(t.root.id)||iS(t)},cr="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",aS=c.memo(function(e){const s=Ve.c(17),{visible:r,title:o,ariaLabel:i,onClick:l,className:a,Icon:d,iconClassName:u,pressed:f}=e,m=r===void 0?!0:r,h=f===void 0?!1:f;if(!m)return null;const b=a??cr,g=h&&"bg-interactive-selection text-interactive-selection-foreground";let w;s[0]!==b||s[1]!==g?(w=xe(b,g),s[0]=b,s[1]=g,s[2]=w):w=s[2];const S=u??"h-[18px] w-[18px]";let x;s[3]!==d||s[4]!==S?(x=n.jsx($,{name:d,className:S}),s[3]=d,s[4]=S,s[5]=x):x=s[5];let p;s[6]!==i||s[7]!==l||s[8]!==h||s[9]!==w||s[10]!==x?(p=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:l,"aria-label":i,"aria-pressed":h,className:w,children:x})}),s[6]=i,s[7]=l,s[8]=h,s[9]=w,s[10]=x,s[11]=p):p=s[11];let y;s[12]!==o?(y=n.jsx(Pt,{children:n.jsx("p",{children:o})}),s[12]=o,s[13]=y):y=s[13];let v;return s[14]!==p||s[15]!==y?(v=n.jsxs(Dt,{children:[p,y]}),s[14]=p,s[15]=y,s[16]=v):v=s[16],v}),lS=c.memo(function(e){const s=Ve.c(43),{isDesktopApp:r,currentInstanceLabel:o,currentInstanceIsLocal:i,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:f,remoteUpdateChecking:m,remoteUpdateError:h,onOpenRemoteUpdate:b}=e,{t:g}=mt();let w;s[0]!==d||s[1]!==a?(w=F=>{a(F),F&&d()},s[0]=d,s[1]=a,s[2]=w):w=s[2];let S;s[3]!==o||s[4]!==r||s[5]!==g?(S=r?g("header.services.openWithCurrent",{current:o}):g("header.services.open"),s[3]=o,s[4]=r,s[5]=g,s[6]=S):S=s[6];const x=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;s[7]!==x?(p=xe(cr,x),s[7]=x,s[8]=p):p=s[8];let y;s[9]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx($,{name:"server",className:"h-[18px] w-[18px]"}),s[9]=y):y=s[9];let v;s[10]!==o||s[11]!==r?(v=r?n.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:o}):null,s[10]=o,s[11]=r,s[12]=v):v=s[12];let j;s[13]!==S||s[14]!==p||s[15]!==v?(j=n.jsx(Et,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button","aria-label":S,className:p,children:[y,v]})})}),s[13]=S,s[14]=p,s[15]=v,s[16]=j):j=s[16];let C;s[17]!==o||s[18]!==u||s[19]!==g?(C=g("header.services.tooltip.currentInstance",{current:o,toggle:u("toggle_services_menu")}),s[17]=o,s[18]=u,s[19]=g,s[20]=C):C=s[20];let k;s[21]!==C?(k=n.jsx(Pt,{children:n.jsx("p",{children:C})}),s[21]=C,s[22]=k):k=s[22];let T;s[23]!==j||s[24]!==k?(T=n.jsxs(Dt,{children:[j,k]}),s[23]=j,s[24]=k,s[25]=T):T=s[25];let O;s[26]!==i||s[27]!==r||s[28]!==l||s[29]!==b||s[30]!==m||s[31]!==h||s[32]!==f||s[33]!==a||s[34]!==g?(O=r?n.jsxs("div",{children:[i?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:g("header.services.remoteUpdate.title")}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:f?.available?g("header.services.remoteUpdate.available",{version:f.version||""}):m?g("header.services.remoteUpdate.checking"):h||g("header.services.remoteUpdate.upToDate")})]}),f?.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:b,children:g("header.services.remoteUpdate.actions.open")}):null]})}),n.jsx(db,{embedded:!0,open:l,onOpenChange:dS,onHostSwitched:()=>a(!1)})]}):null,s[26]=i,s[27]=r,s[28]=l,s[29]=b,s[30]=m,s[31]=h,s[32]=f,s[33]=a,s[34]=g,s[35]=O):O=s[35];let M;s[36]!==O?(M=n.jsx(As,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:O}),s[36]=O,s[37]=M):M=s[37];let L;return s[38]!==l||s[39]!==w||s[40]!==T||s[41]!==M?(L=n.jsxs(Ps,{open:l,onOpenChange:w,children:[T,M]}),s[38]=l,s[39]=w,s[40]=T,s[41]=M,s[42]=L):L=s[42],L}),pn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},wc=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(s=>s.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,cS=()=>{Os("ui.header.render");const{t}=mt(),e=be(ee=>ee.isSidebarOpen),s=be(ee=>ee.openContextOverview),r=be(ee=>ee.closeContextPanel),o=be(ee=>ee.shortcutOverrides),i=be(ee=>ee.sessionTabsEnabled),l=Ze(ee=>ee.getContextUsage),a=Ze(ee=>!!ee.newSessionDraft?.open),d=Ze(ee=>ee.currentSessionId),u=ub(d??""),f=fb(d??""),m=Of(d??""),h=ws(yr(c.useCallback(ee=>{if(!d)return null;const tt=[...ee.activeSessions,...ee.archivedSessions].find(Ut=>Ut.id===d);if(!tt)return null;const ht=tt;return{title:tt.title??null,directory:ht.directory??null,created:tt.time?.created??null,slug:ht.slug??null,parentId:tt.parentID??null}},[d]))),b=Xt(yr(ee=>{if(!ee.activeProjectId)return null;const tt=ee.projects.find(ht=>ht.id===ee.activeProjectId);return tt?{id:tt.id,path:tt.path,label:tt.label}:null})),g=c.useMemo(()=>{if(!b)return null;const ee=b.label?.trim();if(ee)return ee;const tt=b.path.split(/[\\/]/).filter(Boolean);return tt[tt.length-1]??null},[b]),w=ar(ee=>ee.loadSettings),{isMobile:S}=Ln(),x=c.useRef(null),[p,y]=c.useState(()=>typeof window>"u"?!1:cn()),v=c.useMemo(()=>Tr(),[]),j=pb(),[C,k]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:O,side:M}=Sf(),L=c.useMemo(()=>{if(typeof window>"u")return null;const ee=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof ee=="number"&&Number.isFinite(ee)&&ee>0)return ee;if(typeof navigator>"u")return null;const tt=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!tt)return null;const ht=Number.parseInt(tt[1],10),Ut=Number.parseInt(tt[2],10);return Number.isNaN(ht)?null:ht===10?Ut:ht},[]);us.useEffect(()=>{typeof window>"u"||y(cn())},[]);const{context:F,output:D}=mb(d),U=l(F,D),[N,A]=c.useState(null),H=!d||u;us.useEffect(()=>{if(!d){A(ee=>ee===null?ee:null);return}if(U){A(ee=>hb(ee,U)?ee:U);return}H&&A(ee=>ee===null?ee:null)},[U,d,H]);const[I,R]=c.useState(!1),[P,_]=c.useState("Local"),[G,ae]=c.useState(!0),[Se,J]=c.useState(!1),[re,ie]=c.useState(null),[Be,Ae]=c.useState(!1),[K,q]=c.useState(null),X=c.useMemo(()=>qs(),[]),me=be(ee=>ee.workStatusPanelVisible),he=be(ee=>ee.workStatusPanelEnabled),je=be(ee=>ee.setWorkStatusPanelEnabled),Y=be(ee=>ee.workStatusPanelFits),ue=be(ee=>ee.workStatusOverlayOpen),we=be(ee=>ee.setWorkStatusOverlayOpen),le=he&&Y||ue,Re=c.useCallback(()=>{if(he&&!Y){we(!ue);return}je(!he)},[we,je,ue,he,Y]),Oe=!X&&!me&&!!N,Te=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if($r()){_("Local"),ae(!0);return}ae(!1);const ee=await Vo(),tt=km(),ht=Cm([Nm(tt),...ee.hosts]);if(ht.id===Am){_("Local"),ae(!0);return}_(Jd(ht.label.trim()||"Instance"))}catch{_("Local"),ae(!0)}},[p]);us.useEffect(()=>(Te(),Wr(()=>{Te()})),[Te]);const De=c.useCallback(async()=>{if(G){ie(null),q(null);return}Ae(!0),q(null);try{const ee=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),tt=await Fs(`/api/openchamber/update-check?${ee.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!tt.ok)throw new Error(`Server responded with ${tt.status}`);const ht=await tt.json();ie({available:ht.available??!1,version:ht.version,currentVersion:ht.currentVersion??"unknown",body:ht.body,nextSuggestedCheckInSec:typeof ht.nextSuggestedCheckInSec=="number"?ht.nextSuggestedCheckInSec:void 0,packageManager:ht.packageManager,updateCommand:ht.updateCommand})}catch(ee){ie(null),q(ee instanceof Error?ee.message:t("header.services.remoteUpdate.error"))}finally{Ae(!1)}},[G,t]);c.useEffect(()=>{ie(null),q(null),J(!1)},[G,P]),c.useEffect(()=>{if(!p||G)return;const ee=3e3,tt=3600*1e3;let ht=!1,Ut=null;const ds=js=>{Ut=window.setTimeout(()=>{if(ht||typeof document<"u"&&document.visibilityState!=="visible"){ds(tt);return}De().finally(()=>{ht||ds(tt)})},js)};return ds(ee),()=>{ht=!0,Ut!==null&&window.clearTimeout(Ut)}},[De,G,P,p]);const te=c.useCallback(()=>{if(re?.available){J(!0);return}De()},[De,re?.available]);gb(),c.useEffect(()=>{w()},[w]);const de=d?h??null:null,fe=c.useRef(null),[ge,B]=c.useState(0);c.useEffect(()=>{if(!d){fe.current&&(fe.current=null,B(Ut=>Ut+1));return}if(de){fe.current={sessionId:d,session:de,expiresAt:Date.now()+2e3};return}const ee=fe.current;if(!ee||ee.sessionId!==d)return;const tt=ee.expiresAt-Date.now();if(tt<=0){fe.current=null,B(Ut=>Ut+1);return}const ht=window.setTimeout(()=>{fe.current?.sessionId===d&&(fe.current=null),B(Ut=>Ut+1)},tt);return()=>{window.clearTimeout(ht)}},[d,de]);const Q=(()=>{if(de)return de;if(!d)return null;const ee=fe.current;return ee&&ee.sessionId===d&&ee.expiresAt>Date.now()?ee.session:null})(),ke=Ze(ee=>d?ee.worktreeMetadata.get(d)?.path??"":""),Ie=Ze(ee=>d?ee.worktreeMetadata.get(d)?.branch?.trim()??null:null),oe=Cu(ee=>d?ee.getAttachment(d):void 0),$e=c.useMemo(()=>oe?bb(oe,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,oe]),Fe=c.useMemo(()=>oe?oe.legacy?"legacy":oe.degraded?"degraded":oe.worktreeStatus==="pending"?"pending":oe.worktreeStatus==="missing"?"missing":oe.worktreeStatus==="invalid"?"invalid":oe.attentionReason?"attention":null:null,[oe]),Ce=c.useMemo(()=>pn(ke||""),[ke]),Ue=c.useMemo(()=>{const ee=typeof Q?.directory=="string"?Q.directory:"";return pn(ee||"")},[Q?.directory]),pe=Ma(d??"",Ue),ne=Ze(ee=>ee.newSessionDraft?.open?pn(ee.newSessionDraft.bootstrapPendingDirectory??ee.newSessionDraft.directoryOverride??""):""),Me=Ze(ee=>ee.newSessionDraft.target),He=Ze(ee=>ee.newSessionDraft.selectedProjectId),Ye=Ze(ee=>ee.currentSessionDirectory),Xe=Ss(ee=>ee.homeDirectory),Je=c.useMemo(()=>Ce||Ue||ne,[ne,Ue,Ce]),bt=be(c.useCallback(ee=>{const tt=pn(Je||"");return tt?wc(ee.contextPanelByDirectory[tt]):null},[Je])),et=Ze(ee=>{const tt=pn(Ce||Ue||"");if(!tt)return null;for(const ht of ee.availableWorktreesByProject.values()){const ds=ht.find(js=>pn(js.path)===tt)?.branch?.trim();if(ds)return ds}return null}),xt=yb(Je||null)||Ie||et,wt=a?Me==="chat":Pm(Ue||Ye,Xe),dt=!wt&&!me&&!!(g||xt||!a&&Fe),It=c.useMemo(()=>{if(!d)return g??"OpenChamber";const ee=Q?.title?.trim();return ee&&ee.length>0?ee:"Untitled Session"},[g,Q?.title,d]),_t=Nu(),Bt=Ze(ee=>ee.updateSessionTitle),ye=Ze(ee=>ee.archiveSessions),z=Ze(ee=>ee.deleteSessions),[W,Z]=c.useState(!1),[ve,E]=c.useState(!1),V=c.useRef(null),[Ne,We]=c.useState(""),[Ge,qe]=c.useState(!1),Pe=Xt(ee=>ee.projects.length>0),[ze,Rt]=c.useState(null),zt=c.useRef(null),Tt=c.useCallback(()=>{d&&(We(Q?.title?.trim()||It),Z(!0))},[Q?.title,d,It]),Ft=c.useRef(Tt);Ft.current=Tt;const gt=c.useCallback(ee=>{ee&&(ee.focus(),ee.select())},[]);c.useEffect(()=>{if(E(!1),Rt(null),d&&V.current===d){V.current=null,Ft.current();return}Z(!1),We("")},[d]);const vt=c.useCallback(async()=>{if(!d)return;const ee=Ne.trim();ee&&ee!==Q?.title?.trim()&&await Bt(d,ee),Z(!1)},[Q?.title,d,Ne,Bt]);c.useEffect(()=>{if(!W)return;const ee=tt=>{const ht=tt.target;(!ht||!zt.current?.contains(ht))&&vt()};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[W,vt]);const qt=c.useCallback(ee=>{ee&&Xn(ee).then(tt=>{Ke[tt.ok?"success":"error"](t(tt.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(t("sessions.sidebar.session.copyId.error")))},[t]),ct=c.useCallback(async()=>{if(!d||!Je){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ee=await _t({sessionID:d,directory:Je}).catch(()=>null);if(!ee){Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(ee.length===0){Ke.error(t("sessions.sidebar.session.export.nothingToExport"));return}const tt=Au(ee,Q?.title??null),ht=Pu(Q?.title??null);await Iu(tt,ht)||Du(tt,ht),Ke.success(t("sessions.sidebar.session.export.success"))},[Q?.title,d,_t,Je,t]),at=Eu(),yt=c.useMemo(()=>Ru(at),[at]),$t=c.useCallback(ee=>{d&&Tf({entry:ee,t,session:{id:d,title:Q?.title,directory:Ue??Je},loadRecords:async()=>{if(!Je)return null;try{return await _t({sessionID:d,directory:Je})}catch{return null}},onLoadFailed:()=>Ke.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[Q?.title,d,_t,Je,Ue,t]),ls=c.useCallback(ee=>yt.map(tt=>n.jsxs(ee,{onClick:()=>$t(tt),children:[n.jsx(vr,{icon:tt.icon,iconSrc:tt.iconSrc,className:"mr-1 size-4"}),tt.action.label]},`${tt.guest.id}:${tt.action.id}`)),[yt,$t]),jt=f?.type==="busy"||f?.type==="retry",kt=c.useCallback(()=>{if(!d||!Ue||jt||m)return;const ee=ws.getState().activeSessions,tt=ee.find(ds=>ds.id===d);if(!tt)return;const ht=[],Ut=[d];for(let ds=0;ds<Ut.length;ds+=1){const js=Ut[ds];for(const as of ee)as.parentID===js&&(ht.push(as),Ut.push(as.id))}Bo({kind:"quick",root:tt,descendants:ht,sourceDirectory:Ue,messages:Oo(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,jt,m,Ue,t]),Vt=c.useCallback(ee=>{if(!d||!Ue||jt||m)return;const tt=ws.getState().activeSessions,ht=tt.find(js=>js.id===d);if(!ht)return;const Ut=[],ds=[d];for(let js=0;js<ds.length;js+=1)for(const as of tt)as.parentID===ds[js]&&(Ut.push(as),ds.push(as.id));Bo({kind:"project",root:ht,descendants:Ut,sourceDirectory:Ue,projectDirectory:ee,messages:Oo(t,{success:"sessions.moveChatToProject.success",failure:"sessions.moveChatToProject.failed"})})},[d,jt,m,Ue,t]),es=c.useCallback(async(ee,tt)=>{const ht=[tt,...lu(tt,[],ee==="delete")],Ut=Ze.getState().currentSessionId===tt?tt:null;if(ee==="delete"){const{failedIds:as}=await z(ht);as.length>0?Ke.error(t("sessions.sidebar.session.delete.error")):Ke.success(t("sessions.sidebar.session.delete.success"));return}const{archivedIds:ds,failedIds:js}=await ye(ht);if(js.length>0){Ke.error(t("sessions.sidebar.session.archive.error"));return}Ke.success(t("sessions.sidebar.session.archive.success"),Ih(ds,Ut,t))},[ye,z,t]),Is=c.useCallback(async()=>{if(!ze)return;const{action:ee,sessionId:tt}=ze;Rt(null),await es(ee,tt)},[ze,es]),Ds=be(ee=>ee.openGuestPageId),ts=Fa(ee=>ee.guests.find(tt=>tt.id===Ds)),Le=be(ee=>ee.isScheduledTasksDialogOpen),nt=be(ee=>ee.isArchivePageOpen),it=be(ee=>ee.isUsageStatsPageOpen),_e=be(ee=>ee.isSourceBoardOpen),st=be(ee=>ee.worktreesPageProjectId),ut=be(ee=>ee.isolatedSpacesEnabled?ee.spacesPageProjectId:null),St=be(ee=>ee.runOverviewKey),Ct=Dh(St),Nt=st??ut,os=Xt(ee=>{if(!Nt)return null;const tt=ee.projects.find(ht=>ht.id===Nt);return tt?.label?.trim()||tt?.path?.split("/").pop()||null}),Ht=c.useMemo(()=>ts?{title:ts.pageTitle??ts.name,subtitle:null}:Le?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:nt?{title:t("sessions.archivePage.title"),subtitle:null}:it?{title:t("usageStats.title"),subtitle:null}:_e?{title:t("sourceBoard.title"),subtitle:null}:st?{title:t("sessions.worktreesPage.title",{project:os??""}),subtitle:null}:ut?{title:t("spaces.page.title",{project:os??""}),subtitle:null}:St?{title:Ct??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[ts,nt,Ct,St,Le,_e,it,ut,os,t,st]),Ee=c.useMemo(()=>pn(Je||b?.path||""),[b?.path,Je]),Qe=Iv(),rt=La(ee=>ee.planModeEnabled),pt=Ze(ee=>ee.isSessionPlanAvailable),Mt=rt&&d?pt(d):!1,Wt=c.useRef("");c.useEffect(()=>{if(!rt||!d)return;const ee=`${d||"none"}:${Ue||"none"}:${Q?.created||0}:${Q?.slug||"none"}`;Wt.current!==ee&&(Wt.current=ee)},[rt,Mt,Q?.slug,Q?.created,d,Ue]);const ss=c.useCallback(()=>{On("desktop_open_draft_mini_chat_window",{directory:wt?"":ne,projectId:wt?null:He,apiBaseUrl:Co(),clientToken:Wi()}).catch(ee=>{console.warn("[header] failed to open draft mini chat window",ee)})},[ne,He,wt]),Kt=c.useCallback(()=>{if(a){ss();return}d&&On("desktop_open_session_mini_chat_window",{sessionId:d,directory:Ue||pn(Ye||"")||Ce,apiBaseUrl:Co(),clientToken:Wi()}).catch(ee=>{console.warn("[header] failed to open session mini chat window",ee)})},[d,ss,a,Ye,Ue,Ce]),Yt=c.useCallback(()=>{const ee=pn(Je||"");if(!ee)return;const tt=be.getState().contextPanelByDirectory[ee];if(wc(tt)==="context"){r(ee);return}s(ee)},[r,s,Je]),ys=bt==="context",Es=cr,Ws=c.useMemo(()=>p&&T&&!C?"88px":j?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||O)&&!X?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,C,T,j,X,O]);us.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Ws)},[Ws]);const en=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",cs=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";us.useEffect(()=>{if(!p||!T){k(!1);return}let ee=!1;const tt=async()=>{try{const Ut=await On("desktop_is_window_fullscreen");ee||k(Ut===!0)}catch{ee||k(!1)}},ht=()=>{tt()};return tt(),window.addEventListener("openchamber:window-resized",ht),()=>{ee=!0,window.removeEventListener("openchamber:window-resized",ht)}},[p,T]);const Rs=c.useMemo(()=>!p||!T||L===null?"":L>=26?"h-12":L<=15?"h-14":"",[p,T,L]),Ms=c.useMemo(()=>p&&T&&!C?L!==null&&L<=15?"56px":"48px":"0px",[p,C,T,L]),tn=c.useMemo(()=>{const ee=`max(3rem, ${Ms}, var(--oc-wco-titlebar-height, 0px))`,tt=p&&!O||X,ht=O&&M==="right";if(tt&&Ms==="0px")return{};const Ut={minHeight:ee,height:ee};return!tt&&!ht&&(Ut.paddingRight="calc(0.75rem + var(--oc-wco-right-inset, 0px))"),Ut},[p,X,Ms,O,M]),on=c.useCallback(()=>{if(typeof document>"u")return;const ee=x.current?.getBoundingClientRect().height;ee&&document.documentElement.style.setProperty("--oc-header-height",`${ee}px`)},[]);us.useEffect(()=>{if(typeof window>"u")return;on();const ee=x.current;if(!ee||typeof ResizeObserver>"u")return()=>{};let tt=0;const ht=()=>{tt||(tt=requestAnimationFrame(()=>{tt=0,on()}))},Ut=new ResizeObserver(ht);return Ut.observe(ee),window.addEventListener("resize",ht),window.addEventListener("orientationchange",ht),()=>{tt&&cancelAnimationFrame(tt),Ut.disconnect(),window.removeEventListener("resize",ht),window.removeEventListener("orientationchange",ht)}},[on]),us.useEffect(()=>{on()},[on,S,Rs]);const Vr=c.useCallback(async ee=>{const tt=ee.target;tt.closest(".app-region-no-drag")||tt.closest("button, a, input, select, textarea")||ee.button===0&&p&&await Im()},[p]),Gr=c.useCallback(ee=>Qn(zr(ee,o)),[o]);xb({rename_current_session:()=>{if(!d||S)return!1;Tt()},archive_current_session:()=>{if(!d||S||ws.getState().entityById.get(d)?.time.archived)return!1;if(be.getState().showDeletionDialog){Rt({action:"archive",sessionId:d});return}es("archive",d)},toggle_services_menu:()=>{if(I){R(!1);return}R(!0),Te()}});const $n=n.jsxs(n.Fragment,{children:[Qe?n.jsx(Cv,{projectRef:Qe.projectRef,directory:Qe.directory,className:"mr-2"}):null,n.jsx(Nv,{directory:Je,className:xe(cr,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),n.jsx(Eh,{directory:Je,className:xe(cr,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),n.jsx(U1,{directory:Ee,className:"mr-1"}),p?n.jsx(lS,{isDesktopApp:p,currentInstanceLabel:P,currentInstanceIsLocal:G,isDesktopServicesOpen:I,setIsDesktopServicesOpen:R,refreshCurrentInstanceLabel:Te,shortcutLabel:Gr,remoteUpdateInfo:re,remoteUpdateChecking:Be,remoteUpdateError:K,onOpenRemoteUpdate:te}):null]}),Ks=v&&(a||!!d),Zn=c.useCallback(({session:ee,open:tt,isActive:ht,select:Ut,closeOtherTabs:ds,components:js})=>{const{Item:as,Separator:er}=js,ii=ht&&!X&&!wt&&Q&&!Q.parentId,Wn=ht&&!X&&wt&&Q&&!Q.parentId&&Pe;return n.jsxs(n.Fragment,{children:[n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(as,{onClick:()=>{ht||Ut(),V.current=ee.id},children:[n.jsx($,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(ia,{sessionID:ee.id,directory:ee.directory,open:tt,Item:as}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(as,{onClick:()=>qt(ee.id),children:[n.jsx($,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(er,{}),ht?n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(as,{onClick:()=>{ct()},children:[n.jsx($,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}):null,ht?ls(as):null,ii?n.jsx(ns,{hint:t(m?"sessions.sidebar.session.moveToWorktree.tooltipMoving":jt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(as,{disabled:!Ue||jt||m,onClick:kt,className:"w-full",children:[n.jsx($,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,Wn?n.jsx(ns,{hint:t(jt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.moveChatToProject.hint"),children:n.jsx("span",{className:"block",children:n.jsxs(as,{disabled:!Ue||jt||m,onClick:()=>qe(!0),className:"w-full",children:[n.jsx($,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.moveChatToProject.menu")]})})}):null,n.jsx(er,{}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.closeOtherTabs"),children:n.jsxs(as,{onClick:ds,children:[n.jsx($,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]})}),n.jsx(er,{}),n.jsx(bc,{sessionId:ee.id,Item:as,onArchive:()=>Rt({action:"archive",sessionId:ee.id})}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(as,{className:"text-destructive focus:text-destructive",onClick:()=>Rt({action:"delete",sessionId:ee.id}),children:[n.jsx($,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})},[qt,Q,ct,Pe,wt,jt,m,X,kt,ls,Ue,t]),fn=()=>n.jsxs("div",{onMouseDown:Vr,className:xe("app-region-drag relative flex h-12 select-none items-center",O&&M==="right"?"pr-0":"pr-3",Rs),style:tn,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[n.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:en}}),n.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:cs}}),n.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Ht?n.jsxs(n.Fragment,{children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>be.getState().closeMainSurfaces(),children:n.jsx($,{name:"arrow-left",className:"size-[18px]"})})}),n.jsx(Pt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),n.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[n.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ht.title}),Ht.subtitle?n.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Ht.subtitle}):null]})]}):X||!i?n.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[pe?n.jsx($,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:n.jsx(pc,{align:"start",children:n.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:n.jsx($,{name:"history",className:"h-[18px] w-[18px]"})})}),n.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[W?n.jsxs("form",{ref:zt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ee=>ee.stopPropagation(),onSubmit:ee=>{ee.preventDefault(),vt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:ee=>We(ee.target.value),onKeyDown:ee=>Hi(ee,()=>Z(!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($,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Z(!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($,{name:"close",className:"size-4"})})]}):a?null:n.jsx("span",{dir:"auto",className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:It}),dt?n.jsxs("span",{className:xe("flex min-w-0 max-w-full items-center gap-1.5 truncate font-normal leading-tight",a?"typography-ui-label text-[14px] text-foreground":"typography-micro text-[10.5px] text-muted-foreground/75"),children:[g?n.jsx("span",{className:"truncate",children:g}):null,xt?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[n.jsx($,{name:"git-branch",className:xe("flex-shrink-0 text-muted-foreground/70",a?"h-3.5 w-3.5":"h-3 w-3")}),n.jsx("span",{className:xe("truncate",a&&"text-muted-foreground"),children:xt})]}):null,!a&&Fe?n.jsxs("span",{className:xe("inline-flex min-w-0 items-center gap-0.5",Fe==="attention"||Fe==="invalid"||Fe==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[n.jsx($,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"truncate",children:$e})]}):null]}):null]}),n.jsx("div",{className:xe("flex h-[18px] shrink-0 items-center justify-center",dt?"self-start":"self-center"),children:d&&!a&&!W?n.jsxs(Ps,{open:ve,onOpenChange:E,onOpenChangeComplete:ee=>{!ee&&V.current&&V.current===d&&(V.current=null,Tt())},children:[n.jsx(Ns,{asChild:!0,children:n.jsx(ft,{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($,{name:"more",className:"size-4"})})}),n.jsxs(As,{align:"end",className:"min-w-[190px]",children:[n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(Gt,{onClick:()=>{V.current=d},children:[n.jsx($,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]})}),n.jsx(ia,{sessionID:d,directory:Ue,open:ve,Item:Gt}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(Gt,{onClick:()=>d&&qt(d),children:[n.jsx($,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]})}),n.jsx(Cs,{}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(Gt,{onClick:()=>{ct()},children:[n.jsx($,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]})}),ls(Gt),!X&&!wt&&Q&&!Q.parentId?n.jsx(ns,{hint:t(m?"sessions.sidebar.session.moveToWorktree.tooltipMoving":jt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip"),children:n.jsx("span",{className:"block",children:n.jsxs(Gt,{disabled:!Ue||jt||m,onClick:kt,className:"w-full",children:[n.jsx($,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}):null,n.jsx(Cs,{}),n.jsx(bc,{sessionId:d,Item:Gt,onArchive:()=>Rt({action:"archive",sessionId:d})}),n.jsx(ns,{hint:t("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(Gt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Rt({action:"delete",sessionId:d})},children:[n.jsx($,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})})]})]}):null})]}):n.jsxs("div",{className:"flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:n.jsx(pc,{align:"start",children:n.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:n.jsx($,{name:"history",className:"h-[18px] w-[18px]"})})}),n.jsx(Bv,{renderMenu:Zn,suppressActiveTabControls:W,onMenuOpenChangeComplete:ee=>{!ee&&V.current&&V.current===d&&(V.current=null,Tt())},children:n.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:W?n.jsxs("form",{ref:zt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:ee=>ee.stopPropagation(),onSubmit:ee=>{ee.preventDefault(),vt()},children:[n.jsx("input",{ref:gt,value:Ne,onChange:ee=>We(ee.target.value),onKeyDown:ee=>Hi(ee,()=>Z(!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($,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:()=>Z(!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($,{name:"close",className:"size-4"})})]}):n.jsx("span",{dir:"auto",className:"block overflow-hidden whitespace-nowrap text-left text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):It})})})]}),Ht||X||!i?n.jsx("div",{className:"flex-1"}):null,n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Oe&&N?n.jsx(x1,{reading:v1(N),contextLimit:N.contextLimit,outputLimit:N.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Yt,pressed:ys,className:Ks?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,n.jsx(aS,{visible:Ks,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Kt,className:xe(Es,"mr-1"),Icon:"picture-in-picture-2"}),X?null:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":le,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:Re,className:xe(cr,"mr-1",le?"text-foreground":"text-muted-foreground/50"),children:n.jsx($,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),n.jsx(Pt,{side:"bottom",children:t(he&&!Y?ue?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":he?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),$n,n.jsx(wf,{visible:O&&M==="right",position:"right"})]})]})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{ref:x,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:fn()}),n.jsx(Yv,{open:Ge,onOpenChange:qe,onPick:Vt}),n.jsx(_s,{open:ze!==null,onOpenChange:ee=>{ee||Rt(null)},children:n.jsxs(Ls,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Zs,{children:[n.jsx(Xs,{children:ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),n.jsx(Js,{children:ze?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:It}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:It})})]}),n.jsxs(Jn,{children:[n.jsx(ft,{variant:"outline",size:"sm",onClick:()=>Rt(null),children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{Is()},children:ze?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),n.jsx(Oa,{open:Se,onOpenChange:J,info:re,downloading:!1,downloaded:!1,progress:null,error:K,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function dS(){}const jc=280,kc=264,Cc=500,uS=({isOpen:t,isMobile:e,children:s,className:r,topBar:o})=>{const{t:i}=mt(),l=be(k=>k.sidebarWidth),a=be(k=>k.setSidebarWidth),[d,u]=c.useState(!1),f=c.useRef(0),m=c.useRef(l||jc),h=c.useRef(null),b=c.useRef(null),g=c.useRef(null),w=c.useCallback(k=>Math.min(Cc,Math.max(kc,k)),[]),S=c.useCallback(k=>{const T=g.current;T&&(T.style.width=`${k}px`,T.style.minWidth=`${k}px`,T.style.maxWidth=`${k}px`,T.style.setProperty("--oc-left-sidebar-width",`${k}px`),document.documentElement.style.setProperty("--oc-left-sidebar-width",`${k}px`))},[]);c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(h.current=null,b.current=null)},[d]);const x=Math.min(Cc,Math.max(kc,l||jc)),p=t?x:0,y=d?h.current??p:p;if(c.useEffect(()=>{document.documentElement.style.setProperty("--oc-left-sidebar-width",`${d?y:x}px`)},[y,d,x]),e)return null;const v=k=>{if(t){try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}b.current=k.pointerId,u(!0),f.current=k.clientX,m.current=p,h.current=p,S(p),k.preventDefault()}},j=k=>{if(e||!d||b.current!==k.pointerId)return;const T=k.clientX-f.current,O=w(m.current+T);h.current!==O&&(h.current=O,S(O))},C=k=>{if(b.current!==k.pointerId||e)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const T=w(h.current??p);b.current=null,h.current=null,u(!1),a(T)};return n.jsxs("aside",{ref:g,className:xe("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${y}px`,minWidth:`${y}px`,maxWidth:`${y}px`,"--oc-left-sidebar-width":`${d?y:x}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,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)]","aria-hidden":"true"}),t&&n.jsx("div",{className:xe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:v,onPointerMove:j,onPointerUp:C,onPointerCancel:C,role:"separator","aria-orientation":"vertical","aria-label":i("sidebar.resize.leftPanelAria")}),n.jsxs("div",{className:xe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[o,n.jsx(Cn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:n.jsx(Ts,{children:s})})]})]})},fS=()=>{const t=Ve.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-left-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",{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},Zr="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",pS=()=>{const t=Ve.c(41),{t:e,locale:s}=mt(),r=be(mS),o=be(hS),i=be(gS),l=c.useRef(null),a=Qn(zr("toggle_sidebar",i)),d=bS,{usesFramelessChrome:u,side:f}=Sf();let m;t[0]!==s?(m=I=>{const R=I.currentTarget.getBoundingClientRect();On("desktop_show_app_menu",{x:R.left,y:R.bottom,locale:s}).catch(yS)},t[0]=s,t[1]=m):m=t[1];const h=m;let b,g;t[2]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{if(typeof document>"u")return;const I=l.current;if(!I)return;const R=()=>{const _=Math.max(I.getBoundingClientRect().width,I.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(_)}px`)};if(R(),typeof ResizeObserver>"u")return;const P=new ResizeObserver(R);return P.observe(I),()=>{P.disconnect()}},g=[],t[2]=b,t[3]=g):(b=t[2],g=t[3]),c.useEffect(b,g);const w="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2",S=o?"var(--oc-left-sidebar-width, 100%)":void 0;let x;t[4]!==S?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)",maxWidth:S},t[4]=S,t[5]=x):x=t[5];const p="flex min-w-0 items-center gap-2";let y;t[6]!==u||t[7]!==f?(y=u&&f==="left"?n.jsx(wf,{visible:!0,position:"left"}):null,t[6]=u,t[7]=f,t[8]=y):y=t[8];let v;t[9]!==h||t[10]!==e||t[11]!==u?(v=u?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,"aria-label":e("header.actions.openAppMenuAria"),className:xe(Zr,"shrink-0"),children:n.jsx($,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),n.jsx(Pt,{children:n.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[9]=h,t[10]=e,t[11]=u,t[12]=v):v=t[12];const j=Dt;let C;t[13]!==e?(C=e("header.actions.openSessionsAria"),t[13]=e,t[14]=C):C=t[14];let k,T;t[15]===Symbol.for("react.memo_cache_sentinel")?(k=xe(Zr,"shrink-0"),T=n.jsx($,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[15]=k,t[16]=T):(k=t[15],T=t[16]);let O;t[17]!==C||t[18]!==r?(O=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,"aria-label":C,className:k,children:T})}),t[17]=C,t[18]=r,t[19]=O):O=t[19];const M=Pt,L=e("header.actions.openSessionsWithShortcut",{shortcut:a});let F;t[20]!==L?(F=n.jsx("p",{children:L}),t[20]=L,t[21]=F):F=t[21];let D;t[22]!==M||t[23]!==F?(D=n.jsx(M,{children:F}),t[22]=M,t[23]=F,t[24]=D):D=t[24];let U;t[25]!==j||t[26]!==O||t[27]!==D?(U=n.jsxs(j,{children:[O,D]}),t[25]=j,t[26]=O,t[27]=D,t[28]=U):U=t[28];let N;t[29]!==d||t[30]!==o||t[31]!==e?(N=o?n.jsxs("button",{type:"button",onClick:d,className:xe(Zr,"-ml-1 w-auto min-w-0 px-2 font-normal"),children:[n.jsx($,{name:"chat-new",className:"h-[18px] w-[18px] shrink-0"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:xe(Zr,"-ml-1 shrink-0"),children:n.jsx($,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),n.jsx(Pt,{children:n.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[29]=d,t[30]=o,t[31]=e,t[32]=N):N=t[32];let A;t[33]!==U||t[34]!==N||t[35]!==y||t[36]!==v?(A=n.jsxs("div",{ref:l,className:p,children:[y,v,U,N]}),t[33]=U,t[34]=N,t[35]=y,t[36]=v,t[37]=A):A=t[37];let H;return t[38]!==A||t[39]!==x?(H=n.jsx("div",{className:w,style:x,children:A}),t[38]=A,t[39]=x,t[40]=H):H=t[40],H};function mS(t){return t.toggleSidebar}function hS(t){return t.isSidebarOpen}function gS(t){return t.shortcutOverrides}function bS(){be.getState().closeMainSurfaces(),Ze.getState().openNewSessionDraft()}function yS(t){console.warn("[titlebar] failed to open app menu",t)}function xS(t,e,s){const r=Ve.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([vb(t),Sb(t)]).catch(vS);if(d)return;const m=ot(u),h=ot(f);if(!m||!h||h===m)return;const b=s||"",g=h.split("/").filter(Boolean).pop()||h;i({source:"sdk",path:h,projectDirectory:m,branch:b,label:b||g,name:g,worktreeRoot:h,worktreeStatus:"ready",headState:b?"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 vS(){return["",""]}const SS=()=>{const t=Ve.c(3),e=be(wS),s=be(jS);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 wS(t){return t.setSettingsDialogOpen}function jS(t){return t.setSettingsPage}const kS="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)]",Nc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",CS=({className:t,identity:e=Mu})=>{const{t:s}=mt(),{sourceControl:r}=Qs(),o=Tu(e),i=e.provider==="gitlab",l=i?"gitlab":"github-fill",a=o?.status??null,d=Bn(x=>x.setStatus),[u,f]=c.useState(!1),m=c.useCallback(async x=>{if(!(!x||u)){f(!0);try{d(e,await r.authActivate(e,x))}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 h=a.user.username||null,b=a.user.avatarUrl??null,g=a.accounts,w=i?h?s("header.gitlab.connectedWithLogin",{login:h}):s("header.gitlab.connected"):h?s("header.github.connectedWithLogin",{login:h}):s("header.github.connected"),S=b?n.jsx("img",{src:b,alt:h?s("header.github.avatarWithLogin",{login:h}):s(i?"header.gitlab.avatar":"header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):n.jsx($,{name:l,className:"h-3.5 w-3.5 text-foreground"});return g.length<=1?n.jsx("div",{className:xe(Nc,t),title:w,children:S}):n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:xe(Nc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:w,disabled:u,children:S})}),n.jsxs(As,{align:"end",className:"w-64",children:[n.jsx(ir,{className:"typography-ui-header font-semibold text-foreground",children:s(i?"header.gitlab.accountsTitle":"header.github.accountsTitle")}),n.jsx(Cs,{}),g.map(x=>{const p=x.user,y=!!x.current,v=s(wb(x.source??"oauth"));return n.jsxs(Gt,{className:"gap-2",disabled:u,onSelect:()=>{y||m(x.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($,{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:v})]}):null]}),y?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})},NS=t=>JSON.stringify(jb(t)),AS=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}},Bf=t=>"code"in t&&t.code==="SOURCE_CONTROL_MUTATION_OUTCOME_UNKNOWN";async function PS(t){if(!Bf(t.error)||!t.isCurrent())return!1;try{await t.refresh()}catch{}return t.isCurrent()&&t.scheduleRefresh(),!0}function IS(t,e,s){const r=Ve.c(16),{sourceControl:o}=Qs(),[i,l]=us.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 m=!1;return o.githubReferences(t,{kind:"pull",query:`#${e}`}).then(h=>{if(m||!h.connected)return;const b=h.items.find(g=>g.kind==="pull"&&g.number===e);b&&l({key:d,pull:b})}).catch(DS),()=>{m=!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],us.useEffect(u,f),i?.key===d?i.pull:null}function DS(){}const ES=t=>{const e=Ve.c(58),{directory:s,context:r,changeRequest:o,onChanged:i}=t,l=Fn(),a=Xt(RS),[d,u]=us.useState(0),[f,m]=us.useState(!1),[h]=us.useState(TS),b=IS(r,o.number,d);let g;e[0]!==o?(g=kb(o),e[0]=o,e[1]=g):g=e[1];const w=g;let S;e[2]!==b||e[3]!==w?(S=b?{...w,labels:b.labels,commentCount:b.commentCount}:w,e[2]=b,e[3]=w,e[4]=S):S=e[4];const x=S,{detail:p,refresh:y}=Cb(s,x,!0),v=Rh(x);let j;e[5]!==i||e[6]!==y?(j=()=>{y(),u(MS),i()},e[5]=i,e[6]=y,e[7]=j):j=e[7];const C=j;let k;e[8]!==x?(k={source:"github",reference:x},e[8]=x,e[9]=k):k=e[9];const T=k,O=l??s;let M;e[10]===Symbol.for("react.memo_cache_sentinel")?(M={status:"idle"},e[10]=M):M=e[10];let L;e[11]!==r||e[12]!==T||e[13]!==C?(L=n.jsx(Oh,{item:T,project:null,context:r,onStartWorktree:BS,onChanged:C}),e[11]=r,e[12]=T,e[13]=C,e[14]=L):L=e[14];let F;e[15]===Symbol.for("react.memo_cache_sentinel")?(F=()=>m(!0),e[15]=F):F=e[15];let D;e[16]!==v.attachComment||e[17]!==v.attachComments?(D={onAttach:v.attachComment,onAttachAll:v.attachComments},e[16]=v.attachComment,e[17]=v.attachComments,e[18]=D):D=e[18];let U;e[19]!==r||e[20]!==x||e[21]!==C?(U=n.jsx(Bh,{reference:x,context:r,onChanged:C}),e[19]=r,e[20]=x,e[21]=C,e[22]=U):U=e[22];let N;e[23]!==r||e[24]!==p||e[25]!==x||e[26]!==C?(N=n.jsx(Fh,{pull:x,detail:p,context:r,onChanged:C}),e[23]=r,e[24]=p,e[25]=x,e[26]=C,e[27]=N):N=e[27];let A;e[28]!==r||e[29]!==x||e[30]!==C?(A=n.jsx(Th,{reference:x,context:r,onRefresh:C},x.number),e[28]=r,e[29]=x,e[30]=C,e[31]=A):A=e[31];const H=a??"";let I;e[32]!==O||e[33]!==H?(I={id:H,path:O},e[32]=O,e[33]=H,e[34]=I):I=e[34];let R;e[35]!==r||e[36]!==O||e[37]!==x||e[38]!==I?(R=n.jsx(Lh,{pull:x,project:I,context:r,projectOwnsDirectory:FS,currentDirectory:O}),e[35]=r,e[36]=O,e[37]=x,e[38]=I,e[39]=R):R=e[39];let P;e[40]!==p||e[41]!==T||e[42]!==h||e[43]!==N||e[44]!==A||e[45]!==R||e[46]!==L||e[47]!==D||e[48]!==U?(P=n.jsx(Nb,{item:T,pullStatus:Ab,linearDetail:M,githubDetail:p,purpose:"attach",pinned:!0,includeDiff:!1,onIncludeDiffChange:OS,now:h,footer:L,onOpenChecks:F,commentAttachments:D,labelsControl:U,reviewersControl:N,reply:A,pullLinks:R}),e[40]=p,e[41]=T,e[42]=h,e[43]=N,e[44]=A,e[45]=R,e[46]=L,e[47]=D,e[48]=U,e[49]=P):P=e[49];let _;e[50]!==v.attachFailedChecks||e[51]!==f||e[52]!==r||e[53]!==x?(_=n.jsx(Mh,{pull:x,context:r,open:f,onOpenChange:m,onAttachFailed:v.attachFailedChecks}),e[50]=v.attachFailedChecks,e[51]=f,e[52]=r,e[53]=x,e[54]=_):_=e[54];let G;return e[55]!==P||e[56]!==_?(G=n.jsxs(n.Fragment,{children:[P,_]}),e[55]=P,e[56]=_,e[57]=G):G=e[57],G};function RS(t){return t.activeProjectId}function TS(){return Date.now()}function MS(t){return t+1}function OS(){}function BS(){}function FS(){return!0}function LS(t,e){const{git:s,sourceControl:r}=Qs(),{t:o}=mt(),i=_h(),l=$h({directory:t,branch:e,chooseContributor:i.choose}),a=Wh(t,s,r),d=async()=>{const f=a.start();if(!f)return Ke.info(o("gitView.pr.toast.gitBusy")),!1;const m=o("gitView.toast.syncActionFailed",{action:o("gitView.publish.title")});try{return await(await l.prepare("push",{onOperation:f.onOperation}))(),f.isCurrent()}catch(h){if(h instanceof Pb){if(h.code==="stale-runtime")return!1;const b=l.errorMessage(h);return b?Ke.info(b):Ke.error(m),!1}return h instanceof Ib||h instanceof Db?(Ke.error(m,{description:h.message||void 0}),!1):(Ke.error(m,{description:h instanceof Error?h.message:String(h)}),!1)}finally{f.finish()}},u=n.jsxs(n.Fragment,{children:[l.context?n.jsx(Kh,{context:l.context,onSelect:l.settle}):null,l.confirmDialog,n.jsx(zh,{candidates:i.candidates,onSelect:i.settle})]});return{push:d,dialogs:u}}const _S=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"}},$S=(t,e)=>{const{currentSessionId:s,getDirectoryForSession:r}=Ze.getState(),o=s?r(s):null;!s||!o||ot(o)!==ot(t)||Wb(s,o,Kb({url:e.url,number:e.number,title:e.title,kind:"pull",linkedAt:Date.now()}),!0).catch(()=>{})},WS=t=>{const e=t?.changeRequest??t?.pr;return e?zb({state:e.state,draft:e.draft,checksState:(t?.ci?.summary??t?.checks)?.state,mergeable:e.mergeable,mergeableState:e.mergeableState}):null},KS=[2e3,5e3];let Ac=0;const zS=()=>{const t=globalThis.crypto?.randomUUID?.();return t||(Ac+=1,`source-control-${Date.now().toString(36)}-${Ac.toString(36)}`)},US=(t,e,s)=>JSON.stringify(["create",t,e.provider,e.instance,e.directory,e.repositoryId,e.accountId,e.bindingRevision,e.primaryRemote,...s]),Ff="openchamber:pr-create-as-draft:v1",Pc=()=>{try{return localStorage.getItem(Ff)==="true"}catch{return!1}},HS=t=>{try{localStorage.setItem(Ff,String(t))}catch{}},Ii=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),An=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):""},VS=(t,e)=>{const s=An(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},GS=(t,e)=>`${t}::${e}`,Di=new Map,Ic=qo;function qS(t,e,s){const r=Ve.c(14);let o;r[0]!==s?(o=s?NS(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 h=!1;return(async()=>{try{const b=await AS(e,s);h||d({contextKey:i,detectedUpstream:b.upstream,upstreamBranches:b.branches})}catch{}})(),()=>{h=!0}},f=[i,t,s,e],r[3]=i,r[4]=t,r[5]=s,r[6]=e,r[7]=u,r[8]=f):(u=r[7],f=r[8]),c.useEffect(u,f);let m;return r[9]!==i||r[10]!==a.contextKey||r[11]!==a.detectedUpstream||r[12]!==a.upstreamBranches?(m=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]=m):m=r[13],m}const YS=({directory:t,branch:e,baseBranch:s,trackingBranch:r,ahead:o=0,remoteBranches:i=[],onGeneratedDescription:l})=>{const{t:a}=mt(),d=Ou(t),u=c.useCallback((_e,st)=>a(Tn(_e,d?.provider),st),[d?.provider,a]),f=SS(),{sourceControl:m}=Qs(),h=Bn(_e=>_e.entries),{isMobile:b,hasTouchInput:g,screenWidth:w}=Ln(),S=be(_e=>_e.openContextSurface),x=Eb(_e=>_e.requestTarget),p=!b&&w>=768&&!qs(),y=c.useMemo(()=>GS(t,e),[t,e]),v=c.useMemo(()=>Di.get(y)??null,[y]),j=hs(_e=>_e.ensureEntry),C=hs(_e=>_e.setParams),k=hs(_e=>_e.beginActiveContextsLoad),T=hs(_e=>_e.commitActiveContexts),O=hs(_e=>_e.releaseActiveContexts),M=c.useId(),L=hs(_e=>_e.startWatching),F=hs(_e=>_e.stopWatching),D=hs(_e=>_e.refresh),[U,N]=c.useState(()=>v?.title??Ii(e)),[A,H]=c.useState(()=>v?.body??""),[I,R]=c.useState(()=>v?.draft??Pc()),[P,_]=c.useState(()=>v?.additionalContext??""),[G,ae]=c.useState(()=>{const _e=typeof v?.targetBaseBranch=="string"?An(v.targetBaseBranch):"";return _e||An(s)}),[Se,J]=c.useState(!1),[re,ie]=c.useState(!1),[Be,Ae]=c.useState(!1),K=Bu(t,m),q=K.scope.runtimeKey;c.useEffect(()=>{if(!t)return;const _e=K.scope.runtimeKey,st=k(_e,t,M),ut=K.contexts.filter(St=>qi(h[lr(St)],St).connected);return T(_e,t,M,st,ut),()=>{O(_e,t,M)}},[k,K.contexts,K.scope.runtimeKey,T,t,O,h,M]);const me=K.contexts[0]??null,he=Bn(_e=>d?_e.entries[lr(d)]?.hasChecked===!0:!1),je=me?.primaryRemote??null,Y=c.useMemo(()=>me?lr(me):"",[me]),ue=Bn(_e=>_e.entries[Y]),we=me?qi(ue,me):{authChecked:ue?.hasChecked??!1,connected:!1},ce=we.authChecked,[le,Re]=c.useState(0),[Oe,Te]=c.useState({key:"",status:"loading",capabilities:null}),[De,te]=c.useState(!1),{detectedUpstream:de,upstreamBranches:fe}=qS(t,m,me);c.useEffect(()=>{if(!me)return;let _e=!1;const st=lr(me);return Te({key:st,status:"loading",capabilities:null}),m.capabilities(me).then(ut=>{_e||Te({key:st,status:"ready",capabilities:ut})}).catch(()=>{_e||Te({key:st,status:"error",capabilities:null})}),()=>{_e=!0}},[le,me,m]);const ge=Oe.key===Y?Oe:null,B=ge?.status==="ready"?ge.capabilities:null;c.useEffect(()=>{te(!1)},[t]);const ke=!!(t&&e&&s&&(e!==s||de!==null)),Ie=c.useMemo(()=>me?Fu(me,e):"",[e,me]),oe=c.useRef(Ie);oe.current=Ie;const $e=c.useCallback((_e,st)=>_e===Jt()&&st===oe.current,[]),Fe=hs(_e=>_e.entries[Ie]),Ce=c.useMemo(()=>Ie?[Ie]:[],[Ie]);Lu(_u(Ce));const Ue=Fe?.isLoading??!1,pe=we.connected?Fe?.status??null:null,ne=K.error?u("settings.gitlab.status.operationFailed"):Fe?.error??null,Me=Fe?.isInitialStatusResolved??!1,He=c.useMemo(()=>{const _e=De?null:je,st=new Set;for(const Ct of i){const Nt=VS(Ct,_e);!Nt||Nt==="HEAD"||st.add(Nt)}if(De)for(const Ct of fe)Ct&&Ct!=="HEAD"&&st.add(Ct);const ut=An(s);ut&&ut!=="HEAD"&&st.add(ut);const St=An(G);return St&&St!=="HEAD"&&st.add(St),Array.from(st).sort((Ct,Nt)=>Ct.localeCompare(Nt))},[s,i,je,G,fe,De]);c.useEffect(()=>{const _e=An(s);if(!G&&_e){ae(_e);return}if(He.length!==0&&!He.includes(G)){const st=He.includes(_e)?_e:He[0];st&&ae(st)}},[He,s,G]);const Ye=c.useRef([]),Xe=c.useRef(new Map),Je=c.useCallback(_e=>{const st=Xe.current.get(_e);if(st?.inFlight)return null;if(st)return st.inFlight=!0,st.key;const ut=zS();return Xe.current.set(_e,{key:ut,inFlight:!0}),ut},[]),bt=c.useCallback((_e,st,ut)=>{const St=Xe.current.get(_e);!St||St.key!==st||(ut?St.inFlight=!1:Xe.current.delete(_e))},[]);c.useEffect(()=>{de&&te(!0)},[de]),c.useEffect(()=>{De&&de?.defaultBranch&&ae(de.defaultBranch)},[De,de?.defaultBranch]);const et=pe?.changeRequest??pe?.pr??null,lt=pe?.identity??me,xt=c.useMemo(()=>pe?.project??(pe?.repo&&lt?{...pe.repo,...lt,id:`${pe.repo.owner}/${pe.repo.repo}`,name:pe.repo.repo}:null),[pe?.project,pe?.repo,lt]),wt=et?.state==="merged"||et?.state==="closed",dt=wt?null:et,It=pe?.ci?.summary??pe?.checks??null,[_t,Bt]=c.useState(!1),ye=c.useRef(!0);c.useEffect(()=>(ye.current=!0,()=>{ye.current=!1}),[]);const z=c.useCallback(async _e=>{await D(Ie,_e)},[Ie,D]),W=c.useCallback((_e,st)=>{Ye.current.forEach(ut=>{window.clearTimeout(ut)}),Ye.current=KS.map(ut=>window.setTimeout(()=>{$e(_e,st)&&D(st,{force:!0,silent:!0,markInitialResolved:!0})},ut))},[$e,D]),Z=c.useCallback(async(_e,st,ut)=>{await PS({error:_e,isCurrent:()=>$e(st,ut),refresh:()=>D(ut,{force:!0,silent:!0,markInitialResolved:!0}),scheduleRefresh:()=>W(st,ut)})},[$e,D,W]);c.useEffect(()=>{!me||!Ie||(j(Ie),C(Ie,{directory:t,branch:e,remoteName:me.primaryRemote,canShow:ke,identity:me,readContext:me,sourceControl:m,authChecked:we.authChecked,connected:we.connected}))},[e,ke,t,j,Ie,me,m,we.authChecked,we.connected,C]);const ve=600,E=c.useCallback(async()=>{if(_t)return;Bt(!0);const _e=Date.now();try{await z({force:!0})}finally{const st=ve-(Date.now()-_e);st>0&&await new Promise(ut=>window.setTimeout(ut,st)),ye.current&&Bt(!1)}},[_t,z]);c.useEffect(()=>{if(!(!me||!Ie))return L(Ie),()=>{F(Ie)}},[Ie,me,L,F]),c.useEffect(()=>{const _e=Di.get(y)??null;N(_e?.title??Ii(e)),H(_e?.body??""),R(_e?.draft??Pc()),ae(_e?.targetBaseBranch?An(_e.targetBaseBranch):An(s))},[s,e,y]),c.useEffect(()=>{!me||!Ie||!we.connected||z({markInitialResolved:!0})},[Ie,me,z,we.connected]),c.useEffect(()=>{!ke||!me||!we.connected||z({force:!0,silent:!0,markInitialResolved:!0})},[ke,me,z,we.connected]),c.useEffect(()=>{const _e=()=>{const ut=hs.getState().entries[Ie]?.lastRefreshAt??0;Date.now()-ut>6e4&&z({force:!0,silent:!0})},st=()=>{document.visibilityState==="visible"&&_e()};return window.addEventListener("focus",_e),document.addEventListener("visibilitychange",st),()=>{window.removeEventListener("focus",_e),document.removeEventListener("visibilitychange",st)}},[Ie,z]),c.useEffect(()=>{ce&&!we.connected&&z({force:!0,silent:!0,markInitialResolved:!0})},[z,we.connected,ce]),c.useEffect(()=>{!t||!e||Di.set(y,{title:U,body:A,draft:I,additionalContext:P,targetBaseBranch:G})},[y,U,A,I,P,G,t,e]),c.useEffect(()=>()=>{Ye.current.forEach(_e=>{window.clearTimeout(_e)}),Ye.current=[]},[Ie,q]),c.useEffect(()=>()=>{Xe.current.clear()},[]);const V=De&&de?.defaultBranchSha?de.defaultBranchSha:me?`${me.primaryRemote}/${G}`:G;c.useEffect(()=>{if(!t||!e||!V)return;let _e=!1;return Rb(t,{from:V,to:e,maxCount:2}).then(st=>{const ut=st.all.length===1?st.all[0]?.message.trim():"";_e||!ut||N(St=>St===Ii(e)?ut:St)}).catch(()=>{}),()=>{_e=!0}},[e,V,t]);const Ne=!r||o>0,We=LS(t,e),Ge=c.useId(),qe=_e=>{R(_e),HS(_e)},Pe=c.useCallback(async()=>{if(!Se&&t){J(!0);try{const st={base:V,head:e,...me?.provider?{changeRequestProvider:me.provider}:{}};P&&(st.context=P);const ut=await Tb(t,st);ut.title?.trim()&&N(ut.title.trim()),ut.body?.trim()&&H(ut.body.trim()),l?.()}catch(_e){const st=_e instanceof Error?_e.message:String(_e);Ke.error(u("gitView.pr.toast.generateDescriptionFailed"),{description:st})}finally{J(!1)}}},[P,e,V,t,Se,l,me,u]),ze=c.useCallback(async()=>{if(B?.changeRequests!==!0){Ke.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.capabilitiesUnavailable")});return}const _e=U.trim();if(!_e){Ke.error(u("gitView.pr.toast.titleRequired"));return}const st=G.trim();if(!st){Ke.error(u("gitView.pr.toast.baseBranchRequired"));return}if(!De&&st===e){Ke.error(u("gitView.pr.toast.baseMustDifferFromHead"));return}const ut=De?de:xt;if(!me||!ut){Ke.error(u("gitView.pr.toast.createPrFailed"),{description:u("gitView.pr.statusUnavailable")});return}if(Ne&&(ie(!0),!await We.push())){ie(!1);return}const St=Jt(),Ct=Ie,Nt={owner:ut.owner,name:ut.name},os=A.trim()?A:void 0,Ht=De?void 0:me.primaryRemote,Ee=De?me.primaryRemote:void 0,Qe=US(St,me,[Nt.owner,Nt.name,e,st,_e,os,I,Ht,Ee]),rt=Je(Qe);if(!rt){ie(!1);return}ie(!0);let pt=!1,Mt=!1;try{const Wt={...me,idempotencyKey:rt,target:{project:Nt,head:e,base:st},title:_e,draft:I};os!==void 0&&(Wt.body=os),Ht&&(Wt.remote=Ht),Ee&&(Wt.headRemote=Ee);const ss=await m.changeRequestCreate(Wt);if(Mt=!0,bt(Qe,rt,!1),!$e(St,Ct)||(Ke.success(u("gitView.pr.toast.prCreated")),await z({force:!0}),!$e(St,Ct)))return;const Kt=hs.getState().entries[Ct]?.status,Yt=Kt?.changeRequest??Kt?.pr;Yt&&Yt.number===ss.target.number&&$S(t,Yt),W(St,Ct)}catch(Wt){const ss=Wt instanceof Error?Wt:new Error(String(Wt));pt=Bf(ss);const Kt=ss.message;Ke.error(u("gitView.pr.toast.createPrFailed"),{description:Kt}),pt&&await Z(ss,St,Ct)}finally{Mt||bt(Qe,rt,pt),ie(!1)}},[Je,A,e,We,de,t,I,bt,$e,Ne,Ie,me,Z,z,W,m,B?.changeRequests,xt,G,U,De,u]),Rt="border-0 bg-transparent rounded-none px-4 py-3";if(!ke)return n.jsx("section",{className:Rt,children:n.jsxs("div",{className:"space-y-1 pt-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:u("gitView.pullRequest.title")}),n.jsx(CS,{identity:d??void 0})]}),n.jsx("div",{className:"typography-micro text-muted-foreground",children:u("gitView.pullRequest.availableOnFeatureBranches")})]})});const zt=pe?.changeRequest&&pe.changeRequest.state==="open"?pe.changeRequest:dt&&xt&&lt?{...lt,id:`${xt.owner}/${xt.name}#${dt.number}`,number:dt.number,project:{...lt,id:xt.id,owner:xt.owner,name:xt.name,url:xt.url??""},title:dt.title,body:dt.body,url:dt.url,state:dt.state,draft:dt.draft,base:dt.base,head:dt.head,headSha:dt.headSha,mergeable:dt.mergeable,mergeableState:dt.mergeableState}:null;if(zt&&me)return n.jsx("div",{className:"h-full min-h-0",children:n.jsx(ES,{directory:t,context:me,changeRequest:zt,onChanged:()=>{z({force:!0,silent:!0,markInitialResolved:!0})}})});const Tt=xt?.url||null,Ft=De&&de?.url?de.url:Tt,gt=ge?.status==="error",vt=!!pe?.connected,qt=!!(!me&&d&&K.status==="ready"&&he),ct=!!(lt&&ce&&pe?.connected===!1)||qt,at=lt??d,yt=at?Mb(at.provider):null,$t=WS(pe),ls=$t?`var(--pr-${$t})`:"var(--status-info)",jt=$t==="draft"?"git-pr-draft":$t==="merged"?"git-merge":$t==="closed"?"git-close-pull-request":"git-pull-request",kt=et?[`${et.state}${et.draft?" (draft)":""}`,et.state==="open"&&et.mergeable===!1?u("gitView.pr.notMergeable"):null,et.state==="open"&&typeof et.mergeableState=="string"&&et.mergeableState&&et.mergeableState!=="unknown"?et.mergeableState:null].filter(Boolean).join(" · "):"",Vt=It?It.total>0?`${It.success}/${It.total} ${u("gitView.pr.checks.label")}`:`${It.state} ${u("gitView.pr.checks.label")}`:"",es="px-0 py-3 border-b border-border/40 flex flex-col gap-1",Is="flex flex-col gap-3 py-3",Ds=n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Ue||_t,onClick:()=>{E()},"aria-label":u("gitView.pr.actions.refreshAria"),children:n.jsx($,{name:Ue||_t?"loader-4":"refresh",className:xe("size-4 text-muted-foreground",(Ue||_t)&&"animate-spin")})})}),n.jsx(Pt,{children:n.jsx("p",{children:u("gitView.pr.actions.refresh")})})]}),ts=Be||P.trim().length>0,Le=Ne?r?o===1?u("gitView.pr.unpushed.one"):u("gitView.pr.unpushed.many",{count:o}):u("gitView.pr.unpushed.unpublished"):null,nt=u(Ne?I?"gitView.pr.actions.pushAndCreateDraftPr":"gitView.pr.actions.pushAndCreatePr":I?"gitView.pr.actions.createDraftPr":"gitView.pr.actions.createPr"),it=re||!vt||B?.changeRequests!==!0||!G.trim()||!De&&G.trim()===e;return n.jsxs("section",{className:Rt,children:[et?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(ft,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Ic(et.url)},"aria-label":yt?u("gitView.pr.actions.openOnProviderAria",{provider:yt}):u("gitView.header.openPullRequest"),children:[n.jsx($,{name:jt,className:"size-4 shrink-0",style:{color:ls}}),yt?u("gitView.pr.actions.openOnProvider",{provider:yt}):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:_a(lt?.provider,et.number)})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Ds})]}),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:ls},children:kt}),It?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:`h-2 w-2 rounded-full ${_S(It.state)}`}),Vt]}):null,r&&je&&r.split("/")[0]!==je?n.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",je]}):null]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:p&&(me?.provider==="github"||me?.provider==="gitlab")?n.jsxs(ft,{variant:"outline",size:"sm",className:xe("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",kS),onClick:()=>{x(t,{source:{kind:"pr",number:et.number,...xt?{sourceRepo:{owner:xt.owner,repo:xt.name}}:{}},context:me}),S(t,"walkthrough")},"aria-label":u("walkthrough.action.open"),children:[n.jsx($,{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:Is,children:[gt?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(ft,{variant:"outline",size:"sm",onClick:()=>Re(_e=>_e+1),children:u("settings.sourceControl.transport.retry")})]}):null,ct&&yt?n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"typography-meta text-muted-foreground",children:u("gitView.pr.providerNotConnected",{provider:yt})}),n.jsx(ft,{variant:"outline",size:"sm",onClick:f,className:"w-fit",children:u("gitView.pr.actions.openSettings")})]}):null,ne?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:ne}),K.error?n.jsx(ft,{variant:"outline",size:"sm",onClick:()=>{K.retry()},disabled:K.status==="loading",children:u("settings.sourceControl.transport.retry")}):null,Ft?n.jsx(ft,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:n.jsxs("a",{href:Ft,target:"_blank",rel:"noopener noreferrer",children:[n.jsx($,{name:"external-link",className:"size-4"}),u("gitView.pr.actions.repo")]})}):null]}):null,(dt||!et&&!Me)&&!ne&&!ct&&(K.status==="loading"||me)?n.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[n.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),u("gitView.pr.checkingStatus")]}):n.jsxs("div",{className:"flex flex-col gap-3",children:[et&&wt?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($,{name:et.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:ls}}),n.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:et.state==="merged"?u("gitView.pr.history.merged",{number:et.number,base:et.base||G}):u("gitView.pr.history.closed",{number:et.number})}),n.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Ic(et.url)},"aria-label":u("gitView.pr.actions.openOnProviderAria",{provider:yt}),children:n.jsx($,{name:"external-link",className:"size-3.5"})})]}):null,n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx($,{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($,{name:"arrow-right",className:"size-3.5 shrink-0 text-muted-foreground"}),De&&de?n.jsxs("span",{className:"min-w-0 shrink truncate typography-meta text-muted-foreground",children:[de.owner,"/",de.name]}):null,He.length>0?n.jsxs(Ob,{value:G,onValueChange:ae,children:[n.jsx(Bb,{size:"sm",className:"w-auto min-w-0","aria-label":u("gitView.pr.field.baseBranch"),children:n.jsx(Fb,{placeholder:u("gitView.pr.placeholder.selectBaseBranch")})}),n.jsx(Lb,{children:He.map(_e=>n.jsx(_b,{value:_e,children:_e},_e))})]}):n.jsx(Po,{value:G,onChange:_e=>ae(_e.target.value),placeholder:u("gitView.pr.placeholder.main"),"aria-label":u("gitView.pr.field.baseBranch"),className:"h-7 w-32"}),n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[Ft?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",asChild:!0,children:n.jsx("a",{href:Ft,target:"_blank",rel:"noopener noreferrer","aria-label":u("gitView.pr.actions.repo"),children:n.jsx($,{name:"external-link",className:"size-4 text-muted-foreground"})})})}),n.jsx(Pt,{children:n.jsx("p",{children:u("gitView.pr.actions.repo")})})]}):null,Ds]})]}),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(Po,{value:U,onChange:_e=>N(_e.target.value),placeholder:u("gitView.pr.placeholder.title"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("label",{htmlFor:Ge,className:"typography-micro text-muted-foreground",children:u("gitView.pr.field.description")}),n.jsxs("div",{className:"flex items-center",children:[n.jsxs(ft,{variant:"ghost",size:"xs",className:"rounded-r-none supports-[corner-shape:squircle]:rounded-r-none",onClick:Pe,disabled:Se||re,children:[Se?n.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx($,{name:"ai-generate-2",className:"size-3.5 text-primary"}),u("gitView.commit.generate")]}),n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"xs",className:"rounded-l-none border-l-0 supports-[corner-shape:squircle]:rounded-l-none px-1",disabled:Se||re,"aria-label":u("gitView.pr.generate.optionsAria"),children:n.jsx($,{name:"arrow-down-s",className:"size-3.5"})})}),n.jsx(As,{align:"end",className:"w-60",children:n.jsxs(Gt,{onSelect:()=>Ae(!0),children:[n.jsx($,{name:"sticky-note",className:"size-4 shrink-0"}),u("gitView.pr.generate.withNotes")]})})]})]})]}),ts?n.jsxs("div",{className:"relative",children:[n.jsx(Xl,{value:P,onChange:_e=>_(_e.target.value),className:"min-h-[72px] pr-9",placeholder:u("gitView.pr.placeholder.additionalContext"),"aria-label":u("gitView.pr.generate.notesAria"),autoFocus:Be&&!P}),n.jsx(ft,{variant:"ghost",size:"xs",className:"absolute right-1.5 top-1.5 h-6 w-6 px-0",onClick:()=>{_(""),Ae(!1)},"aria-label":u("gitView.pr.generate.removeNotesAria"),children:n.jsx($,{name:"close",className:"size-3.5"})})]}):null,n.jsx(Xl,{id:Ge,value:A,onChange:_e=>H(_e.target.value),className:"min-h-[140px]",placeholder:u("gitView.pr.placeholder.whatChanged"),autoCorrect:g?"on":"off",autoCapitalize:g?"sentences":"off",spellCheck:g})]}),Le?n.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-[var(--status-warning)]",children:[n.jsx($,{name:"arrow-up",className:"size-3.5 shrink-0"}),Le]}):null,n.jsx("div",{className:"flex justify-end",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs(ft,{size:"sm",className:"justify-center gap-2 rounded-r-none supports-[corner-shape:squircle]:rounded-r-none",onClick:ze,disabled:it,children:[re?n.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx($,{name:I?"git-pr-draft":"git-pull-request",className:"size-4"}),n.jsx("span",{children:nt})]}),n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(ft,{size:"sm",className:"rounded-l-none border-l-0 supports-[corner-shape:squircle]:rounded-l-none px-1.5",disabled:re,"aria-label":u("gitView.pr.createKindAria"),children:n.jsx($,{name:"arrow-down-s",className:"size-4"})})}),n.jsx(As,{align:"end",className:"w-56",children:n.jsxs($b,{value:I?"draft":"ready",onValueChange:_e=>qe(_e==="draft"),children:[n.jsx(Jl,{value:"ready",children:u("gitView.pr.actions.createPr")}),n.jsx(Jl,{value:"draft",children:u("gitView.pr.actions.createDraftPr")})]})})]})]})}),We.dialogs]})]})]})},QS=()=>{const t=Ve.c(100),{t:e}=mt(),{git:s,sourceControl:r}=Qs(),o=Fn(),{rootIsGitRepo:i,gitDirectory:l,nestedRepos:a}=Ub(o??null),d=$a(l??null),u=Hb(l??null),f=Vb(l??null),m=Bu(l,r),{ensureAll:h,ensureNestedRepos:b,selectNestedRepo:g}=xn(yr(XS)),w=Ze(JS),S=Ze(ZS),x=Ze(ew),p=Ze(tw);let y;t[0]!==o?(y=ot(o),t[0]=o,t[1]=y):y=t[1];const v=y;let j;if(t[2]!==p||t[3]!==v||t[4]!==x){e:{if(!v){j=void 0;break e}let ce;if(t[6]!==p||t[7]!==v){let Re;t[9]!==v?(Re=Oe=>ot(Oe.path)===v,t[9]=v,t[10]=Re):Re=t[10],ce=p.find(Re),t[6]=p,t[7]=v,t[8]=ce}else ce=t[8];const le=ce;if(le){j=le;break e}for(const Re of x.values())if(ot(Re.path)===v){j=Re;break e}j=void 0}t[2]=p,t[3]=v,t[4]=x,t[5]=j}else j=t[5];const C=j;let k;t[11]!==w||t[12]!==C||t[13]!==S?.open||t[14]!==x?(k=()=>{if(w)return x.get(w)??C;if(S?.open)return C},t[11]=w,t[12]=C,t[13]=S?.open,t[14]=x,t[15]=k):k=t[15],S?.open;let T;t[16]!==k?(T=k(),t[16]=k,t[17]=T):T=t[17];const O=T;let M;t[18]!==w?(M=ce=>w?ce.getAttachment(w):void 0,t[18]=w,t[19]=M):M=t[19];const L=Cu(M),F=L&&!L.degraded&&!L.legacy?L.worktreeRoot??void 0:void 0,D=xS(o,O,d?.current??void 0);let U,N;t[20]!==h||t[21]!==s||t[22]!==l?(U=()=>{!l||!s||h(l,s)},N=[l,h,s],t[20]=h,t[21]=s,t[22]=l,t[23]=U,t[24]=N):(U=t[23],N=t[24]),c.useEffect(U,N);const[A,H]=c.useState(null);let I;t[25]!==F||t[26]!==D?.projectDirectory?(I=()=>{const ce=F||D?.projectDirectory;if(!ce){H(null);return}let le=!1;return $u(ce).then(Re=>{if(le)return;const Oe=Re.trim();H(Oe&&Oe!=="HEAD"?Oe:null)}).catch(()=>{le||H(null)}),()=>{le=!0}},t[25]=F,t[26]=D?.projectDirectory,t[27]=I):I=t[27];const R=D?.projectDirectory;let P;t[28]!==F||t[29]!==R?(P=[F,R],t[28]=F,t[29]=R,t[30]=P):P=t[30],c.useEffect(I,P);let _;e:{if(!u?.all){let le;t[31]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[31]=le):le=t[31],_=le;break e}let ce;t[32]!==u.all?(ce=u.all.filter(sw).sort(),t[32]=u.all,t[33]=ce):ce=t[33],_=ce}const G=_;let ae;e:{if(!u?.all){let le;t[34]===Symbol.for("react.memo_cache_sentinel")?(le=[],t[34]=le):le=t[34],ae=le;break e}let ce;t[35]!==u.all?(ce=u.all.filter(nw).map(rw).sort(),t[35]=u.all,t[36]=ce):ce=t[36],ae=ce}const Se=ae,J=d?.current??null,re=m.contexts[0]?.primaryRemote,ie=re?u?.defaultBranches?.[re]:void 0;let Be;t[37]!==m.contexts[0]||t[38]!==m.read?.repository.remotes||t[39]!==J||t[40]!==ie||t[41]!==G||t[42]!==A||t[43]!==D?.createdFromBranch?(Be=()=>Uh({remoteNames:new Set(m.contexts[0]?.primaryRemote?[m.contexts[0].primaryRemote]:[]),knownRemoteNames:new Set(m.read?.repository.remotes.map(ow)??[]),localBranches:G,worktreeCreatedFromBranch:D?.createdFromBranch,rootBranchHint:A,defaultBranch:ie,headBranch:J,fallbackToConventional:!1}),t[37]=m.contexts[0],t[38]=m.read?.repository.remotes,t[39]=J,t[40]=ie,t[41]=G,t[42]=A,t[43]=D?.createdFromBranch,t[44]=Be):Be=t[44],D?.createdFromBranch;let Ae;t[45]!==Be?(Ae=Be(),t[45]=Be,t[46]=Ae):Ae=t[46];const K=Ae,q=Ou(o??null)?.provider;if(!o){let ce;t[47]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx($,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[47]=ce):ce=t[47];let le;t[48]!==q||t[49]!==e?(le=e(Tn("gitView.pullRequest.title",q)),t[48]=q,t[49]=e,t[50]=le):le=t[50];let Re;t[51]!==le?(Re=n.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[51]=le,t[52]=Re):Re=t[52];let Oe;t[53]!==q||t[54]!==e?(Oe=e(Tn("gitView.pullRequest.createHint",q)),t[53]=q,t[54]=e,t[55]=Oe):Oe=t[55];let Te;t[56]!==Oe?(Te=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Oe}),t[56]=Oe,t[57]=Te):Te=t[57];let De;return t[58]!==Re||t[59]!==Te?(De=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ce,Re,Te]}),t[58]=Re,t[59]=Te,t[60]=De):De=t[60],De}if(i===!1&&f!==!0){let ce;t[61]!==o||t[62]!==b?(ce=()=>{b(o,{force:!0})},t[61]=o,t[62]=b,t[63]=ce):ce=t[63];let le;return t[64]!==o||t[65]!==f||t[66]!==a||t[67]!==i||t[68]!==ce?(le=n.jsx(Hh,{root:o,rootIsGitRepo:i,resolvedIsGitRepo:f,nestedRepos:a,onRetryDiscovery:ce}),t[64]=o,t[65]=f,t[66]=a,t[67]=i,t[68]=ce,t[69]=le):le=t[69],le}if(!J){let ce;t[70]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx($,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[70]=ce):ce=t[70];let le;t[71]!==q||t[72]!==e?(le=e(Tn("gitView.pullRequest.title",q)),t[71]=q,t[72]=e,t[73]=le):le=t[73];let Re;t[74]!==le?(Re=n.jsx("div",{className:"typography-ui-header text-foreground",children:le}),t[74]=le,t[75]=Re):Re=t[75];let Oe;t[76]!==q||t[77]!==e?(Oe=e(Tn("gitView.pullRequest.createHint",q)),t[76]=q,t[77]=e,t[78]=Oe):Oe=t[78];let Te;t[79]!==Oe?(Te=n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Oe}),t[79]=Oe,t[80]=Te):Te=t[80];let De;return t[81]!==Re||t[82]!==Te?(De=n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[ce,Re,Te]}),t[81]=Re,t[82]=Te,t[83]=De):De=t[83],De}const X=i===!1&&Array.isArray(a)&&a.length>0;let me;t[84]!==o||t[85]!==l||t[86]!==a||t[87]!==g||t[88]!==X?(me=X?n.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:n.jsx(Vh,{repositories:a,selectedRepository:l??null,onSelectRepository:ce=>{o&&g(o,ce)},repositoryRoot:o??void 0})}):null,t[84]=o,t[85]=l,t[86]=a,t[87]=g,t[88]=X,t[89]=me):me=t[89];const he=l??o,je=d?.tracking??void 0,Y=d?.ahead??0;let ue;t[90]!==K||t[91]!==J||t[92]!==Se||t[93]!==he||t[94]!==je||t[95]!==Y?(ue=n.jsx(Cn,{as:Gb,outerClassName:"h-full min-h-0 flex-1",className:"h-full",disableHorizontal:!0,preventOverscroll:!0,children:n.jsx(YS,{directory:he,branch:J,baseBranch:K,trackingBranch:je,ahead:Y,remoteBranches:Se})}),t[90]=K,t[91]=J,t[92]=Se,t[93]=he,t[94]=je,t[95]=Y,t[96]=ue):ue=t[96];let we;return t[97]!==me||t[98]!==ue?(we=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[me,ue]}),t[97]=me,t[98]=ue,t[99]=we):we=t[99],we};function XS(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function JS(t){return t.currentSessionId}function ZS(t){return t.newSessionDraft}function ew(t){return t.worktreeMetadata}function tw(t){return t.availableWorktrees}function sw(t){return!t.startsWith("remotes/")}function nw(t){return t.startsWith("remotes/")}function rw(t){return t.replace(/^remotes\//,"")}function ow(t){return t.name}const Fo=new Map,iw=(t,e)=>{if(t.size!==e.size)return!1;for(const[s,r]of t)if(e.get(s)!==r)return!1;return!0},aw=t=>{const e=t.time?.updated;return typeof e=="number"&&Number.isFinite(e)?e:0},lw=(t,e)=>{if(e.length===0)return Fo;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=aw(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?Fo:o},aa=2e4,cw=(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},eo=(t,e)=>Dm(Em.getState().dictionary,t,e),dw=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"},uw=async(t,e,s)=>{const r=!!(s?.directory&&!Jb(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 Fs(`/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()},Lf=async(t,e,s)=>{if(qb(e)||Yb(e)||Qb(e))return{ok:!0};try{const r=await uw(t,e,s);return Xb(r)?{ok:!1,reason:"binary"}:cw(r,aa)>aa?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:dw(r)}}},_f=t=>{if(t==="too-large"){const e=aa.toLocaleString(Wa());return eo("contextFileOpen.failure.tooLarge",{count:e})}return eo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},Dc=8;let la=null;const $f=t=>{la={x:t.clientX,y:t.clientY}},Wf=t=>{const e=la;return la=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=Dc&&Math.abs(t.clientY-e.y)<=Dc},pr=t=>Array.from(t.types).includes("Files"),fw=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]:[]})},pw=t=>t.slice().sort((e,s)=>e.type!==s.type?e.type==="directory"?-1:1:e.name.localeCompare(s.name)),fs=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},rl=(t,e)=>{const s=fs(e),r=fs(t).replace(/\/+$/,"");return s===r?".":!r||!s.startsWith(`${r}/`)?s:s.slice(r.length+1)},mw=(t,e)=>{const s=rl(t,e);if(s!==".")return s;const r=fs(t);return r.split("/").filter(Boolean).pop()??r},ca=t=>{const e=fs(t),s=e.lastIndexOf("/");return s<0?"":s===0?"/":e.slice(0,s)},hw=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),gw=new Set(["node_modules"]),bw=t=>gw.has(t),yw=t=>{const e=fs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},xw=8,ln=new Map,ol=t=>JSON.stringify([Jt(),t]),vw=t=>{const e=ol(t),s=ln.get(e);return s?(s.touchedAt=Date.now(),ln.delete(e),ln.set(e,s),s):null},Ei=t=>{const e=ol(t),s=ln.get(e);if(s)return s.touchedAt=Date.now(),s;if(ln.size>=xw){const o=ln.keys().next().value;o!==void 0&&ln.delete(o)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return ln.set(e,r),r},Kf=(t,e)=>n.jsx(Ka,{filePath:t,extension:e}),Sw=t=>{const e=Ve.c(3),{status:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const o=r[s];let i;return e[1]!==o?(i=n.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),e[1]=o,e[2]=i):i=e[2],i},ww=t=>{const e=Ve.c(95),{node:s,root:r,isExpanded:o,isActive:i,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:f,permissions:m,downloadFile:h,onSelect:b,onToggle:g,onRevealPath:w,onOpenDialog:S,onSetDropTarget:x,onDropFiles:p,onPickFiles:y}=t,{t:v}=mt(),j=s.type==="directory";let C;e[0]!==j||e[1]!==s.path?(C=j?s.path:ca(s.path),e[0]=j,e[1]=s.path,e[2]=C):C=e[2];const k=C,{canRename:T,canCreateFile:O,canCreateFolder:M,canDelete:L,canReveal:F}=m,D=!j&&!!h,U=F&&!l,N=j&&f,A=T||O||M||N||L||D||U,[H,I]=c.useState(!1),[R,P]=c.useState(!1);let _;e[3]!==A?(_=$e=>{A&&($e?.preventDefault(),P(!0))},e[3]=A,e[4]=_):_=e[4];const G=_;let ae;e[5]!==j||e[6]!==s||e[7]!==b||e[8]!==g?(ae=()=>{j?g(s.path):b(s)},e[5]=j,e[6]=s,e[7]=b,e[8]=g,e[9]=ae):ae=e[9];const Se=ae;let J;e[10]!==j||e[11]!==s||e[12]!==b?(J=()=>{j||b(s,{pin:!0})},e[10]=j,e[11]=s,e[12]=b,e[13]=J):J=e[13];const re=J;let ie;e[14]===Symbol.for("react.memo_cache_sentinel")?(ie=$e=>{$e.stopPropagation(),P(!1),I(!0)},e[14]=ie):ie=e[14];const Be=ie;let Ae;e[15]!==O||e[16]!==M||e[17]!==L||e[18]!==T||e[19]!==U||e[20]!==N||e[21]!==h||e[22]!==l||e[23]!==j||e[24]!==s||e[25]!==S||e[26]!==y||e[27]!==w||e[28]!==v?(Ae=$e=>{const{Item:Fe,Separator:Ce}=$e;return n.jsxs(n.Fragment,{children:[T&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),S("rename",s)},children:[n.jsx($,{name:"edit",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.rename")]}),n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),Xn(s.path).then(pe=>{if(pe.ok){Ke.success(v("sidebarFilesTree.toast.pathCopied"));return}Ke.error(v("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx($,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.copyPath")]}),!j&&h&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),h(s.path).catch(pe=>{console.error("Download failed:",pe),Ke.error(v("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx($,{name:"download",className:"mr-2 h-4 w-4"})," ",v(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),w(s.path)},children:[n.jsx($,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",v(Zb())]}),!j&&U&&$r()&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),Qd(s.path).then(pe=>{pe||Ke.error(v("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx($,{name:"external-link",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.openInDefaultApp")]}),j&&(O||M||N)&&n.jsxs(n.Fragment,{children:[n.jsx(Ce,{}),O&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),S("createFile",s)},children:[n.jsx($,{name:"file-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFile")]}),M&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),S("createFolder",s)},children:[n.jsx($,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.newFolder")]}),N&&n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),y(s.path)},children:[n.jsx($,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.uploadFiles")]})]}),L&&n.jsxs(n.Fragment,{children:[n.jsx(Ce,{}),n.jsxs(Fe,{onClick:Ue=>{Ue.stopPropagation(),S("delete",s)},className:"text-destructive focus:text-destructive",children:[n.jsx($,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",v("sidebarFilesTree.menu.delete")]})]})]})},e[15]=O,e[16]=M,e[17]=L,e[18]=T,e[19]=U,e[20]=N,e[21]=h,e[22]=l,e[23]=j,e[24]=s,e[25]=S,e[26]=y,e[27]=w,e[28]=v,e[29]=Ae):Ae=e[29];const K=Ae;let q;e[30]!==s.path||e[31]!==r?(q=$e=>{$f($e);const Fe=rl(r,s.path);!Fe||Fe==="."||($e.dataTransfer.setData("application/x-openchamber-file-path",Fe),$e.dataTransfer.effectAllowed="copy")},e[30]=s.path,e[31]=r,e[32]=q):q=e[32];const X=q;let me;e[33]!==Se?(me=$e=>{Wf($e)&&Se()},e[33]=Se,e[34]=me):me=e[34];const he=me;let je;e[35]!==f||e[36]!==x||e[37]!==k?(je=$e=>{!f||!k||!pr($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),$e.dataTransfer.dropEffect="copy",x(k))},e[35]=f,e[36]=x,e[37]=k,e[38]=je):je=e[38];const Y=je;let ue;e[39]!==f||e[40]!==x||e[41]!==k?(ue=$e=>{!f||!k||!pr($e.dataTransfer)||$e.relatedTarget instanceof Node&&$e.currentTarget.contains($e.relatedTarget)||($e.stopPropagation(),x(null))},e[39]=f,e[40]=x,e[41]=k,e[42]=ue):ue=e[42];const we=ue;let ce;e[43]!==f||e[44]!==p||e[45]!==k?(ce=$e=>{!f||!k||!pr($e.dataTransfer)||($e.preventDefault(),$e.stopPropagation(),p(k,$e.dataTransfer))},e[43]=f,e[44]=p,e[45]=k,e[46]=ce):ce=e[46];const le=ce;let Re;e[47]===Symbol.for("react.memo_cache_sentinel")?(Re={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[47]=Re):Re=e[47];let Oe;e[48]!==G||e[49]!==we||e[50]!==Y||e[51]!==le?(Oe=n.jsx("div",{className:"group relative flex items-center typography-meta",style:Re,onContextMenu:G,onDragEnter:Y,onDragOver:Y,onDragLeave:we,onDrop:le}),e[48]=G,e[49]=we,e[50]=Y,e[51]=le,e[52]=Oe):Oe=e[52];const Te=u?"bg-interactive-selection ring-2 ring-inset ring-primary":i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let De;e[53]!==Te?(De=xe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Te),e[53]=Te,e[54]=De):De=e[54];let te;e[55]!==j||e[56]!==o||e[57]!==s.extension||e[58]!==s.path?(te=j?o?n.jsx($,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):n.jsx($,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Kf(s.path,s.extension),e[55]=j,e[56]=o,e[57]=s.extension,e[58]=s.path,e[59]=te):te=e[59];let de;e[60]!==s.name||e[61]!==s.path?(de=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:s.path,children:s.name}),e[60]=s.name,e[61]=s.path,e[62]=de):de=e[62];let fe;e[63]!==j||e[64]!==a?(fe=!j&&a&&n.jsx(Sw,{status:a}),e[63]=j,e[64]=a,e[65]=fe):fe=e[65];let ge;e[66]!==d||e[67]!==j?(ge=j&&d&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[66]=d,e[67]=j,e[68]=ge):ge=e[68];let B;e[69]!==G||e[70]!==re||e[71]!==he||e[72]!==X||e[73]!==Se||e[74]!==De||e[75]!==te||e[76]!==de||e[77]!==fe||e[78]!==ge?(B=n.jsxs("button",{type:"button",onClick:Se,onDoubleClick:re,onContextMenu:G,draggable:!0,onDragStart:X,onDragEnd:he,className:De,children:[te,de,fe,ge]}),e[69]=G,e[70]=re,e[71]=he,e[72]=X,e[73]=Se,e[74]=De,e[75]=te,e[76]=de,e[77]=fe,e[78]=ge,e[79]=B):B=e[79];let Q;e[80]!==H||e[81]!==A||e[82]!==K||e[83]!==v?(Q=A&&n.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:n.jsxs(Ps,{open:H,onOpenChange:I,children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Ns,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Be,title:v("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":v("sidebarFilesTree.actions.fileMenuTitle"),children:n.jsx($,{name:"more-2-fill",className:"h-4 w-4"})})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:v("sidebarFilesTree.actions.fileMenuTitle")})]}),n.jsx(As,{align:"end",side:"bottom",onCloseAutoFocus:()=>I(!1),children:K({Item:Gt,Separator:Cs})})]})}),e[80]=H,e[81]=A,e[82]=K,e[83]=v,e[84]=Q):Q=e[84];let ke;e[85]!==Oe||e[86]!==B||e[87]!==Q?(ke=n.jsxs(Ku,{render:Oe,children:[B,Q]}),e[85]=Oe,e[86]=B,e[87]=Q,e[88]=ke):ke=e[88];let Ie;e[89]!==K?(Ie=n.jsx(Wu,{className:"min-w-[180px]",children:K({Item:qn,Separator:Yi})}),e[89]=K,e[90]=Ie):Ie=e[90];let oe;return e[91]!==R||e[92]!==ke||e[93]!==Ie?(oe=n.jsxs(zu,{open:R,onOpenChange:P,children:[ke,Ie]}),e[91]=R,e[92]=ke,e[93]=Ie,e[94]=oe):oe=e[94],oe},jw=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles,kw=c.memo(ww,jw),Cw=t=>{const e=Ve.c(6),{visible:s}=t,r=s===void 0?!0:s,o=xn(Aw),i=Fn();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(Nw,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},Nw=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:s}=mt(),{files:r,runtime:o}=Qs(),i=Rm(o.platform),l=Fn()??"",a=fs(l.trim()),d=ol(a),u=Tm(),f=Mm(),m=Zd(ye=>ye.searchFiles),h=be(ye=>ye.openContextFile),b=$a(t?l:null),[g,w]=c.useState(""),S=Uu(g,200),x=c.useRef(null),[p,y]=c.useState([]),[v,j]=c.useState(!1),[C,k]=c.useState(null),[T,O]=c.useState({}),[M,L]=c.useState({}),F=c.useRef(new Set),D=c.useRef(new Map),U=c.useMemo(()=>new C1,[]);c.useEffect(()=>()=>U.clear(),[U]);const N=c.useRef(null);c.useEffect(()=>{if(k(null),!a){O({}),L({}),F.current=new Set;return}const ye=vw(a);ye?(O({...ye.childrenByDir}),L({...ye.loadErrorsByDir}),F.current=new Set(ye.loadedDirs)):(O({}),L({}),F.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const ye=Ei(a);ye.childrenByDir=T},[a,T]),c.useEffect(()=>{if(!a)return;const ye=Ei(a);ye.loadErrorsByDir=M},[a,M]),c.useEffect(()=>{if(!a)return;const ye=Ei(a);ye.loadedDirs=new Set(F.current)},[a,T,M]),c.useEffect(()=>()=>{if(!a)return;const ye=ln.get(d);ye&&ye.loadedDirs.size===0&&Object.keys(ye.childrenByDir).length===0&&ln.delete(d)},[d,a]);const A=c.useMemo(()=>[],[]),H=c.useMemo(()=>[],[]),I=an(ye=>a?ye.byRoot[a]?.expandedPaths??A:A),R=c.useMemo(()=>new Set(I),[I]),P=an(ye=>a?ye.byRoot[a]?.selectedPath??null:null),_=an(ye=>ye.setSelectedPath),G=c.useRef(null),ae=c.useRef(null);c.useEffect(()=>{ae.current=P},[P]);const Se=an(ye=>ye.addOpenPath),J=an(ye=>ye.removeOpenPathsByPrefix),re=an(ye=>ye.toggleExpandedPath),ie=an(ye=>ye.collapseAllExpandedPaths),Be=be(ye=>a?ye.contextPanelByDirectory[a]?.tabs??H:H),Ae=c.useMemo(()=>new Set(Be.map(ye=>ye.mode==="file"?ye.targetPath:null).filter(ye=>typeof ye=="string"&&ye.length>0).map(ye=>fs(ye))),[Be]),[K,q]=c.useState(null),[X,me]=c.useState(null),[he,je]=c.useState(""),[Y,ue]=c.useState(!1),we=!!r.writeFile,ce=!!r.createDirectory,le=!!r.rename,Re=!!r.delete,Oe=!!r.revealPath,Te=c.useMemo(()=>({canRename:le,canCreateFile:we,canCreateFolder:ce,canDelete:Re,canReveal:Oe}),[le,we,ce,Re,Oe]),De=c.useCallback(ye=>{r.revealPath&&r.revealPath(ye).catch(()=>{Ke.error(s("sidebarFilesTree.toast.revealFailed"))})},[r,s]),te=c.useCallback((ye,z)=>{q(ye),me(z),je(ye==="rename"&&z.name||""),ue(!1)},[]),de=c.useCallback((ye,z)=>{const W=z.filter(Z=>Z&&typeof Z.name=="string"&&Z.name.length>0).filter(Z=>u||!Z.name.startsWith(".")).filter(Z=>f||!bw(Z.name)).map(Z=>{const ve=Z.name,E=fs(Z.path||""),V=E?hw(E)?E:fs(`${ye}/${E}`):fs(`${ye}/${ve}`),Ne=Z.isDirectory?"directory":"file",We=Ne==="file"&&ve.includes(".")?ve.split(".").pop()?.toLowerCase():void 0;return{name:ve,path:V,type:Ne,extension:We}});return pw(W)},[f,u]),fe=c.useCallback(async(ye,z,W=!1)=>{if(!e.current||z?.())return;const Z=fs(ye.trim());if(!Z||!W&&F.current.has(Z))return;const ve=Jt();return U.run(Z,async E=>{const V=()=>!E()||Jt()!==ve;try{const Ne=!f,We=r.listDirectory?(await r.listDirectory(Z,{respectGitignore:Ne})).entries:await Mr.listLocalDirectory(Z,{respectGitignore:Ne});if(V())return;D.current.set(Z,We.length);const Ge=de(Z,We);F.current=new Set(F.current),F.current.add(Z),L(qe=>{if(!qe[Z])return qe;const Pe={...qe};return delete Pe[Z],Pe}),O(qe=>qe[Z]&&N1(qe[Z],Ge)?qe:{...qe,[Z]:Ge})}catch(Ne){if(V())return;const We=Ne instanceof Error?Ne.message:String(Ne??"");console.error("Failed to load sidebar directory:",Ne),L(Ge=>({...Ge,[Z]:We}))}},W)},[U,r,de,f]),ge=c.useCallback(async()=>{if(!a)return;N.current?.abort();const ye=new AbortController;N.current=ye,U.clear();try{const W=(an.getState().byRoot[a]?.expandedPaths??[]).map(E=>fs(E)).filter(E=>!!E&&E!==a&&E.startsWith(`${a}/`)),Z=[a,...W];F.current=new Set(F.current);for(const E of Z)F.current.delete(E);L(E=>{if(Object.keys(E).length===0)return E;const V={...E};let Ne=!1;for(const We of Z)We in V&&(delete V[We],Ne=!0);return Ne?V:E});const ve=()=>ye.signal.aborted;await fe(a,ve);for(let E=0;E<W.length&&!ye.signal.aborted;E+=3){const V=W.slice(E,E+3);await Promise.all(V.map(Ne=>fe(Ne,ve)))}}catch(z){if(ye.signal.aborted)return;console.error("Failed to refresh sidebar tree:",z)}finally{N.current===ye&&(N.current=null)}},[U,fe,a]),B=c.useCallback(async ye=>{if(!ye){await ge();return}const z=fs(ye);F.current=new Set(F.current),F.current.delete(z),await fe(z,void 0,!0)},[fe,ge]);c.useEffect(()=>{a&&(N.current?.abort(),F.current=new Set,U.clear(),L({}),O(ye=>Object.keys(ye).length===0?ye:{}),fe(a))},[U,fe,a,u,f]),c.useEffect(()=>{if(!t||!a||I.length===0)return;const ye=I.map(Z=>fs(Z)).filter(Z=>!!Z&&Z!==a&&Z.startsWith(`${a}/`)&&!F.current.has(Z)&&!U.has(Z)).sort((Z,ve)=>Z.split("/").length-ve.split("/").length);if(ye.length===0)return;let z=!1;const W=()=>z;return(async()=>{for(let Z=0;Z<ye.length&&!z;Z+=3){const ve=ye.slice(Z,Z+3);await Promise.all(ve.map(E=>fe(E,W)))}})(),()=>{z=!0}},[U,I,fe,a,t]);const Q=c.useRef(t);c.useEffect(()=>{const ye=t&&!Q.current;Q.current=t,ye&&ge()},[ge,t]);const ke=c.useCallback(({directories:ye})=>{if(!a)return;const z=new Set((an.getState().byRoot[a]?.expandedPaths??[]).map(We=>fs(We))),W=a==="/"?"/":`${a}/`,Z=We=>{for(let Ge=We;Ge!==a;Ge=ca(Ge))if(!Ge.startsWith(W)||!z.has(Ge))return!1;return!0},ve=We=>{for(let Ge=We;Ge===a||Ge.startsWith(W);Ge=ca(Ge)){if(F.current.has(Ge))return Ge;if(Ge===a)break}return null},E=new Set,V=new Set;for(const We of ye??F.current){const Ge=ve(fs(We));Ge&&(Z(Ge)?E:V).add(Ge)}V.size>0&&(F.current=new Set([...F.current].filter(We=>!V.has(We))));const Ne=[...E].filter(We=>(D.current.get(We)??0)<=Gh);(async()=>{for(let We=0;We<Ne.length;We+=3)await Promise.all(Ne.slice(We,We+3).map(Ge=>fe(Ge,void 0,!0)))})()},[fe,a]);qh({root:a,active:t,whileInactive:"drop",onChanges:ke}),c.useEffect(()=>{if(!t)return;if(!l){y([]),j(!1);return}const ye=S.trim();if(!ye){y([]),j(!1);return}let z=!1;return j(!0),m(l,ye,150,{includeHidden:u,respectGitignore:!f,type:"file"}).then(W=>{if(z)return;const ve=W.filter(E=>f||!yw(E.path)).map(E=>({name:E.name,path:fs(E.path),type:"file",extension:E.extension,relativePath:E.relativePath}));y(ve)}).catch(()=>{z||y([])}).finally(()=>{z||j(!1)}),()=>{z=!0}},[l,S,m,u,f,t]);const Ie=c.useMemo(()=>{const ye=new Map;if(!b?.files)return ye;for(const z of b.files)z.index==="A"||z.working_dir==="?"?ye.set(z.path,"git-added"):z.index==="D"?ye.set(z.path,"git-deleted"):(z.index==="M"||z.working_dir==="M")&&ye.set(z.path,"git-modified");return ye},[b]),oe=c.useMemo(()=>{const ye=new Map;if(!b?.files||!a)return ye;for(const z of b.files){const W=z.index==="M"||z.working_dir==="M",Z=z.index==="A"||z.working_dir==="?";if(!W&&!Z)continue;const ve=z.path.split("/");if(ve.length<=1)continue;let E=a;for(let V=0;V<ve.length-1;V++){E=`${E}/${ve[V]}`;let Ne=ye.get(E);Ne||(Ne={modified:0,added:0},ye.set(E,Ne)),W&&Ne.modified++,Z&&Ne.added++}}return ye},[b,a]),$e=c.useCallback(ye=>{if(Ae.has(ye))return"open";if(Ie.size===0)return null;const z=ye.startsWith(a+"/")?ye.slice(a.length+1):ye;return Ie.get(z)??null},[Ae,Ie,a]),Fe=c.useCallback(ye=>{if(oe.size===0)return null;const z=oe.get(ye);return z&&z.modified+z.added>0?z:null},[oe]),Ce=c.useCallback(async(ye,z)=>{if(!a)return;const W=await Lf(r,ye.path,{directory:a});if(!W.ok){Ke.error(_f(W.reason));return}_(a,ye.path),Se(a,ye.path),h(a,ye.path,{preview:!z?.pin&&!be.getState().isMobile})},[Se,r,h,a,_]),Ue=c.useCallback(async ye=>{const z=fs(ye);a&&(re(a,z),F.current.has(z)||await fe(z))},[fe,a,re]),{canUpload:pe,uploadingDirectory:ne,uploadFiles:Me,pickFiles:He,uploadElements:Ye}=Yh({root:a,refreshDirectory:B}),Xe=ne!==null,Je=ne??C,bt=c.useCallback((ye,z)=>{const W=fw(z);W.length!==0&&(k(null),Me(ye,W))},[Me]),et=c.useCallback(ye=>{!pe||Xe||!a||!pr(ye.dataTransfer)||(ye.preventDefault(),ye.dataTransfer.dropEffect="copy",k(a))},[pe,Xe,a]),lt=c.useCallback(ye=>{pr(ye.dataTransfer)&&(ye.relatedTarget instanceof Node&&ye.currentTarget.contains(ye.relatedTarget)||k(null))},[]),xt=c.useCallback(ye=>{!pe||Xe||!a||!pr(ye.dataTransfer)||(ye.preventDefault(),bt(a,ye.dataTransfer))},[pe,bt,Xe,a]),wt=c.useCallback(async ye=>{if(ye?.preventDefault(),!X||!K)return;ue(!0);const z=()=>ue(!1),W=()=>q(null);if(K==="createFile"){if(!he.trim()){Ke.error(s("sidebarFilesTree.toast.filenameRequired")),z();return}if(!r.writeFile){Ke.error(s("sidebarFilesTree.toast.writeNotSupported")),z();return}const Z=X.path,ve=Z?`${Z}/`:"",E=fs(`${ve}${he.trim()}`);await r.writeFile(E,"").then(async V=>{V.success&&(Ke.success(s("sidebarFilesTree.toast.fileCreated")),await B(Z)),W()}).catch(()=>Ke.error(s("sidebarFilesTree.toast.operationFailed"))).finally(z);return}if(K==="createFolder"){if(!he.trim()){Ke.error(s("sidebarFilesTree.toast.folderNameRequired")),z();return}const Z=X.path,ve=Z?`${Z}/`:"",E=fs(`${ve}${he.trim()}`);await r.createDirectory(E).then(async V=>{V.success&&(Ke.success(s("sidebarFilesTree.toast.folderCreated")),await B(Z)),W()}).catch(()=>Ke.error(s("sidebarFilesTree.toast.operationFailed"))).finally(z);return}if(K==="rename"){if(!he.trim()){Ke.error(s("sidebarFilesTree.toast.nameRequired")),z();return}if(!r.rename){Ke.error(s("sidebarFilesTree.toast.renameNotSupported")),z();return}const Z=X.path,ve=Z.split("/").slice(0,-1).join("/"),E=ve?`${ve}/`:"",V=fs(`${E}${he.trim()}`);await r.rename(Z,V).then(async Ne=>{Ne.success&&(Ke.success(s("sidebarFilesTree.toast.renamedSuccessfully")),await B(ve),a&&J(a,Z),(P===Z||P&&P.startsWith(`${Z}/`))&&_(a,null)),W()}).catch(()=>Ke.error(s("sidebarFilesTree.toast.operationFailed"))).finally(z);return}if(K==="delete"){if(!r.delete){Ke.error(s("sidebarFilesTree.toast.deleteNotSupported")),z();return}const Z=X.path,ve=Z.split("/").slice(0,-1).join("/");await r.delete(Z).then(async E=>{E.success&&(Ke.success(s("sidebarFilesTree.toast.deletedSuccessfully")),await B(ve),a&&J(a,Z),(P===Z||P&&P.startsWith(Z+"/"))&&_(a,null)),W()}).catch(()=>Ke.error(s("sidebarFilesTree.toast.operationFailed"))).finally(z);return}z()},[K,X,he,r,B,J,a,P,_,s]);function dt(ye,z){const W=T[ye]??[];return W.map((Z,ve)=>{const E=Z.type==="directory",V=E&&R.has(Z.path),Ne=P===Z.path,We=ve===W.length-1;return n.jsxs("li",{className:"relative","data-file-tree-path":E?void 0:Z.path,children:[z>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),We&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),n.jsx(kw,{node:Z,root:a,isExpanded:V,isActive:Ne,isBrowserClient:i,status:E?void 0:$e(Z.path),badge:E?Fe(Z.path):void 0,isDropTarget:E&&Je===Z.path,canUpload:pe&&!Xe,permissions:Te,downloadFile:r.downloadFile,onSelect:Ce,onToggle:Ue,onRevealPath:De,onOpenDialog:te,onSetDropTarget:k,onDropFiles:bt,onPickFiles:He}),E&&V&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[M[Z.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:M[Z.path],children:M[Z.path]}),n.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{B(Z.path)},children:[n.jsx($,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):null,dt(Z.path,z+1)]})]},Z.path)})}c.useEffect(()=>{const ye=ae.current,z=G.current;if(!ye||!z)return;const W=z.querySelector(`[data-file-tree-path="${CSS.escape(ye)}"]`);!W||W.offsetParent===null||(ae.current=null,W.scrollIntoView({block:"nearest"}))});const It=!!(a&&T[a]),_t=a?M[a]:null,Bt=Je?mw(a,Je):"";return n.jsxs("section",{ref:G,className:"flex h-full min-h-0 flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[we&&n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>te("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.newFileTitle"),"aria-label":s("sidebarFilesTree.actions.newFileTitle"),children:n.jsx($,{name:"file-add",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.newFileTitle")})]}),ce&&n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>te("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.newFolderTitle"),"aria-label":s("sidebarFilesTree.actions.newFolderTitle"),children:n.jsx($,{name:"folder-add",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.newFolderTitle")})]}),pe&&n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>He(a),disabled:!a||Xe,className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":s("sidebarFilesTree.actions.uploadFilesTitle"),children:n.jsx($,{name:"upload-2",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.uploadFilesTitle")})]}),n.jsx(A1,{className:"h-8 w-8"}),n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>{ge()},className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.refreshTitle"),"aria-label":s("sidebarFilesTree.actions.refreshTitle"),children:n.jsx($,{name:"refresh",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.refreshTitle")})]}),n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>{a&&ie(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:s("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":s("sidebarFilesTree.actions.collapseAllTitle"),children:n.jsx($,{name:"collapse-vertical",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:6,children:s("sidebarFilesTree.actions.collapseAllTitle")})]})]}),n.jsxs("div",{className:"relative min-w-0",children:[n.jsx($,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),n.jsx(Po,{ref:x,value:g,onChange:ye=>w(ye.target.value),placeholder:s("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),g.trim().length>0?n.jsx("button",{type:"button","aria-label":s("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{w(""),x.current?.focus()},children:n.jsx($,{name:"close",className:"h-4 w-4"})}):null]})]}),n.jsxs("div",{className:"relative flex-1 min-h-0",children:[n.jsx(Cn,{outerClassName:"h-full min-h-0",className:xe("p-2",Je===a&&"bg-interactive-selection/10"),onDragEnter:et,onDragOver:et,onDragLeave:lt,onDrop:xt,children:n.jsx("ul",{className:"flex flex-col",children:v?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx($,{name:"loader-4",className:"h-4 w-4 animate-spin"}),s("sidebarFilesTree.state.searching")]}):p.length>0?p.map(ye=>{const z=P===ye.path;return n.jsx("li",{"data-file-tree-path":ye.path,children:n.jsxs("button",{type:"button",onClick:()=>Ce(ye),onDoubleClick:()=>Ce(ye,{pin:!0}),draggable:!0,onDragStart:W=>{$f(W);const Z=ye.relativePath||rl(a??"",ye.path);!Z||Z==="."||(W.dataTransfer.setData("application/x-openchamber-file-path",Z),W.dataTransfer.effectAllowed="copy")},onDragEnd:W=>{Wf(W)&&Ce(ye)},className:xe("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",z?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:ye.path,children:[Kf(ye.path,ye.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:`‎${ye.relativePath??ye.path}‎`})]})},ye.path)}):_t?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{children:_t}),n.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ge()},children:[n.jsx($,{name:"refresh",className:"h-3.5 w-3.5"}),s("sidebarFilesTree.actions.refreshTitle")]})]}):It&&a?dt(a,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:s("sidebarFilesTree.state.loading")})})}),Je?n.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[n.jsx($,{name:Xe?"loader-4":"folder-received",className:xe("size-4 flex-shrink-0",Xe&&"animate-spin")}),n.jsx("span",{className:"min-w-0 truncate typography-meta",title:Bt,children:s(Xe?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Bt})})]}):null]}),Ye,n.jsx(_s,{open:!!K,onOpenChange:ye=>!ye&&q(null),children:n.jsxs(Ls,{children:[n.jsxs(Zs,{children:[n.jsxs(Xs,{children:[K==="createFile"&&s("sidebarFilesTree.dialog.createFile.title"),K==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.title"),K==="rename"&&s("sidebarFilesTree.dialog.rename.title"),K==="delete"&&s("sidebarFilesTree.dialog.delete.title")]}),n.jsxs(Js,{children:[K==="createFile"&&s("sidebarFilesTree.dialog.createFile.description",{path:X?.path??s("sidebarFilesTree.dialog.rootFallback")}),K==="createFolder"&&s("sidebarFilesTree.dialog.createFolder.description",{path:X?.path??s("sidebarFilesTree.dialog.rootFallback")}),K==="rename"&&s("sidebarFilesTree.dialog.rename.description",{name:X?.name??""}),K==="delete"&&s("sidebarFilesTree.dialog.delete.description",{name:X?.name??""})]})]}),K!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(Po,{value:he,onChange:ye=>je(ye.target.value),placeholder:s(K==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:ye=>{ye.key==="Enter"&&wt()},autoFocus:!0})}),n.jsxs(Jn,{children:[n.jsx(ft,{variant:"outline",onClick:()=>q(null),disabled:Y,children:s("sidebarFilesTree.dialog.cancel")}),n.jsx(ft,{variant:K==="delete"?"destructive":"default",onClick:()=>{wt()},disabled:Y||K!=="delete"&&!he.trim(),children:Y?n.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s(K==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function Aw(t){return t.runtimeKey}const Ec=60,Pw=t=>{try{return new URL(t).origin}catch{return""}},Ri=new Set,zf=tl()((t,e)=>({byOrigin:{},resolve:(s,r,o)=>{const i=Pw(s);!i||!r||e().byOrigin[i]||Ri.has(i)||(Ri.add(i),Nr("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<=Ec)return{byOrigin:u};for(const m of f.slice(0,f.length-Ec))delete u[m];return{byOrigin:u}})}).catch(()=>{}).finally(()=>{Ri.delete(i)}))}})),il=t=>t,da=t=>{const e=il(t).type;return typeof e=="string"?e:""},Iw=t=>{const e=il(t).tool;return typeof e=="string"?e:""},Dw=t=>{const e=il(t).text;return typeof e=="string"?e:""},Ew=t=>{const e=da(t);return e==="tool"?Iw(t).trim().toLowerCase()||"tool":e||"unknown"},Rw=t=>{if(t.length===0)return"";const e=[];for(const s of t){const r=Ew(s);e.includes(r)||e.push(r)}return e.join(" + ")},Tw=t=>t.replace(/\s+/g," ").trim(),Mw=t=>{for(const s of t)if(da(s)==="text"){const r=Tw(Dw(s));if(r.length===0)continue;return r}const e=t.filter(s=>da(s)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},Ow=(t,e,s)=>`${s(t)} / ${s(e)}`,Bw=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Fw=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const s=Bw(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}})},ua={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},vo={user:0,assistant:0,tool:0,other:0},Pn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Rc=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{...ua,total:Pn(s)};if(!s||typeof s!="object")return ua;const r=s,o=Pn(r.input),i=Pn(r.output),l=Pn(r.reasoning),a=Pn(r.cache?.read),d=Pn(r.cache?.write),u=Pn(r.total);return{input:o,output:i,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:o+i+l+a+d}},Lw=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},$s=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,s)=>e+$s(s),0):t&&typeof t=="object"?Object.values(t).reduce((e,s)=>e+$s(s),0):0,_w=(t,e)=>{const s=t,r=typeof s.type=="string"?s.type:"";if(r==="reasoning")return{...vo,assistant:$s(s.text)+$s(s.content)};const o=Lw(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:$s(s.input)+$s(s.output)+$s(s.error)+$s(s.call?.input)+$s(s.call?.output)+$s(s.call?.error)+$s(s.raw)+Math.round($s(s.metadata)*.25)+Math.round($s(s.state)*.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}},Tc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),$w=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",Ww=(t,e)=>{if(t.length===0)return{...vo};const s=t.reduce((r,o)=>{const i=$w(o);let l={...vo};for(const a of o.parts)l=Tc(l,_w(a,i));return Tc(r,l)},{...vo});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)}},Vn=t=>t.toLocaleString(Wa()),Kw=(t,e)=>!t||!Number.isFinite(t)?"-":ny(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),zw=(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}},Uw=()=>{const t=Ve.c(209),{t:e}=mt(),s=be(Hw);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[o,i]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=Ze(Vw),f=Ze(Gw),m=Hu(f??void 0),h=ey(u??"",f??void 0),b=ps(qw);let g;t[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(Yw),a(null)},t[1]=g):g=t[1];let w;t[2]!==f||t[3]!==u?(w=[f,u],t[2]=f,t[3]=u,t[4]=w):w=t[4],c.useEffect(g,w);let S,x;t[5]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},x=[],t[5]=S,t[6]=x):(S=t[5],x=t[6]),c.useEffect(S,x);let p;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=async(gt,vt)=>{(await Xn(vt)).ok?(a(gt),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(ct=>ct===gt?null:ct),d.current=null},2e3)):a(null)},t[7]=p):p=t[7];const y=p;let v;t[8]!==u||t[9]!==m?(v=u?m.find(gt=>gt.id===u)??null:null,t[8]=u,t[9]=m,t[10]=v):v=t[10];const j=v;let C,k,T,O,M,L,F;if(t[11]!==h){C=h.filter(Qw),F=h.filter(Xw);const gt=ty(h.map(Jw));T=gt?h[gt.index]??null:null,O=gt?.state==="compacted";let vt;t[19]!==T?(L=T?Rc(T):ua,vt=sy({input:L.input,cache:{read:L.cacheRead,write:L.cacheWrite}}),t[19]=T,t[20]=vt,t[21]=L):(vt=t[20],L=t[21]),k=vt,M=C.reduce(Zw,0),t[11]=h,t[12]=C,t[13]=k,t[14]=T,t[15]=O,t[16]=M,t[17]=L,t[18]=F}else C=t[12],k=t[13],T=t[14],O=t[15],M=t[16],L=t[17],F=t[18];const D=M,U=T?.info??null,N=b,A=U?.providerID||"",H=U?.modelID||"";let I;t[22]!==H||t[23]!==N||t[24]!==A?(I=zw(N,A,H),t[22]=H,t[23]=N,t[24]=A,t[25]=I):I=t[25];const R=I,P=R.contextLimit,_=O?null:P&&P>0?Math.min(999,L.total/P*100):0;let G;if(t[26]!==h){const gt=[...h].reverse().find(ej),vt=gt?.info.role==="system"?gt.info.text:"";G=Ww(h,vt),t[26]=h,t[27]=G}else G=t[27];const ae=G,Se=ae.user,J=ae.assistant,re=ae.tool,ie=Math.max(0,L.input-Se-J-re),Be=Se+J+re+ie,Ae=h[0]?.info?.time?.created,K=h.length>0?h[h.length-1]?.info?.time?.created:null;let q;t[28]!==j?.title||t[29]!==e?(q=j?.title||e("contextSidebar.session.untitled"),t[28]=j?.title,t[29]=e,t[30]=q):q=t[30];const X=j?.time?.created??Ae??null,me=K??j?.time?.created??null;let he;t[31]!==J||t[32]!==ie||t[33]!==re||t[34]!==Se?(he={user:Se,assistant:J,tool:re,other:ie},t[31]=J,t[32]=ie,t[33]=re,t[34]=Se,t[35]=he):he=t[35];let je;t[36]!==C.length||t[37]!==Be||t[38]!==k||t[39]!==P||t[40]!==R||t[41]!==h.length||t[42]!==q||t[43]!==X||t[44]!==me||t[45]!==he||t[46]!==L||t[47]!==D||t[48]!==_||t[49]!==F.length?(je={sessionTitle:q,messagesCount:h.length,userMessagesCount:F.length,assistantMessagesCount:C.length,createdAt:X,lastActivityAt:me,providerModel:R,tokenBreakdown:L,usagePercent:_,cacheHitRate:k,totalAssistantCost:D,contextLimit:P,breakdown:he,breakdownTotal:Be},t[36]=C.length,t[37]=Be,t[38]=k,t[39]=P,t[40]=R,t[41]=h.length,t[42]=q,t[43]=X,t[44]=me,t[45]=he,t[46]=L,t[47]=D,t[48]=_,t[49]=F.length,t[50]=je):je=t[50];const Y=je;if(!u){let gt;t[51]!==e?(gt=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=gt):gt=t[52];let vt;return t[53]!==gt?(vt=n.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:gt}),t[53]=gt,t[54]=vt):vt=t[54],vt}let ue;t[55]!==e?(ue=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ue):ue=t[56];let we;t[57]!==ue||t[58]!==Y.breakdown.user?(we={key:"user",label:ue,value:Y.breakdown.user,color:"var(--status-success)"},t[57]=ue,t[58]=Y.breakdown.user,t[59]=we):we=t[59];let ce;t[60]!==e?(ce=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=ce):ce=t[61];let le;t[62]!==ce||t[63]!==Y.breakdown.assistant?(le={key:"assistant",label:ce,value:Y.breakdown.assistant,color:"var(--primary-base)"},t[62]=ce,t[63]=Y.breakdown.assistant,t[64]=le):le=t[64];let Re;t[65]!==e?(Re=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=Re):Re=t[66];let Oe;t[67]!==Re||t[68]!==Y.breakdown.tool?(Oe={key:"tool",label:Re,value:Y.breakdown.tool,color:"var(--status-warning)"},t[67]=Re,t[68]=Y.breakdown.tool,t[69]=Oe):Oe=t[69];let Te;t[70]!==e?(Te=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=Te):Te=t[71];let De;t[72]!==Te||t[73]!==Y.breakdown.other?(De={key:"other",label:Te,value:Y.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=Te,t[73]=Y.breakdown.other,t[74]=De):De=t[74];let te;t[75]!==we||t[76]!==le||t[77]!==Oe||t[78]!==De?(te=[we,le,Oe,De],t[75]=we,t[76]=le,t[77]=Oe,t[78]=De,t[79]=te):te=t[79];const de=te;let fe;t[80]!==Y.sessionTitle?(fe=n.jsx("h2",{dir:"auto",className:"typography-ui-header font-semibold text-foreground truncate text-left",children:Y.sessionTitle}),t[80]=Y.sessionTitle,t[81]=fe):fe=t[81];let ge;t[82]!==Y.providerModel.modelName||t[83]!==Y.providerModel.providerName?(ge=n.jsxs("span",{children:[Y.providerModel.providerName," / ",Y.providerModel.modelName]}),t[82]=Y.providerModel.modelName,t[83]=Y.providerModel.providerName,t[84]=ge):ge=t[84];let B;t[85]!==s||t[86]!==Y.createdAt?(B=Y.createdAt&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsx("span",{children:Kw(Y.createdAt,s)})]}),t[85]=s,t[86]=Y.createdAt,t[87]=B):B=t[87];let Q;t[88]!==ge||t[89]!==B?(Q=n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[ge,B]}),t[88]=ge,t[89]=B,t[90]=Q):Q=t[90];let ke;t[91]!==fe||t[92]!==Q?(ke=n.jsxs("div",{className:"mb-6",children:[fe,Q]}),t[91]=fe,t[92]=Q,t[93]=ke):ke=t[93];let Ie;t[94]!==e?(Ie=e("contextSidebar.section.context"),t[94]=e,t[95]=Ie):Ie=t[95];let oe;t[96]!==Ie?(oe=n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ie}),t[96]=Ie,t[97]=oe):oe=t[97];let $e;t[98]!==Y.tokenBreakdown.total||t[99]!==Y.usagePercent?($e=Y.usagePercent===null?"—":Vn(Y.tokenBreakdown.total),t[98]=Y.tokenBreakdown.total,t[99]=Y.usagePercent,t[100]=$e):$e=t[100];let Fe;t[101]!==Y.contextLimit?(Fe=Y.contextLimit?` / ${Vn(Y.contextLimit)}`:"",t[101]=Y.contextLimit,t[102]=Fe):Fe=t[102];let Ce;t[103]!==$e||t[104]!==Fe?(Ce=n.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[$e,Fe]}),t[103]=$e,t[104]=Fe,t[105]=Ce):Ce=t[105];let Ue;t[106]!==oe||t[107]!==Ce?(Ue=n.jsxs("div",{className:"flex items-baseline justify-between",children:[oe,Ce]}),t[106]=oe,t[107]=Ce,t[108]=Ue):Ue=t[108];let pe;t[109]!==Y.usagePercent?(pe=Y.usagePercent!==null&&Y.usagePercent>0&&n.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,Y.usagePercent)}%`,backgroundColor:Y.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=Y.usagePercent,t[110]=pe):pe=t[110];let ne;t[111]!==pe?(ne=n.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:pe}),t[111]=pe,t[112]=ne):ne=t[112];let Me;t[113]!==e||t[114]!==Y.usagePercent?(Me=Y.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:Y.usagePercent.toFixed(1)}),t[113]=e,t[114]=Y.usagePercent,t[115]=Me):Me=t[115];let He;t[116]!==Me?(He=n.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Me}),t[116]=Me,t[117]=He):He=t[117];let Ye;t[118]!==Ue||t[119]!==ne||t[120]!==He?(Ye=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Ue,ne,He]}),t[118]=Ue,t[119]=ne,t[120]=He,t[121]=Ye):Ye=t[121];let Xe;t[122]!==e?(Xe=e("contextSidebar.stats.messages"),t[122]=e,t[123]=Xe):Xe=t[123];let Je;t[124]!==Y.messagesCount?(Je=Vn(Y.messagesCount),t[124]=Y.messagesCount,t[125]=Je):Je=t[125];let bt;t[126]!==Xe||t[127]!==Je?(bt={label:Xe,value:Je},t[126]=Xe,t[127]=Je,t[128]=bt):bt=t[128];let et;t[129]!==e?(et=e("contextSidebar.stats.user"),t[129]=e,t[130]=et):et=t[130];let lt;t[131]!==Y.userMessagesCount?(lt=Vn(Y.userMessagesCount),t[131]=Y.userMessagesCount,t[132]=lt):lt=t[132];let xt;t[133]!==et||t[134]!==lt?(xt={label:et,value:lt},t[133]=et,t[134]=lt,t[135]=xt):xt=t[135];let wt;t[136]!==e?(wt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=wt):wt=t[137];let dt;t[138]!==Y.assistantMessagesCount?(dt=Vn(Y.assistantMessagesCount),t[138]=Y.assistantMessagesCount,t[139]=dt):dt=t[139];let It;t[140]!==wt||t[141]!==dt?(It={label:wt,value:dt},t[140]=wt,t[141]=dt,t[142]=It):It=t[142];let _t;t[143]!==e?(_t=e("contextSidebar.stats.cost"),t[143]=e,t[144]=_t):_t=t[144];let Bt;t[145]!==Y.totalAssistantCost?(Bt=S1(Y.totalAssistantCost),t[145]=Y.totalAssistantCost,t[146]=Bt):Bt=t[146];let ye;t[147]!==_t||t[148]!==Bt?(ye={label:_t,value:Bt},t[147]=_t,t[148]=Bt,t[149]=ye):ye=t[149];let z;t[150]!==bt||t[151]!==xt||t[152]!==It||t[153]!==ye?(z=[bt,xt,It,ye],t[150]=bt,t[151]=xt,t[152]=It,t[153]=ye,t[154]=z):z=t[154];const W=z;let Z;t[155]!==W?(Z=n.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:W.map(tj)}),t[155]=W,t[156]=Z):Z=t[156];let ve;t[157]!==e?(ve=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=ve):ve=t[158];let E;t[159]!==ve?(E=n.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:ve}),t[159]=ve,t[160]=E):E=t[160];let V;t[161]!==e||t[162]!==Y.cacheHitRate.hasInput||t[163]!==Y.cacheHitRate.percent||t[164]!==Y.tokenBreakdown.cacheRead||t[165]!==Y.tokenBreakdown.cacheWrite||t[166]!==Y.tokenBreakdown.input||t[167]!==Y.tokenBreakdown.output||t[168]!==Y.tokenBreakdown.reasoning?(V=n.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:Y.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:Y.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:Y.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:Y.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:Y.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:Y.cacheHitRate.hasInput?Y.cacheHitRate.percent:null,format:"percent"}].map(sj)}),t[161]=e,t[162]=Y.cacheHitRate.hasInput,t[163]=Y.cacheHitRate.percent,t[164]=Y.tokenBreakdown.cacheRead,t[165]=Y.tokenBreakdown.cacheWrite,t[166]=Y.tokenBreakdown.input,t[167]=Y.tokenBreakdown.output,t[168]=Y.tokenBreakdown.reasoning,t[169]=V):V=t[169];let Ne;t[170]!==E||t[171]!==V?(Ne=n.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[E,V]}),t[170]=E,t[171]=V,t[172]=Ne):Ne=t[172];let We;t[173]!==de||t[174]!==Y.breakdownTotal?(We=n.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:de.map(gt=>gt.value<=0||Y.breakdownTotal<=0?null:n.jsx("div",{style:{width:`${gt.value/Y.breakdownTotal*100}%`,backgroundColor:gt.color}},gt.key))}),t[173]=de,t[174]=Y.breakdownTotal,t[175]=We):We=t[175];let Ge;t[176]!==de||t[177]!==Y.breakdownTotal?(Ge=n.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:de.map(gt=>{const vt=Y.breakdownTotal>0?gt.value/Y.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:gt.color}}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[gt.label," ",n.jsxs("span",{className:"tabular-nums",children:[vt.toFixed(0),"%"]})]})]},gt.key)})}),t[176]=de,t[177]=Y.breakdownTotal,t[178]=Ge):Ge=t[178];let qe;t[179]!==We||t[180]!==Ge?(qe=n.jsxs("div",{className:"mb-6",children:[We,Ge]}),t[179]=We,t[180]=Ge,t[181]=qe):qe=t[181];let Pe;t[182]!==e?(Pe=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Pe):Pe=t[183];let ze;t[184]!==Pe?(ze=n.jsx("div",{className:"typography-micro text-muted-foreground",children:Pe}),t[184]=Pe,t[185]=ze):ze=t[185];let Rt;if(t[186]!==l||t[187]!==o||t[188]!==h||t[189]!==e||t[190]!==s){let gt;t[192]!==l||t[193]!==o||t[194]!==e||t[195]!==s?(gt=vt=>{const qt=vt.info.role,ct=qt==="assistant",at=qt==="user",yt=o[vt.info.id]===!0,$t=l===vt.info.id,ls=vt.info.time?.created??null,jt=Rw(vt.parts),kt=ct?Rc({info:vt.info,parts:vt.parts}):null,Vt=at?Mw(vt.parts):"",es=Fw(ls,s),Is=jt||"—",Ds=kt?Ow(kt.input,kt.output,Vn):"",ts=qt||"unknown",Le=jt?`${ts}: ${jt}`:ts,nt=yt?JSON.stringify({info:vt.info,parts:vt.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-left hover:bg-[var(--interactive-hover)]","aria-expanded":yt,onClick:()=>{i(it=>({...it,[vt.info.id]:it[vt.info.id]!==!0}))},children:n.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:ct?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[at?n.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[n.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Vt]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:ct?Is:Le}),ct&&n.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Ds})]}),n.jsx("span",{className:"text-right text-muted-foreground",children:es})]})}),yt&&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 right-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(),y(vt.info.id,nt)},"aria-label":e($t?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e($t?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:$t?n.jsx($,{name:"check",className:"size-3.5"}):n.jsx($,{name:"file-copy",className:"size-3.5"})})}),n.jsx(ry,{language:"json",code:nt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},vt.info.id)},t[192]=l,t[193]=o,t[194]=e,t[195]=s,t[196]=gt):gt=t[196],Rt=[...h].reverse().map(gt),t[186]=l,t[187]=o,t[188]=h,t[189]=e,t[190]=s,t[191]=Rt}else Rt=t[191];let zt;t[197]!==Rt?(zt=n.jsx("div",{className:"mt-2.5 space-y-1",children:Rt}),t[197]=Rt,t[198]=zt):zt=t[198];let Tt;t[199]!==ze||t[200]!==zt?(Tt=n.jsxs("div",{children:[ze,zt]}),t[199]=ze,t[200]=zt,t[201]=Tt):Tt=t[201];let Ft;return t[202]!==ke||t[203]!==Ye||t[204]!==Z||t[205]!==Ne||t[206]!==qe||t[207]!==Tt?(Ft=n.jsx(Cn,{outerClassName:"h-full",className:"bg-background",children:n.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[ke,Ye,Z,Ne,qe,Tt]})}),t[202]=ke,t[203]=Ye,t[204]=Z,t[205]=Ne,t[206]=qe,t[207]=Tt,t[208]=Ft):Ft=t[208],Ft};function Hw(t){return t.timeFormatPreference}function Vw(t){return t.currentSessionId}function Gw(t){return t.currentSessionDirectory}function qw(t){return t.providers}function Yw(t){return Object.keys(t).length>0?{}:t}function Qw(t){return t.info.role==="assistant"}function Xw(t){return t.info.role==="user"}function Jw(t){return t.info}function Zw(t,e){const s=Pn(e.info.cost);return t+s}function ej(t){return t.info.role==="system"}function tj(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 sj(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)}%`:Vn(t.value):"—"})]},t.label)}const nj=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"},rj=async(t,e)=>{try{const s=await Fs("/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(nj)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},oj=async t=>{try{const e=await Fs("/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}},ij=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}},aj=({announced:t,discovered:e})=>{const s=new Map;for(const r of t){const o=ij(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)},fa="__openchamberBrowserAnnotationActive",lj=`(() => {
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['${fa}']; } catch (error) { /* non-configurable */ }
12
+ })();`,cj=(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['${fa}'] = 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['${fa}']; } 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
+ });`},dj={kind:"idle"},un=t=>typeof t=="object"&&t!==null,yn=t=>typeof t=="number"&&Number.isFinite(t),Mc=t=>un(t)&&Object.values(t).every(e=>typeof e=="string"),al=t=>un(t)&&yn(t.x)&&yn(t.y)&&yn(t.width)&&yn(t.height),Uf=t=>un(t)&&yn(t.x)&&yn(t.y),uj=t=>un(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"),fj=t=>un(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&al(t.bounds)&&Uf(t.center)&&Mc(t.attributes)&&Mc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(uj),pj=t=>un(t)&&typeof t.id=="string"&&fj(t.element),mj=t=>un(t)&&typeof t.id=="string"&&al(t.rect),hj=t=>un(t)&&typeof t.id=="string"&&al(t.bounds)&&Array.isArray(t.points)&&t.points.every(Uf),gj=t=>un(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&un(t.viewport)&&yn(t.viewport.width)&&yn(t.viewport.height)&&yn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(pj)&&Array.isArray(t.regions)&&t.regions.every(mj)&&Array.isArray(t.strokes)&&t.strokes.every(hj),bj=1600,yj=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}),xj=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 yj(`data:${e};base64,${t}`),f=Math.max(1,u.naturalWidth||s),m=Math.max(1,u.naturalHeight||r),h=f/Math.max(1,o||f),b=m/Math.max(1,i||m),g=Math.min(1,bj/f),w=document.createElement("canvas");w.width=Math.max(1,Math.floor(f*g)),w.height=Math.max(1,Math.floor(m*g));const S=w.getContext("2d");if(!S)return null;S.scale(g,g),S.drawImage(u,0,0,f,m);const x=j=>({x:j.x*h,y:j.y*b,width:j.width*h,height:j.height*b}),p=Math.max(2,2.5*h/Math.max(g,.2));S.strokeStyle=a,S.fillStyle=d;const y=j=>{const C=x(j);S.lineWidth=p,S.fillRect(C.x,C.y,C.width,C.height),S.strokeRect(C.x,C.y,C.width,C.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||(S.beginPath(),j.points.forEach((C,k)=>{const T=C.x*h,O=C.y*b;k===0?S.moveTo(T,O):S.lineTo(T,O)}),S.lineCap="round",S.lineJoin="round",S.lineWidth=p*1.4,S.stroke());const v=await new Promise(j=>w.toBlob(j,"image/jpeg",.85));return v?new File([v],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},vj="({ width: window.innerWidth, height: window.innerHeight })",Sj=async t=>{try{const e=await t.executeJavaScript(vj,!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}},So=async t=>{try{await t.executeJavaScript(lj,!1)}catch{}},wj=async({host:t,theme:e,labels:s})=>{const r=cj(e,s),o=await t.executeJavaScript(r,!0);if(o==null)return null;if(!gj(o))return await So(t),null;const i=o;try{const l=await Sj(t)??i.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:i,screenshot:null};const d=await xj({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}}},Hs={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)"},jj=()=>{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()}},kj=t=>{const e=jj();if(!e)return{...Hs,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)`)||Hs.glassSurface,glassFilter:`blur(${i}) saturate(${l})`,primary:s("--primary",Hs.primary),primarySoft:r("--primary",16,Hs.primarySoft),primaryFaint:r("--primary",10,Hs.primaryFaint),primaryContrast:s("--primary-foreground",Hs.primaryContrast),surface:s("--surface-background",Hs.surface),surfaceElevated:s("--surface-elevated",Hs.surfaceElevated),border:s("--border",Hs.border),text:s("--foreground",Hs.text),mutedText:s("--muted-foreground",Hs.mutedText)}}catch{return{...Hs,colorScheme:t}}finally{e.dispose()}},Cj=2e3,Nj=50,Aj=400,Ys=new Map,Sn=new Map;let wo=null,Mn=null,Rr=null;const pa=async t=>{try{const e=await Fs("/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}},Pj=async(t,e)=>{try{const s=await Fs("/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)}},Hf=async(t,e=Cj)=>{const s=Date.now()+e;for(;!Ys.has(t)&&Date.now()<s;)await new Promise(r=>setTimeout(r,Nj));return Ys.get(t)??null},ma=t=>Ys.has(t)||Sn.has(t),Oc=t=>{let e=null;for(const s of t.keys())e=s;return e},Vf=()=>wo&&ma(wo)?wo:Oc(Ys)??Oc(Sn),Gf=async t=>{const e=Ys.get(t);if(e)return e;const s=Sn.get(t);return s?(s.wake(),Hf(t)):null},Ij=()=>{const t=Vf();return[...Ys.values(),...[...Sn.values()].filter(s=>!Ys.has(s.tabId))].map(s=>{let r={title:"",url:""};try{r=s.describe()}catch{}return{id:s.tabId,title:r.title,url:r.url,active:s.tabId===t}})},qf=t=>`The browser tab ${t} could not be loaded. Try again, or open the page in a new tab with browser.open.`,Dj=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use the tab the user is looking at.`,gn=(t,e)=>Pj(t.requestId,t.action==="browser.open"&&e.ok?{...e,data:Object.assign({},e.data,{drivable:oy()})}:e),Ej=async t=>{const e=t.action==="browser.open",{tabId:s,...r}=t.parameters,o=s===void 0?null:String(s);if(o!==null){if(!ma(o)){if(Ys.size===0&&Sn.size===0&&!Mn)return;if(await new Promise(l=>setTimeout(l,Aj)),ma(o)){await Bc(t,o,r);return}if(!await pa(t.requestId))return;await gn(t,{ok:!1,error:Dj(o)});return}await Bc(t,o,r);return}const i=Vf();if(!(!i&&!(e&&Mn))&&await pa(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await gn(t,{ok:!1,error:"url is required"});return}const a=e&&Mn?Mn(l):null;if(e&&!a&&!i){await gn(t,{ok:!1,error:"There is no browser here to open the page in."});return}if(a){const u=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!u||u==="fill"){await gn(t,{ok:!0,data:{url:l,opened:!0,tabId:a}});return}const f=await Hf(a);if(!f){await gn(t,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const m=await f.run("browser.resize",{viewport:u}),h=m&&typeof m=="object"?m.viewport??null:null;await gn(t,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!0,viewport:h}});return}const d=await Gf(i);await gn(t,d?await Yf(d,t.action,r):{ok:!1,error:qf(i)})}catch(l){await gn(t,{ok:!1,error:l instanceof Error?l.message:String(l)})}},Bc=async(t,e,s)=>{if(!await pa(t.requestId))return;const r=await Gf(e);await gn(t,r?await Yf(r,t.action,s):{ok:!1,error:qf(e)})},Yf=async(t,e,s)=>{try{const r=await t.run(e,s);return e==="browser.snapshot"&&Object(r)===r?{ok:!0,data:{...Object(r),tabs:Ij()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},ll=()=>{Rr||(Rr=_n(t=>{t.type==="browser-control-request"&&Ej({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},cl=()=>{Ys.size>0||Sn.size>0||Mn||!Rr||(Rr(),Rr=null)},Rj=t=>(Ys.set(t.tabId,t),ll(),()=>{Ys.get(t.tabId)===t&&Ys.delete(t.tabId),cl()}),Tj=t=>(Sn.set(t.tabId,t),ll(),()=>{Sn.get(t.tabId)===t&&Sn.delete(t.tabId),cl()}),Mj=t=>{wo=t},Oj=t=>(Mn=t,ll(),()=>{Mn===t&&(Mn=null),cl()}),Bj=50,Fj=6,Lj=2048,_j=200,Qf=t=>{const e=fr(String(t??"").trim());if(!e||e.length>Lj)return"";try{const s=new URL(e);return s.protocol!=="http:"&&s.protocol!=="https:"?"":s.toString()}catch{return""}},$j=(t,e)=>{const s=Qf(e.url);if(!s)return t;const r=t.find(l=>l.url===s),o=String(e.title??"").trim().slice(0,_j)||r?.title||"";return[{url:s,title:o,lastVisitedAt:e.at},...t.filter(l=>l.url!==s)].slice(0,Bj)},Wj=(t,e)=>{const s=Qf(e);return t.filter(r=>r.url!==s)},Kj=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Xf=(t,e,s=Fj)=>{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=Kj(l);return l.url===r||a===i?!1:a.includes(i)}).slice(0,s)},Fc=20,jo=t=>{const e=ot((t||"").trim());return e?JSON.stringify([Jt(),e]):""},zj=t=>{const e=Object.keys(t);if(e.length<=Fc)return t;const s=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,o)=>o[1]-r[1]).slice(0,Fc);return Object.fromEntries(s.map(([r])=>[r,t[r]??[]]))},mr=tl()(B1(t=>({byProject:{},recordVisit:(e,s)=>{const r=jo(e);r&&t(o=>{const i=o.byProject[r]??[],l=$j(i,{...s,at:Date.now()});return l===i?o:{byProject:zj({...o.byProject,[r]:l})}})},forget:(e,s)=>{const r=jo(e);r&&t(o=>{const i=o.byProject[r];return i?{byProject:{...o.byProject,[r]:Wj(i,s)}}:o})},clear:e=>{const s=jo(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:Om(),partialize:t=>({byProject:t.byProject})})),Uj=[],Jf=t=>e=>{const s=jo(t);return(s?e.byProject[s]:void 0)??Uj},dl=t=>{const e=Ve.c(9),{t:s}=mt();let r;e[0]!==t?(r=rn(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=ur(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.placeId||e[7]!==s?(a=l.placeId==="docker"?s("spaces.create.place.localDocker"):l.placeId,e[6]=l.placeId,e[7]=s,e[8]=a):a=e[8];const d=a;return`${l.name} · ${d}`},Lc=6e3,Hj=120,Vj=80,Gj=`
681
+ var MAX_ELEMENTS = ${Hj};
682
+ var MAX_LABEL_CHARS = ${Vj};
683
+ var visible = function (element) {
684
+ var rect = element.getBoundingClientRect();
685
+ if (rect.width < 1 || rect.height < 1) return false;
686
+ var style = window.getComputedStyle(element);
687
+ return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
688
+ };
689
+ var label = function (element) {
690
+ var aria = element.getAttribute('aria-label');
691
+ if (aria) return aria.trim();
692
+ var value = element.getAttribute('value');
693
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
694
+ if (text) return text.slice(0, MAX_LABEL_CHARS);
695
+ if (value) return String(value).slice(0, MAX_LABEL_CHARS);
696
+ var placeholder = element.getAttribute('placeholder');
697
+ return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
698
+ };
699
+ var isUnique = function (selector) {
700
+ try {
701
+ return document.querySelectorAll(selector).length === 1;
702
+ } catch (error) {
703
+ return false;
704
+ }
705
+ };
706
+
707
+ /**
708
+ * Names an element by what it is, falling back to where it sits.
709
+ *
710
+ * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
711
+ * only until the markup shifts, and says nothing about what it points at.
712
+ * Anything the page states about identity — an id, a test id, an accessible
713
+ * name — outlives edits and reads as the thing it selects. The chain remains
714
+ * as the last resort, because something always has to work.
715
+ */
716
+ var cssPath = function (element) {
717
+ var tag = element.tagName.toLowerCase();
718
+
719
+ if (element.id) {
720
+ var byId = '#' + CSS.escape(element.id);
721
+ if (isUnique(byId)) return byId;
722
+ }
723
+ var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
724
+ for (var a = 0; a < stableAttrs.length; a += 1) {
725
+ var value = element.getAttribute(stableAttrs[a]);
726
+ if (!value) continue;
727
+ var raw = String(value);
728
+ // A value containing a quote would need escaping for no real gain: such
729
+ // attributes are rare, and the positional chain still covers them.
730
+ if (raw.indexOf('"') !== -1) continue;
731
+ var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
732
+ if (isUnique(byAttr)) return byAttr;
733
+ }
734
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
735
+ if (className) {
736
+ var classes = className.split(/\\s+/).filter(Boolean);
737
+ for (var c = 0; c < classes.length; c += 1) {
738
+ var byClass = tag + '.' + CSS.escape(classes[c]);
739
+ if (isUnique(byClass)) return byClass;
740
+ }
741
+ }
742
+
743
+ var parts = [];
744
+ var node = element;
745
+ var depth = 0;
746
+ while (node && node.nodeType === 1 && depth < 6) {
747
+ var part = node.tagName.toLowerCase();
748
+ var parent = node.parentElement;
749
+ if (!parent) { parts.unshift(part); break; }
750
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
751
+ return child.tagName === node.tagName;
752
+ });
753
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
754
+ parts.unshift(part);
755
+ if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
756
+ node = parent;
757
+ depth += 1;
758
+ }
759
+ return parts.join(' > ');
760
+ };
761
+
762
+ /** What a screen reader would announce, or '' when there is nothing to say. */
763
+ var accessibleName = function (element) {
764
+ var aria = element.getAttribute('aria-label');
765
+ if (aria && aria.trim()) return aria.trim();
766
+ var labelled = element.getAttribute('aria-labelledby');
767
+ if (labelled) {
768
+ var source = document.getElementById(labelled.split(/\\s+/)[0]);
769
+ if (source && (source.innerText || '').trim()) return source.innerText.trim();
770
+ }
771
+ var title = element.getAttribute('title');
772
+ if (title && title.trim()) return title.trim();
773
+ var alt = element.getAttribute('alt');
774
+ if (alt && alt.trim()) return alt.trim();
775
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
776
+ if (text) return text;
777
+ var value = element.getAttribute('value');
778
+ return value && String(value).trim() ? String(value).trim() : '';
779
+ };
780
+ var findByText = function (needle) {
781
+ var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
782
+ var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
783
+ var exact = null;
784
+ var partial = null;
785
+ for (var i = 0; i < candidates.length; i += 1) {
786
+ var element = candidates[i];
787
+ if (!visible(element)) continue;
788
+ var text = label(element).toLowerCase();
789
+ if (!text) continue;
790
+ if (text === wanted) { exact = element; break; }
791
+ if (!partial && text.indexOf(wanted) !== -1) partial = element;
792
+ }
793
+ return exact || partial;
794
+ };
795
+ `,Hr=t=>`(() => {
796
+ ${Gj}
797
+ ${t}
798
+ })()`,qj=({selector:t}={})=>Hr(`
799
+ var scopeSelector = ${JSON.stringify(t??"")};
800
+ var root = document;
801
+ if (scopeSelector) {
802
+ try { root = document.querySelector(scopeSelector); }
803
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
804
+ if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
805
+ }
806
+ var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
807
+ var elements = [];
808
+ var visibleTotal = 0;
809
+ for (var i = 0; i < interactive.length; i += 1) {
810
+ var element = interactive[i];
811
+ if (!visible(element)) continue;
812
+ visibleTotal += 1;
813
+ if (elements.length >= MAX_ELEMENTS) continue;
814
+
815
+ var rect = element.getBoundingClientRect();
816
+ // Empty and default-valued fields are left out rather than serialized as
817
+ // "" and false. Repeated across a hundred entries that overhead dwarfed
818
+ // the information it carried.
819
+ var entry = {
820
+ selector: cssPath(element),
821
+ tag: element.tagName.toLowerCase(),
822
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
823
+ };
824
+ // The list covers the whole document so anything can be clicked without
825
+ // scrolling to it first, which means bounds alone do not say what is on
826
+ // screen — a negative y reads as a bug otherwise.
827
+ if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
828
+ var type = element.getAttribute('type');
829
+ if (type) entry.type = type;
830
+ var role = element.getAttribute('role');
831
+ if (role) entry.role = role;
832
+ var labelText = label(element);
833
+ if (labelText) entry.label = labelText;
834
+ if (element.disabled === true) entry.disabled = true;
835
+ // Flagged rather than described: reporting the accessible name of every
836
+ // element would cost more than it tells, while its absence on something
837
+ // clickable is a defect worth naming.
838
+ if (!accessibleName(element)) entry.missingAccessibleName = true;
839
+ elements.push(entry);
840
+ }
841
+ var body = document.body ? (document.body.innerText || '') : '';
842
+ var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
843
+ var docEl = document.documentElement;
844
+ var result = {
845
+ ok: true,
846
+ url: String(location.href),
847
+ title: String(document.title || ''),
848
+ scope: scopeSelector || 'document',
849
+ scrollY: Math.round(window.scrollY),
850
+ maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
851
+ text: text.slice(0, ${Lc}),
852
+ elements: elements
853
+ };
854
+ // State what was dropped. A capped list that reports only its own length
855
+ // reads as the whole page, and the agent acts as if it had seen everything.
856
+ if (text.length > ${Lc}) {
857
+ result.textTruncated = true;
858
+ result.textTotalChars = text.length;
859
+ }
860
+ if (visibleTotal > elements.length) {
861
+ result.elementsTruncated = true;
862
+ result.interactiveElementsOnPage = visibleTotal;
863
+ }
864
+ return result;
865
+ `),Yj=({selector:t,text:e})=>Hr(`
866
+ var selector = ${JSON.stringify(t??"")};
867
+ var text = ${JSON.stringify(e??"")};
868
+ var target = null;
869
+ if (selector) {
870
+ try { target = document.querySelector(selector); }
871
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
872
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
873
+ } else {
874
+ target = findByText(text);
875
+ if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
876
+ }
877
+ if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
878
+ target.scrollIntoView({ block: 'center', inline: 'center' });
879
+ target.click();
880
+ return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
881
+ `),Qj=({selector:t,value:e,submit:s})=>Hr(`
882
+ var selector = ${JSON.stringify(t)};
883
+ var value = ${JSON.stringify(e)};
884
+ var target = null;
885
+ try { target = document.querySelector(selector); }
886
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
887
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
888
+
889
+ var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
890
+ if (!editable) return { ok: false, error: selector + ' is not a text field' };
891
+ if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
892
+
893
+ target.scrollIntoView({ block: 'center' });
894
+ target.focus();
895
+ if (target.isContentEditable) {
896
+ target.textContent = value;
897
+ } else {
898
+ // Frameworks track the value through the native setter; assigning the
899
+ // property directly leaves React and friends unaware of the change.
900
+ var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
901
+ var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
902
+ if (setter && setter.set) setter.set.call(target, value);
903
+ else target.value = value;
904
+ }
905
+ target.dispatchEvent(new Event('input', { bubbles: true }));
906
+ target.dispatchEvent(new Event('change', { bubbles: true }));
907
+
908
+ if (${s?"true":"false"}) {
909
+ var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
910
+ target.dispatchEvent(new KeyboardEvent('keydown', enter));
911
+ target.dispatchEvent(new KeyboardEvent('keyup', enter));
912
+ var form = target.form;
913
+ if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
914
+ }
915
+ return { ok: true, selector: cssPath(target), url: String(location.href) };
916
+ `),Xj=({selector:t,direction:e})=>Hr(`
917
+ var selector = ${JSON.stringify(t??"")};
918
+ var direction = ${JSON.stringify(e??"")};
919
+
920
+ var settle = function (extra) {
921
+ return new Promise(function (resolve) {
922
+ requestAnimationFrame(function () {
923
+ requestAnimationFrame(function () {
924
+ var doc = document.documentElement;
925
+ var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
926
+ var scrollY = Math.round(window.scrollY);
927
+ var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
928
+ result.atTop = scrollY <= 1;
929
+ result.atBottom = scrollY >= maxScrollY - 1;
930
+ for (var key in extra) {
931
+ if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
932
+ }
933
+ resolve(result);
934
+ });
935
+ });
936
+ });
937
+ };
938
+
939
+ if (selector) {
940
+ var target = null;
941
+ try { target = document.querySelector(selector); }
942
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
943
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
944
+ // Instant on purpose: the page's own smooth scrolling would still be
945
+ // animating when the next action runs against it.
946
+ target.scrollIntoView({ block: 'center', behavior: 'instant' });
947
+ return settle({ scrolledTo: cssPath(target) });
948
+ }
949
+
950
+ var doc = document.documentElement;
951
+ var page = Math.round(window.innerHeight * 0.85);
952
+ var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
953
+ if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
954
+ else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
955
+ else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
956
+ else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
957
+ else return { ok: false, error: 'Unknown scroll direction: ' + direction };
958
+ return settle({ direction: direction });
959
+ `),Jj=["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"],Zj=({selector:t})=>Hr(`
960
+ var selector = ${JSON.stringify(t)};
961
+ var target = null;
962
+ try { target = document.querySelector(selector); }
963
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
964
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
965
+
966
+ var computed = window.getComputedStyle(target);
967
+ var styles = {};
968
+ var props = ${JSON.stringify(Jj)};
969
+ for (var i = 0; i < props.length; i += 1) {
970
+ var value = computed.getPropertyValue(props[i]);
971
+ if (value) styles[props[i]] = String(value).trim();
972
+ }
973
+
974
+ var rect = target.getBoundingClientRect();
975
+ return {
976
+ ok: true,
977
+ selector: cssPath(target),
978
+ tag: target.tagName.toLowerCase(),
979
+ label: label(target),
980
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
981
+ inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
982
+ styles: styles
983
+ };
984
+ `),e0=t=>{const e=Ve.c(18),{entries:s,activeIndex:r,onSelect:o,onForget:i,onHighlight:l}=t,{t:a}=mt();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 m;e[9]!==r||e[10]!==i||e[11]!==l||e[12]!==o||e[13]!==a?(m=(h,b)=>n.jsxs("div",{role:"option","aria-selected":b===r,className:xe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:g=>{g.preventDefault(),o(h.url)},onPointerEnter:()=>l(b),children:[n.jsx($,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate typography-micro text-foreground",children:h.title||Go(h.url)}),n.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:h.url})]}),n.jsx("button",{type:"button",className:xe("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:g=>{g.preventDefault(),g.stopPropagation(),i(h.url)},children:n.jsx($,{name:"close",className:"size-3","aria-hidden":"true"})})]},h.url),e[9]=r,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=m):m=e[14],u=s.map(m),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},Vs=t=>{const e=Ve.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=xe("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($,{name:s,className:"size-3.5","aria-hidden":"true"}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==f?(m=n.jsx(Et,{asChild:!0,children:n.jsx(ft,{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]=m):m=e[11];let h;e[12]!==r?(h=n.jsx(Pt,{sideOffset:6,children:r}),e[12]=r,e[13]=h):h=e[13];let b;return e[14]!==m||e[15]!==h?(b=n.jsxs(Dt,{children:[m,h]}),e[14]=m,e[15]=h,e[16]=b):b=e[16],b},Zf=t=>{const e=Ve.c(110),{address:s,addressMark:r,suggestions:o,onForgetSuggestion:i,onAddressChange:l,onSubmit:a,onBack:d,onForward:u,onReload:f,onOpenExternal:m,canOpenExternal:h,canGoBack:b,canGoForward:g,isLoading:w,onAnnotate:S,onOpenDevTools:x,isAnnotating:p,onHardReload:y,onZoomIn:v,onZoomOut:j,onZoomReset:C,zoomPercent:k,onClearCookies:T,onClearCache:O,onToggleDeviceBar:M,isDeviceBarOpen:L}=t;let F;e[0]!==o?(F=o===void 0?[]:o,e[0]=o,e[1]=F):F=e[1];const D=F,U=h===void 0?!0:h,N=k===void 0?100:k,{t:A}=mt(),[H,I]=c.useState(!1),[R,P]=c.useState(-1);let _;e[2]!==H||e[3]!==D?(_=H?D:[],e[2]=H,e[3]=D,e[4]=_):_=e[4];const G=_;let ae;e[5]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{P(-1)},e[5]=ae):ae=e[5];let Se;e[6]!==s||e[7]!==H?(Se=[s,H],e[6]=s,e[7]=H,e[8]=Se):Se=e[8],c.useEffect(ae,Se);let J;e[9]!==a?(J=He=>{I(!1),P(-1),a(He)},e[9]=a,e[10]=J):J=e[10];const re=J;let ie;e[11]!==R||e[12]!==re||e[13]!==G?(ie=He=>{if(G.length!==0){if(He.key==="ArrowDown"||He.key==="ArrowUp"){He.preventDefault();const Ye=He.key==="ArrowDown"?1:-1,Xe=G.length;P(Je=>{const bt=Je+Ye;return bt<-1?Xe-1:bt>=Xe?-1:bt});return}if(He.key==="Escape"&&R>=0){He.preventDefault(),P(-1);return}if(He.key==="Enter"&&R>=0){He.preventDefault();const Ye=G[R];Ye&&re(Ye.url)}}},e[11]=R,e[12]=re,e[13]=G,e[14]=ie):ie=e[14];const Be=ie;let Ae;e[15]!==A?(Ae=A("contextPanel.browser.back"),e[15]=A,e[16]=Ae):Ae=e[16];const K=!b;let q;e[17]!==d||e[18]!==Ae||e[19]!==K?(q=n.jsx(Vs,{icon:"arrow-left",label:Ae,onClick:d,disabled:K}),e[17]=d,e[18]=Ae,e[19]=K,e[20]=q):q=e[20];let X;e[21]!==A?(X=A("contextPanel.browser.forward"),e[21]=A,e[22]=X):X=e[22];const me=!g;let he;e[23]!==u||e[24]!==X||e[25]!==me?(he=n.jsx(Vs,{icon:"arrow-right",label:X,onClick:u,disabled:me}),e[23]=u,e[24]=X,e[25]=me,e[26]=he):he=e[26];let je;e[27]!==w||e[28]!==A?(je=A(w?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=w,e[28]=A,e[29]=je):je=e[29];let Y;e[30]!==f||e[31]!==je?(Y=n.jsx(Vs,{icon:"refresh",label:je,onClick:f}),e[30]=f,e[31]=je,e[32]=Y):Y=e[32];let ue;e[33]!==y||e[34]!==A?(ue=y?n.jsx(Vs,{icon:"restart",label:A("contextPanel.browser.hardReload"),onClick:y}):null,e[33]=y,e[34]=A,e[35]=ue):ue=e[35];let we;e[36]!==s||e[37]!==re?(we=He=>{He.preventDefault(),re(s)},e[36]=s,e[37]=re,e[38]=we):we=e[38];let ce;e[39]!==r?(ce=r?n.jsx("span",{className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",title:r.label,"aria-label":r.label,role:"img",children:n.jsx($,{name:r.icon,className:"size-3.5","aria-hidden":"true"})}):null,e[39]=r,e[40]=ce):ce=e[40];let le;e[41]!==l?(le=He=>l(He.target.value),e[41]=l,e[42]=le):le=e[42];let Re,Oe;e[43]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>I(!0),Oe=()=>I(!1),e[43]=Re,e[44]=Oe):(Re=e[43],Oe=e[44]);const Te=G.length>0,De=r&&"pl-8";let te;e[45]!==De?(te=xe("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3",De,"typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[45]=De,e[46]=te):te=e[46];let de;e[47]!==A?(de=A("contextPanel.browser.addressAria"),e[47]=A,e[48]=de):de=e[48];let fe;e[49]!==s||e[50]!==Be||e[51]!==le||e[52]!==Te||e[53]!==te||e[54]!==de?(fe=n.jsx("input",{value:s,onChange:le,onFocus:Re,onBlur:Oe,onKeyDown:Be,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Te,"aria-controls":"openchamber-browser-address-suggestions",className:te,"aria-label":de}),e[49]=s,e[50]=Be,e[51]=le,e[52]=Te,e[53]=te,e[54]=de,e[55]=fe):fe=e[55];let ge;e[56]!==i?(ge=He=>i?.(He),e[56]=i,e[57]=ge):ge=e[57];let B;e[58]!==R||e[59]!==re||e[60]!==ge||e[61]!==G?(B=n.jsx("div",{id:"openchamber-browser-address-suggestions",children:n.jsx(e0,{entries:G,activeIndex:R,onSelect:re,onForget:ge,onHighlight:P})}),e[58]=R,e[59]=re,e[60]=ge,e[61]=G,e[62]=B):B=e[62];let Q;e[63]!==we||e[64]!==ce||e[65]!==fe||e[66]!==B?(Q=n.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:we,children:[ce,fe,B]}),e[63]=we,e[64]=ce,e[65]=fe,e[66]=B,e[67]=Q):Q=e[67];let ke;e[68]!==v||e[69]!==j||e[70]!==C||e[71]!==A||e[72]!==N?(ke=j&&v?n.jsxs("div",{className:"flex shrink-0 items-center",children:[n.jsx(Vs,{icon:"subtract",label:A("contextPanel.browser.zoomOut"),onClick:j}),N!==100&&C?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsxs(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:C,"aria-label":A("contextPanel.browser.zoomReset"),children:[N,"%"]})}),n.jsx(Pt,{sideOffset:6,children:A("contextPanel.browser.zoomReset")})]}):null,n.jsx(Vs,{icon:"add",label:A("contextPanel.browser.zoomIn"),onClick:v})]}):null,e[68]=v,e[69]=j,e[70]=C,e[71]=A,e[72]=N,e[73]=ke):ke=e[73];let Ie;e[74]!==T||e[75]!==A?(Ie=T?n.jsx(Vs,{icon:"delete-bin",label:A("contextPanel.browser.clearCookies"),onClick:T}):null,e[74]=T,e[75]=A,e[76]=Ie):Ie=e[76];let oe;e[77]!==O||e[78]!==A?(oe=O?n.jsx(Vs,{icon:"database-2",label:A("contextPanel.browser.clearCache"),onClick:O}):null,e[77]=O,e[78]=A,e[79]=oe):oe=e[79];let $e;e[80]!==L||e[81]!==M||e[82]!==A?($e=M?n.jsx(Vs,{icon:"smartphone",label:A("contextPanel.browser.deviceToolbar"),onClick:M,pressed:L}):null,e[80]=L,e[81]=M,e[82]=A,e[83]=$e):$e=e[83];let Fe;e[84]!==p||e[85]!==S||e[86]!==A?(Fe=S?n.jsx(Vs,{icon:"markup",label:A("contextPanel.browser.annotate.toggle"),onClick:S,pressed:p}):null,e[84]=p,e[85]=S,e[86]=A,e[87]=Fe):Fe=e[87];let Ce;e[88]!==x||e[89]!==A?(Ce=x?n.jsx(Vs,{icon:"terminal-box",label:A("contextPanel.browser.devTools"),onClick:x}):null,e[88]=x,e[89]=A,e[90]=Ce):Ce=e[90];let Ue;e[91]!==A?(Ue=A("contextPanel.browser.openExternal"),e[91]=A,e[92]=Ue):Ue=e[92];const pe=!U;let ne;e[93]!==m||e[94]!==Ue||e[95]!==pe?(ne=n.jsx(Vs,{icon:"external-link",label:Ue,onClick:m,disabled:pe}),e[93]=m,e[94]=Ue,e[95]=pe,e[96]=ne):ne=e[96];let Me;return e[97]!==q||e[98]!==he||e[99]!==Y||e[100]!==ue||e[101]!==Q||e[102]!==ke||e[103]!==Ie||e[104]!==oe||e[105]!==$e||e[106]!==Fe||e[107]!==Ce||e[108]!==ne?(Me=n.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[q,he,Y,ue,Q,ke,Ie,oe,$e,Fe,Ce,ne]}),e[97]=q,e[98]=he,e[99]=Y,e[100]=ue,e[101]=Q,e[102]=ke,e[103]=Ie,e[104]=oe,e[105]=$e,e[106]=Fe,e[107]=Ce,e[108]=ne,e[109]=Me):Me=e[109],Me},Lo={kind:"fill"},_c=240,t0=3840,ep=[{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}],$c=t=>Number.isFinite(t)?Math.round(Math.min(t0,Math.max(_c,t))):_c,_o=t=>t.kind==="fill"?null:{width:t.width,height:t.height},tp=t=>{const e=ep.find(s=>s.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},s0=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},n0=(t,e)=>{const s=_o(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}},r0=["mobile","tablet","desktop","fill"],o0={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Wc=t=>typeof t=="string"&&r0.includes(t),ha=t=>t==="fill"?Lo:tp(o0[t])??Lo,to=t=>{const e=_o(t);if(!e)return{mode:"fill",width:null,height:null};for(const s of["mobile","tablet","desktop"]){const r=ha(s),o=_o(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}},i0=t=>{const e=Ve.c(70),{viewport:s,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:l}=t,{t:a}=mt();let d;e[0]!==s?(d=_o(s),e[0]=s,e[1]=d):d=e[1];const u=d,f=s.kind==="preset"?s.id:"";let m;e[2]!==r||e[3]!==u?(m=(ie,Be)=>{const Ae=Number.parseInt(Be,10);if(!Number.isFinite(Ae))return;const K=u??{width:1280,height:800};r({kind:"custom",width:$c(ie==="width"?Ae:K.width),height:$c(ie==="height"?Ae:K.height)})},e[2]=r,e[3]=u,e[4]=m):m=e[4];const h=m;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=xe("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]=b):b=e[5];const g=b;let w;e[6]!==r?(w=ie=>{const Be=tp(ie.target.value);r(Be??Lo)},e[6]=r,e[7]=w):w=e[7];let S;e[8]!==a?(S=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=S):S=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=xe("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]=x):x=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 v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=ep.map(a0),e[15]=v):v=e[15];let j;e[16]!==f||e[17]!==w||e[18]!==S||e[19]!==y?(j=n.jsxs("select",{value:f,onChange:w,"aria-label":S,className:x,children:[y,v]}),e[16]=f,e[17]=w,e[18]=S,e[19]=y,e[20]=j):j=e[20];const C=u?String(u.width):"";let k;e[21]!==h?(k=ie=>h("width",ie.target.value),e[21]=h,e[22]=k):k=e[22];let T;e[23]!==a?(T=a("contextPanel.browser.device.width"),e[23]=a,e[24]=T):T=e[24];let O;e[25]!==C||e[26]!==k||e[27]!==T?(O=n.jsx("input",{value:C,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":T,className:g}),e[25]=C,e[26]=k,e[27]=T,e[28]=O):O=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=M):M=e[29];const L=u?String(u.height):"";let F;e[30]!==h?(F=ie=>h("height",ie.target.value),e[30]=h,e[31]=F):F=e[31];let D;e[32]!==a?(D=a("contextPanel.browser.device.height"),e[32]=a,e[33]=D):D=e[33];let U;e[34]!==L||e[35]!==F||e[36]!==D?(U=n.jsx("input",{value:L,onChange:F,placeholder:"—",inputMode:"numeric","aria-label":D,className:g}),e[34]=L,e[35]=F,e[36]=D,e[37]=U):U=e[37];let N;e[38]!==r||e[39]!==s?(N=()=>r(s0(s)),e[38]=r,e[39]=s,e[40]=N):N=e[40];const A=!u;let H;e[41]!==a?(H=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=H):H=e[42];let I;e[43]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx($,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=I):I=e[43];let R;e[44]!==N||e[45]!==A||e[46]!==H?(R=n.jsx(Et,{asChild:!0,children:n.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:N,disabled:A,"aria-label":H,children:I})}),e[44]=N,e[45]=A,e[46]=H,e[47]=R):R=e[47];let P;e[48]!==a?(P=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=P):P=e[49];let _;e[50]!==P?(_=n.jsx(Pt,{sideOffset:6,children:P}),e[50]=P,e[51]=_):_=e[51];let G;e[52]!==R||e[53]!==_?(G=n.jsxs(Dt,{children:[R,_]}),e[52]=R,e[53]=_,e[54]=G):G=e[54];let ae;e[55]!==l||e[56]!==u?(ae=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]=ae):ae=e[57];let Se;e[58]===Symbol.for("react.memo_cache_sentinel")?(Se=["system","light","dark"],e[58]=Se):Se=e[58];let J;e[59]!==o||e[60]!==i||e[61]!==a?(J=n.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:Se.map(ie=>n.jsx(ft,{type:"button",variant:o===ie?"secondary":"ghost",size:"xs",className:xe("shrink-0 rounded-full px-2.5 typography-micro",o===ie?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(ie),"aria-pressed":o===ie,children:a(ie==="system"?"contextPanel.browser.device.schemeSystem":ie==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ie))}),e[59]=o,e[60]=i,e[61]=a,e[62]=J):J=e[62];let re;return e[63]!==j||e[64]!==O||e[65]!==U||e[66]!==G||e[67]!==ae||e[68]!==J?(re=n.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[j,O,M,U,G,ae,J]}),e[63]=j,e[64]=O,e[65]=U,e[66]=G,e[67]=ae,e[68]=J,e[69]=re):re=e[69],re};function a0(t){return n.jsx("option",{value:t.id,children:t.label},t.id)}const sp="oc.browser.hiddenDevServerPorts.v1",l0=sl(jn(),ri(F1().int().positive())),ga=new Set,np=[];let so=null;const ul=()=>{const t=eu().getItem(sp);if(so&&so.raw===t)return so.value;let e={};if(t!==null)try{const s=l0.safeParse(JSON.parse(t));s.success&&(e=s.data)}catch{e={}}return so={raw:t,value:e},e},rp=t=>{eu().setItem(sp,JSON.stringify(t));for(const e of ga)e()},c0=(t=Jt())=>ul()[t]??np,d0=t=>{const e=Jt(),s=ul(),r=s[e]??[];r.includes(t)||rp({...s,[e]:[...r,t].sort((o,i)=>o-i)})},u0=()=>{const t=Jt(),e=ul();if(!e[t])return;const s={...e};delete s[t],rp(s)},f0=t=>(ga.add(t),()=>{ga.delete(t)}),p0=()=>c.useSyncExternalStore(f0,m0,h0);function m0(){return c0()}function h0(){return np}const g0=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},b0=2e3,y0=t=>cu("http://localhost",t),op=t=>{const e=Ve.c(51),{onOpen:s,directory:r}=t,o=r===void 0?"":r,{t:i}=mt();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=sv(o);let f;e[1]!==o?(f=()=>y0(o),e[1]=o,e[2]=f):f=e[2];const[m]=c.useState(f);let h;e[3]!==o?(h=()=>Qh(o),e[3]=o,e[4]=h):h=e[4];const[b]=c.useState(h);let g;e[5]!==o?(g=Bm(o),e[5]=o,e[6]=g):g=e[6];const w=g,S=dl(o),x=Fm(o);let p,y;e[7]!==o||e[8]!==x?(p=()=>{if(x){d({kind:"ready",servers:[]});return}let P=!0,_=null;const G=new AbortController,ae=()=>{rj(G.signal,o).then(Se=>{P&&(d(Se),_=setTimeout(ae,b0))})};return ae(),()=>{P=!1,_&&clearTimeout(_),G.abort()}},y=[o,x],e[7]=o,e[8]=x,e[9]=p,e[10]=y):(p=e[9],y=e[10]),c.useEffect(p,y);const v=a.kind==="ready"?a.servers:null;let j;e[11]!==u||e[12]!==v?(j=aj({announced:u,discovered:v}),e[11]=u,e[12]=v,e[13]=j):j=e[13];const C=j,k=p0();let T;if(e[14]!==C||e[15]!==k){let P;e[17]!==k?(P=_=>_.announced||!k.includes(_.port),e[17]=k,e[18]=P):P=e[18],T=C.filter(P),e[14]=C,e[15]=k,e[16]=T}else T=e[16];const O=T,M=C.length-O.length;let L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Vu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[19]=L):L=e[19];let F;e[20]!==i?(F=i("contextPanel.browser.empty"),e[20]=i,e[21]=F):F=e[21];let D;e[22]!==F?(D=n.jsx("span",{className:"typography-ui-header text-foreground",children:F}),e[22]=F,e[23]=D):D=e[23];let U;e[24]!==i?(U=i("contextPanel.browser.emptyHint"),e[24]=i,e[25]=U):U=e[25];let N;e[26]!==U?(N=n.jsx("span",{className:"typography-micro text-muted-foreground",children:U}),e[26]=U,e[27]=N):N=e[27];let A;e[28]!==D||e[29]!==N?(A=n.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[D,N]}),e[28]=D,e[29]=N,e[30]=A):A=e[30];let H;e[31]!==u||e[32]!==C.length||e[33]!==o||e[34]!==M||e[35]!==w||e[36]!==s||e[37]!==m||e[38]!==S||e[39]!==b||e[40]!==i||e[41]!==O?(H=C.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-left text-muted-foreground",children:u.length>0?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),m&&!b?n.jsx("span",{className:"shrink-0 pb-1 text-left 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 pr-0.5",children:O.map(P=>n.jsxs("div",{className:"group/server flex shrink-0 items-center gap-1",children:[n.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:xe("min-w-0 flex-1 justify-start gap-2",m&&"cursor-default opacity-60"),"aria-disabled":m||void 0,onClick:()=>{m||(Z1(o),s(P.url))},children:[w?n.jsx("span",{className:"shrink-0",role:"img","aria-label":S??i("contextPanel.browser.spaceAddress"),title:S??i("contextPanel.browser.spaceAddress"),children:n.jsx($,{name:"box-3",className:"size-3.5","aria-hidden":"true"})}):n.jsx($,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"truncate",children:Go(P.url)||P.url}),b?n.jsx("span",{className:"ml-auto shrink-0 text-muted-foreground",role:"img","aria-label":i("contextPanel.browser.devServers.spaceOnlyDesktop"),title:i("contextPanel.browser.devServers.spaceOnlyDesktop"),children:n.jsx($,{name:"computer",className:"size-3.5","aria-hidden":"true"})}):n.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:g0(P.url)})]}),P.announced?null:n.jsx(ft,{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:()=>d0(P.port),"aria-label":i("contextPanel.browser.devServers.hide",{port:P.port}),title:i("contextPanel.browser.devServers.hide",{port:P.port}),children:n.jsx($,{name:"eye-off",className:"size-3.5","aria-hidden":"true"})})]},P.port))}),M>0?n.jsx(ft,{type:"button",variant:"link",size:"xs",className:"h-auto shrink-0 self-start p-0 typography-micro text-muted-foreground",onClick:u0,children:M===1?i("contextPanel.browser.devServers.showHiddenSingle",{count:M}):i("contextPanel.browser.devServers.showHiddenPlural",{count:M})}):null]}):null,e[31]=u,e[32]=C.length,e[33]=o,e[34]=M,e[35]=w,e[36]=s,e[37]=m,e[38]=S,e[39]=b,e[40]=i,e[41]=O,e[42]=H):H=e[42];let I;e[43]!==C.length||e[44]!==a.kind||e[45]!==i?(I=C.length===0&&a.kind==="unavailable"?n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[43]=C.length,e[44]=a.kind,e[45]=i,e[46]=I):I=e[46];let R;return e[47]!==A||e[48]!==H||e[49]!==I?(R=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:[L,A,H,I]}),e[47]=A,e[48]=H,e[49]=I,e[50]=R):R=e[50],R},Bs=t=>Math.round(t),x0=(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=${Bs(l.x)}, y=${Bs(l.y)}, width=${Bs(l.width)}, height=${Bs(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")},v0=(t,e)=>{const s=t.rect;return`Region ${e+1}: x=${Bs(s.x)}, y=${Bs(s.y)}, width=${Bs(s.width)}, height=${Bs(s.height)}`},S0=(t,e)=>{const s=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Bs(s.x)}, y=${Bs(s.y)}, width=${Bs(s.width)}, height=${Bs(s.height)}`},w0=({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: ${Bs(t.viewport.width)}x${Bs(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("",...x0(a.element,l));return t.regions.length>0&&(i.push(""),t.regions.forEach((l,a)=>i.push(v0(l,a)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((l,a)=>i.push(S0(l,a)))),i.filter(l=>typeof l=="string").join(`
985
+ `)},j0=t=>{const e=Ve.c(7),{t:s}=mt(),r=Ze(C0),o=Ze(N0),i=iy(A0),l=ay(P0);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){Ke.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:w0({payload:d.payload,screenshotAttached:f,intro:s("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ke.success(s("contextPanel.browser.annotate.attached")),requestAnimationFrame(ly)},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},k0=()=>{const t=Ve.c(16),{t:e}=mt();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 C0(t){return t.currentSessionId}function N0(t){return t.newSessionDraft?.open}function A0(t){return t.addDraft}function P0(t){return t.addAttachedFile}const I0=3e4,D0=3,E0=250,R0={attempts:0,windowStartedAt:null},T0=(t,e)=>{const s=t.windowStartedAt===null||e-t.windowStartedAt>=I0,r=s?0:t.attempts;return r>=D0?null:{delayMs:E0*2**r,state:{attempts:r+1,windowStartedAt:s?e:t.windowStartedAt}}},M0=-3,no=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",dr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},O0=(t,{initialUrl:e,onUrlChange:s})=>{const[r,o]=c.useState(e?{kind:"loading",url:e}:dj),[i,l]=c.useState(e),[a,d]=c.useState(""),[u,f]=c.useState(!1),[m,h]=c.useState(!1),b=c.useRef(s);b.current=s;const g=c.useRef(R0);return c.useEffect(()=>{if(!t)return;const w=()=>{try{const M=t.getURL();return no(M)?M:""}catch{return""}},S=()=>{try{f(t.canGoBack()),h(t.canGoForward())}catch{}},x=M=>{no(M)&&(l(M),b.current(M))},p=()=>{const M=w();o({kind:"loading",url:M})},y=()=>{const M=w();let L="";try{L=t.getTitle()||""}catch{L=""}d(L),x(M),S(),o(F=>F.kind==="failed"?F:{kind:"ready",url:M,title:L})},v=M=>{const L=dr(M);no(L.url)&&(x(L.url),S())},j=M=>{const L=dr(M),F=Array.isArray(L.favicons)?L.favicons.find(Boolean):"",D=w();if(!F||!D)return;let U=-1;try{U=t.getWebContentsId()}catch{return}!Number.isFinite(U)||U<0||zf.getState().resolve(D,F,U)},C=M=>{const L=dr(M);typeof L.title=="string"&&d(L.title)},k=M=>{const L=dr(M);if(L.isMainFrame===!1)return;const F=typeof L.errorCode=="number"?L.errorCode:0;F!==M0&&o({kind:"failed",url:no(L.validatedURL)?L.validatedURL:w(),code:F,description:typeof L.errorDescription=="string"?L.errorDescription:""})};let T=null;const O=()=>{const M=w(),L=T0(g.current,Date.now());if(!L){o({kind:"failed",url:M,code:0,description:"",crashed:!0});return}g.current=L.state,o({kind:"loading",url:M}),T=setTimeout(()=>{T=null;try{t.reload()}catch{o({kind:"failed",url:M,code:0,description:"",crashed:!0})}},L.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",y),t.addEventListener("did-navigate",v),t.addEventListener("did-navigate-in-page",v),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",j),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",O),t.addEventListener("crashed",O);try{!t.isLoading()&&w()&&y()}catch{}return()=>{T!==null&&clearTimeout(T),t.removeEventListener("render-process-gone",O),t.removeEventListener("crashed",O),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",y),t.removeEventListener("did-navigate",v),t.removeEventListener("did-navigate-in-page",v),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",j),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:m}},B0=1e3,ip=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.left>=0&&e.right<=window.innerWidth&&t.checkVisibility({opacityProperty:!0,visibilityProperty:!0})},F0=t=>{const e=t.composedPath()[0];return e instanceof HTMLElement?e:null},L0=()=>{let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null},_0=(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=L0());const a=d=>{if(document.activeElement!==t){i.current=F0(d);return}const u=e.current,f=s.current>r.current||Date.now()<o.current;u&&ip(u)&&!f||r.current>0||l()};return document.addEventListener("focusin",a,!0),()=>document.removeEventListener("focusin",a,!0)},[l,e,t]),c.useCallback(async(a,d)=>{const u=t!==null&&document.activeElement===t;s.current+=1,a&&(r.current+=1);try{return await d()}finally{s.current-=1,a&&(r.current-=1),o.current=Date.now()+B0,a&&!u&&r.current===0&&l()}},[l,t])},$0=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,ro=.5,W0=-3,K0=4,z0="persist:openchamber-browser",ap=(t,e,s)=>rn(t)!==null&&su(e)?{icon:"box-3",label:s}:void 0,Kc=t=>{const e=rn(t);return e?`openchamber-space-preview:${e}`:z0},zc=20,U0=600,H0=2e4,V0=15e3,G0=t=>{if(!t||ip(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}},q0=({initialUrl:t,directory:e,tabID:s})=>{const{t:r}=mt(),{currentTheme:o}=Kr(),i=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(pe=>{i.current=pe,a(pe)},[]),u=be(pe=>pe.setContextPanelTabTargetPath),f=c.useRef(fr(t)),m=f.current!==Dn?f.current:"",[h,b]=c.useState(m?null:Dn),g=dl(e),[w,S]=c.useState(m),[x,p]=c.useState(!1),[y,v]=c.useState(!1),[j,C]=c.useState(0),k=c.useRef(0),[T,O]=c.useState(!1),[M,L]=c.useState(Lo),F=c.useRef(M);F.current=M;const D=c.useRef([]),[U,N]=c.useState("system"),[A,H]=c.useState({width:0,height:0}),I=c.useRef(null),R=c.useRef(null),P=En(e),_=c.useRef(!!m&&!Lm(P,s));c.useEffect(()=>{tu(P,s)},[P,s]);const G=c.useRef(!1),ae=c.useRef(Date.now()),Se=c.useCallback(pe=>{!pe||pe===Dn||!e||!s||u(e,s,pe)},[e,s,u]),J=O0(l,{initialUrl:m,onUrlChange:c.useCallback(pe=>{const ne=rr(pe);S(ne),Se(ne)},[Se])}),[re,ie]=c.useState(null),[Be,Ae]=c.useState(rn(e)===null);c.useEffect(()=>{const pe=rn(e);if(pe===null){Ae(!0);return}let ne=!0;return Ae(!1),Nr("desktop_space_preview_prepare",{spaceId:pe}).then(()=>{ne&&Ae(!0)}).catch(()=>{ne&&ie(m||"http://localhost/")}),()=>{ne=!1}},[e,m]);const K=j0(e),q=k0(),X=J.status.kind==="loading",me=mr(Jf(e)),he=mr(pe=>pe.recordVisit),je=mr(pe=>pe.forget);c.useEffect(()=>{J.status.kind==="ready"&&he(e,{url:rr(J.status.url),title:J.status.title})},[e,J.status,he]);const Y=c.useMemo(()=>Xf(me,w),[me,w]),ue=c.useCallback(pe=>{const ne=fr(pe);ne!==Dn&&(_.current=!1,S(ne),ie(null),Kl(ne,e).then(Me=>{const He=i.current;if(!He){b(Me);return}try{He.loadURL(Me)}catch{b(Me)}}).catch(Me=>{Me instanceof zl&&ie(ne)}))},[e]);c.useEffect(()=>{if(!m)return;let pe=!0;return Kl(m,e).then(ne=>{pe&&b(ne)}).catch(ne=>{if(pe){if(ne instanceof zl){ie(m),_.current=!1,b(Dn);return}b(m)}}),()=>{pe=!1}},[]);const we=c.useMemo(()=>({executeJavaScript:async(pe,ne)=>{const Me=i.current;if(!Me)throw new Error("Browser view is not available");return Me.executeJavaScript(pe,ne)},capturePage:async()=>{const pe=i.current;if(!pe)return null;const ne=pe.getWebContentsId();return Number.isFinite(ne)?await Nr("desktop_browser_capture_page",{webContentsId:ne}):null}}),[]),ce=c.useCallback(()=>{if(x){p(!1),So(we);return}if(!J.url){Ke.error(r("contextPanel.browser.annotate.noPage"));return}const pe=kj(o.metadata.variant==="light"?"light":"dark");p(!0),wj({host:we,theme:pe,labels:q}).then(async ne=>{p(!1),ne&&await K(ne)}).catch(()=>{p(!1),Ke.error(r("contextPanel.browser.annotate.failed"))})},[we,K,o,x,J.url,q,r]);c.useEffect(()=>{if(!x)return;const pe=ne=>{cy(ne)||ne.key!=="Escape"||(ne.preventDefault(),ne.stopImmediatePropagation(),p(!1),So(we))};return window.addEventListener("keydown",pe,!0),()=>window.removeEventListener("keydown",pe,!0)},[we,x]);const le=c.useRef(!1);c.useEffect(()=>{if(!l)return;const pe=()=>{le.current=!0};return l.addEventListener("dom-ready",pe),l.addEventListener("did-fail-load",pe),()=>{l.removeEventListener("dom-ready",pe),l.removeEventListener("did-fail-load",pe)}},[l]);const Re=c.useCallback(async()=>{const pe=Date.now()+V0;for(;!(i.current&&le.current)&&Date.now()<pe;)await new Promise(ne=>setTimeout(ne,100));return i.current},[]),Oe=c.useCallback(async(pe=8e3)=>{const ne=Date.now();for(;;){const Me=i.current;if(!Me)return!1;let He=!1;try{He=Me.isLoading()}catch{return!1}if(!He)return!0;if(Date.now()-ne>pe)return!1;await new Promise(Ye=>setTimeout(Ye,120))}},[]),Te=c.useCallback(async(pe,ne)=>{const Me=await Re();if(!Me)throw new Error("The browser panel is not ready");const He=()=>{Wc(ne.viewport)&&(L(ha(ne.viewport)),O(!0))};if(pe==="browser.back"||pe==="browser.forward"){const lt=pe==="browser.back";if(!(lt?Me.canGoBack():Me.canGoForward()))throw new Error(lt?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");lt?Me.goBack():Me.goForward(),await new Promise(dt=>setTimeout(dt,150)),await Oe();let wt="";try{wt=Me.getTitle()||""}catch{wt=""}return{url:rr(Me.getURL()),title:wt}}if(pe==="browser.capture"){const lt=G0(I.current);try{await new Promise(dt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>dt()))}),await Oe();const xt=await we.capturePage();if(!xt)throw new Error("The page could not be captured");let wt="";try{wt=Me.getTitle()||""}catch{wt=""}return{...xt,url:rr(Me.getURL()),title:wt,viewport:to(F.current)}}finally{lt()}}if(pe==="browser.resize"){if(!Wc(ne.viewport))throw new Error("viewport is required");return He(),await new Promise(lt=>setTimeout(lt,200)),await Oe(),{viewport:to(ha(ne.viewport))}}if(pe==="browser.open"){const lt=typeof ne.url=="string"?ne.url:"";if(!lt)throw new Error("url is required");He(),ue(lt),await new Promise(dt=>setTimeout(dt,150));const xt=await Oe(25e3);let wt="";try{wt=Me.getTitle()||""}catch{wt=""}return{url:fr(lt),title:wt,opened:!0,settled:xt,viewport:to(F.current)}}await Oe();const Ye=lt=>typeof lt=="string"&&lt?lt:void 0,Je=(()=>{switch(pe){case"browser.snapshot":return qj({selector:Ye(ne.selector)});case"browser.click":return Yj({selector:Ye(ne.selector),text:Ye(ne.text)});case"browser.type":return Qj({selector:String(ne.selector??""),value:String(ne.value??""),submit:ne.submit===!0});case"browser.inspect":return Zj({selector:String(ne.selector??"")});case"browser.scroll":return Xj({selector:Ye(ne.selector),direction:Ye(ne.direction)});default:return null}})();if(!Je)throw new Error(`Unsupported browser action: ${pe}`);(pe==="browser.click"||pe==="browser.type")&&Me.focus({preventScroll:!0});const bt=await Me.executeJavaScript(Je,!0);if(!bt||typeof bt!="object")throw new Error("The page returned no result");const et=bt;if(et.ok!==!0)throw new Error(typeof et.error=="string"&&et.error?et.error:"Browser action failed");if(pe==="browser.snapshot"){const lt=D.current;return{...et,viewport:to(F.current),...lt.length>0?{consoleProblems:[...lt]}:{}}}return(pe==="browser.click"||pe==="browser.type"&&ne.submit===!0)&&(await new Promise(lt=>setTimeout(lt,150)),await Oe()),bt},[we,ue,Oe,Re]),De=_0(l,I),te=c.useCallback((pe,ne)=>De(pe==="browser.click"||pe==="browser.type",()=>Te(pe,ne)),[De,Te]),de=c.useCallback(()=>{const pe=i.current;if(!pe)return{title:"",url:""};let ne="",Me="";try{ne=pe.getTitle()||""}catch{ne=""}try{Me=rr(pe.getURL())}catch{Me=""}return{title:ne,url:Me}},[]);c.useEffect(()=>Rj({tabId:s,describe:de,run:te}),[de,te,s]),c.useEffect(()=>{const pe=we;return()=>{So(pe)}},[we]),c.useEffect(()=>{if(!l)return;const pe=Me=>{const He=Me;if(typeof He.level!="number"||He.level<2)return;const Ye=He.sourceId?`${He.sourceId}${He.line?`:${He.line}`:""}`:"";D.current.push({level:He.level>=3?"error":"warning",message:String(He.message??"").slice(0,400),source:Ye}),D.current.length>zc&&D.current.splice(0,D.current.length-zc)},ne=()=>{D.current=[]};return l.addEventListener("console-message",pe),l.addEventListener("did-start-loading",ne),()=>{l.removeEventListener("console-message",pe),l.removeEventListener("did-start-loading",ne)}},[l]);const fe=c.useRef(new Set),ge=c.useCallback(pe=>{fe.current.clear(),ue(pe)},[ue]),B=c.useRef(J.status);B.current=J.status;const Q=c.useRef(!1);J.status.kind==="ready"&&J.status.url&&(Q.current=!0),c.useEffect(()=>_m(P,s,pe=>{Wm(B.current,Q.current)&&ge(pe)}),[ge,P,s]),c.useEffect(()=>{if(!l)return;const pe=Me=>{const He=dr(Me),Ye=typeof He.url=="string"?He.url:"";!Ye||!Ul(Ye,e)||(Me.preventDefault(),ue(Ye))},ne=Me=>{const He=dr(Me);if(He.isMainFrame===!1||He.errorCode===-3)return;const Ye=typeof He.validatedURL=="string"?He.validatedURL:"";!Ye||!Ul(Ye,e)||fe.current.has(Ye)||(fe.current.add(Ye),ue(Ye))};return l.addEventListener("will-navigate",pe),l.addEventListener("did-fail-load",ne),()=>{l.removeEventListener("will-navigate",pe),l.removeEventListener("did-fail-load",ne)}},[e,ue,l]),c.useEffect(()=>{if(!l)return;const pe=ne=>{const Me=ne.detail;ne.preventDefault(),Me?.url&&ue(Me.url)};return l.addEventListener("new-window",pe),()=>l.removeEventListener("new-window",pe)},[ue,l]);const ke=c.useCallback(pe=>{const ne=Math.min(K0,Math.max(W0,pe));k.current=ne,C(ne);try{i.current?.setZoomLevel(ne)}catch{}},[]);c.useEffect(()=>{const pe=ne=>{if(!(ne instanceof CustomEvent))return;const Me=ne.detail,He=i.current;!He||document.activeElement!==He||(Me==="zoom-in"?ke(k.current+ro):Me==="zoom-out"?ke(k.current-ro):Me==="zoom-reset"&&ke(0))};return window.addEventListener("openchamber:zoom",pe),()=>window.removeEventListener("openchamber:zoom",pe)},[ke]);const Ie=c.useCallback(pe=>{Nr("desktop_browser_clear_data",{partition:Kc(e),cookies:pe==="cookies",cache:pe==="cache"}).then(()=>{Ke.success(r(pe==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{i.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ke.error(r("contextPanel.browser.clearFailed")))},[e,r]);c.useEffect(()=>{const pe=I.current;if(!pe||typeof ResizeObserver>"u")return;const ne=new ResizeObserver(Me=>{const He=Me[0]?.contentRect;He&&H({width:He.width,height:He.height})});return ne.observe(pe),()=>ne.disconnect()},[]);const oe=c.useCallback(pe=>{N(pe);const ne=i.current;if(!ne)return;let Me=-1;try{Me=ne.getWebContentsId()}catch{return}Nr("desktop_browser_set_color_scheme",{webContentsId:Me,scheme:pe}).catch(He=>{N("system"),Ke.error(He instanceof Error?He.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),$e=c.useCallback(()=>{try{X?i.current?.stop():i.current?.reload()}catch{}},[X]),Fe=J.status;c.useEffect(()=>{const pe=()=>{v(!0);const Xe=setTimeout(()=>{try{i.current?.reload()}catch{}},U0);return()=>clearTimeout(Xe)};if(Fe.kind==="loading")return;const ne=_.current;if((Fe.kind==="failed"||Fe.kind==="ready"&&Fe.url)&&(_.current=!1),Fe.kind==="failed"){const Xe=$m(Fe,{run:R.current,restored:ne,now:Date.now()});if(R.current=Xe.run,!Xe.retry){v(!1);return}return pe()}if(R.current=null,Fe.kind!=="ready"||!Fe.url||!su(Fe.url)){G.current=!0,v(!1);return}if(ne||G.current||Date.now()-ae.current>H0){G.current=!0,v(!1);return}let Me=!1,He=null;return(rn(e)?Promise.resolve(null):oj(rr(Fe.url))).then(Xe=>{if(!Me){if(Xe===null||Xe<500){G.current=!0,v(!1);return}He=pe()}}),()=>{Me=!0,He?.()}},[e,Fe]);const Ce=J.status.kind==="failed"&&!y?J.status:null,Ue=n0(M,A);return n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[n.jsx(Zf,{address:w,onAddressChange:S,onSubmit:ge,suggestions:Y,onForgetSuggestion:pe=>je(e,pe),onBack:()=>{try{i.current?.goBack()}catch{}},onForward:()=>{try{i.current?.goForward()}catch{}},onReload:$e,onOpenExternal:()=>{qo(J.url||w)},addressMark:ap(e,w,g??r("contextPanel.browser.spaceAddress")),canOpenExternal:rn(e)===null,canGoBack:J.canGoBack,canGoForward:J.canGoForward,isLoading:X,onAnnotate:ce,isAnnotating:x,onOpenDevTools:()=>{try{i.current?.openDevTools()}catch{}},onHardReload:()=>{try{i.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ke(j+ro),onZoomOut:()=>ke(j-ro),onZoomReset:()=>ke(0),zoomPercent:Math.round(Math.pow(1.2,j)*100),onClearCookies:()=>Ie("cookies"),onClearCache:()=>Ie("cache"),onToggleDeviceBar:()=>O(pe=>!pe),isDeviceBarOpen:T}),T?n.jsx(i0,{viewport:M,onViewportChange:L,colorScheme:U,onColorSchemeChange:oe,scale:Ue?.scale??1}):null,n.jsxs("div",{ref:I,className:xe("relative min-h-0 flex-1 bg-background",Ue&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[h!==null&&Be?n.jsx("webview",{ref:d,src:h,partition:Kc(e),allowpopups:!0,style:Ue?{width:`${Ue.width}px`,height:`${Ue.height}px`,transform:`scale(${Ue.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,h!==null&&!m&&!J.url&&!X?n.jsx(op,{onOpen:ge,directory:e}):null,y?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:r("contextPanel.browser.waitingForServer")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[rn(e)!==null?n.jsx($,{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:r("contextPanel.browser.tunnelFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:r(rn(e)!==null?"contextPanel.browser.spaceTunnelFailedHint":"contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,Ce&&!re?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:Ce.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:Ce.crashed?r("contextPanel.browser.crashedHint"):Ce.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,X?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]})]})},Y0=t=>{const e=Ve.c(74),{initialUrl:s,directory:r,tabID:o}=t,{t:i}=mt(),l=be(X0);let a;e[0]!==s?(a=fr(s),e[0]=s,e[1]=a):a=e[1];const d=a,u=d!==Dn?d:"",[f,m]=c.useState(u);let h;e[2]!==r||e[3]!==u?(h=vi(u,r),e[2]=r,e[3]=u,e[4]=h):h=e[4];const[b,g]=c.useState(h);let w;e[5]!==r||e[6]!==u?(w=cu(u,r)?u:"",e[5]=r,e[6]=u,e[7]=w):w=e[7];const[S,x]=c.useState(w);let p;e[8]!==r?(p=rn(r),e[8]=r,e[9]=p):p=e[9];const y=p!==null,v=dl(r);let j;e[10]!==u?(j=u?[u]:[],e[10]=u,e[11]=j):j=e[11];const[C,k]=c.useState(j),[T,O]=c.useState(u?0:-1),[M,L]=c.useReducer(J0,0);let F,D;e[12]!==r||e[13]!==o?(F=()=>{tu(En(r),o)},D=[r,o],e[12]=r,e[13]=o,e[14]=F,e[15]=D):(F=e[14],D=e[15]),c.useEffect(F,D);let U;e[16]!==r||e[17]!==l||e[18]!==o?(U=we=>{!we||we===Dn||!r||!o||l(r,o,we)},e[16]=r,e[17]=l,e[18]=o,e[19]=U):U=e[19];const N=U;let A;e[20]!==r?(A=Jf(r),e[20]=r,e[21]=A):A=e[21];const H=mr(A),I=mr(Z0),R=mr(ek);let P;e[22]!==f||e[23]!==H?(P=Xf(H,f),e[22]=f,e[23]=H,e[24]=P):P=e[24];const _=P;let G;e[25]!==r||e[26]!==T||e[27]!==N||e[28]!==I?(G=we=>{const ce=fr(we);if(ce===Dn)return;m(ce);const le=vi(ce,r);g(le),x(le?"":ce),N(ce),I(r,{url:ce}),k(Re=>{const Oe=T>=0?Re.slice(0,T+1):[];return Oe[Oe.length-1]===ce?(O(Oe.length-1),Oe):(O(Oe.length),[...Oe,ce])})},e[25]=r,e[26]=T,e[27]=N,e[28]=I,e[29]=G):G=e[29];const ae=G;let Se;e[30]!==r||e[31]!==C||e[32]!==N?(Se=we=>{const ce=C[we];if(!ce)return;O(we),m(ce);const le=vi(ce,r);g(le),x(le?"":ce),N(ce)},e[30]=r,e[31]=C,e[32]=N,e[33]=Se):Se=e[33];const J=Se;let re;e[34]!==r||e[35]!==R?(re=we=>R(r,we),e[34]=r,e[35]=R,e[36]=re):re=e[36];let ie,Be;e[37]!==J||e[38]!==T?(ie=()=>J(T-1),Be=()=>J(T+1),e[37]=J,e[38]=T,e[39]=ie,e[40]=Be):(ie=e[39],Be=e[40]);let Ae;e[41]!==f||e[42]!==b?(Ae=()=>{qo(b||f)},e[41]=f,e[42]=b,e[43]=Ae):Ae=e[43];let K;e[44]!==v||e[45]!==i?(K=v??i("contextPanel.browser.spaceAddress"),e[44]=v,e[45]=i,e[46]=K):K=e[46];let q;e[47]!==f||e[48]!==r||e[49]!==K?(q=ap(r,f,K),e[47]=f,e[48]=r,e[49]=K,e[50]=q):q=e[50];const X=!S,me=T>0,he=T>=0&&T<C.length-1;let je;e[51]!==f||e[52]!==ae||e[53]!==_||e[54]!==re||e[55]!==ie||e[56]!==Be||e[57]!==Ae||e[58]!==q||e[59]!==X||e[60]!==me||e[61]!==he?(je=n.jsx(Zf,{address:f,onAddressChange:m,onSubmit:ae,suggestions:_,onForgetSuggestion:re,onBack:ie,onForward:Be,onReload:L,onOpenExternal:Ae,addressMark:q,canOpenExternal:X,canGoBack:me,canGoForward:he,isLoading:!1}),e[51]=f,e[52]=ae,e[53]=_,e[54]=re,e[55]=ie,e[56]=Be,e[57]=Ae,e[58]=q,e[59]=X,e[60]=me,e[61]=he,e[62]=je):je=e[62];let Y;e[63]!==r||e[64]!==y||e[65]!==b||e[66]!==ae||e[67]!==M||e[68]!==i||e[69]!==S?(Y=n.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:S?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($,{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:Go(S)})}),n.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.remoteLoopback.hint")})]}):b?n.jsx("iframe",{src:b,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${b}|${M}`):n.jsx(op,{onOpen:ae,directory:r})}),e[63]=r,e[64]=y,e[65]=b,e[66]=ae,e[67]=M,e[68]=i,e[69]=S,e[70]=Y):Y=e[70];let ue;return e[71]!==je||e[72]!==Y?(ue=n.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[je,Y]}),e[71]=je,e[72]=Y,e[73]=ue):ue=e[73],ue},Q0=t=>{const e=Ve.c(3),[s]=c.useState($0);let r;return e[0]!==s||e[1]!==t?(r=s?n.jsx(q0,{...t}):n.jsx(Y0,{...t}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r};function X0(t){return t.setContextPanelTabTargetPath}function J0(t){return t+1}function Z0(t){return t.recordVisit}function ek(t){return t.forget}const tk=Sr(()=>kn(()=>import("./WalkthroughView-DI31zD02.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),sk=Sr(()=>kn(()=>import("./DiffView-Cv9MSXl1.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,87,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,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,129,116,117,118,119,120,121,122,130,123,124,125,126,127])).then(t=>({default:t.DiffView}))),nk=Sr(()=>kn(()=>import("./FilesView-BVoD8I2x.js"),__vite__mapDeps([131,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,132,133,134,135,126,136,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,137,138,121,122,83,84,85,86,119,139,120,140])).then(t=>({default:t.FilesView}))),rk=Sr(()=>kn(()=>import("./GitView-Bzb8p-ew.js"),__vite__mapDeps([141,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,142,130,116,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),ok=Sr(()=>kn(()=>import("./PlanView-RCBadcY7.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,132,29,30,31,32,33,34,28,35,36,37,133,134,135,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,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,120,83,84,85,86,140,121,122,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104])).then(t=>({default:t.PlanView}))),lp=c.lazy(()=>kn(()=>import("./useAppFontEffects-DGlvOqP_.js").then(t=>t.mT),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.PluginPane}))),cp={top:{container:"flex-col",page:"border-b border-border",vertical:!0},bottom:{container:"flex-col-reverse",page:"border-t border-border",vertical:!0},left:{container:"flex-row",page:"border-r border-border",vertical:!1},right:{container:"flex-row-reverse",page:"border-l border-border",vertical:!1}},ik=t=>{const e=Ve.c(12),{mode:s,docking:r}=t,[o,i]=c.useState(null),l=cp[r.dock],a=Math.max(gy,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=xe("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 m;e[6]!==s?(m=n.jsx(lp,{mode:s,onResize:i}),e[6]=s,e[7]=m):m=e[7];let h;return e[8]!==u||e[9]!==f||e[10]!==m?(h=n.jsx("div",{className:u,style:f,children:m}),e[8]=u,e[9]=f,e[10]=m,e[11]=h):h=e[11],h},Uc=c.lazy(()=>kn(()=>import("./GuestSurfacePane-Crdbvsxo.js"),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.GuestSurfacePane}))),dp=320,fl=600,ak=400,lk=100,ck=24,Hc=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},Vc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(dp,Math.round(t))):fl,Gc=t=>{const e=t??(typeof window<"u"?window.innerWidth:fl*2);return Math.max(dp,e-ak)},dk=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},uk=(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},up=(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)?Fa.getState().guests.find(r=>r.id===No(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),fk=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},pk=(t,e,s)=>{if(t.mode==="chat"){const r=ba(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"?Go(t.targetPath??"")||t.label||s("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?fk(t.targetPath)||s("contextPanel.mode.files"):t.mode==="diff"?s("contextPanel.mode.diff"):up(t.mode,s)},mk=t=>{const e=Ve.c(8),{mode:s}=t,r=za();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??by,a=i?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=n.jsx(vr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},qc=(t,e={})=>{if(t.mode==="file")return t.targetPath?n.jsx(Ka,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return n.jsx(uu,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return n.jsx($,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return n.jsx($,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return n.jsx($,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return n.jsx($,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return n.jsx($,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return n.jsx($,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return n.jsx($,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return n.jsx($,{name:"chat-4",className:"h-3.5 w-3.5"});if(Yn(t.mode))return n.jsx(mk,{mode:t.mode});if(t.mode==="browser"){const s=hk(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($,{name:"global",className:"h-3.5 w-3.5"})}},hk=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},gk=({visible:t,active:e,fill:s=!1})=>{const{t:r}=mt(),o=be(p=>p.contextEditorTreeWidth),i=be(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(o),f=c.useRef(null),m=c.useRef(null),h=c.useRef(null),b=c.useCallback(p=>{const y=h.current;y&&(y.style.width=`${p}px`,y.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),g=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}m.current=p.pointerId,a(!0),d.current=p.clientX,u.current=o,f.current=o,p.preventDefault()}},w=p=>{if(!l||m.current!==p.pointerId)return;const y=d.current-p.clientX,v=Ki(u.current+y);f.current!==v&&(f.current=v,b(v))},S=p=>{if(m.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const y=Ki(f.current??o);m.current=null,f.current=null,a(!1),i(y)},x=t?o:0;return n.jsxs("div",{ref:h,className:xe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",s&&"ml-auto"),style:{width:`${l?f.current??x:x}px`,maxWidth:s?"100%":void 0,"--oc-editor-tree-width":`${l?f.current??o:o}px`,overflowX:"clip",transitionProperty:l?"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:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!s&&n.jsx("div",{className:xe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:g,onPointerMove:w,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),n.jsx("div",{className:xe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:s?"100%":void 0},"aria-hidden":!t,children:n.jsx(Cw,{visible:t&&e})})]})},ba=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,bk=t=>{const e=Ur(),s=c.useRef(Fo),r=c.useRef(t);return r.current=t,c.useSyncExternalStore(c.useCallback(o=>e.subscribeAllSelected(i=>i.session,o),[e]),c.useCallback(()=>{const o=Array.from(e.children.values(),l=>l.getState()),i=lw(o,r.current);return iw(s.current,i)?s.current:(s.current=i,i)},[e]),()=>Fo)},yk=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,xk=()=>{const{t}=mt(),e=Fn()??"",s=Gu(e||null),r=c.useCallback((z,W)=>t(Tn(z,s),W),[s,t]),o=c.useMemo(()=>Hc(e),[e]),i=be(z=>o?z.contextPanelByDirectory[o]:void 0),l=be(z=>z.closeContextPanel),a=be(z=>z.closeContextPanelTab),d=be(z=>z.pinContextPanelTab),u=be(z=>z.openContextPanelTab),f=be(z=>z.toggleContextPanelExpanded),m=be(z=>z.setContextPanelWidth),h=be(z=>z.setActiveContextPanelTab),b=be(z=>z.openAgentBrowserTab),[g,w]=c.useState(()=>new Set),S=c.useCallback(z=>{w(W=>W.has(z)?W:new Set(W).add(z))},[]);c.useEffect(()=>{if(e)return Oj(z=>{const W=b(e,z);return W&&S(W),W})},[e,b,S]);const x=be(z=>z.openContextFile);c.useEffect(()=>_n(z=>{if(z.type!=="file-open-request")return;const W=z.directory??e;W&&x(W,z.path)}),[e,x]);const p=be(z=>z.reorderContextPanelTabs),y=an(z=>z.setSelectedPath),v=be(z=>z.contextEditorTreeVisible),j=be(z=>z.contextEditorTreeWidth),C=be(z=>z.setContextEditorTreeWidth),k=be(z=>z.toggleContextEditorTree),T=be(z=>z.contextEditorVisible),O=be(z=>z.toggleContextEditor),M=be(z=>z.openNewContextBrowserTab),L=zf(z=>z.byOrigin),F=c.useMemo(()=>i?.tabs??[],[i?.tabs]),D=F.find(z=>z.id===i?.activeTabId)??F[F.length-1]??null,U=D?.mode==="browser"?D.id:null;c.useEffect(()=>{U&&Mj(U)},[U]);const N=!!(i?.isOpen&&D),[A,H]=c.useState(null),I=c.useMemo(()=>F.some(z=>z.mode==="file"&&z.targetPath),[F]),R=I&&(T||!v),P=D?.mode??null,_=P==="file"&&!R,G=!!(N&&i?.expanded&&!_),ae=P?i?.widthByMode?.[P]:void 0,Se=P?i?.widthFractionByMode?.[P]:void 0,J=P?dy(P):.5,re=A??(typeof window<"u"?window.innerWidth:fl*2),ie=Se!=null&&A!=null?Math.round(Se*A):ae,Be=_?j:Vc(ie??Math.round(J*re),Gc(A??re));c.useEffect(()=>{!o||!P||_||Se!=null||ae==null||A==null||m(o,P,ae,A)},[P,A,o,_,ae,Se,m]);const Ae=c.useMemo(()=>{const z=[];for(const W of F){if(W.mode!=="chat")continue;const Z=ba(W.dedupeKey);Z&&!z.includes(Z)&&z.push(Z)}return z},[F]),K=bk(Ae),[q,X]=c.useState(!1),me=c.useRef(0),he=c.useRef(Be),je=c.useRef(null),Y=c.useRef(null),ue=c.useRef(null),we=c.useRef(!1);c.useLayoutEffect(()=>{const z=ue.current?.parentElement;if(!z||typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{H(z.clientWidth||null)});return W.observe(z),H(z.clientWidth||null),()=>W.disconnect()},[]),c.useEffect(()=>{if(!N||we.current){we.current=N;return}const z=window.requestAnimationFrame(()=>{ue.current?.focus({preventScroll:!0})});return we.current=!0,()=>window.cancelAnimationFrame(z)},[N]);const ce=c.useRef(null),le=c.useRef(null),Re=c.useCallback(()=>{le.current=null;const z=ue.current,W=je.current;!z||W===null||z.style.setProperty("--oc-context-panel-width",`${W}px`)},[]);c.useEffect(()=>()=>{le.current!==null&&clearTimeout(le.current)},[]);const Oe=c.useCallback(z=>{const W=ce.current,Z=_?Ki(z):Vc(z,Gc(W));return W===null?Z:Math.min(Z,Math.max(1,W))},[_]),Te=c.useCallback(z=>{!N||G||!o||(Y.current=z.pointerId,X(!0),me.current=z.clientX,he.current=Be,je.current=Be,ce.current=dk(ue.current),document.documentElement.style.cursor="col-resize",z.preventDefault())},[o,G,N,Be]),De=c.useCallback(()=>{const z=Oe(je.current??Be),W=ce.current;je.current=null,ce.current=null,le.current!==null&&(clearTimeout(le.current),le.current=null),document.documentElement.style.cursor="",_?C(z):o&&P&&m(o,P,z,W??void 0),X(!1),Y.current=null},[P,Oe,o,_,C,m,Be]);c.useEffect(()=>{if(!q)return;const z=ve=>{if(Y.current!==ve.pointerId)return;const E=me.current-ve.clientX,V=Oe(he.current+E);je.current!==V&&(je.current=V,le.current===null&&(le.current=setTimeout(Re,lk)))},W=ve=>{Y.current===ve.pointerId&&De()},Z=()=>{De()};return window.addEventListener("pointermove",z),window.addEventListener("pointerup",W),window.addEventListener("pointercancel",W),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",W),window.removeEventListener("blur",Z)}},[Re,Oe,De,q]),c.useEffect(()=>{q||(je.current=null,document.documentElement.style.cursor="")},[q]);const te=c.useCallback(()=>{o&&l(o)},[l,o]),de=c.useCallback(()=>{o&&f(o)},[o,f]),fe=c.useCallback(z=>{z.key==="Escape"&&(z.target instanceof Node&&!z.currentTarget.contains(z.target)||uy(z.target)||fy(z.target)||z.defaultPrevented||(z.preventDefault(),z.stopPropagation(),te()))},[te]);c.useEffect(()=>{if(!(!o||!D)&&D.mode==="file"&&D.targetPath){y(o,D.targetPath,{allowOutsideRoot:!0});return}},[D,o,y]);const ge=c.useMemo(()=>F.filter(z=>z.mode==="chat"),[F]),B=N&&D?.mode==="chat"?D.id:null,Q=N&&D?.mode==="chat"?ba(D.dedupeKey):null,ke=B?ge.find(z=>z.id===B)??null:null,Ie=c.useMemo(()=>(ke?.targetDirectory?Hc(ke.targetDirectory):"")||o||null,[ke?.targetDirectory,o]),oe=c.useMemo(()=>Q?{sessionId:Q,directory:Ie}:null,[Q,Ie]);c.useEffect(()=>{if(!N||!Ie||!Q||typeof window>"u")return;const z=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){wi(Ie,Q,!1);return}qu(Q),wi(Ie,Q,!0)};z();const W=window.setInterval(z,1e4);return window.addEventListener("focus",z),window.addEventListener("blur",z),document.addEventListener("visibilitychange",z),()=>{window.clearInterval(W),window.removeEventListener("focus",z),window.removeEventListener("blur",z),document.removeEventListener("visibilitychange",z),wi(Ie,Q,!1)}},[Ie,Q,N]);const $e=c.useCallback(z=>{!o||D?.mode!=="diff"||u(o,{mode:"diff",targetPath:D.targetPath,stagedDiff:z==="staged",diffScope:z})},[D,o,u]),Fe=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",Ce=c.useMemo(()=>D?F.filter(z=>z.mode===D.mode):[],[D,F]),Ue=c.useMemo(()=>Ce.map(z=>{const W=pk(z,K,r),Z=yk(W,ck),ve=uk(z.targetPath,e);return{id:z.id,label:Z,icon:qc(z,L),title:ve?`${W}: ${ve}`:W,closeLabel:t("contextPanel.tab.closeTabAria",{label:Z}),preview:z.preview}}),[Ce,e,L,K,t,r]),pe=D?.mode==="context"?n.jsx(Uw,{}):D?.mode==="git"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(rk,{isActive:N})}):D?.mode==="pr"?n.jsx(QS,{}):D?.mode==="notes"?n.jsx(Xh,{visible:N}):D?.mode==="plan"?n.jsx(c.Suspense,{fallback:null,children:n.jsx(ok,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,ne=c.useMemo(()=>F.filter(z=>z.mode==="browser"),[F]),Me=N&&D?.mode==="browser"?D.id:null;c.useEffect(()=>{Me&&S(Me)},[Me,S]);const He=c.useMemo(()=>ne.filter(z=>z.id===Me||g.has(z.id)),[ne,Me,g]);c.useEffect(()=>{if(!window.__OPENCHAMBER_ELECTRON__)return;const z=ne.filter(W=>!He.includes(W)).map(W=>Tj({tabId:W.id,describe:()=>({title:"",url:W.targetPath??""}),wake:()=>S(W.id)}));return()=>z.forEach(W=>W())},[ne,He,S]);const Ye=c.useMemo(()=>F.filter(z=>z.mode==="diff"),[F]),Xe=c.useMemo(()=>F.find(z=>z.mode==="terminal")??null,[F]),Je=c.useMemo(()=>F.some(z=>z.mode==="walkthrough"),[F]),bt=c.useMemo(()=>F.filter(z=>Yn(z.mode)),[F]),et=Fa(z=>z.guests),lt=c.useMemo(()=>new Set(et.filter(py).map(z=>z.id)),[et]),xt=c.useMemo(()=>{const z=new Map;for(const W of et){const Z=my(W);Z&&z.set(W.id,Z)}return z},[et]),wt=c.useMemo(()=>F.some(z=>z.mode==="file"),[F]),dt=D?.mode==="file",It=be(z=>z.closeContextPanelTabs),_t=c.useCallback(z=>{if(!o)return null;const{id:W,index:Z,allIds:ve,close:E}=z,V=()=>It(o,ve.filter(Rt=>Rt!==W)),Ne=()=>It(o,ve.slice(0,Z)),We=()=>It(o,ve.slice(Z+1)),Ge=()=>It(o,ve),qe=ve.length>1,Pe=Z===0,ze=Z===ve.length-1;return n.jsxs(n.Fragment,{children:[n.jsxs(qn,{onClick:E,children:[n.jsx($,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),n.jsx(Yi,{}),n.jsxs(qn,{onClick:V,disabled:!qe,children:[n.jsx($,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),n.jsxs(qn,{onClick:Ne,disabled:Pe,children:[n.jsx($,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),n.jsxs(qn,{onClick:We,disabled:ze,children:[n.jsx($,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),n.jsx(Yi,{}),n.jsxs(qn,{onClick:Ge,disabled:!qe,children:[n.jsx($,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[It,o,t]),Bt=n.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Fe?n.jsx(hy,{items:Ue,activeId:D?.id??null,onSelect:z=>{o&&h(o,z)},onClose:z=>{o&&a(o,z)},onReorder:(z,W)=>{o&&p(o,z,W)},onDoubleClickTab:z=>{o&&d(o,z)},layoutMode:"scrollable",variant:"default",tabContextMenu:_t}):n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?.mode==="pr"&&s==="gitlab"?n.jsx($,{name:"gitlab",className:"h-3.5 w-3.5"}):D?qc(D,L):null,n.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?.mode==="pr"&&s==="gitlab"?t("contextPanel.mode.mr"):D?up(D.mode,r):null})]}),n.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?n.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>{o&&M(o)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:n.jsx($,{name:"add",className:"h-3.5 w-3.5"})}):null,dt&&I?n.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:O,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":R,children:n.jsx($,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,dt?n.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:k,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":v,children:n.jsx($,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,_?null:n.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:de,className:"h-7 w-7 p-0",title:t(G?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(G?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:G?n.jsx($,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):n.jsx($,{name:"fullscreen",className:"h-3.5 w-3.5"})}),n.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:te,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:n.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ye=N?G?{"--oc-context-panel-width":A!==null?`${A}px`:"100%",width:A!==null?`${A}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Be}px`}:{"--oc-context-panel-width":`${Be}px`,width:0,maxWidth:"100%",overflowX:"clip"};return n.jsxs("aside",{ref:ue,"data-context-panel":"true",tabIndex:-1,inert:!N||void 0,className:xe("flex min-h-0 flex-col overflow-hidden bg-background",G?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!N&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:fe,style:ye,children:[N&&!G&&n.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),N&&n.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!G&&n.jsx("div",{className:xe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",q&&"bg-[var(--interactive-border)]"),onPointerDown:Te,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),n.jsxs("div",{className:xe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!N&&"pointer-events-none select-none opacity-0"),style:{width:G?A!==null?`${A}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!N,children:[Bt,n.jsxs("div",{className:xe("relative min-h-0 flex-1 overflow-hidden",q&&"pointer-events-none"),children:[wt?n.jsxs("div",{className:xe("absolute inset-0 flex",dt?"flex":"hidden"),children:[I||!v?n.jsx("div",{className:xe("h-full min-w-0 flex-1",I&&!R&&"hidden"),children:I?n.jsx(c.Suspense,{fallback:null,children:n.jsx(nk,{mode:"editor-only",visible:N&&dt&&R})}):n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx($,{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(gk,{visible:v,active:N&&dt,fill:!R})]}):null,ke&&Q&&oe?n.jsx("section",{"aria-label":t("contextPanel.iframe.sessionChatTitle",{sessionID:Q}),className:"absolute inset-0 bg-background",children:n.jsx(du,{pinnedSession:oe,readOnly:ke.readOnly})},ke.id):null,He.map(z=>n.jsx("div",{className:xe("absolute inset-0",D?.id!==z.id&&"invisible pointer-events-none"),"aria-hidden":D?.id!==z.id||void 0,children:n.jsx(Q0,{initialUrl:z.targetPath??"",directory:o,tabID:z.id})},`${o}\0${z.id}`)),Ye.map(z=>n.jsx("div",{className:xe("absolute inset-0",D?.id!==z.id&&"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(sk,{visible:N&&D?.id===z.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:z.diffScope??(z.stagedDiff?"staged":"working"),onDiffScopeChange:$e,targetFilePath:z.targetPath,flushContent:!0})})},z.id)),Xe?n.jsx("div",{className:xe("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:n.jsx(Jh,{visible:N&&D?.mode==="terminal",directory:Xe.targetDirectory,onLastTabClosed:()=>{o&&a(o,Xe.id)}})}):null,Je?n.jsx("div",{className:xe("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:n.jsx(tk,{directory:e,visible:N&&D?.mode==="walkthrough"})})}):null,bt.map(z=>{if(!Yn(z.mode))return null;const W=No(z.mode),Z=lt.has(W),ve=xt.get(W),E=D?.id===z.id,V=E&&N;return Z&&!ve&&!V?null:n.jsx("div",{className:xe("absolute inset-0",E?"block":"hidden"),children:n.jsx(c.Suspense,{fallback:null,children:Z?ve?n.jsxs("div",{className:xe("flex h-full",cp[ve.dock].container),children:[n.jsx(ik,{mode:z.mode,docking:ve}),n.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:V?n.jsx(Uc,{mode:z.mode}):null})]}):n.jsx(Uc,{mode:z.mode}):n.jsx(lp,{mode:z.mode})})},z.id)}),D?.mode!=="chat"&&!dt&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"&&!(D&&Yn(D.mode))?pe:null]})]})]})},vk=t=>{const e=Ve.c(43),{open:s,onOpenChange:r}=t,{t:o}=mt(),i=be(Sk),l=be(wk),a=be(jk),d=be(kk),u=za();let f;e[0]!==i||e[1]!==u?(f=Yu(i,u),e[0]=i,e[1]=u,e[2]=f):f=e[2];const m=f,h=l.length===0;let b;if(e[3]!==l||e[4]!==m){let O;e[6]!==l?(O=M=>l.includes(M.id),e[6]=l,e[7]=O):O=e[7],b=m.every(O),e[3]=l,e[4]=m,e[5]=b}else b=e[5];const g=b;let w;e[8]!==o?(w=o("contextRail.configure.dialogTitle"),e[8]=o,e[9]=w):w=e[9];let S;e[10]!==w?(S=n.jsx(Xs,{children:w}),e[10]=w,e[11]=S):S=e[11];let x;e[12]!==o?(x=o("contextRail.configure.dialogDescription"),e[12]=o,e[13]=x):x=e[13];let p;e[14]!==x?(p=n.jsx(Js,{children:x}),e[14]=x,e[15]=p):p=e[15];let y;e[16]!==S||e[17]!==p?(y=n.jsxs(Zs,{children:[S,p]}),e[16]=S,e[17]=p,e[18]=y):y=e[18];let v;if(e[19]!==l||e[20]!==a||e[21]!==m||e[22]!==o){let O;e[24]!==l||e[25]!==a||e[26]!==o?(O=M=>n.jsx(yy,{settingsItem:`layout.context-rail.surface.${M.id}`,checked:!l.includes(M.id),onChange:L=>a(M.id,L),label:M.label??o(M.labelKey),ariaLabel:M.label??o(M.labelKey)},M.id),e[24]=l,e[25]=a,e[26]=o,e[27]=O):O=e[27],v=m.map(O),e[19]=l,e[20]=a,e[21]=m,e[22]=o,e[23]=v}else v=e[23];let j;e[28]!==v?(j=n.jsx("div",{className:"flex flex-col",children:v}),e[28]=v,e[29]=j):j=e[29];let C;e[30]!==h||e[31]!==g||e[32]!==d||e[33]!==o?(C=h?null:n.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[g?n.jsx("span",{className:"text-xs text-destructive",children:o("contextRail.configure.noneWarning")}):n.jsx("span",{}),n.jsx(ft,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:o("contextRail.configure.showAll")})]}),e[30]=h,e[31]=g,e[32]=d,e[33]=o,e[34]=C):C=e[34];let k;e[35]!==C||e[36]!==y||e[37]!==j?(k=n.jsxs(Ls,{className:"max-w-md",children:[y,j,C]}),e[35]=C,e[36]=y,e[37]=j,e[38]=k):k=e[38];let T;return e[39]!==r||e[40]!==s||e[41]!==k?(T=n.jsx(_s,{open:s,onOpenChange:r,children:k}),e[39]=r,e[40]=s,e[41]=k,e[42]=T):T=e[42],T};function Sk(t){return t.contextRailOrder}function wk(t){return t.contextRailHiddenSurfaces}function jk(t){return t.setContextRailSurfaceVisible}function kk(t){return t.setContextRailHiddenSurfaces}const fp=150,Ck=500,Nk=[],Ak=t=>t>99?"99+":String(t),Pk=t=>{const e=Ve.c(52),{surface:s,isActive:r,showActivityDot:o,label:i,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:f,showOrderNumber:m,onSelect:h}=t;let b;e[0]!==s.id?(b={id:s.id},e[0]=s.id,e[1]=b):b=e[1];const{attributes:g,listeners:w,setNodeRef:S,transform:x,transition:p,isDragging:y}=si(b);let v;e[2]!==a?(v=a!=null&&a>0?Ak(a):null,e[2]=a,e[3]=v):v=e[3];const j=v;let C;e[4]!==x?(C=ni.Translate.toString(x),e[4]=x,e[5]=C):C=e[5];let k;e[6]!==C||e[7]!==p?(k={transform:C,transition:p},e[6]=C,e[7]=p,e[8]=k):k=e[8];const T=y&&"z-10 opacity-70";let O;e[9]!==T?(O=xe("relative",T),e[9]=T,e[10]=O):O=e[10];let M;e[11]!==h||e[12]!==s?(M=()=>h(s),e[11]=h,e[12]=s,e[13]=M):M=e[13];const L=d??i,F=r?"text-primary":"text-muted-foreground hover:text-foreground";let D;e[14]!==F?(D=xe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",F),e[14]=F,e[15]=D):D=e[15];let U;e[16]!==s.icon||e[17]!==s.iconSrc||e[18]!==s.id?(U=s.id==="diff"?n.jsx(uu,{className:"h-[18px] w-[18px]"}):n.jsx(vr,{icon:s.icon,iconSrc:s.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=s.icon,e[17]=s.iconSrc,e[18]=s.id,e[19]=U):U=e[19];let N;e[20]!==j||e[21]!==f||e[22]!==o||e[23]!==m?(N=m&&f!=null?n.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:f===10?"0":f}):j?n.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:j}):o?n.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=j,e[21]=f,e[22]=o,e[23]=m,e[24]=N):N=e[24];let A;e[25]!==g||e[26]!==r||e[27]!==w||e[28]!==D||e[29]!==U||e[30]!==N||e[31]!==M||e[32]!==L?(A=n.jsx(Et,{asChild:!0,children:n.jsxs("button",{type:"button",...g,...w,onClick:M,"aria-label":L,"aria-pressed":r,className:D,children:[U,N]})}),e[25]=g,e[26]=r,e[27]=w,e[28]=D,e[29]=U,e[30]=N,e[31]=M,e[32]=L,e[33]=A):A=e[33];let H;e[34]!==i?(H=n.jsx("span",{children:i}),e[34]=i,e[35]=H):H=e[35];let I;e[36]!==l?(I=n.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=I):I=e[37];let R;e[38]!==u?(R=u?n.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=R):R=e[39];let P;e[40]!==H||e[41]!==I||e[42]!==R?(P=n.jsx(Pt,{side:"left",sideOffset:8,children:n.jsxs("div",{className:"flex flex-col gap-0.5",children:[H,I,R]})}),e[40]=H,e[41]=I,e[42]=R,e[43]=P):P=e[43];let _;e[44]!==A||e[45]!==P?(_=n.jsxs(Dt,{delayDuration:fp,children:[A,P]}),e[44]=A,e[45]=P,e[46]=_):_=e[46];let G;return e[47]!==S||e[48]!==_||e[49]!==k||e[50]!==O?(G=n.jsx("div",{ref:S,style:k,className:O,children:_}),e[47]=S,e[48]=_,e[49]=k,e[50]=O,e[51]=G):G=e[51],G},Ik=()=>{const t=Ve.c(89),{t:e}=mt(),s=Fn();let r;t[0]!==s?(r=s?En(s):"",t[0]=s,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=Te=>o?Te.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const l=be(i),a=be(Dk),d=be(Ek),u=be(Rk),f=be(Tk),m=be(Mk),h=be(Ok),b=be(Bk),g=La(Fk),w=Tu(Mu)?.hasChecked??!1,S=Bn(_k),x=Gu(o||null),{screenWidth:p}=Ln(),y=$a(o||null);let v;t[4]!==b?(v=Qi("switch_context_surface",b),t[4]=b,t[5]=v):v=t[5];const j=v,[C,k]=c.useState(!1);let T,O;t[6]!==j?(T=()=>{const Te=new Set;let De=null,te=!1;const de=$k,fe=()=>{ec(j,Te)?!te&&De===null&&(De=setTimeout(()=>k(!0),Ck)):(te=!1,De!==null&&(clearTimeout(De),De=null),k(!1))},ge=ke=>{if(Te.add(ke.key.toLowerCase()),de(ke.key)&&ec(j,Te)){te=!0,De!==null&&(clearTimeout(De),De=null),k(!1);return}fe()},B=ke=>{Te.delete(ke.key.toLowerCase()),fe()},Q=()=>{Te.clear(),te=!1,De!==null&&(clearTimeout(De),De=null),k(!1)};return window.addEventListener("keydown",ge,!0),window.addEventListener("keyup",B,!0),window.addEventListener("blur",Q),()=>{window.removeEventListener("keydown",ge,!0),window.removeEventListener("keyup",B,!0),window.removeEventListener("blur",Q),De!==null&&clearTimeout(De)}},O=[j],t[6]=j,t[7]=T,t[8]=O):(T=t[7],O=t[8]),c.useEffect(T,O);let M;t[9]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{distance:8}},t[9]=M):M=t[9];let L;t[10]===Symbol.for("react.memo_cache_sentinel")?(L={activationConstraint:{delay:200,tolerance:6}},t[10]=L):L=t[10];const F=Xo(vn(Zo,M),vn(Jo,L)),D=za(),U=Zl(Wk),N=Zl(Kk),A=l?.tabs??Nk;let H;t[11]!==l?.activeTabId||t[12]!==A?(H=A.find(Te=>Te.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=A,t[13]=H):H=t[13];const I=H,R=l?.isOpen?I?.mode??null:null,P=y?.files.length??0;let _;if(t[14]!==u||t[15]!==d||t[16]!==D||t[17]!==g||t[18]!==x||t[19]!==p||t[20]!==S||t[21]!==A){let Te;t[23]!==x?(Te=De=>De.id==="pr"&&x==="gitlab"?{...De,icon:"gitlab"}:De,t[23]=x,t[24]=Te):Te=t[24],_=xy({railOrder:d,hiddenSurfaces:u,planModeEnabled:g,isVSCode:qs(),screenWidth:p,tabs:A,sourceControlConnected:S,extras:D}).map(Te),t[14]=u,t[15]=d,t[16]=D,t[17]=g,t[18]=x,t[19]=p,t[20]=S,t[21]=A,t[22]=_}else _=t[22];const G=_;let ae,Se;t[25]!==R||t[26]!==h||t[27]!==o||t[28]!==w||t[29]!==S?(Se=()=>{!o||!w||S||R!=="pr"||h(o)},ae=[R,h,o,w,S],t[25]=R,t[26]=h,t[27]=o,t[28]=w,t[29]=S,t[30]=ae,t[31]=Se):(ae=t[30],Se=t[31]),c.useEffect(Se,ae);const[J,re]=c.useState(!1);let ie;t[32]!==D||t[33]!==f?(ie=Te=>{const{active:De,over:te}=Te;if(!te||De.id===te.id)return;const de=Yu(be.getState().contextRailOrder,D).map(zk),fe=de.indexOf(De.id),ge=de.indexOf(te.id);fe===-1||ge===-1||f(jf(de,fe,ge))},t[32]=D,t[33]=f,t[34]=ie):ie=t[34];const Be=ie;if(!o)return null;let Ae;t[35]!==e?(Ae=e("contextRail.aria.rail"),t[35]=e,t[36]=Ae):Ae=t[36];let K;t[37]!==G?(K=G.map(Uk),t[37]=G,t[38]=K):K=t[38];let q;if(t[39]!==R||t[40]!==P||t[41]!==N||t[42]!==o||t[43]!==U||t[44]!==m||t[45]!==x||t[46]!==C||t[47]!==G||t[48]!==e||t[49]!==a){let Te;t[51]!==R||t[52]!==P||t[53]!==N||t[54]!==o||t[55]!==U||t[56]!==m||t[57]!==x||t[58]!==C||t[59]!==e||t[60]!==a?(Te=(De,te)=>{const de=De.label??e(Tn(De.labelKey,x)),fe=De.id==="git"&&!a?P:0,ge=Yn(De.mode)&&R!==De.mode?U[No(De.mode)]??0:0,B=fe>0?fe:ge>0?ge:null,Q=B!==null&&fe===0;return n.jsx(Pk,{surface:De,isActive:R===De.mode,showActivityDot:!1,label:de,description:e(Tn(De.descriptionKey,x)),badgeCount:B,badgeAriaLabel:B!==null?e(Q?B===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":B===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:de,count:B}):null,badgeDescription:B!==null?e(Q?B===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":B===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:B}):null,orderNumber:te+1,showOrderNumber:C,onSelect:ke=>{Yn(ke.mode)&&N(No(ke.mode)),m(o,ke.mode)}},De.id)},t[51]=R,t[52]=P,t[53]=N,t[54]=o,t[55]=U,t[56]=m,t[57]=x,t[58]=C,t[59]=e,t[60]=a,t[61]=Te):Te=t[61],q=G.map(Te),t[39]=R,t[40]=P,t[41]=N,t[42]=o,t[43]=U,t[44]=m,t[45]=x,t[46]=C,t[47]=G,t[48]=e,t[49]=a,t[50]=q}else q=t[50];let X;t[62]!==K||t[63]!==q?(X=n.jsx(el,{items:K,strategy:kf,children:q}),t[62]=K,t[63]=q,t[64]=X):X=t[64];let me;t[65]!==Be||t[66]!==F||t[67]!==X?(me=n.jsx(ei,{sensors:F,collisionDetection:ti,onDragEnd:Be,children:X}),t[65]=Be,t[66]=F,t[67]=X,t[68]=me):me=t[68];let he;t[69]!==e?(he=e("contextRail.configure.open"),t[69]=e,t[70]=he):he=t[70];let je;t[71]===Symbol.for("react.memo_cache_sentinel")?(je=()=>re(!0),t[71]=je):je=t[71];let Y;t[72]===Symbol.for("react.memo_cache_sentinel")?(Y=n.jsx($,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[72]=Y):Y=t[72];let ue;t[73]!==he?(ue=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button","aria-label":he,onClick:je,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:Y})}),t[73]=he,t[74]=ue):ue=t[74];let we;t[75]!==e?(we=e("contextRail.configure.open"),t[75]=e,t[76]=we):we=t[76];let ce;t[77]!==we?(ce=n.jsx(Pt,{side:"left",sideOffset:8,children:we}),t[77]=we,t[78]=ce):ce=t[78];let le;t[79]!==ue||t[80]!==ce?(le=n.jsxs(Dt,{delayDuration:fp,children:[ue,ce]}),t[79]=ue,t[80]=ce,t[81]=le):le=t[81];let Re;t[82]!==J?(Re=n.jsx(vk,{open:J,onOpenChange:re}),t[82]=J,t[83]=Re):Re=t[83];let Oe;return t[84]!==Ae||t[85]!==me||t[86]!==le||t[87]!==Re?(Oe=n.jsxs("nav",{"aria-label":Ae,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[me,le,Re]}),t[84]=Ae,t[85]=me,t[86]=le,t[87]=Re,t[88]=Oe):Oe=t[88],Oe};function Dk(t){return t.workStatusPanelVisible}function Ek(t){return t.contextRailOrder}function Rk(t){return t.contextRailHiddenSurfaces}function Tk(t){return t.setContextRailOrder}function Mk(t){return t.openContextSurface}function Ok(t){return t.closeContextPanel}function Bk(t){return t.shortcutOverrides}function Fk(t){return t.planModeEnabled}function Lk(t){return t.status?.status==="connected"}function _k(t){return Object.values(t.entries).some(Lk)}function $k(t){return t.length===1&&t>="0"&&t<="9"}function Wk(t){return t.countByGuest}function Kk(t){return t.clearBadge}function zk(t){return t.id}function Uk(t){return t.id}const Hk=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),Vk=(t,e,s,r)=>!s||r!==s||t.length===0?[]:Ar(t,e,o=>o.relativePath||o.name,{limit:10,threshold:.4}),Yc={status:"idle"},Gk=({query:t,enabled:e,limit:s,sessionId:r=null,directories:o,role:i=null,includeReasoning:l=!0,order:a="desc"})=>{const[d,u]=c.useState(Yc),f=(o??[]).join(`
986
+ `),m=`${t}\0${r??""}\0${f}\0${i??""}\0${a}\0${s}\0${l}`,h=c.useRef(m);h.current=m;const b=c.useRef(o);b.current=o,c.useEffect(()=>{if(!e||!t.trim()){u(Yc);return}if(!vy(t)){u({status:"too-short"});return}const S=new AbortController;return u(x=>({status:"loading",hits:"hits"in x?x.hits:[]})),tc({query:t,sessionId:r,directories:b.current,role:i,includeReasoning:l,order:a,limit:s,signal:S.signal}).then(x=>{S.signal.aborted||(x.status==="ok"?u({status:"ready",hits:x.hits,next:x.next,index:x.index,loadingMore:!1}):x.status==="query-too-short"?u({status:"too-short"}):u({status:"unavailable"}))}).catch(()=>{S.signal.aborted||u({status:"error",hits:[]})}),()=>S.abort()},[e,m]);const g=c.useRef(d);g.current=d;const w=c.useCallback(()=>{const S=g.current;if(S.status!=="ready"||!S.next||S.loadingMore)return;const x=h.current,p=S.next;u({...S,loadingMore:!0}),tc({query:t,sessionId:r,directories:b.current,role:i,includeReasoning:l,order:a,limit:s,before:p}).then(y=>{h.current!==x||y.status!=="ok"||u(v=>v.status==="ready"?{...v,hits:[...v.hits,...y.hits],next:y.next,index:y.index,loadingMore:!1}:v)}).catch(()=>{h.current===x&&u(y=>y.status==="ready"?{...y,loadingMore:!1}:y)})},[t,r,i,l,a,s]);return{state:d,loadMore:w}},qk={user:"user-3",assistant:"chat-ai-3",reasoning:"brain-ai-3"},Yk=t=>{const e=Ve.c(4),{snippet:s}=t;let r;e[0]!==s?(r=Sy(s).map(Jk),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==r?(o=n.jsx(n.Fragment,{children:r}),e[2]=r,e[3]=o):o=e[3],o},Qk=t=>{const e=new Date(t);if(!Number.isFinite(e.getTime()))return"";const s=e.getFullYear()===new Date().getFullYear();return new Intl.DateTimeFormat(Wa(),s?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"}).format(e)},Qc=t=>{const e=Ve.c(38),{hit:s,projectLabel:r,onSelect:o}=t,{t:i}=mt();let l;e[0]!==s.sessionTitle||e[1]!==i?(l=s.sessionTitle||i("commandPalette.session.untitled"),e[0]=s.sessionTitle,e[1]=i,e[2]=l):l=e[2];const a=l;let d;e[3]!==s.role||e[4]!==i?(d=s.role==="user"?i("commandPalette.messages.byYou"):s.role==="reasoning"?i("commandPalette.messages.inReasoning"):i("commandPalette.messages.byAgent"),e[3]=s.role,e[4]=i,e[5]=d):d=e[5];const u=d,f=`message:${s.role}:${s.id}`;let m;e[6]!==s||e[7]!==o?(m=()=>o(s),e[6]=s,e[7]=o,e[8]=m):m=e[8];const h=qk[s.role];let b;e[9]!==u||e[10]!==h?(b=n.jsx($,{name:h,className:"mr-2 mt-0.5 h-4 w-4 shrink-0",role:"img","aria-hidden":!1,"aria-label":u}),e[9]=u,e[10]=h,e[11]=b):b=e[11];let g;e[12]!==s.snippet?(g=n.jsx("span",{className:"line-clamp-2 break-words text-foreground",children:n.jsx(Yk,{snippet:s.snippet})}),e[12]=s.snippet,e[13]=g):g=e[13];let w;e[14]!==s.role||e[15]!==i?(w=s.role==="reasoning"?n.jsxs("span",{className:"shrink-0",children:[i("commandPalette.messages.inReasoning")," ·"]}):null,e[14]=s.role,e[15]=i,e[16]=w):w=e[16];let S;e[17]!==a?(S=n.jsx("span",{className:"min-w-0 truncate",children:a}),e[17]=a,e[18]=S):S=e[18];let x;e[19]!==r?(x=r?n.jsxs("span",{className:"max-w-[40%] shrink-0 truncate",children:["· ",r]}):null,e[19]=r,e[20]=x):x=e[20];let p;e[21]!==s.createdAt?(p=Qk(s.createdAt),e[21]=s.createdAt,e[22]=p):p=e[22];let y;e[23]!==p?(y=n.jsxs("span",{className:"shrink-0",children:["· ",p]}),e[23]=p,e[24]=y):y=e[24];let v;e[25]!==x||e[26]!==y||e[27]!==w||e[28]!==S?(v=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground typography-micro",children:[w,S,x,y]}),e[25]=x,e[26]=y,e[27]=w,e[28]=S,e[29]=v):v=e[29];let j;e[30]!==v||e[31]!==g?(j=n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[g,v]}),e[30]=v,e[31]=g,e[32]=j):j=e[32];let C;return e[33]!==j||e[34]!==f||e[35]!==m||e[36]!==b?(C=n.jsxs(Nn,{value:f,onSelect:m,className:"items-start",children:[b,j]}),e[33]=j,e[34]=f,e[35]=m,e[36]=b,e[37]=C):C=e[37],C},Xc=t=>{const e=Ve.c(10),{options:s,value:r,onChange:o,label:i}=t;let l;if(e[0]!==o||e[1]!==s||e[2]!==r){let d;e[4]!==o||e[5]!==r?(d=u=>n.jsx(ft,{type:"button",variant:"chip",size:"xs","aria-pressed":r===u.value,onClick:()=>o(u.value),children:u.label},u.value),e[4]=o,e[5]=r,e[6]=d):d=e[6],l=s.map(d),e[0]=o,e[1]=s,e[2]=r,e[3]=l}else l=e[3];let a;return e[7]!==i||e[8]!==l?(a=n.jsx("div",{className:"flex items-center gap-1",role:"group","aria-label":i,children:l}),e[7]=i,e[8]=l,e[9]=a):a=e[9],a},Xk=t=>{const e=Ve.c(42),{scope:s,onScopeChange:r,projectScopeAvailable:o,author:i,onAuthorChange:l,reasoningAvailable:a,onBack:d}=t,{t:u}=mt();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx($,{name:"arrow-left",className:"h-3.5 w-3.5"}),e[0]=f):f=e[0];let m;e[1]!==u?(m=u("commandPalette.messages.back"),e[1]=u,e[2]=m):m=e[2];let h;e[3]!==d||e[4]!==m?(h=n.jsxs(ft,{type:"button",variant:"ghost",size:"xs",onClick:d,children:[f,m]}),e[3]=d,e[4]=m,e[5]=h):h=e[5];let b;e[6]!==r||e[7]!==o||e[8]!==s||e[9]!==u?(b=o?n.jsx(Xc,{label:u("commandPalette.messages.filter.scopeLabel"),value:s,onChange:r,options:[{value:"all",label:u("commandPalette.messages.filter.allProjects")},{value:"project",label:u("commandPalette.messages.filter.thisProject")}]}):null,e[6]=r,e[7]=o,e[8]=s,e[9]=u,e[10]=b):b=e[10];let g;e[11]!==u?(g=u("commandPalette.messages.filter.authorLabel"),e[11]=u,e[12]=g):g=e[12];let w;e[13]!==u?(w=u("commandPalette.messages.filter.anyone"),e[13]=u,e[14]=w):w=e[14];let S;e[15]!==w?(S={value:"any",label:w},e[15]=w,e[16]=S):S=e[16];let x;e[17]!==u?(x=u("commandPalette.messages.filter.you"),e[17]=u,e[18]=x):x=e[18];let p;e[19]!==x?(p={value:"user",label:x},e[19]=x,e[20]=p):p=e[20];let y;e[21]!==u?(y=u("commandPalette.messages.filter.agent"),e[21]=u,e[22]=y):y=e[22];let v;e[23]!==y?(v={value:"assistant",label:y},e[23]=y,e[24]=v):v=e[24];let j;e[25]!==a||e[26]!==u?(j=a?[{value:"reasoning",label:u("commandPalette.messages.filter.reasoning")}]:[],e[25]=a,e[26]=u,e[27]=j):j=e[27];let C;e[28]!==v||e[29]!==j||e[30]!==S||e[31]!==p?(C=[S,p,v,...j],e[28]=v,e[29]=j,e[30]=S,e[31]=p,e[32]=C):C=e[32];let k;e[33]!==i||e[34]!==l||e[35]!==C||e[36]!==g?(k=n.jsx(Xc,{label:g,value:i,onChange:l,options:C}),e[33]=i,e[34]=l,e[35]=C,e[36]=g,e[37]=k):k=e[37];let T;return e[38]!==k||e[39]!==h||e[40]!==b?(T=n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-2 py-1.5",children:[h,b,k]}),e[38]=k,e[39]=h,e[40]=b,e[41]=T):T=e[41],T};function Jk(t,e){return t.match?n.jsx("mark",{className:"rounded-[2px] bg-primary/25 text-foreground",children:t.text},e):n.jsx(c.Fragment,{children:t.text},e)}const Zk=new Set,e2=[],t2=3,s2=30,Ti=(t,e)=>{const s=t.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);return e.toLowerCase().split(/\s+/).filter(Boolean).every(r=>s.some(o=>o.startsWith(r)))},Jc=t=>{const e=t.lastIndexOf("/");return e===-1?{name:t,directory:""}:{name:t.slice(e+1),directory:t.slice(0,e)}},Zc="‎",ed=t=>{const e=Ve.c(7),{text:s,className:r}=t;let o;e[0]!==r?(o=xe("min-w-0 truncate text-muted-foreground",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={direction:"rtl",textAlign:"left"},e[2]=i):i=e[2];const l=`${Zc}${s}${Zc}`;let a;return e[3]!==o||e[4]!==l||e[5]!==s?(a=n.jsx("span",{className:o,style:i,title:s,children:l}),e[3]=o,e[4]=l,e[5]=s,e[6]=a):a=e[6],a},mn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),s=e.startsWith("//");let r=e.replace(/\/+/g,"/");s&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",i=/^[A-Za-z]:\/$/.test(r);return!o&&!i&&(r=r.replace(/\/+$/,"")),r},n2=()=>{const{t}=mt(),e=be(E=>E.isCommandPaletteOpen),s=be(E=>E.setCommandPaletteOpen),r=be(E=>E.setSettingsDialogOpen),o=be(E=>E.setSettingsPage),i=be(E=>E.setSessionSwitcherOpen),l=be(E=>E.toggleSidebar),a=be(E=>E.openContextOverview),d=be(E=>E.openContextSurface),u=be(E=>E.openContextFile),f=be(E=>E.shortcutOverrides),m=be(E=>E.setArchivePageOpen),h=be(E=>E.setProjectContextTab),b=Ze(E=>E.openNewSessionDraft),g=Ze(E=>E.setCurrentSession),w=Ze(E=>E.currentSessionId),S=br(E=>E.toggle),x=ws(c.useCallback(E=>e?E.activeSessions:e2,[e])),p=br(c.useCallback(E=>e?E.ids:Zk,[e])),y=Ua(c.useCallback(E=>e?E.rankById:Ha,[e])),v=Ss(E=>E.currentDirectory),j=Xt(E=>E.getActiveProject()),C=Xt(E=>E.projects),k=Fn(),T=Zd(E=>E.searchFiles),{files:O,git:M}=Qs(),L=xn(E=>E.ensureStatus),{isMobile:F}=Ln(),D=c.useMemo(()=>k?mn(k):null,[k]),[U,N]=c.useState(""),H=Uu(U,200).trim(),I=U.trim(),[R,P]=c.useState(!1),[_,G]=c.useState("all"),[ae,Se]=c.useState("any");c.useEffect(()=>{e&&(N(""),P(!1))},[e]),c.useEffect(()=>{if(!e||!M)return;const E=setTimeout(()=>{const V=new Set;for(const Ne of x){const We=dn(Ne);!We||V.has(We)||(V.add(We),L(We,M))}},0);return()=>clearTimeout(E)},[e,x,M,L]);const J=c.useCallback(()=>s(!1),[s]),re=c.useCallback(E=>()=>{J(),E()},[J]),ie=c.useMemo(()=>{const E=[{id:"new-session",title:t("commandPalette.item.newSession"),icon:n.jsx($,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:t("commandPalette.item.newSession"),onSelect:re(()=>{i(!1),b()})},{id:"new-worktree",title:t("commandPalette.item.quickWorktree"),icon:n.jsx($,{name:"flashlight",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:t("commandPalette.item.quickWorktree"),onSelect:re(()=>{Qu()})},{id:"new-worktree-dialog",title:t("commandPalette.item.newWorktreeDialog"),icon:n.jsx($,{name:"git-branch",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.newWorktreeDialog"),onSelect:re(()=>{be.getState().setNewWorktreeDialogOpen(!0)})},{id:"add-project",title:t("commandPalette.item.addProject"),icon:n.jsx($,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.addProject"),onSelect:re(()=>{wn.requestDirectoryDialog()})},{id:"toggle-sidebar",title:t(F?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:n.jsx($,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:t(F?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:re(()=>{if(F){const{isSessionSwitcherOpen:V}=be.getState();i(!V)}else l()})},{id:"toggle-terminal",title:t("commandPalette.item.toggleTerminal"),icon:n.jsx($,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:t("commandPalette.item.toggleTerminal"),onSelect:re(()=>{v&&d(v,"terminal")})},{id:"context-usage",title:t("commandPalette.item.showContextUsage"),icon:n.jsx($,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showContextUsage"),onSelect:re(()=>{v&&a(v)})},{id:"cycle-theme",secondary:!0,title:t("commandPalette.item.cycleTheme"),icon:n.jsx($,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:t("commandPalette.item.cycleTheme"),onSelect:re(()=>{wy.invoke("cycle_theme")})},{id:"open-status",secondary:!0,title:t("commandPalette.item.showOpenCodeStatus"),icon:n.jsx($,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.showOpenCodeStatus"),onSelect:re(()=>{Xu()})},{id:"open-settings",title:t("commandPalette.item.openSettings"),icon:n.jsx($,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:t("commandPalette.item.openSettings"),onSelect:re(()=>r(!0))}];return qs()||(E.push({id:"open-source-board",secondary:!0,title:t("sourceBoard.title"),icon:n.jsx($,{name:"todo",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_source_board",searchText:t("sourceBoard.title"),onSelect:re(()=>be.getState().setSourceBoardOpen(!0))}),E.push({id:"reload-ui",secondary:!0,title:t("commandPalette.item.reloadUi"),icon:n.jsx($,{name:"refresh",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.reloadUi"),onSelect:re(()=>window.location.reload())})),E.push({id:"pin-session",secondary:!0,title:t("commandPalette.item.pinSession"),icon:n.jsx($,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.pinSession"),onSelect:re(()=>{w&&v&&S({directory:v,sessionId:w})})},{id:"copy-session-id",secondary:!0,title:t("commandPalette.item.copySessionId"),icon:n.jsx($,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.copySessionId"),onSelect:re(()=>{w&&Xn(w).then(V=>{if(V.ok){Ke.success(t("sessions.sidebar.session.copyId.success"));return}Ke.error(t("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(t("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:t("commandPalette.item.openMultiRun"),icon:n.jsx($,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openMultiRun"),onSelect:re(()=>{i(!1),jy()})},{id:"open-archive",secondary:!0,title:t("commandPalette.item.openArchive"),icon:n.jsx($,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openArchive"),onSelect:re(()=>{i(!1),m(!0)})},{id:"open-notes",secondary:!0,title:t("commandPalette.item.openNotes"),icon:n.jsx($,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openNotes"),onSelect:re(()=>{v&&(h("notes"),d(v,"notes"))})},{id:"open-todos",secondary:!0,title:t("commandPalette.item.openTodos"),icon:n.jsx($,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.openTodos"),onSelect:re(()=>{v&&(h("todos"),d(v,"notes"))})}),qs()||E.push({id:"restart-opencode",secondary:!0,title:t("commandPalette.item.restartOpenCode"),icon:n.jsx($,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.restartOpenCode"),onSelect:re(()=>{Zh(t)})}),E.push({id:"toggle-memory-debug",secondary:!0,title:t("commandPalette.item.toggleMemoryDebug"),icon:n.jsx($,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:t("commandPalette.item.toggleMemoryDebug"),onSelect:re(()=>{window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))})}),Tr()&&E.splice(1,0,{id:"new-mini-chat",title:t("commandPalette.item.newMiniChat"),icon:n.jsx($,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:t("commandPalette.item.newMiniChat"),onSelect:re(()=>{On("desktop_open_draft_mini_chat_window",{directory:mn(v||j?.path||""),projectId:j?.id??null}).catch(V=>{console.warn("[command-palette] failed to open draft mini chat window",V)})})}),E},[t,re,F,i,b,l,d,v,a,r,j?.id,j?.path,w,S,m,h]),Be=be(E=>E.routingFeatureAvailable),Ae=ky(),K=Cy(),q=c.useMemo(()=>{const E=cn();return{isVSCode:qs(),isWeb:!E&&Ea(),isDesktop:E,isMobile:F,routingAvailable:Be,enterpriseMode:Ae,jevBlockedByEnterprise:K}},[F,Be,Ae,K]),X=c.useMemo(()=>eg.filter(E=>E.slug!=="home").filter(E=>E.isAvailable?E.isAvailable(q):!0).map(E=>{const V=tg(E.slug)??"settings-3",Ne=(E.keywords??[]).join(" ");return{id:`settings:${E.slug}`,title:E.title,icon:E.slug==="mcp"?n.jsx(Ny,{className:"mr-2 h-4 w-4"}):n.jsx($,{name:V,className:"mr-2 h-4 w-4"}),searchText:`${E.title} ${E.group} ${Ne}`,onSelect:re(()=>{o(E.slug),r(!0)})}}),[q,re,o,r]),me=c.useMemo(()=>{const E=x.filter(V=>!Ay(V)&&!V.parentID);return Py(E,p,y)},[x,p,y]),he=Ju(),je=Ze(E=>E.worktreeMetadata),Y=c.useCallback((E,V)=>{const Ne=je.get(E);return Ne?.branch?Ne.branch.trim()||null:V&&he.get(V)?.trim()||null},[je,he]),[ue,we]=c.useState([]),[ce,le]=c.useState(""),Re=Hk(D,H),Oe=Ze(E=>E.availableWorktrees),Te=c.useMemo(()=>D?Oe.map(E=>mn(E.path)).filter(E=>E.startsWith(`${D}/`)).map(E=>`${E}/`):[],[Oe,D]),De=c.useRef(Te);De.current=Te;const de=be(E=>E.messageSearchEnabled)&&!qs(),fe=be(E=>E.messageSearchReasoningEnabled),ge=be(E=>E.showReasoningTraces),B=fe&&ge,Q=ae==="reasoning"&&!B?"any":ae,ke=c.useMemo(()=>j?.path?[...new Set([mn(j.path),...Oe.map(E=>mn(E.path))])]:[],[j?.path,Oe]),Ie=R&&_==="project"&&ke.length>0,{state:oe,loadMore:$e}=Gk({query:H,enabled:e&&de,limit:R?s2:t2,directories:Ie?ke:void 0,role:R&&Q!=="any"?Q:null,includeReasoning:ge}),Fe="hits"in oe?oe.hits:[];c.useEffect(()=>{if(!e){we([]),le("");return}if(!Re){we([]),le("");return}if(!D){we([]),le("");return}let E=!1;const V=De.current,Ne=V.length>0?100:40;return T(D,H,Ne,{type:"file"}).then(We=>{E||(we(We.map(Ge=>({path:mn(Ge.path),name:Ge.name,relativePath:Ge.relativePath})).filter(Ge=>!V.some(qe=>Ge.path.startsWith(qe)))),le(Re))}).catch(()=>{E||(we([]),le(Re))}),()=>{E=!0}},[e,D,H,Re,T]);const Ce=I.length>0,Ue=c.useMemo(()=>{if(!Ce)return ie.filter(V=>!V.secondary).map(V=>({item:V,score:0}));const E=ie.filter(V=>Ti(V.searchText,I));return Ar(E,I,V=>V.searchText,{limit:7,noFuzzy:!0})},[ie,I,Ce]),pe=c.useMemo(()=>{if(!Ce)return[];const E=X.filter(V=>Ti(V.searchText,I));return Ar(E,I,V=>V.searchText,{limit:7,noFuzzy:!0})},[X,I,Ce]),ne=c.useMemo(()=>Ce?Ar(me,I,E=>E.title||"",{limit:7,threshold:.2}):me.slice(0,5).map(E=>({item:E,score:0})),[me,I,Ce]),Me=c.useMemo(()=>e?Vk(ue,H,Re,ce):[],[e,ue,ce,Re,H]),He=e&&Re.length>0&&ce!==Re,Ye=c.useMemo(()=>{if(!Ce)return[];const V=C.map(Ne=>({...Ne,displayName:Ne.label||Ne.path.split("/").pop()||Ne.path,searchText:`${Ne.label||""} ${Ne.path}`})).filter(Ne=>Ti(Ne.searchText,I));return Ar(V,I,Ne=>Ne.searchText,{limit:7,threshold:.4})},[C,I,Ce]),Xe=be(E=>e&&D?E.contextPanelByDirectory[D]?.tabs:void 0),Je=c.useMemo(()=>!D||!Xe?[]:Xe.filter(E=>E.mode==="file"&&E.targetPath).sort((E,V)=>V.touchedAt-E.touchedAt).slice(0,5).flatMap(E=>{const V=mn(E.targetPath??"");if(!V)return[];const Ne=V.startsWith(`${D}/`)?V.slice(D.length+1):V;return[{path:V,name:Jc(Ne).name,relativePath:Ne}]}),[Xe,D]),bt=c.useCallback(E=>{if(!E)return null;const V=mn(E);let Ne=null;for(const We of C){const Ge=mn(We.path);V!==Ge&&!V.startsWith(`${Ge}/`)||Ne&&Ne.length>=Ge.length||(Ne={label:We.label||Ge.split("/").pop()||Ge,length:Ge.length})}return Ne?.label??null},[C]),et=Ue.map(E=>E.item),lt=pe.map(E=>E.item),xt=ne.map(E=>E.item),wt=Ce?Me.map(E=>E.item):[],dt=Ce?Ye.map(E=>E.item):[],It=Ce?[]:Je,_t=c.useMemo(()=>{if(!Ce)return["openFiles","sessions","commands"];const E=Ne=>Ne.length?Ne[0].score:1/0,V=[{key:"commands",score:E(Ue)},{key:"settings",score:E(pe)},{key:"sessions",score:E(ne)},{key:"files",score:E(Me)},{key:"projects",score:E(Ye)}];return V.sort((Ne,We)=>Ne.score-We.score),[...V.map(Ne=>Ne.key),"messages"]},[Ce,Ue,pe,ne,Me,Ye]),Bt=c.useCallback(E=>{J(),Iy(E.role==="reasoning"?E.id:null),Xi(E.sessionId,E.id)},[J]),ye=c.useCallback(E=>{J(),g(E.id,dn(E))},[J,g]),z=c.useCallback(async E=>{if(!D)return;const V=await Lf(O,E,{directory:D});if(!V.ok){Ke.error(_f(V.reason));return}u(D,E),J()},[D,O,u,J]),W=c.useCallback((E,V)=>{J(),b({selectedProjectId:E,directoryOverride:V})},[J,b]),Z=c.useCallback(E=>Qn(zr(E,f)),[f]),ve=(E,V)=>{const{name:Ne,directory:We}=Jc(E.relativePath||E.name);return n.jsxs(Nn,{value:`${V}:${E.path}`,onSelect:()=>{z(E.path)},children:[n.jsx(Ka,{filePath:E.path,className:"mr-2 size-4 shrink-0"}),n.jsx("span",{className:"shrink-0 truncate","aria-label":E.relativePath,children:Ne}),We?n.jsx(ed,{text:We,className:"flex-1"}):null]},`${V}:${E.path}`)};return n.jsxs(_s,{open:e,onOpenChange:(E,V)=>{if(!E&&R&&V.reason==="escape-key"){V.cancel(),P(!1);return}s(E)},children:[n.jsxs(Zs,{className:"sr-only",children:[n.jsx(Xs,{children:t("commandPalette.title")}),n.jsx(Js,{children:t("commandPalette.description")})]}),n.jsx(Ls,{className:"gap-0 overflow-hidden p-0 max-w-[min(720px,calc(100vw-2rem))]",layerClassName:"items-start pt-[12vh]",showCloseButton:!1,children:n.jsxs(Dy,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pt-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:!text-[11px] [&_[cmdk-group-heading]]:!leading-4 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[n.jsx(Ey,{value:U,onValueChange:N,placeholder:t(R?"commandPalette.messages.placeholder":"commandPalette.input.placeholder"),onKeyDown:E=>{R&&E.key==="Backspace"&&U.length===0&&(E.preventDefault(),P(!1))}}),R?n.jsx(Xk,{scope:_,onScopeChange:G,projectScopeAvailable:ke.length>0,author:Q,onAuthorChange:Se,reasoningAvailable:B,onBack:()=>P(!1)}):null,n.jsx("div",{className:xe("min-h-0",R?"h-[min(403px,calc(60vh-37px))]":"h-[min(440px,60vh)]"),children:n.jsx(Ry,{children:R?n.jsxs(n.Fragment,{children:[Fe.map(E=>n.jsx(Qc,{hit:E,projectLabel:bt(E.directory),onSelect:Bt},`${E.role}:${E.id}`)),oe.status==="ready"&&oe.next?n.jsxs(Nn,{value:"message:load-more",onSelect:$e,disabled:oe.loadingMore,children:[n.jsx($,{name:"more",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.loadMore")})]}):null,n.jsxs("div",{className:"px-4 py-2 typography-meta text-muted-foreground",role:"status",children:[oe.status==="idle"||oe.status==="too-short"?t("commandPalette.messages.tooShort"):oe.status==="loading"&&Fe.length===0?t("commandPalette.messages.searching"):oe.status==="error"?t("commandPalette.messages.error"):oe.status==="unavailable"?t("commandPalette.messages.unavailable"):oe.status==="ready"&&Fe.length===0?t("commandPalette.messages.empty"):null,oe.status==="ready"&&oe.index?.backfill.state==="running"?` ${t("commandPalette.messages.indexing",{done:oe.index.backfill.done,total:oe.index.backfill.total})}`:null]})]}):n.jsxs(n.Fragment,{children:[n.jsx(Ty,{children:t("commandPalette.empty.noResults")}),_t.map(E=>E==="messages"?!Ce||Fe.length===0?null:n.jsxs(Kn,{heading:t("commandPalette.group.messages"),children:[Fe.map(V=>n.jsx(Qc,{hit:V,projectLabel:bt(V.directory),onSelect:Bt},`${V.role}:${V.id}`)),n.jsxs(Nn,{value:"message:show-all",onSelect:()=>P(!0),children:[n.jsx($,{name:"search",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t("commandPalette.messages.showAll")})]})]},"messages"):E==="openFiles"&&It.length>0?n.jsx(Kn,{heading:t("commandPalette.group.openFiles"),children:It.map(V=>ve(V,"open-file"))},"openFiles"):E==="commands"&&et.length>0?n.jsx(Kn,{heading:t("commandPalette.group.commands"),children:et.map(V=>n.jsxs(Nn,{value:V.id,onSelect:V.onSelect,children:[V.icon,n.jsx("span",{className:"truncate",children:V.title}),V.shortcutId?n.jsx(My,{children:Z(V.shortcutId)}):null]},V.id))},"commands"):E==="settings"&&lt.length>0?n.jsx(Kn,{heading:t("commandPalette.group.settings"),children:lt.map(V=>n.jsxs(Nn,{value:V.id,onSelect:V.onSelect,children:[V.icon,n.jsx("span",{className:"truncate",children:V.title})]},V.id))},"settings"):E==="sessions"&&xt.length>0?n.jsx(Kn,{heading:t("commandPalette.group.sessions"),children:xt.map(V=>{const Ne=V.title||t("commandPalette.session.untitled"),We=dn(V),Ge=Y(V.id,We),qe=bt(We);return n.jsxs(Nn,{value:`session:${V.id}`,onSelect:()=>ye(V),children:[n.jsx($,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),n.jsx("span",{dir:"auto",className:"min-w-0 flex-1 truncate text-left",children:Ne}),qe?n.jsx("span",{className:"max-w-[180px] shrink-0 truncate text-muted-foreground typography-meta",children:qe}):null,Ge?n.jsxs("span",{className:"inline-flex max-w-[160px] shrink-0 items-center gap-1 text-muted-foreground typography-meta",children:[n.jsx($,{name:"git-branch",className:"h-3 w-3"}),n.jsx("span",{className:"truncate",children:Ge})]}):null]},V.id)})},"sessions"):E==="files"&&wt.length>0?n.jsx(Kn,{heading:t("commandPalette.group.files"),children:wt.map(V=>ve(V,"file"))},"files"):E==="projects"&&dt.length>0?n.jsx(Kn,{heading:t("commandPalette.group.projects"),children:dt.map(V=>n.jsxs(Nn,{value:`project:${V.id}`,onSelect:()=>W(V.id,V.path),children:[n.jsx($,{name:"folder",className:"mr-2 h-4 w-4"}),n.jsx("span",{className:"shrink-0 truncate",children:V.displayName}),n.jsx(ed,{text:V.path,className:"flex-1"})]},`project:${V.id}`))},"projects"):null),He?n.jsx("div",{className:"px-4 py-2 typography-meta text-muted-foreground",children:t("commandPalette.empty.searchingFiles")}):null]})})}),F?null:n.jsxs("div",{className:"flex items-center gap-4 border-t border-border px-3 py-1.5 typography-micro text-muted-foreground","aria-hidden":"true",children:[n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"↑↓"})," ",t("commandPalette.footer.navigate")]}),n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"↵"})," ",t("commandPalette.footer.open")]}),n.jsxs("span",{children:[n.jsx("kbd",{className:"font-sans",children:"esc"})," ",t("commandPalette.footer.close")]})]})]})})]})},td=(t,e,s)=>Qn(zr(t,e),s),r2=()=>{const t=Ve.c(47),{t:e}=mt(),s=be(o2),r=be(i2),o=be(a2);let i,l,a,d,u,f,m,h,b,g,w,S;if(t[0]!==s||t[1]!==r||t[2]!==o||t[3]!==e){const j=[{categoryKey:"helpDialog.section.navigationCommands",column:"left",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[Qn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",column:"right",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""},{id:"background_session_work",icon:"arrow-up-double",keys:""}]},{categoryKey:"helpDialog.section.panels",column:"right",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${Qn(Qi("switch_context_surface",o))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Qn(Qi("switch_session_tab",o))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",column:"left",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"toggle_source_board",descriptionKey:"helpDialog.item.toggleSourceBoard",icon:"todo",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}],C=F=>n.jsxs("div",{children:[n.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(F.categoryKey)}),n.jsx("div",{className:"space-y-1",children:F.items.map(D=>{const U=D.id?Oy(D.id):void 0,N=D.descriptionKey??(U?.customizable?U.settingsLabelKey:void 0);if(!N||D.id&&!zr(D.id,o))return null;const A=D.id?td(D.id,o,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(D.keys)?D.keys:D.keys.split(" / ");return n.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[D.icon&&n.jsx($,{name:D.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"typography-meta",children:e(N)})]}),n.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),n.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(A)?A:[A]).map((H,I)=>n.jsxs(c.Fragment,{children:[I>0&&n.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),n.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:H})]},`${H}-${I}`))})]},D.id||N)})})]},F.categoryKey);a=_s,w=s,S=r,l=Ls,b="max-w-6xl w-[min(72rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let k;t[16]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx($,{name:"command",className:"h-5 w-5"}),t[16]=k):k=t[16];let T;t[17]!==e?(T=e("helpDialog.title"),t[17]=e,t[18]=T):T=t[18];let O;t[19]!==T?(O=n.jsxs(Xs,{className:"flex items-center gap-2",children:[k,T]}),t[19]=T,t[20]=O):O=t[20];let M;t[21]!==e?(M=e("helpDialog.description"),t[21]=e,t[22]=M):M=t[22];let L;t[23]!==M?(L=n.jsx(Js,{children:M}),t[23]=M,t[24]=L):L=t[24],t[25]!==O||t[26]!==L?(g=n.jsxs(Zs,{children:[O,L]}),t[25]=O,t[26]=L,t[27]=g):g=t[27],i=Cn,f="flex-1 min-h-0 mt-3",m="pr-1",h=!0,d="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(F=>n.jsxs("div",{className:"space-y-4",children:[j.filter(D=>D.column===F).map(C),F==="right"&&n.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[n.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:td("open_command_palette",o,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),n.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),n.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},F)),t[0]=s,t[1]=r,t[2]=o,t[3]=e,t[4]=i,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=f,t[10]=m,t[11]=h,t[12]=b,t[13]=g,t[14]=w,t[15]=S}else i=t[4],l=t[5],a=t[6],d=t[7],u=t[8],f=t[9],m=t[10],h=t[11],b=t[12],g=t[13],w=t[14],S=t[15];let x;t[28]!==d||t[29]!==u?(x=n.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=x):x=t[30];let p;t[31]!==i||t[32]!==f||t[33]!==m||t[34]!==h||t[35]!==x?(p=n.jsx(i,{outerClassName:f,className:m,disableHorizontal:h,children:x}),t[31]=i,t[32]=f,t[33]=m,t[34]=h,t[35]=x,t[36]=p):p=t[36];let y;t[37]!==l||t[38]!==p||t[39]!==b||t[40]!==g?(y=n.jsxs(l,{className:b,children:[g,p]}),t[37]=l,t[38]=p,t[39]=b,t[40]=g,t[41]=y):y=t[41];let v;return t[42]!==a||t[43]!==y||t[44]!==w||t[45]!==S?(v=n.jsx(a,{open:w,onOpenChange:S,children:y}),t[42]=a,t[43]=y,t[44]=w,t[45]=S,t[46]=v):v=t[46],v};function o2(t){return t.isHelpDialogOpen}function i2(t){return t.setHelpDialogOpen}function a2(t){return t.shortcutOverrides}const l2=()=>{const t=Ve.c(32),{t:e}=mt(),s=be(c2),r=be(d2),o=be(u2);let i;t[0]!==o||t[1]!==e?(i=async()=>{if(!o)return;if((await Xn(o)).ok){Ke.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ke.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=o,t[1]=e,t[2]=i):i=t[2];const l=i;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=n.jsx(Xs,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==u?(f=n.jsx(Js,{children:u}),t[9]=u,t[10]=f):f=t[10];let m;t[11]!==d||t[12]!==f?(m=n.jsxs(Zs,{children:[d,f]}),t[11]=d,t[12]=f,t[13]=m):m=t[13];let h;t[14]!==e?(h=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=h):h=t[15];let b;t[16]!==l||t[17]!==h?(b=n.jsx("div",{className:"flex items-center justify-end",children:n.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:h})}),t[16]=l,t[17]=h,t[18]=b):b=t[18];let g;t[19]!==o||t[20]!==e?(g=o||e("openCodeStatusDialog.empty.noData"),t[19]=o,t[20]=e,t[21]=g):g=t[21];let w;t[22]!==g?(w=n.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:g}),t[22]=g,t[23]=w):w=t[23];let S;t[24]!==m||t[25]!==b||t[26]!==w?(S=n.jsxs(Ls,{className:"max-w-2xl",children:[m,b,w]}),t[24]=m,t[25]=b,t[26]=w,t[27]=S):S=t[27];let x;return t[28]!==s||t[29]!==r||t[30]!==S?(x=n.jsx(_s,{open:s,onOpenChange:r,children:S}),t[28]=s,t[29]=r,t[30]=S,t[31]=x):x=t[31],x};function c2(t){return t.isOpenCodeStatusDialogOpen}function d2(t){return t.setOpenCodeStatusDialogOpen}function u2(t){return t.openCodeStatusText}const f2=t=>{const e=Ve.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 w=window.requestAnimationFrame(()=>{l.current?.focus(),l.current?.select()});return()=>window.cancelAnimationFrame(w)},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 m,h;e[5]!==d||e[6]!==o||e[7]!==l?(m=()=>{if(!d||typeof window>"u")return;const w=()=>{o(),l.current?.focus(),l.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},h=[d,o,l],e[5]=d,e[6]=o,e[7]=l,e[8]=m,e[9]=h):(m=e[8],h=e[9]),c.useEffect(m,h);let b,g;e[10]!==i||e[11]!==d||e[12]!==r||e[13]!==a?(b=()=>{if(!d||!r||typeof document>"u")return;const w=S=>{a.current&&(a.current.contains(S.target)||i())};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},g=[d,r,i,a],e[10]=i,e[11]=d,e[12]=r,e[13]=a,e[14]=b,e[15]=g):(b=e[14],g=e[15]),c.useEffect(b,g)},p2=t=>{const e=Ve.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(m2)),u=[];a.forEach(h=>{const b=d.get(h);b&&(u.push(b),d.delete(h))});const f=[],m=[];return l.forEach(h=>{d.has(h.id)&&(h.isArchivedBucket?m.push(h):f.push(h))}),[...f,...u,...m]},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 m2(t){return[t.id,t]}const h2=(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}))},sd=(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)},xr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const s of t.children)if(xr(s,e))return!0;return!1},g2=({isSubtaskSession:t,archivedBucket:e,isVSCode:s,sessionDirectory:r})=>!t&&!e&&!s&&!Ra(r),b2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:s})=>!t||e||s,ya=(t,e,s)=>{const r=new Map,o=i=>{const l=dn(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}))},xa=(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})},pp=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},mp=(t,e)=>{const s=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),o=new Map,i=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){i.add(u.id);continue}if(u.parentId){const h=o.get(u.parentId)??[];h.push(u.id),o.set(u.parentId,h)}const f=new Set;let m=u.id;for(;m;){if(f.has(m)){i.add(u.id);break}f.add(m),m=r.get(m)?.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 m=i.has(u);return!m&&e.archivedBucket&&f.nodeCount===0?m=(o.get(u)??[]).some(d):(!m&&!e.searchQuery&&(m=!0),!m&&(f.nodeCount>0||!s&&Io([f.name],e.searchQuery))&&(m=!0),m||(m=(o.get(u)??[]).some(d))),a.delete(u),m&&l.add(u),m};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},nd=new WeakMap;let rd=1;const y2=t=>{const e=nd.get(t);if(e!==void 0)return e;const s=rd;return rd+=1,nd.set(t,s),s},Fr=t=>t.children.length===0?"":t.children.map(s=>{const r=y2(s.session);return s.children.length===0?`${s.session.id}@${r}`:`${s.session.id}@${r}:${Fr(s)}`}).join("|"),hp=(t,e,s,r,o,i)=>{const l=Jt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const f=d.session.directory??o,m=u.session.directory??i,h=sc(l,f??"",d.session.id),b=sc(l,m??"",u.session.id);return(h?s.has(h):!1)!==(b?r.has(b):!1)?!0:d.children.some((g,w)=>a(g,u.children[w]))};return a(t,e)},x2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,v2=(t,e)=>t?t.branchLabel??null:e??null,S2=(t,e)=>{if(e)return null;const s=t?.branch?.trim(),r=ot(t?.path??null);return s&&r?{directory:r,branch:s}:null},$o=(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},Gn=(t,e)=>`${t}\0${e}`,Rn=(t,e)=>t??Ta(e)??ot(e??null),Lr=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}]:[]},pl=t=>t.startsWith("__archived__:"),gp=["chats","work","active-now"],oo=t=>"run"in t,w2=(t,e)=>`${t}:active:run:${e}`,Mi=(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},bp=(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)},j2=[],k2=new Set,od=32,id=64,C2=3,N2=7,io=32,Hn=28,ad=(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 Va(t.session,e.session,s,Ha)},ao=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}},A2=(t,e,s)=>`${t}:${e?"archived":"active"}:${s}`,P2=(t,e)=>{let s=null;for(const r of t){if(r.rowIndex>e)break;s=r}return s},I2=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??k2;let m=0;const b=[...[...t.authoritativeSections.flatMap(N=>N.groups.flatMap(A=>A.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 g=N=>{const A=a.get(N)??0;return a.set(N,A+1),A===0?N:`${N}:${A}`},w=N=>{e.push(Object.freeze(N))},S=t.runIndex??By,x=(N,A)=>{const H=w2(A.renderContext,N.run.key),I=A.renderContext!=="timeline"&&(d||t.expandedParents.has(H)),R=N.lanes[0]?.session.id,P=R&&A.getSecondaryMeta?A.getSecondaryMeta(R):A.secondaryMeta,_=Object.freeze([...new Set(N.lanes.flatMap(G=>(A.getBlockingBadgeSessionScopes?.(G.session.id)??[]).flatMap(ae=>ae.sessionIDs)))]);w({kind:"run",key:g(`${A.containerKey}:run:${N.run.key}`),estimateSize:A.renderContext==="timeline"?id:od,run:N.run,depth:A.baseDepth??0,laneNodes:Object.freeze([...N.lanes]),blockingSessionIds:_,projectId:A.projectId,projectLabel:P?.projectLabel??null,groupDirectory:A.groupDirectory,renderContext:A.renderContext,expansionKey:H,expanded:I,forceExpanded:d}),I&&y(N.lanes,(A.baseDepth??0)+1,A)},p=N=>{for(const A of Mi(N.nodes,S,N.archived))oo(A)?x(A,N):y([A],N.baseDepth??0,N)},y=(N,A,H)=>{const I=[...N].reverse().map(R=>({node:R,depth:A,directory:H.groupDirectory}));for(;I.length>0;){const R=I.pop();if(!R)continue;const P=g(`${H.containerKey}:session:${R.node.session.id}`),_=R.node.session.directory??R.directory;l.set(R.node.session.id,R.node.session),w({kind:"session",key:P,estimateSize:H.renderContext==="timeline"?id:od,node:R.node,blockingBadgeSessionScopes:R.depth===A?H.getBlockingBadgeSessionScopes?.(R.node.session.id)??H.blockingBadgeSessionScopes:void 0,depth:R.depth,projectId:H.projectId,groupDirectory:R.directory,ownerKey:H.ownerKey,selectionScopeKey:H.selectionScopeKey,archived:H.archived,renderContext:H.renderContext,secondaryMeta:H.getSecondaryMeta?H.getSecondaryMeta(R.node.session.id):H.secondaryMeta??null});const G=H.indexedNodes?.subtreeRangeByNode.get(R.node),ae=G&&G[1]>G[0]+1?Object.freeze([(H.selectionPoolOffset??0)+G[0]+1,(H.selectionPoolOffset??0)+G[1]]):void 0;if(s.push(Object.freeze({id:R.node.session.id,rowKey:P,scopeKey:H.selectionScopeKey,archived:H.archived,descendantRange:ae})),!(!d&&!t.expandedParents.has(A2(H.renderContext,H.archived,R.node.session.id))))for(let Se=R.node.children.length-1;Se>=0;Se-=1){const J=R.node.children[Se];J&&I.push({node:J,depth:R.depth+1,directory:_})}}},v=N=>{const A=t.groupSearchDataByGroup.get(N);if(A?.hasMatch!==!0)return 0;const H=f.size>0?A.filteredNodes.filter(R=>f.has(R.session.id)):[];return Math.max(0,A.matchedSessionCount-bp(H,t.normalizedQuery))+A.folderNameMatchCount+(A.groupMatches?1:0)},j=(N,A,H,I,R)=>{const P=t.groupSearchDataByGroup.get(N);if(d){const oe=v(N);if(oe===0)return;m+=oe}const _=!(t.keepWorkInGroup===!0&&!d),G=(d?P?.filteredNodes??[]:N.sessions).filter(oe=>!_||!f.has(oe.session.id)).sort((oe,$e)=>ad(oe,$e,u,t.sessionOrderIndex)),ae=ao(G),Se=r.length;r.push(...ae.preorderIds);for(const[oe,$e]of ae.sessionsById)l.set(oe,$e);const J=Rn(H,N.directory),re=!d&&t.collapsedGroups.has(A);if(!I){const oe=ae.preorderIds.flatMap($e=>ae.sessionsById.get($e)??[]);w({kind:"group-header",key:`${A}:header`,estimateSize:io,group:N,groupKey:A,projectId:H,collapsed:re,forceExpanded:d,allSessions:Object.freeze(oe)})}if(re)return;const ie=Lr(N).flatMap(({scopeKey:oe,directory:$e})=>(t.foldersMap[oe]??j2).map(Fe=>({folder:Fe,scopeKey:oe,scopeDirectory:$e,ownerKey:J,nodes:xa(Fe.sessionIds,ae.byId).sort((Ce,Ue)=>ad(Ce,Ue,u,t.sessionOrderIndex))}))),Be=mp(ie.map(oe=>({id:oe.folder.id,name:oe.folder.name,parentId:oe.folder.parentId,nodeCount:oe.nodes.length})),{archivedBucket:N.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),Ae=ie.filter(oe=>Be.has(oe.folder.id)),K=new Map(Ae.map(oe=>[Gn(oe.scopeKey,oe.folder.id),oe])),q=new Map;for(const oe of Ae){if(!oe.folder.parentId)continue;const $e=Gn(oe.scopeKey,oe.folder.parentId),Fe=q.get($e)??[];Fe.push(oe),q.set($e,Fe)}const X=pp(Ae.map(oe=>({...oe.folder,scopeKey:oe.scopeKey}))).map(oe=>K.get(Gn(oe.scopeKey??"",oe.id))).filter(oe=>!!oe),me=new Set(Ae.flatMap(oe=>oe.folder.sessionIds)),he=G.filter(oe=>!me.has(oe.session.id)),je=new Map,Y=X.map(oe=>({folder:oe,visited:!1})),ue=new Set;for(;Y.length>0;){const oe=Y.pop();if(!oe)continue;const $e=Gn(oe.folder.scopeKey,oe.folder.folder.id);if(!oe.visited){if(ue.has($e))continue;ue.add($e),Y.push({folder:oe.folder,visited:!0});for(const Ce of q.get($e)??[])Y.push({folder:Ce,visited:!1});continue}const Fe=oe.folder.nodes.flatMap(Ce=>{const Ue=ae.subtreeRangeByNode.get(Ce);return Ue?ae.preorderIds.slice(Ue[0],Ue[1]).flatMap(pe=>ae.sessionsById.get(pe)??[]):[Ce.session]});for(const Ce of q.get($e)??[])Fe.push(...je.get(Gn(Ce.scopeKey,Ce.folder.id))??[]);je.set($e,Object.freeze(Fe))}const we=new Set,ce=(oe,$e)=>{const Fe=Gn(oe.scopeKey,oe.folder.id);if(we.has(Fe))return;we.add(Fe);const Ce=$e?`${$e} / ${oe.folder.name}`:oe.folder.name,Ue=`${A}:folder:${Fe}`,pe=!d&&t.collapsedFolders.has(oe.folder.id),ne=je.get(Fe)??[],Me=pe&&!N.isArchivedBucket?xa([...new Set(ne.map(Xe=>Xe.id))],ae.byId):[],He=J?t.folderAuthorityByOwner.get(J):void 0,Ye=!!J&&!N.isArchivedBucket&&!pl(oe.scopeKey)&&He?.complete===!0&&He.scopeKeys.includes(oe.scopeKey);if(w({kind:"folder-header",key:Ue,estimateSize:io,group:N,folder:oe.folder,displayName:Ce,scopeKey:oe.scopeKey,scopeDirectory:oe.scopeDirectory,ownerKey:J,nodes:oe.nodes,activityNodes:Me,projectId:H,archived:N.isArchivedBucket===!0,collapsed:pe,forceExpanded:d,deleteSessions:ne,subFolderCount:q.get(Fe)?.length??0,dropEnabled:Ye}),J&&i.push(Object.freeze({rowKey:Ue,scopeKey:oe.scopeKey,folderId:oe.folder.id,ownerKey:J,enabled:Ye})),!pe){p({nodes:oe.nodes,containerKey:Ue,projectId:H,groupDirectory:oe.scopeDirectory??N.directory,ownerKey:J,selectionScopeKey:J,archived:N.isArchivedBucket===!0,renderContext:"project",indexedNodes:ae,selectionPoolOffset:Se,baseDepth:1});for(const Xe of q.get(Fe)??[])ce(Xe,Ce)}};for(const oe of X)ce(oe,"");const le=H?t.sessionBatchSize:void 0,Re=R?.initial??le??(t.hideDirectoryControls?10:5),Oe=R?.increment??le??7,Te=Math.max(Re,t.visibleCountByContainer.get(A)??Re),De=oe=>!oo(oe)&&R?.pinnedAlwaysVisible===!0&&Ga(u,oe.session.directory??N.directory,oe.session.id),te=Mi(he,S,N.isArchivedBucket===!0),de=te.filter(oe=>!De(oe));let fe=Te;const ge=N.isArchivedBucket||d?te:te.filter(oe=>De(oe)?!0:fe<=0?!1:(fe-=1,!0)),B=ge.flatMap(oe=>oo(oe)?oe.lanes:[oe]);p({nodes:B,containerKey:A,projectId:H,groupDirectory:N.directory,ownerKey:J,selectionScopeKey:J,archived:N.isArchivedBucket===!0,renderContext:R?.renderContext??"project",indexedNodes:ae,selectionPoolOffset:Se});const Q=te.length-ge.length,ke=Te-fe;!d&&!N.isArchivedBucket&&Q>0?w({kind:"show-control",key:`${A}:more`,estimateSize:Hn,control:"more",containerKey:A,currentCount:ke,increment:Oe}):!d&&!N.isArchivedBucket&&de.length>Re&&Q===0&&w({kind:"show-control",key:`${A}:fewer`,estimateSize:Hn,control:"fewer",containerKey:A,currentCount:ke,increment:Oe});const Ie=t.groupStatusByKey.get(A);G.length===0&&Ae.length===0?Ie&&Ie.state!=="ready"?w({kind:"status",key:`${A}:status`,estimateSize:Hn,status:Ie,group:N,groupKey:A}):w({kind:"empty",key:`${A}:empty`,estimateSize:Hn,emptyKind:N.isArchivedBucket?"archived":"group",group:N,projectId:H}):Ie&&Ie.state!=="ready"&&Ie.state!=="loading"&&w({kind:"status",key:`${A}:status`,estimateSize:Hn,status:Ie,group:N,groupKey:A})},C=N=>{const A=!d&&t.collapsedActivities.has(N),H=e.length;return w({kind:"activity-header",key:`activity:${N}:header`,estimateSize:io,activityKey:N,collapsed:A,forceExpanded:d}),o.push(Object.freeze({rowIndex:H,kind:"activity",id:N})),A},k=t.viewMode==="timeline",T=N=>"run"in N,O=N=>{const A=Mi(N.map(I=>I.node),S,!1),H=new Map(N.map(I=>[I.node,I]));return A.flatMap(I=>{if(!oo(I)){const R=H.get(I);return R?[R]:[]}return[{run:I.run,items:I.lanes.flatMap(R=>H.get(R)??[])}]})},M=(N,A,H,I)=>{const R=N.items[0];if(!R)return;const P=N.items.map(re=>re.node),_=ao(P),G=r.length;r.push(..._.preorderIds);const ae=Rn(R.projectId,R.groupDirectory),Se=new Map(N.items.map(re=>[re.node.session.id,re.getSecondaryMeta?re.getSecondaryMeta(re.node.session.id):re.secondaryMeta])),J=new Map(N.items.map(re=>[re.node.session.id,re.blockingBadgeSessionScopes]));x({run:N.run,lanes:P},{nodes:P,containerKey:A,projectId:R.projectId,groupDirectory:R.groupDirectory,ownerKey:ae,selectionScopeKey:I?ae:null,archived:!1,renderContext:H,getSecondaryMeta:re=>Se.get(re)??null,getBlockingBadgeSessionScopes:re=>J.get(re),indexedNodes:_,selectionPoolOffset:G})},L=(N,A,H,I,R=()=>1)=>{for(const P of O(N)){if(T(P)){M(P,A,H,I),d&&(m+=P.items.reduce((J,re)=>J+R(re),0));continue}const _=P,G=ao([_.node]),ae=r.length;r.push(...G.preorderIds);const Se=Rn(_.projectId,_.groupDirectory);p({nodes:[_.node],containerKey:A,projectId:_.projectId,groupDirectory:_.groupDirectory,ownerKey:Se,selectionScopeKey:null,archived:!1,renderContext:H,blockingBadgeSessionScopes:_.blockingBadgeSessionScopes,secondaryMeta:_.secondaryMeta,getSecondaryMeta:_.getSecondaryMeta,indexedNodes:G,selectionPoolOffset:ae}),d&&(m+=R(_))}};t.chatGroup&&(!d||v(t.chatGroup)>0)&&(C("chats")||j(t.chatGroup,"activity:chats",null,!0,k?{initial:C2,increment:N2,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const F=t.workItems??[];if(F.length>0&&(C("work")||L(F,"activity:work",k?"timeline":"recent",!1,A=>sg(A.node,t.normalizedQuery))),k){const N=(t.timelineItems??[]).filter(A=>!f.has(A.node.session.id));N.length>0&&(C("timeline")||L(N,"activity:timeline","timeline",!1))}if(!k&&t.showRecentSection)for(const N of t.recentSections){const A={...N,items:N.items.filter(Se=>!f.has(Se.node.session.id))};if(A.items.length===0||C("active-now"))continue;const I=`activity:${A.key}`,R=7,P=Math.max(R,t.visibleCountByContainer.get(I)??R),_=O(A.items),G=d?_:_.slice(0,P);for(const Se of G){if(T(Se)){M(Se,I,"recent",!0),d&&(m+=Se.items.length);continue}const J=Se,re=ao([J.node]),ie=r.length;r.push(...re.preorderIds),p({nodes:[J.node],containerKey:I,projectId:J.projectId,groupDirectory:J.groupDirectory,ownerKey:Rn(J.projectId,J.groupDirectory),selectionScopeKey:Rn(J.projectId,J.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:J.secondaryMeta,getSecondaryMeta:J.getSecondaryMeta,indexedNodes:re,selectionPoolOffset:ie}),d&&(m+=1)}const ae=_.length-G.length;!d&&ae>0?w({kind:"show-control",key:`${I}:more`,estimateSize:Hn,control:"more",containerKey:I,currentCount:G.length,increment:7}):!d&&_.length>R&&w({kind:"show-control",key:`${I}:fewer`,estimateSize:Hn,control:"fewer",containerKey:I,currentCount:G.length,increment:7})}let D=k?[]:t.singleProjectMode?t.sections.filter(N=>N.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const N=D.find(A=>A.project.id===t.activeProjectId)??D[0];D=N?[N]:[]}for(const N of D){const A=h2(N,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!A.some(I=>v(I.group)>0))continue;const H=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(N.project.id);if(!t.showOnlyMainWorkspace){const I=e.length;w({kind:"project-header",key:`project:${N.project.id}:header`,estimateSize:io,section:N,collapsed:H,forceExpanded:d}),o.push(Object.freeze({rowIndex:I,kind:"project",id:N.project.id}))}if(!H)for(const I of A)j(I.group,I.groupKey,I.projectId,I.hideGroupLabel)}e.length===0&&w({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const U=new Map;return e.forEach((N,A)=>U.set(N.key,A)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(s),selectionDescendantIds:Object.freeze(r),rowIndexByKey:U,stickyHeaders:Object.freeze(o),folderDropTargets:Object.freeze(i),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?m:0})},lo="oc.sessions.projectCollapse",ld="oc.sessions.groupOrder",cd="oc.sessions.groupCollapse",dd=t=>{if(!t)return new Set;try{const e=ri(jn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},D2=t=>{if(!t)return new Map;try{const e=sl(jn(),ri(jn())).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}},E2=t=>{const e=Ve.c(40),{isVSCode:s,projects:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ao(),e[0]=o):o=e[0];const i=o;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>dd(i.getItem(lo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>dd(i.getItem(cd)),e[2]=u):u=e[2];const[f,m]=c.useState(u),[h,b]=c.useState(R2);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>D2(i.getItem(ld)),e[3]=g):g=e[3];const[w,S]=c.useState(g),x=c.useRef(0),p=c.useRef(!1),y=c.useRef(!1),v=c.useRef(null),j=c.useRef(null);let C;e[4]!==s?(C=()=>{if(s)return;const X=j.current;if(j.current=null,v.current=null,!X)return;const{projects:me}=Xt.getState(),he=me.map(je=>({...je,sidebarCollapsed:X.has(je.id)}));In({projects:he}).catch(T2)},e[4]=s,e[5]=C):C=e[5];const k=C;let T;e[6]!==k||e[7]!==s?(T=X=>{!globalThis.window||s||(j.current=X,v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{k()},700))},e[6]=k,e[7]=s,e[8]=T):T=e[8];const O=T;let M,L;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=()=>()=>{globalThis.window&&v.current!==null&&window.clearTimeout(v.current),v.current=null,j.current=null},L=[],e[9]=M,e[10]=L):(M=e[9],L=e[10]),c.useEffect(M,L);let F,D;e[11]!==w?(D=()=>{if(y.current)try{i.setItem(ld,JSON.stringify(Object.fromEntries(w.entries())))}catch{}},F=[w,i],e[11]=w,e[12]=F,e[13]=D):(F=e[12],D=e[13]),c.useEffect(D,F);let U,N;e[14]!==f?(U=()=>{if(p.current)try{i.setItem(cd,JSON.stringify(Array.from(f)))}catch{}},N=[f,i],e[14]=f,e[15]=U,e[16]=N):(U=e[15],N=e[16]),c.useEffect(U,N);let A;e[17]!==r||e[18]!==O?(A=()=>{x.current=Date.now()+150,p.current=!0,m(new Set),b(M2),d(()=>{const X=new Set(r.map(O2));try{i.setItem(lo,JSON.stringify(Array.from(X)))}catch{}return O(X),X})},e[17]=r,e[18]=O,e[19]=A):A=e[19];const H=A;let I;e[20]!==O?(I=()=>{x.current=Date.now()+150,p.current=!0,m(new Set),b(B2),d(()=>{const X=new Set;try{i.setItem(lo,JSON.stringify([]))}catch{}return O(X),X})},e[20]=O,e[21]=I):I=e[21];const R=I;let P;e[22]!==O?(P=X=>{x.current=Date.now()+150,d(me=>{const he=new Set(me);he.has(X)?he.delete(X):he.add(X);try{i.setItem(lo,JSON.stringify(Array.from(he)))}catch{}return O(he),he})},e[22]=O,e[23]=P):P=e[23];const _=P;let G;e[24]===Symbol.for("react.memo_cache_sentinel")?(G=X=>{p.current=!0,m(me=>{const he=new Set(me);return he.has(X)?he.delete(X):he.add(X),he})},e[24]=G):G=e[24];const ae=G;let Se;e[25]===Symbol.for("react.memo_cache_sentinel")?(Se=X=>{y.current=!0,S(X)},e[25]=Se):Se=e[25];const J=Se,{getOrderedGroups:re}=p2(w);let ie;e[26]!==h||e[27]!==f||e[28]!==a||e[29]!==w?(ie={collapsedProjects:a,collapsedGroups:f,collapsedActivities:h,groupOrderByProject:w},e[26]=h,e[27]=f,e[28]=a,e[29]=w,e[30]=ie):ie=e[30];const Be=ie;let Ae;e[31]!==H||e[32]!==R||e[33]!==re||e[34]!==O||e[35]!==_?(Ae={setCollapsedProjects:d,toggleProject:_,collapseAll:H,expandAll:R,scheduleCollapsedProjectsPersist:O,setCollapsedGroups:m,setCollapsedActivities:b,toggleGroup:ae,setGroupOrderByProject:J,getOrderedGroups:re},e[31]=H,e[32]=R,e[33]=re,e[34]=O,e[35]=_,e[36]=Ae):Ae=e[36];const K=Ae;let q;return e[37]!==K||e[38]!==Be?(q={state:Be,actions:K},e[37]=K,e[38]=Be,e[39]=q):q=e[39],q};function R2(){return new Set}function T2(){}function M2(t){return new Set([...t,...gp])}function O2(t){return t.id}function B2(t){const e=new Set(t);for(const s of gp)e.delete(s);return e}const F2=5*6e4,L2=t=>{const e=Ve.c(32),{normalizedProjects:s,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=Qs(),u=xn(_2),f=xn($2),m=c.useRef(null);let h,b;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==f||e[4]!==s||e[5]!==i?(h=()=>{if(!a||!d||s.length===0){m.current=null,i(new Map);return}let T=m.current;(!T||T.runtimeKey!==f||T.git!==d)&&(T={runtimeKey:f,git:d,paths:new Set},m.current=T);const{paths:O}=T,M=new Set(s.map(W2));for(const L of O)M.has(L)||O.delete(L);for(const L of M){if(O.has(L))continue;O.add(L);const F=()=>{const D=xn.getState().directories.get(L);D?.isGitRepo!==!1&&!D?.status&&O.delete(L)};Do(()=>u(L,d)).then(F,F)}},b=[a,s,d,f,u,i],e[0]=a,e[1]=u,e[2]=d,e[3]=f,e[4]=s,e[5]=i,e[6]=h,e[7]=b):(h=e[6],b=e[7]),c.useEffect(h,b);let g,w;e[8]!==a||e[9]!==o||e[10]!==s||e[11]!==i?(g=()=>{if(!a)return;const T=new Map;s.forEach(O=>{T.set(O.id,o.get(O.normalizedPath)?.isGitRepo??null)}),i(T)},w=[a,s,o,i],e[8]=a,e[9]=o,e[10]=s,e[11]=i,e[12]=g,e[13]=w):(g=e[12],w=e[13]),c.useEffect(g,w);let S;if(e[14]!==o||e[15]!==s){let T;e[17]!==o?(T=O=>{const M=o.get(O.normalizedPath)?.branch??"";return`${O.id}:${M}`},e[17]=o,e[18]=T):T=e[18],S=s.map(T).join("|"),e[14]=o,e[15]=s,e[16]=S}else S=e[16];const x=S;let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const y=c.useRef(p);let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=new Map,e[20]=v):v=e[20];const j=c.useRef(v);let C;e[21]!==a||e[22]!==o||e[23]!==s||e[24]!==l?(C=()=>{if(!a)return;let T=!1;const O=setTimeout(()=>{(async()=>{const L=new Set(s.map(K2));for(const H of y.current.keys())L.has(H)||(y.current.delete(H),j.current.delete(H));const F=Date.now(),D=s.filter(H=>{const I=o.get(H.normalizedPath);if(I?.isGitRepo===!1)return y.current.delete(H.id),j.current.delete(H.id),!1;if(I?.isGitRepo!==!0||I.branch===null)return!1;const R=I.branch.trim(),P=`${H.normalizedPath}\0${R}`,_=y.current.get(H.id);if(_===P){const G=j.current.get(H.id);return G&&(G.at=F),!1}return!(_!==void 0&&F-(j.current.get(H.id)?.at??0)<F2)});if(D.length===0)return;const U=await Fy(D,2,async H=>{const I=o.get(H.normalizedPath)?.branch?.trim()??"",R=`${H.normalizedPath}\0${I}`,P=await Do(()=>$u(H.normalizedPath,I?{knownBranch:I}:void 0)).catch(z2);return{id:H.id,inputKey:R,branch:P}});if(T)return;const N=U.filter(U2);if(N.length===0)return;const A=Date.now();l(H=>{const I=new Map(H);return N.forEach(R=>{const{id:P,branch:_}=R;_&&I.set(P,_)}),I}),N.forEach(H=>{const{id:I,inputKey:R,branch:P}=H;y.current.set(I,R),P&&j.current.set(I,{branch:P,at:A})})})()},150);return()=>{T=!0,clearTimeout(O)}},e[21]=a,e[22]=o,e[23]=s,e[24]=l,e[25]=C):C=e[25];let k;e[26]!==a||e[27]!==o||e[28]!==s||e[29]!==x||e[30]!==l?(k=[a,s,x,o,l],e[26]=a,e[27]=o,e[28]=s,e[29]=x,e[30]=l,e[31]=k):k=e[31],c.useEffect(C,k)};function _2(t){return t.ensureStatus}function $2(t){return t.runtimeKey}function W2(t){return t.normalizedPath}function K2(t){return t.id}function z2(){return null}function U2(t){return t.branch}const H2=t=>{const e=Ve.c(10),{open:s,onOpenChange:r,project:o,onSave:i}=t;let l;e[0]!==i||e[1]!==s||e[2]!==o?(l=s&&o?n.jsx(ng,{project:o,onIdentitySave:i,showWorktrees:!1}):null,e[0]=i,e[1]=s,e[2]=o,e[3]=l):l=e[3];let a;e[4]!==l?(a=n.jsx(Ls,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:n.jsx(Cn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:n.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==s||e[8]!==a?(d=n.jsx(_s,{open:s,onOpenChange:r,children:a}),e[6]=r,e[7]=s,e[8]=a,e[9]=d):d=e[9],d};function V2(t,e,s,r){const o=Ve.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,m=s.current;if(!u||!f||!m||r===0)return;const h=()=>{const g=f.lastElementChild,w=g?g.getBoundingClientRect().width:0,S=Number.parseFloat(getComputedStyle(f).columnGap)||0,x=Number.parseFloat(getComputedStyle(u).columnGap)||0,p=f.getBoundingClientRect().width+r*(S+w),y=u.getBoundingClientRect().right-f.getBoundingClientRect().left-m.getBoundingClientRect().width-x;l(p<=y)};h();const b=new ResizeObserver(h);return b.observe(u),b.observe(f),b.observe(m),()=>b.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 yp="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground",xp="text-muted-foreground hover:text-foreground hover:bg-transparent";function co(t){const e=Ve.c(14),{label:s,pressed:r,onClick:o,className:i,children:l}=t,a=r?yp:xp;let d;e[0]!==i||e[1]!==a?(d=xe(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(Et,{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(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:s})}),e[9]=s,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=n.jsxs(Dt,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function G2(t){const e=Ve.c(191),{t:s}=mt(),r=Zu(),{hideDirectoryControls:o,showProjectDisplayControls:i,showRecentControls:l,handleOpenDirectoryDialog:a,showSourceBoard:d,headerActionIconClass:u,headerActionButtonClass:f,isSessionSearchOpen:m,openSessionSearch:h,closeSessionSearch:b,sessionSearchInputRef:g,sessionSearchQuery:w,setSessionSearchQuery:S,hasSessionSearchQuery:x,searchMatchCount:p,collapseAll:y,expandAll:v}=t,j=c.useRef(null),C=c.useRef(null),k=c.useRef(null),T=V2(j,C,k,r.length),O=bs(fC),M=bs(uC),L=be(dC),F=be(cC),D=be(lC),U=be(aC),N=ms(iC),A=ms(oC),H=ms(rC),I=ms(nC),R=ms(sC),P=ms(tC),_=ms(eC),G=ms(Z2),ae=ms(J2),Se=ms(X2),J=ms(Q2),re=ms(Y2),ie=i&&J==="single",Be=i&&ae==="timeline";if(o){let V;e[0]!==s?(V=s("sessions.sidebar.header.search.placeholder"),e[0]=s,e[1]=V):V=e[1];let Ne;e[2]!==s?(Ne=s("sessions.sidebar.header.search.clear"),e[2]=s,e[3]=Ne):Ne=e[3];let We;e[4]!==x||e[5]!==p||e[6]!==s?(We=x?p===1?s("sessions.sidebar.header.search.matchCountSingle",{count:p}):s("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,e[4]=x,e[5]=p,e[6]=s,e[7]=We):We=e[7];let Ge;e[8]!==s?(Ge=s("sessions.sidebar.header.search.escapeHint"),e[8]=s,e[9]=Ge):Ge=e[9];let qe;return e[10]!==b||e[11]!==g||e[12]!==w||e[13]!==S||e[14]!==V||e[15]!==Ne||e[16]!==We||e[17]!==Ge?(qe=n.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1.5",children:n.jsx(Hl,{inputRef:g,value:w,onSearch:S,onClose:b,placeholder:V,clearLabel:Ne,leadingHint:We,trailingHint:Ge})}),e[10]=b,e[11]=g,e[12]=w,e[13]=S,e[14]=V,e[15]=Ne,e[16]=We,e[17]=Ge,e[18]=qe):qe=e[18],qe}let Ae;e[19]!==f||e[20]!==u||e[21]!==L||e[22]!==d||e[23]!==s?(Ae=d?n.jsx(co,{label:s("sourceBoard.title"),pressed:L,onClick:()=>be.getState().setSourceBoardOpen(!L),className:f,children:n.jsx($,{name:"todo",className:u})}):null,e[19]=f,e[20]=u,e[21]=L,e[22]=d,e[23]=s,e[24]=Ae):Ae=e[24];let K;e[25]!==s?(K=s("sessions.sidebar.header.actions.scheduledTasks"),e[25]=s,e[26]=K):K=e[26];let q;e[27]!==F?(q=()=>be.getState().setScheduledTasksDialogOpen(!F),e[27]=F,e[28]=q):q=e[28];let X;e[29]!==u?(X=n.jsx($,{name:"calendar-schedule",className:u}),e[29]=u,e[30]=X):X=e[30];let me;e[31]!==f||e[32]!==F||e[33]!==K||e[34]!==q||e[35]!==X?(me=n.jsx(co,{label:K,pressed:F,onClick:q,className:f,children:X}),e[31]=f,e[32]=F,e[33]=K,e[34]=q,e[35]=X,e[36]=me):me=e[36];let he;e[37]!==s?(he=s("sessions.sidebar.nav.archive"),e[37]=s,e[38]=he):he=e[38];let je;e[39]!==D?(je=()=>be.getState().setArchivePageOpen(!D),e[39]=D,e[40]=je):je=e[40];let Y;e[41]!==u?(Y=n.jsx($,{name:"archive",className:u}),e[41]=u,e[42]=Y):Y=e[42];let ue;e[43]!==f||e[44]!==D||e[45]!==he||e[46]!==je||e[47]!==Y?(ue=n.jsx(co,{label:he,pressed:D,onClick:je,className:f,children:Y}),e[43]=f,e[44]=D,e[45]=he,e[46]=je,e[47]=Y,e[48]=ue):ue=e[48];let we;e[49]!==Ae||e[50]!==me||e[51]!==ue?(we=n.jsxs("div",{ref:C,className:"flex items-center gap-1.5",children:[Ae,me,ue]}),e[49]=Ae,e[50]=me,e[51]=ue,e[52]=we):we=e[52];let ce;e[53]!==r||e[54]!==T||e[55]!==f||e[56]!==u||e[57]!==U||e[58]!==s?(ce=T?r.map(V=>{const Ne=U===V.id;return n.jsx(co,{label:V.pageTitle??V.name,pressed:Ne,onClick:()=>be.getState().setOpenGuestPage(Ne?null:V.id),className:f,children:n.jsx(vr,{icon:tf(V.icon),iconSrc:ef(V.id,V.icon,nu().authenticatedAsset),className:u})},V.id)}):r.length>0&&n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsx(ft,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":s("sessions.sidebar.header.actions.extensionPages"),children:n.jsx($,{name:"puzzle",className:u})})}),n.jsxs(As,{align:"start",children:[n.jsx(ir,{children:s("sessions.sidebar.header.actions.extensionPages")}),r.map(q2)]})]}),e[53]=r,e[54]=T,e[55]=f,e[56]=u,e[57]=U,e[58]=s,e[59]=ce):ce=e[59];let le;e[60]!==ce||e[61]!==we?(le=n.jsxs("div",{className:"ml-[3px] flex min-w-0 items-center gap-1.5",children:[we,ce]}),e[60]=ce,e[61]=we,e[62]=le):le=e[62];const Re=m?b:h,Oe=m?yp:xp;let Te;e[63]!==f||e[64]!==Oe?(Te=xe(f,Oe),e[63]=f,e[64]=Oe,e[65]=Te):Te=e[65];let De;e[66]!==s?(De=s("sessions.sidebar.header.actions.searchSessions"),e[66]=s,e[67]=De):De=e[67];let te;e[68]!==u?(te=n.jsx($,{name:"search",className:u}),e[68]=u,e[69]=te):te=e[69];let de;e[70]!==m||e[71]!==Re||e[72]!==Te||e[73]!==De||e[74]!==te?(de=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Re,className:Te,"aria-label":De,"aria-expanded":m,children:te})}),e[70]=m,e[71]=Re,e[72]=Te,e[73]=De,e[74]=te,e[75]=de):de=e[75];let fe;e[76]!==s?(fe=s("sessions.sidebar.header.actions.searchSessions"),e[76]=s,e[77]=fe):fe=e[77];let ge;e[78]!==fe?(ge=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:fe})}),e[78]=fe,e[79]=ge):ge=e[79];let B;e[80]!==de||e[81]!==ge?(B=n.jsxs(Dt,{children:[de,ge]}),e[80]=de,e[81]=ge,e[82]=B):B=e[82];let Q;e[83]!==f?(Q=xe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[83]=f,e[84]=Q):Q=e[84];let ke;e[85]!==s?(ke=s("sessions.sidebar.header.actions.addProject"),e[85]=s,e[86]=ke):ke=e[86];let Ie;e[87]!==u?(Ie=n.jsx($,{name:"folder-add",className:u}),e[87]=u,e[88]=Ie):Ie=e[88];let oe;e[89]!==a||e[90]!==Q||e[91]!==ke||e[92]!==Ie?(oe=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:a,className:Q,"aria-label":ke,children:Ie})}),e[89]=a,e[90]=Q,e[91]=ke,e[92]=Ie,e[93]=oe):oe=e[93];let $e;e[94]!==s?($e=s("sessions.sidebar.header.actions.addProject"),e[94]=s,e[95]=$e):$e=e[95];let Fe;e[96]!==$e?(Fe=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:$e})}),e[96]=$e,e[97]=Fe):Fe=e[97];let Ce;e[98]!==oe||e[99]!==Fe?(Ce=n.jsxs(Dt,{children:[oe,Fe]}),e[98]=oe,e[99]=Fe,e[100]=Ce):Ce=e[100];let Ue;e[101]!==f?(Ue=xe(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[101]=f,e[102]=Ue):Ue=e[102];let pe;e[103]!==s?(pe=s("sessions.sidebar.header.displayMode.label"),e[103]=s,e[104]=pe):pe=e[104];let ne;e[105]!==u?(ne=n.jsx($,{name:"equalizer-2",className:u}),e[105]=u,e[106]=ne):ne=e[106];let Me;e[107]!==Ue||e[108]!==pe||e[109]!==ne?(Me=n.jsx(Et,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:Ue,"aria-label":pe,children:ne})})}),e[107]=Ue,e[108]=pe,e[109]=ne,e[110]=Me):Me=e[110];let He;e[111]!==s?(He=s("sessions.sidebar.header.displayMode.label"),e[111]=s,e[112]=He):He=e[112];let Ye;e[113]!==He?(Ye=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:He})}),e[113]=He,e[114]=Ye):Ye=e[114];let Xe;e[115]!==Me||e[116]!==Ye?(Xe=n.jsxs(Dt,{children:[Me,Ye]}),e[115]=Me,e[116]=Ye,e[117]=Xe):Xe=e[117];let Je;e[118]!==Se||e[119]!==i||e[120]!==ae||e[121]!==s||e[122]!==Be?(Je=i?n.jsxs(n.Fragment,{children:[n.jsx(ir,{children:s("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(V=>{const[Ne,We]=V;return n.jsxs(Gt,{onClick:()=>{Se(Ne),In({sidebarViewMode:Ne})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(We)}),ae===Ne?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]},Ne)}),Be?null:n.jsx(Cs,{})]}):null,e[118]=Se,e[119]=i,e[120]=ae,e[121]=s,e[122]=Be,e[123]=Je):Je=e[123];let bt;e[124]!==J||e[125]!==R||e[126]!==re||e[127]!==P||e[128]!==G||e[129]!==i||e[130]!==s||e[131]!==Be||e[132]!==_?(bt=Be?null:n.jsxs(n.Fragment,{children:[n.jsx(ir,{children:s("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(V=>{const[Ne,We]=V;return n.jsxs(Gt,{onClick:()=>{P(Ne),In({sidebarProjectSortOrder:Ne})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(We)}),R===Ne?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]},Ne)}),n.jsx(Cs,{}),i?n.jsxs(n.Fragment,{children:[n.jsx(ir,{children:s("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(V=>{const[Ne,We]=V;return n.jsxs(Gt,{onClick:()=>{G(Ne),In({sidebarWorktreeSortOrder:Ne})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(We)}),_===Ne?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]},Ne)}),n.jsx(Cs,{})]}):null,i?n.jsxs(n.Fragment,{children:[n.jsx(ir,{children:s("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(V=>{const[Ne,We]=V;return n.jsxs(Gt,{onClick:()=>{re(Ne),In({sidebarProjectDisplayMode:Ne})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s(We)}),J===Ne?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]},Ne)}),n.jsx(Cs,{})]}):null]}),e[124]=J,e[125]=R,e[126]=re,e[127]=P,e[128]=G,e[129]=i,e[130]=s,e[131]=Be,e[132]=_,e[133]=bt):bt=e[133];let et;e[134]!==I||e[135]!==H||e[136]!==l||e[137]!==s?(et=l?n.jsxs(Gt,{onClick:()=>{I(!H),In({sidebarShowChatsSection:!H})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s("sessions.sidebar.header.displayMode.showChats")}),H?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[134]=I,e[135]=H,e[136]=l,e[137]=s,e[138]=et):et=e[138];let lt;e[139]!==ie||e[140]!==l||e[141]!==N||e[142]!==s||e[143]!==Be||e[144]!==A?(lt=!Be&&l&&!ie?n.jsxs(Gt,{onClick:()=>{A(),In({sidebarShowRecentSection:!N})},className:"flex items-center justify-between",children:[n.jsx("span",{children:s("sessions.sidebar.header.displayMode.showRecent")}),N?n.jsx($,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[139]=ie,e[140]=l,e[141]=N,e[142]=s,e[143]=Be,e[144]=A,e[145]=lt):lt=e[145];let xt;e[146]!==y||e[147]!==v||e[148]!==ie||e[149]!==s||e[150]!==Be?(xt=!Be&&!ie?n.jsxs(n.Fragment,{children:[n.jsx(Cs,{}),n.jsxs(Gt,{onClick:y,className:"flex items-center gap-2",children:[n.jsx($,{name:"contract-up-down",className:"h-4 w-4"}),n.jsx("span",{children:s("sessions.sidebar.header.displayMode.collapseAll")})]}),n.jsxs(Gt,{onClick:v,className:"flex items-center gap-2",children:[n.jsx($,{name:"expand-up-down",className:"h-4 w-4"}),n.jsx("span",{children:s("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[146]=y,e[147]=v,e[148]=ie,e[149]=s,e[150]=Be,e[151]=xt):xt=e[151];let wt;e[152]===Symbol.for("react.memo_cache_sentinel")?(wt=n.jsx(Cs,{}),e[152]=wt):wt=e[152];let dt;e[153]===Symbol.for("react.memo_cache_sentinel")?(dt=n.jsx($,{name:"checkbox-multiple",className:"h-4 w-4"}),e[153]=dt):dt=e[153];let It;e[154]!==O||e[155]!==s?(It=s(O?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[154]=O,e[155]=s,e[156]=It):It=e[156];let _t;e[157]!==It?(_t=n.jsx("span",{children:It}),e[157]=It,e[158]=_t):_t=e[158];let Bt;e[159]!==_t||e[160]!==M?(Bt=n.jsxs(Gt,{onClick:M,className:"flex items-center gap-2",children:[dt,_t]}),e[159]=_t,e[160]=M,e[161]=Bt):Bt=e[161];let ye;e[162]!==Je||e[163]!==bt||e[164]!==et||e[165]!==lt||e[166]!==xt||e[167]!==Bt?(ye=n.jsxs(As,{align:"end",className:"min-w-[180px]",children:[Je,bt,et,lt,xt,wt,Bt]}),e[162]=Je,e[163]=bt,e[164]=et,e[165]=lt,e[166]=xt,e[167]=Bt,e[168]=ye):ye=e[168];let z;e[169]!==Xe||e[170]!==ye?(z=n.jsxs(Ps,{children:[Xe,ye]}),e[169]=Xe,e[170]=ye,e[171]=z):z=e[171];let W;e[172]!==B||e[173]!==Ce||e[174]!==z?(W=n.jsxs("div",{ref:k,className:"flex min-w-0 items-center gap-1.5",children:[B,Ce,z]}),e[172]=B,e[173]=Ce,e[174]=z,e[175]=W):W=e[175];let Z;e[176]!==le||e[177]!==W?(Z=n.jsxs("div",{ref:j,className:"flex min-h-8 flex-wrap items-center justify-between gap-2",children:[le,W]}),e[176]=le,e[177]=W,e[178]=Z):Z=e[178];let ve;e[179]!==b||e[180]!==x||e[181]!==m||e[182]!==p||e[183]!==g||e[184]!==w||e[185]!==S||e[186]!==s?(ve=m?n.jsx("div",{className:"pb-1",children:n.jsx(Hl,{inputRef:g,value:w,onSearch:S,onClose:b,placeholder:s("sessions.sidebar.header.search.placeholder"),clearLabel:s("sessions.sidebar.header.search.clear"),leadingHint:x?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[179]=b,e[180]=x,e[181]=m,e[182]=p,e[183]=g,e[184]=w,e[185]=S,e[186]=s,e[187]=ve):ve=e[187];let E;return e[188]!==Z||e[189]!==ve?(E=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:[Z,ve]})}),e[188]=Z,e[189]=ve,e[190]=E):E=e[190],E}function q2(t){return n.jsxs(Gt,{onSelect:()=>be.getState().setOpenGuestPage(t.id),children:[n.jsx(vr,{icon:tf(t.icon),iconSrc:ef(t.id,t.icon,nu().authenticatedAsset),className:"size-4"}),n.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function Y2(t){return t.setProjectDisplayMode}function Q2(t){return t.projectDisplayMode}function X2(t){return t.setSidebarViewMode}function J2(t){return t.sidebarViewMode}function Z2(t){return t.setWorktreeSortOrder}function eC(t){return t.worktreeSortOrder}function tC(t){return t.setProjectSortOrder}function sC(t){return t.projectSortOrder}function nC(t){return t.setShowChatsSection}function rC(t){return t.showChatsSection}function oC(t){return t.toggleRecentSection}function iC(t){return t.showRecentSection}function aC(t){return t.openGuestPageId}function lC(t){return t.isArchivePageOpen}function cC(t){return t.isScheduledTasksDialogOpen}function dC(t){return t.isSourceBoardOpen}function uC(t){return t.toggleMode}function fC(t){return t.enabled}const uo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",pC="bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-selection hover:text-interactive-selection-foreground";function mC(t){const e=Ve.c(15),{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}=mt(),m=rg(),h=be(hC);if(!d&&!u)return null;let b;e[0]!==h||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==d||e[5]!==f?(b=d?n.jsxs(n.Fragment,{children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:s,className:uo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:n.jsx($,{name:"settings-3",className:"h-4.5 w-4.5"})})}),n.jsx(Pt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:()=>be.getState().setUsageStatsPageOpen(!h),className:xe(uo,h&&pC),"aria-label":f("usageStats.openAction"),"aria-pressed":h,children:n.jsx($,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),n.jsx(Pt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("usageStats.openAction")})})]}),n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:r,className:uo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:n.jsx($,{name:"command",className:"h-4.5 w-4.5"})})}),n.jsx(Pt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:o,className:uo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:n.jsx($,{name:"information",className:"h-4.5 w-4.5"})})}),n.jsx(Pt,{side:"top",sideOffset:4,children:n.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=h,e[1]=o,e[2]=s,e[3]=r,e[4]=d,e[5]=f,e[6]=b):b=e[6];let g;e[7]!==m||e[8]!==i||e[9]!==u||e[10]!==f?(g=u?n.jsx(ft,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:i,children:f(m?"sessions.sidebar.footer.actions.updateApp":"sessions.sidebar.footer.actions.update")}):null,e[7]=m,e[8]=i,e[9]=u,e[10]=f,e[11]=g):g=e[11];let w;return e[12]!==b||e[13]!==g?(w=n.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[b,g]}),e[12]=b,e[13]=g,e[14]=w):w=e[14],w}function hC(t){return t.isUsageStatsPageOpen}function gC(t){const e=Ve.c(19),{query:s,showArchive:r,resetSessionSearch:o}=t,{t:i}=mt();let l;e[0]!==s||e[1]!==o?(l=()=>{be.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 m;e[9]!==f?(m=n.jsx("p",{className:"typography-meta mt-1",children:f}),e[9]=f,e[10]=m):m=e[10];let h;e[11]!==a||e[12]!==r||e[13]!==i?(h=r?n.jsx(ft,{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]=h):h=e[14];let b;return e[15]!==u||e[16]!==m||e[17]!==h?(b=n.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[u,m,h]}),e[15]=u,e[16]=m,e[17]=h,e[18]=b):b=e[18],b}const bC=t=>{for(const e of t.sessions.values())if(e.tabs.some(ru))return!0;return!1},yC=()=>{const t=Ve.c(4),{terminal:e}=Qs(),s=Ot(bC);let r,o;return t[0]!==s||t[1]!==e?(r=()=>{const i=xC,l=vC;if(s)return Ui(e,"",l,i);let a=SC;return a=Ui(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 xC(t){const e=Ot.getState(),s=og(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 vC(){return new Map(Ot.getState().actionMutationRevisions)}function SC(){}const wC=50,jC=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===wC))break}return[...e.values()]},kC=t=>{const e=Ve.c(12),{normalizedProjects:s,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:f,addSessionToFolder:m}=t,h=r===void 0?!0:r;let b,g;e[0]!==m||e[1]!==f||e[2]!==h||e[3]!==u||e[4]!==l||e[5]!==i||e[6]!==a||e[7]!==s||e[8]!==o||e[9]!==d?(b=()=>{!h||i||!l||a||s.forEach(w=>{if(d.has(w.normalizedPath))return;const S=sf(w.normalizedPath),x=o.archivedSessionsByProject.get(w.id)??[],p=u[S]??[],y=new Map(p.map(CC));x.forEach(v=>{const j=Ly(v,w.normalizedPath),C=j.toLowerCase();let k=y.get(C);k||(k=f(S,j),y.set(C,k)),k.sessionIds.includes(v.id)||m(S,k.id,v.id)})})},g=[s,h,o,i,l,a,d,u,f,m],e[0]=m,e[1]=f,e[2]=h,e[3]=u,e[4]=l,e[5]=i,e[6]=a,e[7]=s,e[8]=o,e[9]=d,e[10]=b,e[11]=g):(b=e[10],g=e[11]),c.useEffect(b,g)};function CC(t){return[t.name.toLowerCase(),t]}function NC({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,m])=>f!==t&&m.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 AC=t=>{const e=Ve.c(26),{projectSections:s,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:f,openNewSessionDraft:m,setSessionSwitcherOpen:h}=t;let b,g;if(e[0]!==s){g=new Map,b=new Map;const C=(k,T,O,M)=>{g.has(k)||g.set(k,new Map);const L=g.get(k);M.forEach(F=>{const D=ot(F.worktree?.path??F.session.directory??O??T);L.set(F.session.id,{directory:D}),b.has(k)||b.set(k,{id:F.session.id,directory:D}),F.children.length>0&&C(k,T,D,F.children)})};s.forEach(k=>{k.groups.forEach(T=>{C(k.project.id,k.project.normalizedPath,T.directory,T.sessions)})}),e[0]=s,e[1]=b,e[2]=g}else b=e[1],g=e[2];let w;e[3]!==b||e[4]!==g?(w={metaByProject:g,firstSessionByProject:b},e[3]=b,e[4]=g,e[5]=w):w=e[5];const S=w,x=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]!==m||e[14]!==s||e[15]!==S||e[16]!==i||e[17]!==h?(p=()=>{if(!r||u||be.getState().isNewWorktreeDialogOpen||x.current===r)return;const C=s.find(M=>M.project.id===r);if(!C)return;if(x.current===null){x.current=r;return}const k=S.metaByProject.get(r);if(l&&k&&k.has(l)){x.current=r,i(M=>{if(M.get(r)===l)return M;const L=new Map(M);return L.set(r,l),L});return}const T=NC({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:k,metaByProject:S.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:S.firstSessionByProject.get(r)?.id??null});if(T.kind==="preserve-current"){a===r&&(x.current=r);return}if(x.current=r,T.kind==="open-draft"){f&&h(!1),m({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(T.kind!=="select-session")return;const O=k?.get(T.sessionId)?.directory??null;d(T.sessionId,O)},y=[r,o,l,a,d,u,f,m,s,S,h,i],e[6]=r,e[7]=o,e[8]=l,e[9]=a,e[10]=d,e[11]=f,e[12]=u,e[13]=m,e[14]=s,e[15]=S,e[16]=i,e[17]=h,e[18]=p,e[19]=y):(p=e[18],y=e[19]),c.useLayoutEffect(p,y);let v,j;e[20]!==r||e[21]!==l||e[22]!==S||e[23]!==i?(v=()=>{if(!r||!l)return;const C=S.metaByProject.get(r);!C||!C.has(l)||i(k=>{if(k.get(r)===l)return k;const T=new Map(k);return T.set(r,l),T})},j=[r,l,S,i],e[20]=r,e[21]=l,e[22]=S,e[23]=i,e[24]=v,e[25]=j):(v=e[24],j=e[25]),c.useEffect(v,j)},PC=t=>{const e=Ve.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=Ze(IC),a=Ze(DC);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[m,h]=c.useState(f);let b;e[10]!==m||e[11]!==s||e[12]!==l||e[13]!==u||e[14]!==a?(b={...s,activeSessionByProject:m,setActiveSessionByProject:h,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=m,e[11]=s,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],AC(b);let g,w;return e[16]!==m||e[17]!==o?(g=()=>{o(m)},w=[m,o],e[16]=m,e[17]=o,e[18]=g,e[19]=w):(g=e[18],w=e[19]),c.useEffect(g,w),null};function IC(t){return t.currentSessionId}function DC(t){return!!t.newSessionDraft?.open}const EC=t=>{const e=Ve.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},RC=(t,e)=>t.map(s=>{const r=ot(s.path)??s.path;return`${r}=${e.get(r)??""}`}).join(`
987
+ `),TC=[],MC=t=>{const{normalizedProjects:e,getSessionsForProject:s,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:f,normalizedSessionSearchQuery:m,filterSessionNodesForSearch:h,buildGroupSearchText:b,foldersMap:g,standaloneGroups:w}=t,S=c.useRef(new Map),x=c.useMemo(()=>{const O=S.current,M=new Map;let L=0,F=0;const D=(N,A)=>N.length===A.length&&N.every((H,I)=>H===A[I]),U=e.map(N=>{const A=s(N.id),H=r(N.id),I=o.get(N.normalizedPath)??TC,R=i.has(N.id)?!!i.get(N.id):d,P=l.get(N.id)??null,_=RC(I,a),G=O.get(N.id);if(G&&G.project===N&&D(G.activeSessions,A)&&D(G.archivedSessions,H)&&G.availableWorktrees===I&&G.rootBranch===P&&G.worktreeBranchesKey===_&&G.isRepo===R&&G.buildGroupedSessions===u)return L+=1,M.set(N.id,G),G.section;if(F+=1,G){const re=G.project!==N?"project":D(G.activeSessions,A)?D(G.archivedSessions,H)?G.availableWorktrees!==I?"worktrees":G.rootBranch!==P?"branch":G.worktreeBranchesKey!==_?"worktreeBranches":G.isRepo!==R?"repo":"builder":"archived":"sessions";Os(`ui.sidebar.project_section.rebuilt_reason.${re}`)}const ae=nf([...A,...H]),Se=u(ae,N.normalizedPath,I,P,R),J={project:N,groups:Se};return M.set(N.id,{project:N,activeSessions:A,archivedSessions:H,availableWorktrees:I,rootBranch:P,worktreeBranchesKey:_,isRepo:R,buildGroupedSessions:u,section:J}),J});return S.current=M,L>0&&Os("ui.sidebar.project_section.reused",L),F>0&&Os("ui.sidebar.project_section.rebuilt",F),U},[e,s,r,o,i,d,u,l,a]),p=c.useMemo(()=>x,[x]),y=c.useMemo(()=>{const O=new WeakMap;if(!f)return O;const L=m.trim().toLowerCase().startsWith("ses_"),F=D=>{const U=h(D.sessions,m),N=bp(U,m),A=!L&&Io([b(D)],m),H=Lr(D).flatMap(({scopeKey:R})=>g[R]??[]),I=L?0:H.filter(R=>Io([R.name],m)).length;O.set(D,{filteredNodes:U,matchedSessionCount:N,folderNameMatchCount:I,groupMatches:A,hasMatch:A||N>0||I>0})};return p.forEach(D=>{D.groups.forEach(F)}),w.forEach(F),O},[f,p,w,h,m,b,g]),v=c.useMemo(()=>f?p.map(O=>({...O,groups:O.groups.filter(M=>y.get(M)?.hasMatch===!0)})).filter(O=>O.groups.length>0):p,[f,p,y]),j=f?v:p,C=c.useRef(new WeakMap),k=c.useMemo(()=>{const O=C.current;return j.map(M=>{const L=O.get(M);if(L&&L.query===m)return L.section;const F=M.groups.filter(R=>!R.isArchivedBucket),D=M.groups.filter(R=>R.isArchivedBucket),U=F.flatMap(R=>f?y.get(R)?.filteredNodes??[]:R.sessions),N=F.map(R=>({scopeKey:R.folderScopeKey??ot(R.directory??null),directory:R.directory??null})).filter(R=>!!R.scopeKey),A=F.find(R=>R.isMain)??null,H={id:"flat",label:A?.label??"",branch:A?.branch??null,description:A?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:A?.directory??M.project.normalizedPath,folderScopeKey:A?.folderScopeKey??M.project.normalizedPath,folderScopes:N,sessions:U};if(f){const R=F.map(P=>y.get(P)).filter(P=>!!P);y.set(H,{filteredNodes:U,matchedSessionCount:R.reduce((P,_)=>P+_.matchedSessionCount,0),folderNameMatchCount:R.reduce((P,_)=>P+_.folderNameMatchCount,0),groupMatches:R.some(P=>P.groupMatches),hasMatch:R.some(P=>P.hasMatch)})}const I={project:M.project,groups:[H,...D]};return O.set(M,{query:m,section:I}),I})},[y,f,m,j]),T=c.useMemo(()=>{if(!f)return 0;const O=(L,F)=>{const D=y.get(F);if(!D)return L;const U=D.folderNameMatchCount+(D.groupMatches?1:0);return L+D.matchedSessionCount+U},M=j.reduce((L,F)=>F.groups.reduce(O,L),0);return w.reduce(O,M)},[f,j,w,y]);return{projectSections:x,visibleProjectSections:p,groupSearchDataByGroup:y,searchableProjectSections:v,sectionsForRender:j,flatSectionsForRender:k,searchMatchCount:T}},OC=180,ud=150,BC=2,FC=8,fd=[-1,1],Oi=t=>`${t.directory}
988
+ ${t.sessionId}`,LC=t=>t?.directory?.trim()||null,_C=({enabled:t=!0,currentSessionId:e,sortedSessions:s,recentSessions:r=[],prefetchSession:o})=>{const i=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>qs(),[]),f=c.useCallback(()=>{d.current+=1,l.current=[],i.current.forEach(b=>window.clearTimeout(b)),i.current.clear()},[]),m=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<BC&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==d.current||Ze.getState().currentSessionId===b.sessionId||Ji(b.sessionId,b.directory).renderable)continue;const w=Oi(b);a.current.add(w),o({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(w),m()})}},[t,u,o]),h=c.useCallback(b=>{const g=b?.id,w=LC(b);if(!t||u||!g||!w||g===e)return;const S={sessionId:g,directory:w,generation:d.current},x=Oi(S);if(Ji(g,w).renderable||a.current.has(x)||l.current.some(v=>Oi(v)===x))return;const p=i.current.get(x);p!==void 0&&window.clearTimeout(p);const y=window.setTimeout(()=>{if(i.current.delete(x),S.generation!==d.current)return;const v=l.current;v.length>=FC&&v.shift(),v.push(S),m()},OC);i.current.set(x,y)},[e,t,u,m]);c.useEffect(()=>{f()},[f,e,t,u]),c.useEffect(()=>{if(!t||u||!e||s.length===0)return;const b=window.setTimeout(()=>{const g=s.findIndex(w=>w.id===e);if(!(g<0))for(const w of fd)h(s[g+w])},ud);return()=>window.clearTimeout(b)},[e,t,u,h,s]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const b=window.setTimeout(()=>{const g=r.findIndex(w=>w.id===e);if(!(g<0))for(const w of fd)h(r[g+w])},ud);return()=>window.clearTimeout(b)},[e,t,u,r,h]),c.useEffect(()=>f,[f])},$C=t=>{const e=Ve.c(3),s=Ze(WC);let r;return e[0]!==t||e[1]!==s?(r={...t,currentSessionId:s},e[0]=t,e[1]=s,e[2]=r):r=e[2],_C(r),null};function WC(t){return t.currentSessionId}const KC=t=>{const e=Ve.c(83),{folder:s,displayName:r,sessions:o,subFolderItems:i,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:f,children:m,renderBody:h,mobileVariant:b,alwaysShowActions:g,isRenaming:w,renameDraft:S,onRenameDraftChange:x,onRenameSave:p,onRenameCancel:y,droppableRef:v,isDropTarget:j,onNewSession:C,depth:k,hideActions:T,archivedBucket:O}=t,M=a===void 0?null:a,L=h===void 0?!0:h,D=g===void 0?b===void 0?!1:b:g,U=w===void 0?!1:w,N=S===void 0?"":S,A=j===void 0?!1:j,H=T===void 0?!1:T,I=O===void 0?!1:O,{t:R}=mt(),[P,_]=c.useState(!1),[G,ae]=c.useState(""),Se=c.useRef(null),J=U||P,re=U?N:G;let ie;e[0]!==s.name?(ie=()=>{ae(s.name),_(!0)},e[0]=s.name,e[1]=ie):ie=e[1];const Be=ie;let Ae;e[2]!==re||e[3]!==s.name||e[4]!==U||e[5]!==u||e[6]!==p?(Ae=()=>{const Ce=re.trim();Ce&&Ce!==s.name&&u(Ce),U&&p&&p(),_(!1),ae("")},e[2]=re,e[3]=s.name,e[4]=U,e[5]=u,e[6]=p,e[7]=Ae):Ae=e[7];const K=Ae;let q;e[8]!==U||e[9]!==y?(q=()=>{U&&y&&y(),_(!1),ae("")},e[8]=U,e[9]=y,e[10]=q):q=e[10];const X=q;let me;e[11]!==U||e[12]!==x?(me=Ce=>{U&&x?x(Ce):ae(Ce)},e[11]=U,e[12]=x,e[13]=me):me=e[13];const he=me;let je,Y;e[14]!==U?(je=()=>{if(!U)return;const Ce=()=>{const ne=Se.current;ne&&(ne.focus(),ne.select())},Ue=requestAnimationFrame(Ce),pe=window.setTimeout(Ce,0);return()=>{cancelAnimationFrame(Ue),window.clearTimeout(pe)}},Y=[U],e[14]=U,e[15]=je,e[16]=Y):(je=e[15],Y=e[16]),c.useEffect(je,Y);const ue=l?"folder":"folder-open",we=A&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ce;e[17]!==we?(ce=xe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",we),e[17]=we,e[18]=ce):ce=e[18];let le;e[19]!==d||e[20]!==J?(le=J?void 0:Ce=>{Ce.currentTarget.blur(),d()},e[19]=d,e[20]=J,e[21]=le):le=e[21];const Re=J?void 0:"button",Oe=J?void 0:0;let Te;e[22]!==d||e[23]!==J?(Te=J?void 0:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),d())},e[22]=d,e[23]=J,e[24]=Te):Te=e[24];let De;e[25]!==s.name||e[26]!==l||e[27]!==R?(De=l?R("sessions.sidebar.folderItem.expandAria",{folderName:s.name}):R("sessions.sidebar.folderItem.collapseAria",{folderName:s.name}),e[25]=s.name,e[26]=l,e[27]=R,e[28]=De):De=e[28];const te=I?D?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":D?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let de;e[29]!==te?(de=xe("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1",te),e[29]=te,e[30]=de):de=e[30];const fe=A?"text-primary":"text-muted-foreground";let ge;e[31]!==fe?(ge=xe("h-3.5 w-3.5 flex-shrink-0",fe),e[31]=fe,e[32]=ge):ge=e[32];let B;e[33]!==ue||e[34]!==ge?(B=n.jsx($,{name:ue,className:ge}),e[33]=ue,e[34]=ge,e[35]=B):B=e[35];let Q;e[36]!==M||e[37]!==r||e[38]!==re||e[39]!==s.name||e[40]!==X||e[41]!==he||e[42]!==K||e[43]!==l||e[44]!==A||e[45]!==J||e[46]!==o||e[47]!==R?(Q=J?n.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:zC,onMouseDown:UC,onSubmit:Ce=>{Ce.preventDefault(),K()},children:[n.jsx("input",{ref:Se,value:re,onChange:Ce=>he(Ce.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:R("sessions.sidebar.folderItem.namePlaceholder"),onClick:HC,onPointerDown:VC,onMouseDown:GC,onKeyDown:Ce=>{if(Ce.key==="Escape"){Ce.stopPropagation(),X();return}(Ce.key===" "||Ce.key==="Enter")&&Ce.stopPropagation()}}),n.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:qC,onPointerDown:YC,onMouseDown:QC,children:n.jsx($,{name:"check",className:"size-4"})}),n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),X()},onPointerDown:XC,onMouseDown:JC,className:"shrink-0 text-muted-foreground hover:text-foreground",children:n.jsx($,{name:"close",className:"size-4"})})]}):n.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("span",{className:xe("typography-ui-label font-semibold truncate",A?"text-primary":"text-muted-foreground"),children:r??s.name})}),n.jsx(Pt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??s.name})]}),n.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",o.length]}),M?n.jsx(ig,{state:M}):null,l?n.jsx($,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx($,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=M,e[37]=r,e[38]=re,e[39]=s.name,e[40]=X,e[41]=he,e[42]=K,e[43]=l,e[44]=A,e[45]=J,e[46]=o,e[47]=R,e[48]=Q):Q=e[48];let ke;e[49]!==de||e[50]!==B||e[51]!==Q?(ke=n.jsxs("div",{className:de,children:[B,Q]}),e[49]=de,e[50]=B,e[51]=Q,e[52]=ke):ke=e[52];let Ie;e[53]!==D||e[54]!==I||e[55]!==s.name||e[56]!==Be||e[57]!==H||e[58]!==f||e[59]!==C||e[60]!==J||e[61]!==R?(Ie=!J&&(!H||I)?n.jsx("div",{className:xe("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",D?"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:[!I&&C?n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),C()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":R("sessions.sidebar.folderItem.newSessionAria",{folderName:s.name}),title:R("sessions.sidebar.project.actions.newSession"),children:n.jsx($,{name:"add",className:"h-3.5 w-3.5"})}):null,I?null:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),Be()},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":R("sessions.sidebar.folderItem.renameAria",{folderName:s.name}),children:n.jsx($,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),n.jsx("button",{type:"button",onClick:Ce=>{Ce.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":I?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:s.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:s.name}),children:n.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=D,e[54]=I,e[55]=s.name,e[56]=Be,e[57]=H,e[58]=f,e[59]=C,e[60]=J,e[61]=R,e[62]=Ie):Ie=e[62];let oe;e[63]!==v||e[64]!==ce||e[65]!==le||e[66]!==Re||e[67]!==Oe||e[68]!==Te||e[69]!==De||e[70]!==ke||e[71]!==Ie?(oe=n.jsxs("div",{ref:v,className:ce,onClick:le,role:Re,tabIndex:Oe,onKeyDown:Te,"aria-label":De,children:[ke,Ie]}),e[63]=v,e[64]=ce,e[65]=le,e[66]=Re,e[67]=Oe,e[68]=Te,e[69]=De,e[70]=ke,e[71]=Ie,e[72]=oe):oe=e[72];let $e;e[73]!==m||e[74]!==l||e[75]!==L||e[76]!==o||e[77]!==i||e[78]!==R?($e=!l&&L?n.jsxs("div",{className:"pb-1",children:[i,o.length>0?m:i?null:n.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:R("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=m,e[74]=l,e[75]=L,e[76]=o,e[77]=i,e[78]=R,e[79]=$e):$e=e[79];let Fe;return e[80]!==oe||e[81]!==$e?(Fe=n.jsxs("div",{className:"oc-folder",children:[oe,$e]}),e[80]=oe,e[81]=$e,e[82]=Fe):Fe=e[82],Fe},vp=c.memo(KC);function zC(t){return t.stopPropagation()}function UC(t){return t.stopPropagation()}function HC(t){return t.stopPropagation()}function VC(t){return t.stopPropagation()}function GC(t){return t.stopPropagation()}function qC(t){return t.stopPropagation()}function YC(t){return t.stopPropagation()}function QC(t){return t.stopPropagation()}function XC(t){return t.stopPropagation()}function JC(t){return t.stopPropagation()}function ZC(t){const e=Ve.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=fu(l);let d;return e[8]!==a||e[9]!==o?(d=n.jsx(vp,{...o,collapsedActivityState:a}),e[8]=a,e[9]=o,e[10]=d):d=e[10],d}const _r=t=>{const e=Ve.c(13),{directory:s,className:r}=t,{t:o}=mt();let i;e[0]!==s?(i=Km(s),e[0]=s,e[1]=i):i=e[1];const l=i;let a;if(e[2]!==l?(a=w=>w.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Ot(a)?.tabs.some(ru))return null;let f;e[4]!==o?(f=o("sessions.sidebar.projectAction.active"),e[4]=o,e[5]=f):f=e[5];const m=f;let h;e[6]!==r?(h=xe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=h):h=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx($,{name:"pulse",className:"size-3.5"}),e[8]=b):b=e[8];let g;return e[9]!==l||e[10]!==m||e[11]!==h?(g=n.jsx("span",{className:h,role:"img","aria-label":m,title:m,"data-action-directory":l,children:b}),e[9]=l,e[10]=m,e[11]=h,e[12]=g):g=e[12],g},e3=t=>{const e=Ve.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,m=`session-drag:${r??s}`;let h;e[0]!==f||e[1]!==u||e[2]!==i||e[3]!==s||e[4]!==l?(h={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]=h):h=e[5];let b;e[6]!==f||e[7]!==m||e[8]!==h?(b={id:m,disabled:f,data:h},e[6]=f,e[7]=m,e[8]=h,e[9]=b):b=e[9];const{attributes:g,listeners:w,setNodeRef:S,isDragging:x}=P1(b);let p;e[10]!==w?(p=C=>{C.stopPropagation(),w?.onPointerDown&&w.onPointerDown(C)},e[10]=w,e[11]=p):p=e[11];const y=p,v=`touch-pan-y select-none${x?" opacity-30":""}`;let j;return e[12]!==g||e[13]!==d||e[14]!==y||e[15]!==w||e[16]!==S||e[17]!==v?(j=n.jsx("div",{ref:S,...g,...w,onPointerDown:y,className:v,children:d}),e[12]=g,e[13]=d,e[14]=y,e[15]=w,e[16]=S,e[17]=v,e[18]=j):j=e[18],j},Sp=t=>{const e=Ve.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=Gn(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||pl(r),e[3]=a,e[4]=r,e[5]=f):f=e[5];let m;e[6]!==s||e[7]!==o||e[8]!==r?(m={type:"folder",folderId:s,scopeKey:r,ownerKey:o},e[6]=s,e[7]=o,e[8]=r,e[9]=m):m=e[9];let h;e[10]!==u||e[11]!==f||e[12]!==m?(h={id:u,disabled:f,data:m},e[10]=u,e[11]=f,e[12]=m,e[13]=h):h=e[13];const{setNodeRef:b,isOver:g}=I1(h);let w;e[14]!==l||e[15]!==g||e[16]!==b?(w=l(b,g),e[14]=l,e[15]=g,e[16]=b,e[17]=w):w=e[17];let S;return e[18]!==w?(S=n.jsx(n.Fragment,{children:w}),e[18]=w,e[19]=S):S=e[19],S},t3=t=>{const e=Ve.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=Xo(vn(Zo,d),vn(Jo,u)),[m,h]=c.useState(null),[b,g]=c.useState("Session"),[w,S]=c.useState(null),[x,p]=c.useState(null);if(!s){let M;return e[2]!==l?(M=n.jsx(n.Fragment,{children:l}),e[2]=l,e[3]=M):M=e[3],M}let y;e[4]!==i||e[5]!==a?(y=M=>{h(null),S(null),p(null);const{active:L,over:F}=M;if(!F)return;const D=L.data.current,U=F.data.current;D?.type!=="session"||!D.sessionId||!D.ownerKey||D.archivedBucket===!0||a&&D.ownerKey!==a||U?.type!=="folder"||!U.folderId||!U.scopeKey||!U.ownerKey||pl(U.scopeKey)||U.ownerKey!==D.ownerKey||i(D.sessionId,{folderId:U.folderId,scopeKey:U.scopeKey,ownerKey:U.ownerKey},D.ownerKey)},e[4]=i,e[5]=a,e[6]=y):y=e[6];const v=y;let j,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=M=>{const L=M.active.data.current;if(L?.type==="session"&&L.sessionId){h(L.sessionId),g(L.sessionTitle??"Session");const F=M.active.rect.current.initial?.width,D=M.active.rect.current.initial?.height;S(F??null),p(D??null)}},C=()=>{h(null),S(null),p(null)},e[7]=j,e[8]=C):(j=e[7],C=e[8]);let k;e[9]!==x||e[10]!==m||e[11]!==b||e[12]!==w||e[13]!==o?(k=m&&o?n.jsxs("div",{style:{width:w?`${w}px`:"auto",height:x?`${x}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($,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:b})]}):null,e[9]=x,e[10]=m,e[11]=b,e[12]=w,e[13]=o,e[14]=k):k=e[14];let T;e[15]!==k?(T=n.jsx(D1,{children:k}),e[15]=k,e[16]=T):T=e[16];let O;return e[17]!==l||e[18]!==v||e[19]!==f||e[20]!==T?(O=n.jsxs(ei,{sensors:f,collisionDetection:ti,onDragStart:j,onDragCancel:C,onDragEnd:v,children:[l,T]}),e[17]=l,e[18]=v,e[19]=f,e[20]=T,e[21]=O):O=e[21],O},wp=c.createContext(null),s3=({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(wp.Provider,{value:a.current,children:r})},jp=()=>c.useContext(wp),n3=(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},kp=(t,e)=>{if(t.size===0)return!1;for(const s of t)if(!e.get(s)?.time?.archived)return!1;return!0},r3=({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,m=e?s===e&&!d:l,h=p=>{if(s===p){if(o()){u(!0);return}r(null)}},b=p=>{if(p){a(!1),u(!1),r(t);return}h(t)},g=p=>{if(!e){a(p);return}if(p){u(!1),r(e);return}h(e)},w=p=>{p||(i(),u(!1),(s===t||s===e)&&r(null))},S=()=>{u(!1),r(f?null:t)},x=c.useRef({menu:b,contextMenu:g});return x.current={menu:b,contextMenu:g},c.useEffect(()=>{if(!f&&!m)return;const p=()=>{m&&x.current.contextMenu(!1),f&&x.current.menu(!1)};return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[f,m]),{isMenuOpen:f,isContextMenuOpen:m,handleMenuOpenChange:b,handleContextMenuOpenChange:g,handleMenuOpenChangeComplete:w,toggleMenu:S}},o3=t=>{const e=Ve.c(10),{project:s,fallback:r}=t,{currentTheme:o}=Kr(),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(lf,{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},i3=t=>{const e=Ve.c(13),{project:s}=t,r=s?.icon?of[s.icon]:null,o=s?.color?af[s.color]??null:null;let i;e[0]!==o||e[1]!==r?(i=r?n.jsx($,{name:r,className:xe("h-3.5 w-3.5",!o&&"text-muted-foreground/75"),style:o?{color:o}:void 0}):n.jsx($,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:o?{color:o}:void 0}),e[0]=o,e[1]=r,e[2]=i):i=e[2];const l=i;if(!s?.iconImage){let f;return e[3]!==l?(f=n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=f):f=e[4],f}let a;e[5]!==s.iconBackground?(a=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[5]=s.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==s?(d=n.jsx(o3,{project:s,fallback:l}),e[7]=l,e[8]=s,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=n.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},va=t=>{const e=Ve.c(57),{compact:s,project:r,projectLabel:o,title:i,titleClassName:l,branchLabel:a,spaceMark:d,thirdLineLead:u,statusDot:f,pinnedMarker:m,timeSlot:h,directoryIndicator:b,prBadge:g,zombieIndicator:w,goal:S,badges:x,doneHint:p,providerId:y,metaPaddingClass:v,hideMetaOnHoverClass:j,actionsReserveClass:C,actionsMaskClass:k}=t,T=s===void 0?!1:s,O=d===void 0?null:d,M=u===void 0?null:u,L=S===void 0?null:S,F=p===void 0?null:p,D=!T&&(!!a||!!M||!!g||!!w||!!L||!!x||!!y);let U;e[0]!==j||e[1]!==v?(U=xe("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",v,j),e[0]=j,e[1]=v,e[2]=U):U=e[2];const N=T?L:null,A=T?x:null;let H;e[3]!==h?(H=n.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:h}),e[3]=h,e[4]=H):H=e[4];let I;e[5]!==b||e[6]!==F||e[7]!==m||e[8]!==f||e[9]!==U||e[10]!==N||e[11]!==A||e[12]!==H?(I=n.jsxs("span",{className:U,children:[N,A,b,m,F,f,H]}),e[5]=b,e[6]=F,e[7]=m,e[8]=f,e[9]=U,e[10]=N,e[11]=A,e[12]=H,e[13]=I):I=e[13];const R=I;if(T){let Be;e[14]!==C?(Be=xe("@container relative flex w-full min-w-0 items-center gap-1",C),e[14]=C,e[15]=Be):Be=e[15];let Ae;e[16]!==k||e[17]!==l?(Ae=xe("min-w-0 flex-1 truncate typography-ui-label font-normal",k,l),e[16]=k,e[17]=l,e[18]=Ae):Ae=e[18];let K;e[19]!==Ae||e[20]!==i?(K=n.jsx("div",{dir:"auto",className:Ae,children:i}),e[19]=Ae,e[20]=i,e[21]=K):K=e[21];let q;return e[22]!==R||e[23]!==Be||e[24]!==K?(q=n.jsxs("div",{className:Be,children:[K,R]}),e[22]=R,e[23]=Be,e[24]=K,e[25]=q):q=e[25],q}let P;e[26]!==C?(P=xe("@container relative flex h-5 w-full min-w-0 items-center gap-1",C),e[26]=C,e[27]=P):P=e[27];let _;e[28]!==r?(_=n.jsx(i3,{project:r}),e[28]=r,e[29]=_):_=e[29];let G;e[30]!==k||e[31]!==o?(G=o?n.jsx("span",{className:xe("min-w-0 truncate typography-micro text-muted-foreground/85 [--oc-actions-inset:18px]",k),children:o}):null,e[30]=k,e[31]=o,e[32]=G):G=e[32];let ae;e[33]!==R||e[34]!==P||e[35]!==_||e[36]!==G?(ae=n.jsxs("div",{className:P,children:[_,G,R]}),e[33]=R,e[34]=P,e[35]=_,e[36]=G,e[37]=ae):ae=e[37];let Se;e[38]!==l?(Se=xe("w-full min-w-0 truncate typography-ui-label font-normal",l),e[38]=l,e[39]=Se):Se=e[39];let J;e[40]!==Se||e[41]!==i?(J=n.jsx("div",{dir:"auto",className:Se,children:i}),e[40]=Se,e[41]=i,e[42]=J):J=e[42];let re;e[43]!==x||e[44]!==a||e[45]!==L||e[46]!==D||e[47]!==g||e[48]!==y||e[49]!==O||e[50]!==M||e[51]!==w?(re=D?n.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[M??(a?n.jsxs(n.Fragment,{children:[O?n.jsx($,{name:"box-3",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":!1,role:"img","aria-label":O}):n.jsx($,{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),n.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[L,w??g,x,y?n.jsx(rf,{providerId:y,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[43]=x,e[44]=a,e[45]=L,e[46]=D,e[47]=g,e[48]=y,e[49]=O,e[50]=M,e[51]=w,e[52]=re):re=e[52];let ie;return e[53]!==ae||e[54]!==J||e[55]!==re?(ie=n.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[ae,J,re]}),e[53]=ae,e[54]=J,e[55]=re,e[56]=ie):ie=e[56],ie},Sa=750,Wo=t=>{const e=Ve.c(9),{items:s,directory:r}=t,o=qa();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:xe("group/ref flex min-w-0 flex-col rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",d.color?"oc-ref-tint":"text-muted-foreground"),style:d.color?bn(d.color):void 0,disabled:!d.url,onPointerDown:a3,onMouseDown:l3,onKeyDown:c3,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($,{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 pl-[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 a3(t){return t.stopPropagation()}function l3(t){return t.stopPropagation()}function c3(t){return t.stopPropagation()}const d3=150,Bi={capture:!0,passive:!0};let ko=null;const pd=new WeakSet,u3=t=>{ko={target:t.target,at:performance.now()}},md=(t,e)=>t instanceof Node&&t.contains(e);function f3(){const t=Ve.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",u3,Bi)),()=>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(ko&&performance.now()-ko.at<d3&&md(ko.target,f)){u.cancel();return}const m=h=>{md(h.target,f)&&e.current?.close()};document.addEventListener("scroll",m,Bi),s.current=()=>document.removeEventListener("scroll",m,Bi)},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 wa=!1;const ja=new Set;let hd=!1;function p3(){for(const t of ja)t()}function Cp(t){wa!==t&&(wa=t,p3())}function fo(t){Cp(t.shiftKey)}function m3(){Cp(!1)}function h3(){if(hd||typeof window>"u")return;hd=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",fo,t),window.addEventListener("keyup",fo,t),window.addEventListener("pointermove",fo,t),window.addEventListener("pointerdown",fo,t),window.addEventListener("blur",m3)}function g3(t){return h3(),ja.add(t),()=>{ja.delete(t)}}function b3(){return wa}function y3(){return!1}function Np(){return us.useSyncExternalStore(g3,b3,y3)}const Ap=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(g=>g.id===t.id)??null;if(!a||ot(a.path??null)!==o)throw new Error("Project removed during worktree refresh");const d=ml({rawWorktreesByProjectRef:s.rawWorktreesByProjectRef,publishedWorktreesByProject:s.getPublishedWorktreesByProject(),runtimeKey:r}),u=i.map(g=>Ko(g));u.sort((g,w)=>Pp({metadata:g},{metadata:w}));const f=_y(d.worktreesByProject,o,u,e?.projectDirectory);x3(s.rawWorktreesByProjectRef,r),s.rawWorktreesByProjectRef.current={runtimeKey:r,revision:s.rawWorktreesByProjectRef.current.revision,worktreesByProject:f};const m=s.getPublishedWorktreesByProject(),h=$y(s.partitionWorktreesByRegisteredProject(l,f),m),b=[...h.values()].flat();return s.recordWorktreesSeen(b.map(g=>g.path),s.now()),s.worktreeMapsEqual(h,m)||s.publishTopology({availableWorktrees:b,availableWorktreesByProject:h}),u},x3=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),v3=t=>new Map([...t.entries()].map(([e,s])=>[e,s.map(r=>Ko(r))])),ml=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:v3(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),Pp=(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"})},gd=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Ko=t=>({...t,path:ot(t.path)??t.path,projectDirectory:ot(t.projectDirectory)??t.projectDirectory,worktreeRoot:ot(t.worktreeRoot??t.path)??t.worktreeRoot}),bd=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||gd(s):o||gd(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},yd=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 m=ot(f.metadata.path??null);!m||l.has(m)||l.set(m,{...f,metadata:Ko({...f.metadata,path:m})})};for(const f of t.discoveredWorktrees){const m=ot(f.path??null);m&&a({metadata:Ko({...f,path:m,projectDirectory:ot(f.projectDirectory??null)??i??e??m}),isPrimary:i===m,isCurrent:s===m})}i&&!l.has(i)&&a({metadata:bd({path:i,projectDirectory:i,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:s===i}),s&&!l.has(s)&&a({metadata:bd({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,m)=>f.metadata.path.localeCompare(m.metadata.path,void 0,{sensitivity:"base"})),u.sort(Pp),[...d,...u]},Ip=(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},S3=(t,e)=>{const s=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),o=ml({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:s}),i=Ip(t,e),l=ot(i?.path??null);return{cachedTargets:yd({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 Ap(i,t.currentWorktree,e);return yd({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},w3=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},j3=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),k3=(t,e)=>ot(t.worktree?.path??null)===ot(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,C3=[],N3=[],A3=[],Ir=6,po=14,xd=Ir+14+6,Fi=new WeakMap,P3=t=>{const e=t.closest("[data-session-row]"),s=e?.closest(".overlay-scrollbar-container");if(!e||!s)return;Fi.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,Fi.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,Os("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}),Fi.set(s,a),l=window.requestAnimationFrame(d)},I3=c.memo(function(e){const s=Ve.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:i,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:f}=e,m=Np(),h=m?o:r;let b;s[0]!==u||s[1]!==f||s[2]!==m?(b=C=>{if(m||C.shiftKey){f(C);return}u(C)},s[0]=u,s[1]=f,s[2]=m,s[3]=b):b=s[3];const g=b,w=m?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let S;s[4]!==i||s[5]!==w?(S=xe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",w,i),s[4]=i,s[5]=w,s[6]=S):S=s[6];const x=m?"delete-bin":"archive";let p;s[7]!==l||s[8]!==x?(p=n.jsx($,{name:x,className:l}),s[7]=l,s[8]=x,s[9]=p):p=s[9];let y;s[10]!==g||s[11]!==h||s[12]!==d||s[13]!==a||s[14]!==S||s[15]!==p?(y=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",className:S,"aria-label":h,onPointerDown:a,onMouseDown:d,onClick:g,onKeyDown:L3,children:p})}),s[10]=g,s[11]=h,s[12]=d,s[13]=a,s[14]=S,s[15]=p,s[16]=y):y=s[16];let v;s[17]!==h?(v=n.jsx(Pt,{side:"left",sideOffset:8,children:h}),s[17]=h,s[18]=v):v=s[18];let j;return s[19]!==y||s[20]!==v?(j=n.jsxs(Dt,{children:[y,v]}),s[19]=y,s[20]=v,s[21]=j):j=s[21],j});function D3(t){Os("ui.sidebar_session_node.render");const{t:e}=mt(),{node:s,depth:r=0,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:f,hasSessionSearchQuery:m,normalizedSessionSearchQuery:h,notifyOnSubtasks:b,editingId:g,editingRowKey:w,setEditingId:S,setEditingRowKey:x,editTitle:p,setEditTitle:y,handleSaveEdit:v,handleCancelEdit:j,toggleParent:C,handleSessionSelect:k,handleSessionDoubleClick:T,handleCopySessionId:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:L,createFolderAndStartRename:F,handleDeleteSession:D,handleRestoreSession:U,startSessionWorktreeMenuLoad:N,onEditProject:A,mobileVariant:H,alwaysShowActions:I,secondaryMeta:R,renderContext:P="project",blockingBadgeSessionScopes:_,rowKey:G,dragKey:ae,children:Se}=t,J=br(se=>se.toggle),re=rs(se=>se.getFoldersForScope),ie=rs(se=>se.getSessionFolderId),Be=rs(se=>se.removeSessionFromFolder),Ae=rs(se=>se.addSessionToFolder),K=be(se=>se.openContextPanelTab),q=c.useMemo(()=>qs(),[]),X=c.useMemo(()=>Tr(),[]),me=c.useContext(Wy),he=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",Y=q,ue=!d&&!H,we=be(se=>se.sessionWorkEnabled),ce=be(se=>se.sessionRecapEnabled),le=we&&!d&&!s.session.parentID&&!Ra(s.session.directory),Re=le&&!I,Oe=(Re?1:0)+(ue?1:0)+(Y?1:0),Te=["group-hover:pr-8","group-hover:pr-14","group-hover:pr-18","group-hover:pr-22"][Oe],De=ue?"pr-13":"pr-7",te=c.useRef(!1),[de,fe]=c.useState(!1),ge=c.useRef(g);ge.current=g;const B=c.useRef(null),Q=c.useRef(!1),ke=c.useRef(v);ke.current=v;const Ie=p,oe=c.useRef(Ie);oe.current=Ie;const $e=c.useRef(null),Fe=c.useRef(!1),Ce=c.useRef(null),Ue=c.useRef(null),pe=f3(),ne=s.session,Me=ne,He=Xt(c.useCallback(se=>{if(R?.projectLabel||!i)return null;const At=se.projects.find(Zt=>Zt.id===i);return At?At.label?.trim()||Yo(ot(At.path)??At.path,null)||At.path:null},[i,R?.projectLabel])),Ye=P==="timeline"||P==="timeline-chat",Xe=P==="timeline-chat",Je=Xt(c.useCallback(se=>!Ye||!i?null:se.projects.find(At=>At.id===i)??null,[Ye,i])),bt=R?.projectLabel??(He?cf(He):null),et=v2(R,s.worktree?.branch??null),lt=R?.inSpace===!0,xt=c.useMemo(()=>S2(s.worktree,q),[q,s.worktree]),wt=df(xt?.directory??null,xt?.branch??null),dt=c.useMemo(()=>q?C3:uf(ne),[q,ne]),It=c.useMemo(()=>dt.map(se=>({item:Or("pull",se),url:se.url,title:se.title})),[dt]),_t=nc(It),Bt=c.useMemo(()=>_t.filter(se=>se!==null),[_t]),ye=c.useMemo(()=>q?A3:Ky(ne),[q,ne]),z=c.useMemo(()=>ye.flatMap(se=>se.gitlab?[{item:Br("pull",se.gitlab),url:se.url,title:se.title}]:[]),[ye]),W=nc(z),Z=c.useMemo(()=>zy(wt,[...Bt,...W.filter(se=>se!==null)]),[wt,W,Bt]),ve=c.useMemo(()=>{let se=0;return ye.filter(At=>{if(!At.gitlab)return!0;const Zt=W[se]!==null;return se+=1,!Zt})},[W,ye]),E=c.useMemo(()=>Uy(dt,Z),[dt,Z]),V=wt?`var(--pr-${wt.visualState})`:void 0,Ne=!!et&&P==="recent",We=c.useMemo(()=>q?N3:Ya(ne),[q,ne]),Ge=c.useMemo(()=>We.flatMap(se=>se.source==="github"?[Or("issue",se)]:[]),[We]),qe=Eo(Ge),Pe=c.useMemo(()=>We.flatMap(se=>se.source==="gitlab"?[Br("issue",se.ref)]:[]),[We]),ze=Eo(Pe),Rt=c.useMemo(()=>We.flatMap(se=>se.source==="linear"?[Qa(se.identifier)]:[]),[We]),zt=ff(Rt),Tt=c.useMemo(()=>{if(Z.length>0||E.length>0||ve.length>0){const se=Z.map(Lt=>{const gs=pf(Lt,e),Qt=_a(Lt.provider,Lt.number);return{key:`${Lt.provider??""}:${Lt.repo?.owner??""}/${Lt.repo?.repo??""}#${Lt.number}`,icon:"git-pull-request",label:Qt,color:`var(--pr-${Lt.visualState})`,url:Lt.url,title:Lt.title,text:gs?`${Qt} · ${gs}`:Qt}}),At=E.map(Lt=>({key:`${Lt.owner}/${Lt.repo}#${Lt.number}`,icon:"git-pull-request",label:`#${Lt.number}`,url:Lt.url,title:Lt.title,text:`#${Lt.number}`})),Zt=ve.map(Lt=>({key:Lt.key,icon:"git-pull-request",label:Lt.identifier,url:Lt.url,title:Lt.title,text:Lt.identifier}));return[...se,...At,...Zt]}return mf(We,qe,zt,ze).map(se=>({key:se.key,icon:se.icon,label:se.label,color:se.color??void 0,url:se.url,title:se.title,text:se.statusKey?`${se.label} · ${e(se.statusKey)}`:se.statusText?`${se.label} · ${se.statusText}`:se.label}))},[ze,qe,We,zt,E,Z,e,ve]),Ft=Tt[0]??null,gt=Math.max(0,Tt.length-1),vt=qa(),qt=Tt.map(se=>se.text).join(", "),ct=Ze(se=>se.currentSessionId===ne.id),at=ot(ne.directory??null)??ot(o??null),yt=a!==void 0?a:i??at??null,$t=Nu(),ls=hf(),jt=q,kt=bs(se=>se.enabled),Vt=bs(c.useCallback(se=>se.selectedIds.has(ne.id),[ne.id])),es=bs(se=>se.toggleSelected),Is=bs(se=>se.setRange),Ds=jp(),ts=G??ne.id,Le=g===ne.id&&w===ts,nt=c.useCallback(se=>{const At=[],Zt=Lt=>{Lt.children.forEach(gs=>{At.push(gs.session.id),Zt(gs)})};return Zt(se),At},[]),it=c.useCallback(se=>{const At=[],Zt=Lt=>{Lt.children.forEach(gs=>{At.push(gs.session),Zt(gs)})};return Zt(se),At},[]),[_e,st]=c.useState(!1),[ut,St]=c.useState(!0),Ct=`${P}:${d?"archived":"active"}:${ne.id}`,Nt=G?`session-menu:${G}`:Ct,os=G?`session-context:${G}`:null,Ht=gf(c.useCallback(se=>!!se.sessionMemoryState.get(Hy(ne.id))?.isZombie,[ne.id])),Ee=gu(ne.id),Qe=Ee!==null,rt=Vy(ne.id,Qe),pt=Of(ne.id),Mt=Ma(ne.id,at),Wt=pt||Mt,ss=s.worktree??Ze.getState().getWorktreeMetadata(ne.id)??null,[Kt,Yt]=c.useState([]),[ys,Es]=c.useState(!1),[Ws,en]=c.useState(!1),cs=c.useRef(!1),Rs=c.useRef(0),Ms=Gy(Me),tn=le&&Xa(Me),on=tn&&!Qe&&qy(Me),Vr=e(tn?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),Gr=async()=>{try{await ax(ne.id,at,tn?"done":"open")}catch{Ke.error(e("sessions.sidebar.session.work.updateFailed"))}},$n=Ms?n.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(rc[Ms.status]),"aria-label":e(rc[Ms.status]),children:n.jsx($,{name:"target",className:"h-3 w-3",style:{color:Yy[Ms.status]}})}):null,Ks=Me.title||e("sessions.sidebar.session.untitled"),Zn=!Ye&&s.children.length>0,fn=Ga(u,at,ne.id),qr=Ct,ee=m?!0:f.has(qr),tt=c.useMemo(()=>_??ya(s,ee,at),[ee,s,at,_]),{permissionCount:ht,formCount:Ut}=Qy(tt),ds=!!Me.parentID,as=bu(ne.id)>0&&(!ds||b),er=Me.time?.updated||Me.time?.created||Date.now(),ii=Xy(er),Wn=bf(er),{isMenuOpen:hl,isContextMenuOpen:gl,handleMenuOpenChange:Hp,handleContextMenuOpenChange:Vp,handleMenuOpenChangeComplete:bl,toggleMenu:Gp}=r3({menuInstanceKey:Nt,contextMenuInstanceKey:os,openSidebarMenuKey:M,setOpenSidebarMenuKey:L,hasDeferredCloseWork:()=>B.current!==null,onCloseComplete:()=>{if(!B.current)return;const{id:se,title:At}=B.current;B.current=null,S(se),x(ts),y(At)}}),tr=hl||gl,yl=c.useMemo(()=>Jy(Me)?.key??null,[Me]),ai=c.useMemo(()=>nt(s).length,[nt,s]),li=c.useCallback(async se=>{const At=[];let Zt=0;for(const Lt of se)try{if(!at)throw new Error("Session directory is required for export");const gs=await $t({directory:at,sessionID:Lt.session.id});if(!gs)throw new Error("Session runtime changed during export");const Qt=Lt.session.title||e("sessions.sidebar.session.export.untitledSubagent"),zs=Lt.session.agent,is=await li(Lt.children);Zt+=is.skipped,At.push({title:Qt,agent:zs,records:gs,children:is.children})}catch{Zt+=nt(Lt).length+1}return{children:At,skipped:Zt}},[nt,$t,at,e]),ci=c.useCallback(se=>{se<=0||Ke.warning(se===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:se}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:se}))},[e]),di=c.useCallback(async se=>{if(!at){Ke.error(e("sessions.sidebar.session.export.nothingToExport"));return}const At=await $t({directory:at,sessionID:ne.id}).catch(()=>null);if(!At){Ke.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(At.length===0){Ke.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Zt,Lt=0;if(se&&s.children.length>0){const is=await li(s.children);Zt=is.children,Lt=is.skipped}const gs=Au(At,Me.title??null,Zt),Qt=Pu(Me.title??null),zs=await Iu(gs,Qt);if(zs){Ke.success(e("sessions.sidebar.session.export.success"),{action:{label:e(ex()),onClick:()=>{Zy(zs).then(is=>{is||Ke.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),ci(Lt);return}Du(gs,Qt),Ke.success(e("sessions.sidebar.session.export.success")),ci(Lt)},[li,$t,s.children,Me.title,ne.id,at,ci,e]),xl=Eu(),qp=c.useMemo(()=>Ru(xl),[xl]),Yp=c.useCallback(se=>{Tf({entry:se,t:e,session:{id:ne.id,title:Me.title,directory:at},loadRecords:()=>at?$t({directory:at,sessionID:ne.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Ke.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[$t,Me.title,ne.id,at,e]),Qp=c.useCallback(async()=>{if(s.children.length>0){St(!0),st(!0);return}await di(!1)},[di,s.children.length]),Xp=c.useCallback(()=>{at&&On("desktop_open_session_mini_chat_window",{sessionId:ne.id,directory:at,apiBaseUrl:Co(),clientToken:Wi()}).catch(se=>{console.warn("[session-sidebar] failed to open mini chat window",se)})},[ne.id,at]);if(c.useEffect(()=>{if(!Le)return;const se=At=>{const Lt=(At.target instanceof HTMLElement?At.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(ts)}"]`);Ue.current&&!Lt&&ke.current(oe.current)};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[Le,ts]),c.useLayoutEffect(()=>{if(!Le){$e.current===ts&&($e.current=null);return}$e.current!==ts&&($e.current=ts,Fe.current=!0)},[p,Le,ts]),c.useLayoutEffect(()=>{if(!Le||!Fe.current)return;const se=Ce.current;!se||se.value!==p||(Fe.current=!1,se.focus(),se.select())},[p,Le,Ie]),Le){const se=n.jsxs("form",{ref:Ue,"data-session-rename-form":ts,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:At=>{At.preventDefault(),v(Ie)},children:[n.jsx("input",{ref:Ce,value:Ie,onChange:At=>y(At.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:At=>Hi(At,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($,{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($,{name:"close",className:"size-3.5"})})]});return Ye?n.jsx("div",{style:{paddingLeft:Ir+4},className:xe("oc-ref-tint-scope group relative my-0.5 flex items-center rounded-md pr-2.5",Xe?"py-1":"py-1.5",ct&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:n.jsx(va,{compact:Xe,project:Je,projectLabel:bt,title:se,titleClassName:"text-foreground",branchLabel:et,spaceMark:lt?e("sessions.sidebar.group.space"):null,statusDot:null,pinnedMarker:null,timeSlot:Wn,directoryIndicator:null,prBadge:Ft?n.jsxs("span",{className:xe("inline-flex flex-shrink-0 items-center gap-1 typography-micro",Ft.color?"oc-ref-tint":"text-muted-foreground"),style:Ft.color?bn(Ft.color):void 0,children:[n.jsx($,{name:Ft.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:Ft.label}),gt>0?n.jsxs("span",{className:"leading-none tabular-nums text-muted-foreground",children:["+",gt]}):null]}):null,zombieIndicator:null,goal:$n,badges:null,hideMetaOnHoverClass:""})},ne.id):n.jsx("div",{style:{paddingLeft:xd+r*po},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:n.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:se})},ne.id)}const Yr=Ut===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:Ut}),ui=x2({actionsAlwaysVisible:I&&!q,menuOpen:tr,hideOnHoverClass:je}),vl=!Wt&&!Qe&&as&&!ct,sr=Qe||vl,Sl=n.jsx(vu,{state:Ee??"unread"}),Qr=(Qe||vl)&&rt,wl=Ye&&!Xe?["[--oc-actions-reserve:14px]","[--oc-actions-reserve:36px]","[--oc-actions-reserve:58px]","[--oc-actions-reserve:80px]"][Oe]:["[--oc-actions-reserve:10px]","[--oc-actions-reserve:28px]","[--oc-actions-reserve:46px]","[--oc-actions-reserve:64px]"][Oe],jl=I?void 0:tr?"oc-actions-mask":q?"group-hover:oc-actions-mask":"group-hover:oc-actions-mask group-has-[:focus-visible]:oc-actions-mask",fi=tr?"opacity-0":je,Jp=!I&&Zn&&(Wt||sr||fn),kl=fn&&!Wt&&!sr,Cl=n.jsx($,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Nl=n.jsx($,{name:"loader-4",className:"h-3 w-3 flex-shrink-0 animate-spin text-primary","aria-label":e(Mt?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}),Zp=Wt||sr||kl?n.jsx("span",{style:{left:Ir+r*po},className:xe("pointer-events-none absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center transition-opacity",Jp?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:Wt?Nl:sr?Sl:kl?Cl:null}):null,em=Zn&&!I&&(Wt||sr||fn),tm=Zn?n.jsx("span",{role:"button",tabIndex:0,onClick:se=>{se.stopPropagation(),se.currentTarget.blur(),C(qr)},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),C(qr))},style:{minWidth:14,minHeight:14,left:Ir+r*po},className:xe("absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",em?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto":""),"aria-label":e(ee?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:ee?n.jsx($,{name:"arrow-down-s",className:"h-3 w-3"}):n.jsx($,{name:"arrow-right-s",className:"h-3 w-3"})}):null,pi=Ht?n.jsx($,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,sm=se=>{se.preventDefault(),se.stopPropagation(),Gp()},nm=se=>{se.preventDefault(),se.stopPropagation()},rm=se=>{se.preventDefault(),se.stopPropagation()},mi=se=>{se.preventDefault(),se.stopPropagation()},hi=se=>{se.preventDefault(),se.stopPropagation()},om=se=>{se.preventDefault(),se.stopPropagation(),L(null),D(ne,{archivedBucket:d})},im=se=>{se.preventDefault(),se.stopPropagation(),L(null),D(ne,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},am=se=>{se.preventDefault(),se.stopPropagation()},lm=se=>{se.preventDefault(),se.stopPropagation()},cm=se=>{se.preventDefault(),se.stopPropagation(),me?.vscode?.executeCommand("openchamber.openSessionInEditor",ne.id,Ks)},Al=se=>{if(te.current){te.current=!1;return}if(kt){if(se?.preventDefault(),se?.stopPropagation(),se?.shiftKey){const At=Ds?.getEntries(),Zt=At??Array.from(document.querySelectorAll("[data-session-row]")).map(Qt=>Qt.getAttribute("data-session-row")).filter(Qt=>!!Qt).map(Qt=>({id:Qt,rowKey:Qt,scopeKey:yt,archived:d})),Lt=At?bs.getState().anchorRowKey:bs.getState().anchorId,gs=new Map;gs.set(ne.id,nt(s)),Is(Lt,ts,Zt,Ds?.getDescendantIds()??[],yt,gs);return}es(ne.id,yt,nt(s),ts);return}se?.currentTarget&&P3(se.currentTarget),k(ne.id,at)},dm=se=>{se.defaultPrevented||(se.target instanceof HTMLElement?se.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||Al(se)},um=se=>{(se.button===2||se.button===0&&se.ctrlKey&&!kt)&&(te.current=!0)},fm=se=>{H&&se.pointerType==="touch"&&fe(!0),se.button===0&&!ct&&!kt&&!jt&&at&&!Ji(ne.id,at).renderable&&ls({directory:at,sessionID:ne.id}).catch(()=>{})},Pl=se=>{H&&se.pointerType==="touch"&&fe(!1)},pm=se=>{cs.current=se,Rs.current+=1;const At=Rs.current;if(!se){Es(!1),en(!1);return}const Zt=N({projectId:i??null,sourceDirectory:at,currentWorktree:ss});Yt(Zt.cachedTargets),Es(!0),en(!1),Zt.refreshTargets.then(Lt=>{!cs.current||Rs.current!==At||(Yt(Lt),Es(!1),en(!1))}).catch(()=>{!cs.current||Rs.current!==At||(Es(!1),en(!0))})},Il=({Item:se,Separator:At,Sub:Zt,SubTrigger:Lt,SubContent:gs})=>n.jsxs(n.Fragment,{children:[n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.rename"),children:n.jsxs(se,{onClick:()=>{B.current={id:ne.id,title:Ks}},className:"[&>svg]:mr-1",children:[n.jsx($,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]})}),n.jsx(ia,{sessionID:ne.id,directory:at,open:tr,Item:se}),n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.copyId"),children:n.jsxs(se,{onClick:()=>O(ne.id),className:"[&>svg]:mr-1",children:[n.jsx($,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]})}),n.jsx(ns,{hint:e(fn?"sessions.sidebar.session.menuHint.unpin":"sessions.sidebar.session.menuHint.pin"),children:n.jsxs(se,{onClick:()=>at&&J({directory:at,sessionId:ne.id}),className:"[&>svg]:mr-1",children:[fn?n.jsx($,{name:"unpin",className:"mr-1 h-4 w-4"}):n.jsx($,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(fn?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]})}),le?n.jsx(ns,{hint:e(tn?"sessions.sidebar.session.menuHint.markDone":"sessions.sidebar.session.menuHint.track"),children:n.jsxs(se,{onClick:()=>{Gr()},className:"[&>svg]:mr-1",children:[n.jsx($,{name:tn?"check":"eye",className:"mr-1 h-4 w-4"}),e(tn?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]})}):null,n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.exportMarkdown"),children:n.jsxs(se,{onClick:()=>{Qp()},className:"[&>svg]:mr-1",children:[n.jsx($,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]})}),qp.map(Qt=>n.jsxs(se,{onClick:()=>Yp(Qt),className:"[&>svg]:mr-1",children:[n.jsx(vr,{icon:Qt.icon,iconSrc:Qt.iconSrc,className:"mr-1 size-4"}),Qt.action.label]},`${Qt.guest.id}:${Qt.action.id}`)),Ye&&i&&A?n.jsxs(se,{onClick:()=>A(i),className:"[&>svg]:mr-1",children:[n.jsx($,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,g2({isSubtaskSession:ds,archivedBucket:!!d,isVSCode:q,sessionDirectory:at})?(()=>{const Qt=b2({sessionDirectory:at,isStreaming:Qe,isMovingToWorktree:pt}),zs=j3({targets:Kt,isRefreshing:ys,loadFailed:Ws});return n.jsxs(Zt,{onOpenChange:pm,children:[n.jsx(ns,{hint:e(pt?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Qe?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets"),children:n.jsxs(Lt,{disabled:Qt,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":ne.id,children:[n.jsx($,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),n.jsxs(gs,{className:"min-w-[220px]","data-session-worktree-submenu":ne.id,children:[Kt.map(is=>{const Us=ot(is.metadata.path??null)??is.metadata.path,wr=is.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):is.metadata.label||is.metadata.branch||is.metadata.name||is.metadata.path,xs=is.isCurrent||is.metadata.worktreeStatus!=="ready";return n.jsxs(se,{disabled:xs,title:is.metadata.path,"data-session-worktree-target":Us,onClick:()=>{xs||!at||Bo({kind:"existing",root:Me,descendants:it(s),sourceDirectory:at,destination:is.metadata,messages:Oo(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:wr}),is.isCurrent?n.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),is.isCurrent?n.jsx($,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Us)}),zs.refreshState==="loading"?n.jsx(se,{disabled:!0,"data-session-worktree-refresh-state":"loading",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.refreshing")}):null,zs.refreshState==="error"?n.jsx(se,{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(At,{}),n.jsxs(se,{disabled:Qt,"data-session-worktree-new-action":"true",onClick:()=>{Qt||!at||Bo({kind:"quick",root:Me,descendants:it(s),sourceDirectory:at,messages:Oo(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[n.jsx($,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,yl?n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.openRunOverview"),children:n.jsxs(se,{onClick:()=>be.getState().setRunOverviewKey(yl),className:"[&>svg]:mr-1",children:[n.jsx(Zi,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]})}):null,at&&!d&&!Ye?(()=>{const Qt=[],zs=xs=>{const ks=ot(xs??null);ks&&!Qt.includes(ks)&&Qt.push(ks)};if(i&&!q){const xs=Xt.getState().projects.find(nr=>nr.id===i),ks=ot(xs?.path??null);zs(ks),ks&&(Ze.getState().availableWorktreesByProject.get(ks)??[]).forEach(nr=>zs(nr.path))}zs(Ta(at)),zs(at);const is=Qt.flatMap(xs=>re(xs).map(ks=>({scope:xs,folder:ks}))),Us=is.find(({scope:xs,folder:ks})=>ie(xs,ne.id)===ks.id)??null,wr=Qt[0]??at;return n.jsxs(n.Fragment,{children:[n.jsx(At,{}),n.jsxs(Zt,{children:[n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.moveToFolder"),children:n.jsxs(Lt,{className:"[&>svg]:mr-1",children:[n.jsx($,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]})}),n.jsxs(gs,{className:"min-w-[180px]",children:[is.length===0?n.jsx(se,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):is.map(({scope:xs,folder:ks})=>{const nr=Us?.folder.id===ks.id;return n.jsxs(se,{onClick:()=>{if(nr){Be(xs,ne.id);return}Us&&Us.scope!==xs&&Be(Us.scope,ne.id),Ae(xs,ks.id,ne.id)},children:[n.jsx("span",{className:"flex-1 truncate",children:ks.name}),nr?n.jsx($,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ks.id)}),n.jsx(At,{}),n.jsxs(se,{onClick:()=>{const xs=F(wr);xs&&(Q.current=!0,Us&&Us.scope!==wr&&Be(Us.scope,ne.id),Ae(wr,xs.id,ne.id))},children:[n.jsx($,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Us?n.jsxs(se,{onClick:()=>{Be(Us.scope,ne.id)},className:"text-destructive focus:text-destructive",children:[n.jsx($,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,q?null:n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.openInSidePanel"),children:n.jsxs(se,{disabled:!at,onClick:()=>{if(!at)return;const Qt=sx()??at;K(Qt,{mode:"chat",dedupeKey:`session:${ne.id}`,label:Ks,sessionTitleFallback:Ks,targetDirectory:at})},className:"[&>svg]:mr-1",children:[n.jsx($,{name:"chat-4",className:"mr-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),n.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]})}),X?n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.openMiniChatWindow"),children:n.jsxs(se,{disabled:!at,onClick:Xp,className:"[&>svg]:mr-1",children:[n.jsx($,{name:"window",className:"mr-1 h-4 w-4"}),n.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]})}):null,n.jsx(At,{}),d?null:n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.archive"),children:n.jsxs(se,{className:"[&>svg]:mr-1",onClick:()=>D(ne,{archivedBucket:d}),children:[n.jsx($,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]})}),d?n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.restore"),children:n.jsxs(se,{className:"[&>svg]:mr-1",onClick:()=>U(ne),children:[n.jsx($,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]})}):null,n.jsx(ns,{hint:e("sessions.sidebar.session.menuHint.delete"),children:n.jsxs(se,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>D(ne,{archivedBucket:d,hardDelete:!0}),children:[n.jsx($,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})})]}),mm=se=>{se.preventDefault(),se.stopPropagation(),Gr()},gi=I?"h-6 w-6":Ye&&!Xe?"h-5 w-5":"h-4 w-4",Xr=I?"h-3.5 w-3.5":Ye&&!Xe?"h-3 w-3":"h-2.5 w-2.5",hm=I?"h-4 w-4":Ye&&!Xe?"h-3.5 w-3.5":"h-3 w-3",Dl=ce&&!Qe&&tx(Me)?.recap||null,El=e("sessions.sidebar.session.work.doneSuggested"),bi=se=>on?n.jsx("span",{className:xe("inline-flex flex-shrink-0 items-center text-muted-foreground/75",se),title:El,"aria-label":El,children:n.jsx($,{name:"check",className:"h-3.5 w-3.5"})}):null,Rl=!Ye&&on,gm=ht>0||Ut>0||Rl?n.jsxs(n.Fragment,{children:[Rl?bi():null,ht>0?n.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[n.jsx($,{name:"shield",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:ht})]}):null,Ut>0?n.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:Yr,"aria-label":Yr,children:[n.jsx($,{name:"question",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:Ut})]}):null]}):null,bm=Ye&&Ft?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,closeDelay:Sa,children:n.jsxs("button",{type:"button",className:xe("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",Ft.color?"oc-ref-tint":"text-muted-foreground"),style:Ft.color?bn(Ft.color):void 0,disabled:!Ft.url,"aria-label":qt,onPointerDown:mi,onMouseDown:hi,onClick:se=>{se.preventDefault(),se.stopPropagation(),!(se.target instanceof Element&&se.target.closest("[data-ref-more]"))&&Ft.url&&vt(Ft.url,at,se)},onKeyDown:se=>se.stopPropagation(),children:[n.jsx($,{name:Ft.icon,className:"h-3 w-3"}),n.jsx("span",{className:"leading-none tabular-nums",children:Ft.label}),gt>0?n.jsxs("span",{"data-ref-more":!0,className:"leading-none tabular-nums text-muted-foreground",children:["+",gt]}):null]})}),n.jsx(Pt,{side:"top",sideOffset:6,className:"max-w-xs",children:n.jsx(Wo,{items:Tt,directory:at})})]}):null,ym=Ye?n.jsx(va,{compact:Xe,project:Je,projectLabel:bt,title:Er(Ks,h),titleClassName:ct||Vt?"text-interactive-selection-foreground":as?"text-foreground":"text-foreground/80",branchLabel:et,spaceMark:lt?e("sessions.sidebar.group.space"):null,statusDot:Wt?Nl:sr?Sl:null,pinnedMarker:fn&&!Wt?Cl:null,timeSlot:Qr?n.jsx(ji,{sessionId:ne.id,running:Qe,className:"typography-micro"}):Wn,directoryIndicator:!d&&at?n.jsx(_r,{directory:at}):null,prBadge:bm,zombieIndicator:pi,goal:$n,badges:gm,doneHint:bi(),providerId:Me.model?.providerID??null,metaPaddingClass:I?ue?"pr-13":"pr-7":void 0,hideMetaOnHoverClass:I&&!q?"":fi,actionsReserveClass:wl,actionsMaskClass:jl}):null,xm=n.jsx(As,{align:"end",className:"min-w-[180px]",finalFocus:()=>Q.current?(Q.current=!1,!1):!ge.current,children:Il({Item:Gt,Separator:Cs,Sub:rx,SubTrigger:ox,SubContent:ix})}),vm=n.jsx(ta,{children:n.jsx(sa,{className:"app-region-no-drag z-50",children:n.jsx(na,{"data-slot":"dropdown-menu-content",finalFocus:()=>Q.current?(Q.current=!1,!1):!ge.current,style:{color:"var(--surface-elevated-foreground)"},className:xe(Vi,"min-w-[180px]"),children:Il({Item:({className:se,...At})=>n.jsx(Nf,{className:xe(xu,se),...At}),Separator:({className:se,...At})=>n.jsx(Cf,{className:xe(yu,se),...At}),Sub:M1,SubTrigger:({className:se,children:At,...Zt})=>n.jsxs(O1,{className:xe(nx,se),...Zt,children:[At,n.jsx($,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:se,children:At,...Zt})=>n.jsx(ta,{children:n.jsx(sa,{className:"app-region-no-drag z-50",children:n.jsx(na,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:xe(Vi,se),...Zt,children:At})})})})})})});return n.jsxs(c.Fragment,{children:[n.jsx(e3,{sessionId:ne.id,dragKey:ae??ts,ownerKey:l??yt,sessionDirectory:at??null,sessionTitle:Ks,archivedBucket:d,children:n.jsxs(Pf,{open:gl,onOpenChange:Vp,onOpenChangeComplete:bl,children:[n.jsxs(Af,{render:n.jsx("div",{"data-session-row":ne.id,"data-session-scope":yt??"","data-session-archived":d?"1":"0","aria-current":ct?"page":void 0,onClick:dm,style:{paddingLeft:Ye?Ir+4:xd+r*po},className:xe("oc-ref-tint-scope group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Ye&&!Xe?"py-1.5":"py-1",Ye&&!(ct||Vt)&&"hover:bg-interactive-hover/60",(ct||Vt)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Vt&&"ring-1 ring-inset ring-border")}),children:[Ye?null:Zp,Ye?null:tm,n.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:n.jsxs(Dt,{actionsRef:pe.actionsRef,onOpenChange:pe.onOpenChange,children:[n.jsx(Et,{asChild:!0,closeDelay:Sa,disabled:q||Ye,children:n.jsx("button",{type:"button","aria-pressed":kt?Vt:void 0,onPointerDown:fm,onPointerUp:Pl,onPointerCancel:Pl,onMouseDown:um,onClick:se=>Al(se),onDoubleClick:se=>{se.stopPropagation(),T(ne.id,Ks)},className:xe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none",de&&"bg-interactive-hover/70",Ye||!I?void 0:q?Te:De),children:Ye?ym:n.jsxs("div",{className:xe("@container flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",wl),children:[n.jsx("div",{dir:"auto",className:xe("block min-w-0 flex-1 truncate typography-ui-label font-normal",jl,ct||Vt?"text-interactive-selection-foreground":as?"text-foreground":"text-foreground/80"),children:Er(Ks,h)}),!d&&at&&P==="recent"?n.jsx(_r,{directory:at,className:I?void 0:xe("transition-opacity",fi)}):null,bi(xe(ui,I?"ml-2":"ml-1")),I?n.jsx("span",{className:xe("inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",!on&&"ml-2"),children:Qr?n.jsx(ji,{sessionId:ne.id,running:Qe}):n.jsxs(n.Fragment,{children:[$n,Ne?n.jsx($,{name:"git-branch",className:xe("h-3 w-3",V?"oc-ref-tint":"text-muted-foreground/60"),style:V?bn(V):void 0}):null,Wn]})}):Qr||$n||Ne||P==="recent"?n.jsx("div",{className:xe("relative flex h-4 flex-shrink-0 items-center justify-end transition-opacity",!on&&"ml-1",fi),children:n.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:Qr?n.jsx(ji,{sessionId:ne.id,running:Qe,className:"typography-micro"}):n.jsxs(n.Fragment,{children:[$n,Ne?n.jsx($,{name:"git-branch",className:xe("h-3 w-3",V?"oc-ref-tint":"text-muted-foreground/60"),style:V?bn(V):void 0}):null,P==="recent"?n.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Wn}):null]})})}):null,ht>0?n.jsxs("span",{className:xe("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",ui),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[n.jsx($,{name:"shield",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:ht})]}):null,Ut>0?n.jsxs("span",{className:xe("inline-flex items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info flex-shrink-0",ui),title:Yr,"aria-label":Yr,children:[n.jsx($,{name:"question",className:"h-3 w-3"}),n.jsx("span",{className:"leading-none",children:Ut})]}):null]})})}),!q&&!Ye?n.jsx(Pt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:n.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{dir:"auto",className:"min-w-0 truncate font-medium text-foreground",children:Ks}),n.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:ii,children:Wn})]}),bt&&!Ye?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[n.jsx($,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),n.jsx("span",{className:"min-w-0 truncate",children:bt})]}):null,et?n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[lt?n.jsx($,{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($,{name:"git-branch",className:xe("h-3 w-3 flex-shrink-0",V&&"oc-ref-tint"),style:V?bn(V):void 0}),n.jsx("span",{className:"min-w-0 truncate",children:et})]}):null,Tt.length>0?n.jsx(Wo,{items:Tt,directory:at}):null,Dl?n.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:Dl}):null]})}):null]})}),pi&&!H&&!Ye?n.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:pi}):null,n.jsx("div",{className:xe("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Ye&&!Xe?"top-1.5 h-5":"top-1/2 -translate-y-1/2",tr||I&&!q?"opacity-100":xe("opacity-0",he)),children:n.jsxs(Qo,{delayDuration:400,children:[Re?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",className:xe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",gi,tn?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":Vr,onPointerDown:mi,onMouseDown:hi,onClick:mm,onKeyDown:se=>se.stopPropagation(),children:n.jsx($,{name:tn?"check":"eye",className:tn?hm:Xr})})}),n.jsx(Pt,{side:"left",sideOffset:8,children:Vr})]}):null,ue?n.jsx(I3,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:gi,iconSizeClass:Xr,onPointerDown:mi,onMouseDown:hi,onArchive:om,onDelete:im}):null,Y?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",className:xe("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",gi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:am,onMouseDown:lm,onClick:cm,onKeyDown:se=>se.stopPropagation(),children:n.jsx($,{name:"external-link",className:Xr})})}),n.jsx(Pt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,n.jsxs(Ps,{open:hl,onOpenChange:Hp,onOpenChangeComplete:bl,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:xe("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",I?"h-6 w-6 opacity-100":tr?"h-4 w-4 opacity-100":xe("h-4 w-4 opacity-0",he)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:nm,onMouseDown:rm,onClick:sm,onKeyDown:se=>se.stopPropagation(),children:n.jsx($,{name:"more-2",className:Xr})})}),xm]})]})})]}),vm]})}),Zn&&ee?Se:null,n.jsx(_s,{open:_e,onOpenChange:st,children:n.jsxs(Ls,{showCloseButton:!1,className:"max-w-sm gap-5",children:[n.jsxs(Zs,{children:[n.jsx(Xs,{children:e("sessions.sidebar.session.export.dialog.title")}),n.jsx(Js,{children:ai===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:ai}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:ai})})]}),n.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:ut,onChange:se=>St(se.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),n.jsxs(Jn,{children:[n.jsx(ft,{type:"button",onClick:()=>st(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),n.jsx(ft,{type:"button",onClick:()=>{st(!1),di(ut)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},ne.id)}const vd=t=>ot(t.session.directory??null),E3=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null)&&(t?.inSpace??!1)===(e?.inSpace??!1),R3=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},Sd=t=>t.menuOpenSessionId??R3(t),mo=(t,e,s)=>e?s.has(t.node.session.id)?!0:xr(t.node,e):!1,ka=(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(ka(t.children[l],e.children[l],s,r,o))return!0;return!1},T3=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const s=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return ka(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${s}:${o.session.id}`)||ka(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},M3=(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&&yf(t,e),O3=(t,e)=>{if(t.node.session.id!==e.node.session.id||!M3(t.node.session,e.node.session)||!k3(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(!E3(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&hp(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&T3(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(mo(t,t.editingId,t.subtreeContainsEditing)||mo(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&&(mo(t,t.editingId,t.subtreeContainsEditing)||mo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=Sd(t),o=Sd(e);if(xr(t.node,r)||xr(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.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},B3=(t,e)=>{const s=O3(t,e);return s===null?!0:(Os(`ui.sidebar_session_node.props_changed.${s}`),!1)},F3=c.memo(D3,B3);function L3(t){return t.stopPropagation()}const _3=t=>{const{t:e}=mt(),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=be(I=>I.setSessionSwitcherOpen),l=Ze(I=>I.setCurrentSession),a=Ze(I=>I.updateSessionTitle),d=Ze(I=>I.deleteSession),u=Ze(I=>I.deleteSessions),f=Ze(I=>I.archiveSession),m=Ze(I=>I.archiveSessions),h=Ze(I=>I.unarchiveSession),{mobileVariant:b,allowReselect:g,onSessionSelected:w,resetSessionSearch:S,descendantIds:x,showDeletionDialog:p,setDeleteSessionConfirm:y,setEditingId:v,setEditingRowKey:j,editingSessionId:C,editingOccurrenceKey:k,setEditTitle:T}=t,O=c.useCallback((I,R)=>{if(zi("navigation.session_select"),be.getState().closeMainSurfaces(),b&&i(!1),I===Ze.getState().currentSessionId){g&&w?.(I),S();return}zi("navigation.session_state_set"),l(I,R??null),w?.(I),S()},[g,b,w,S,l,i]),M=c.useCallback((I,R)=>{v(I),j(k),T(R)},[k,T,v,j]),L=c.useCallback(async I=>{if(!s.current)return;const P=(I??r.current).trim();if(P)try{await a(C,P)}catch(_){console.error("[session-actions] rename failed",_),Ke.error(e("sessions.sidebar.session.rename.error",{detail:pu(_ instanceof Error?_:new Error(String(_)),e)}))}v(null),j(null),T("")},[C,T,v,j,e,a]),F=c.useCallback(()=>{v(null),j(null),T("")},[T,v,j]),D=c.useCallback(I=>{Xn(I).then(R=>{if(R.ok){Ke.success(e("sessions.sidebar.session.copyId.success"));return}Ke.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Ke.error(e("sessions.sidebar.session.copyId.error")))},[e]),U=c.useCallback(async(I,R,P)=>{const _=R?.archivedBucket===!0||R?.hardDelete===!0,G=P?.descendantIds??x;await ag(_?"delete":"archive",I,G,{archiveSession:f,archiveSessions:m,deleteSession:d,deleteSessions:u},e)},[f,m,d,u,x,e]),N=c.useCallback((I,R)=>{const P=R?.archivedBucket===!0||R?.hardDelete===!0,_=lu(I.id,x,P);if(!p||R?.skipConfirm===!0){U(I,R,{descendantIds:_});return}y({session:I,descendantCount:_.length,descendantIds:_,archivedBucket:P})},[x,U,y,p]),A=c.useCallback(async()=>{const I=o.current;if(!I)return;const{session:R,archivedBucket:P,descendantIds:_}=I;y(null),await U(R,{archivedBucket:P},{descendantIds:_})},[U,y]),H=c.useCallback(async I=>{await h(I.id)?Ke.success(e("sessions.sidebar.session.restore.success")):Ke.error(e("sessions.sidebar.session.restore.error"))},[e,h]);return c.useMemo(()=>({handleSessionSelect:O,handleSessionDoubleClick:M,handleSaveEdit:L,handleCancelEdit:F,handleCopySessionId:D,handleDeleteSession:N,handleRestoreSession:H,confirmDeleteSession:A}),[F,D,N,H,L,M,O,A])};function $3(t){const e=Ve.c(71),{t:s}=mt(),{value:r,setValue:o,showDeletionDialog:i,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,f,m,h,b,g,w,S,x;if(e[0]!==o||e[1]!==s||e[2]!==r){const R=s("sessions.sidebar.session.untitled");m=_s,S=!!r,e[13]!==o?(x=_=>{_||o(null)},e[13]=o,e[14]=x):x=e[14],f=Ls,g=!1,w="max-w-sm gap-5",u=Zs;let P;e[15]!==s||e[16]!==r?.archivedBucket?(P=r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.title"):s("sessions.sidebar.dialogs.archiveSession.title"),e[15]=s,e[16]=r?.archivedBucket,e[17]=P):P=e[17],e[18]!==P?(b=n.jsx(Xs,{children:P}),e[18]=P,e[19]=b):b=e[19],d=Js,h=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?s("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||R,count:r.descendantCount}):s("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||R,count:r.descendantCount}):r.descendantCount===1?s("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||R,count:r.descendantCount}):s("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||R,count:r.descendantCount}):r?.archivedBucket?s("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||R}):s("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||R}),e[0]=o,e[1]=s,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=m,e[7]=h,e[8]=b,e[9]=g,e[10]=w,e[11]=S,e[12]=x}else d=e[3],u=e[4],f=e[5],m=e[6],h=e[7],b=e[8],g=e[9],w=e[10],S=e[11],x=e[12];let p;e[20]!==d||e[21]!==h?(p=n.jsx(d,{children:h}),e[20]=d,e[21]=h,e[22]=p):p=e[22];let y;e[23]!==u||e[24]!==b||e[25]!==p?(y=n.jsxs(u,{children:[b,p]}),e[23]=u,e[24]=b,e[25]=p,e[26]=y):y=e[26];let v;e[27]!==l||e[28]!==i?(v=()=>l(!i),e[27]=l,e[28]=i,e[29]=v):v=e[29];const j=!i;let C;e[30]!==i?(C=i?n.jsx($,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx($,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=i,e[31]=C):C=e[31];let k;e[32]!==s?(k=s("sessions.sidebar.dialogs.neverAsk"),e[32]=s,e[33]=k):k=e[33];let T;e[34]!==C||e[35]!==k||e[36]!==v||e[37]!==j?(T=n.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":j,children:[C,k]}),e[34]=C,e[35]=k,e[36]=v,e[37]=j,e[38]=T):T=e[38];let O;e[39]!==o?(O=()=>o(null),e[39]=o,e[40]=O):O=e[40];let M;e[41]!==s?(M=s("sessions.sidebar.dialogs.cancel"),e[41]=s,e[42]=M):M=e[42];let L;e[43]!==O||e[44]!==M?(L=n.jsx("button",{type:"button",onClick:O,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:M}),e[43]=O,e[44]=M,e[45]=L):L=e[45];let F;e[46]!==a?(F=()=>{a()},e[46]=a,e[47]=F):F=e[47];let D;e[48]!==s||e[49]!==r?.archivedBucket?(D=r?.archivedBucket?s("sessions.sidebar.bulkActions.delete"):s("sessions.sidebar.bulkActions.archive"),e[48]=s,e[49]=r?.archivedBucket,e[50]=D):D=e[50];let U;e[51]!==F||e[52]!==D?(U=n.jsx("button",{type:"button",onClick:F,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:D}),e[51]=F,e[52]=D,e[53]=U):U=e[53];let N;e[54]!==L||e[55]!==U?(N=n.jsxs("div",{className:"flex items-center gap-2",children:[L,U]}),e[54]=L,e[55]=U,e[56]=N):N=e[56];let A;e[57]!==T||e[58]!==N?(A=n.jsxs(Jn,{className:"w-full sm:items-center sm:justify-between",children:[T,N]}),e[57]=T,e[58]=N,e[59]=A):A=e[59];let H;e[60]!==f||e[61]!==g||e[62]!==A||e[63]!==w||e[64]!==y?(H=n.jsxs(f,{showCloseButton:g,className:w,children:[y,A]}),e[60]=f,e[61]=g,e[62]=A,e[63]=w,e[64]=y,e[65]=H):H=e[65];let I;return e[66]!==m||e[67]!==H||e[68]!==S||e[69]!==x?(I=n.jsx(m,{open:S,onOpenChange:x,children:H}),e[66]=m,e[67]=H,e[68]=S,e[69]=x,e[70]=I):I=e[70],I}function W3(t){const e=Ve.c(57),{t:s}=mt(),{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 m=f;let h;e[4]!==d||e[5]!==u||e[6]!==s?(h=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]=h):h=e[7];const b=h,g=!!r;let w;e[8]!==o?(w=I=>{I||o(null)},e[8]=o,e[9]=w):w=e[9];let S;e[10]!==m?(S=n.jsx(Xs,{children:m}),e[10]=m,e[11]=S):S=e[11];let x;e[12]!==b?(x=n.jsx(Js,{children:b}),e[12]=b,e[13]=x):x=e[13];let p;e[14]!==S||e[15]!==x?(p=n.jsxs(Zs,{children:[S,x]}),e[14]=S,e[15]=x,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 v=!i;let j;e[20]!==i?(j=i?n.jsx($,{name:"checkbox-blank",className:"h-4 w-4"}):n.jsx($,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=i,e[21]=j):j=e[21];let C;e[22]!==s?(C=s("sessions.sidebar.dialogs.neverAsk"),e[22]=s,e[23]=C):C=e[23];let k;e[24]!==C||e[25]!==y||e[26]!==v||e[27]!==j?(k=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":v,children:[j,C]}),e[24]=C,e[25]=y,e[26]=v,e[27]=j,e[28]=k):k=e[28];let T;e[29]!==o?(T=()=>o(null),e[29]=o,e[30]=T):T=e[30];let O;e[31]!==s?(O=s("sessions.sidebar.dialogs.cancel"),e[31]=s,e[32]=O):O=e[32];let M;e[33]!==T||e[34]!==O?(M=n.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:O}),e[33]=T,e[34]=O,e[35]=M):M=e[35];let L;e[36]!==a?(L=()=>{a()},e[36]=a,e[37]=L):L=e[37];let F;e[38]!==d||e[39]!==s?(F=s(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=s,e[40]=F):F=e[40];let D;e[41]!==L||e[42]!==F?(D=n.jsx("button",{type:"button",onClick:L,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:F}),e[41]=L,e[42]=F,e[43]=D):D=e[43];let U;e[44]!==M||e[45]!==D?(U=n.jsxs("div",{className:"flex items-center gap-2",children:[M,D]}),e[44]=M,e[45]=D,e[46]=U):U=e[46];let N;e[47]!==k||e[48]!==U?(N=n.jsxs(Jn,{className:"w-full sm:items-center sm:justify-between",children:[k,U]}),e[47]=k,e[48]=U,e[49]=N):N=e[49];let A;e[50]!==N||e[51]!==p?(A=n.jsxs(Ls,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,N]}),e[50]=N,e[51]=p,e[52]=A):A=e[52];let H;return e[53]!==g||e[54]!==A||e[55]!==w?(H=n.jsx(_s,{open:g,onOpenChange:w,children:A}),e[53]=g,e[54]=A,e[55]=w,e[56]=H):H=e[56],H}function Dp(t){const e=Ve.c(36),{t:s}=mt(),{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(Xs,{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 m;e[9]!==f?(m=n.jsx(Js,{children:f}),e[9]=f,e[10]=m):m=e[10];let h;e[11]!==u||e[12]!==m?(h=n.jsxs(Zs,{children:[u,m]}),e[11]=u,e[12]=m,e[13]=h):h=e[13];let b;e[14]!==o?(b=()=>o(null),e[14]=o,e[15]=b):b=e[15];let g;e[16]!==s?(g=s("sessions.sidebar.dialogs.cancel"),e[16]=s,e[17]=g):g=e[17];let w;e[18]!==b||e[19]!==g?(w=n.jsx("button",{type:"button",onClick:b,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:g}),e[18]=b,e[19]=g,e[20]=w):w=e[20];let S;e[21]!==s?(S=s("sessions.sidebar.bulkActions.delete"),e[21]=s,e[22]=S):S=e[22];let x;e[23]!==i||e[24]!==S?(x=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:S}),e[23]=i,e[24]=S,e[25]=x):x=e[25];let p;e[26]!==x||e[27]!==w?(p=n.jsxs(Jn,{children:[w,x]}),e[26]=x,e[27]=w,e[28]=p):p=e[28];let y;e[29]!==p||e[30]!==h?(y=n.jsxs(Ls,{showCloseButton:!1,className:"max-w-sm gap-5",children:[h,p]}),e[29]=p,e[30]=h,e[31]=y):y=e[31];let v;return e[32]!==l||e[33]!==a||e[34]!==y?(v=n.jsx(_s,{open:l,onOpenChange:a,children:y}),e[32]=l,e[33]=a,e[34]=y,e[35]=v):v=e[35],v}const K3=new Set;function z3(t){const e=Ve.c(114),{node:s,depth:r,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:f,rowKey:m,dragKey:h,renderExtras:b,pinnedSessionIds:g,expandedParents:w,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:v,setEditingId:j,setEditingRowKey:C,editTitle:k,setEditTitle:T,toggleParent:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:L,allowReselect:F,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:N,setDeleteSessionConfirm:A,startFolderRename:H,startSessionWorktreeMenuLoad:I,onEditProject:R,mobileVariant:P,alwaysShowActions:_,renderChildren:G}=t,ae=r===void 0?0:r,Se=d===void 0?!1:d,J=f===void 0?"project":f,re=G===void 0?!0:G;Os("ui.sidebar_tree_item.render");const ie=m??`${J}:${Se?"archived":"active"}:${s.session.id}`,Be=rs(G3),Ae=rs(V3),K=be(H3),q=be(U3);let X;if(e[0]!==s){X=[];const $e=Fe=>Fe.children.forEach(Ce=>{X.push(Ce.session.id),$e(Ce)});$e(s),e[0]=s,e[1]=X}else X=e[1];const me=X.join(`
989
+ `);let he;e[2]!==me?(he=me?me.split(`
990
+ `):[],e[2]=me,e[3]=he):he=e[3];const je=he;let Y;e[4]!==Be||e[5]!==H||e[6]!==Ae?(Y=($e,Fe)=>{if(!$e)return null;Fe&&rs.getState().collapsedFolderIds.has(Fe)&&Ae(Fe);const Ce=Be($e,"New folder",Fe);return H($e,Ce),Ce},e[4]=Be,e[5]=H,e[6]=Ae,e[7]=Y):Y=e[7];const ue=Y;let we;e[8]!==F||e[9]!==N||e[10]!==je||e[11]!==k||e[12]!==y||e[13]!==ie||e[14]!==P||e[15]!==s.session.id||e[16]!==D||e[17]!==U||e[18]!==A||e[19]!==T||e[20]!==j||e[21]!==C||e[22]!==K?(we={mobileVariant:P,allowReselect:F,onSessionSelected:D,resetSessionSearch:U,descendantIds:je,showDeletionDialog:K,setDeleteSessionConfirm:A,deleteSessionConfirm:N,editingId:y,setEditingId:j,setEditingRowKey:C,editingSessionId:s.session.id,editingOccurrenceKey:ie,editTitle:k,setEditTitle:T},e[8]=F,e[9]=N,e[10]=je,e[11]=k,e[12]=y,e[13]=ie,e[14]=P,e[15]=s.session.id,e[16]=D,e[17]=U,e[18]=A,e[19]=T,e[20]=j,e[21]=C,e[22]=K,e[23]=we):we=e[23];const ce=_3(we),le=b?.childRenderExtrasFor,Re=s.session.directory??o;let Oe;e[24]!==Se||e[25]!==i||e[26]!==J||e[27]!==Re?(Oe={groupDirectory:Re,projectId:i,archivedBucket:Se,renderContext:J},e[24]=Se,e[25]=i,e[26]=J,e[27]=Re,e[28]=Oe):Oe=e[28];const Te=Oe,De=h??m??s.session.id,te=b?.subtreeContainsEditing??K3,de=b?.menuOpenSessionId??null,fe=b?.nodeStructureKey??"",ge=b?.blockingBadgeSessionScopes,B=b?.relativeTimeTick;let Q;e[29]!==F||e[30]!==_||e[31]!==Te||e[32]!==le||e[33]!==N||e[34]!==ae||e[35]!==k||e[36]!==y||e[37]!==v||e[38]!==w||e[39]!==l||e[40]!==S||e[41]!==P||e[42]!==s.children||e[43]!==x||e[44]!==p||e[45]!==D||e[46]!==M||e[47]!==g||e[48]!==re||e[49]!==U||e[50]!==a||e[51]!==A||e[52]!==T||e[53]!==j||e[54]!==C||e[55]!==L||e[56]!==H||e[57]!==I||e[58]!==O?(Q=re?s.children.map($e=>n.jsx(zo,{node:$e,pinnedSessionIds:g,expandedParents:w,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:v,setEditingId:j,setEditingRowKey:C,editTitle:k,setEditTitle:T,toggleParent:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:L,allowReselect:F,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:N,setDeleteSessionConfirm:A,startFolderRename:H,startSessionWorktreeMenuLoad:I,mobileVariant:P,alwaysShowActions:_,depth:ae+1,folderOwnerKey:l,selectionScopeKey:a,...Te,renderExtras:le?.($e)},$e.session.id)):null,e[29]=F,e[30]=_,e[31]=Te,e[32]=le,e[33]=N,e[34]=ae,e[35]=k,e[36]=y,e[37]=v,e[38]=w,e[39]=l,e[40]=S,e[41]=P,e[42]=s.children,e[43]=x,e[44]=p,e[45]=D,e[46]=M,e[47]=g,e[48]=re,e[49]=U,e[50]=a,e[51]=A,e[52]=T,e[53]=j,e[54]=C,e[55]=L,e[56]=H,e[57]=I,e[58]=O,e[59]=Q):Q=e[59];let ke;e[60]!==_||e[61]!==Se||e[62]!==ue||e[63]!==ae||e[64]!==k||e[65]!==y||e[66]!==v||e[67]!==ie||e[68]!==w||e[69]!==l||e[70]!==o||e[71]!==S||e[72]!==P||e[73]!==s||e[74]!==x||e[75]!==p||e[76]!==R||e[77]!==M||e[78]!==g||e[79]!==i||e[80]!==J||e[81]!==u||e[82]!==a||e[83]!==ce.handleCancelEdit||e[84]!==ce.handleCopySessionId||e[85]!==ce.handleDeleteSession||e[86]!==ce.handleRestoreSession||e[87]!==ce.handleSaveEdit||e[88]!==ce.handleSessionDoubleClick||e[89]!==ce.handleSessionSelect||e[90]!==T||e[91]!==j||e[92]!==C||e[93]!==L||e[94]!==I||e[95]!==De||e[96]!==te||e[97]!==de||e[98]!==fe||e[99]!==ge||e[100]!==B||e[101]!==Q||e[102]!==O?(ke=n.jsx(F3,{expandedParents:w,hasSessionSearchQuery:S,normalizedSessionSearchQuery:x,notifyOnSubtasks:p,editingId:y,editingRowKey:v,setEditingId:j,setEditingRowKey:C,editTitle:k,setEditTitle:T,handleSaveEdit:ce.handleSaveEdit,handleCancelEdit:ce.handleCancelEdit,toggleParent:O,handleSessionSelect:ce.handleSessionSelect,handleSessionDoubleClick:ce.handleSessionDoubleClick,handleCopySessionId:ce.handleCopySessionId,openSidebarMenuKey:M,setOpenSidebarMenuKey:L,createFolderAndStartRename:ue,handleDeleteSession:ce.handleDeleteSession,handleRestoreSession:ce.handleRestoreSession,startSessionWorktreeMenuLoad:I,onEditProject:R,mobileVariant:P,alwaysShowActions:_,pinnedSessionIds:g,node:s,depth:ae,groupDirectory:o,projectId:i,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:Se,secondaryMeta:u,renderContext:J,rowKey:ie,dragKey:De,subtreeContainsEditing:te,menuOpenSessionId:de,nodeStructureKey:fe,blockingBadgeSessionScopes:ge,relativeTimeTick:B,children:Q}),e[60]=_,e[61]=Se,e[62]=ue,e[63]=ae,e[64]=k,e[65]=y,e[66]=v,e[67]=ie,e[68]=w,e[69]=l,e[70]=o,e[71]=S,e[72]=P,e[73]=s,e[74]=x,e[75]=p,e[76]=R,e[77]=M,e[78]=g,e[79]=i,e[80]=J,e[81]=u,e[82]=a,e[83]=ce.handleCancelEdit,e[84]=ce.handleCopySessionId,e[85]=ce.handleDeleteSession,e[86]=ce.handleRestoreSession,e[87]=ce.handleSaveEdit,e[88]=ce.handleSessionDoubleClick,e[89]=ce.handleSessionSelect,e[90]=T,e[91]=j,e[92]=C,e[93]=L,e[94]=I,e[95]=De,e[96]=te,e[97]=de,e[98]=fe,e[99]=ge,e[100]=B,e[101]=Q,e[102]=O,e[103]=ke):ke=e[103];let Ie;e[104]!==N||e[105]!==s.session.id||e[106]!==ce.confirmDeleteSession||e[107]!==A||e[108]!==q||e[109]!==K?(Ie=N?.session.id===s.session.id?n.jsx($3,{value:N,setValue:A,showDeletionDialog:K,setShowDeletionDialog:q,onConfirm:ce.confirmDeleteSession}):null,e[104]=N,e[105]=s.session.id,e[106]=ce.confirmDeleteSession,e[107]=A,e[108]=q,e[109]=K,e[110]=Ie):Ie=e[110];let oe;return e[111]!==ke||e[112]!==Ie?(oe=n.jsxs(n.Fragment,{children:[ke,Ie]}),e[111]=ke,e[112]=Ie,e[113]=oe):oe=e[113],oe}function U3(t){return t.setShowDeletionDialog}function H3(t){return t.showDeletionDialog}function V3(t){return t.toggleFolderCollapse}function G3(t){return t.createFolder}const q3=(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&&yf(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,Y3=(t,e)=>{if(t.node!==e.node&&!q3(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","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const o of r)if(t[o]!==e[o])return!1;return!0},zo=c.memo(z3,Y3),Ca=6,wd=14,Q3=Ca+14+6,X3=4;function jd(t){const e=Ve.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:xe("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:n.jsx(rf,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=l):l=e[4],o=s.slice(0,X3).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 J3(t){const e=Ve.c(96),{run:s,depth:r,laneNodes:o,blockingSessionIds:i,renderContext:l,projectId:a,projectLabel:d,expansionKey:u,expanded:f,forceExpanded:m,notifyOnSubtasks:h,toggleParent:b}=t,{t:g}=mt();let w;e[0]!==s.key?(w=ue=>ue.runOverviewKey===s.key,e[0]=s.key,e[1]=w):w=e[1];const S=be(w),x=l==="timeline";let p;e[2]!==x||e[3]!==a?(p=ue=>x&&a?ue.projects.find(we=>we.id===a)??null:null,e[2]=x,e[3]=a,e[4]=p):p=e[4];const y=Xt(p),v=s.lanes.length;let j;e[5]!==v||e[6]!==g?(j=v===1?g("sessions.sidebar.run.laneCountSingle",{count:v}):g("sessions.sidebar.run.laneCountPlural",{count:v}),e[5]=v,e[6]=g,e[7]=j):j=e[7];const C=j;let k;e[8]!==o?(k=[...o],e[8]=o,e[9]=k):k=e[9];const T=k;let O;e[10]!==T||e[11]!==i||e[12]!==h?(O=n.jsx(mu,{nodes:T,blockingSessionIds:i,includeUnreadSubtasks:h}),e[10]=T,e[11]=i,e[12]=h,e[13]=O):O=e[13];const M=O,L=S?"text-interactive-selection-foreground":"text-foreground/80";let F;e[14]!==s.key?(F=()=>be.getState().setRunOverviewKey(s.key),e[14]=s.key,e[15]=F):F=e[15];const D=F;if(x){const ue=s.key,we=S?"page":void 0;let ce;e[16]!==s.title||e[17]!==g?(ce=g("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[16]=s.title,e[17]=g,e[18]=ce):ce=e[18];let le;e[19]===Symbol.for("react.memo_cache_sentinel")?(le={paddingLeft:Ca+4},e[19]=le):le=e[19];const Re=S?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Oe;e[20]!==Re?(Oe=xe("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pr-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Re),e[20]=Re,e[21]=Oe):Oe=e[21];const Te=s.title;let De;e[22]===Symbol.for("react.memo_cache_sentinel")?(De=n.jsx(Zi,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[22]=De):De=e[22];let te;e[23]!==C?(te=n.jsxs(n.Fragment,{children:[De,n.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:C})]}),e[23]=C,e[24]=te):te=e[24];let de;e[25]!==s.lastActivity?(de=bf(s.lastActivity),e[25]=s.lastActivity,e[26]=de):de=e[26];let fe;e[27]!==s.providerIDs?(fe=n.jsx(jd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[27]=s.providerIDs,e[28]=fe):fe=e[28];let ge;e[29]!==M||e[30]!==d||e[31]!==s.title||e[32]!==te||e[33]!==de||e[34]!==fe||e[35]!==y||e[36]!==L?(ge=n.jsx(va,{project:y,projectLabel:d,title:Te,titleClassName:L,branchLabel:null,thirdLineLead:te,statusDot:M,pinnedMarker:null,timeSlot:de,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:fe,hideMetaOnHoverClass:""}),e[29]=M,e[30]=d,e[31]=s.title,e[32]=te,e[33]=de,e[34]=fe,e[35]=y,e[36]=L,e[37]=ge):ge=e[37];let B;return e[38]!==D||e[39]!==s.key||e[40]!==Oe||e[41]!==ge||e[42]!==we||e[43]!==ce?(B=n.jsx("button",{type:"button","data-run-row":ue,"aria-current":we,"aria-label":ce,onClick:D,style:le,className:Oe,children:ge}),e[38]=D,e[39]=s.key,e[40]=Oe,e[41]=ge,e[42]=we,e[43]=ce,e[44]=B):B=e[44],B}let U;e[45]!==u||e[46]!==m||e[47]!==b?(U=ue=>{ue.stopPropagation(),m||b(u)},e[45]=u,e[46]=m,e[47]=b,e[48]=U):U=e[48];const N=U,A=s.key,H=S?"page":void 0,I=Q3+r*wd;let R;e[49]!==I?(R={paddingLeft:I},e[49]=I,e[50]=R):R=e[50];const P=S?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let _;e[51]!==P?(_=xe("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-2.5",P),e[51]=P,e[52]=_):_=e[52];let G;e[53]!==N?(G=ue=>{(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),N(ue))},e[53]=N,e[54]=G):G=e[54];const ae=Ca+r*wd;let Se;e[55]!==ae?(Se={left:ae},e[55]=ae,e[56]=Se):Se=e[56];let J;e[57]!==f||e[58]!==g?(J=g(f?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[57]=f,e[58]=g,e[59]=J):J=e[59];const re=f?"arrow-down-s":"arrow-right-s";let ie;e[60]!==re?(ie=n.jsx($,{name:re,className:"h-3 w-3"}),e[60]=re,e[61]=ie):ie=e[61];let Be;e[62]!==f||e[63]!==G||e[64]!==Se||e[65]!==J||e[66]!==ie||e[67]!==N?(Be=n.jsx("button",{type:"button",onClick:N,onKeyDown:G,style:Se,className:"absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":f,"aria-label":J,children:ie}),e[62]=f,e[63]=G,e[64]=Se,e[65]=J,e[66]=ie,e[67]=N,e[68]=Be):Be=e[68];let Ae;e[69]!==D?(Ae=ue=>{ue.stopPropagation(),D()},e[69]=D,e[70]=Ae):Ae=e[70];let K;e[71]!==s.title||e[72]!==g?(K=g("sessions.sidebar.run.openOverviewAria",{title:s.title}),e[71]=s.title,e[72]=g,e[73]=K):K=e[73];let q;e[74]===Symbol.for("react.memo_cache_sentinel")?(q=n.jsx(Zi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[74]=q):q=e[74];let X;e[75]!==L?(X=xe("block min-w-0 flex-1 truncate typography-ui-label font-normal",L),e[75]=L,e[76]=X):X=e[76];let me;e[77]!==s.title||e[78]!==X?(me=n.jsx("span",{dir:"auto",className:X,children:s.title}),e[77]=s.title,e[78]=X,e[79]=me):me=e[79];let he;e[80]!==s.providerIDs?(he=n.jsx(jd,{providerIDs:s.providerIDs,ringClass:"ring-sidebar"}),e[80]=s.providerIDs,e[81]=he):he=e[81];let je;e[82]!==M||e[83]!==Ae||e[84]!==K||e[85]!==me||e[86]!==he?(je=n.jsxs("button",{type:"button",onClick:Ae,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":K,children:[q,me,he,M]}),e[82]=M,e[83]=Ae,e[84]=K,e[85]=me,e[86]=he,e[87]=je):je=e[87];let Y;return e[88]!==D||e[89]!==s.key||e[90]!==R||e[91]!==_||e[92]!==Be||e[93]!==je||e[94]!==H?(Y=n.jsxs("div",{"data-run-row":A,"aria-current":H,onClick:D,style:R,className:_,children:[Be,je]}),e[88]=D,e[89]=s.key,e[90]=R,e[91]=_,e[92]=Be,e[93]=je,e[94]=H,e[95]=Y):Y=e[95],Y}const Z3=c.memo(J3),e4=24,t4=t=>Array.from({length:Math.min(t,e4)},(e,s)=>s),s4=(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)},n4=(t,e)=>t.find(s=>s.end>e)?.index??0,r4={"pb-2":8,"pb-6":24},kd=(t,e)=>`${t.kind}:${"renderContext"in t?t.renderContext:""}:${Uo(t,e)??""}`,o4=(t,e)=>{const s=Uo(t,e);return t.estimateSize+(s?r4[s]:0)},Uo=(t,e)=>t.key.startsWith("activity:")&&e!==void 0&&!e.key.startsWith("activity:")&&(e.kind==="project-header"||e.kind==="group-header")?"pb-6":e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0;function i4({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.useCallback(p=>{const y=i[p];if(!y)return 32;const v=i[p+1];return a.current.get(kd(y,v))??o4(y,v)},[i]),u=c.useCallback((p,y,v)=>{const j=$1(p,y,v),C=v.indexFromElement(p),k=i[C];return k&&a.current.set(kd(k,i[C+1]),j),j},[i]),f=c.useCallback(p=>i[p]?.key??p,[i]),m=c.useCallback(p=>s4(W1(p),s,i.length),[s,i.length]),h=_1({count:i.length,enabled:e!==null,getScrollElement:l,estimateSize:d,measureElement:u,getItemKey:f,overscan:8,rangeExtractor:m}),b=h.getVirtualItems(),g=e?h.getTotalSize():0,w=e?Math.max(g-e.clientHeight,0):0,S=e?Math.min(e.scrollTop,w):0,x=n4(b,S);if(c.useLayoutEffect(()=>{o(x)},[x,o]),!e){const p=t4(i.length),y=p.reduce((j,C)=>j+(i[C]?.estimateSize??0),0),v=i.reduce((j,C)=>j+C.estimateSize,0);return n.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[p.map(j=>{const C=i[j];return C?n.jsx("div",{className:Uo(C,i[j+1]),children:r(C,j)},C.key):null}),v>y?n.jsx("div",{"aria-hidden":"true",style:{height:v-y}}):null]})}return n.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:g,position:"relative"},children:b.map(p=>{const y=i[p.index];return y?n.jsx("div",{className:`[&_[data-session-row]]:my-px ${Uo(y,i[p.index+1])??""}`,"data-index":p.index,"data-sidebar-virtual-start":p.start,ref:h.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${p.start}px)`},children:r(y,p.index)},y.key):null})})}const a4={work:"eye",chats:"chat-4","active-now":"history",timeline:"folder"},Cd={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},l4=t=>{const e=Ve.c(48),{activityKey:s,collapsed:r,forceExpanded:o,alwaysShowActions:i,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:f}=mt(),m=s==="chats";if(u){const F=o?void 0:l;let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=xe("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=D):D=e[0];const U=!r,N=Cd[s];let A;e[1]!==f||e[2]!==N?(A=f(N),e[1]=f,e[2]=N,e[3]=A):A=e[3];let H;e[4]!==A?(H=n.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:A}),e[4]=A,e[5]=H):H=e[5];let I;e[6]!==r||e[7]!==o?(I=o?null:n.jsx($,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=o,e[8]=I):I=e[8];let R;return e[9]!==o||e[10]!==F||e[11]!==U||e[12]!==H||e[13]!==I?(R=n.jsx("div",{className:"relative group/chats -mr-2",children:n.jsxs("button",{type:"button",onClick:F,disabled:o,className:D,"aria-expanded":U,children:[H,I]})}),e[9]=o,e[10]=F,e[11]=U,e[12]=H,e[13]=I,e[14]=R):R=e[14],R}const h=o?void 0:l,b=m?"pr-10":"pr-3.5";let g;e[15]!==b?(g=xe("group flex w-full items-center gap-1.5 py-1 pl-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",b),e[15]=b,e[16]=g):g=e[16];const w=!r,S=a4[s],x=!o&&"group-hover:hidden";let p;e[17]!==x?(p=xe("h-3.5 w-3.5 text-muted-foreground/80",x),e[17]=x,e[18]=p):p=e[18];let y;e[19]!==S||e[20]!==p?(y=n.jsx($,{name:S,className:p}),e[19]=S,e[20]=p,e[21]=y):y=e[21];let v;e[22]!==r||e[23]!==o?(v=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($,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=o,e[24]=v):v=e[24];let j;e[25]!==v||e[26]!==y?(j=n.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[y,v]}),e[25]=v,e[26]=y,e[27]=j):j=e[27];const C=Cd[s];let k;e[28]!==f||e[29]!==C?(k=f(C),e[28]=f,e[29]=C,e[30]=k):k=e[30];let T;e[31]!==k?(T=n.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:k}),e[31]=k,e[32]=T):T=e[32];let O;e[33]!==o||e[34]!==j||e[35]!==T||e[36]!==h||e[37]!==g||e[38]!==w?(O=n.jsxs("button",{type:"button",onClick:h,disabled:o,className:g,"aria-expanded":w,children:[j,T]}),e[33]=o,e[34]=j,e[35]=T,e[36]=h,e[37]=g,e[38]=w,e[39]=O):O=e[39];let M;e[40]!==i||e[41]!==m||e[42]!==a||e[43]!==f?(M=m?n.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),a()},className:xe("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",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":f("sessions.sidebar.header.actions.newSession"),children:n.jsx($,{name:"add",className:"h-4 w-4"})}):null,e[40]=i,e[41]=m,e[42]=a,e[43]=f,e[44]=M):M=e[44];let L;return e[45]!==O||e[46]!==M?(L=n.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[O,M]}),e[45]=O,e[46]=M,e[47]=L):L=e[47],L},Ep=c.createContext(null);function Nd(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 c4(t){const e=Ve.c(14),{enabled:s,suspended:r,layoutKey:o,scrollRef:i,children:l}=t,a=r===void 0?!1:r,d=o===void 0?"":o;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const f=c.useRef(u),m=c.useRef(null);let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=p=>(f.current.add(p),m.current?.(),()=>{f.current.delete(p),m.current?.()}),e[1]=h):h=e[1];const b=h;let g;e[2]!==s||e[3]!==i||e[4]!==a?(g=()=>{const p=i.current;if(!s||a||!p)return;const y=document.createElement("div");y.dataset.sidebarCrossfadeLayer="true",y.className="pointer-events-none sticky top-0 z-30 h-0",y.style.marginBlock="0px",p.prepend(y);let v=null,j=null,C=null,k=0;const T=new Set;let O=[];const M=window.matchMedia("(prefers-reduced-motion: reduce)"),L=u4,F=()=>{C?.cancel(),C=null,j?.remove(),j=null},D=()=>{let I=null,R=-1/0;for(const{entry:P,top:_}of O)_<=p.scrollTop&&_>=R&&(R=_,I=P);if(v!==I){if(F(),v&&I&&!M.matches){const P=v.host.cloneNode(!0);P instanceof HTMLElement&&(P.inert=!0,P.setAttribute("aria-hidden","true"),P.querySelectorAll("[id]").forEach(d4),P.className="pointer-events-none absolute inset-x-0 top-0 z-30",j=P)}v&&(L(v,v.slot),v.slot.style.removeProperty("height")),v=I,y.hidden=!I,I&&(I.slot.style.height=`${I.host.getBoundingClientRect().height}px`,L(I,y),j&&(y.append(j),C=j.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),C.onfinish=F))}},U=()=>{v&&(v.slot.style.height=`${v.host.getBoundingClientRect().height}px`);const I=Nd(p)+p.clientTop;O=Array.from(f.current,R=>({entry:R,top:Nd(R.slot)-I})),D()},N=new ResizeObserver(U),A=new MutationObserver(()=>{cancelAnimationFrame(k),k=requestAnimationFrame(U)});N.observe(p);const H=()=>{A.disconnect();for(const I of T)f.current.has(I)||(N.unobserve(I.host),I.slot.parentElement&&N.unobserve(I.slot.parentElement),T.delete(I));for(const I of f.current){const R=I.slot.closest("[data-sidebar-virtual-start]");R&&A.observe(R,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),T.has(I)||(N.observe(I.host),I.slot.parentElement&&N.observe(I.slot.parentElement),T.add(I))}cancelAnimationFrame(k),k=requestAnimationFrame(U)};return m.current=H,p.addEventListener("scroll",D,{passive:!0}),H(),U(),()=>{m.current=null,cancelAnimationFrame(k),p.removeEventListener("scroll",D),N.disconnect(),A.disconnect(),F(),y.hidden=!0,v&&(L(v,v.slot),v.slot.style.removeProperty("height")),y.remove()}},e[2]=s,e[3]=i,e[4]=a,e[5]=g):g=e[5];let w;e[6]!==s||e[7]!==d||e[8]!==i||e[9]!==a?(w=[s,a,d,i],e[6]=s,e[7]=d,e[8]=i,e[9]=a,e[10]=w):w=e[10],c.useLayoutEffect(g,w);const S=s?b:null;let x;return e[11]!==l||e[12]!==S?(x=n.jsx(Ep.Provider,{value:S,children:l}),e[11]=l,e[12]=S,e[13]=x):x=e[13],x}function d4(t){return t.removeAttribute("id")}function u4(t,e){const s=document.activeElement,r=s instanceof HTMLElement&&t.host.contains(s);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&s.focus({preventScroll:!0})}function f4(t){const e=Ve.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(p4);let l,a;e[3]!==i||e[4]!==r?(l=()=>{const h=o.current;if(!h)return;h.append(i);const b=r({slot:h,host:i});return()=>{b(),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=Sm.createPortal(u,i),e[10]=i,e[11]=u,e[12]=f):f=e[12];let m;return e[13]!==f?(m=n.jsxs(n.Fragment,{children:[d,f]}),e[13]=f,e[14]=m):m=e[14],m}function p4(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function Rp(t){const e=Ve.c(3),s=c.useContext(Ep);let r;return e[0]!==t||e[1]!==s?(r=s?n.jsx(f4,{...t,register:s}):n.jsx("div",{...t}),e[0]=t,e[1]=s,e[2]=r):r=e[2],r}const m4=t=>{const e=Ve.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=()=>{Mr.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},Li=t=>{const e=Ve.c(25),{id:s,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u,labelClassName:f}=t,m=u===void 0?!1:u,{currentTheme:h}=Kr(),b=o?of[o]:null,g=i?af[i]??null:null,w=d!==void 0,S=w?m?"hidden":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0":void 0;let x;e[0]!==m||e[1]!==w||e[2]!==d?(x=w?n.jsx("span",{className:xe("h-3.5 w-3.5 items-center justify-center text-muted-foreground",m?"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($,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=m,e[1]=w,e[2]=d,e[3]=x):x=e[3];let p;e[4]!==m||e[5]!==h||e[6]!==w||e[7]!==g||e[8]!==S||e[9]!==s||e[10]!==a||e[11]!==l||e[12]!==b?(p=l?n.jsx("span",{className:xe("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",w&&m?"hidden":"inline-flex",S),style:a?{backgroundColor:a}:void 0,children:n.jsx(lf,{project:{id:s,iconImage:l},options:{themeVariant:h.metadata.variant,iconColor:h.colors.surface.foreground},className:"h-full w-full object-contain",fallback:b?n.jsx($,{name:b,className:"h-3.5 w-3.5",style:g?{color:g}:void 0}):n.jsx($,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:g?{color:g}:void 0})})}):b?n.jsx($,{name:b,className:xe("h-3.5 w-3.5",S),style:g?{color:g}:void 0}):n.jsx($,{name:"folder",className:xe("h-3.5 w-3.5 text-muted-foreground/80",S),style:g?{color:g}:void 0}),e[4]=m,e[5]=h,e[6]=w,e[7]=g,e[8]=S,e[9]=s,e[10]=a,e[11]=l,e[12]=b,e[13]=p):p=e[13];let y;e[14]!==x||e[15]!==p?(y=n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[x,p]}),e[14]=x,e[15]=p,e[16]=y):y=e[16];let v;e[17]!==f?(v=xe("truncate typography-ui-label font-semibold lowercase text-foreground",f),e[17]=f,e[18]=v):v=e[18];let j;e[19]!==r||e[20]!==v?(j=n.jsx("span",{className:v,children:r}),e[19]=r,e[20]=v,e[21]=j):j=e[21];let C;return e[22]!==y||e[23]!==j?(C=n.jsxs(n.Fragment,{children:[y,j]}),e[22]=y,e[23]=j,e[24]=C):C=e[24],C},h4=t=>{const e=Ve.c(66),{id:s,disabled:r,projectLabel:o,projectDescription:i,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:m,isRepo:h,hideDirectoryControls:b,alwaysShowActions:g,onToggle:w,onNewSession:S,onNewWorktreeSession:x,onManageWorktrees:p,onManageSpaces:y,onRenameStart:v,onArchiveAll:j,onClose:C,children:k,showCreateButtons:T,hideHeader:O,statusIndicator:M,openSidebarMenuKey:L,setOpenSidebarMenuKey:F,projectPickerOptions:D,onProjectSelect:U}=t,N=r===void 0?!1:r,A=T===void 0?!0:T,H=O===void 0?!1:O,I=M===void 0?null:M,{t:R}=mt(),P=m4(l);let _;e[0]!==N||e[1]!==s?(_={id:s,disabled:N},e[0]=N,e[1]=s,e[2]=_):_=e[2];const{attributes:G,listeners:ae,setNodeRef:Se,transform:J,transition:re,isDragging:ie}=si(_),Be=c.useRef(!1),Ae=`project:${s}`,K=L===Ae,[q,X]=c.useState(!1),me=!!(D&&U);let he;e[3]!==Ae||e[4]!==F?(he=Ce=>{Ce&&X(!1),F(Ce?Ae:null)},e[3]=Ae,e[4]=F,e[5]=he):he=e[5];const je=he;let Y;e[6]!==b||e[7]!==h||e[8]!==j||e[9]!==C||e[10]!==y||e[11]!==p||e[12]!==S||e[13]!==v||e[14]!==A||e[15]!==R?(Y=Ce=>n.jsxs(n.Fragment,{children:[A&&!h&&!b&&S&&n.jsxs(Ce,{onClick:S,children:[n.jsx($,{name:"add",className:"mr-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.newSession")]}),h&&!b&&p&&n.jsxs(Ce,{onClick:p,children:[n.jsx($,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.manageWorktrees")]}),h&&!b&&y&&n.jsxs(Ce,{onClick:y,children:[n.jsx($,{name:"box-3",className:"mr-1.5 h-4 w-4"}),R("spaces.page.menuItem")]}),n.jsxs(Ce,{onClick:v,children:[n.jsx($,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.edit")]}),j&&n.jsxs(Ce,{onClick:j,children:[n.jsx($,{name:"archive",className:"mr-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.archiveAll")]}),n.jsxs(Ce,{onClick:C,className:"text-destructive focus:text-destructive",children:[n.jsx($,{name:"close",className:"mr-1.5 h-4 w-4"}),R("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=h,e[8]=j,e[9]=C,e[10]=y,e[11]=p,e[12]=S,e[13]=v,e[14]=A,e[15]=R,e[16]=Y):Y=e[16];const ue=Y,we=y4,ce=x4,le=v4;let Re;e[17]===Symbol.for("react.memo_cache_sentinel")?(Re=Ce=>{(Ce.button===2||Ce.button===0&&Ce.ctrlKey)&&(Be.current=!0)},e[17]=Re):Re=e[17];const Oe=Re;let Te;e[18]!==w?(Te=Ce=>{if(Ce.currentTarget.blur(),Be.current){Be.current=!1;return}w()},e[18]=w,e[19]=Te):Te=e[19];const De=Te,de=(A&&h&&!b&&!!x?1:0)+(b?0:1),fe=de===2?"[--oc-actions-reserve:66px]":de===1&&A?"[--oc-actions-reserve:38px]":A||de===1?"[--oc-actions-reserve:12px]":void 0,ge=g?void 0:K?"oc-actions-mask":"group-hover/project:oc-actions-mask group-focus-within/project:oc-actions-mask",B=g?void 0:K?"opacity-0":"transition-opacity group-hover/project:opacity-0 group-focus-within/project:opacity-0";let Q;e[20]!==J?(Q=ni.Transform.toString(J),e[20]=J,e[21]=Q):Q=e[21];let ke;e[22]!==Q||e[23]!==re?(ke={transform:Q,transition:re},e[22]=Q,e[23]=re,e[24]=ke):ke=e[24];const Ie=ie&&"opacity-30";let oe;e[25]!==Ie?(oe=xe("relative",Ie),e[25]=Ie,e[26]=oe):oe=e[26];let $e;e[27]!==g||e[28]!==G||e[29]!==P||e[30]!==je||e[31]!==De||e[32]!==fe||e[33]!==B||e[34]!==ge||e[35]!==b||e[36]!==H||e[37]!==s||e[38]!==m||e[39]!==q||e[40]!==K||e[41]!==me||e[42]!==h||e[43]!==ae||e[44]!==S||e[45]!==x||e[46]!==U||e[47]!==d||e[48]!==i||e[49]!==l||e[50]!==a||e[51]!==f||e[52]!==u||e[53]!==o||e[54]!==D||e[55]!==ue||e[56]!==A||e[57]!==I||e[58]!==R?($e=H?null:n.jsx(n.Fragment,{children:n.jsxs(zu,{open:q,onOpenChange:X,children:[n.jsx(Ku,{render:n.jsx(Rp,{className:xe("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:Ce=>{b||(Ce.preventDefault(),X(!0))}}),children:n.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...G,children:[me?n.jsxs(Ps,{children:[n.jsx(Ns,{asChild:!0,children:n.jsxs("button",{type:"button",className:xe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",h&&!b?g||K?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":g||K?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":R("sessions.sidebar.project.selectAria",{project:o}),children:[n.jsx(Li,{id:s,projectLabel:o,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f}),n.jsx($,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?n.jsx(_r,{directory:l,className:"ml-auto"}):null]})}),n.jsx(As,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:D?.map(Ce=>n.jsxs(Gt,{onClick:()=>U?.(Ce.id),className:"flex items-center justify-between gap-3",title:Ce.projectDescription,children:[n.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:n.jsx(Li,{...Ce})}),Ce.id===s?n.jsx($,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},Ce.id))})]}):n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsxs("button",{type:"button",onMouseDown:Oe,onClick:De,...ae,className:xe("@container flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing",g?h&&!b?"pr-20":"pr-14":fe),children:[n.jsx(Li,{id:s,projectLabel:o,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:f,isCollapsed:m,alwaysShowActions:g,labelClassName:xe("[--oc-actions-inset:20px]",ge)}),P?n.jsx("span",{className:xe("inline-flex flex-shrink-0 items-center text-status-warning",B),title:R("sessions.sidebar.project.folderMissing"),"aria-label":R("sessions.sidebar.project.folderMissing"),children:n.jsx($,{name:"alert",className:"h-3 w-3"})}):null,I?n.jsx("span",{className:xe("ml-1 inline-flex flex-shrink-0 items-center",B),children:I}):null,l?n.jsx(_r,{directory:l,className:xe("ml-auto",B)}):null]})}),n.jsx(Pt,{side:"right",sideOffset:8,children:i})]}),n.jsxs("div",{className:xe("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",A?"right-7":"right-0.5"),children:[A&&h&&!b&&x?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),x()},className:xe("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",g?"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($,{name:"node-tree",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:R("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:n.jsxs(Ps,{open:K,onOpenChange:je,children:[n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:xe("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",K?"opacity-100 pointer-events-auto":g?"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:ce,onMouseDown:le,onClick:we,children:n.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),n.jsx(As,{align:"end",className:"min-w-[180px]",children:ue(Gt)})]})]}),A&&S?n.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ce=>{Ce.stopPropagation(),S()},className:xe("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",g?"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(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:n.jsx($,{name:"add",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:R(h?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),n.jsx(Wu,{className:"min-w-[180px]",children:ue(qn)})]})}),e[27]=g,e[28]=G,e[29]=P,e[30]=je,e[31]=De,e[32]=fe,e[33]=B,e[34]=ge,e[35]=b,e[36]=H,e[37]=s,e[38]=m,e[39]=q,e[40]=K,e[41]=me,e[42]=h,e[43]=ae,e[44]=S,e[45]=x,e[46]=U,e[47]=d,e[48]=i,e[49]=l,e[50]=a,e[51]=f,e[52]=u,e[53]=o,e[54]=D,e[55]=ue,e[56]=A,e[57]=I,e[58]=R,e[59]=$e):$e=e[59];let Fe;return e[60]!==k||e[61]!==Se||e[62]!==ke||e[63]!==oe||e[64]!==$e?(Fe=n.jsxs("div",{ref:Se,style:ke,className:oe,children:[$e,k]}),e[60]=k,e[61]=Se,e[62]=ke,e[63]=oe,e[64]=$e,e[65]=Fe):Fe=e[65],Fe},g4=t=>{const e=Ve.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:m,isDragging:h}=si(l);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const g=b;let w;e[6]!==f?(w=ni.Transform.toString(f),e[6]=f,e[7]=w):w=e[7];let S;e[8]!==w||e[9]!==m?(S={transform:w,transition:m},e[8]=w,e[9]=m,e[10]=S):S=e[10];const x=h&&"opacity-50";let p;e[11]!==x?(p=xe("space-y-0.5 rounded-md",x),e[11]=x,e[12]=p):p=e[12];let y;e[13]!==o||e[14]!==g?(y=o(g),e[13]=o,e[14]=g,e[15]=y):y=e[15];let v;return e[16]!==d||e[17]!==S||e[18]!==p||e[19]!==y?(v=n.jsx("div",{ref:d,style:S,className:p,children:y}),e[16]=d,e[17]=S,e[18]=p,e[19]=y,e[20]=v):v=e[20],v},b4=c.memo(g4);function y4(t){t.stopPropagation()}function x4(t){t.stopPropagation()}function v4(t){t.stopPropagation()}const Ad=[],S4=t=>{const e=Ve.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=fu(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},_i=(t,e)=>e?t.sessions.some(s=>xr(s,e)):!1,w4=(t,e,s)=>t.sessions.some(r=>hp(r,r,e,s,t.directory,t.directory)),j4=(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)},k4=(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)},C4=(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&&w4(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&j4(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&k4(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(_i(e.group,t.editingId)||_i(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&_i(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const s=e.group.isArchivedBucket===!0,r=$o(e.group.sessions,t.openSidebarMenuKey,"project",s),o=$o(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},N4=c.memo(function(e){const s=Ve.c(23),{label:r,sessions:o,worktree:i}=e,{t:l}=mt(),a=Np();let d;s[0]!==o||s[1]!==a||s[2]!==i?(d=x=>{x.stopPropagation(),wn.requestDelete({sessions:o,mode:"worktree",worktree:i,skipDialogIfSafe:a||x.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=xe("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 m;s[6]!==r||s[7]!==a||s[8]!==l?(m=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]=m):m=s[9];let h;s[10]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx($,{name:"delete-bin",className:"h-4 w-4"}),s[10]=h):h=s[10];let b;s[11]!==d||s[12]!==f||s[13]!==m?(b=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:d,className:f,"aria-label":m,children:h})}),s[11]=d,s[12]=f,s[13]=m,s[14]=b):b=s[14];let g;s[15]!==a||s[16]!==l?(g=l(a?"sessions.sidebar.group.actions.deleteWorktreeAndBranch":"sessions.sidebar.group.actions.deleteWorktree"),s[15]=a,s[16]=l,s[17]=g):g=s[17];let w;s[18]!==g?(w=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:g})}),s[18]=g,s[19]=w):w=s[19];let S;return s[20]!==b||s[21]!==w?(S=n.jsxs(Dt,{children:[b,w]}),s[20]=b,s[21]=w,s[22]=S):S=s[22],S}),Pd=[];function A4(t){const{t:e}=mt(),s=qa(),r=zm(t.group.space?.id),{group:o,groupKey:i,projectId:l,hideGroupLabel:a,renderBody:d=!0,hasSessionSearchQuery:u,normalizedSessionSearchQuery:f,groupSearchDataByGroup:m,visibleSessionCount:h,sessionBatchSize:b,collapsedGroups:g,hideDirectoryControls:w,showMoreGroupSessions:S,resetGroupSessionLimit:x,mobileVariant:p,alwaysShowActions:y,activeProjectId:v,setActiveProjectIdOnly:j,setSessionSwitcherOpen:C,openNewSessionDraft:k,pinnedSessionIds:T,sessionOrderIndex:O,notifyOnSubtasks:M,onToggleCollapsedGroup:L,dragHandleProps:F,compactBodyPadding:D=!1,expandedParents:U,editingId:N,editingRowKey:A,openSidebarMenuKey:H,editTitle:I,folderRename:R,setFolderRenameDraft:P,clearFolderRename:_}=t,G=rs(Ee=>Ee.toggleFolderCollapse),ae=rs(Ee=>Ee.renameFolder),Se=rs(Ee=>Ee.deleteFolder),J=rs(Ee=>Ee.addSessionToFolder),re=be(Ee=>Ee.showDeletionDialog),[ie,Be]=c.useState(null),Ae=c.useCallback((Ee,Qe)=>{const rt=O.get(Ee.session.id),pt=O.get(Qe.session.id);if(rt!==void 0||pt!==void 0){if(rt===void 0)return 1;if(pt===void 0)return-1;if(rt!==pt)return rt-pt}return Va(Ee.session,Qe.session,T,Ha)},[T,O]),K=u?m.get(o):null,q=u?!1:g.has(i),X=lx(!o.isMain&&o.worktree?o.worktree.path:null),me=o.isMain||o.isArchivedBucket||a?null:ot(o.directory??null),he=o.isMain||o.isArchivedBucket||a?null:o.branch?.trim()||null,je=df(me,he),Y=je?`var(--pr-${je.visualState})`:void 0,ue=pf(je,e),we=je?_a(je.provider,je.number):"",ce=je?ue?`${we} · ${ue}`:we:void 0,le=Ur(),Re=c.useMemo(()=>{const Ee=o.folderScopes?.map(Qe=>ot(Qe.directory))??[ot(o.directory??null)];return[...new Set(Ee.filter(Qe=>!!Qe))]},[o.directory,o.folderScopes]);c.useSyncExternalStore(c.useCallback(Ee=>Re.length>0?le.subscribeBootstrap(Ee):()=>{},[Re.length,le]),c.useCallback(()=>Re.map(Ee=>`${Ee}\0${le.getBootstrapState(Ee)??""}\0${le.getBootstrapFailure(Ee)??""}\0${le.getInitializationState(Ee)??""}\0${le.getInitializationFailure(Ee)??""}`).join(""),[Re,le]),c.useCallback(()=>"",[]));const Oe=Re.some(Ee=>{const Qe=le.getBootstrapState(Ee);return Qe==="queued"||Qe==="running"}),Te=Re.find(Ee=>le.getBootstrapState(Ee)==="failed"||le.getInitializationState(Ee)==="failed")??null,De=Te!==null&&le.getBootstrapState(Te)==="failed",te=Te?De?le.getBootstrapFailure(Te):le.getInitializationFailure(Te):void 0,de=te==="os-permission"&&ou(),[fe,ge]=c.useState(!1),B=c.useCallback(()=>{Te&&le.requestBootstrap({directory:Te,priority:q?"visible":"expanded",reason:o.isMain?"project-expanded":"worktree-expanded",force:!0})},[le,Te,o.isMain,q]),Q=c.useCallback(async()=>{if(!(!Te||!de||fe)){ge(!0);try{(await iu(Te)).success&&B()}finally{ge(!1)}}},[de,Te,fe,B]),ke=b??(w?10:5),Ie=Math.max(ke,h??ke),oe=u?K?.groupMatches===!0:!1,$e=u,Fe=c.useMemo(()=>[...$e?K?.filteredNodes??[]:o.sessions].sort(Ae),[Ae,o.sessions,K?.filteredNodes,$e]),Ce=o.folderScopeKey??ot(o.directory??null),Ue=Rn(l,o.directory),pe=c.useMemo(()=>o.folderScopes&&o.folderScopes.length>0?o.folderScopes:Ce?[{scopeKey:Ce,directory:o.directory??null}]:[],[Ce,o.directory,o.folderScopes]),ne=rs(yr(c.useCallback(Ee=>pe.map(({scopeKey:Qe})=>Ee.foldersMap[Qe]??Ad),[pe]))),Me=c.useMemo(()=>pe.flatMap(({scopeKey:Ee,directory:Qe},rt)=>(ne[rt]??Ad).map(Mt=>({folder:Mt,scopeKey:Ee,scopeDirectory:Qe}))),[ne,pe]),He=rs(yr(c.useCallback(Ee=>new Set(ne.flatMap(Qe=>Qe.filter(rt=>Ee.collapsedFolderIds.has(rt.id)).map(rt=>rt.id))),[ne]))),Ye=c.useMemo(()=>{const Ee=new Map,Qe=rt=>{rt.forEach(pt=>{Ee.set(pt.session.id,pt),pt.children.length>0&&Qe(pt.children)})};return Qe(Fe),Ee},[Fe]),Xe=c.useMemo(()=>Me.map(({folder:Ee,scopeKey:Qe,scopeDirectory:rt})=>{const pt=xa(Ee.sessionIds,Ye).sort(Ae);return{folder:Ee,scopeKey:Qe,scopeDirectory:rt,nodes:pt}}),[Me,Ye,Ae]),Je=c.useMemo(()=>{const Ee=mp(Xe.map(({folder:Qe,nodes:rt})=>({id:Qe.id,name:Qe.name,parentId:Qe.parentId,nodeCount:rt.length})),{archivedBucket:o.isArchivedBucket===!0,searchQuery:u?f:""});return Xe.filter(({folder:Qe})=>Ee.has(Qe.id))},[Xe,o.isArchivedBucket,u,f]),bt=N,et=H,lt=c.useMemo(()=>new Set(Je.flatMap(Ee=>Ee.folder.sessionIds)),[Je]),xt=c.useMemo(()=>Fe.filter(Ee=>!lt.has(Ee.session.id)),[Fe,lt]),wt=c.useMemo(()=>{const Ee=new Map(Je.map(Qe=>[Qe.folder.id,Qe]));return pp(Je.map(Qe=>Qe.folder)).map(Qe=>Ee.get(Qe.id)).filter(Qe=>!!Qe)},[Je]),dt=c.useMemo(()=>{const Ee=new Map;return Je.forEach(Qe=>{if(!Qe.folder.parentId)return;const rt=Ee.get(Qe.folder.parentId)??[];rt.push(Qe),Ee.set(Qe.folder.parentId,rt)}),Ee},[Je]),It=c.useMemo(()=>{const Ee=new Map(Je.map(pt=>[pt.folder.id,pt])),Qe=new Map,rt=(pt,Mt)=>{const Wt=Qe.get(pt);if(Wt!==void 0)return Wt;if(Mt.has(pt))return[];Mt.add(pt);const ss=Ee.get(pt),Kt=ss?[...ss.nodes]:[];for(const Yt of dt.get(pt)??[])Kt.push(...rt(Yt.folder.id,Mt));return Qe.set(pt,Kt),Kt};return Je.forEach(({folder:pt})=>rt(pt.id,new Set)),Qe},[Je,dt]),_t="project",Bt=c.useMemo(()=>{const Ee=new Set;return sd(Fe,bt,Ee),Je.forEach(({nodes:Qe})=>{sd(Qe,bt,Ee)}),Ee},[Fe,Je,bt]),ye=c.useMemo(()=>{if(!et)return null;const Ee=$o(Fe,et,_t,!!o.isArchivedBucket);if(Ee)return Ee;for(const{nodes:Qe}of Je){const rt=$o(Qe,et,_t,!!o.isArchivedBucket);if(rt)return rt}return null},[et,Fe,Je,o.isArchivedBucket]),z=c.useCallback(Ee=>{const Qe=new WeakMap,rt=pt=>{Qe.set(pt,Fr(pt));for(const Mt of pt.children)rt(Mt)};return Ee.forEach(rt),Qe},[]),W=c.useMemo(()=>z(Fe),[z,Fe]),Z=c.useMemo(()=>{const Ee=new WeakMap;return Je.forEach(({nodes:Qe})=>{Qe.forEach(rt=>Ee.set(rt,Fr(rt)))}),Ee},[Je]),ve=c.useCallback(Ee=>W.get(Ee)??Z.get(Ee)??"",[W,Z]),E=c.useCallback(Ee=>({subtreeContainsEditing:Bt,menuOpenSessionId:ye,nodeStructureKey:ve(Ee)}),[Bt,ye,ve]),V=xt.length,Ne=o.isArchivedBucket||u?xt:xt.slice(0,Ie),We=V-Ne.length,Ge=!o.isArchivedBucket&&!u&&V>ke&&We===0,qe=c.useCallback(Ee=>{const Qe=[],rt=pt=>{pt.forEach(Mt=>{Qe.push(Mt.session),Mt.children.length>0&&rt(Mt.children)})};return rt(Ee),Qe},[]),Pe=c.useMemo(()=>qe(Fe),[qe,Fe]),ze=c.useMemo(()=>{if(je||o.isMain||o.isArchivedBucket||a)return Pd;const Ee=new Map;for(const Qe of Pe)for(const rt of Ya(Qe))Ee.has(rt.key)||Ee.set(rt.key,rt);return Ee.size>0?[...Ee.values()]:Pd},[Pe,o.isArchivedBucket,o.isMain,je,a]),Rt=c.useMemo(()=>ze.flatMap(Ee=>Ee.source==="github"?[Or("issue",Ee)]:[]),[ze]),zt=Eo(Rt),Tt=c.useMemo(()=>ze.flatMap(Ee=>Ee.source==="linear"?[Qa(Ee.identifier)]:[]),[ze]),Ft=ff(Tt),gt=c.useMemo(()=>ze.flatMap(Ee=>Ee.source==="gitlab"?[Br("issue",Ee.ref)]:[]),[ze]),vt=Eo(gt),qt=c.useMemo(()=>mf(ze,zt,Ft,vt).map(Ee=>({...Ee,text:Ee.statusKey?`${Ee.label} · ${e(Ee.statusKey)}`:Ee.statusText?`${Ee.label} · ${Ee.statusText}`:Ee.label})),[vt,zt,ze,Ft,e]),ct=qt[0]??null,at=c.useMemo(()=>{if(!o.isArchivedBucket)return new Map;const Ee=new Map,Qe=new Map;for(const{folder:pt}of Je){if(!pt.parentId)continue;const Mt=Qe.get(pt.parentId)??[];Mt.push(pt.id),Qe.set(pt.parentId,Mt)}const rt=(pt,Mt)=>{if(Mt.has(pt))return[];Mt.add(pt);const Wt=Je.find(({folder:Yt})=>Yt.id===pt),ss=Wt?qe(Wt.nodes):[],Kt=Qe.get(pt)??[];for(const Yt of Kt)ss.push(...rt(Yt,Mt));return ss};for(const{folder:pt}of Je)Ee.set(pt.id,rt(pt.id,new Set));return Ee},[Je,qe,o.isArchivedBucket]);if(u&&!oe&&wt.length===0&&xt.length===0)return null;const yt=!o.isMain&&!!o.branch,$t=o.branch&&cx(o.branch,o.label)?{label:o.branch}:null,ls=q?n.jsx(mu,{nodes:Fe,includeUnreadSubtasks:M}):null,jt=(Ee,Qe)=>{const{folder:rt,scopeKey:pt,scopeDirectory:Mt,nodes:Wt}=Ee,ss=at.get(rt.id)??[],Kt=R?.folderId===rt.id&&R?.scopeKey===pt,Yt=u?!1:He.has(rt.id),ys=Es=>n.jsx(Sp,{folderId:rt.id,scopeKey:pt,ownerKey:Ue,children:(Ws,en)=>n.jsx(vp,{folder:rt,displayName:Qe,sessions:Wt,isCollapsed:Yt,collapsedActivityState:Es,onToggle:()=>G(rt.id),onRename:cs=>{ae(pt,rt.id,cs)},onDelete:()=>{if(o.isArchivedBucket){wn.requestDelete({sessions:ss,mode:"session"});return}if(!re){Se(pt,rt.id);return}const cs=Je.filter(({folder:Ms})=>Ms.parentId===rt.id).length,Rs=Wt.length;Be({scopeKey:pt,folderId:rt.id,folderName:rt.name,subFolderCount:cs,sessionCount:Rs})},groupDirectory:Mt??o.directory,projectId:l,mobileVariant:p,alwaysShowActions:y,isRenaming:Kt,renameDraft:Kt?R?.draft:void 0,onRenameDraftChange:P,onRenameSave:()=>{const cs=R?.draft.trim()??"";cs&&ae(pt,rt.id,cs),_()},onRenameCancel:_,droppableRef:Ws,isDropTarget:en,depth:0,onNewSession:()=>{l&&l!==v&&j(l),p&&C(!1),k({selectedProjectId:l,directoryOverride:Mt??o.directory,targetFolderId:rt.id,target:o.draftTarget})},hideActions:!1,archivedBucket:o.isArchivedBucket===!0,children:Wt.map(cs=>n.jsx(zo,{node:cs,pinnedSessionIds:T,expandedParents:U,hasSessionSearchQuery:u,normalizedSessionSearchQuery:f,notifyOnSubtasks:M,editingId:N,editingRowKey:A,editTitle:I,openSidebarMenuKey:H,mobileVariant:p,alwaysShowActions:y,groupDirectory:Mt??o.directory,projectId:l,folderOwnerKey:Ue,selectionScopeKey:Ue,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Bt,menuOpenSessionId:ye,nodeStructureKey:ve(cs),childRenderExtrasFor:E},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},cs.session.id))})},rt.id);return Yt?n.jsx(S4,{nodes:It.get(rt.id)??Wt,includeUnreadSubtasks:M,children:ys},rt.id):ys(null)},kt=()=>{const Ee=new Map;for(const Mt of Je){const Wt=Mt.folder.parentId;if(!Wt)continue;const ss=Ee.get(Wt);ss?ss.push(Mt):Ee.set(Wt,[Mt])}const Qe=[],rt=new Set,pt=(Mt,Wt)=>{if(rt.has(Mt.folder.id))return;rt.add(Mt.folder.id);const ss=Wt?`${Wt} / ${Mt.folder.name}`:Mt.folder.name;Qe.push(jt(Mt,ss)),!(!u&&He.has(Mt.folder.id))&&(Ee.get(Mt.folder.id)??[]).forEach(Yt=>pt(Yt,ss))};return wt.forEach(Mt=>pt(Mt,"")),Qe},Vt=!!(!o.isMain&&o.worktree&&!X),es=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($,{name:"alert",className:"h-3 w-3"})}):null,Is=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($,{name:"alert",className:"h-3 w-3"})}):null,Ds=Vt||!!o.space,ts=!!o.space,Le=y?ts?"pr-20":Ds?"pr-14":"pr-7":xe("pr-2",ts?"[--oc-actions-reserve:68px]":Ds?"[--oc-actions-reserve:44px]":"[--oc-actions-reserve:18px]"),nt=y?void 0:"group-hover/gh:oc-actions-mask group-focus-within/gh:oc-actions-mask",it=y?void 0:"transition-opacity group-hover/gh:opacity-0 group-focus-within/gh:opacity-0",_e=y?"hidden":"transition-opacity group-hover/gh:opacity-0",st=y?"inline-flex":"absolute inset-0 inline-flex opacity-0 transition-opacity group-hover/gh:opacity-100",ut=je&&ue?[{key:`pr:${je.number}`,icon:"git-pull-request",text:`${we} · ${ue}`,title:je.title,color:Y,url:je.url}]:[],St=Te?n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(te==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":De?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),de?n.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:fe,onClick:()=>{Q()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,n.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:B,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ct=Ee=>n.jsx(zo,{node:Ee,pinnedSessionIds:T,expandedParents:U,hasSessionSearchQuery:u,normalizedSessionSearchQuery:f,notifyOnSubtasks:M,editingId:N,editingRowKey:A,editTitle:I,openSidebarMenuKey:H,mobileVariant:p,alwaysShowActions:y,groupDirectory:o.directory,projectId:l,folderOwnerKey:Ue,selectionScopeKey:Ue,archivedBucket:o.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:Bt,menuOpenSessionId:ye,nodeStructureKey:ve(Ee),childRenderExtrasFor:E},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},Ee.session.id),Nt=n.jsxs(t3,{scopeKey:pe[0]?.scopeKey??Ce,ownerKey:Ue,hasFolders:Je.length>0,onSessionDroppedOnFolder:(Ee,Qe)=>{const rt=Je.find(({folder:Mt,scopeKey:Wt})=>Mt.id===Qe.folderId&&Wt===Qe.scopeKey);if(!rt)return;const pt=rs.getState();for(const{scopeKey:Mt}of pe)Mt!==rt.scopeKey&&pt.getSessionFolderId(Mt,Ee)&&pt.removeSessionFromFolder(Mt,Ee);J(rt.scopeKey,Qe.folderId,Ee)},children:[kt(),Ne.map(Ct),V===0&&Je.length===0&&!r?!o.isArchivedBucket&&!Oe&&!St&&o.directory&&!o.emptyMessage?n.jsx(ft,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{l&&l!==v&&j(l),p&&C(!1),k({selectedProjectId:l,directoryOverride:o.directory,target:o.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:o.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):Oe?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx($,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):St||(o.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,V>0&&St?n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:St}):null,We>0?n.jsx("button",{type:"button",onClick:()=>S(i,Ne.length,b??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,Ge?n.jsx("button",{type:"button",onClick:()=>x(i),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),os="pb-2",Ht=n.jsx(Dp,{value:ie,setValue:Be,onConfirm:()=>{const Ee=ie;Ee&&(Se(Ee.scopeKey,Ee.folderId),Be(null))}});return a?d?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"oc-group",children:n.jsx("div",{className:xe("oc-group-body",os),children:Nt})}),Ht]}):null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:xe("oc-group",X&&"opacity-60"),"aria-busy":X||void 0,children:[n.jsxs("div",{className:xe("oc-ref-tint-scope group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),children:[n.jsxs(Dt,{disabled:je?!ue:!ct,children:[n.jsx(Et,{asChild:!0,closeDelay:Sa,children:n.jsx("div",{className:"min-w-0 flex-1",onClick:()=>L(i),role:"button",tabIndex:0,onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),L(i))},"aria-label":q?e("sessions.sidebar.group.expandAria",{label:o.label}):e("sessions.sidebar.group.collapseAria",{label:o.label}),"aria-expanded":!q,children:n.jsxs("div",{ref:F?.setActivatorNodeRef,className:xe("@container min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5",Le),...F?.listeners??{},children:[n.jsxs("div",{className:xe("min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",nt),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-1",children:[n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[n.jsx($,{name:"archive",className:xe("h-3.5 w-3.5 shrink-0 text-muted-foreground",_e)}),n.jsx("span",{className:xe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",st),children:q?n.jsx($,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):n.jsx($,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:Er(o.label,f)}),es,ls]}):!o.isMain||o.worktree?n.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[X?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($,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"})}):n.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[n.jsx($,{name:o.space?"box-3":"git-branch",className:xe("h-3.5 w-3.5 shrink-0",Y?"oc-ref-tint":"text-muted-foreground",_e),style:Y?bn(Y):void 0,"aria-label":o.space?e("sessions.sidebar.group.space"):void 0}),n.jsx("span",{className:xe("text-muted-foreground h-3.5 w-3.5 items-center justify-center",st),children:q?n.jsx($,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):n.jsx($,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),n.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:Er(o.label,f)}),es,Is,ls,je?n.jsx("button",{type:"button",className:xe("ml-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",Y&&"oc-ref-tint",it),style:Y?bn(Y):void 0,disabled:!je.url,"aria-label":ce,onPointerDown:Ee=>Ee.stopPropagation(),onKeyDown:Ee=>Ee.stopPropagation(),onClick:Ee=>{Ee.stopPropagation(),je.url&&s(je.url,o.directory??null,Ee)},children:we}):ct?n.jsxs("button",{type:"button",className:xe("ml-auto inline-flex flex-shrink-0 items-center gap-1 rounded text-[0.72rem] font-medium leading-none hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ct.color?"oc-ref-tint":"text-muted-foreground",it),style:ct.color?bn(ct.color):void 0,"aria-label":qt.map(Ee=>Ee.text).join(", "),onPointerDown:Ee=>Ee.stopPropagation(),onKeyDown:Ee=>Ee.stopPropagation(),onClick:Ee=>{Ee.stopPropagation(),!(Ee.target instanceof Element&&Ee.target.closest("[data-ref-more]"))&&s(ct.url,o.directory??null,Ee)},children:[n.jsx($,{name:ct.icon,className:"h-3 w-3"}),ct.label,qt.length>1?n.jsxs("span",{"data-ref-more":!0,className:"text-muted-foreground",children:["+",qt.length-1]}):null]}):null]}):n.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[n.jsx("span",{className:"min-w-0 truncate",children:Er(o.label,f)}),ls]})}),yt&&$t?n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[o.isArchivedBucket?n.jsx($,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):n.jsx($,{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:$t.label})]}):null]}),!o.isArchivedBucket&&o.directory?n.jsx(_r,{directory:o.directory,className:xe("self-center",it)}):null]})})}),ut.length>0?n.jsx(Pt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Wo,{items:ut,directory:o.directory??null})}):!je&&ct?n.jsx(Pt,{side:"right",sideOffset:8,className:"max-w-xs",children:n.jsx(Wo,{items:qt,directory:o.directory??null})}):null]}),n.jsxs(Qo,{delayDuration:400,children:[o.isArchivedBucket&&Pe.length>0?n.jsx("div",{className:xe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",y?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),wn.requestDelete({sessions:Pe,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($,{name:"delete-bin",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,o.directory&&!o.isMain&&o.worktree&&!X?n.jsx("div",{className:xe("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",y?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsx(N4,{label:o.label,sessions:Pe,worktree:o.worktree})}):null,o.space?n.jsx("div",{className:xe("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",y?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),o.space&&ur.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($,{name:"key",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,o.space?n.jsx("div",{className:xe("absolute right-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",y?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:n.jsx(lg,{spaceId:o.space.id,label:o.label})}):null,o.directory?n.jsx("div",{className:xe("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",y?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),l&&l!==v&&j(l),p&&C(!1),k({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($,{name:"add",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]})]}),o.space?n.jsx(cg,{spaceId:o.space.id,className:"pb-1 pl-5"}):null,!q&&d?n.jsx("div",{className:xe("oc-group-body",os),children:Nt}):null]}),Ht]})}const P4=c.memo(A4,C4),ho=({projectId:t,mobileVariant:e,closeMobileSwitcher:s,setActiveProjectIdOnly:r,setSessionSwitcherOpen:o})=>{t&&r(t),e&&s&&o(!1)},I4=(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]},Id=(t,e)=>cf(t.label?.trim()||Yo(t.normalizedPath,e)||t.normalizedPath);function D4(t){const e=Ve.c(111),{model:s,view:r,actions:o}=t;Os("ui.sidebar_projects_list.render");const{t:i}=mt(),l=Ur(),a=rs(z4),d=rs(K4),u=rs(W4),f=rs($4),m=be(_4),h=be(L4)&&!qs(),b=ur(F4),[g,w]=c.useState(null),[S,x]=c.useState(null),[p,y]=c.useState(null),[v,j]=c.useState(null),[C,k]=c.useState(!1),T=c.useRef(null);let O;e[0]===Symbol.for("react.memo_cache_sentinel")?(O={activationConstraint:{distance:8}},e[0]=O):O=e[0];let M;e[1]===Symbol.for("react.memo_cache_sentinel")?(M={activationConstraint:{delay:200,tolerance:6}},e[1]=M):M=e[1];let L;e[2]===Symbol.for("react.memo_cache_sentinel")?(L={coordinateGetter:T1},e[2]=L):L=e[2];const F=Xo(vn(Zo,O),vn(Jo,M),vn(E1,L));let D;e[3]===Symbol.for("react.memo_cache_sentinel")?(D=B=>{T.current=B,j(B)},e[3]=D):D=e[3];const U=D;let N;if(e[4]!==s.projectSections||e[5]!==r.homeDirectory){let B;e[7]!==r.homeDirectory?(B=Q=>({id:Q.project.id,projectLabel:Id(Q.project,r.homeDirectory),projectDescription:gr(Q.project.normalizedPath,r.homeDirectory),projectIcon:Q.project.icon,projectColor:Q.project.color,projectIconImage:Q.project.iconImage,projectIconBackground:Q.project.iconBackground}),e[7]=r.homeDirectory,e[8]=B):B=e[8],N=s.projectSections.map(B),e[4]=s.projectSections,e[5]=r.homeDirectory,e[6]=N}else N=e[6];const A=N,H=dx(),{confirm:I}=H;let R;e[9]!==I||e[10]!==i?(R=async(B,Q)=>{const ke=br.getState().ids,Ie=I4(Q,Ce=>Ga(ke,Ce.directory,Ce.id)||wu(Ce.id)||Xa(Ce));if(Ie.length===0){Ke.info(i("sessions.sidebar.project.archiveAll.nothing"));return}if(!await I({title:i("sessions.sidebar.project.archiveAll.title",{project:B}),message:Ie.length===1?i("sessions.sidebar.project.archiveAll.descriptionSingle",{count:Ie.length}):i("sessions.sidebar.project.archiveAll.descriptionPlural",{count:Ie.length}),action:i("sessions.sidebar.bulkActions.archive")}))return;const{archivedIds:$e,failedIds:Fe}=await Ze.getState().archiveSessions(Ie);$e.length>0&&Ke.success($e.length===1?i("sessions.sidebar.bulkActions.archivedSingle",{count:$e.length}):i("sessions.sidebar.bulkActions.archivedPlural",{count:$e.length})),Fe.length>0&&Ke.error(Fe.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Fe.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:Fe.length}))},e[9]=I,e[10]=i,e[11]=R):R=e[11];const P=R;let _;e:{if(!r.stickyZoneHeaders){_=-1;break e}let B;if(e[12]!==s.rowModel.stickyHeaders||e[13]!==S){let Q;e[15]!==S?(Q=ke=>`${ke.kind}:${ke.id}`===S,e[15]=S,e[16]=Q):Q=e[16],B=s.rowModel.stickyHeaders.findIndex(Q),e[12]=s.rowModel.stickyHeaders,e[13]=S,e[14]=B}else B=e[14];_=B}const G=_;let ae;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]!==G){if(ae=new Set,p){let B;e[25]!==p||e[26]!==s.rowModel.rowIndexByKey?(B=s.rowModel.rowIndexByKey.get(p),e[25]=p,e[26]=s.rowModel.rowIndexByKey,e[27]=B):B=e[27];const Q=B;Q!==void 0&&ae.add(Q)}for(let B=0;B<s.rowModel.rows.length;B=B+1,B){const Q=s.rowModel.rows[B];Q?.kind==="session"&&(s.groupProps.editingRowKey===Q.key||s.state.openSidebarMenuKey===`session-menu:${Q.key}`||s.state.openSidebarMenuKey===`session-context:${Q.key}`)&&ae.add(B)}if(G>=0){const B=Math.max(0,G-1),Q=Math.min(s.rowModel.stickyHeaders.length-1,G+1);for(let ke=B;ke<=Q;ke=ke+1,ke){const Ie=s.rowModel.stickyHeaders[ke];Ie&&ae.add(Ie.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]=G,e[24]=ae}else ae=e[24];const Se=ae;let J;e[28]!==s.rowModel.stickyHeaders||e[29]!==r.stickyZoneHeaders?(J=B=>{const Q=r.stickyZoneHeaders?P2(s.rowModel.stickyHeaders,B):null,ke=Q?`${Q.kind}:${Q.id}`:null;x(Ie=>Ie===ke?Ie:ke)},e[28]=s.rowModel.stickyHeaders,e[29]=r.stickyZoneHeaders,e[30]=J):J=e[30];const re=J;let ie;e[31]!==l||e[32]!==i?(ie=B=>{const Q=()=>{if(!B.status.directory){Ja();return}l.requestBootstrap({directory:B.status.directory,priority:"expanded",reason:B.group.isMain?"project-expanded":"worktree-expanded",force:!0})},ke=async()=>{if(!B.status.directory)return;(await iu(B.status.directory)).success&&Q()};let Ie;e:switch(B.status.state){case"permission-denied":{Ie=i("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{Ie=i("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{Ie=i("sessions.sidebar.group.empty.initializationFailed");break e}default:Ie=i("sessions.sidebar.group.empty.loadingSessions")}return n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[B.status.state==="loading"?n.jsx($,{name:"loader-4",className:"size-3 animate-spin"}):null,Ie,B.status.canGrantAccess?n.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{ke()},children:i("sessions.sidebar.group.empty.grantAccess")}):null,B.status.state!=="loading"?n.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:Q,children:i("sessions.sidebar.group.empty.retry")}):null]})})},e[31]=l,e[32]=i,e[33]=ie):ie=e[33];const Be=ie;let Ae;e[34]!==o||e[35]!==u||e[36]!==s.emptyState||e[37]!==s.groupProps||e[38]!==s.projectRepoStatus||e[39]!==s.searchEmptyState||e[40]!==s.singleProjectMode||e[41]!==s.state||e[42]!==A||e[43]!==d||e[44]!==Be||e[45]!==P||e[46]!==m||e[47]!==b||e[48]!==h||e[49]!==i||e[50]!==a||e[51]!==r.alwaysShowActions||e[52]!==r.hideDirectoryControls||e[53]!==r.homeDirectory||e[54]!==r.mobileVariant||e[55]!==r.projectSortOrder||e[56]!==r.stickyZoneHeaders||e[57]!==r.timelineView||e[58]!==r.worktreeSortOrder?(Ae=B=>{if(B.kind==="activity-header")return n.jsx(Rp,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:n.jsx(l4,{activityKey:B.activityKey,collapsed:B.collapsed,forceExpanded:B.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!B.collapsed){const Q=`activity:${B.activityKey}`;o.group.resetGroupSessionLimit(Q),s.state.setVisibleActivityCountByKey(ke=>{if(!ke.has(Q))return ke;const Ie=new Map(ke);return Ie.delete(Q),Ie})}s.state.setCollapsedActivityKeys(Q=>{const ke=new Set(Q);return ke.has(B.activityKey)?ke.delete(B.activityKey):ke.add(B.activityKey),ke})},onNewChat:()=>{be.getState().closeMainSurfaces(),r.mobileVariant&&o.setSessionSwitcherOpen(!1),o.openNewSessionDraft({selectedProjectId:Um,directoryOverride:null})}})});if(B.kind==="project-header"){const Q=B.section.project,ke=Id(Q,r.homeDirectory);return n.jsx(h4,{id:Q.id,disabled:s.singleProjectMode||B.forceExpanded||s.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:ke,projectDescription:gr(Q.normalizedPath,r.homeDirectory),projectDirectory:Q.normalizedPath,projectIcon:Q.icon,projectColor:Q.color,projectIconImage:Q.iconImage,projectIconBackground:Q.iconBackground,isCollapsed:B.collapsed,isRepo:!!s.projectRepoStatus.get(Q.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:B.collapsed?o.renderProjectStatusIndicator?.(Q.id,B.section.groups):null,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,projectPickerOptions:s.singleProjectMode?A:void 0,onProjectSelect:s.singleProjectMode?o.setSingleProjectId:void 0,onToggle:()=>{!B.forceExpanded&&!s.singleProjectMode&&o.toggleProject(Q.id)},onNewSession:()=>{ho({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:Q.id,directoryOverride:Q.normalizedPath})},onNewWorktreeSession:()=>{ho({projectId:Q.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewWorktreeDialog()},onManageWorktrees:()=>o.openWorktreesPage(Q.id),onManageSpaces:h?()=>be.getState().setSpacesPageProjectId(Q.id):void 0,onRenameStart:()=>o.openProjectEditDialog(Q.id),onArchiveAll:()=>{P(ke,B.section.groups)},onClose:()=>o.removeProject(Q.id),showCreateButtons:!0})}if(B.kind==="group-header")return n.jsx(b4,{id:B.groupKey,disabled:B.forceExpanded||s.state.editingId!==null||r.worktreeSortOrder!=="manual",children:Q=>n.jsx(P4,{...s.groupProps,...o.group,group:B.group,groupKey:B.groupKey,projectId:B.projectId,visibleSessionCount:s.state.visibleSessionCountByGroup.get(B.groupKey),editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,dragHandleProps:Q,renderBody:!1})});if(B.kind==="folder-header"){const Q=s.groupProps.folderRename?.folderId===B.folder.id&&s.groupProps.folderRename.scopeKey===B.scopeKey;return n.jsx(Sp,{folderId:B.folder.id,scopeKey:B.scopeKey,ownerKey:B.ownerKey,disabled:!B.dropEnabled,children:(ke,Ie)=>n.jsx(ZC,{notifyOnSubtasks:s.groupProps.notifyOnSubtasks,activityNodes:B.activityNodes,folder:B.folder,displayName:B.displayName,sessions:B.nodes,isCollapsed:B.collapsed,onToggle:B.forceExpanded?B4:()=>a(B.folder.id),onRename:oe=>d(B.scopeKey,B.folder.id,oe),onDelete:()=>{B.archived?wn.requestDelete({sessions:[...B.deleteSessions],mode:"session"}):m?w({scopeKey:B.scopeKey,folderId:B.folder.id,folderName:B.folder.name,subFolderCount:B.subFolderCount,sessionCount:B.nodes.length}):u(B.scopeKey,B.folder.id)},renderBody:!1,groupDirectory:B.scopeDirectory??B.group.directory,projectId:B.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:Q,renameDraft:Q?s.groupProps.folderRename?.draft:void 0,onRenameDraftChange:s.groupProps.setFolderRenameDraft,onRenameSave:()=>{const oe=s.groupProps.folderRename?.draft.trim();oe&&d(B.scopeKey,B.folder.id,oe),s.groupProps.clearFolderRename()},onRenameCancel:s.groupProps.clearFolderRename,droppableRef:ke,isDropTarget:Ie,onNewSession:()=>{ho({projectId:B.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:B.projectId,directoryOverride:B.scopeDirectory??B.group.directory,targetFolderId:B.folder.id,target:B.group.draftTarget})},archivedBucket:B.archived})})}if(B.kind==="session"){const Q=new Set;return xr(B.node,s.state.editingId)&&Q.add(B.node.session.id),n.jsx("div",{onFocusCapture:()=>y(B.key),onBlurCapture:()=>y(ke=>ke===B.key?null:ke),children:n.jsx(zo,{...s.groupProps,node:B.node,depth:B.depth,groupDirectory:B.groupDirectory,projectId:B.projectId,folderOwnerKey:B.ownerKey,selectionScopeKey:B.selectionScopeKey,archivedBucket:B.archived,renderContext:B.renderContext,rowKey:B.key,dragKey:B.key,secondaryMeta:B.secondaryMeta,renderChildren:!1,editingId:s.state.editingId,openSidebarMenuKey:s.state.openSidebarMenuKey,setOpenSidebarMenuKey:s.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:Q,menuOpenSessionId:s.state.openSidebarMenuKey===`session-menu:${B.key}`||s.state.openSidebarMenuKey===`session-context:${B.key}`?B.node.session.id:null,nodeStructureKey:B.blockingBadgeSessionScopes?`${Fr(B.node)}:${JSON.stringify(B.blockingBadgeSessionScopes)}`:Fr(B.node),blockingBadgeSessionScopes:B.blockingBadgeSessionScopes}})})}if(B.kind==="run")return n.jsx(Z3,{run:B.run,depth:B.depth,laneNodes:B.laneNodes,blockingSessionIds:B.blockingSessionIds,renderContext:B.renderContext,projectId:B.projectId,projectLabel:B.projectLabel,expansionKey:B.expansionKey,expanded:B.expanded,forceExpanded:B.forceExpanded,notifyOnSubtasks:s.groupProps.notifyOnSubtasks,toggleParent:s.groupProps.toggleParent});if(B.kind==="show-control")return n.jsx("button",{type:"button",className:xe("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{B.containerKey.startsWith("activity:")?s.state.setVisibleActivityCountByKey(Q=>{const ke=new Map(Q);return B.control==="more"?ke.set(B.containerKey,B.currentCount+B.increment):ke.delete(B.containerKey),ke}):B.control==="more"?o.group.showMoreGroupSessions(B.containerKey,B.currentCount,B.increment):o.group.resetGroupSessionLimit(B.containerKey)},children:i(B.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(B.kind==="status")return Be(B);if(B.emptyKind==="sidebar")return s.emptyState;if(B.emptyKind==="search")return s.searchEmptyState;if(B.emptyKind==="group"&&Hm(b?.get(B.group?.space?.id??"")))return null;if(B.emptyKind==="group"&&B.group?.directory&&!B.group.emptyMessage){const Q=B.group;return n.jsx(ft,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{ho({projectId:B.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:o.setActiveProjectIdOnly,setSessionSwitcherOpen:o.setSessionSwitcherOpen}),o.openNewSessionDraft({selectedProjectId:B.projectId,directoryOverride:Q.directory,target:Q.draftTarget})},children:i("sessions.sidebar.group.empty.startSession")})}return n.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:B.emptyKind==="archived"?i("sessions.sidebar.group.empty.noArchivedSessions"):B.group?.emptyMessage??i("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[34]=o,e[35]=u,e[36]=s.emptyState,e[37]=s.groupProps,e[38]=s.projectRepoStatus,e[39]=s.searchEmptyState,e[40]=s.singleProjectMode,e[41]=s.state,e[42]=A,e[43]=d,e[44]=Be,e[45]=P,e[46]=m,e[47]=b,e[48]=h,e[49]=i,e[50]=a,e[51]=r.alwaysShowActions,e[52]=r.hideDirectoryControls,e[53]=r.homeDirectory,e[54]=r.mobileVariant,e[55]=r.projectSortOrder,e[56]=r.stickyZoneHeaders,e[57]=r.timelineView,e[58]=r.worktreeSortOrder,e[59]=Ae):Ae=e[59];const K=Ae;let q;e[60]!==s.rowModel.rows?(q=s.rowModel.rows.flatMap(O4),e[60]=s.rowModel.rows,e[61]=q):q=e[61];const X=q;let me;e[62]!==s.sectionsForRender?(me=new Set(s.sectionsForRender.map(M4)),e[62]=s.sectionsForRender,e[63]=me):me=e[63];const he=me;let je;e[64]!==s.rowModel.stickyHeaders?(je=s.rowModel.stickyHeaders.map(T4).join(""),e[64]=s.rowModel.stickyHeaders,e[65]=je):je=e[65];const Y=je,ue=!r.timelineView;let we;e[66]!==he?(we=B=>{k(he.has(String(B.active.id)))},e[66]=he,e[67]=we):we=e[67];let ce;e[68]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>k(!1),e[68]=ce):ce=e[68];let le;e[69]!==o||e[70]!==f||e[71]!==s.rowModel.folderAuthorityByOwner||e[72]!==s.rowModel.folderDropTargets||e[73]!==s.rowModel.rows||e[74]!==s.sectionsForRender||e[75]!==s.state||e[76]!==r.hasSessionSearchQuery||e[77]!==r.projectSortOrder?(le=B=>{if(k(!1),!B.over)return;const Q=B.active.data.current,ke=B.over.data.current;if(Q?.type==="session"&&Q.sessionId&&Q.ownerKey&&Q.archivedBucket!==!0&&ke?.type==="folder"&&ke.folderId&&ke.scopeKey&&ke.ownerKey===Q.ownerKey){const Xe=s.rowModel.folderDropTargets.find(et=>et.folderId===ke.folderId&&et.scopeKey===ke.scopeKey&&et.ownerKey===Q.ownerKey),Je=s.rowModel.folderAuthorityByOwner.get(Q.ownerKey);if(!Xe?.enabled||Je?.complete!==!0)return;const bt=rs.getState();for(const et of Je.scopeKeys)et!==ke.scopeKey&&bt.removeSessionFromFolder(et,Q.sessionId);f(ke.scopeKey,ke.folderId,Q.sessionId);return}if(r.hasSessionSearchQuery||s.state.editingId!==null||B.active.id===B.over.id)return;const Ie=String(B.active.id),oe=String(B.over.id),$e=s.sectionsForRender.map(R4),Fe=$e.indexOf(Ie),Ce=$e.indexOf(oe);if(Fe>=0&&Ce>=0&&r.projectSortOrder==="manual"){o.reorderProjects(Fe,Ce);return}const Ue=s.rowModel.rows.find(Xe=>Xe.kind==="group-header"&&Xe.groupKey===Ie),pe=s.rowModel.rows.find(Xe=>Xe.kind==="group-header"&&Xe.groupKey===oe);if(!Ue||!pe||Ue.projectId!==pe.projectId||!Ue.projectId)return;const ne=Ue.projectId,Me=s.sectionsForRender.find(Xe=>Xe.project.id===ne);if(!Me)return;const He=Me.groups.findIndex(Xe=>Xe.id===Ue.group.id),Ye=Me.groups.findIndex(Xe=>Xe.id===pe.group.id);He<0||Ye<0||o.setGroupOrderByProject(Xe=>new Map(Xe).set(ne,jf(Me.groups,He,Ye).map(E4)))},e[69]=o,e[70]=f,e[71]=s.rowModel.folderAuthorityByOwner,e[72]=s.rowModel.folderDropTargets,e[73]=s.rowModel.rows,e[74]=s.sectionsForRender,e[75]=s.state,e[76]=r.hasSessionSearchQuery,e[77]=r.projectSortOrder,e[78]=le):le=e[78];let Re;e[79]!==re||e[80]!==s.rowModel||e[81]!==Se||e[82]!==K||e[83]!==v?(Re=n.jsx(i4,{model:s.rowModel,scrollElement:v,pinnedRowIndexes:Se,renderRow:K,onFirstVisibleIndexChange:re}),e[79]=re,e[80]=s.rowModel,e[81]=Se,e[82]=K,e[83]=v,e[84]=Re):Re=e[84];let Oe;e[85]!==X||e[86]!==Re?(Oe=n.jsx(el,{items:X,strategy:kf,children:Re}),e[85]=X,e[86]=Re,e[87]=Oe):Oe=e[87];let Te;e[88]!==F||e[89]!==we||e[90]!==le||e[91]!==Oe?(Te=n.jsx(ei,{sensors:F,collisionDetection:ti,onDragStart:we,onDragCancel:ce,onDragEnd:le,children:Oe}),e[88]=F,e[89]=we,e[90]=le,e[91]=Oe,e[92]=Te):Te=e[92];let De;e[93]!==ue||e[94]!==Te?(De=n.jsx(Cn,{ref:U,useScrollShadow:!0,hideTopScrollShadow:ue,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:Te}),e[93]=ue,e[94]=Te,e[95]=De):De=e[95];let te;e[96]!==C||e[97]!==De||e[98]!==r.stickyZoneHeaders||e[99]!==Y?(te=n.jsx(c4,{enabled:r.stickyZoneHeaders,suspended:C,layoutKey:Y,scrollRef:T,children:De}),e[96]=C,e[97]=De,e[98]=r.stickyZoneHeaders,e[99]=Y,e[100]=te):te=e[100];let de;e[101]!==u||e[102]!==g?(de=()=>{g&&(u(g.scopeKey,g.folderId),w(null))},e[101]=u,e[102]=g,e[103]=de):de=e[103];let fe;e[104]!==g||e[105]!==de?(fe=n.jsx(Dp,{value:g,setValue:w,onConfirm:de}),e[104]=g,e[105]=de,e[106]=fe):fe=e[106];let ge;return e[107]!==H.dialog||e[108]!==te||e[109]!==fe?(ge=n.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[te,fe,H.dialog]}),e[107]=H.dialog,e[108]=te,e[109]=fe,e[110]=ge):ge=e[110],ge}function E4(t){return t.id}function R4(t){return t.project.id}function T4(t){const{kind:e,id:s,rowIndex:r}=t;return`${e}:${s}:${r}`}function M4(t){return t.project.id}function O4(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function B4(){}function F4(t){return t.journey}function L4(t){return t.isolatedSpacesEnabled}function _4(t){return t.showDeletionDialog}function $4(t){return t.addSessionToFolder}function W4(t){return t.deleteFolder}function K4(t){return t.renameFolder}function z4(t){return t.toggleFolderCollapse}const U4=c.memo(D4),Na=new Map,Dd=(t,e)=>{for(const s of t){const r=ot(s??null);r&&!Na.has(r)&&Na.set(r,e)}},Ed=t=>{const e=ot(t??null);return e?Na.get(e)??0:0},jr=t=>!!t.time?.archived,H4=t=>{const{t:e}=mt(),s=c.useRef(t.gitBranches);s.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),o=c.useCallback(a=>{const d=ot(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),i=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),f=u.startsWith("ses_");return a.flatMap(m=>{if(f&&jr(m.session))return[];if(f?m.session.id.toLowerCase()===u:Io([o(m.session)],d))return[m];const b=i(m.children,d);return b.length===0?[]:[{...m,children:b}]})},[o]),l=c.useCallback((a,d,u,f,m)=>{const h=ot(d??null),b=nf(a),g=new Map(b.map(P=>[P.id,P])),w=new Map;b.forEach(P=>{const _=P.parentID;if(!_)return;const G=g.get(_);if(!G||jr(G)||jr(P))return;const ae=w.get(_)??[];ae.push(P),w.set(_,ae)});const S=ux(u,h),x=(h&&!t.isVSCode?t.spacesByProject?.get(h):void 0)??[],p=new Map;for(const P of x){const _=ot(P.directory);_&&p.set(_,P)}const y=P=>{const _=ot(P.directory??null),G=t.worktreeMetadata.get(P.id)??null;if(G)return G;if(_){const ae=S.get(_)??null;if(ae&&_!==h)return ae}return null},v=new Set,j=P=>{v.add(P.id);const _=w.get(P.id)??[],G=[];for(const ae of _)v.has(ae.id)||G.push(j(ae));return{session:P,children:G,worktree:y(P)}},C=P=>{const _=P.parentID;if(!_)return!1;if(jr(P))return!0;const G=g.get(_);return!!(G&&jr(G))},k=b.filter(P=>{const _=P.parentID;return _?!g.has(_)&&!C(P):!0}),T=[],O=P=>{v.has(P.id)||T.push(j(P))};k.forEach(O),b.forEach(P=>{C(P)||O(P)});const M=new Map,L="__archived__",F=P=>{if(P.time?.archived)return L;if(t.isVSCode||t.runKeyBySessionId?.has(P.id))return h??"__project_root__";const _=t.sessionOwners?.get(P.id)?.scopeDirectory;if(_){if(_===h)return h??"__project_root__";if(S.has(_)||p.has(_))return _}const ae=ot(t.worktreeMetadata.get(P.id)?.path??null)??dn(P);return ae&&ae!==h&&S.has(ae)?ae:h??"__project_root__"};T.forEach(P=>{const _=F(P.session);M.has(_)||M.set(_,[]),M.get(_)?.push(P)});const D=h??"__project_root__",U=[{id:"root",label:m&&f&&f!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:f}):e("sessions.sidebar.grouping.projectRoot"),branch:f??null,description:h?gr(h,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:h,folderScopeKey:h,sessions:M.get(D)??[]}],N=new Map;u.forEach(P=>{const _=ot(P.path)??P.path,G=M.get(_)??[],ae=G.length>0,Se=G.reduce((J,re)=>{const ie=fx(re.session,t.sessionOrderRanks);return Number.isFinite(ie)?Math.max(J,ie):J},0);N.set(_,{hasActiveSession:ae,lastUpdatedAt:Se})});const A=(P,_)=>{const G=(P.label||P.branch||P.name||P.path||"").toLowerCase(),ae=(_.label||_.branch||_.name||_.path||"").toLowerCase();return G.localeCompare(ae)},H=t.worktreeSortOrder!=="recent"?[...u].sort(A):[...u].sort((P,_)=>{const G=ot(P.path)??P.path,ae=ot(_.path)??_.path,Se=N.get(G)??{hasActiveSession:!1,lastUpdatedAt:0},J=N.get(ae)??{hasActiveSession:!1,lastUpdatedAt:0};if(Se.hasActiveSession!==J.hasActiveSession)return Se.hasActiveSession?-1:1;if(Se.hasActiveSession&&J.hasActiveSession)return J.lastUpdatedAt-Se.lastUpdatedAt;const re=Ed(P.path),ie=Ed(_.path);return re!==ie?ie-re:A(P,_)});(t.isVSCode?[]:H).forEach(P=>{const _=ot(P.path)??P.path,G=s.current.get(_)?.trim()||null,ae=P.branch?.trim()||null,J=!!(G&&ae&&P.label&&oc(P.label)===oc(ae))?G:P.label||P.name||Yo(_,t.homeDirectory)||_;U.push({id:`worktree:${_}`,label:J,branch:G||ae,description:gr(_,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:P,directory:_,folderScopeKey:_,sessions:M.get(_)??[]})});for(const[P,_]of p)U.push({id:`space:${_.id}`,label:_.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:_,directory:P,folderScopeKey:P,sessions:M.get(P)??[]});const R=M.get(L)??[];return R.length>0&&U.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&&h?sf(h):null,sessions:R}),U},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:r,buildSessionSearchText:o,filterSessionNodesForSearch:i,buildGroupedSessions:l}},V4=t=>{const e=Ve.c(60),{selectedCount:s,scopeKey:r,scopeFolders:o,archivedBucket:i,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:f,onArchive:m,onDelete:h,onDone:b}=t,{t:g}=mt(),w=s>0,S=w&&!!r&&!i;let x;e[0]!==s||e[1]!==g?(x=g("sessions.sidebar.bulkActions.selectedCount",{count:s}),e[0]=s,e[1]=g,e[2]=x):x=e[2];let p;e[3]!==x?(p=n.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:x}),e[3]=x,e[4]=p):p=e[4];let y;e[5]!==S||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==o||e[11]!==g?(y=S?n.jsxs(Ps,{children:[n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx(Ns,{asChild:!0,children:n.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":g("sessions.sidebar.bulkActions.moveToFolder"),children:n.jsx($,{name:"folder",className:"h-4 w-4"})})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:g("sessions.sidebar.bulkActions.moveToFolder")})})]}),n.jsxs(As,{align:"end",className:"min-w-[180px]",children:[o.length===0?n.jsx(Gt,{disabled:!0,className:"text-muted-foreground",children:g("sessions.sidebar.folders.none")}):o.map(G=>n.jsx(Gt,{onClick:()=>l(G.id),children:n.jsx("span",{className:"flex-1 truncate",children:G.name})},G.id)),n.jsx(Cs,{}),n.jsxs(Gt,{onClick:a,children:[n.jsx($,{name:"add",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.newFolderEllipsis")]}),u?n.jsxs(Gt,{onClick:d,className:"text-destructive focus:text-destructive",children:[n.jsx($,{name:"close",className:"mr-1 h-4 w-4"}),g("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=S,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=o,e[11]=g,e[12]=y):y=e[12];let v;e[13]!==i||e[14]!==w||e[15]!==f||e[16]!==g?(v=i?n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:f,disabled:!w,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":g("sessions.sidebar.bulkActions.restore"),children:n.jsx($,{name:"inbox-unarchive",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:g("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=i,e[14]=w,e[15]=f,e[16]=g,e[17]=v):v=e[17];let j;e[18]!==i||e[19]!==w||e[20]!==m||e[21]!==g?(j=i?null:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:m,disabled:!w,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":g("sessions.sidebar.bulkActions.archive"),children:n.jsx($,{name:"archive",className:"h-4 w-4"})})}),n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:g("sessions.sidebar.bulkActions.archive")})})]}),e[18]=i,e[19]=w,e[20]=m,e[21]=g,e[22]=j):j=e[22];const C=!w;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=xe("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]=k):k=e[23];let T;e[24]!==g?(T=g("sessions.sidebar.bulkActions.delete"),e[24]=g,e[25]=T):T=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx($,{name:"delete-bin",className:"h-4 w-4"}),e[26]=O):O=e[26];let M;e[27]!==h||e[28]!==C||e[29]!==T?(M=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:h,disabled:C,className:k,"aria-label":T,children:O})}),e[27]=h,e[28]=C,e[29]=T,e[30]=M):M=e[30];let L;e[31]!==g?(L=g("sessions.sidebar.bulkActions.delete"),e[31]=g,e[32]=L):L=e[32];let F;e[33]!==L?(F=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:L})}),e[33]=L,e[34]=F):F=e[34];let D;e[35]!==M||e[36]!==F?(D=n.jsxs(Dt,{children:[M,F]}),e[35]=M,e[36]=F,e[37]=D):D=e[37];let U;e[38]!==g?(U=g("sessions.sidebar.header.actions.exitSelection"),e[38]=g,e[39]=U):U=e[39];let N;e[40]===Symbol.for("react.memo_cache_sentinel")?(N=n.jsx($,{name:"close",className:"h-4 w-4"}),e[40]=N):N=e[40];let A;e[41]!==b||e[42]!==U?(A=n.jsx(Et,{asChild:!0,children:n.jsx("button",{type:"button",onClick:b,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":U,children:N})}),e[41]=b,e[42]=U,e[43]=A):A=e[43];let H;e[44]!==g?(H=g("sessions.sidebar.header.actions.exitSelection"),e[44]=g,e[45]=H):H=e[45];let I;e[46]!==H?(I=n.jsx(Pt,{side:"bottom",sideOffset:4,children:n.jsx("p",{children:H})}),e[46]=H,e[47]=I):I=e[47];let R;e[48]!==A||e[49]!==I?(R=n.jsxs(Dt,{children:[A,I]}),e[48]=A,e[49]=I,e[50]=R):R=e[50];let P;e[51]!==D||e[52]!==R||e[53]!==y||e[54]!==v||e[55]!==j?(P=n.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[y,v,j,D,R]}),e[51]=D,e[52]=R,e[53]=y,e[54]=v,e[55]=j,e[56]=P):P=e[56];let _;return e[57]!==p||e[58]!==P?(_=n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[p,P]}),e[57]=p,e[58]=P,e[59]=_):_=e[59],_},Rd=new Map,G4=(t,e)=>{if(!t)return[];const s=e(t);return s.length>0?s.map(r=>r.scopeKey):[t]},q4=(t,e)=>{const s=t.sessionIds.filter(i=>e.has(i));if(s.length===0)return{ready:!1,value:null};const r=t.archivedBucket||kp(new Set(s),e),o={sessionIds:s,sessionCount:s.length,archivedBucket:r};return{ready:s.length===t.sessionIds.length&&r===t.archivedBucket,value:o}},Y4=t=>{const e=Ve.c(89),{t:s}=mt();let r;e[0]!==s?(r=de=>{const fe=px(de);return fe?{description:pu(fe,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:m,archiveSessions:h,unarchiveSessions:b,deleteSessions:g,bulkDeleteConfirm:w,setBulkDeleteConfirm:S}=t,x=bs(Q4),p=bs(X4),y=p>0,v=bs(J4),j=bs(Z4),C=jp(),k=e5,T=t5;let O;e[2]!==y||e[3]!==C||e[4]!==v?(O=y&&kp(v,C?.getSessionsById()??Rd),e[2]=y,e[3]=C,e[4]=v,e[5]=O):O=e[5];const M=O;let L;e:{if(j){L=j;break e}L=null}const F=L;let D;e[6]!==F||e[7]!==d?(D=G4(F,d),e[6]=F,e[7]=d,e[8]=D):D=e[8];const U=D;let N;if(e[9]!==a||e[10]!==U){let de;e[12]!==a?(de=fe=>a[fe]??[],e[12]=a,e[13]=de):de=e[13],N=U.flatMap(de),e[9]=a,e[10]=U,e[11]=N}else N=e[11];const A=N;let H;e[14]!==a||e[15]!==U?(H=de=>{for(const fe of U)if((a[fe]??[]).some(ge=>ge.id===de))return fe;return null},e[14]=a,e[15]=U,e[16]=H):H=e[16];const I=H;let R;e:{if(!y){R=!1;break e}for(const de of U)for(const fe of a[de]??[])for(const ge of fe.sessionIds)if(v.has(ge)){R=!0;break e}R=!1}const P=R;let _;e[17]!==u||e[18]!==f||e[19]!==v||e[20]!==U?(_=(de,fe)=>{const ge=Array.from(v);for(const B of U)B!==de&&f(B,ge);u(de,fe,ge)},e[17]=u,e[18]=f,e[19]=v,e[20]=U,e[21]=_):_=e[21];const G=_;let ae;e[22]!==y||e[23]!==G||e[24]!==I?(ae=de=>{if(!y)return;const fe=I(de);fe&&G(fe,de)},e[22]=y,e[23]=G,e[24]=I,e[25]=ae):ae=e[25];const Se=ae;let J;e[26]!==m||e[27]!==y||e[28]!==G||e[29]!==U?(J=()=>{const de=U[0];if(!de||!y)return;const fe=m(de);fe&&G(de,fe.id)},e[26]=m,e[27]=y,e[28]=G,e[29]=U,e[30]=J):J=e[30];const re=J;let ie;e[31]!==y||e[32]!==f||e[33]!==v||e[34]!==U?(ie=()=>{if(!y)return;const de=Array.from(v);for(const fe of U)f(fe,de)},e[31]=y,e[32]=f,e[33]=v,e[34]=U,e[35]=ie):ie=e[35];const Be=ie;let Ae;e[36]!==h||e[37]!==g||e[38]!==o||e[39]!==s?(Ae=async(de,fe)=>{if(de.length!==0)if(fe){const{deletedIds:ge,failedIds:B}=await g(de);ge.length>0&&Ke.success(ge.length===1?s("sessions.sidebar.bulkActions.deletedSingle",{count:ge.length}):s("sessions.sidebar.bulkActions.deletedPlural",{count:ge.length})),B.length>0&&Ke.error(B.length===1?s("sessions.sidebar.bulkActions.failedDeleteSingle",{count:B.length}):s("sessions.sidebar.bulkActions.failedDeletePlural",{count:B.length}),o(B)),bs.getState().removeMany(ge)}else{const{archivedIds:ge,failedIds:B}=await h(de);ge.length>0&&Ke.success(ge.length===1?s("sessions.sidebar.bulkActions.archivedSingle",{count:ge.length}):s("sessions.sidebar.bulkActions.archivedPlural",{count:ge.length})),B.length>0&&Ke.error(B.length===1?s("sessions.sidebar.bulkActions.failedArchiveSingle",{count:B.length}):s("sessions.sidebar.bulkActions.failedArchivePlural",{count:B.length}),o(B)),bs.getState().removeMany(ge)}},e[36]=h,e[37]=g,e[38]=o,e[39]=s,e[40]=Ae):Ae=e[40];const K=Ae;let q;e[41]!==K||e[42]!==y||e[43]!==v||e[44]!==S||e[45]!==l?(q=de=>{if(!y)return;const fe=Array.from(v);if(!l){K(fe,de);return}S({sessionIds:fe,sessionCount:fe.length,archivedBucket:de})},e[41]=K,e[42]=y,e[43]=v,e[44]=S,e[45]=l,e[46]=q):q=e[46];const X=q;let me;e[47]!==M||e[48]!==X?(me=()=>X(M),e[47]=M,e[48]=X,e[49]=me):me=e[49];const he=me;let je;e[50]!==X?(je=()=>X(!1),e[50]=X,e[51]=je):je=e[51];const Y=je;let ue;e[52]!==X?(ue=()=>X(!0),e[52]=X,e[53]=ue):ue=e[53];const we=ue;let ce;e[54]!==M||e[55]!==o||e[56]!==y||e[57]!==v||e[58]!==s||e[59]!==b?(ce=async()=>{if(!y||!M)return;const de=Array.from(v),{restoredIds:fe,failedIds:ge}=await b(de);fe.length>0&&Ke.success(fe.length===1?s("sessions.sidebar.bulkActions.restoredSingle",{count:fe.length}):s("sessions.sidebar.bulkActions.restoredPlural",{count:fe.length})),ge.length>0&&Ke.error(ge.length===1?s("sessions.sidebar.bulkActions.failedRestoreSingle",{count:ge.length}):s("sessions.sidebar.bulkActions.failedRestorePlural",{count:ge.length}),o(ge)),bs.getState().removeMany(fe)},e[54]=M,e[55]=o,e[56]=y,e[57]=v,e[58]=s,e[59]=b,e[60]=ce):ce=e[60];const le=ce;let Re;e[61]!==w||e[62]!==K||e[63]!==C||e[64]!==S?(Re=async()=>{if(!w)return;const de=C?.getSessionsById()??Rd,fe=q4(w,de);if(!fe.ready){S(fe.value);return}S(null),await K(fe.value.sessionIds,fe.value.archivedBucket)},e[61]=w,e[62]=K,e[63]=C,e[64]=S,e[65]=Re):Re=e[65];const Oe=Re;let Te,De;e[66]!==w||e[67]!==he||e[68]!==i||e[69]!==C||e[70]!==x?(Te=()=>{if(!x)return;const de=/Macintosh|Mac OS X/.test(navigator.userAgent||""),fe=ge=>{if(w||i)return;const B=ge.target instanceof HTMLElement?ge.target:null;if(B&&(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.isContentEditable))return;const Q=de?ge.metaKey:ge.ctrlKey;if(ge.key==="Escape"){ge.preventDefault(),bs.getState().disable();return}if(Q&&ge.key==="Backspace"){ge.preventDefault(),he();return}if(Q&&(ge.key==="a"||ge.key==="A")){const ke=n3(C?.getEntries()??[],C?.getDescendantIds()??[],bs.getState().scopeKey);if(!ke)return;ge.preventDefault(),bs.getState().replaceAll(ke.ids,ke.scopeKey)}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},De=[w,he,i,C,x],e[66]=w,e[67]=he,e[68]=i,e[69]=C,e[70]=x,e[71]=Te,e[72]=De):(Te=e[71],De=e[72]),c.useEffect(Te,De);let te;return e[73]!==P||e[74]!==A||e[75]!==M||e[76]!==Oe||e[77]!==F||e[78]!==Y||e[79]!==re||e[80]!==he||e[81]!==we||e[82]!==Se||e[83]!==Be||e[84]!==le||e[85]!==y||e[86]!==p||e[87]!==x?(te={selectionModeEnabled:x,hasSelection:y,selectedIdsSize:p,bulkScopeIsArchived:M,derivedSelectionScope:F,bulkScopeFolders:A,bulkCanRemoveFromFolder:P,handleToggleSelectionMode:k,handleExitSelectionMode:T,handleBulkMoveToFolder:Se,handleBulkCreateFolderAndMove:re,handleBulkRemoveFromFolder:Be,handleBulkDelete:he,handleBulkArchive:Y,handleBulkHardDelete:we,handleBulkRestore:le,confirmBulkDelete:Oe},e[73]=P,e[74]=A,e[75]=M,e[76]=Oe,e[77]=F,e[78]=Y,e[79]=re,e[80]=he,e[81]=we,e[82]=Se,e[83]=Be,e[84]=le,e[85]=y,e[86]=p,e[87]=x,e[88]=te):te=e[88],te};function Q4(t){return t.enabled}function X4(t){return t.selectedIds.size}function J4(t){return t.selectedIds}function Z4(t){return t.scopeKey}function e5(){bs.getState().toggleMode()}function t5(){bs.getState().disable()}function s5(t){const e=Ve.c(37),{getFolderScopesForProject:s,isInlineEditing:r,startFolderRename:o}=t,[i,l]=c.useState(null),a=be(u5),d=be(d5),u=rs(c5),f=rs(l5),m=rs(a5),h=rs(i5),b=Ze(o5),g=Ze(r5),w=Ze(n5);let S;e[0]!==f||e[1]!==o?(S=C=>{const k=f(C,"New folder");return o(C,k),k},e[0]=f,e[1]=o,e[2]=S):S=e[2];let x;e[3]!==m||e[4]!==b||e[5]!==i||e[6]!==w||e[7]!==u||e[8]!==s||e[9]!==r||e[10]!==h||e[11]!==a||e[12]!==S||e[13]!==g?(x={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:s,addSessionsToFolder:m,removeSessionsFromFolders:h,createFolderAndStartRename:S,archiveSessions:b,unarchiveSessions:g,deleteSessions:w,bulkDeleteConfirm:i,setBulkDeleteConfirm:l},e[3]=m,e[4]=b,e[5]=i,e[6]=w,e[7]=u,e[8]=s,e[9]=r,e[10]=h,e[11]=a,e[12]=S,e[13]=g,e[14]=x):x=e[14];const p=Y4(x);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(V4,{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 v;e[29]!==p.confirmBulkDelete||e[30]!==i||e[31]!==d||e[32]!==a?(v=n.jsx(W3,{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]=v):v=e[33];let j;return e[34]!==y||e[35]!==v?(j=n.jsxs(n.Fragment,{children:[y,v]}),e[34]=y,e[35]=v,e[36]=j):j=e[36],j}function n5(t){return t.deleteSessions}function r5(t){return t.unarchiveSessions}function o5(t){return t.archiveSessions}function i5(t){return t.removeSessionsFromFolders}function a5(t){return t.addSessionsToFolder}function l5(t){return t.createFolder}function c5(t){return t.foldersMap}function d5(t){return t.setShowDeletionDialog}function u5(t){return t.showDeletionDialog}const Tp="oc.sessions.expandedParents.v3",f5=ri(jn()),p5=()=>{try{const t=globalThis.localStorage.getItem(Tp);if(t===null)return new Set;const e=f5.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},m5=()=>{const[t,e]=c.useState(p5),s=c.useRef(t);s.current=t;const r=c.useCallback(o=>{const i=mx(s.current,o);s.current=i,e(i);try{globalThis.localStorage.setItem(Tp,JSON.stringify([...i]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},h5=t=>{const e=Ve.c(22),{childStores:s,sections:r,chatGroup:o,canGrantAccess:i}=t,l=ws(g5),a=ws(b5);let d;e[0]!==o||e[1]!==r?(d=[...r.flatMap(y5),...o?[{key:"activity:chats",group:o}]:[]].map(S5),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(w5)),e[3]=u,e[4]=f):f=e[4];let m;e[5]!==f?(m=[...f],e[5]=f,e[6]=m):m=e[6];const h=m;let b;e[7]!==s||e[8]!==h.length?(b=y=>h.length>0?s.subscribeBootstrap(y):j5,e[7]=s,e[8]=h.length,e[9]=b):b=e[9];let g;e[10]!==s||e[11]!==h?(g=()=>h.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]=h,e[12]=g):g=e[12];const w=c.useSyncExternalStore(b,g,k5);let S;if(e[13]!==i||e[14]!==s||e[15]!==l||e[16]!==u||e[17]!==a){S=new Map;for(const{key:y,archived:v,directories:j}of u){const C=j.find(k=>s.getBootstrapState(k)==="failed"||s.getInitializationState(k)==="failed");if(C){const k=s.getBootstrapState(C)==="failed",T=k?s.getBootstrapFailure(C):s.getInitializationFailure(C);S.set(y,{state:T==="os-permission"?"permission-denied":k?"load-failed":"initialization-failed",directory:C,canGrantAccess:T==="os-permission"&&i})}else{const k=a||!v&&j.length>0&&j.every(T=>s.getBootstrapState(T)==="complete");S.set(y,{state:k?"ready":l==="error"?"load-failed":"loading",directory:k?j[0]??null:null,canGrantAccess:!1})}}e[13]=i,e[14]=s,e[15]=l,e[16]=u,e[17]=a,e[18]=S}else S=e[18];const x=S;let p;return e[19]!==w||e[20]!==x?(p={groupStatusByKey:x,bootstrapSnapshot:w},e[19]=w,e[20]=x,e[21]=p):p=e[21],p};function g5(t){return t.status}function b5(t){return t.hasLoaded}function y5(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function x5(t){return ot(t.directory)}function v5(t){return!!t}function S5(t){const{key:e,group:s}=t;return{key:e,archived:s.isArchivedBucket===!0,directories:Lr(s).map(x5).filter(v5)}}function w5(t){return t.directories}function j5(){}function k5(){return""}const C5=6e4,N5=[],Td=[],Md=[],A5=t=>!t.parentID,P5=({topology:t,view:e,actions:s})=>{const{alwaysShowActions:r,notifyOnSubtasks:o,projectViewActions:i,rowActions:l,...a}=s,d=rs(Le=>Le.foldersMap),u=rs(Le=>Le.collapsedFolderIds),f=rs(Le=>Le.createFolder),m=rs(Le=>Le.addSessionToFolder),h=e.projectView,{getOrderedGroups:b,setGroupOrderByProject:g,toggleGroup:w,toggleProject:S,setCollapsedActivities:x}=i,p=dg({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),y=hx(Le=>Le.projects),v=Vm(),j=c.useMemo(()=>new Map(v.map(Le=>[Le.id,Le.name])),[v]),C=c.useMemo(()=>{const Le=new Map;for(const nt of v){const it=ot(nt.projectDirectory);if(!it)continue;const _e=Le.get(it);_e?_e.push(nt):Le.set(it,[nt])}return Le},[v]),k=c.useMemo(()=>L1(p.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,p.archivedSessions,y,v),[y,p.archivedSessions,p.sessions,v,t.availableWorktreesByProject,t.isVSCode,t.projects]),[T,O]=c.useState(new Map),[M,L]=c.useState(new Map),F=c.useCallback((Le,nt,it=7)=>{O(_e=>new Map(_e).set(Le,nt+it))},[]),D=c.useCallback(Le=>{O(nt=>{if(!nt.has(Le))return nt;const it=new Map(nt);return it.delete(Le),it})},[]),U=ms(Le=>Le.showRecentSection),N=ms(Le=>Le.showChatsSection),A=ms(Le=>Le.projectDisplayMode),H=ms(Le=>Le.singleProjectId),I=ms(Le=>Le.setSingleProjectId),P=!t.isVSCode&&!Gm()&&A==="single",_=e.sidebarViewMode==="timeline"&&!t.isVSCode,G=ug({enabled:U&&!P&&!_,isVSCode:t.isVSCode,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,sessions:p.rootSessions}),ae=c.useMemo(()=>gx(p.rootSessions,Le=>ot(t.worktreeMetadata.get(Le.id)?.projectDirectory??Le.directory??null)),[p.rootSessions,t.worktreeMetadata]),Se=c.useRef(null),J=c.useMemo(()=>{const Le=Array.from(ae.runKeyBySessionId,([nt,it])=>`${nt}\0${it}`).sort().join("");return Se.current?.signature!==Le&&(Se.current={signature:Le,map:ae.runKeyBySessionId}),Se.current.map},[ae]),[re,ie]=c.useState(null),[Be,Ae]=c.useState(null),[K,q]=c.useState(""),[X,me]=c.useState(null),[he,je]=c.useState(null),[Y,ue]=c.useState(null),we=c.useCallback((Le,nt)=>{ue({scopeKey:Le,folderId:nt.id,draft:nt.name})},[]),ce=c.useCallback(Le=>{ue(nt=>nt?{...nt,draft:Le}:null)},[]),le=c.useCallback(()=>ue(null),[]),{expandedParents:Re,toggleParent:Oe}=m5(),Te=Ze(Le=>Le.setCurrentSession),De=c.useCallback((Le,nt)=>{Le!==Ze.getState().currentSessionId&&Te(Le,nt)},[Te]),te=hf(),de=ms(Le=>Le.worktreeSortOrder),{buildGroupedSessions:fe,filterSessionNodesForSearch:ge,buildGroupSearchText:B}=H4({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:p.pinnedSessionIds,sessionOrderRanks:p.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:de,sessionOwners:k.bySessionId,spacesByProject:C,runKeyBySessionId:J}),{getSessionsForProject:Q,getArchivedSessionsForProject:ke}=EC({ownership:k}),Ie=bx(),oe=c.useMemo(()=>{if(t.isVSCode)return null;const Le=Ie??p.chatSessions.map(it=>Ta(it.directory)).find(Boolean)??null;if(!Le)return null;const nt=Array.from(new Set([Le,...p.chatSessions.map(it=>ot(it.directory??null)).filter(Boolean)])).filter(it=>!!it).map(it=>({scopeKey:it,directory:it}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Le,folderScopeKey:Le,folderScopes:nt,draftTarget:"chat",sessions:p.chatSessions.filter(it=>!it.time?.archived&&A5(it)).map(it=>or(p.childrenMap,it))}},[p.chatSessions,p.childrenMap,Ie,t.isVSCode]),$e=c.useMemo(()=>oe?[oe]:N5,[oe]),{projectSections:Fe,groupSearchDataByGroup:Ce,sectionsForRender:Ue,flatSectionsForRender:pe}=MC({normalizedProjects:t.projects,getSessionsForProject:Q,getArchivedSessionsForProject:ke,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:fe,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:ge,buildGroupSearchText:B,foldersMap:d,standaloneGroups:$e}),ne=e.onSearchMatchCountChange;c.useEffect(()=>()=>ne(0),[ne]);const Me=Ur(),He=e.useGroupedSections?Ue:pe,Ye=c.useMemo(()=>e.showInlineArchived?He:He.map(Le=>Le.groups.some(nt=>nt.isArchivedBucket)?{...Le,groups:Le.groups.filter(nt=>!nt.isArchivedBucket)}:Le),[He,e.showInlineArchived]),Xe=c.useCallback(Le=>pe.find(it=>it.project.id===Le)?.groups.find(it=>!it.isArchivedBucket)?.folderScopes??[],[pe]);kC({enabled:!0,normalizedProjects:t.projects,ownership:k,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:p.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:f,addSessionToFolder:m});const{sourceControl:Je}=Qs(),bt=hs(Le=>Le.ensureEntry),et=hs(Le=>Le.setParams),lt=hs(Le=>Le.refreshTargets),xt=hs(Le=>Le.clearDirectoryStatus),wt=hs(Le=>Le.beginActiveContextsLoad),dt=hs(Le=>Le.commitActiveContexts),It=hs(Le=>Le.releaseActiveContexts),_t=hs(Le=>Le.activeContextRegistrations),Bt=c.useId(),ye=c.useRef(new Set),z=c.useMemo(()=>new Map(p.orderedSessions.map((Le,nt)=>[Le.id,nt])),[p.orderedSessions]),[W,Z]=c.useState(null),ve=c.useRef([]),E=e.projectSortOrder==="recent";c.useEffect(()=>{E||Z(null)},[E]);const V=c.useMemo(()=>{const Le=de!=="manual"?Ye:Ye.map(it=>{const _e=b(it.project.id,it.groups);return _e===it.groups?it:{...it,groups:_e}}),nt=fg(Le,e.projectSortOrder,it=>it.project.id,k.sessionsByProject);return[...W&&E?pg(nt,W,it=>it.project.id):nt]},[b,W,E,k.sessionsByProject,Ye,e.projectSortOrder,de]);c.useEffect(()=>{ve.current=V.map(Le=>Le.project.id)},[V]);const Ne=c.useMemo(()=>{const Le=new Map(G.map(st=>[st.id,or(p.childrenMap,st)])),nt=[...Le.values()],it=[];for(;nt.length>0;){const st=nt.pop();if(!st)break;it.push(st.session),nt.push(...st.children)}const _e=Si({sessions:it,projects:t.projects,ownerBySessionId:k.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return mg({sessions:G,getSessionLocation:st=>_e.get(st)??null,getSessionNode:st=>Le.get(st.id)??or(p.childrenMap,st),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[p.childrenMap,k.bySessionId,G,j,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),We=c.useMemo(()=>{if(!_)return Td;const Le=new Set(p.rootSessions.map(ut=>ut.id)),nt=p.orderedSessions.filter(ut=>Le.has(ut.id)&&!ut.time?.archived),it=new Map,_e=Si({sessions:nt,projects:t.projects,ownerBySessionId:k.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return Vl({sessions:nt,getSessionLocation:ut=>_e.get(ut)??null,getSessionNode:ut=>{const St=or(p.childrenMap,ut),Ct=_e.get(ut.id);return it.set(ut.id,ya(St,!1,Ct?.groupDirectory??ut.directory??null)),{...St,children:[],worktree:Ct?.worktree??null}},query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""}).map(ut=>({...ut,blockingBadgeSessionScopes:it.get(ut.node.session.id)}))},[p.childrenMap,p.orderedSessions,p.rootSessions,k.bySessionId,j,_,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Ge=be(Le=>Le.sessionWorkEnabled),qe=be(Le=>Le.sessionWorkKeepInGroup),Pe=c.useMemo(()=>{if(!Ge)return Md;const Le=p.orderedSessions.filter(nt=>!nt.parentID&&!nt.time?.archived&&!Ra(nt.directory)&&Xa(nt));return Le.length>0?Le:Md},[p.orderedSessions,Ge]),ze=c.useMemo(()=>new Set(Pe.map(Le=>Le.id)),[Pe]),Rt=c.useMemo(()=>{if(Pe.length===0)return Td;const Le=Si({sessions:[...Pe],projects:t.projects,ownerBySessionId:k.bySessionId,spaceLabelById:j,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!_}),nt=new Map,it=new Map(Pe.map(St=>{const Ct=or(p.childrenMap,St);_&&nt.set(St.id,ya(Ct,!1,Le.get(St.id)?.groupDirectory??St.directory??null));const Nt={...Ct,children:_?[]:Ct.children,worktree:Le.get(St.id)?.worktree??null};return[St.id,Nt]})),_e=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",st=_e?Pe.filter(St=>{const Ct=it.get(St.id);return Ct?hg(Ct,_e):!1}):[...Pe],ut=Vl({sessions:st,getSessionLocation:St=>Le.get(St)??null,getSessionNode:St=>it.get(St.id)??or(p.childrenMap,St),query:""});return _?ut.map(St=>({...St,blockingBadgeSessionScopes:nt.get(St.node.session.id)})):ut},[p.childrenMap,k.bySessionId,j,_,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,Pe]),zt=c.useMemo(()=>{const Le=new Map,nt=new Map,it=new Map,_e=new Map,st=new Set,ut=(Ct,Nt)=>{const os=Nt?.trim();Ct&&os&&Le.set(vx(Ct,os),{directory:Ct,branch:os})},St=Ct=>{if(ut(ot(Ct.worktree?.path??null),Ct.worktree?.branch),!t.isVSCode){for(const Nt of uf(Ct.session))nt.set(`${Nt.owner.toLowerCase()}/${Nt.repo.toLowerCase()}#${Nt.number}`,{owner:Nt.owner,repo:Nt.repo,number:Nt.number});for(const Nt of Ya(Ct.session))Nt.source==="github"?it.set(`${Nt.owner.toLowerCase()}/${Nt.repo.toLowerCase()}#${Nt.number}`,{owner:Nt.owner,repo:Nt.repo,number:Nt.number}):Nt.source==="linear"&&st.add(Nt.identifier.toUpperCase());for(const Nt of xx(Ct.session))_e.set(Nt.key,Nt)}Ct.children.forEach(St)};return Rt.forEach(Ct=>St(Ct.node)),_?(We.forEach(Ct=>St(Ct.node)),{targets:Le,linkedRefs:[...nt.values()],linkedIssueRefs:[...it.values()],linearIdentifiers:[...st],gitlabRefs:[..._e.values()]}):(Ne.forEach(Ct=>Ct.items.forEach(Nt=>St(Nt.node))),Fe.forEach(Ct=>{h.collapsedProjects.has(Ct.project.id)||Ct.groups.forEach(Nt=>{if(Nt.isArchivedBucket||(Nt.sessions.forEach(St),Nt.isMain))return;const os=ot(Nt.directory??null);ut(os,Nt.branch?.trim()||t.gitBranches.get(os||""))})}),{targets:Le,linkedRefs:[...nt.values()],linkedIssueRefs:[...it.values()],linearIdentifiers:[...st],gitlabRefs:[..._e.values()]})},[Fe,h.collapsedProjects,Ne,We,_,t.gitBranches,t.isVSCode,Rt]),Tt=zt.targets,Ft=c.useRef(null),gt=c.useMemo(()=>{const Le=jC(Tt.values()),nt=JSON.stringify(Le);return Ft.current?.signature!==nt&&(Ft.current={signature:nt,candidates:Le}),Ft.current.candidates},[Tt]);c.useEffect(()=>{const Le=gt;if(Le.length===0)return;let nt=!1;const it=Jt(),_e=async(Ht,Ee=C5)=>{const Qe=Date.now(),rt=new Map,pt=Kt=>{const Yt=rt.get(Kt);if(Yt)return Yt;const ys=wt(it,Kt,Bt),Es=zn.scope(Kt),Ws=Do(()=>zn.read(Es,Je)).then(en=>{if(nt||it!==Jt())return null;const cs=en.contexts[0],Rs=cs&&qi(Bn.getState().entries[lr(cs)],cs).connected?[cs]:[];return dt(it,Kt,Bt,ys,Rs)?(Rs.length===0&&xt(Kt),Rs):null});return rt.set(Kt,Ws),Ws},Mt=await Promise.all(Le.filter(Kt=>!Ht||Kt.directory===Ht).map(async Kt=>(await pt(Kt.directory)??[]).map(ys=>({...Kt,context:ys}))));if(nt||it!==Jt())return;const Wt=new Map,ss=new Map;for(const Kt of Mt.flat()){const Yt=Fu(Kt.context,Kt.branch);ss.set(Yt,{context:Kt.context,branch:Kt.branch});const ys=hs.getState().entries[Yt],Es=ys?.status?.changeRequest??ys?.status?.pr,Ws=Es?.state,cs=!!Es&&!(Ws==="closed"||Ws==="merged"),Rs=Math.max(ys?.lastRefreshAt??0,ys?.lastDiscoveryPollAt??0),Ms=!!(ys?.isInitialStatusResolved&&!cs&&(!ye.current.has(Yt)||Qe-Rs>=Ee));(!ys||!ys.isInitialStatusResolved||Ms)&&(Ms&&ye.current.add(Yt),Wt.has(Yt)||Wt.set(Yt,{context:Kt.context,branch:Kt.branch}))}ss.forEach((Kt,Yt)=>{bt(Yt),et(Yt,{directory:Kt.context.directory,branch:Kt.branch,remoteName:Kt.context.primaryRemote,canShow:!0,identity:Kt.context,readContext:Kt.context,sourceControl:Je,authChecked:!0,connected:!0})}),Wt.size!==0&&await lt([...Wt.values()],{silent:!0,markInitialResolved:!0})},st=[...new Set(Le.map(Ht=>Ht.directory))].map(Ht=>zn.scope(Ht)),ut=st.map(Ht=>{let Ee=zn.snapshot(Ht);return zn.subscribe(Ht,()=>{const Qe=zn.snapshot(Ht),rt=Ee.read!==null&&Ee!==Qe;Ee=Qe,rt&&!nt&&_e(Ht.directory)})}),St=Bn.subscribe((Ht,Ee)=>{if(!(nt||it!==Jt()||Ht.entries===Ee.entries))for(const Qe of st){const rt=zn.snapshot(Qe).contexts[0];if(!rt)continue;const pt=lr(rt);Ht.entries[pt]!==Ee.entries[pt]&&_e(Qe.directory)}});_e();const Ct=new Set(Le.map(Ht=>Ht.directory)),Nt=_n(Ht=>{!nt&&Ht.type==="source-control-activity"&&Ct.has(Ht.directory)&&_e(Ht.directory,0)}),os=()=>{!nt&&document.visibilityState==="visible"&&_e()};return document.addEventListener("visibilitychange",os),()=>{nt=!0,St(),ut.forEach(Ht=>Ht()),Nt(),document.removeEventListener("visibilitychange",os);for(const Ht of Le)It(it,Ht.directory,Bt)}},[wt,xt,dt,gt,bt,lt,It,et,Je,Bt]);const vt=c.useMemo(()=>yx(_t,Tt.values()),[_t,Tt]),qt=_u(vt),ct=c.useMemo(()=>[...qt,...zt.linkedRefs.map(Le=>Or("pull",Le)),...zt.linkedIssueRefs.map(Le=>Or("issue",Le)),...zt.gitlabRefs.map(Le=>Le.thread==="pull"?Br("pull",Le):Br("issue",Le)),...zt.linearIdentifiers.map(Qa)],[qt,zt]);Lu(ct);const{groupStatusByKey:at,bootstrapSnapshot:yt}=h5({childStores:Me,sections:V,chatGroup:oe,canGrantAccess:ou()});let $t=null;P&&(Fe.some(Le=>Le.project.id===H)?$t=H:Fe.some(Le=>Le.project.id===e.activeProjectId)?$t=e.activeProjectId:$t=Fe[0]?.project.id??null);const ls=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:Ce,collapsedGroups:h.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:o,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:z,expandedParents:Re,editingId:re,editingRowKey:Be,editTitle:K,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,setEditingId:ie,setEditingRowKey:Ae,setEditTitle:q,toggleParent:Oe,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:he,setDeleteSessionConfirm:je,startFolderRename:we,startSessionWorktreeMenuLoad:s.startSessionWorktreeMenuLoad,onEditProject:_?a.openProjectEditDialog:void 0,folderRename:Y,setFolderRenameDraft:ce,clearFolderRename:le}),[p.pinnedSessionIds,r,o,h.collapsedGroups,Ce,z,K,re,Be,Re,Y,ce,le,we,he,s.startSessionWorktreeMenuLoad,a.openProjectEditDialog,_,l,Oe,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,P]),jt=c.useMemo(()=>({showMoreGroupSessions:F,resetGroupSessionLimit:D,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:w}),[D,F,w,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),kt=c.useMemo(()=>{const Le=new Map;for(const nt of V)for(const it of nt.groups){const _e=Rn(nt.project.id,it.directory);if(!_e)continue;const st=Lr(it),ut=Le.get(_e),St=[...new Set([...ut?.scopeKeys??[],...st.map(Nt=>Nt.scopeKey)])],Ct=p.hasAuthoritativeGlobalSessions&&st.every(Nt=>{const os=ot(Nt.directory);return!os||Me.getBootstrapState(os)==="complete"});Le.set(_e,{scopeKeys:St,complete:(ut?.complete??!0)&&Ct})}if(oe){const nt=Rn(null,oe.directory);nt&&Le.set(nt,{scopeKeys:Lr(oe).map(it=>it.scopeKey),complete:p.hasAuthoritativeGlobalSessions})}return Le},[yt,oe,Me,p.hasAuthoritativeGlobalSessions,V]),Vt=c.useMemo(()=>new Map([...T,...M]),[M,T]),es=c.useMemo(()=>I2({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:_?"timeline":"projects",sections:V,authoritativeSections:Fe,chatGroup:N?oe:null,recentSections:Ne,timelineItems:We,workItems:Rt,workSessionIds:ze,keepWorkInGroup:qe,showRecentSection:U&&!P&&!_,foldersMap:d,groupSearchDataByGroup:Ce,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:h.collapsedProjects,collapsedGroups:h.collapsedGroups,collapsedFolders:u,collapsedActivities:h.collapsedActivities,expandedParents:Re,visibleCountByContainer:Vt,pinnedSessionIds:p.pinnedSessionIds,sessionOrderIndex:z,groupStatusByKey:at,folderAuthorityByOwner:kt,activeProjectId:e.activeProjectId,singleProjectMode:P&&!_,singleProjectId:$t,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:P&&!e.useGroupedSections?20:void 0,runIndex:ae}),[ae,oe,N,h.collapsedActivities,We,_,Rt,ze,qe,u,p.pinnedSessionIds,Re,kt,d,Ce,at,V,Fe,h.collapsedGroups,h.collapsedProjects,Ne,$t,z,U,P,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Vt]);c.useEffect(()=>{ne(es.searchMatchCount)},[ne,es.searchMatchCount]);const Is=c.useMemo(()=>({rowModel:es,sectionsForRender:V,projectSections:Fe,singleProjectMode:P,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:re,openSidebarMenuKey:X,setOpenSidebarMenuKey:me,visibleSessionCountByGroup:T,collapsedActivityKeys:h.collapsedActivities,setCollapsedActivityKeys:x,visibleActivityCountByKey:M,setVisibleActivityCountByKey:L},groupProps:ls}),[ls,re,X,Fe,V,es,t.projectRepoStatus,e.emptyState,e.searchEmptyState,T,M,h.collapsedActivities,x,P]),Ds=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:de,timelineView:_}),[_,de,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),ts=c.useMemo(()=>({group:jt,toggleProject:S,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:g,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:I}),[jt,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,g,S,a.renderProjectStatusIndicator,I]);return n.jsxs(n.Fragment,{children:[n.jsx(yC,{}),n.jsx(PC,{projectSections:Fe,activeProjectId:e.activeProjectId,initialActiveSessionByProject:s.initialActiveSessionByProject,persistActiveSessionByProject:s.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:s.openNewSessionDraft,setSessionSwitcherOpen:s.setSessionSwitcherOpen,sessionOwnerBySessionId:k.bySessionId,handleSessionSelect:De}),n.jsx($C,{sortedSessions:p.orderedSessions,recentSessions:G,prefetchSession:te}),n.jsxs(s3,{entries:es.selectionEntries,descendantIds:es.selectionDescendantIds,sessionsById:es.sessionById,children:[n.jsx(s5,{getFolderScopesForProject:Xe,isInlineEditing:re!==null,startFolderRename:we}),n.jsx("div",{className:"contents",onPointerEnter:Le=>{E&&Le.pointerType==="mouse"&&Z(ve.current)},onPointerLeave:()=>Z(null),children:n.jsx(U4,{model:Is,view:Ds,actions:ts})})]})]})},I5=t=>{const e=Ve.c(2);let s;return e[0]!==t?(s=t.view.isVisible?n.jsx(P5,{...t}):null,e[0]=t,e[1]=s):s=e[1],s},Mp=(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=[],E5=sl(jn(),jn().min(1).catch("")),R5=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:s,allowReselect:r=!1,hideDirectoryControls:o=!1,showOnlyMainWorkspace:i=!1})=>{zi("react.session_sidebar_render"),Os("ui.session_sidebar.render"),Os(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),Os(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=mt(),[a,d]=c.useState(!1),[u,f]=c.useState(""),m=c.useCallback(()=>d(!0),[]),h=c.useCallback(()=>{f(""),d(!1)},[]),[b,g]=c.useState(0),w=c.useRef(null),S=c.useRef(null),[x,p]=c.useState(null),y=c.useMemo(()=>Ao(),[]),[v,j]=c.useState(new Map),C=be(Pe=>Pe.isNewWorktreeDialogOpen),k=be(Pe=>Pe.setNewWorktreeDialogOpen),[T,O]=c.useState(!1),M=c.useMemo(()=>{try{const Pe=y.getItem(Od);if(!Pe)return new Map;const ze=E5.safeParse(JSON.parse(Pe));if(!ze.success)return new Map;const Rt=new Map;return Object.entries(ze.data).forEach(([zt,Tt])=>{Tt&&Rt.set(zt,Tt)}),Rt}catch{return new Map}},[y]),L=c.useCallback(Pe=>{try{y.setItem(Od,JSON.stringify(Object.fromEntries(Pe.entries())))}catch{}},[y]),[F,D]=c.useState(new Map),U=Ss(Pe=>Pe.homeDirectory),N=Xt(Pe=>Pe.projects),A=Xt(Pe=>Pe.activeProjectId),H=Xt(Pe=>Pe.removeProject),I=Xt(Pe=>Pe.setActiveProjectIdOnly),R=Xt(Pe=>Pe.updateProjectMeta),P=Xt(Pe=>Pe.reorderProjects),_=be(Pe=>Pe.setSettingsDialogOpen),G=be(Pe=>Pe.toggleHelpDialog),ae=be(Pe=>Pe.setAboutDialogOpen),Se=be(Pe=>Pe.setSessionSwitcherOpen),J=be(Pe=>Pe.setWorktreesPageProjectId),re=be(Pe=>Pe.notifyOnSubtasks),ie=c.useMemo(()=>u.trim().toLowerCase(),[u]),Be=ie.length>0;f2({enabled:t,isSessionSearchOpen:a,openSessionSearch:m,closeSessionSearch:h,sessionSearchInputRef:S,sessionSearchContainerRef:w});const Ae=Ju(t),K=c.useMemo(()=>qs(),[]),q=Ze(Pe=>Pe.worktreeMetadata),X=Ze(Pe=>Pe.availableWorktreesByProject),me=Ze(Pe=>Pe.openNewSessionDraft),he=c.useMemo(()=>Mp(N,X,{includeWorktrees:!K}),[X,K,N]),je=c.useCallback(Pe=>{be.getState().closeMainSurfaces(),me(Pe),K&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[K,me]),Y=Dr(yr(Pe=>({checkForUpdates:Pe.checkForUpdates,available:Pe.available,runtimeType:Pe.runtimeType,info:Pe.info,downloading:Pe.downloading,downloaded:Pe.downloaded,installing:Pe.installing,progress:Pe.progress,error:Pe.error,downloadUpdate:Pe.downloadUpdate,restartToUpdate:Pe.restartToUpdate}))),ue=Jt(),we=c.useMemo(()=>`${ue}|${N.map(Pe=>`${Pe.id}:${ot(Pe.path)??""}`).join("|")}`,[N,ue]),[ce,le]=c.useState(K?we:null),[Re,Oe]=c.useReducer(Pe=>Pe+1,0),Te=!K&&ce!==we,[De,te]=c.useState(new Set),de=c.useRef(De);de.current=De;const fe=ps(Pe=>Pe.isConnected),ge=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Pe=!1;return(async()=>{const Rt=ue,zt=ps.getState().isConnected,Tt=Xt.getState().projects;if(Ze.setState({worktreeDiscoveryByProject:new Map(Tt.map(kt=>[ot(kt.path)??kt.path,"loading"]))}),Tt.length===0||K){Pe||(ge.current={runtimeKey:null,revision:0,worktreesByProject:new Map},te(new Set),le(we));return}const Ft=Ze.getState().availableWorktreesByProject,gt=ml({rawWorktreesByProjectRef:ge,publishedWorktreesByProject:Ft,runtimeKey:Rt}),vt=gt.revision,qt=new Map(gt.worktreesByProject),ct=new Set,at=3;let yt=0;const $t=Array.from({length:at},async()=>{for(;;){const kt=yt;if(yt+=1,kt>=Tt.length)return;const Vt=Tt[kt],es=ot(Vt.path);if(es)try{const Is=await Do(async()=>xn.getState().directories.get(es)?.isGitRepo??await ju(es)?lc({id:Vt.id,path:es}):null);if(Is===null){qt.delete(es);continue}if(Pe)return;Is.length===0?qt.delete(es):qt.set(es,Is)}catch{ct.add(es)}}});if(await Promise.all($t),Pe||Jt()!==Rt)return;const ls=new Set(Tt.map(kt=>ot(kt.path)).filter(Boolean));for(const kt of qt.keys())ls.has(kt)||qt.delete(kt);w3({rawWorktreesByProjectRef:ge,runtimeKey:Rt,capturedRevision:vt,nextRawWorktreesByProject:qt,publishedWorktreesByProject:Ft,partitionWorktreesByRegisteredProject:ac,projects:Tt,worktreeMapsEqual:ic,recordWorktreesSeen:Dd,publishTopology:kt=>{Ze.setState(kt)},requestRediscovery:()=>{Oe()},now:()=>Date.now()})&&(te(ct),Ze.setState({worktreeDiscoveryByProject:new Map(Tt.map(kt=>{const Vt=ot(kt.path)??kt.path;return[Vt,ct.has(Vt)?"error":"ready"]}))}),le(we),ct.size>0&&!zt&&ps.getState().isConnected&&Oe())})(),()=>{Pe=!0}},[K,we,ue,Re]),c.useEffect(()=>{fe&&de.current.size>0&&Oe()},[fe]);const B=c.useMemo(()=>cn(),[]),{isTablet:Q}=Ln(),ke=e||Q,Ie=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]),oe=c.useMemo(()=>N.find(Pe=>Pe.id===x)??null,[N,x]),$e=c.useCallback(Pe=>{x&&R(x,{label:Pe.label,icon:Pe.icon,color:Pe.color,iconBackground:Pe.iconBackground,defaultAgent:Pe.defaultAgent??null,defaultModel:Pe.defaultModel??null,defaultVariant:Pe.defaultVariant??null})},[x,R]),Fe=c.useCallback(()=>{k(!0)},[k]),Ce=c.useCallback(()=>{const Pe=Dr.getState();if(Pe.available&&Pe.info){O(!0);return}Y.checkForUpdates().then(()=>{const{available:ze,error:Rt}=Dr.getState();if(Rt){Ke.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Rt});return}if(!ze){Ke.success(l("sessions.sidebar.updateCheck.latestVersion"));return}O(!0)})},[l,Y]),Ue=c.useCallback(()=>{e&&Se(!1),_(!0)},[e,Se,_]),pe=Y.available&&(Y.runtimeType==="desktop"||Y.runtimeType==="web"),ne=c.useCallback(()=>{wn.requestDirectoryDialog()},[]),Me=c.useMemo(()=>N.flatMap(Pe=>{const ze=ot(Pe.path);return ze?[{id:Pe.id,path:Pe.path,label:Pe.label,normalizedPath:ze,icon:Pe.icon??void 0,color:Pe.color??void 0,iconImage:Pe.iconImage??void 0,iconBackground:Pe.iconBackground??void 0,addedAt:Pe.addedAt,lastOpenedAt:Pe.lastOpenedAt,sidebarCollapsed:Pe.sidebarCollapsed}]:[]}),[N]),He=c.useMemo(()=>Me.map(Pe=>Pe.normalizedPath),[Me]),Ye=Sx(t?He:D5);L2({enabled:t,normalizedProjects:Me,gitRepoStatus:Ye,setProjectRepoStatus:j,setProjectRootBranches:D});const Xe=Ze(Pe=>Pe.isLoading),Je=c.useRef(!1);A&&v.has(A)&&(Je.current=!!v.get(A));const bt=ms(Pe=>Pe.showArchivedSessions),et=ms(Pe=>Pe.projectSortOrder),lt=ms(Pe=>Pe.sidebarViewMode),xt=Xt(Pe=>Pe.manualProjectOrder),wt={isVisible:t,mobileVariant:e,onSessionSelected:s,allowReselect:r,hideDirectoryControls:o,showOnlyMainWorkspace:i,t:l,isTablet:Q,projects:N,activeProjectId:A,manualProjectOrder:xt,worktreeMetadata:q,availableWorktreesByProject:X,gitBranches:Ae,gitRepoStatus:Ye,updateStore:Y,showArchivedSessions:bt,projectSortOrder:et,projectRepoStatus:v,projectRootBranches:F,resolvedWorktreeTopologyKey:ce,unresolvedWorktreeProjectPaths:De,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:x,updateDialogOpen:T},dt=c.useRef(null),It=dt.current;if(It){let Pe=!1;for(const ze of Object.keys(wt))Object.is(It[ze],wt[ze])||(Os(`ui.session_sidebar.source.${ze}`),Pe=!0);Pe||Os("ui.session_sidebar.source.parent_or_context")}dt.current=wt;const _t=c.useMemo(()=>gg(Me,et,xt),[Me,et,xt]),Bt=E2({isVSCode:K,projects:_t}),ye=c.useMemo(()=>n.jsx(gC,{query:u,showArchive:!K,resetSessionSearch:h}),[K,h,u]),z=K&&bt,W=!K,Z=K?"projects":lt,ve=Z==="projects",Ne=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",We="h-4.5 w-4.5",Ge=c.useMemo(()=>({projects:N,getCurrentProjects:()=>Xt.getState().projects,rawWorktreesByProjectRef:ge,getPublishedWorktreesByProject:()=>Ze.getState().availableWorktreesByProject,resolveProject:Pe=>Gi(Pe),listProjectWorktrees:lc,partitionWorktreesByRegisteredProject:ac,worktreeMapsEqual:ic,recordWorktreesSeen:Dd,publishTopology:Pe=>{Ze.setState(Pe)},getRuntimeKey:Jt,now:()=>Date.now()}),[N]),qe=c.useCallback(Pe=>{const ze=Ip(Pe,{projects:N,resolveProject:Gi});return S3(Pe,{...Ge,projectRootBranch:ze?F.get(ze.id)??null:null})},[F,N,Ge]);return c.useEffect(()=>{if(K)return;const Pe=ze=>{for(const Rt of ze){const zt=ot(Rt.path),Tt=Jt(),Ft=gt=>{!zt||Jt()!==Tt||Ze.setState(vt=>({worktreeDiscoveryByProject:new Map(vt.worktreeDiscoveryByProject).set(zt,gt)}))};Ft("loading"),Ap(Rt,null,Ge).then(()=>{!zt||Jt()!==Tt||(Ft("ready"),te(gt=>{if(!gt.has(zt))return gt;const vt=new Set(gt);return vt.delete(zt),vt}))}).catch(()=>{!zt||Jt()!==Tt||(Ft("error"),te(gt=>new Set(gt).add(zt)))})}};return _n(ze=>{if(ze.type==="session-created"){const Rt=wx(ze.directory,Xt.getState().projects);if(!Rt){Oe();return}Pe([Rt]);return}ze.type==="worktree-changed"&&Pe(jx(ze.directories))})},[K,Ge]),n.jsx(Qo,{delay:400,closeDelay:0,timeout:300,children:n.jsxs("div",{ref:w,className:xe("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[n.jsx(G2,{hideDirectoryControls:o,showProjectDisplayControls:!K,showRecentControls:!K,handleOpenDirectoryDialog:ne,showSourceBoard:!e&&!K,headerActionIconClass:We,headerActionButtonClass:Ne,isSessionSearchOpen:a,openSessionSearch:m,closeSessionSearch:h,sessionSearchInputRef:S,sessionSearchQuery:u,setSessionSearchQuery:f,hasSessionSearchQuery:Be,searchMatchCount:b,collapseAll:Bt.actions.collapseAll,expandAll:Bt.actions.expandAll}),n.jsx(I5,{topology:{projects:_t,availableWorktreesByProject:X,knownDirectories:he,isVSCode:K,worktreeMetadata:q,gitBranches:Ae,projectRepoStatus:v,projectRootBranches:F,lastRepoStatus:Je.current},view:{isVisible:t,hasSessionSearchQuery:Be,normalizedSessionSearchQuery:ie,activeProjectId:A,showInlineArchived:z,useGroupedSections:W,homeDirectory:U,mobileVariant:e,hideDirectoryControls:o,showOnlyMainWorkspace:i,isDesktopShellRuntime:B,stickyZoneHeaders:ve,projectSortOrder:et,sidebarViewMode:Z,emptyState:Ie,searchEmptyState:ye,isSessionsLoading:Xe,isWorktreeTopologyLoading:Te,unresolvedWorktreeProjectPaths:De,projectView:Bt.state,onSearchMatchCountChange:g},actions:{rowActions:{allowReselect:r,onSessionSelected:s,resetSessionSearch:h},alwaysShowActions:ke,notifyOnSubtasks:re,setActiveProjectIdOnly:I,setSessionSwitcherOpen:Se,openNewSessionDraft:je,openNewWorktreeDialog:Fe,openWorktreesPage:Pe=>{e&&Se(!1),J(Pe)},openProjectEditDialog:p,removeProject:H,reorderProjects:P,startSessionWorktreeMenuLoad:qe,initialActiveSessionByProject:M,persistActiveSessionByProject:L,projectViewActions:Bt.actions}}),n.jsx(mC,{onOpenSettings:Ue,onOpenShortcuts:G,onOpenAbout:()=>ae(!0),onOpenUpdate:Ce,showRuntimeButtons:!K,showUpdateButton:pe}),n.jsx(Oa,{open:T,onOpenChange:O,info:Y.info,downloading:Y.downloading,downloaded:Y.downloaded,installing:Y.installing,progress:Y.progress,error:Y.error,onDownload:Y.downloadUpdate,onRestart:Y.restartToUpdate,runtimeType:Y.runtimeType}),n.jsx(H2,{open:!!oe,onOpenChange:Pe=>{Pe||p(null)},project:oe,onSave:$e}),n.jsx(kx,{open:C,onOpenChange:k,onWorktreeCreated:Pe=>{be.getState().closeMainSurfaces(),e&&Se(!1),me({directoryOverride:Pe,preserveDirectoryOverride:!0})}})]})})},T5=c.memo(R5),M5=t=>{const e=Ve.c(10),{ready:s,hasProjects:r,loadSettings:o,saveDismissed:i}=t,[l,a]=c.useState(!1),d=c.useRef(!1);let u,f;e[0]!==r||e[1]!==o||e[2]!==s?(u=()=>{if(d.current||!s||r)return;let g=!1;return o().then(w=>{g||!w||(d.current=!0,w.addProjectDialogDismissed!==!0&&a(!0))}),()=>{g=!0}},f=[r,o,s],e[0]=r,e[1]=o,e[2]=s,e[3]=u,e[4]=f):(u=e[3],f=e[4]),c.useEffect(u,f);let m;e[5]!==i?(m=g=>{a(g),g||i()},e[5]=i,e[6]=m):m=e[6];const h=m;let b;return e[7]!==h||e[8]!==l?(b={open:l,setOpen:a,onOpenChange:h},e[7]=h,e[8]=l,e[9]=b):b=e[9],b},hn=t=>t?n.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Gs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},O5=()=>{In({addProjectDialogDismissed:!0})},B5=()=>{const{t}=mt(),{git:e,sourceControl:s}=Qs(),[r,o]=c.useState(null),[i,l]=c.useState([]),[a,d]=c.useState(!1),[u,f]=c.useState(!1),[m,h]=c.useState(!1),[b,g]=c.useState(!1),[w,S]=c.useState(new Set),x=Ze(te=>te.getWorktreeMetadata),p=Ze(te=>te.newSessionDraft),y=Ze(te=>te.setNewSessionDraftTarget),v=Ze(te=>te.setDraftBootstrapPendingDirectory),j=Cx,C=Ax,k=Ze(te=>te.deleteSessions),T=Ze(te=>te.archiveSessions),O=be(te=>te.showDeletionDialog),M=be(te=>te.setShowDeletionDialog),L=Ss(te=>te.currentDirectory),F=Ss(te=>te.homeDirectory),D=Ss(te=>te.isHomeReady),U=Xt(te=>te.projects),N=Xt(te=>te.activeProjectId),{open:A,setOpen:H,onOpenChange:I}=M5({ready:D,hasProjects:U.length>0,loadSettings:qm,saveDismissed:O5}),{isMobile:R,isTablet:P,hasTouchInput:_}=Ln(),G=R||P||_,ae=c.useMemo(()=>{const de=(N?U.find(fe=>fe.id===N)??null:null)?.path??L;return Gs(de)},[N,L,U]),Se=c.useCallback(te=>{const fe=Gs(te.projectDirectory)||ae;return{id:(U.find(B=>Gs(B.path)===fe)??null)?.id??`path:${fe}`,path:fe}},[ae,U]),J=b&&w.size>0,re=c.useMemo(()=>{const te=r?.worktree;return te&&typeof te.branch=="string"&&te.branch.trim().length>0?!!te.status?.upstream?.split("/")[0]?.trim():i.length>0&&i.every(({metadata:de})=>typeof de.branch=="string"&&de.branch.trim().length>0&&!!de.status?.upstream?.split("/")[0]?.trim())},[r?.worktree,i]),ie=r?.mode==="worktree",Be=m||!ie||!re,Ae=m||!ie,K=c.useCallback(te=>{o({sessions:te.sessions,dateLabel:te.dateLabel,mode:te.mode??"session",worktree:te.worktree??null})},[]),q=c.useCallback(()=>{o(null),l([]),d(!1),f(!1),h(!1),g(!1),S(new Set)},[]),X=c.useCallback(async te=>{if(te.sessions.length===0)return;if(te.sessions.length===1){const B=te.sessions[0];await j(B.id)?Ke.success(t("sessions.sidebar.session.delete.success")):Ke.error(t("sessions.sidebar.session.delete.error"));return}const de=te.sessions.map(B=>B.id),{deletedIds:fe,failedIds:ge}=await k(de);if(fe.length>0){const B=ge.length>0?ge.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ge.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ge.length}):te.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:te.dateLabel}):void 0;Ke.success(fe.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:fe.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:fe.length}),{description:hn(B)})}ge.length>0&&Ke.error(ge.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ge.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ge.length}),{description:hn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[j,k,t]);c.useEffect(()=>wn.onDirectoryRequest(()=>{H(!0)}),[]),c.useEffect(()=>{if(!r){l([]),d(!1),f(!1),g(!1),S(new Set);return}const te=r.sessions.map(ge=>{const B=x(ge.id);return B?{session:ge,metadata:B}:null}).filter(ge=>!!ge);l(te),d(!1),g(!1),S(new Set);const de=new Map;if(r.worktree?.path&&de.set(Gs(r.worktree.path),r.worktree),te.forEach(({metadata:ge})=>{ge.path&&de.set(Gs(ge.path),ge)}),de.size===0){g(!0);return}let fe=!1;return(async()=>{const ge=new Map,B=new Set;await Promise.all(Array.from(de.entries()).map(async([Q,ke])=>{try{const Ie=await cc(ke.path);ge.set(Q,Ie),Ie?.isDirty&&B.add(Q)}catch{ke.status&&(ge.set(Q,ke.status),ke.status.isDirty&&B.add(Q))}})).catch(Q=>{console.warn("Failed to inspect worktree status before deletion:",Q)}),!fe&&(S(B),g(!0),o(Q=>{if(!Q?.worktree?.path)return Q;const ke=Gs(Q.worktree.path),Ie=ge.get(ke);if(!Ie)return Q;const oe=Q.worktree.status;return oe?.isDirty===Ie.isDirty&&oe?.ahead===Ie.ahead&&oe?.behind===Ie.behind&&oe?.upstream===Ie.upstream?Q:{...Q,worktree:{...Q.worktree,status:Ie}}}),l(Q=>Q.map(ke=>{const Ie=Gs(ke.metadata.path),oe=ge.get(Ie);return oe?{session:ke.session,metadata:{...ke.metadata,status:oe}}:ke})))})(),()=>{fe=!0}},[r,x]),c.useEffect(()=>{re||d(!1)},[re]);const me=c.useCallback(async(te,de,fe)=>{const ge=a&&re,B=Se(te),Q=Gs(te.path),ke=Gs(B.path);try{await ku(B,te,{deleteRemoteBranch:ge,deleteLocalBranch:de,remoteName:te.status?.upstream?.split("/")[0]?.trim(),network:{git:e,sourceControl:s}});const Ie=Gs(p?.directoryOverride);return p?.open&&Q&&Ie===Q&&ke&&(v(null),y({projectId:B.id,directoryOverride:ke},{force:!0})),Gs(L)===Q&&ke&&Ss.getState().setDirectory(ke,{showOverlay:!1}),!0}catch(Ie){return Ke.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:ki(te)}),{id:fe,description:hn(Ie instanceof Error?Ie.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[re,L,a,Se,e,p?.directoryOverride,p?.open,v,y,s,t]),he=c.useCallback((te,de,fe)=>{const ge=a&&re,B=Ke.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:ki(te)}));return Nx(te.path),(async()=>{try{const Q=await bg({sessionIds:de,removeWorktree:()=>me(te,fe,B),archiveSessions:async oe=>oe.length===1?await C(oe[0])?{archivedIds:oe,failedIds:[]}:{archivedIds:[],failedIds:oe}:T(oe)});if(!Q.removed)return;const ke=t(ge?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Ke.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:ki(te)}),{id:B,description:hn(ke)});const{failedIds:Ie}=Q.archive;Ie.length>0&&Ke.error(Ie.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Ie.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:Ie.length}),{description:hn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}catch(Q){Ke.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:B,description:hn(Q instanceof Error?Q.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}finally{Px(te.path)}})()},[C,T,re,a,me,t]),je=c.useRef(new Set),Y=c.useCallback(async(te,de)=>{const fe=Gs(te.path);if(!je.current.has(fe)){je.current.add(fe);try{const ge=await cc(te.path).catch(()=>{});if(!Ix(ge)){K({sessions:de,mode:"worktree",worktree:te});return}await he(te,de.map(B=>B.id),!0)}finally{je.current.delete(fe)}}},[K,he]);c.useEffect(()=>wn.onDeleteRequest(te=>{if(!O&&(te.mode??"session")==="session"){X(te);return}if(te.mode==="worktree"&&te.skipDialogIfSafe&&te.worktree){Y(te.worktree,te.sessions);return}K(te)}),[K,O,X,Y]);const ue=c.useCallback(async()=>{if(r){h(!0);try{if(ie){const te=r.worktree??i[0]?.metadata;if(!te){Ke.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:hn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),h(!1);return}he(te,r.sessions.map(de=>de.id),u),q();return}if(r.sessions.length===1){const te=r.sessions[0];if(!await j(te.id)){Ke.error(t("sessions.sidebar.session.delete.error")),h(!1);return}Ke.success(t("sessions.sidebar.session.delete.success"),{action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const te=r.sessions.map(ge=>ge.id),{deletedIds:de,failedIds:fe}=await k(te);if(de.length>0){const ge=fe.length>0?fe.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:fe.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:fe.length}):r.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:r.dateLabel}):void 0;Ke.success(de.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:de.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:de.length}),{description:hn(ge),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(fe.length>0&&(Ke.error(fe.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:fe.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:fe.length}),{description:hn(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),de.length===0)){h(!1);return}}q()}finally{h(!1)}}},[r,i,u,j,k,q,ie,he,t]),we=r?.worktree??i[0]?.metadata??null;let ce="";if(r?.mode==="worktree"){const te=r.sessions.length;te===0?ce=t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):te===1?ce=t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:te}):ce=t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:te})}else if(r){const te=r.sessions.length;te===1?ce=r.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:r.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):ce=r.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:te,dateLabel:r.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:te})}const le=r?n.jsxs("div",{className:xe(ie?"space-y-3":"space-y-2"),children:[r.sessions.length>0&&n.jsxs("div",{className:xe(ie?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ie&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"typography-meta font-medium text-foreground",children:r.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:r.sessions.length})]}),n.jsxs("ul",{className:xe(ie?"mt-2 space-y-1":"space-y-0.5"),children:[r.sessions.slice(0,5).map(te=>n.jsxs("li",{className:xe(ie?"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:xe(!ie&&"hidden"),children:"•"}),n.jsx("span",{dir:"auto",className:"truncate",children:te.title||t("sessions.sidebar.session.untitled")})]},te.id)),r.sessions.length>5&&n.jsx("li",{className:xe(ie?"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:r.sessions.length-5})})]})]}),ie?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($,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),we?.label?n.jsx("span",{className:"typography-micro text-muted-foreground/70",children:we.label}):null]}),n.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:we?gr(we.path,F):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),J&&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,Re=ie?re?n.jsxs("button",{type:"button",onClick:()=>{Be||d(te=>!te)},disabled:Be,"aria-pressed":a,className:xe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Be?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[a?n.jsx($,{name:"checkbox",className:"size-4 text-primary"}):n.jsx($,{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,Oe=ie?n.jsxs("button",{type:"button",onClick:()=>{Ae||f(te=>!te)},disabled:Ae,"aria-pressed":u,className:xe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Ae?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?n.jsx($,{name:"checkbox",className:"size-4 text-primary"}):n.jsx($,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Te=ie?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:[Oe,Re]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ft,{variant:"ghost",onClick:q,disabled:m,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ft,{variant:"destructive",onClick:ue,disabled:m,children:t(m?"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:()=>M(!O),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":!O,children:[O?n.jsx($,{name:"checkbox-blank",className:"size-4"}):n.jsx($,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ft,{variant:"ghost",onClick:q,disabled:m,children:t("sessions.sidebar.dialogs.cancel")}),n.jsx(ft,{variant:"destructive",onClick:ue,disabled:m,children:m?t("sessions.sidebar.sessionDialogs.actions.deleting"):r?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),De=ie?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):r?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return n.jsxs(n.Fragment,{children:[G?n.jsx(Dx,{open:!!r,onClose:()=>{m||q()},title:De,footer:n.jsx("div",{className:"flex justify-end gap-2",children:Te}),children:n.jsxs("div",{className:"space-y-2 pb-2",children:[ce&&n.jsx("p",{className:"typography-meta text-muted-foreground/80",children:ce}),le]})}):n.jsx(_s,{open:!!r,onOpenChange:te=>{if(!te){if(m)return;q()}},children:n.jsxs(Ls,{className:xe(ie?"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(Zs,{children:[n.jsxs(Xs,{className:xe(ie&&"flex items-center gap-2"),children:[ie&&n.jsx($,{name:"delete-bin",className:"h-5 w-5"}),De]}),ce&&n.jsx(Js,{children:ce})]}),n.jsx("div",{className:xe(ie&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:le}),n.jsx(Jn,{className:"mt-2 gap-2 pt-1 pb-1",children:Te})]})}),n.jsx(yg,{open:A,onOpenChange:I})]})};function F5(){const t=Ve.c(18),{t:e}=mt(),s=be($5),r=be(_5),o=Xt(L5);let i;t[0]!==s?(i=b=>b.projects.find(g=>g.id===s)??null,t[0]=s,t[1]=i):i=t[1];const l=Xt(i);if(!s||!l)return null;let a;t[2]!==l.id||t[3]!==o||t[4]!==r?(a=()=>{o(l.id),r(!0)},t[2]=l.id,t[3]=o,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx($,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==u?(f=n.jsx("div",{className:"flex items-center",children:n.jsxs(ft,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=f):f=t[11];let m;t[12]!==l.id||t[13]!==l.path?(m=n.jsx(xg,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=m):m=t[14];let h;return t[15]!==f||t[16]!==m?(h=n.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:n.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[f,m]})})}),t[15]=f,t[16]=m,t[17]=h):h=t[17],h}function L5(t){return t.setActiveProjectIdOnly}function _5(t){return t.setNewWorktreeDialogOpen}function $5(t){return t.worktreesPageProjectId}function W5(){const t=Ve.c(52),{t:e}=mt(),s=be(z5);let r;t[0]!==s?(r=T=>T.projects.find(O=>O.id===s)??null,t[0]=s,t[1]=r):r=t[1];const o=Xt(r),{journey:i,error:l}=Ym(),[a,d]=c.useState(!1);if(!o)return null;let u,f,m,h,b,g,w,S,x,p;if(t[2]!==l||t[3]!==i||t[4]!==o||t[5]!==e){const T=i?Qm(i,o.path):[];p="absolute inset-0 z-10 flex flex-col bg-background",x="flex-1 overflow-y-auto px-6 py-4",w="mx-auto w-full max-w-4xl space-y-4";let O,M;t[16]===Symbol.for("react.memo_cache_sentinel")?(O=()=>d(!0),M=n.jsx($,{name:"box-3",className:"mr-1 h-3.5 w-3.5"}),t[16]=O,t[17]=M):(O=t[16],M=t[17]);let L;t[18]!==e?(L=e("spaces.page.new"),t[18]=e,t[19]=L):L=t[19],t[20]!==L?(S=n.jsx("div",{className:"flex items-center",children:n.jsxs(ft,{size:"sm",onClick:O,children:[M,L]})}),t[20]=L,t[21]=S):S=t[21],u=Mx,t[22]!==e?(f=e("spaces.page.listTitle"),t[22]=e,t[23]=f):f=t[23],t[24]!==l||t[25]!==e?(m=l?n.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("spaces.page.loadFailed",{reason:Ex(e,Rx(l))})}):null,t[24]=l,t[25]=e,t[26]=m):m=t[26],t[27]!==l||t[28]!==i||t[29]!==e?(h=i===null&&!l?n.jsx("p",{className:"typography-meta text-muted-foreground",children:e("spaces.page.loading")}):null,t[27]=l,t[28]=i,t[29]=e,t[30]=h):h=t[30],b=i!==null&&!l&&T.length===0?n.jsx("p",{className:"typography-meta text-muted-foreground/70",children:e("spaces.page.empty")}):null,g=T.length>0?n.jsx("div",{className:"space-y-1",children:T.map(K5)}):null,t[2]=l,t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=f,t[8]=m,t[9]=h,t[10]=b,t[11]=g,t[12]=w,t[13]=S,t[14]=x,t[15]=p}else u=t[6],f=t[7],m=t[8],h=t[9],b=t[10],g=t[11],w=t[12],S=t[13],x=t[14],p=t[15];let y;t[31]!==u||t[32]!==f||t[33]!==m||t[34]!==h||t[35]!==b||t[36]!==g?(y=n.jsxs(u,{title:f,children:[m,h,b,g]}),t[31]=u,t[32]=f,t[33]=m,t[34]=h,t[35]=b,t[36]=g,t[37]=y):y=t[37];let v;t[38]!==y||t[39]!==w||t[40]!==S?(v=n.jsxs("div",{className:w,children:[S,y]}),t[38]=y,t[39]=w,t[40]=S,t[41]=v):v=t[41];let j;t[42]!==v||t[43]!==x?(j=n.jsx("div",{className:x,children:v}),t[42]=v,t[43]=x,t[44]=j):j=t[44];let C;t[45]!==a||t[46]!==o?(C=a?n.jsx(Tx,{open:!0,onOpenChange:T=>{T||d(!1)},project:{id:o.id,path:o.path}}):null,t[45]=a,t[46]=o,t[47]=C):C=t[47];let k;return t[48]!==j||t[49]!==C||t[50]!==p?(k=n.jsxs("div",{className:p,children:[j,C]}),t[48]=j,t[49]=C,t[50]=p,t[51]=k):k=t[51],k}function K5(t){return n.jsx(vg,{entry:t,actions:"menu"},t.id)}function z5(t){return t.spacesPageProjectId}function U5(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 Ox(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 H5(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 V5=new Map,G5=t=>{const e=Ve.c(23),{isVSCode:s}=t,r=Ur(),o=Xt(q5),i=Ss(Y5),l=Ze(Q5);let a;e[0]!==s?(a=O=>s?V5:O.availableWorktreesByProject,e[0]=s,e[1]=a):a=e[1];const d=Ze(a),u=!s;let f;e[2]!==d||e[3]!==o||e[4]!==u?(f=Mp(o,d,{includeWorktrees:u}),e[2]=d,e[3]=o,e[4]=u,e[5]=f):f=e[5];const m=f,h=ws(X5),b=ws(J5),g=ws(Z5),w=`session-list-sync:${c.useId()}`;let S,x;e[6]!==w||e[7]!==r||e[8]!==i||e[9]!==l?(S=()=>(r.setBootstrapDemand(w,H5({currentDirectory:i,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(w)),x=[w,r,i,l],e[6]=w,e[7]=r,e[8]=i,e[9]=l,e[10]=S,e[11]=x):(S=e[10],x=e[11]),c.useEffect(S,x);const p=c.useRef(null);let y,v;e[12]!==s||e[13]!==m?(y=()=>{const O=new Set(m),M=p.current;p.current=O;const L=M?[...O].filter(F=>!M.has(F)):s?[...O]:[];L.length&&Ba(L,Ro())},v=[s,m],e[12]=s,e[13]=m,e[14]=y,e[15]=v):(y=e[14],v=e[15]),c.useEffect(y,v);let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[16]=j):j=e[16],c.useEffect(eN,j);let C;e[17]!==b||e[18]!==h?(C=[...h,...b],e[17]=b,e[18]=h,e[19]=C):C=e[19];const k=C;let T;e[20]!==k||e[21]!==g?(T={enabled:!0,hasAuthoritativeGlobalSessions:g,sessions:k},e[20]=k,e[21]=g,e[22]=T):T=e[22],Sg(T)};function q5(t){return t.projects}function Y5(t){return t.currentDirectory}function Q5(t){return t.currentSessionDirectory}function X5(t){return t.activeSessions}function J5(t){return t.archivedSessions}function Z5(t){return t.status==="ready"}function eN(){let t=null,e=!1;const s=new Set,r=_n(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(),Ja(Ro());return}const i=[...s];s.clear(),i.length&&Ba(i,Ro())},500)});return()=>{t&&clearTimeout(t),r()}}const tN=()=>kn(()=>import("./SettingsWindow-DyM7QuhI.js"),__vite__mapDeps([145,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,146,83,84,85,86,147,132,133,134,135,121,122,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,148,149,150])).then(t=>t.SettingsWindow),sN=()=>{const t=Ve.c(75);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],G5(e),wg();const s=be(nN),r=be(rN),o=be(oN),i=be(iN),l=be(aN);let a;t[1]!==l?(a=()=>l(!1),t[1]=l,t[2]=a):a=t[2];const d=U5(i,tN,a),u=be(lN),f=be(cN),m=be(dN),h=be(uN),b=be(fN),g=be(pN),w=be(mN),S=be(hN),x=Zu();let p;if(t[3]!==x||t[4]!==S){let te;t[6]!==S?(te=de=>de.id===S,t[6]=S,t[7]=te):te=t[7],p=x.find(te),t[3]=x,t[4]=S,t[5]=p}else p=t[5];const y=p;let v,j;t[8]!==y||t[9]!==S?(v=()=>{S&&!y&&be.getState().setOpenGuestPage(null)},j=[S,y],t[8]=y,t[9]=S,t[10]=v,t[11]=j):(v=t[10],j=t[11]),c.useEffect(v,j);let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=[],t[12]=C):C=t[12],c.useEffect(bN,C);const k=f||m||h||b||!!g||w||u||!!y;let T;t[13]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[13]=T):T=t[13],c.useEffect(xN,T);const{isMobile:O}=Ln();jg();let M,L;t[14]!==O||t[15]!==o?(M=()=>{be.getState().isMobile!==O&&o(O)},L=[O,o],t[14]=O,t[15]=o,t[16]=M,t[17]=L):(M=t[16],L=t[17]),c.useEffect(M,L);let F,D,U,N,A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(n2,{}),F=n.jsx(r2,{}),D=n.jsx(l2,{}),U=n.jsx(kg,{}),N=n.jsx(B5,{}),t[18]=F,t[19]=D,t[20]=U,t[21]=N,t[22]=A):(F=t[18],D=t[19],U=t[20],N=t[21],A=t[22]);let H;t[23]!==r?(H=r?n.jsxs(n.Fragment,{children:[n.jsx(Cg,{}),n.jsx(Ng,{}),n.jsx(Ag,{}),n.jsx(Pg,{}),n.jsx(Ig,{})]}):null,t[23]=r,t[24]=H):H=t[24];let I;t[25]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx(pS,{}),t[25]=I):I=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(fS,{}),t[26]=R):R=t[26];let P;t[27]!==s?(P=n.jsx(T5,{isVisible:s}),t[27]=s,t[28]=P):P=t[28];let _;t[29]!==O||t[30]!==s||t[31]!==P?(_=n.jsx(uS,{isOpen:s,isMobile:O,className:"border-border",topBar:R,children:P}),t[29]=O,t[30]=s,t[31]=P,t[32]=_):_=t[32];let G;t[33]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx(cS,{}),t[33]=G):G=t[33];const ae=k&&"invisible";let Se;t[34]!==ae?(Se=xe("absolute inset-0",ae),t[34]=ae,t[35]=Se):Se=t[35];const J=!i&&!k;let re;t[36]!==J?(re=n.jsx(Ts,{children:n.jsx(du,{active:J})}),t[36]=J,t[37]=re):re=t[37];let ie;t[38]!==Se||t[39]!==re?(ie=n.jsx("div",{className:Se,children:re}),t[38]=Se,t[39]=re,t[40]=ie):ie=t[40];let Be;t[41]===Symbol.for("react.memo_cache_sentinel")?(Be=n.jsx(Ts,{children:n.jsx(Dg,{})}),t[41]=Be):Be=t[41];let Ae;t[42]===Symbol.for("react.memo_cache_sentinel")?(Ae=n.jsx(Ts,{children:n.jsx(Eg,{})}),t[42]=Ae):Ae=t[42];let K;t[43]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx(Ts,{children:n.jsx(Rg,{})}),t[43]=K):K=t[43];let q;t[44]!==h?(q=h&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Ts,{children:n.jsx(Tg,{})})}),t[44]=h,t[45]=q):q=t[45];let X;t[46]===Symbol.for("react.memo_cache_sentinel")?(X=n.jsx(Mg,{}),t[46]=X):X=t[46];let me;t[47]===Symbol.for("react.memo_cache_sentinel")?(me=n.jsx(Ts,{children:n.jsx(F5,{})}),t[47]=me):me=t[47];let he;t[48]!==w?(he=w?n.jsx(Ts,{children:n.jsx(W5,{})}):null,t[48]=w,t[49]=he):he=t[49];let je;t[50]!==y?(je=y&&n.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:n.jsx(Ts,{children:n.jsx(Bx,{mode:`plugin:${y.id}`,surface:"page",item:null,onDismiss:vN})})}),t[50]=y,t[51]=je):je=t[51];let Y;t[52]!==ie||t[53]!==q||t[54]!==he||t[55]!==je?(Y=n.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ie,Be,Ae,K,q,X,me,he,je]}),t[52]=ie,t[53]=q,t[54]=he,t[55]=je,t[56]=Y):Y=t[56];let ue;t[57]===Symbol.for("react.memo_cache_sentinel")?(ue=n.jsx(xk,{}),t[57]=ue):ue=t[57];let we;t[58]!==Y?(we=n.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:n.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children: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:[Y,ue]})})}),t[58]=Y,t[59]=we):we=t[59];let ce;t[60]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:n.jsx(Ts,{children:n.jsx(Ik,{})})}),t[60]=ce):ce=t[60];let le;t[61]===Symbol.for("react.memo_cache_sentinel")?(le=n.jsx(Ts,{children:n.jsx(w1,{})}),t[61]=le):le=t[61];let Re;t[62]!==we?(Re=n.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[G,n.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[we,ce,le]})]}),t[62]=we,t[63]=Re):Re=t[63];let Oe;t[64]!==_||t[65]!==Re?(Oe=n.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[_,Re]}),t[64]=_,t[65]=Re,t[66]=Oe):Oe=t[66];let Te;t[67]!==d||t[68]!==i||t[69]!==l?(Te=d?n.jsx(d,{open:i,onOpenChange:l}):null,t[67]=d,t[68]=i,t[69]=l,t[70]=Te):Te=t[70];let De;return t[71]!==H||t[72]!==Oe||t[73]!==Te?(De=n.jsx(Og,{children:n.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[A,F,D,U,N,H,I,Oe,Te]})}),t[71]=H,t[72]=Oe,t[73]=Te,t[74]=De):De=t[74],De};function nN(t){return t.isSidebarOpen}function rN(t){return t.isolatedSpacesEnabled}function oN(t){return t.setIsMobile}function iN(t){return t.isSettingsDialogOpen}function aN(t){return t.setSettingsDialogOpen}function lN(t){return t.runOverviewKey!==null}function cN(t){return t.isScheduledTasksDialogOpen}function dN(t){return t.isArchivePageOpen}function uN(t){return t.isUsageStatsPageOpen}function fN(t){return t.isSourceBoardOpen}function pN(t){return t.worktreesPageProjectId}function mN(t){return t.isolatedSpacesEnabled&&t.spacesPageProjectId!==null}function hN(t){return t.openGuestPageId}function gN(){return be.getState().setOpenGuestPage(null)}function bN(){return Wr(gN)}function yN(){return be.getState().closeMainSurfaces()}function xN(){const t=yN,e=Ze.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 vN(){return be.getState().setOpenGuestPage(null)}const Op=12,SN=[{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"}],wN=t=>{const e=Ve.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?SN:l,m=us.useRef(!1);let h,b;e[0]!==s||e[1]!==a?(h=()=>{!s&&m.current&&a?.(),s&&(m.current=!0)},b=[s,a],e[0]=s,e[1]=a,e[2]=h,e[3]=b):(h=e[2],b=e[3]),us.useEffect(h,b);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=Array.from({length:Op},jN),e[4]=g):g=e[4];const w=g;if(!s)return null;let S;e[5]!==o?(S=xe("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=S):S=e[6];let x;if(e[7]!==d||e[8]!==f||e[9]!==u){let y;e[11]!==d||e[12]!==u?(y=v=>{const j={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${u}ms`};return n.jsx("div",{className:"firework-burst",style:j,children:w.map((C,k)=>{const T=C.x*v.radius,O=C.y*v.radius,M={"--translate-x":`${T}px`,"--translate-y":`${O}px`,"--particle-delay":`${C.delay}ms`,color:`var(${v.colorVar})`};return n.jsx("span",{className:"firework-particle",style:M},`${v.id}-${k}-${d}`)})},`${v.id}-${d}`)},e[11]=d,e[12]=u,e[13]=y):y=e[13],x=f.map(y),e[7]=d,e[8]=f,e[9]=u,e[10]=x}else x=e[10];let p;return e[14]!==d||e[15]!==S||e[16]!==x?(p=n.jsx("div",{className:S,"aria-hidden":"true","data-burst-key":d,children:x}),e[14]=d,e[15]=S,e[16]=x,e[17]=p):p=e[17],p};function jN(t,e){const s=Math.PI*2*e/Op;return{x:Math.cos(s),y:Math.sin(s),delay:e*18}}const kN=t=>{const e=Ve.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]=us.useState(i),d=us.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 m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{f(),a(CN)},e[4]=m):m=e[4];const h=m;let b;e[5]!==o?(b=()=>{f(),a(NN),d.current=window.setTimeout(()=>{a(AN),d.current=null},o)},e[5]=o,e[6]=b):b=e[6];const g=b;let w,S;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=()=>()=>f(),S=[f],e[7]=w,e[8]=S):(w=e[7],S=e[8]),us.useEffect(w,S);let x;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==g?(x={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:g,dismissFireworks:h},e[9]=l.cycle,e[10]=l.isActive,e[11]=g,e[12]=x):x=e[12],x};function CN(t){return t.isActive?{...t,isActive:!1}:t}function NN(t){return{isActive:!0,cycle:t.cycle+1}}function AN(t){return t.isActive?{...t,isActive:!1}:t}const Bp=c.createContext(void 0),PN=t=>{const e=Ve.c(10),{children:s}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:l}=kN();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(wN,{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(Bp.Provider,{value:d,children:[s,u]}),e[6]=s,e[7]=u,e[8]=d,e[9]=f):f=e[9],f},EP=()=>{const t=c.useContext(Bp);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Aa="openchamber_requests_in_flight",Fp=1e3,IN=300*1e3,Ho=Math.ceil(IN/Fp),DN=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Aa)==="1"}catch{return!1}},Lp=()=>({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 EN=1;const RN=(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))},TN=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},_p=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},hr=(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)},MN=()=>{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=EN++;RN(i,Date.now());try{return await e(r,o)}finally{TN(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)},kr=t=>{t.length>Ho&&t.splice(0,t.length-Ho)},ON=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=_p(t),s=e.length>0?e[e.length-1]:0;t.p50Samples.push(hr(e,50)),t.p90Samples.push(hr(e,90)),t.p99Samples.push(hr(e,99)),t.maxSamples.push(s),s>t.peakAgeMs&&(t.peakAgeMs=s),t.sampleCount+=1,kr(t.samples),kr(t.p50Samples),kr(t.p90Samples),kr(t.p99Samples),kr(t.maxSamples),t.lastSampleAt=Date.now()},BN=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(ON,Fp))},Fd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Ld=t=>{if(!(typeof window>"u"))try{if(t){Fd(),Bd(),window.localStorage.setItem(Aa,"1"),window.__openchamberRequestsInFlight__=Lp(),MN(),BN();return}window.localStorage.removeItem(Aa),Fd(),Bd(),delete window.__openchamberRequestsInFlight__}catch{}},FN=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=Lp();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Pa=()=>{if(typeof window>"u")return _d();const t=window.__openchamberRequestsInFlight__;if(!DN()||!t)return _d();const e=_p(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:hr(e,50),ageP90:hr(e,90),ageP99:hr(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:Ho}},_d=()=>({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:Ho});function LN(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const $p=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const s=Math.floor(e/60),r=Math.round(e%60);return`${s}m ${r}s`},Ia=t=>`${(t/1e3).toFixed(2)} s`,vs=t=>{const e=Ve.c(8),{label:s,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let i;e[1]!==s?(i=n.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:s}),e[1]=s,e[2]=i):i=e[2];let l;e[3]!==r?(l=n.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=n.jsxs("div",{className:"rounded-md p-2",style:o,children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a},$d=t=>{const e=Ve.c(43),{title:s,snapshot:r,emptyLabel:o}=t,{t:i}=mt();let l;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==i||e[6]!==s){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(WN,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let f;e[10]!==s?(f=n.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:s}),e[10]=s,e[11]=f):f=e[11];let m;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==i?(m=r.startedAt?$p(r.durationMs):i("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=i,e[15]=m):m=e[15];let h;e[16]!==m?(h=n.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:m}),e[16]=m,e[17]=h):h=e[17];let b;e[18]!==f||e[19]!==h?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f,h]}),e[18]=f,e[19]=h,e[20]=b):b=e[20];let g;e[21]!==i?(g=i("memoryDebugPanel.metric.metrics"),e[21]=i,e[22]=g):g=e[22];let w;e[23]!==r.entries.length||e[24]!==g?(w=n.jsx(vs,{label:g,value:r.entries.length}),e[23]=r.entries.length,e[24]=g,e[25]=w):w=e[25];let S;e[26]!==i?(S=i("memoryDebugPanel.metric.samples"),e[26]=i,e[27]=S):S=e[27];let x;e[28]!==S||e[29]!==u?(x=n.jsx(vs,{label:S,value:u}),e[28]=S,e[29]=u,e[30]=x):x=e[30];let p;e[31]!==i?(p=i("memoryDebugPanel.metric.lastUpdate"),e[31]=i,e[32]=p):p=e[32];let y;e[33]!==r.lastUpdatedAt||e[34]!==i?(y=r.lastUpdatedAt?i("memoryDebugPanel.common.live"):i("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=i,e[35]=y):y=e[35];let v;e[36]!==p||e[37]!==y?(v=n.jsx(vs,{label:p,value:y}),e[36]=p,e[37]=y,e[38]=v):v=e[38];let j;e[39]!==x||e[40]!==v||e[41]!==w?(j=n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[w,x,v]}),e[39]=x,e[40]=v,e[41]=w,e[42]=j):j=e[42],l=n.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,j,a.length===0?n.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):n.jsx(Cn,{outerClassName:"max-h-64",className:"pr-1",children:n.jsx("div",{className:"space-y-1",children:a.map(C=>n.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[n.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),n.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[n.jsx("span",{children:i("memoryDebugPanel.metric.countValue",{value:C.count})}),n.jsx("span",{children:i("memoryDebugPanel.metric.avgValue",{value:C.avg})}),n.jsx("span",{children:i("memoryDebugPanel.metric.maxValue",{value:C.max})}),n.jsx("span",{children:i("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=i,e[6]=s,e[7]=l}else l=e[7];return l},Wd=t=>{const e=Ve.c(24),{series:s,peak:r,windowSeconds:o,ariaLabel:i,maxLabel:l}=t,a=o,d=s.reduce(KN,0),u=r>0?52/r:0;let f;e[0]!==d||e[1]!==a?(f=v=>a-d+v,e[0]=d,e[1]=a,e[2]=f):f=e[2];const m=f;let h;e[3]!==u?(h=v=>56-v*u,e[3]=u,e[4]=h):h=e[4];const b=h;let g;e[5]!==l?(g=n.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=g):g=e[6];const w=`0 0 ${a} 56`;let S;e[7]!==a?(S=n.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=S):S=e[8];let x;if(e[9]!==s||e[10]!==m||e[11]!==b){let v;e[13]!==m||e[14]!==b?(v=(j,C)=>{const k=j.samples.length;if(k===0)return null;const T=j.samples.map((M,L)=>`${m(L)},${b(M).toFixed(2)}`),O=`M ${T.join(" L ")}`;return n.jsxs(c.Fragment,{children:[j.filled?n.jsx("path",{d:`M ${m(0)},56 L ${T.join(" L ")} L ${m(k-1)},56 Z`,fill:`color-mix(in srgb, ${j.color} 18%, transparent)`,stroke:"none"}):null,n.jsx("path",{d:O,fill:"none",stroke:j.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=m,e[14]=b,e[15]=v):v=e[15],x=s.map(v),e[9]=s,e[10]=m,e[11]=b,e[12]=x}else x=e[12];let p;e[16]!==i||e[17]!==w||e[18]!==S||e[19]!==x?(p=n.jsxs("svg",{viewBox:w,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":i,children:[S,x]}),e[16]=i,e[17]=w,e[18]=S,e[19]=x,e[20]=p):p=e[20];let y;return e[21]!==g||e[22]!==p?(y=n.jsxs("div",{className:"relative w-full",children:[g,p]}),e[21]=g,e[22]=p,e[23]=y):y=e[23],y},_N=t=>{const e=Ve.c(100),{onClose:s}=t,{t:r}=mt(),[o,i]=c.useState("memory"),[l,a]=c.useState("idle"),d=Ze(zN),u=gf(UN),f=Hu(),m=Fx(HN),h=hs(VN),[b,g]=c.useState(GN),[w,S]=c.useState(qN),[x,p]=c.useState(YN),y=[{label:"p50",current:x.ageP50,samples:x.p50Samples,color:"var(--status-success)"},{label:"p90",current:x.ageP90,samples:x.p90Samples,color:"var(--status-info)"},{label:"p99",current:x.ageP99,samples:x.p99Samples,color:"var(--status-warning)"},{label:"max",current:x.ageMax,samples:x.maxSamples,color:"var(--status-error)"}];let v;e[0]!==x.samples?(v=x.samples.reduce(QN,0),e[0]=x.samples,e[1]=v):v=e[1];const j=v,C=y.reduce(JN,0);let k;e[2]!==b.entries?(k=new Map,b.entries.forEach(Me=>{k.set(Me.metric,Me.count)}),e[2]=b.entries,e[3]=k):k=e[3];let T;e[4]!==k?(T=k.get("ui.message_list.render")??0,e[4]=k,e[5]=T):T=e[5];let O;e[6]!==k?(O=k.get("ui.message_list.render.streaming")??0,e[6]=k,e[7]=O):O=e[7];let M;e[8]!==k?(M=k.get("ui.chat_message.render")??0,e[8]=k,e[9]=M):M=e[9];let L;e[10]!==k?(L=k.get("ui.chat_message.render.streaming")??0,e[10]=k,e[11]=L):L=e[11];let F;e[12]!==k?(F=k.get("ui.chat_message.render.static_during_stream")??0,e[12]=k,e[13]=F):F=e[13];let D;e[14]!==k?(D=k.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=k,e[15]=D):D=e[15];let U;e[16]!==T||e[17]!==O||e[18]!==M||e[19]!==L||e[20]!==F||e[21]!==D?(U={messageListRender:T,messageListRenderStreaming:O,chatMessageRender:M,chatMessageRenderStreaming:L,chatMessageRenderStaticDuringStream:F,chatMessageRenderStaticOutsideActiveTurnDuringStream:D},e[16]=T,e[17]=O,e[18]=M,e[19]=L,e[20]=F,e[21]=D,e[22]=U):U=e[22];const N=U;let A,H;e[23]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{const Me=()=>{g(bo()),S(yo()),p(Pa())};Me();const He=window.setInterval(Me,500);return()=>window.clearInterval(He)},A=[],e[23]=A,e[24]=H):(A=e[23],H=e[24]),c.useEffect(H,A);let I,R;e[25]!==l?(I=()=>{if(l==="idle")return;const Me=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Me)},R=[l],e[25]=l,e[26]=I,e[27]=R):(I=e[26],R=e[27]),c.useEffect(I,R);let P=0,_=0,G=0;for(const Me of Object.keys(m)){const He=m[Me]??[];_=_+He.length;for(const Ye of He)Ye.role==="user"?G=G+1:Ye.role==="assistant"&&(P=P+1)}let ae;e[28]!==P||e[29]!==_||e[30]!==G?(ae={assistant:P,total:_,user:G},e[28]=P,e[29]=_,e[30]=G,e[31]=ae):ae=e[31];const Se=ae;let J;if(e[32]!==d||e[33]!==m||e[34]!==u||e[35]!==f||e[36]!==r){let Me;e[38]!==d||e[39]!==m||e[40]!==u||e[41]!==r?(Me=He=>{const Ye=m[He.id]??[];let Xe=0,Je=0;for(const et of Ye)et.role==="user"?Je=Je+1:et.role==="assistant"&&(Xe=Xe+1);const bt=u.get(He.id);return{id:He.id,title:He.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:Xe,messageCount:Ye.length,userMessageCount:Je,isStreaming:bt?.isStreaming||!1,isZombie:bt?.isZombie||!1,backgroundCount:bt?.backgroundMessageCount||0,lastAccessed:bt?.lastAccessedAt||0,isCurrent:He.id===d}},e[38]=d,e[39]=m,e[40]=u,e[41]=r,e[42]=Me):Me=e[42],J=f.map(Me).sort(ZN),e[32]=d,e[33]=m,e[34]=u,e[35]=f,e[36]=r,e[37]=J}else J=e[37];const re=J;let ie;e[43]!==m?(ie=Object.keys(m),e[43]=m,e[44]=ie):ie=e[44];const Be=ie.length;let Ae;e[45]===Symbol.for("react.memo_cache_sentinel")?(Ae=async()=>{try{const Me={generatedAt:new Date().toISOString(),ui:bo(),vscode:yo()};await navigator.clipboard.writeText(JSON.stringify(Me,null,2)),a("copied")}catch{a("error")}},e[45]=Ae):Ae=e[45];const K=Ae,q=_x,X="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let me;e[46]===Symbol.for("react.memo_cache_sentinel")?(me={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=me):me=e[46];let he;e[47]!==o?(he=LN(o),e[47]=o,e[48]=he):he=e[48];let je;e[49]!==he?(je=n.jsx($,{name:he,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=he,e[50]=je):je=e[50];let Y;e[51]!==r?(Y=r("memoryDebugPanel.title"),e[51]=r,e[52]=Y):Y=e[52];let ue;e[53]!==Y?(ue=n.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Y}),e[53]=Y,e[54]=ue):ue=e[54];let we;e[55]!==je||e[56]!==ue?(we=n.jsxs("div",{className:"flex items-center gap-2",children:[je,ue]}),e[55]=je,e[56]=ue,e[57]=we):we=e[57];let ce;e[58]!==o?(ce=o==="streaming"?n.jsxs(n.Fragment,{children:[n.jsx(ft,{size:"xs",variant:"ghost",onClick:K,children:n.jsx($,{name:"file-copy",className:"h-3.5 w-3.5"})}),n.jsx(ft,{size:"xs",variant:"ghost",onClick:()=>{Xm(),g(bo()),S(yo())},children:n.jsx($,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=o,e[59]=ce):ce=e[59];let le;e[60]!==o?(le=o==="requests"?n.jsx(ft,{size:"xs",variant:"ghost",onClick:()=>{FN(),p(Pa())},children:n.jsx($,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=o,e[61]=le):le=e[61];let Re;e[62]!==s?(Re=s?n.jsx(ft,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:s,children:n.jsx($,{name:"close",className:"h-4 w-4"})}):null,e[62]=s,e[63]=Re):Re=e[63];let Oe;e[64]!==ce||e[65]!==le||e[66]!==Re?(Oe=n.jsxs("div",{className:"flex items-center gap-1",children:[ce,le,Re]}),e[64]=ce,e[65]=le,e[66]=Re,e[67]=Oe):Oe=e[67];let Te;e[68]!==we||e[69]!==Oe?(Te=n.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[we,Oe]}),e[68]=we,e[69]=Oe,e[70]=Te):Te=e[70];let De;e[71]===Symbol.for("react.memo_cache_sentinel")?(De={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=De):De=e[71];const te=o==="memory"?"secondary":"ghost";let de;e[72]===Symbol.for("react.memo_cache_sentinel")?(de=()=>i("memory"),e[72]=de):de=e[72];let fe;e[73]!==r?(fe=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=fe):fe=e[74];let ge;e[75]!==te||e[76]!==fe?(ge=n.jsx(ft,{size:"sm",variant:te,className:"flex-1",onClick:de,children:fe}),e[75]=te,e[76]=fe,e[77]=ge):ge=e[77];const B=o==="streaming"?"secondary":"ghost";let Q;e[78]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>i("streaming"),e[78]=Q):Q=e[78];let ke;e[79]!==r?(ke=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ke):ke=e[80];let Ie;e[81]!==B||e[82]!==ke?(Ie=n.jsx(ft,{size:"sm",variant:B,className:"flex-1",onClick:Q,children:ke}),e[81]=B,e[82]=ke,e[83]=Ie):Ie=e[83];const oe=o==="requests"?"secondary":"ghost";let $e;e[84]===Symbol.for("react.memo_cache_sentinel")?($e=()=>i("requests"),e[84]=$e):$e=e[84];let Fe;e[85]!==r?(Fe=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Fe):Fe=e[86];let Ce;e[87]!==oe||e[88]!==Fe?(Ce=n.jsx(ft,{size:"sm",variant:oe,className:"flex-1",onClick:$e,children:Fe}),e[87]=oe,e[88]=Fe,e[89]=Ce):Ce=e[89];let Ue;e[90]!==ge||e[91]!==Ie||e[92]!==Ce?(Ue=n.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:De,children:[ge,Ie,Ce]}),e[90]=ge,e[91]=Ie,e[92]=Ce,e[93]=Ue):Ue=e[93];const pe=o==="memory"?n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[n.jsx(vs,{label:r("memoryDebugPanel.metric.totalMessages"),value:Se.total}),n.jsx(vs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Be} / ${dc.MAX_SESSIONS}`}),n.jsx(vs,{label:r("memoryDebugPanel.metric.userMessages"),value:Se.user}),n.jsx(vs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:Se.assistant})]}),n.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:Lx()})})]}),n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:dc.ZOMBIE_TIMEOUT/1e3/60})})]}),n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),n.jsx("span",{className:"text-[var(--surface-foreground)]",children:h})]})]}),n.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[n.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),n.jsx(Cn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:re.map(Me=>n.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Me.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Me.title}),Me.isStreaming?n.jsx($,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Me.isZombie?n.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Me.assistantMessageCount,user:Me.userMessageCount})}),n.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Me.messageCount})}),Me.backgroundCount>0?n.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Me.backgroundCount]}):null]})]},Me.id))})]}),n.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:n.jsxs(Dt,{children:[n.jsx(Et,{asChild:!0,children:n.jsx(ft,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:f.map(eA),currentSessionId:d,cachedSessions:Object.keys(m),messageRoleCounts:Se,sessionMessageRoleCounts:re.map(tA),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),n.jsx(Pt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):o==="streaming"?n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[n.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),n.jsx(ft,{size:"xs",variant:"outline",onClick:K,children:r("memoryDebugPanel.actions.copyJson")})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(vs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),n.jsx(vs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:w.entries.length}),n.jsx(vs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:N.messageListRender}),n.jsx(vs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:N.messageListRenderStreaming}),n.jsx(vs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:N.chatMessageRender}),n.jsx(vs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:N.chatMessageRenderStreaming}),n.jsx(vs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:N.chatMessageRenderStaticDuringStream}),n.jsx(vs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:N.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),n.jsx($d,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),w.entries.length>0?n.jsx($d,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:w,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[n.jsx(vs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${x.totalSettled} / ${x.totalStarted}`}),n.jsx(vs,{label:r("memoryDebugPanel.requests.tracking"),value:x.startedAt?$p(x.durationMs):r("memoryDebugPanel.common.idle")})]}),x.samples.length===0?n.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:x.inFlight}),n.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),n.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:x.peak})]})]}),n.jsx(Wd,{series:[{samples:x.samples,color:"var(--status-info)",filled:!0}],peak:j,windowSeconds:x.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:x.peak}),maxLabel:`${j}`}),n.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),n.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ia(x.peakAgeMs)})]}),n.jsx(Wd,{series:y.map(sA),peak:C,windowSeconds:x.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ia(C)}),n.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:y.map(nA)}),n.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[n.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:x.windowSeconds})}),n.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let ne;return e[94]!==q||e[95]!==me||e[96]!==Te||e[97]!==Ue||e[98]!==pe?(ne=n.jsxs(q,{className:X,style:me,children:[Te,Ue,pe]}),e[94]=q,e[95]=me,e[96]=Te,e[97]=Ue,e[98]=pe,e[99]=ne):ne=e[99],ne},$N=_N;function WN(t,e){return t+e.count}function KN(t,e){return Math.max(t,e.samples.length)}function zN(t){return t.currentSessionId}function UN(t){return t.sessionMemoryState}function HN(t){return t.message}function VN(t){return t.totalRequestCount}function GN(){return bo()}function qN(){return yo()}function YN(){return Pa()}function QN(t,e){return Math.max(t,e)}function XN(t,e){return Math.max(t,e)}function JN(t,e){return e.samples.reduce(XN,t)}function ZN(t,e){return e.lastAccessed-t.lastAccessed}function eA(t){return{id:t.id,title:t.title}}function tA(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function sA(t){return{samples:t.samples,color:t.color}}function nA(t){return n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),n.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),n.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ia(t.current)})]},t.label)}const rA=()=>{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()??"":""},oA=async()=>{const t=rA()||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")},Kd="openchamber:menu-action",$i="openchamber:check-for-updates",iA=t=>{const e=Ze(x=>x.openNewSessionDraft),s=be(x=>x.toggleCommandPalette),r=be(x=>x.setCommandPaletteOpen),o=be(x=>x.toggleHelpDialog),i=be(x=>x.toggleSidebar),l=be(x=>x.setSessionSwitcherOpen),a=be(x=>x.setSettingsDialogOpen),d=be(x=>x.setAboutDialogOpen),u=Dr(x=>x.checkForUpdates),{setThemeMode:f}=Kr(),m=c.useRef(!1),h=c.useCallback(()=>{m.current||(m.current=!0,u().then(()=>{const{available:x,error:p}=Dr.getState();if(p){Ke.error("Failed to check for updates",{description:p});return}x||Ke.success("You are on the latest version")}).finally(()=>{m.current=!1}))},[u]),b=c.useCallback(()=>{wn.requestDirectoryDialog()},[]),g=c.useCallback(x=>{const p=$x();if(p.length===0)return;const y=Ze.getState().currentSessionId,v=p.findIndex(k=>k.id===y);let j=x>0?0:p.length-1;v>=0&&(j=(v+x+p.length)%p.length);const C=p[j];C&&(l(!1),Ze.getState().setCurrentSession(C.id))},[l]),w=c.useCallback(x=>{const{activeProjectId:p,projects:y,setActiveProject:v}=Xt.getState();if(y.length===0)return;const j=y.findIndex(T=>T.id===p);let C=x>0?0:y.length-1;j>=0&&(C=(j+x+y.length)%y.length);const k=y[C];k&&v(k.id)},[]),S=c.useCallback(x=>{switch(x){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=Ze.getState(),y=Ss.getState().currentDirectory;e(p.currentSessionId&&y?{directoryOverride:y}:void 0)}break;case"new-worktree-session":l(!1),Qu();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const p=Ss.getState().currentDirectory;if(!p)break;const y=be.getState(),v=En(p),j=y.contextPanelByDirectory[v];j?.isOpen?y.closeContextPanel(v):j?.activeTabId?y.setActiveContextPanelTab(v,j.activeTabId):y.openContextSurface(v,"git");break}case"open-right-sidebar-git":{const p=Ss.getState().currentDirectory;if(!p)break;be.getState().openContextSurface(En(p),"git");break}case"open-right-sidebar-files":{const p=Ss.getState().currentDirectory;if(!p)break;be.getState().openContextSurface(En(p),"file");break}case"toggle-terminal":{const p=Ss.getState().currentDirectory;if(!p)break;be.getState().openContextSurface(En(p),"terminal");break}case"toggle-terminal-expanded":{const p=Ss.getState().currentDirectory;if(!p)break;const y=En(p),v=be.getState(),j=v.contextPanelByDirectory[y];(j?.isOpen?j.tabs.find(k=>k.id===j.activeTabId)?.mode:null)!=="terminal"&&v.openContextSurface(y,"terminal"),v.toggleContextPanelExpanded(y);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||oA();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":Wx();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":uc(-1);break;case"go-forward":uc(1);break;case"previous-session":g(-1);break;case"next-session":g(1);break;case"previous-project":w(-1);break;case"next-project":w(1);break;case"help-dialog":o();break;case"download-logs":{Xu().catch(()=>{Ke.error("Failed to collect OpenCode status")});break}}},[b,w,g,t,e,d,l,r,a,f,s,o,i]);c.useEffect(()=>{const x=y=>{const v=y.detail;v&&S(v)},p=()=>{h()};return window.addEventListener(Kd,x),window.addEventListener($i,p),()=>{window.removeEventListener(Kd,x),window.removeEventListener($i,p)}},[S,h]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let y=null,v=null;return p("openchamber:menu-action",j=>{const C=j?.payload;typeof C=="string"&&S(C)}).then(j=>{y=j}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event($i))}).then(j=>{v=j}).catch(()=>{}),()=>{(async()=>{try{const C=y?.();C instanceof Promise&&await C}catch{}try{const C=v?.();C instanceof Promise&&await C}catch{}})()}},[S])},aA="openchamber:tray-action",lA=5e3,cA=500,dA=20,zd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ud=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,Wp=t=>{const e=t.action.trim()||"Permission",s=t.resources.find(r=>r.trim());return s?`${e}: ${s}`:e},Kp=t=>t.title.trim()||"Question",uA=(t,e)=>Va(t,e,br.getState().ids,Ua.getState().rankById),fA=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),s=e.lastIndexOf("/");return s>=0?e.slice(s+1):e},pA=(t,e,s,r,o)=>{if(!t)return"";const i=hu(s,r,t),l=e.project?.name,a=i?.label?.trim()||l?.trim()||fA(t),d=xo(t);let u=d&&o.get(d)||"";if(!u){for(const[f,m]of xn.getState().directories)if(xo(f)===d){u=m.status?.current??"";break}}if(!u)for(const f of r.values()){const m=f.find(h=>xo(h.path)===d);if(m?.branch){u=m.branch;break}}return u?`${a} · ${u}`:a},mA=()=>{const{results:t,dropdownProviderIds:e,displayMode:s}=ar.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,m]of Object.entries(a.usage?.windows??{})){const h=r==="remaining"?m.remainingPercent:m.usedPercent;d.push({label:Hx(f),value:Ux(m.valueLabel,h)})}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}},hA=async()=>{try{if($r())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Co();if(e&&Ml(e,t))return"Local OpenChamber";const r=(await Vo()).hosts.find(o=>e?Ml(e,au(o)):!1);return r?.label?.trim()?Jd(r.label.trim()):"Instance"}catch{return""}},gA=()=>{const t=new Map,e=new Map,s=[],r=new Map;let o;try{o=ea()}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(xo(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,m=f==="busy"?"busy":f==="retry"?"retry":"idle",h=t.get(d);(!h||h==="idle")&&t.set(d,m)}for(const[d,u]of Object.entries(a.permission??{}))for(const f of u??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"permission",id:f.id,sessionId:m,sessionTitle:"",label:Wp(f),directory:i})}for(const[d,u]of Object.entries(a.form??{}))for(const f of u??[]){if(!f?.id)continue;const m=f.sessionID||d;s.push({kind:"form",id:f.id,sessionId:m,sessionTitle:"",label:Kp(f),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:s,titleById:r}},bA=(t,e)=>{const s=xf.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=[],v=[...o.get(p)??[]],j=new Set;for(;v.length;){const C=v.pop();j.has(C)||(j.add(C),y.push(C),v.push(...o.get(C)??[]))}return y},l=be.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((v,j)=>v+(s.unseenCount[j]??0),0)),y>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=gA(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const f=Za.getState().statusById,m=p=>{const y=d.statusById.get(p);return y&&y!=="idle"?y:f.get(p)?.status.type??y??"idle"},h=p=>{const y=p.map(v=>m(v));return y.includes("busy")?"busy":y.includes("retry")?"retry":"idle"},b=Xt.getState().projects,g=Ze.getState().availableWorktreesByProject,w=r.filter(p=>p?.id&&!p.parentID).slice().sort(uA).slice(0,dA).map(p=>{const y=[p.id,...i(p.id)],v=dn(p)??"";return{id:p.id,title:p.title||"Untitled session",status:h(y),branch:v?d.branchByDirectory.get(v)??"":"",unseen:y.reduce((j,C)=>j+(s.unseenCount[C]??0),0),hasError:y.some(j=>s.unseenHasError[j]??!1),directory:v,subtitle:pA(v,p,b,g,d.branchByDirectory)}}),S=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),x=new Set(S.map(p=>p.id));for(const[p,y]of vf.getState().bySession){const v=u.get(p)||"";for(const j of y.permissions)x.has(j.id)||(x.add(j.id),S.push({kind:"permission",id:j.id,sessionId:p,sessionTitle:v,label:Wp(j),directory:y.directory}));for(const j of y.forms)x.has(j.id)||(x.add(j.id),S.push({kind:"form",id:j.id,sessionId:p,sessionTitle:v,label:Kp(j),directory:y.directory}))}return{sessions:w,approvals:S,instanceName:t,usage:mA(),dockBadgeCount:a}},yA=()=>{c.useEffect(()=>{if(!zd()||!Tr())return;const t=Ud();let e=!1,s="",r=null,o="";const i=()=>{if(e)return;const k=bA(o,t),T=JSON.stringify(k);T!==s&&(s=T,On("desktop_tray_update",k))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,i()},cA))},a=xf.subscribe(()=>l()),d=ws.subscribe(()=>l()),u=be.subscribe((k,T)=>{(k.dockBadgeEnabled!==T.dockBadgeEnabled||k.notifyOnSubtasks!==T.notifyOnSubtasks)&&l()}),f=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return i(),f;hA().then(k=>{e||(o=k,i())});const m=new Map,h=()=>{if(e)return;let k;try{k=ea()}catch{return}const T=new Set;for(const[O,M]of k.children.entries())T.add(O),m.has(O)||m.set(O,M.subscribe(()=>l()));for(const[O,M]of m)T.has(O)||(M(),m.delete(O))};let b=null;try{b=ea().subscribeRegistry(()=>{h(),l()})}catch{}h();const g=Xt.subscribe(()=>l()),w=Ze.subscribe(()=>l()),S=xn.subscribe(()=>l()),x=Za.subscribe(()=>l()),p=vf.subscribe(()=>l()),y=Ua.subscribe(()=>l()),v=br.subscribe(()=>l()),j=ar.subscribe(()=>l());ar.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:k,results:T}=ar.getState();k.length>0&&k.some(M=>!T.some(L=>L.providerId===M))&&ar.getState().fetchQuotas(k)});const C=window.setInterval(()=>{h(),i()},lA);return i(),()=>{f(),window.clearInterval(C),g(),w(),S(),x(),p(),y(),v(),j(),b?.();for(const k of m.values())k();m.clear()}},[]),c.useEffect(()=>{if(!zd()||!Ud()||!Tr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const s=o=>{o.type==="respond-permission"&&Kx(o.sessionId,o.id,o.response).catch(()=>{Ke.error("Failed to respond to permission request")})};let r=null;return e(aA,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{}}},[])},xA=30*6e4,vA=(t,e,s=xA)=>{const r=new Map;for(const[o,i]of Object.entries(t.sessions)){if(i.status!=="busy"&&i.status!=="retry"||t.serverTime-i.lastUpdateAt>s||e.isKnown(o))continue;const l=e.resolveDirectory(o);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:o,status:{type:"busy"}}}),r.set(l,a)}return r};let Cr=null;const SA=()=>{if(Cr)return Cr;const t=Jt();return Cr=(async()=>{const e=await Mr.getHostSessionStatusSnapshot();if(!e||Jt()!==t)return;const s=Za.getState(),r=ws.getState().entityById,o=vA(e,{isKnown:l=>s.statusById.has(l)||s.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?dn(a):null}});for(const[l,a]of o)Vx(l,a);const i=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?dn(d):null;u&&i.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Gx(i)})().finally(()=>{Cr=null}),Cr},wA=45e3,jA=[1e3,2e3,4e3],kA=(t,e,s=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let o=!1,i,l=0,a=!1;const d=async u=>{const f=await u().catch(()=>!1);if(o)return;a||=f;const m=a?void 0:jA[l];m!==void 0&&(l+=1),i=s(()=>{i=void 0,d(e)},m??wA)};return d(t),()=>{o=!0,i!==void 0&&r(i)}},CA=t=>{const e=Ve.c(3);let s,r;e[0]!==t?(s=()=>{const o=NA;let i=o();const l=Wr(()=>{i(),i=o()});return()=>{l(),i()}},r=[t],e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]),c.useEffect(s,r)};function NA(){const t=Jt();let e=!0;const s=async o=>(o?await qx(Ro()):await Ja(),!e||Jt()!==t?!1:(SA(),ws.getState().status==="ready")),r=kA(()=>s(!0),()=>s(!1));return()=>{e=!1,r()}}const AA=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,PA=(t,e,s,r)=>r||[t,e,s].filter(Boolean).join("|")||void 0,IA=t=>{t.kind!=="plugin"||!t.title||Ke.info(t.title,{id:PA(t.kind,t.title,t.body,t.tag),description:t.body})},DA=(t,e)=>t.kind==="plugin"&&e&&t.showWhenFocused===!0,EA=t=>{const e=Ve.c(3),s=!0;let r,o;e[0]!==s?(r=()=>{if(!(cn()||!Ea()||!globalThis.window))return _n(RA)},o=[s],e[0]=s,e[1]=r,e[2]=o):(r=e[1],o=e[2]),c.useEffect(r,o)};function RA(t){if(t.type!=="notification")return;const e=be.getState();if(!e.nativeNotificationsEnabled)return;const s=AA();if(DA(t.payload,s)){IA(t.payload);return}if(e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&s)return;Xd()?.notifications?.notifyAgentCompletion(t.payload)}const TA=6e4,MA=t=>{const e=Ve.c(10),s=be(OA),r=Yx(BA),i=Bg(t)?.path??null;let l,a;e[0]!==s||e[1]!==r||e[2]!==i?(l=()=>{s&&r(i,{maxAgeMs:TA})},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 _n(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 OA(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function BA(t){return t.load}const FA=()=>{const t=Ve.c(4),{t:e}=mt(),s=be(LA);let r,o;t[0]!==s||t[1]!==e?(r=()=>_n(i=>{i.type==="browser-provider-reset"&&(s("builtin"),Ke.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 LA(t){return t.setBrowserProvider}const Hd=()=>{Jm()||(Fg(),Qx(Lg.map(t=>t.id)))},_A=(t,e)=>{const s=Ve.c(5);let r;s[0]!==t?(r=()=>{if(!t)return;if("requestIdleCallback"in window){const l=window.requestIdleCallback(Hd,{timeout:1e4});return()=>window.cancelIdleCallback(l)}const i=setTimeout(Hd,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)},Vd="pwa-install-toast-shown",Gd="pwa-install-toast-dismissed",$A=()=>{const t=Ve.c(6),{browserTab:e}=_g(),{t:s}=mt(),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"||!Ea()||!e)return;let d=null,u=null;const f=()=>{u!==null&&(Ke.dismiss(u),u=null)},m=async()=>{if(!d)return;const g=d;d=null,f(),await g.prompt();const{outcome:w}=await g.userChoice;w==="accepted"&&Ke.success(r.current("pwa.installPrompt.started"))},h=g=>{const w=g;if(typeof w.prompt!="function")return;w.preventDefault(),d=w;const S=Ao(),x=Zm();$g({dismissed:S.getItem(Gd),sessionShown:x.getItem(Vd),hasActiveToast:u!==null})&&(x.setItem(Vd,"true"),u=Ke.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{m()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Ao().setItem(Gd,"true"),f()}}}))},b=()=>{d=null,f(),Ke.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",h),window.addEventListener("appinstalled",b),()=>{f(),window.removeEventListener("beforeinstallprompt",h),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},WA=t=>t==="invalid-connect-link"?"invalid-link":t==="pairing-redeem-failed"?"unreachable":"failed",zp=async(t,e)=>{const s=(await Vo()).hosts.find(o=>o.id===t);if(!s)throw new Error("host-not-found");if(s.relay){await nh(s.id,e);return}const r=rh(au(s));if(!r)throw new Error("host-not-found");oh({apiBaseUrl:r,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:ih(s)})},KA=async t=>{const e=await Vo(),s=await th(t,e.hosts);await sh({hosts:s.hosts,defaultHostId:e.defaultHostId||s.hostId,initialHostChoiceCompleted:!0}),await zp(s.hostId,{reconnectActive:!0})},zA=async t=>{const e=await eh();for(const s of e)try{s.type==="pairing"?await KA(s.link):await zp(s.hostId)}catch(r){const o=r instanceof Error?r.message:String(r);console.warn("[desktop] host action failed",s.type,o),t(WA(o))}},qd="\0",UA=({open:t,onOpenChange:e})=>{const{t:s}=mt(),r=!1,[o,i]=c.useState(void 0),[l,a]=c.useState(void 0),[d,u]=c.useState(!1),[f,m]=c.useState(!1),[h,b]=c.useState(null),[g,w]=c.useState(!1);c.useCallback(async()=>{},[h,d,r,s]),c.useEffect(()=>{if(!t)return;let x=!1;return(async()=>{try{const v=await Fs("/api/system/info");if(v.ok){const j=await v.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){x||i(j.openchamberVersion);return}}}catch{}const y=await Xx().catch(()=>null);x||i(y)})(),()=>{x=!0}},[t]),c.useEffect(()=>{if(!t)return;let x=!1;return(async()=>{let y="";try{const v=await Fs("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(v.ok){const j=await v.json().catch(()=>null);y=typeof j?.currentVersion=="string"?j.currentVersion.trim():""}}catch{}x||a(y||null)})(),()=>{x=!0}},[t]),c.useEffect(()=>{{b(null),w(!1);return}},[t,r]);const S=(x,p)=>{if(p!==void 0)return n.jsx("p",{children:s(x,{version:p??s("settings.openchamber.about.state.unknown")})});const[y,v=""]=s(x,{version:qd}).split(qd);return n.jsxs("p",{className:"flex items-center justify-center",children:[n.jsx("span",{className:"whitespace-pre",children:y}),n.jsx($,{name:"loader",className:"size-3.5 animate-spin"}),n.jsx("span",{className:"whitespace-pre",children:v})]})};return n.jsx(_s,{open:t,onOpenChange:e,children:n.jsx(Ls,{className:"max-w-xs p-6",children:n.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[n.jsx(Vu,{width:64,height:64}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),n.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[S("aboutDialog.openChamberVersionLabel",o),S("aboutDialog.openCodeVersionLabel",l)]})]}),r,n.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[n.jsx($,{name:"github-fill",className:"h-4 w-4"}),n.jsx("span",{children:"GitHub"})]}),n.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[n.jsx($,{name:"discord-fill",className:"h-4 w-4"}),n.jsx("span",{children:"Discord"})]})]}),n.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[n.jsx($,{name:"twitter-xfill",className:"h-4 w-4"}),n.jsx("span",{children:"@openchamber_dev"})]})]}),n.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:s("aboutDialog.footerNote")})]})})})},Da="project-config-invalid",HA=()=>{const t=Ve.c(9),{t:e}=mt(),s=ps(VA);let r;t[0]!==s?(r=h=>h.projectConfigErrors[s],t[0]=s,t[1]=r):r=t[1];const o=ps(r),[i,l]=us.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const h=ps.getState(),b=h.activeDirectoryKey;l(!0),Promise.all([h.loadProviders({directory:b,source:"projectConfigError:retry"}),h.loadAgents({directory:b,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){Ke.dismiss(Da);return}Ke.error(e("projectConfigError.toast.title"),{id:Da,duration:1/0,description:n.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[n.jsx("span",{className:"break-all font-mono typography-meta",children:o.path??e("projectConfigError.toast.unknownFile")}),o.message&&n.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:o.message}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(i?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:h=>{h.preventDefault(),i||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]),us.useEffect(u,f);let m;return t[8]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[8]=m):m=t[8],us.useEffect(qA,m),null};function VA(t){return t.activeDirectoryKey}function GA(){Ke.dismiss(Da)}function qA(){return GA}const YA="\x1B",QA=new RegExp(`${YA}\\[[0-9;?]*[ -/]*[@-~]`,"g"),go=jn().transform(t=>t.replace(QA,"").trim()).nullish(),XA=ra({isOpenCodeReady:hc().optional(),openCodeRunning:hc().optional(),lastOpenCodeError:go,opencodeBinaryResolved:go,lastOpenCodeLaunchDiagnostics:ra({sourceBinary:go,binary:go}).nullish()}),JA=async(t,e=Fs)=>{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=XA.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}},ZA=(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"}},eP=ra({openchamberVersion:jn()}),tP=async(t,e=Fs)=>{const s=await e("/api/version",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!s.ok)return null;const r=eP.safeParse(await s.json().catch(()=>null));return r.success&&r.data.openchamberVersion.trim()||null},sP=t=>{const e=/^(\d+)\./.exec(t)?.[1];return e!==void 0&&Number(e)<2};function nP({version:t}){const{t:e}=mt(),[s,r]=c.useState({kind:"idle"}),o=async()=>{r({kind:"checking"});try{const a=await Wg();r(a.available&&a.installBlocked!=="service-manager"?{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(ft,{type:"button",onClick:()=>{o()},disabled:s.kind==="checking",children:[n.jsx($,{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-left",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(Oa,{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 Yd=Sr(()=>kn(()=>import("./OnboardingScreen-DMIxwYK5.js"),__vite__mapDeps([151,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),rP=()=>{const t=Ve.c(3),e=be(lP),s=be(cP);let r;return t[0]!==e||t[1]!==s?(r=n.jsx(UA,{open:e,onOpenChange:s}),t[0]=e,t[1]=s,t[2]=r):r=t[2],r},oP=t=>{const e=Ve.c(47),{onRetry:s,isRetrying:r}=t,{t:o}=mt(),[i,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const O=new AbortController,M=Jt(),L=setTimeout(()=>O.abort(),5e3);return JA(O.signal).then(F=>{!O.signal.aborted&&Jt()===M&&l(F)}).catch(dP).finally(()=>clearTimeout(L)),()=>{O.abort(),clearTimeout(L)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const[u,f]=c.useState(null);let m,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const O=new AbortController,M=Jt(),L=setTimeout(()=>O.abort(),5e3);return tP(O.signal).then(F=>{O.signal.aborted||Jt()!==M||f(F&&sP(F)?F:null)}).catch(uP).finally(()=>clearTimeout(L)),()=>{O.abort(),clearTimeout(L)}},h=[],e[2]=m,e[3]=h):(m=e[2],h=e[3]),c.useEffect(m,h);const b=ps(fP),g=i?null:b?.message??null;if(u){let O;e[4]!==u?(O=n.jsx(nP,{version:u}),e[4]=u,e[5]=O):O=e[5];let M;e[6]!==r||e[7]!==o?(M=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[6]=r,e[7]=o,e[8]=M):M=e[8];let L;e[9]!==r||e[10]!==s||e[11]!==M?(L=n.jsx(ft,{type:"button",variant:"outline",onClick:s,disabled:r,children:M}),e[9]=r,e[10]=s,e[11]=M,e[12]=L):L=e[12];let F;return e[13]!==O||e[14]!==L?(F=n.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:n.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[O,L]})}),e[13]=O,e[14]=L,e[15]=F):F=e[15],F}let w;e[16]!==o?(w=o("startup.initRecovery.title"),e[16]=o,e[17]=w):w=e[17];let S;e[18]!==w?(S=n.jsx("h1",{className:"typography-title text-foreground",children:w}),e[18]=w,e[19]=S):S=e[19];let x;e[20]!==i||e[21]!==b||e[22]!==o?(x=o(ZA(i,b)),e[20]=i,e[21]=b,e[22]=o,e[23]=x):x=e[23];let p;e[24]!==x?(p=n.jsx("p",{className:"typography-body text-muted-foreground",children:x}),e[24]=x,e[25]=p):p=e[25];let y;e[26]!==S||e[27]!==p?(y=n.jsxs("div",{className:"flex flex-col gap-2",children:[S,p]}),e[26]=S,e[27]=p,e[28]=y):y=e[28];let v;e[29]!==g||e[30]!==o?(v=g&&n.jsxs("dl",{className:"w-full min-w-0 text-left","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:g})]}),e[29]=g,e[30]=o,e[31]=v):v=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-left","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 C;e[35]!==r||e[36]!==o?(C=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[35]=r,e[36]=o,e[37]=C):C=e[37];let k;e[38]!==r||e[39]!==s||e[40]!==C?(k=n.jsx(ft,{type:"button",onClick:s,disabled:r,children:C}),e[38]=r,e[39]=s,e[40]=C,e[41]=k):k=e[41];let T;return e[42]!==v||e[43]!==j||e[44]!==k||e[45]!==y?(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:[y,v,j,k]})}),e[42]=v,e[43]=j,e[44]=k,e[45]=y,e[46]=T):T=e[46],T};function iP({apis:t}){c.useEffect(()=>{ah("App:mounted"),lh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ps(K=>K.initializeApp),s=ps(K=>K.isInitialized),r=ps(K=>K.isConnected),o=ps(K=>K.providers.length),i=ps(K=>K.agents.length),l=ps(K=>K.loadProviders),a=ps(K=>K.loadAgents),d=Ze(K=>K.error),u=Ze(K=>K.clearError),f=Ss(K=>K.currentDirectory),m=Ss(K=>K.isSwitchingDirectory),[h,b]=c.useState(!1),g=Bn(K=>K.refreshAll),w=Jx(K=>K.refreshStatus),[S,x]=c.useState(()=>t.runtime.isVSCode),[p,y]=c.useState(!1),[v,j]=c.useState(0),[C,k]=c.useState(0),[T,O]=c.useState(!1),M=be(K=>K.wideChatLayoutEnabled),L=be(K=>K.mobileKeyboardMode),F=c.useMemo(()=>cn(),[]),D=La(K=>K.setPlanModeEnabled),[U,N]=c.useState(()=>Ol()),[A,H]=c.useState(()=>{const K=yi();return K!==null?Bl({isDesktopShell:!0,bootOutcome:K}):null}),I=c.useRef(!1),{t:R}=mt(),P=c.useRef(!1);c.useEffect(()=>{if(!s||U!=="valid"||P.current)return;const K=yi();K?.target!=="local"||K.status!=="ok"||!K.sshStartupFallbackHostId||(P.current=!0,Ke.error(R("desktopHostSwitcher.startup.title"),{description:R("desktopHostSwitcher.startup.fellBackToLocal")}))},[U,s,R]),c.useEffect(()=>(Fl(h),Ld(h),()=>{Fl(!1),Ld(!1)}),[h]),c.useEffect(()=>{ch(L)},[L]),c.useEffect(()=>{x(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Wr(K=>{zg(K)&&Ug(K),k(q=>q+1),y(!1),j(q=>q+1)}),[]);const _=fc(K=>{const q=Jt();return Object.values(K.runsByOriginalSessionID).filter(X=>X.status==="running"&&X.runtimeKey===q).map(X=>`${X.originalSessionID}:${X.phase}:${X.lastForwardedMessageID??""}:${X.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{const K=Jt(),q=Object.values(fc.getState().runsByOriginalSessionID).filter(X=>X.status==="running"&&X.runtimeKey===K);for(const X of q)Zx(X.originalSessionID)},[_,C]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",M),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[M]),c.useEffect(()=>(Ll(t),()=>Ll(null)),[t]),c.useEffect(()=>{r&&(g(t.sourceControl,{force:!0}),w(t.linear,{force:!0}))},[t.sourceControl,t.linear,r,g,w,C]),e1();const G=U==="valid",ae=A?.screen==="main";c.useEffect(()=>{if(!dh({isDesktopShell:F,isInitialized:s,bootOutcomeKnown:G,bootViewIsMain:ae}))return;const K=setTimeout(()=>{const q=document.getElementById("initial-loading");q&&(q.classList.add("fade-out"),setTimeout(()=>{q.remove()},300))},150);return()=>clearTimeout(K)},[F,s,G,ae]),c.useEffect(()=>{if(!F||U!=="malformed")return;const K=document.getElementById("initial-loading");K&&(K.textContent="Desktop startup failed — please restart the app.")},[F,U]),c.useEffect(()=>{if(F)return;const K=setTimeout(()=>{const q=document.getElementById("initial-loading");q&&!s&&(q.classList.add("fade-out"),setTimeout(()=>{q.remove()},300))},5e3);return()=>clearTimeout(K)},[F,s]),c.useEffect(()=>{let K=!1;return(async()=>{const X=await Fs("/health",{method:"GET"}).catch(()=>null);if(!X||!X.ok||K)return;const me=await X.json().catch(()=>null);if(!me||K)return;const he=me.planModeExperimentalEnabled;D(he===!0||he===1||he==="1"||he==="true")})(),()=>{K=!0}},[D]),c.useEffect(()=>{S||e()},[e,S]),c.useEffect(()=>{if(S||s)return;let K=!0,q,X=0;const me=10,he=1e3,je=async()=>{if(!K)return;if(X>=me){y(!0);return}const Y=ps.getState();if(Y.isInitialized){y(!1);return}X+=1,await Y.initializeApp();const ue=ps.getState();if(!K)return;if(ue.isInitialized){y(!1);return}if(X>=me){y(!0);return}const we=Math.min(he*Math.pow(2,X-1),16e3);q=setTimeout(je,we)};return q=setTimeout(je,he),()=>{K=!1,q&&clearTimeout(q)}},[v,s,S]),c.useEffect(()=>{s&&y(!1)},[s]),c.useEffect(()=>{if(!p)return;const K=document.getElementById("initial-loading");K&&(K.classList.add("fade-out"),setTimeout(()=>{K.remove()},300))},[p]),c.useEffect(()=>{if(S||!r||o>0&&i>0)return;let K=!0,q=0;const X=15,me=async()=>{const je=ps.getState();if(!(je.providers.length>0&&je.agents.length>0))try{je.providers.length===0&&await l({source:"startupRecovery"}),ps.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};me();const he=setInterval(()=>{if(K){if(++q>=X){clearInterval(he);return}me()}},2e3);return()=>{K=!1,clearInterval(he)}},[r,S,a,l,o,i]),c.useEffect(()=>{m||S||r&&Mr.setDirectory(f)},[f,m,r,S]),c.useEffect(()=>{if(typeof window>"u")return;const K=q=>{const X=q.detail,me=typeof X?.sessionId=="string"?X.sessionId.trim():"";if(!me)return;const he=typeof X?.directory=="string"&&X.directory.trim().length>0?X.directory.trim():null,je=String(X?.runtimeKey??"").trim();if(!(je&&je!==Jt()&&mh(je,me))){if(!he){Xi(me,typeof X?.messageId=="string"?X.messageId.trim():null);return}Ze.getState().setCurrentSession(me,he)}};return window.addEventListener("openchamber:open-session",K),uh().then(q=>{for(const X of q)Xi(X.sessionId,X.messageId)}),()=>window.removeEventListener("openchamber:open-session",K)},[]),c.useEffect(()=>{if(!cn())return;const K=()=>{zA(q=>{Ke.error(R(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",K),K(),()=>window.removeEventListener("openchamber:host-actions-ready",K)},[R]);const Se=c.useRef(!1);c.useEffect(()=>{!s||Se.current||(Se.current=!0,Hg({refresh:!1}))},[s]),c.useEffect(()=>{if(typeof window>"u")return;const K=()=>{On("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",K),()=>window.removeEventListener("openchamber:open-mini-chat",K)},[]),c.useEffect(()=>{if(typeof window>"u")return;const K=()=>{const q=Ze.getState().currentSessionId;q&&qu(q)};return window.addEventListener("focus",K),()=>window.removeEventListener("focus",K)},[]),c.useEffect(()=>{if(typeof window>"u")return;const K=q=>{const X=q.detail,me=typeof X?.directory=="string"&&X.directory.trim().length>0?X.directory.trim():null,he=typeof X?.projectId=="string"&&X.projectId.trim().length>0?X.projectId.trim():null,je=!!(me||he);be.getState().setSessionSwitcherOpen(!1),Ze.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?he:null,directoryOverride:je?me:null,preserveDirectoryOverride:!!me})};return window.addEventListener("openchamber:open-draft-session",K),()=>window.removeEventListener("openchamber:open-draft-session",K)},[]),c.useEffect(()=>{typeof window>"u"||!s||m||I.current||(I.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[s,m]),t1(),EA(),MA(f||null),FA(),s1(),Vg(),_A(s&&r,C),$A(),n1(),j1(),Gg();const J=c.useCallback(()=>{b(K=>!K)},[]);iA(J),yA(),CA(!0),c.useEffect(()=>{const K=()=>b(q=>!q);return window.addEventListener("openchamber:memory-debug-toggle",K),()=>window.removeEventListener("openchamber:memory-debug-toggle",K)},[]),c.useEffect(()=>{d&&setTimeout(()=>u(),5e3)},[u,d]),c.useEffect(()=>{if(!F||U!=="not-injected")return;let K=!1,q=0;const X=200,me=2e3,he=50,je=()=>{if(K)return;q++;const Y=Ol();if(Y!=="not-injected"){if(K=!0,N(Y),Y==="valid"){const we=yi();we&&H(Bl({isDesktopShell:!0,bootOutcome:we}))}return}const ue=Math.min(X*Math.pow(1.1,q),me);if(q>=he){const we=document.getElementById("initial-loading");we&&!we.textContent?.includes("taking longer")&&(we.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,ue)};return window.setTimeout(je,X),()=>{K=!0}},[F,U]);const re=c.useCallback(async()=>{if(fh({isDesktopShell:cn(),isDesktopLocalOriginActive:$r()})){await ph();return}window.location.reload()},[]),ie=c.useCallback(async()=>{if(!T){y(!1),O(!0);try{await ps.getState().initializeApp()}finally{O(!1)}ps.getState().isInitialized||j(K=>K+1)}},[T]),Be=K=>{if(K.screen==="recovery")return K.variant};if(F&&A&&A.screen!=="main"){if(A.screen==="chooser")return n.jsx(Ts,{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(Yd,{mode:"first-launch",localAvailable:A.localAvailable!==!1,onCliAvailable:re,onChooseRemote:()=>{}})})})});const K=Be(A),q=A.screen==="recovery"&&"url"in A?A.url:void 0,X=A.screen==="recovery"&&"hostId"in A?A.hostId:void 0;return n.jsx(Ts,{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(Yd,{mode:"recovery",recoveryVariant:K,recoveryHostUrl:q,recoveryHostLabel:void 0,recoveryHostId:X,localAvailable:A.localAvailable!==!1,onCliAvailable:re})})})})}if(p&&!s&&!S)return n.jsx(Ts,{children:n.jsx(oP,{onRetry:()=>{ie()},isRetrying:T},C)});const Ae=!s&&!F;return n.jsx(Ts,{children:n.jsx(r1,{sdk:Mr.getSdkClient(),directory:f||"",children:n.jsx(o1,{apis:t,children:n.jsx(PN,{children:n.jsx(Qo,{delayDuration:300,skipDelayDuration:150,children:n.jsxs("div",{className:F?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[n.jsx(i1,{backgroundWorkEnabled:!0}),n.jsx(qg,{}),n.jsx(HA,{}),n.jsx(sN,{}),n.jsx(Yg,{ready:s&&(!F||G&&ae)}),n.jsx(a1,{}),n.jsx(l1,{}),n.jsx(c1,{}),!Ae&&n.jsxs(n.Fragment,{children:[n.jsx(Qg,{}),n.jsx(rP,{}),h&&n.jsx($N,{onClose:()=>b(!1)})]})]})})})})},C)})}function aP(t){const e=Ve.c(2);let s;return e[0]!==t?(s=n.jsx(Kg,{children:n.jsx(iP,{...t})}),e[0]=t,e[1]=s):s=e[1],s}function lP(t){return t.isAboutDialogOpen}function cP(t){return t.setAboutDialogOpen}function dP(){}function uP(){}function fP(t){return t.lastInitFailure}const pP=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();hh();Xg();gh().then(()=>{Promise.all([bh(),d1()]).catch(t=>{console.error("[main] settings init failed:",t)}),u1(),f1(),p1()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Up=document.getElementById("root");if(!Up)throw new Error("Root element not found");m1();wm.createRoot(Up).render(n.jsx(us.StrictMode,{children:n.jsx(h1,{children:n.jsx(g1,{children:n.jsx(b1,{children:n.jsx(y1,{children:n.jsx(aP,{apis:pP})})})})})}));const RP=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{kS as W,EP as a,_f as g,RP as m,xS as u,Lf as v};