@vantran-se/openchamber-web 2.0.3 → 2.0.5

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 (265) hide show
  1. package/README.md +20 -28
  2. package/bin/cli.js +3 -1
  3. package/bin/cli.test.js +13 -4
  4. package/bin/lib/DOCUMENTATION.md +4 -1
  5. package/bin/lib/commands-serve.js +9 -0
  6. package/dist/assets/{CodeMirrorCommentWidgets-CWhdh0wf.js → CodeMirrorCommentWidgets-DCAQTLMM.js} +1 -1
  7. package/dist/assets/DiffView-uzNpHBlV.js +4 -0
  8. package/dist/assets/FilesView-Bkq0sjNx.js +17 -0
  9. package/dist/assets/{GitView-DKIjpnu4.js → GitView-BmibZC7n.js} +4 -4
  10. package/dist/assets/{GuestAttachDialog-BIa9jCfL.js → GuestAttachDialog-D7TJG1rt.js} +1 -1
  11. package/dist/assets/GuestSurfacePane-PAcYaFzP.js +1 -0
  12. package/dist/assets/{JsonTreeView-CtI1Mqwo.js → JsonTreeView-BNT2yUVu.js} +1 -1
  13. package/dist/assets/{LinearIssuesView-BD2zLu-r.js → LinearIssuesView-D3Azksju.js} +1 -1
  14. package/dist/assets/MarkdownImageGallery-BGY6tuiK.js +1 -0
  15. package/dist/assets/MarkdownRendererImpl-DJmhQ37f.js +12 -0
  16. package/dist/assets/{OnboardingScreen-B8TxloXZ.js → OnboardingScreen-D_41H2qC.js} +1 -1
  17. package/dist/assets/{PatchDiff--Civs1xY.js → PatchDiff-C0RSqa9W.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-BlDmw3-A.js → PierreDiffViewer-BBE7tTY2.js} +3 -3
  19. package/dist/assets/{PlanView-DyH2SyCP.js → PlanView-Bqc-xuDe.js} +4 -4
  20. package/dist/assets/PluginPane-DQ0k41Q-.js +3 -0
  21. package/dist/assets/SettingsView-BAiJU5hJ.js +30 -0
  22. package/dist/assets/{SettingsWindow-y9WpZqK6.js → SettingsWindow-DuC4ecLw.js} +1 -1
  23. package/dist/assets/{SubmoduleDiffSummary-DeFmhPFZ.js → SubmoduleDiffSummary-0HgmcMXz.js} +1 -1
  24. package/dist/assets/{ToolOutputDialog-8DmF7_PZ.js → ToolOutputDialog-DdHkQJEE.js} +6 -6
  25. package/dist/assets/{ToolPartDiffPreview-Ca15DKE1.js → ToolPartDiffPreview-DWdN0r5K.js} +2 -2
  26. package/dist/assets/{VirtualizedFileDiff-BfEBad09.js → VirtualizedFileDiff-ClDezf2d.js} +1 -1
  27. package/dist/assets/{WalkthroughView-Cj3K8Xz6.js → WalkthroughView-BJicp0RC.js} +2 -2
  28. package/dist/assets/{appThemeRegistry-DAdawJZn.js → appThemeRegistry-CiuyzfSW.js} +1 -1
  29. package/dist/assets/changesTree-CePHbFcj.js +1 -0
  30. package/dist/assets/commitAndPush-DTKb6IwT.js +1 -0
  31. package/dist/assets/{computeVirtualFileMetrics-RF-KjfUH.js → computeVirtualFileMetrics-kM_zJNMt.js} +2 -2
  32. package/dist/assets/de-BMnfXm-G.js +10 -0
  33. package/dist/assets/es-DKEvCCL6.js +16 -0
  34. package/dist/assets/fr-D9fgE2xE.js +14 -0
  35. package/dist/assets/index-DUke1nme.css +1 -0
  36. package/dist/assets/{index-CL7ZQ94-.js → index-DWB8bR_g.js} +1 -1
  37. package/dist/assets/index-Di6zUe5h.js +41 -0
  38. package/dist/assets/{isDiffPlainText-D2yJ9fO6.js → isDiffPlainText-DOoIsGqs.js} +1 -1
  39. package/dist/assets/{isFilePlainText-BwMEq1Ey.js → isFilePlainText-bt5VHvcd.js} +1 -1
  40. package/dist/assets/ja-BEXad-KW.js +16 -0
  41. package/dist/assets/ko-DGrQ0lEe.js +16 -0
  42. package/dist/assets/{main-quLSA7jc.js → main-BpLQbZC2.js} +2 -2
  43. package/dist/assets/main-CI9DtHJv.js +896 -0
  44. package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
  45. package/dist/assets/markdownCore-DK2KK5RW.js +7 -0
  46. package/dist/assets/{miniChat-D-lJJibr.js → miniChat-CIWaR8wG.js} +2 -2
  47. package/dist/assets/{mobile-VTtphbW6.js → mobile-CnWKEYIP.js} +2 -2
  48. package/dist/assets/patchFileDiff-Cqn0C0az.js +13 -0
  49. package/dist/assets/pl-BlhkmR5b.js +16 -0
  50. package/dist/assets/pt-BR-Bs96Ew9I.js +16 -0
  51. package/dist/assets/{renderElectronMiniChatApp-DF7ch5eM.js → renderElectronMiniChatApp-D9t0-9nV.js} +2 -2
  52. package/dist/assets/renderMobileApp-CW7fVs_s.js +25 -0
  53. package/dist/assets/runtimeEndpointReset-D0PcCb3K.js +27 -0
  54. package/dist/assets/scheduledTasksApi-Dahv3ws0.js +1 -0
  55. package/dist/assets/{shikiHighlight-_HeCCHx1.js → shikiHighlight-l-MbaNS4.js} +1 -1
  56. package/dist/assets/{textMateThemeFromAppTheme-C95XdFGj.js → textMateThemeFromAppTheme-C-kGcOpD.js} +1 -1
  57. package/dist/assets/tr-CehUK1M9.js +7 -0
  58. package/dist/assets/uk-Bno5WGNz.js +16 -0
  59. package/dist/assets/{useAppFontEffects-ZM9ij19-.js → useAppFontEffects-DDjuwVqi.js} +160 -156
  60. package/dist/assets/{useInlineCommentController-CkfxMJPy.js → useInlineCommentController-Clg8EO3A.js} +2 -2
  61. package/dist/assets/{useRootScrollLock-BtiAC1fj.js → useRootScrollLock-nDcRrgJ1.js} +2 -2
  62. package/dist/assets/{vendor-codemirror-language-data-U-lXzXNK.js → vendor-codemirror-language-data-oKF0MAwd.js} +2 -2
  63. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
  64. package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
  65. package/dist/assets/{web-components-C583Pmfm.js → web-components-Bc1WPd4i.js} +1 -1
  66. package/dist/assets/zh-CN-DnAweIWo.js +16 -0
  67. package/dist/assets/zh-TW-BbBBK25p.js +16 -0
  68. package/dist/index.html +5 -5
  69. package/dist/mini-chat.html +5 -5
  70. package/dist/mobile.html +5 -5
  71. package/package.json +3 -3
  72. package/server/index.d.ts +2 -0
  73. package/server/index.js +196 -52
  74. package/server/lib/agent-tool/DOCUMENTATION.md +5 -0
  75. package/server/lib/agent-tool/runtime.js +89 -51
  76. package/server/lib/agent-tool/runtime.test.js +17 -0
  77. package/server/lib/browser-control/DOCUMENTATION.md +14 -2
  78. package/server/lib/event-stream/DOCUMENTATION.md +2 -2
  79. package/server/lib/event-stream/global-hub.js +45 -7
  80. package/server/lib/event-stream/global-hub.test.js +128 -2
  81. package/server/lib/event-stream/global-ws-bridge.js +3 -1
  82. package/server/lib/event-stream/rebind.test.js +1 -0
  83. package/server/lib/event-stream/runtime.js +1 -2
  84. package/server/lib/event-stream/upstream-reader.js +3 -2
  85. package/server/lib/git/DOCUMENTATION.md +1 -1
  86. package/server/lib/git/service.js +22 -0
  87. package/server/lib/git/service.test.js +8 -0
  88. package/server/lib/guests/DOCUMENTATION.md +4 -3
  89. package/server/lib/guests/catalog.js +19 -1
  90. package/server/lib/guests/catalog.test.js +22 -0
  91. package/server/lib/guests/html-styles.js +5 -3
  92. package/server/lib/guests/html-styles.test.js +3 -1
  93. package/server/lib/guests/routes.js +11 -3
  94. package/server/lib/guests/service.js +5 -0
  95. package/server/lib/guests/surface.js +55 -9
  96. package/server/lib/guests/surface.test.js +56 -6
  97. package/server/lib/notifications/DOCUMENTATION.md +10 -0
  98. package/server/lib/notifications/emit-route.js +118 -0
  99. package/server/lib/notifications/emit-route.test.js +112 -0
  100. package/server/lib/openchamber-control/actions.js +16 -2
  101. package/server/lib/openchamber-control/service.js +23 -0
  102. package/server/lib/openchamber-control/service.test.js +31 -0
  103. package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
  104. package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
  105. package/server/lib/openchamber-sessions/routes.js +11 -0
  106. package/server/lib/openchamber-sessions/routes.test.js +18 -0
  107. package/server/lib/opencode/DOCUMENTATION.md +23 -23
  108. package/server/lib/opencode/bootstrap-runtime.js +14 -1
  109. package/server/lib/opencode/compatibility.js +6 -3
  110. package/server/lib/opencode/compatibility.test.js +8 -0
  111. package/server/lib/opencode/config-entity-v2.test.js +27 -0
  112. package/server/lib/opencode/config-paths.test.js +12 -0
  113. package/server/lib/opencode/config-v2.d.ts +2 -0
  114. package/server/lib/opencode/config-v2.js +42 -0
  115. package/server/lib/opencode/config-v2.test.js +17 -0
  116. package/server/lib/opencode/core-routes.js +20 -4
  117. package/server/lib/opencode/core-routes.test.js +41 -0
  118. package/server/lib/opencode/env-runtime.js +1 -8
  119. package/server/lib/opencode/feature-routes-runtime.js +2 -1
  120. package/server/lib/opencode/lifecycle.js +156 -2
  121. package/server/lib/opencode/lifecycle.test.js +255 -1
  122. package/server/lib/opencode/managed-config-file.js +18 -6
  123. package/server/lib/opencode/managed-config-file.test.js +23 -7
  124. package/server/lib/opencode/mcp.js +7 -2
  125. package/server/lib/opencode/network-runtime.js +16 -7
  126. package/server/lib/opencode/network-runtime.test.js +29 -1
  127. package/server/lib/opencode/npm-registry-config.d.ts +1 -0
  128. package/server/lib/opencode/npm-registry-config.js +123 -0
  129. package/server/lib/opencode/npm-registry-config.test.js +167 -0
  130. package/server/lib/opencode/npm-registry.js +5 -6
  131. package/server/lib/opencode/npm-registry.test.js +30 -0
  132. package/server/lib/opencode/openchamber-routes.js +29 -11
  133. package/server/lib/opencode/openchamber-routes.test.js +18 -0
  134. package/server/lib/opencode/project-directory-runtime.js +8 -0
  135. package/server/lib/opencode/project-directory-runtime.test.js +13 -0
  136. package/server/lib/opencode/provider-source-route.test.js +59 -0
  137. package/server/lib/opencode/providers.js +3 -0
  138. package/server/lib/opencode/providers.test.js +62 -0
  139. package/server/lib/opencode/proxy.js +53 -16
  140. package/server/lib/opencode/routes-upgrade.test.js +1 -1
  141. package/server/lib/opencode/routes.js +36 -1
  142. package/server/lib/opencode/server-startup-runtime.js +25 -0
  143. package/server/lib/opencode/server-startup-runtime.test.js +67 -1
  144. package/server/lib/opencode/server-utils-runtime.js +5 -0
  145. package/server/lib/opencode/settings-helpers.js +10 -0
  146. package/server/lib/opencode/settings-helpers.test.js +2 -2
  147. package/server/lib/opencode/settings-registry.json +17 -0
  148. package/server/lib/opencode/settings-runtime.js +1 -0
  149. package/server/lib/opencode/shared-service-runtime.js +155 -0
  150. package/server/lib/opencode/shared-service-runtime.test.js +180 -0
  151. package/server/lib/opencode/shared.js +49 -4
  152. package/server/lib/opencode/shared.test.js +78 -1
  153. package/server/lib/opencode/shutdown-runtime.js +14 -5
  154. package/server/lib/opencode/shutdown-runtime.test.js +77 -2
  155. package/server/lib/opencode/skill-routes.js +28 -12
  156. package/server/lib/opencode/skill-routes.test.js +121 -1
  157. package/server/lib/opencode/startup-pipeline-runtime.js +5 -4
  158. package/server/lib/opencode/startup-pipeline-runtime.test.js +18 -7
  159. package/server/lib/opencode/upgrade-capability.js +0 -14
  160. package/server/lib/opencode/v1-migration-topup.js +21 -15
  161. package/server/lib/opencode/v1-migration-topup.test.js +14 -6
  162. package/server/lib/opencode/v2-install.d.ts +1 -0
  163. package/server/lib/opencode/v2-install.js +8 -7
  164. package/server/lib/opencode/v2-install.test.js +13 -4
  165. package/server/lib/opencode/watcher.js +3 -1
  166. package/server/lib/opencode/watcher.test.js +54 -0
  167. package/server/lib/opencode/websearch-config.js +13 -1
  168. package/server/lib/quota/providers/kimi.js +1 -1
  169. package/server/lib/realtime-proxy.js +5 -1
  170. package/server/lib/realtime-proxy.test.js +29 -0
  171. package/server/lib/relay/tunnel-host.js +4 -1
  172. package/server/lib/relay/tunnel-host.test.js +11 -0
  173. package/server/lib/session-assist/DOCUMENTATION.md +17 -5
  174. package/server/lib/session-assist/runtime.js +19 -2
  175. package/server/lib/session-assist/runtime.test.js +8 -0
  176. package/server/lib/session-goal/DOCUMENTATION.md +11 -0
  177. package/server/lib/small-model/DOCUMENTATION.md +11 -10
  178. package/server/lib/small-model/index.js +27 -32
  179. package/server/lib/small-model/index.test.js +28 -16
  180. package/server/lib/spaces/DOCUMENTATION.md +404 -32
  181. package/server/lib/spaces/code-in-bait.js +145 -6
  182. package/server/lib/spaces/code-in.js +10 -150
  183. package/server/lib/spaces/code-in.test.js +7 -83
  184. package/server/lib/spaces/code-out.js +1819 -0
  185. package/server/lib/spaces/code-out.test.js +3945 -0
  186. package/server/lib/spaces/code-transfer.js +173 -0
  187. package/server/lib/spaces/command-stream.test.js +181 -0
  188. package/server/lib/spaces/dispatcher.js +670 -0
  189. package/server/lib/spaces/dispatcher.test.js +582 -0
  190. package/server/lib/spaces/gatekeeper-channel.js +61 -7
  191. package/server/lib/spaces/gatekeeper-channel.test.js +43 -7
  192. package/server/lib/spaces/gatekeeper-program.cjs +68 -14
  193. package/server/lib/spaces/gatekeeper-program.test.js +118 -3
  194. package/server/lib/spaces/hardening.js +20 -4
  195. package/server/lib/spaces/hardening.test.js +18 -3
  196. package/server/lib/spaces/host-git.js +7 -4
  197. package/server/lib/spaces/host-git.test.js +6 -2
  198. package/server/lib/spaces/host.js +310 -0
  199. package/server/lib/spaces/host.test.js +273 -0
  200. package/server/lib/spaces/journey.js +552 -0
  201. package/server/lib/spaces/journey.test.js +589 -0
  202. package/server/lib/spaces/layout.js +42 -8
  203. package/server/lib/spaces/manager.js +4 -3
  204. package/server/lib/spaces/manager.test.js +6 -0
  205. package/server/lib/spaces/places/code-out.docker.live.test.js +412 -0
  206. package/server/lib/spaces/places/contract-suite.js +36 -0
  207. package/server/lib/spaces/places/dispatcher.docker.live.test.js +296 -0
  208. package/server/lib/spaces/places/docker-live-support.js +27 -4
  209. package/server/lib/spaces/places/docker.js +33 -5
  210. package/server/lib/spaces/places/docker.test.js +42 -3
  211. package/server/lib/spaces/places/escape-suite.js +118 -14
  212. package/server/lib/spaces/places/fake-docker.js +3 -1
  213. package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
  214. package/server/lib/spaces/places/memory-place.js +24 -1
  215. package/server/lib/spaces/places/registry.js +1 -1
  216. package/server/lib/spaces/places/server.docker.live.test.js +69 -33
  217. package/server/lib/spaces/places/sessions.docker.live.test.js +222 -0
  218. package/server/lib/spaces/routes.js +216 -0
  219. package/server/lib/spaces/routes.test.js +213 -0
  220. package/server/lib/spaces/run-command.js +261 -8
  221. package/server/lib/spaces/run-command.test.js +193 -3
  222. package/server/lib/spaces/space-events.js +153 -0
  223. package/server/lib/spaces/space-events.test.js +160 -0
  224. package/server/lib/spaces/space-opencode.js +52 -0
  225. package/server/lib/spaces/space-opencode.test.js +41 -0
  226. package/server/lib/spaces/space-records.js +150 -0
  227. package/server/lib/spaces/space-records.test.js +113 -0
  228. package/server/lib/spaces/space-sessions.js +210 -0
  229. package/server/lib/spaces/space-sessions.test.js +161 -0
  230. package/server/lib/spaces/websocket.js +329 -0
  231. package/server/lib/spaces/websocket.test.js +345 -0
  232. package/server/lib/ui-auth/ui-auth.js +8 -2
  233. package/server/lib/ui-auth/ui-auth.test.js +29 -0
  234. package/server/opencode-proxy.test.js +271 -0
  235. package/server/proxy-headers.js +8 -2
  236. package/server/proxy-headers.test.js +20 -0
  237. package/dist/assets/DiffView-CX3wAX2S.js +0 -4
  238. package/dist/assets/FilesView-OL3CON3r.js +0 -17
  239. package/dist/assets/GuestSurfacePane-B_cqX5I5.js +0 -1
  240. package/dist/assets/MarkdownImageGallery-DFiTFZgj.js +0 -1
  241. package/dist/assets/MarkdownRendererImpl-DZm5sf1W.js +0 -12
  242. package/dist/assets/PluginPane-BibJit86.js +0 -3
  243. package/dist/assets/SettingsView-h-VpVO47.js +0 -29
  244. package/dist/assets/commitAndPush-BIPfOMXY.js +0 -1
  245. package/dist/assets/de-BqCNGROu.js +0 -10
  246. package/dist/assets/es-BTPpTRgN.js +0 -16
  247. package/dist/assets/fr-hxbzMdAg.js +0 -14
  248. package/dist/assets/index-CLcM8HKx.css +0 -1
  249. package/dist/assets/index-CvLgnuNI.js +0 -41
  250. package/dist/assets/ja-_zLwwYiy.js +0 -16
  251. package/dist/assets/ko-CFn3Dzhc.js +0 -16
  252. package/dist/assets/main-BLJaug9I.js +0 -896
  253. package/dist/assets/markdownCore-DS9FdwrI.js +0 -5
  254. package/dist/assets/patchFileDiff-D9iBcTEi.js +0 -13
  255. package/dist/assets/pl-DFHE7xac.js +0 -16
  256. package/dist/assets/pt-BR-CUjZF179.js +0 -16
  257. package/dist/assets/renderMobileApp-CNQhdXsi.js +0 -25
  258. package/dist/assets/runtimeEndpointReset-DeaERc0M.js +0 -27
  259. package/dist/assets/scheduledTasksApi-BD6Vx9pu.js +0 -1
  260. package/dist/assets/tr-BB6sA_zH.js +0 -7
  261. package/dist/assets/uk-CB4o8g-o.js +0 -16
  262. package/dist/assets/vendor-opencode-client-_BAHQo4R.js +0 -12
  263. package/dist/assets/vendor-zod-Gea9uBlY.js +0 -39
  264. package/dist/assets/zh-CN-BRyDuWhc.js +0 -16
  265. package/dist/assets/zh-TW-BDGbWA1Q.js +0 -16
@@ -0,0 +1,896 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-BJicp0RC.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DDjuwVqi.js","assets/index-Di6zUe5h.js","assets/vendor-zod-BSoePkpP.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-DUke1nme.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/vendor-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-oKF0MAwd.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-Cqn0C0az.js","assets/runtimeEndpointReset-D0PcCb3K.js","assets/GuestAttachDialog-D7TJG1rt.js","assets/PluginPane-DQ0k41Q-.js","assets/VirtualizedFileDiff-ClDezf2d.js","assets/web-components-Bc1WPd4i.js","assets/computeVirtualFileMetrics-kM_zJNMt.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isDiffPlainText-DOoIsGqs.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BBE7tTY2.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-Clg8EO3A.js","assets/appThemeRegistry-CiuyzfSW.js","assets/textMateThemeFromAppTheme-C-kGcOpD.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-nDcRrgJ1.js","assets/scheduledTasksApi-Dahv3ws0.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-uzNpHBlV.js","assets/SubmoduleDiffSummary-0HgmcMXz.js","assets/changesTree-CePHbFcj.js","assets/FilesView-Bkq0sjNx.js","assets/shikiHighlight-l-MbaNS4.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-BNT2yUVu.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-bt5VHvcd.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-DCAQTLMM.js","assets/GitView-BmibZC7n.js","assets/commitAndPush-DTKb6IwT.js","assets/LinearIssuesView-D3Azksju.js","assets/PlanView-Bqc-xuDe.js","assets/GuestSurfacePane-PAcYaFzP.js","assets/SettingsWindow-DuC4ecLw.js","assets/SettingsView-BAiJU5hJ.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-D_41H2qC.js"])))=>i.map(i=>d[i]);
2
+ import{f as Ze,R as c,j as s,r as ct,c as Gm,h as qm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{F as en,H as Qo,I as Ym,J as Qm,h as ls,y as Fd,u as Ae,K as Rt,L as xl,a as Wt,z as vr,o as xt,N as js,O as Vr,P as kn,Q as Ld,R as Xm,S as Jm,T as Zm,U as eh,V as _d,n as Jt,W as jn,X as Ur,e as mn,Y as th,Z as sh,_ as nh,$ as rh,a0 as $d,x as Js,C as Vs,a1 as oh,a2 as bl,a3 as ih,a4 as zd,a5 as ah,a6 as Wd,f as lh,a7 as $n,a8 as Un,a9 as Ro,aa as Wi,ab as ch,ac as Ra,d as Mo,v as lr,q as as,ad as Kd,ae as dh,af as Ki,ag as Vd,ah as Ud,t as Hd,i as uh,ai as fh,aj as ko,ak as Co,al as mh,am as yl,an as hh,ao as ph,ap as gh,aq as xh,ar as wl,as as vl,at as Sl,au as jl,av as bh,B as kl,aw as yh,ax as wh,ay as vh,D as Sh,E as jh}from"./index-Di6zUe5h.js";import{_ as sn}from"./vendor-vite-runtime-DD1OZmLC.js";import{z as Cl,E as Si,F as Gs,G as Vi,H as Nl,I as kh,J as Ch,K as Nh,L as Ah,M as Ph,Q as Dh,R as Ih,V as Th,W as Ma,a as Eh,e as Gd,X as qd,h as Ui,m as Yd,Y as Rh,k as Mh,j as Oh,Z as Qd,_ as Hi,$ as zn,a0 as Xd,a1 as Jd,l as Bh,P as Fh,T as Lh,a2 as _h,a3 as $h,a4 as zh,a5 as Wh,b as Zd,a6 as Kh,a7 as eu,a8 as Oo,a9 as Vh,aa as Uh,ab as Hh,S as ji,ac as tu,ad as su,d as Gh,ae as qh,c as Yh,af as Qh,ag as ro,r as Al,ah as Xh,ai as Jh,u as _r,s as Zh,N as ep,D as tp,aj as sp,ak as Pl,al as np,am as ki,w as rp,q as op,x as nu,U as ip,y as ap,an as lp,ao as cp,ap as dp,O as up,o as fp,t as mp,v as ru,A as hp,C as pp}from"./runtimeEndpointReset-D0PcCb3K.js";import{f as St,h as Me,bh as _t,I as O,g as Jn,t as ze,at as Ps,bi as gs,av as Ds,as as Is,T as Cn,_ as nn,ai as Zn,bj as Nn,o as Qr,bk as Dl,bl as gp,bm as xp,ae as bt,af as yt,ag as wt,b as zt,z as nt,H as bp,bn as ou,bo as oo,u as us,r as xs,D as iu,C as au,bp as Gi,bq as yp,br as lu,bs as cu,S as Oa,bt as wp,bu as vp,bv as Il,bw as Tl,bx as du,by as Sp,bz as El,bA as jp,bB as kp,bC as Ba,bD as qi,bE as uu,bF as Cp,bG as Np,bH as Ap,Q as fu,bI as Pp,bJ as Dp,bK as Ip,n as ur,bL as mu,bM as Tp,bN as Ep,p as Rp,bO as hu,bP as Mp,bQ as Op,bR as Bp,bS as pu,bT as gu,bU as xu,bV as bu,bW as yu,bX as wu,bY as vu,bZ as Xr,b_ as Fa,aJ as La,b$ as Hn,c0 as Jr,c1 as Fp,c2 as bs,c3 as ys,c4 as Us,c5 as Bs,c6 as Fs,c7 as An,B as ut,c8 as gn,aB as ps,c9 as Lp,ca as _p,aH as hn,cb as cr,cc as Ms,cd as Xo,ce as Su,cf as Yi,cg as Qi,ch as Xi,ci as $p,cj as ks,ck as Cs,cl as hs,cm as Ns,cn as Yt,X as un,co as fr,cp as Rl,cq as hr,cr as ju,R as Jo,aj as zp,ak as _a,al as ku,J as Cu,K as pn,cs as $a,a9 as za,ct as Wp,cu as Kp,az as Vp,cv as Up,cw as Nu,cx as Hp,cy as Gp,aA as Wa,cz as qp,cA as Au,cB as pr,cC as Pu,cD as Yp,l as Lt,s as Qp,cE as Xp,cF as Jp,aO as Pn,cG as Zp,cH as dr,O as Du,cI as eg,cJ as tg,cK as Dn,cL as sg,cM as ng,aD as rg,cN as Ci,cO as og,cP as ig,cQ as ag,cR as Iu,cS as lg,cT as Ka,cU as cg,cV as Tu,cW as dg,aI as Ji,cX as Zi,cY as Ml,cZ as ug,c_ as Ol,c$ as Or,c as Hr,d as Va,a4 as fg,a1 as Eu,d0 as Pr,d1 as Br,d2 as mg,d3 as hg,d4 as pg,$ as Ua,aC as gg,d5 as xg,d6 as bg,d7 as yg,d8 as wg,d9 as Ru,da as Qs,db as vg,dc as Mu,dd as Sg,a8 as ea,de as jg,df as Ou,dg as ss,dh as kg,di as Cg,dj as Ng,dk as Bu,dl as Ag,dm as Ha,dn as Fu,a6 as Bo,dp as ta,dq as Zo,a as Ga,dr as qa,a5 as Pg,ds as Bl,P as Fo,U as ei,V as ti,W as si,dt as Dg,du as sa,dv as Lu,dw as Ig,dx as Tg,au as _u,dy as Eg,dz as Ya,L as Rg,dA as Fl,dB as Mg,dC as Og,dD as Ut,dE as Bg,dF as Yn,dG as $u,dH as zu,dI as Wu,dJ as Ku,dK as Fg,E as Lg,dL as _g,dM as $g,dN as zg,dO as Ll,dP as Vu,dQ as Wg,dR as Uu,F as Kg,dS as Vg,dT as Ug,dU as Hg,dV as $r,dW as Gg,dX as qg,dY as Yg,dZ as Qg,e as Qa,d_ as ni,d$ as Xg,e0 as Gr,a3 as Jg,G as ri,e1 as Zg,e2 as ex,e3 as _l,e4 as tx,e5 as sx,a0 as nx,e6 as rx,e7 as ox,a$ as $l,ab as zl,aa as Wl,e8 as ix,aW as na,e9 as ax,M as lx,N as Ni,ea as cx,eb as dx,ec as Hu,ed as Gu,ee as qu,ef as ux,eg as fx,a7 as mx,am as hx,eh as px,ei as Kl,ej as gx,ek as xx,el as bx,em as yx,en as Lo,eo as wx,ep as Vl,eq as vx,er as Sx,es as jx,et as kx,eu as ra,ev as Cx,ew as No,ex as Nx,i as Ax,ey as Px,ez as Dx,eA as Ix,eB as Tx,eC as Ex,eD as Rx,eE as Ul,eF as Mx,aP as Ox,aQ as Bx,aS as Fx,aR as Lx,aU as Hl,aV as Gl,aY as ql,aZ as Yl,aX as Yu,a_ as Qu,eG as _x,bc as $x,bd as zx,be as Wx,bf as Kx,bg as Vx,b6 as Ux,b8 as Hx,b9 as Gx,ba as qx,bb as Yx}from"./useAppFontEffects-DDjuwVqi.js";import{u as Xu,S as Ql,C as Qx,t as Xx,W as Ju,f as Jx,G as Zx,a as eb}from"./useRootScrollLock-nDcRrgJ1.js";import{u as On,O as Xl,D as tb,a as sb,b as nb,f as rb,c as Jl,s as ob,d as ib,e as ab,r as lb}from"./scheduledTasksApi-Dahv3ws0.js";import{f as oi,h as fn,T as ii,M as ai,D as li,j as ci,d as cb,b as db,k as ub,i as fb}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as di,S as Xa,h as mb,a as Zu,v as ef,s as hb}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ui}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as tf,M as sf,C as nf,a as oa,b as ia,c as aa,d as rf,e as pb,f as gb}from"./vendor-base-ui-CsXYnR5c.js";import{c as Zr,u as Qn,d as xb,p as bb}from"./vendor-zustand-BAGL70zf.js";import{g as yb,a as wb,E as of,b as vb,c as Sb,d as jb,e as kb,i as Cb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as Nb}from"./PluginPane-DQ0k41Q-.js";import{a as Ja,s as Xn,r as af,o as Zl,b as ec}from"./vendor-zod-BSoePkpP.js";import{u as Ab}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as Pb}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as lf}from"./vendor-cron-parser-CjvYVigk.js";const Db="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",Ib="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",Ai=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Db:t.id==="terminal"?Ib:void 0}),tc=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),e[2]=p):p=e[2];let x;return e[3]!==u?(x=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=x):x=e[4],x}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Me("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},Tb=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=St(),o=On(Eb),l=On(Rb),a=On(Mb),d=On(Ob),u=On(Bb),h=On(Fb),f=On(Lb);let p,x;e[0]!==u?(p=()=>{u()},x=[u],e[0]=u,e[1]=p,e[2]=x):(p=e[1],x=e[2]),c.useEffect(p,x);const b=en()&&Qo();let k;e:{let ve;e[3]!==l||e[4]!==o?(ve=l.find(U=>U.id===o)??l.find(_b)??l[0]??Xl[0],e[3]=l,e[4]=o,e[5]=ve):ve=e[5];const pe=ve;if(pe){let U;e[6]!==pe?(U=Ai(pe),e[6]=pe,e[7]=U):U=e[7],k=U;break e}let Ne;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ne=Ai(Xl[0]),e[8]=Ne):Ne=e[8],k=Ne}const y=k;if(!b||!n||l.length===0)return null;let m;e[9]!==n?(m=async ve=>{await Ym(n,ve.id,ve.appName)||await Qm(n,ve.appName)},e[9]=n,e[10]=m):m=e[10];const g=m;let j;e[11]!==g||e[12]!==f?(j=async ve=>{await f(ve.id),await g(ve)},e[11]=g,e[12]=f,e[13]=j):j=e[13];const S=j;let w;e[14]!==n||e[15]!==i?(w=async()=>{(await Jn(n)).ok&&ze.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=w):w=e[16];const C=w;let v;e[17]!==r?(v=Me("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=v):v=e[18];let R;e[19]!==g||e[20]!==y?(R=()=>{g(y)},e[19]=g,e[20]=y,e[21]=R):R=e[21];const T=d&&"animate-pulse";let D;e[22]!==T?(D=Me("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",T),e[22]=T,e[23]=D):D=e[23];let F;e[24]!==y.label||e[25]!==i?(F=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=F):F=e[26];let B;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(B=s.jsx(tc,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==R?(E=s.jsx("button",{type:"button",onClick:R,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=R,e[35]=E):E=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Me("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let L;e[37]!==i?(L=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=L):L=e[38];let X;e[39]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=X):X=e[39];let Y;e[40]!==L?(Y=s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":L,children:X})}),e[40]=L,e[41]=Y):Y=e[41];let I;e[42]!==C?(I=()=>{C()},e[42]=C,e[43]=I):I=e[43];let P;e[44]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(O,{name:"file-copy",className:"h-4 w-4"}),e[44]=P):P=e[44];let A;e[45]!==i?(A=i("openInApp.actions.copyPath"),e[45]=i,e[46]=A):A=e[46];let q;e[47]!==A?(q=s.jsx("span",{className:"typography-ui-label text-foreground",children:A}),e[47]=A,e[48]=q):q=e[48];let K;e[49]!==I||e[50]!==q?(K=s.jsxs(_t,{className:"flex items-center gap-2",onClick:I,children:[P,q]}),e[49]=I,e[50]=q,e[51]=K):K=e[51];let te;e[52]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(gs,{}),e[52]=te):te=e[52];let ae;if(e[53]!==l||e[54]!==S||e[55]!==y.id){let ve;e[57]!==S||e[58]!==y.id?(ve=pe=>{const Ne=Ai(pe);return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{S(pe)},children:[s.jsx(tc,{label:pe.label,iconDataUrl:pe.iconDataUrl,fallbackIconDataUrl:Ne.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:pe.label}),y.id===pe.id?s.jsx(O,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},pe.id)},e[57]=S,e[58]=y.id,e[59]=ve):ve=e[59],ae=l.map(ve),e[53]=l,e[54]=S,e[55]=y.id,e[56]=ae}else ae=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==i?(re=a?s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(O,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=re):re=e[63];let he;e[64]!==K||e[65]!==ae||e[66]!==re?(he=s.jsxs(Ds,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[K,te,ae,re]}),e[64]=K,e[65]=ae,e[66]=re,e[67]=he):he=e[67];let ce;e[68]!==Y||e[69]!==he?(ce=s.jsxs(Is,{children:[Y,he]}),e[68]=Y,e[69]=he,e[70]=ce):ce=e[70];let Te;return e[71]!==E||e[72]!==ce||e[73]!==v?(Te=s.jsxs("div",{className:v,children:[E,ce]}),e[71]=E,e[72]=ce,e[73]=v,e[74]=Te):Te=e[74],Te};function Eb(t){return t.selectedAppId}function Rb(t){return t.availableApps}function Mb(t){return t.isCacheStale}function Ob(t){return t.isScanning}function Bb(t){return t.initialize}function Fb(t){return t.loadInstalledApps}function Lb(t){return t.selectApp}function _b(t){return t.id===tb}const _o=new Map,la=new Set,cf=()=>{for(const t of la)t()},Pi=(t,e)=>{const n=t.trim();n&&(e.length===0?_o.delete(n):_o.set(n,[...e]),cf())},$b=t=>{_o.delete(t.trim())&&cf()},df=[],zb=t=>_o.get(t.trim())??df,Wb=t=>(la.add(t),()=>{la.delete(t)}),Kb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>zb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(Wb,n,Vb)};function Vb(){return df}const Ub=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Hb=["dev","start","preview","serve"];async function Gb(t,e,n){if(!t)return null;const r=Qb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Xb(n);if(i){const o=await Jb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await qb(t)){const i=await Yb(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function qb(t){const e=`${t}/index.html`,n=await $o(e,t);return typeof n=="string"&&n.trim().length>0}async function Yb(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Qb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Hb.some(i=>n.includes(i)))return e}return null}function Xb(t){for(const{pattern:e}of Ub)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Jb(t){const e=await $o(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await $o(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function $o(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Fd()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Zb(t){try{const e=await $o(`${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 Ys="__openchamber_auto_discover_preview__",ey=15e3,ty=3e3,Di=t=>t.id===Ys?"scan-2":Th.find(n=>n.key===t.icon)?.Icon??"play",sy=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},ny=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=St(),{currentTheme:l}=Cn(),{terminal:a,runtime:d}=nn(),u=Zn(),{isMobile:h}=Nn(),f=c.useMemo(()=>en(),[]),p=Cl(se=>se.instances),x=Cl(se=>se.load),b=Ae(se=>se.terminalShell),k=Ae(se=>se.terminalLoginShells.includes(se.terminalShell)),y=Ae(se=>se.setSettingsPage),m=Ae(se=>se.setSettingsDialogOpen),g=Ae(se=>se.setSettingsProjectsSelectedId),j=Ae(se=>se.openContextPreview),S=Rt(se=>se.ensureDirectory),w=Rt(se=>se.reconcileServerSessions),C=Rt(se=>se.setTabLabel),v=Rt(se=>se.setTabIconKey),R=Rt(se=>se.setActiveTab),T=Rt(se=>se.setConnecting),D=Rt(se=>se.setTabSessionId),F=Rt(se=>se.setTabPurpose),B=Rt(se=>se.allocateActionExecution),E=Rt(se=>se.setTabLifecycle),$=Rt(se=>se.setTabPreviewUrl),L=Rt(se=>se.matchesActionExecution),X=Rt(se=>se.captureStartedActionMutationRevisions),[Y,I]=c.useState([]),P=c.useRef(null),[A,q]=c.useState(null),[K,te]=c.useState(!1),ae=c.useRef({}),re=c.useRef({}),he=c.useRef({}),ce=c.useRef(new Set),Te=c.useRef(0),[ve,pe]=c.useState({}),Ne=t?.id??null,U=t?.path??"",Z=c.useMemo(()=>Ne?{id:Ne,path:U}:null,[Ne,U]);c.useEffect(()=>{f&&x().catch(()=>{})},[f,x]);const de=c.useCallback(async se=>{await Qr(se)},[]),ye=c.useCallback(async()=>{if(!Z)return;const se=Te.current+1;Te.current=se,te(!0);try{const me=await Dl(Z);if(Te.current!==se)return;P.current=me;const Ie=me.projectActions;I(Ie),q(We=>We===Ys||We&&Ie.some(V=>V.id===We)?We:null)}catch{if(Te.current!==se)return}finally{Te.current===se&&te(!1)}},[Z]),H=c.useMemo(()=>Si(e||Z?.path||""),[e,Z?.path]),je=c.useMemo(()=>Si(Z?.path||""),[Z?.path]),Ee=c.useMemo(()=>Si(u||"")||H,[u,H]),ge=c.useRef(Ee);c.useEffect(()=>{ge.current=Ee},[Ee]);const ne=Rt(se=>H?se.getDirectoryState(H):void 0),be=Rt(se=>je&&je!==H?se.getDirectoryState(je):void 0),G=c.useMemo(()=>{const se=H?[{directory:H,state:ne}]:[];return je&&je!==H&&se.push({directory:je,state:be}),se},[ne,H,je,be]),z=c.useMemo(()=>{const se=H?[H]:[];return je&&je!==H&&se.push(je),se},[H,je]),J=c.useCallback(se=>se.id!==Ys&&se.runIn==="parent"&&je||H,[H,je]),ue=c.useCallback((se,me,Ie)=>`${se}::${me}::${Ie}`,[]),le=c.useCallback((se,me,Ie=Rt.getState())=>se?Ie.getDirectoryState(se)?.tabs.find(We=>We.purpose.type==="project-action"&&We.purpose.actionId===me)??null:null,[]),W=c.useMemo(()=>{const se={};for(const{directory:me,state:Ie}of G)for(const We of Ie?.tabs??[]){if(We.purpose.type!=="project-action"||!We.purpose.executionId||!We.terminalSessionId||We.lifecycle==="idle"||We.lifecycle==="exited")continue;const V=Gs(me,We.purpose.actionId),Fe=ue(me,We.purpose.actionId,We.purpose.executionId);se[V]={directory:me,actionId:We.purpose.actionId,tabId:We.id,sessionId:We.terminalSessionId,executionId:We.purpose.executionId,status:We.lifecycle==="stopping"?"stopping":ve[Fe]?"waiting-for-preview":"running"}}return se},[ue,ve,G]),M=c.useCallback((se,me,Ie)=>{const We=Gs(se,me),V=ue(se,me,Ie),Ye=ae.current[We]?.executionId===Ie,Qe=globalThis.window,xe=st=>{Qe?.clearTimeout(he.current[st]),delete he.current[st]};Ye&&(delete ae.current[We],xe(We)),re.current[V]?.(),delete re.current[V],xe(V),pe(st=>{if(!st[V])return st;const Re={...st};return delete Re[V],Re})},[ue]),_=c.useCallback(se=>{re.current[se]?.(),delete re.current[se]},[]),ee=c.useCallback(se=>{window.clearTimeout(he.current[se]),delete he.current[se]},[]);c.useEffect(()=>{const se=re.current,me=he.current;return()=>{for(const Ie of Object.keys(se))_(Ie);for(const Ie of Object.keys(me))ee(Ie)}},[ee,_]),c.useEffect(()=>{const se=new Set(z);for(const me of Object.values(ae.current))se.has(me.directory)||M(me.directory,me.actionId,me.executionId);for(const me of Object.keys(re.current)){const Ie=me.split("::",1)[0]??"";se.has(Ie)||_(me)}},[M,_,z]);const oe=c.useCallback((se,me)=>{Ae.getState().openContextPanelTab(se,{mode:"terminal",targetDirectory:me===se?null:me})},[]),fe=c.useMemo(()=>A?Y.find(se=>se.id===A)??null:null,[Y,A]),ie=c.useMemo(()=>({id:Ys,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Le=!h,$e=c.useMemo(()=>Le?[ie,...Y]:Y,[Y,ie,Le]);c.useEffect(()=>{ye()},[ye]),c.useEffect(()=>{const se=z.map(me=>Vi(a,me,X,Ie=>w(me,Ie.sessions,{startedActionMutationRevisions:Ie.startedActionMutationRevisions})));return()=>{for(const me of se)me()}},[X,w,a,z]),c.useEffect(()=>{for(const{directory:se,state:me}of G)if(se)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action")continue;const We=Ie.purpose.actionId,V=$e.find(Qe=>Qe.id===We),Fe=V?.name??We,Ye=V?.icon||"play";Ie.label!==Fe&&C(se,Ie.id,Fe),Ie.iconKey!==Ye&&v(se,Ie.id,Ye)}},[$e,v,C,G]),c.useEffect(()=>{const se=globalThis.window;if(!se)return;const me=Ie=>{const We=Ie.detail;Ne&&(We?.projectId&&We.projectId!==Ne||ye())};return se.addEventListener(Nl,me),()=>{se.removeEventListener(Nl,me)}},[ye,Ne]),c.useEffect(()=>{A&&(A===Ys&&Le||Y.some(se=>se.id===A)||q(null))},[Y,Le,A]),c.useEffect(()=>{const se=Ie=>{delete he.current[Ie];const We=ae.current[Ie];if(!We||We.openedUrl)return;const V=ue(We.directory,We.actionId,We.executionId),Fe=We.announced;if(Fe.length!==0){if(window.clearTimeout(he.current[V]),delete he.current[V],We.openedUrl=!0,pe(Ye=>{if(!Ye[V])return Ye;const Qe={...Ye};return delete Qe[V],Qe}),Fe.length===1){Pi(We.directory,[]),$(We.directory,We.tabId,Fe[0],{locked:!1,autoOpened:!0}),j(We.directory,Fe[0]);return}We.offering=!0,Pi(We.directory,Fe),Ae.getState().openContextSurface(We.directory,"browser"),ze.info(o("projectActions.toast.multipleServers"))}},me=()=>{const Ie=Rt.getState(),We=Ie.sessions,V=W;for(const[Fe,Ye]of Object.entries(V)){const xe=We.get(Ye.directory)?.tabs.find(lt=>lt.id===Ye.tabId);if(!xe||xe.terminalSessionId!==Ye.sessionId){M(Ye.directory,Ye.actionId,Ye.executionId);continue}const st=ae.current[Fe],Re=st?.executionId===Ye.executionId?st:{hostDirectory:ge.current||Ye.directory,directory:Ye.directory,tabId:Ye.tabId,actionId:Ye.actionId,executionId:Ye.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};ae.current[Fe]=Re;const ot=$e.find(lt=>lt.id===Ye.actionId),vt=Ie.getBuffer(Ye.directory,Ye.tabId).chunks;if(!ot||vt.length===0)continue;const De=vt.filter(lt=>Re.lastSeenChunkId===null||lt.id>Re.lastSeenChunkId);if(De.length===0)continue;const gt=De.map(lt=>lt.data).join(""),Ct=`${Re.tail}${gt}`;if(Re.openInPreview&&(!Re.openedUrl||Re.offering)){const lt=Dh(Ct),_e=Re.announced.length;for(const Je of lt)Re.announced.includes(Je)||Re.announced.push(Je);const Ge=Re.announced.length-_e;Re.offering&&Ge>0?Pi(Ye.directory,Re.announced):!Re.openedUrl&&_e===0&&Re.announced.length>0&&(window.clearTimeout(he.current[Fe]),he.current[Fe]=window.setTimeout(()=>se(Fe),ty))}const He=!Re.openedUrl&&ot.autoOpenUrl===!0&&!Re.openInPreview?Ih(Ct):null,Ue=De[De.length-1]?.id??Re.lastSeenChunkId;if(Re.lastSeenChunkId=Ue,Re.tail=Ct.slice(-512),He)if(Re.openedUrl=!0,Re.openInPreview){const lt=V[Fe];lt&&($(lt.directory,lt.tabId,He,{locked:!1,autoOpened:!1,expectedExecutionId:lt.executionId}),lt.status==="waiting-for-preview"&&pe(_e=>{const Ge=ue(lt.directory,lt.actionId,lt.executionId);if(!_e[Ge])return _e;const Je={..._e};return delete Je[Ge],Je}),window.clearTimeout(he.current[Fe]),delete he.current[Fe],j(lt.directory,He))}else de(He),ze.success(o("projectActions.toast.openedUrlFromOutput"));ae.current[Fe]=Re}for(const Fe of Object.keys(ae.current))if(!V[Fe]){const Ye=ae.current[Fe],Qe=Ye?We.get(Ye.directory)?.tabs.find(st=>st.id===Ye.tabId):void 0;if(Qe?.purpose.type==="project-action"&&Qe.purpose.executionId===Ye?.executionId&&!!Qe.terminalSessionId&&Qe.lifecycle!=="idle"&&Qe.lifecycle!=="exited")continue;delete ae.current[Fe],window.clearTimeout(he.current[Fe]),delete he.current[Fe]}};return me(),Rt.subscribe((Ie,We)=>{(Ie.sessions!==We.sessions||Ie.buffers!==We.buffers)&&me()})},[M,ge,$e,ue,j,de,W,$,o]),c.useEffect(()=>{for(const{directory:se,state:me}of G)for(const Ie of me?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle!=="running")continue;const We=Ie.purpose.actionId,V=Ie.purpose.executionId,Fe=ue(se,We,V);if(re.current[Fe])continue;const Ye=a.connect(Ie.terminalSessionId,{onEvent:Qe=>{if(!L(se,Ie.id,V))return;Qe.type==="snapshot"&&(Rt.getState().replaceBuffer(se,Ie.id,Qe.data??"",Qe.sequence??0,xl(Qe)),Qe.status==="running"&&Rt.getState().setTabLifecycle(se,Ie.id,"running",{expectedExecutionId:V}),Qe.status==="exited"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V)));const xe=Qe.type==="data"?Qe.data??"":"";xe&&Rt.getState().appendToBuffer(se,Ie.id,xe,Qe.sequence,Qe.replayData),Qe.type==="exit"&&(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))},onError:(Qe,xe)=>{!xe||!L(se,Ie.id,V)||(Rt.getState().setTabLifecycle(se,Ie.id,"exited",{expectedExecutionId:V}),Rt.getState().setTabSessionId(se,Ie.id,null,{expectedExecutionId:V}),Rt.getState().setTabPurpose(se,Ie.id,{type:"project-action",actionId:We,executionId:null}),M(se,We,V))}},se);re.current[Fe]=Ye.close}},[M,ue,L,a,G]);const Pe=c.useCallback(async se=>{const me=J(se);if(!me)throw new Error(o("projectActions.error.noActiveDirectory"));const Ie=Gs(me,se.id);S(me);const We=Rt.getState(),V=le(me,se.id,We),Fe=V?.id??We.createTab(me);C(me,Fe,se.name),v(me,Fe,se.icon||"play"),V||F(me,Fe,{type:"project-action",actionId:se.id,executionId:null}),R(me,Fe);const Qe=Rt.getState().getDirectoryState(me)?.tabs.find(xe=>xe.id===Fe);return{executionDirectory:me,key:Ie,tabId:Fe,sessionId:Qe?.terminalSessionId??null,executionId:Qe?.purpose.type==="project-action"?Qe.purpose.executionId:null}},[S,J,le,R,v,C,F,o]),Oe=c.useCallback(async se=>{if(d.isVSCode||!i&&h)return;if(!H){ze.error(o("projectActions.error.noActiveDirectoryForAction"));return}const me=Gs(J(se),se.id),Ie=W[me];if(Ie&&Ie.status==="running"||ce.current.has(me))return;ce.current.add(me);let We=null;try{const V=se.id===Ys?await(async()=>{const[Ge,Je]=await Promise.all([gp({id:Z?.id??"",path:H}),Zb(H)]),at=await Gb(H,Ge.actions,Je);if(!at)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Ys,name:o("projectActions.actions.autoDiscover"),command:at.command,icon:"scan-2",autoOpenUrl:!0,openUrl:at.previewUrlHint||""}})():se,Fe=V.autoOpenUrl===!0&&(V.openUrl||"").trim().length>0,Ye=!Fe&&se.id!==Ys,Qe=ge.current||H,{executionDirectory:xe,key:st,tabId:Re}=await Pe(V),ot=kh(V.command);if(!ot)throw new Error(o("projectActions.error.failedToRunAction"));const vt=V.autoOpenUrl===!0&&f&&(V.desktopOpenSshForward||"").trim().length>0,De=V.autoOpenUrl?sy(V.openUrl):null,gt=V.autoOpenUrl&&f?Ch(V.desktopOpenSshForward,p):null;if(a.listSessions){const Ge=le(xe,V.id);if(Ge?.purpose.type==="project-action"&&Ge.purpose.executionId===null){const Je=await Nh(a,xe,{captureStartedActionMutationRevisions:X});Je&&w(xe,Je.sessions,{startedActionMutationRevisions:Je.startedActionMutationRevisions})}}const Ct=le(xe,V.id);let He,Ue;if(Ct?.lifecycle==="running"&&Ct.terminalSessionId&&Ct.purpose.type==="project-action"&&Ct.purpose.executionId)He=Ct.terminalSessionId,Ue=Ct.purpose.executionId;else{const Ge=Ct?.purpose.type==="project-action"?Ct.purpose.executionId:null;Ge&&M(xe,V.id,Ge);const Je=B(xe,Re,V.id);if(!Je)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));We={directory:xe,tabId:Re,id:Je},T(xe,Re,!0,{expectedExecutionId:Je});const at=await Ah({terminal:a,createOptions:{cwd:xe,shell:b,loginShell:k,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:ot,isRunStillExpected:()=>L(xe,Re,Je),purpose:{type:"project-action",actionId:V.id,executionId:Je}});if(!L(xe,Re,Je)){at.sessionId===Je&&await a.close(at.sessionId).catch(()=>{});return}Ue=at.purpose?.type==="project-action"?at.purpose.executionId:Je,He=at.sessionId,F(xe,Re,{type:"project-action",actionId:V.id,executionId:Ue}),D(xe,Re,He,{expectedExecutionId:Ue}),T(xe,Re,!1,{expectedExecutionId:Ue})}Ye&&Qe&&oe(Qe,xe),ae.current[st]={hostDirectory:Qe,directory:xe,tabId:Re,actionId:V.id,executionId:Ue,lastSeenChunkId:null,openedUrl:!!gt||!!De||Fe,tail:"",openInPreview:V.id===Ys,announced:[],offering:!1};const lt=ue(xe,V.id,Ue);T(xe,Re,!0,{expectedExecutionId:Ue});const _e=a.connect(He,{onEvent:Ge=>{if(!L(xe,Re,Ue)||Ge.purpose?.type==="project-action"&&Ge.purpose.executionId!==Ue)return;Ge.type==="snapshot"&&(Rt.getState().replaceBuffer(xe,Re,Ge.data??"",Ge.sequence??0,xl(Ge)),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Ge.purpose?.type==="project-action"&&Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:Ge.purpose.actionId,executionId:Ge.purpose.executionId}),Ge.status==="running"&&Rt.getState().setTabLifecycle(xe,Re,"running",{expectedExecutionId:Ue}),Ge.status==="exited"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)));const Je=Ge.type==="data"?Ge.data??"":"";Je&&Rt.getState().appendToBuffer(xe,Re,Je,Ge.sequence,Ge.replayData),Ge.type==="exit"&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue))},onError:(Ge,Je)=>{L(xe,Re,Ue)&&(Rt.getState().setConnecting(xe,Re,!1,{expectedExecutionId:Ue}),Je&&(Rt.getState().setTabLifecycle(xe,Re,"exited",{expectedExecutionId:Ue}),Rt.getState().setTabSessionId(xe,Re,null,{expectedExecutionId:Ue}),Rt.getState().setTabPurpose(xe,Re,{type:"project-action",actionId:V.id,executionId:null}),M(xe,V.id,Ue)))}},xe);if(!L(xe,Re,Ue)){_e.close();return}re.current[lt]?.(),re.current[lt]=_e.close,window.clearTimeout(he.current[lt]),delete he.current[lt],V.id===Ys&&!De&&(pe(Ge=>({...Ge,[lt]:!0})),he.current[lt]=window.setTimeout(()=>{delete he.current[lt];const Ge=ae.current[st];!Ge||Ge.executionId!==Ue||Ge.openedUrl||Ge.offering||L(xe,Re,Ue)&&(pe(Je=>{if(!Je[lt])return Je;const at={...Je};return delete at[lt],at}),Rt.getState().setActiveTab(xe,Re),oe(Ge.hostDirectory,xe))},ey)),gt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),de(gt),ze.success(o("projectActions.toast.openedForwardedUrl"))):De?($(xe,Re,De,{locked:!0,autoOpened:!0,expectedExecutionId:Ue}),j(Qe,De),ze.success(o("projectActions.toast.openedActionUrl"))):Fe?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.invalidCustomUrlFormat"))):vt?($(xe,Re,null,{locked:!0,expectedExecutionId:Ue}),ze.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(xe,Re,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ue})}catch(V){if(We&&L(We.directory,We.tabId,We.id)){const{directory:Fe,tabId:Ye,id:Qe}=We;M(Fe,se.id,Qe),E(Fe,Ye,"exited",{expectedExecutionId:Qe}),F(Fe,Ye,{type:"project-action",actionId:se.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")){ze.error(o("projectActions.error.failedToCreateTerminalSession"));return}ze.error(V instanceof Error?V.message:o("projectActions.error.failedToRunAction"))}finally{ce.current.delete(me)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,ge,p,Pe,i,h,f,H,k,b,de,j,W,oe,d.isVSCode,J,L,M,ue,le,w,B,X,T,E,F,$,D,Z?.id,o,a]),Q=c.useCallback(async se=>{const me=Gs(J(se),se.id),Ie=W[me];Ie&&await Ph({terminal:a,sessionId:Ie.sessionId,isExecutionStillCurrent:()=>L(Ie.directory,Ie.tabId,Ie.executionId),markStopping:()=>{E(Ie.directory,Ie.tabId,"stopping",{expectedExecutionId:Ie.executionId})},restoreRunning:()=>{E(Ie.directory,Ie.tabId,"running",{expectedExecutionId:Ie.executionId})},clearSession:()=>{D(Ie.directory,Ie.tabId,null,{expectedExecutionId:Ie.executionId})},finalizeExit:()=>{E(Ie.directory,Ie.tabId,"exited",{expectedExecutionId:Ie.executionId}),F(Ie.directory,Ie.tabId,{type:"project-action",actionId:Ie.actionId,executionId:null}),M(Ie.directory,Ie.actionId,Ie.executionId)}})},[M,J,L,W,E,F,D,a]),Ce=c.useCallback(()=>{const se=fe??$e[0];if(!se)return;const me=Gs(J(se),se.id),Ie=W[me];if(Ie?.status!=="stopping"){if(Ie){Q(se);return}Oe(se)}},[$e,J,Oe,W,fe,Q]),Se=c.useCallback(async se=>{if(se.source==="shared"&&Z){const me=P.current?.trust.trusted?P.current:await Dl(Z);if(P.current=me,!await xp(Z,me))return;P.current={...me,trust:{...me.trust,trusted:!0}}}await Oe(se)},[Oe,Z]),Ke=c.useCallback((se,me=!1)=>{if(q(se.id),!me){Se(se);return}const Ie=Gs(J(se),se.id),We=W[Ie];if(We?.status!=="stopping"){if(We){Q(se);return}Se(se)}},[J,Se,W,Q]),et=c.useCallback(()=>{Z?.id&&(g(Z.id),y("projects"),m(!0))},[m,y,g,Z?.id]),it=fe??$e[0]??null,rt=it?W[Gs(J(it),it.id)]:null,pt=Rt(se=>rt?se.getDirectoryState(rt.directory)?.tabs.find(me=>me.id===rt.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!Z||!H)return null;const ht=fe??$e[0]??null;if(!ht)return null;const tt=Di(ht),At=Gs(J(ht),ht.id),jt=W[At],we=jt?.status==="stopping",Xe=jt?.status==="waiting-for-preview",mt=!!(jt&&pt),qe=()=>{!jt||!pt||j(jt.directory,pt)},ft=ht.id===Ys;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:K||we,className:Me("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:Ce,"aria-label":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-5 w-5"})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:qe,children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ds,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]}):s.jsxs("div",{className:Me("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ce,disabled:K||we,className:Me("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":jt?o("projectActions.actions.stopNamedAria",{name:ht.name}):o("projectActions.actions.runNamedAria",{name:ht.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:we||Xe?s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):jt?s.jsx(O,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(O,{name:tt,className:"h-4 w-4"})})})}),ft?s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),mt?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:qe,className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(O,{name:"global",className:"h-4 w-4"})})}),s.jsx(wt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ds,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(_t,{className:"flex items-center gap-2",onClick:et,children:[s.jsx(O,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(gs,{}),$e.map(se=>{const me=Di(se),Ie=Gs(J(se),se.id),We=W[Ie],V=!!We,Fe=We?.status==="stopping";return s.jsxs(_t,{className:"flex items-center gap-2",onClick:()=>{Ke(se,!0)},children:[s.jsx(O,{name:me,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:se.name}),se.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Fe||We?.status==="waiting-for-preview"?s.jsx(O,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):V?s.jsx(O,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},se.id)})]})]})]})},Fr=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ry=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Fr(n??"");if(i){const o=ou(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function oy(){const t=zt(b=>b.projects),e=zt(b=>b.activeProjectId),n=nt(b=>b.availableWorktreesByProject),r=nt(b=>b.currentSessionId),i=bp(r??null),o=nt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=nt(b=>b.newSessionDraft?.open?Fr(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Fr(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Fr(b||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>ry({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Fr(u||h?.path||""),[u,h?.path]),p=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),x=c.useRef(null);return c.useEffect(()=>{p&&f&&(x.current={projectRef:p,directory:f})},[f,p]),c.useMemo(()=>p&&f?{projectRef:p,directory:f}:x.current,[p,f])}const iy=({transform:t})=>({...t,y:0}),ay={Item:_t,Separator:gs},ly={Item:({className:t,...e})=>s.jsx(sf,{className:Me(cu,t),...e}),Separator:({className:t,...e})=>s.jsx(tf,{className:Me(lu,t),...e})},cy=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=St(),[p,x]=c.useState(!1),[b,k]=c.useState(!1),[y,m]=c.useState(!1);let g;e[0]!==n.id?(g={id:n.id},e[0]=n.id,e[1]=g):g=e[1];const{attributes:j,listeners:S,setNodeRef:w,transform:C,transition:v,isDragging:R}=di(g);let T;e[2]!==f||e[3]!==n.session.title?(T=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=T):T=e[4];const D=T,F=!i&&(p||b),B=n.id;let E;e[5]!==n.session?(E=xs(n.session),e[5]=n.session,e[6]=E):E=e[6];const $=Ma(B,E),L=iu(n.id),Y=au(n.id)>0&&!r&&!L,I=L||Y;let P;e[7]!==L||e[8]!==f?(P=f(L?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=L,e[8]=f,e[9]=P):P=e[9];const A=P;let q;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==p||e[14]!==o||e[15]!==n?(q=je=>({session:n.session,open:p||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:je}),e[10]=d,e[11]=y,e[12]=r,e[13]=p,e[14]=o,e[15]=n,e[16]=q):q=e[16];const K=q;let te;e[17]!==C?(te=ui.Translate.toString(C),e[17]=C,e[18]=te):te=e[18];let ae;e[19]!==te||e[20]!==v?(ae={transform:te,transition:v},e[19]=te,e[20]=v,e[21]=ae):ae=e[21];const re=R&&"z-10 opacity-60";let he;e[22]!==re?(he=Me("session-tab-slot flex h-7 w-44 shrink-0 touch-none",re),e[22]=re,e[23]=he):he=e[23];const ce=r?"true":"false";let Te;e[24]!==r?(Te=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Te):Te=e[25];let ve;e[26]!==u?(ve=je=>u?.(je),e[26]=u,e[27]=ve):ve=e[27];let pe;e[28]!==h||e[29]!==A||e[30]!==r||e[31]!==$||e[32]!==L||e[33]!==K||e[34]!==p||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==I||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==D?(pe=s.jsx(nf,{render:je=>s.jsxs("div",{...je,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),o(n))},onAuxClick:Ee=>{Ee.button===1&&(Ee.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:Me("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":Me("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Me("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:Me("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:D})})}),$?s.jsx(O,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):I?s.jsx(Oa,{state:L?"running":"unread",label:A,className:Me("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:uy,onPointerDown:fy,className:Me("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",F&&"flex opacity-100"),children:[s.jsxs(Is,{open:p,onOpenChange:Ee=>{x(Ee),Ee&&k(!0)},onOpenChangeComplete:Ee=>{Ee||k(!1),u?.(Ee)},children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsx(Ds,{align:"start",className:"min-w-[190px]",children:a(K(ay))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=A,e[30]=r,e[31]=$,e[32]=L,e[33]=K,e[34]=p,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=I,e[41]=i,e[42]=f,e[43]=n,e[44]=D,e[45]=pe):pe=e[45];let Ne,U;e[46]===Symbol.for("react.memo_cache_sentinel")?(Ne={color:"var(--surface-elevated-foreground)"},U=Me(Gi,"min-w-[190px]"),e[46]=Ne,e[47]=U):(Ne=e[46],U=e[47]);let Z;e[48]!==K||e[49]!==a?(Z=a(K(ly)),e[48]=K,e[49]=a,e[50]=Z):Z=e[50];let de;e[51]!==Z?(de=s.jsx(oa,{children:s.jsx(ia,{className:"app-region-no-drag z-50",children:s.jsx(aa,{"data-slot":"dropdown-menu-content",style:Ne,className:U,children:Z})})}),e[51]=Z,e[52]=de):de=e[52];let ye;e[53]!==y||e[54]!==ve||e[55]!==pe||e[56]!==de?(ye=s.jsxs(rf,{open:y,onOpenChange:m,onOpenChangeComplete:ve,children:[pe,de]}),e[53]=y,e[54]=ve,e[55]=pe,e[56]=de,e[57]=ye):ye=e[57];let H;return e[58]!==j||e[59]!==S||e[60]!==w||e[61]!==he||e[62]!==ce||e[63]!==Te||e[64]!==ye||e[65]!==ae?(H=s.jsx("div",{ref:w,style:ae,className:he,"data-active":ce,...Te,...j,...S,children:ye}),e[58]=j,e[59]=S,e[60]=w,e[61]=he,e[62]=ce,e[63]=Te,e[64]=ye,e[65]=ae,e[66]=H):H=e[66],H},dy=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=St(),d=oo(my),u=oo(hy),h=oo(py),f=oo(gy),p=nt(xy),x=nt(by),b=us(yy);let k,y;e[0]!==p||e[1]!==u?(k=()=>{p&&u(p)},y=[p,u],e[0]=p,e[1]=u,e[2]=k,e[3]=y):(k=e[2],y=e[3]),c.useEffect(k,y);let m;if(e[4]!==b){m=new Map;for(const ge of b)m.set(ge.id,ge);e[4]=b,e[5]=m}else m=e[5];const g=m;let j;if(e[6]!==g||e[7]!==d){j=[];for(const ge of d){const ne=g.get(ge);ne&&j.push({id:ge,session:ne})}e[6]=g,e[7]=d,e[8]=j}else j=e[8];const S=j;let w;e[9]!==x?(w=ge=>{x(ge.id,xs(ge.session))},e[9]=x,e[10]=w):w=e[10];const C=w,v=wy;let R;e[11]!==h||e[12]!==p||e[13]!==C||e[14]!==S?(R=ge=>{if(h(ge),p&&p!==ge){const ne=S.find(be=>be.id===ge);ne&&C(ne)}},e[11]=h,e[12]=p,e[13]=C,e[14]=S,e[15]=R):R=e[15];const T=R;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D={activationConstraint:{distance:8}},e[16]=D):D=e[16];let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{delay:200,tolerance:6}},e[17]=F):F=e[17];const B=oi(fn(ai,D),fn(ii,F));let E;e[18]!==f?(E=ge=>{const{active:ne,over:be}=ge;be&&ne.id!==be.id&&f(String(ne.id),String(be.id))},e[18]=f,e[19]=E):E=e[19];const $=E,L=c.useRef(null);let X;e[20]===Symbol.for("react.memo_cache_sentinel")?(X={left:!1,right:!1},e[20]=X):X=e[20];const[Y,I]=c.useState(X);let P;e[21]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{const ge=L.current;if(!ge)return;const ne=ge.scrollLeft>2,be=ge.scrollLeft+ge.clientWidth<ge.scrollWidth-2;I(G=>G.left===ne&&G.right===be?G:{left:ne,right:be})},e[21]=P):P=e[21];const A=P;let q;e[22]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{A();const ge=L.current;if(!ge||!globalThis.ResizeObserver)return;const ne=new ResizeObserver(A);return ne.observe(ge),()=>ne.disconnect()},e[22]=q):q=e[22];let K;e[23]!==S.length?(K=[A,S.length],e[23]=S.length,e[24]=K):K=e[24],c.useEffect(q,K);let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{L.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=te):te=e[25];let ae;e[26]!==p?(ae=[p],e[26]=p,e[27]=ae):ae=e[27],c.useEffect(te,ae);const re=Y.left&&Y.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":Y.left?"linear-gradient(to right, transparent, black 24px)":Y.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let he;e[28]!==S?(he=S.map(vy),e[28]=S,e[29]=he):he=e[29];const ce=he;let Te;e[30]!==p||e[31]!==S?(Te=!p||!S.some(ge=>ge.id===p),e[30]=p,e[31]=S,e[32]=Te):Te=e[32];const ve=Te;let pe;e[33]!==a?(pe=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=pe):pe=e[34];let Ne;e[35]!==re?(Ne=re?{maskImage:re,WebkitMaskImage:re}:void 0,e[35]=re,e[36]=Ne):Ne=e[36];let U;e[37]===Symbol.for("react.memo_cache_sentinel")?(U=[iy],e[37]=U):U=e[37];let Z;e[38]!==o||e[39]!==p||e[40]!==T||e[41]!==C||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==S?(Z=S.map(ge=>s.jsx(cy,{tab:ge,isActive:ge.id===p,suppressControls:ge.id===p&&l,onSelect:C,onClose:v,renderMenu:n,closeOtherTabs:T,onMenuOpenChangeComplete:r,children:ge.id===p?o:null},ge.id)),e[38]=o,e[39]=p,e[40]=T,e[41]=C,e[42]=r,e[43]=n,e[44]=l,e[45]=S,e[46]=Z):Z=e[46];let de;e[47]!==Z||e[48]!==ce?(de=s.jsx(Xa,{items:ce,strategy:mb,children:Z}),e[47]=Z,e[48]=ce,e[49]=de):de=e[49];let ye;e[50]!==$||e[51]!==B||e[52]!==de?(ye=s.jsx(li,{sensors:B,collisionDetection:ci,modifiers:U,onDragEnd:$,children:de}),e[50]=$,e[51]=B,e[52]=de,e[53]=ye):ye=e[53];let H;e[54]!==o||e[55]!==ve?(H=ve?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=ve,e[56]=H):H=e[56];let je;e[57]!==Ne||e[58]!==ye||e[59]!==H?(je=s.jsxs("div",{ref:L,onScroll:A,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ne,children:[ye,H]}),e[57]=Ne,e[58]=ye,e[59]=H,e[60]=je):je=e[60];let Ee;return e[61]!==pe||e[62]!==je?(Ee=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":pe,children:je}),e[61]=pe,e[62]=je,e[63]=Ee):Ee=e[63],Ee};function uy(t){return t.stopPropagation()}function fy(t){return t.stopPropagation()}function my(t){return t.tabIds}function hy(t){return t.ensureTab}function py(t){return t.closeOtherTabs}function gy(t){return t.reorderTabs}function xy(t){return t.currentSessionId}function by(t){return t.setCurrentSession}function yy(t){return t.activeSessions}function wy(t){yp(t)}function vy(t){return t.id}const uf=async t=>{const{entry:e,session:n}=t,r=Wt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(wp(e.action)&&vp(e.guest,"conversation"))){await Il(e,Tl(e.action.id,i),t.t,r);return}let l=!1;const a=vr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Il(e,Tl(e.action.id,i,d),t.t,r)}};function ca(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=St(),{pending:a,disabled:d,hint:u,run:h}=Eh(n,r,i),f=a?"loader-4":"ai-generate-2",p=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let x;e[0]!==f||e[1]!==p?(x=s.jsx(O,{name:f,className:p}),e[0]=f,e[1]=p,e[2]=x):x=e[2];let b;e[3]!==l?(b=l("sessions.aiRename.action"),e[3]=l,e[4]=b):b=e[4];let k;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==x||e[9]!==b?(k=s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[x,b]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=x,e[9]=b,e[10]=k):k=e[10];let y;e[11]!==u?(y=s.jsx(wt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==k||e[14]!==y?(m=s.jsxs(bt,{children:[k,y]}),e[13]=k,e[14]=y,e[15]=m):m=e[15],m}const da=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class ff extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const fi=Zr(()=>({pendingSessionIds:new Set})),mf=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],fi(n)},sc=(t,e)=>{fi.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},Sy=async(t,e)=>{try{const d=(await Ap(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=xt(t),r=xt(e)??e,i=nt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>xt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},nc=t=>{for(const e of t){const n=jp(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class jy extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const ky=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new jy(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},Cy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(kp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),nt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i},rc=async(t,e,n)=>{try{await fu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},oc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ba(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},hf=async(t,e)=>{if(fi.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");sc(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,nt.getState().getWorktreeMetadata(a.id)]));nc(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){nc(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Sp(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&nt.getState().setWorktreeMetadata(d.id,El(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await Cy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await oc(t.sourceDirectory,i?.directory),u.length>0)throw ky(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new ff(d):d}return nt.getState().setWorktreeMetadata(t.root.id,El(i.metadata)),await oc(t.sourceDirectory,i.directory),i.directory}finally{sc(t.root.id,!1)}},Ny=async t=>{const e=xt(t.sourceDirectory)??t.sourceDirectory,n=xt(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return hf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Ay=async t=>hf(t,async()=>{const e=qi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Sy(t.sourceDirectory,e.path):null,r=await Cp(e,n?{startRef:n}:{});try{await Np(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return rc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>rc(e,r,i)}}),Py=t=>{(t.kind==="existing"?Ny({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>ze.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));ze.error(t.messages.failure,{description:r instanceof ff?t.messages.outcomeUnknown:r.message})})},ua=t=>{fi.getState().pendingSessionIds.has(t.root.id)||Py(t)},zo="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",Dy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,p=h===void 0?!1:h;if(!f)return null;const x=a??zo,b=p&&"bg-interactive-selection text-interactive-selection-foreground";let k;n[0]!==x||n[1]!==b?(k=Me(x,b),n[0]=x,n[1]=b,n[2]=k):k=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(O,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let g;n[6]!==o||n[7]!==l||n[8]!==p||n[9]!==k||n[10]!==m?(g=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":p,className:k,children:m})}),n[6]=o,n[7]=l,n[8]=p,n[9]=k,n[10]=m,n[11]=g):g=n[11];let j;n[12]!==i?(j=s.jsx(wt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=j):j=n[13];let S;return n[14]!==g||n[15]!==j?(S=s.jsxs(bt,{children:[g,j]}),n[14]=g,n[15]=j,n[16]=S):S=n[16],S}),Iy=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:p,onOpenRemoteUpdate:x}=e,{t:b}=St();let k;n[0]!==d||n[1]!==a?(k=B=>{a(B),B&&d()},n[0]=d,n[1]=a,n[2]=k):k=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==b?(y=r?b("header.services.openWithCurrent",{current:i}):b("header.services.open"),n[3]=i,n[4]=r,n[5]=b,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let g;n[7]!==m?(g=Me(zo,m),n[7]=m,n[8]=g):g=n[8];let j;n[9]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(O,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=j):j=n[9];let S;n[10]!==i||n[11]!==r?(S=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=S):S=n[12];let w;n[13]!==y||n[14]!==g||n[15]!==S?(w=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:g,children:[j,S]})})}),n[13]=y,n[14]=g,n[15]=S,n[16]=w):w=n[16];let C;n[17]!==i||n[18]!==u||n[19]!==b?(C=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=C):C=n[20];let v;n[21]!==C?(v=s.jsx(wt,{children:s.jsx("p",{children:C})}),n[21]=C,n[22]=v):v=n[22];let R;n[23]!==w||n[24]!==v?(R=s.jsxs(bt,{children:[w,v]}),n[23]=w,n[24]=v,n[25]=R):R=n[25];let T;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==x||n[30]!==f||n[31]!==p||n[32]!==h||n[33]!==a||n[34]!==b?(T=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:b("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?b("header.services.remoteUpdate.available",{version:h.version||""}):f?b("header.services.remoteUpdate.checking"):p||b("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:x,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Pp,{embedded:!0,open:l,onOpenChange:Ey,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=x,n[30]=f,n[31]=p,n[32]=h,n[33]=a,n[34]=b,n[35]=T):T=n[35];let D;n[36]!==T?(D=s.jsx(Ds,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:T}),n[36]=T,n[37]=D):D=n[37];let F;return n[38]!==l||n[39]!==k||n[40]!==R||n[41]!==D?(F=s.jsxs(Is,{open:l,onOpenChange:k,children:[R,D]}),n[38]=l,n[39]=k,n[40]=R,n[41]=D,n[42]=F):F=n[42],F}),an=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ic=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,Ty=()=>{js("ui.header.render");const{t}=St(),e=Ae(N=>N.isSidebarOpen),n=Ae(N=>N.openContextOverview),r=Ae(N=>N.closeContextPanel),i=Ae(N=>N.shortcutOverrides),o=Ae(N=>N.sessionTabsEnabled),l=nt(N=>N.getContextUsage),a=nt(N=>!!N.newSessionDraft?.open),d=nt(N=>N.currentSessionId),u=Dp(d??""),h=Ip(d??""),f=mf(d??""),p=us(Qn(c.useCallback(N=>{if(!d)return null;const ke=[...N.activeSessions,...N.archivedSessions].find(dt=>dt.id===d);if(!ke)return null;const Ve=ke;return{title:ke.title??null,directory:Ve.directory??null,created:ke.time?.created??null,slug:Ve.slug??null,parentId:ke.parentID??null}},[d]))),x=zt(Qn(N=>{if(!N.activeProjectId)return null;const ke=N.projects.find(Ve=>Ve.id===N.activeProjectId);return ke?{id:ke.id,path:ke.path,label:ke.label}:null})),b=c.useMemo(()=>{if(!x)return null;const N=x.label?.trim();if(N)return N;const ke=x.path.split(/[\\/]/).filter(Boolean);return ke[ke.length-1]??null},[x]),k=ur(N=>N.loadSettings),{isMobile:y}=Nn(),m=c.useRef(null),[g,j]=c.useState(()=>typeof window>"u"?!1:en()),S=c.useMemo(()=>Vr(),[]),w=mu(),[C,v]=c.useState(!1),R=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:T,side:D}=Xu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const N=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof N=="number"&&Number.isFinite(N)&&N>0)return N;if(typeof navigator>"u")return null;const ke=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ke)return null;const Ve=Number.parseInt(ke[1],10),dt=Number.parseInt(ke[2],10);return Number.isNaN(Ve)?null:Ve===10?dt:Ve},[]);ct.useEffect(()=>{typeof window>"u"||j(en())},[]);const{context:B,output:E}=Tp(d),$=l(B,E),[L,X]=c.useState(null),Y=!d||u;ct.useEffect(()=>{if(!d){X(N=>N===null?N:null);return}if($){X(N=>Ep(N,$)?N:$);return}Y&&X(N=>N===null?N:null)},[$,d,Y]);const[I,P]=c.useState(!1),[A,q]=c.useState("Local"),[K,te]=c.useState(!0),[ae,re]=c.useState(!1),[he,ce]=c.useState(null),[Te,ve]=c.useState(!1),[pe,Ne]=c.useState(null),U=c.useMemo(()=>kn(),[]),Z=Ae(N=>N.workStatusPanelVisible),de=Ae(N=>N.workStatusPanelEnabled),ye=Ae(N=>N.setWorkStatusPanelEnabled),H=Ae(N=>N.workStatusPanelFits),je=Ae(N=>N.workStatusOverlayOpen),Ee=Ae(N=>N.setWorkStatusOverlayOpen),ne=de&&H||je,be=c.useCallback(()=>{if(de&&!H){Ee(!je);return}ye(!de)},[Ee,ye,je,de,H]),G=!U&&!Z&&!!L,z=c.useCallback(async()=>{if(!(typeof window>"u"||!g))try{if(Qo()){q("Local"),te(!0);return}te(!1);const N=await Ld(),ke=Xm(),Ve=Jm([Zm(ke),...N.hosts]);if(Ve.id===eh){q("Local"),te(!0);return}q(_d(Ve.label.trim()||"Instance"))}catch{q("Local"),te(!0)}},[g]);ct.useEffect(()=>(z(),vr(()=>{z()})),[z]);const J=c.useCallback(async()=>{if(K){ce(null),Ne(null);return}ve(!0),Ne(null);try{const N=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),ke=await ls(`/api/openchamber/update-check?${N.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!ke.ok)throw new Error(`Server responded with ${ke.status}`);const Ve=await ke.json();ce({available:Ve.available??!1,version:Ve.version,currentVersion:Ve.currentVersion??"unknown",body:Ve.body,nextSuggestedCheckInSec:typeof Ve.nextSuggestedCheckInSec=="number"?Ve.nextSuggestedCheckInSec:void 0,packageManager:Ve.packageManager,updateCommand:Ve.updateCommand})}catch(N){ce(null),Ne(N instanceof Error?N.message:t("header.services.remoteUpdate.error"))}finally{ve(!1)}},[K,t]);c.useEffect(()=>{ce(null),Ne(null),re(!1)},[K,A]),c.useEffect(()=>{if(!g||K)return;const N=3e3,ke=3600*1e3;let Ve=!1,dt=null;const Tt=Et=>{dt=window.setTimeout(()=>{if(Ve||typeof document<"u"&&document.visibilityState!=="visible"){Tt(ke);return}J().finally(()=>{Ve||Tt(ke)})},Et)};return Tt(N),()=>{Ve=!0,dt!==null&&window.clearTimeout(dt)}},[J,K,A,g]);const ue=c.useCallback(()=>{if(he?.available){re(!0);return}J()},[J,he?.available]);Rp(),c.useEffect(()=>{k()},[k]);const le=d?p??null:null,W=c.useRef(null),[M,_]=c.useState(0);c.useEffect(()=>{if(!d){W.current&&(W.current=null,_(dt=>dt+1));return}if(le){W.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const N=W.current;if(!N||N.sessionId!==d)return;const ke=N.expiresAt-Date.now();if(ke<=0){W.current=null,_(dt=>dt+1);return}const Ve=window.setTimeout(()=>{W.current?.sessionId===d&&(W.current=null),_(dt=>dt+1)},ke);return()=>{window.clearTimeout(Ve)}},[d,le]);const ee=(()=>{if(le)return le;if(!d)return null;const N=W.current;return N&&N.sessionId===d&&N.expiresAt>Date.now()?N.session:null})(),oe=nt(N=>d?N.worktreeMetadata.get(d)?.path??"":""),fe=nt(N=>d?N.worktreeMetadata.get(d)?.branch?.trim()??null:null),ie=hu(N=>d?N.getAttachment(d):void 0),Le=c.useMemo(()=>ie?Mp(ie,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,ie]),$e=c.useMemo(()=>ie?ie.legacy?"legacy":ie.degraded?"degraded":ie.worktreeStatus==="pending"?"pending":ie.worktreeStatus==="missing"?"missing":ie.worktreeStatus==="invalid"?"invalid":ie.attentionReason?"attention":null:null,[ie]),Pe=c.useMemo(()=>an(oe||""),[oe]),Oe=c.useMemo(()=>{const N=typeof ee?.directory=="string"?ee.directory:"";return an(N||"")},[ee?.directory]),Q=Ma(d??"",Oe),Ce=nt(N=>N.newSessionDraft?.open?an(N.newSessionDraft.bootstrapPendingDirectory??N.newSessionDraft.directoryOverride??""):""),Se=nt(N=>N.newSessionDraft.target),Ke=nt(N=>N.newSessionDraft.selectedProjectId),et=nt(N=>N.currentSessionDirectory),it=Jt(N=>N.homeDirectory),rt=c.useMemo(()=>Pe||Oe||Ce,[Ce,Oe,Pe]),pt=Ae(c.useCallback(N=>{const ke=an(rt||"");return ke?ic(N.contextPanelByDirectory[ke]):null},[rt])),ht=nt(N=>{const ke=an(Pe||Oe||"");if(!ke)return null;for(const Ve of N.availableWorktreesByProject.values()){const Tt=Ve.find(Et=>an(Et.path)===ke)?.branch?.trim();if(Tt)return Tt}return null}),At=Op(rt||null)||fe||ht,jt=a?Se==="chat":Bp(Oe||et,it),we=!jt&&!Z&&!!(b||At||!a&&$e),Xe=c.useMemo(()=>{if(!d)return b??"OpenChamber";const N=ee?.title?.trim();return N&&N.length>0?N:"Untitled Session"},[b,ee?.title,d]),mt=pu(),qe=nt(N=>N.updateSessionTitle),ft=nt(N=>N.archiveSessions),se=nt(N=>N.deleteSessions),[me,Ie]=c.useState(!1),[We,V]=c.useState(!1),Fe=c.useRef(null),[Ye,Qe]=c.useState(""),[xe,st]=c.useState(null),Re=c.useRef(null),ot=c.useCallback(()=>{d&&(Qe(ee?.title?.trim()||Xe),Ie(!0))},[ee?.title,d,Xe]),vt=c.useRef(ot);vt.current=ot;const De=c.useCallback(N=>{N&&(N.focus(),N.select())},[]);c.useEffect(()=>{if(V(!1),st(null),d&&Fe.current===d){Fe.current=null,vt.current();return}Ie(!1),Qe("")},[d]);const gt=c.useCallback(async()=>{if(!d)return;const N=Ye.trim();N&&N!==ee?.title?.trim()&&await qe(d,N),Ie(!1)},[ee?.title,d,Ye,qe]);c.useEffect(()=>{if(!me)return;const N=ke=>{const Ve=ke.target;(!Ve||!Re.current?.contains(Ve))&&gt()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[me,gt]);const Ct=c.useCallback(N=>{N&&Jn(N).then(ke=>{ze[ke.ok?"success":"error"](t(ke.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(t("sessions.sidebar.session.copyId.error")))},[t]),He=c.useCallback(async()=>{if(!d||!rt){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const N=await mt({sessionID:d,directory:rt}).catch(()=>null);if(!N){ze.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(N.length===0){ze.error(t("sessions.sidebar.session.export.nothingToExport"));return}const ke=gu(N,ee?.title??null),Ve=xu(ee?.title??null);await bu(ke,Ve)||yu(ke,Ve),ze.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,mt,rt,t]),Ue=wu(),lt=c.useMemo(()=>vu(Ue),[Ue]),_e=c.useCallback(N=>{d&&uf({entry:N,t,session:{id:d,title:ee?.title,directory:Oe??rt},loadRecords:async()=>{if(!rt)return null;try{return await mt({sessionID:d,directory:rt})}catch{return null}},onLoadFailed:()=>ze.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,mt,rt,Oe,t]),Ge=c.useCallback(N=>lt.map(ke=>s.jsxs(N,{onClick:()=>_e(ke),children:[s.jsx(Xr,{icon:ke.icon,iconSrc:ke.iconSrc,className:"mr-1 size-4"}),ke.action.label]},`${ke.guest.id}:${ke.action.id}`)),[lt,_e]),Je=h?.type==="busy"||h?.type==="retry",at=c.useCallback(()=>{if(!d||!Oe||Je||f)return;const N=us.getState().activeSessions,ke=N.find(Tt=>Tt.id===d);if(!ke)return;const Ve=[],dt=[d];for(let Tt=0;Tt<dt.length;Tt+=1){const Et=dt[Tt];for(const kt of N)kt.parentID===Et&&(Ve.push(kt),dt.push(kt.id))}ua({kind:"quick",root:ke,descendants:Ve,sourceDirectory:Oe,messages:da(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Je,f,Oe,t]),Nt=c.useCallback(async()=>{if(!xe)return;const N=xe.action,ke=[xe.sessionId,...Gd(xe.sessionId,[],N==="delete")];if(st(null),(N==="archive"?await ft(ke):await se(ke)).failedIds.length>0){ze.error(t(N==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}ze.success(t(N==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ft,se,xe,t]),Bt=Ae(N=>N.openGuestPageId),Ft=Fa(N=>N.guests.find(ke=>ke.id===Bt)),Qt=Ae(N=>N.isScheduledTasksDialogOpen),Mt=Ae(N=>N.isArchivePageOpen),Gt=Ae(N=>N.isUsageStatsPageOpen),$t=Ae(N=>N.worktreesPageProjectId),Zt=Ae(N=>N.isMultiRunLauncherOpen),ts=zt(N=>{if(!$t)return null;const ke=N.projects.find(Ve=>Ve.id===$t);return ke?.label?.trim()||ke?.path?.split("/").pop()||null}),Ot=c.useMemo(()=>Ft?{title:Ft.pageTitle??Ft.name,subtitle:null}:Qt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:Mt?{title:t("sessions.archivePage.title"),subtitle:null}:Gt?{title:t("usageStats.title"),subtitle:null}:$t?{title:t("sessions.worktreesPage.title",{project:ts??""}),subtitle:null}:Zt?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[Ft,Mt,Zt,Qt,Gt,t,$t,ts]),Dt=c.useMemo(()=>an(rt||x?.path||""),[x?.path,rt]),Pt=oy(),fs=La(N=>N.planModeEnabled),Ts=nt(N=>N.isSessionPlanAvailable),xn=fs&&d?Ts(d):!1,ns=c.useRef("");c.useEffect(()=>{if(!fs||!d)return;const N=`${d||"none"}:${Oe||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;ns.current!==N&&(ns.current=N)},[fs,xn,ee?.slug,ee?.created,d,Oe]);const In=c.useCallback(()=>{jn("desktop_open_draft_mini_chat_window",{directory:jt?"":Ce,projectId:jt?null:Ke,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open draft mini chat window",N)})},[Ce,Ke,jt]),to=c.useCallback(()=>{if(a){In();return}d&&jn("desktop_open_session_mini_chat_window",{sessionId:d,directory:Oe||an(et||"")||Pe,apiBaseUrl:mn(),clientToken:Ur()}).catch(N=>{console.warn("[header] failed to open session mini chat window",N)})},[d,In,a,et,Oe,Pe]),Tn=c.useCallback(()=>{const N=an(rt||"");if(!N)return;const ke=Ae.getState().contextPanelByDirectory[N];if(ic(ke)==="context"){r(N);return}n(N)},[r,n,rt]),er=pt==="context",En=zo,Xs=c.useMemo(()=>g&&R&&!C?"88px":w?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!g||T)&&!U?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[g,C,R,w,U,T]);ct.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Xs)},[Xs]);const rn=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";ct.useEffect(()=>{if(!g||!R){v(!1);return}let N=!1;const ke=async()=>{try{const dt=await jn("desktop_is_window_fullscreen");N||v(dt===!0)}catch{N||v(!1)}},Ve=()=>{ke()};return ke(),window.addEventListener("openchamber:window-resized",Ve),()=>{N=!0,window.removeEventListener("openchamber:window-resized",Ve)}},[g,R]);const tr=c.useMemo(()=>!g||!R||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[g,R,F]),sr=c.useMemo(()=>{if(!(g&&!T||U)&&!(T&&D==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[g,U,T,D]),ws=c.useCallback(()=>{if(typeof document>"u")return;const N=m.current?.getBoundingClientRect().height;N&&document.documentElement.style.setProperty("--oc-header-height",`${N}px`)},[]);ct.useEffect(()=>{if(typeof window>"u")return;ws();const N=m.current;if(!N||typeof ResizeObserver>"u")return()=>{};let ke=0;const Ve=()=>{ke||(ke=requestAnimationFrame(()=>{ke=0,ws()}))},dt=new ResizeObserver(Ve);return dt.observe(N),window.addEventListener("resize",Ve),window.addEventListener("orientationchange",Ve),()=>{ke&&cancelAnimationFrame(ke),dt.disconnect(),window.removeEventListener("resize",Ve),window.removeEventListener("orientationchange",Ve)}},[ws]),ct.useEffect(()=>{ws()},[ws,y,tr]);const Rn=c.useCallback(async N=>{const ke=N.target;ke.closest(".app-region-no-drag")||ke.closest("button, a, input, select, textarea")||N.button===0&&g&&await th()},[g]),Es=c.useCallback(N=>Hn(Jr(N,i)),[i]);Fp({rename_current_session:()=>{if(!d||y)return!1;ot()},toggle_services_menu:()=>{if(I){P(!1);return}P(!0),z()}});const nr=s.jsxs(s.Fragment,{children:[Pt?s.jsx(ny,{projectRef:Pt.projectRef,directory:Pt.directory,className:"mr-2"}):null,s.jsx(Tb,{directory:Dt,className:"mr-1"}),g?s.jsx(Iy,{isDesktopApp:g,currentInstanceLabel:A,currentInstanceIsLocal:K,isDesktopServicesOpen:I,setIsDesktopServicesOpen:P,refreshCurrentInstanceLabel:z,shortcutLabel:Es,remoteUpdateInfo:he,remoteUpdateChecking:Te,remoteUpdateError:pe,onOpenRemoteUpdate:ue}):null]}),rr=S&&(a||!!d),kr=c.useCallback(({session:N,open:ke,isActive:Ve,select:dt,closeOtherTabs:Tt,components:Et})=>{const{Item:kt,Separator:Ht}=Et,os=Ve&&!U&&!jt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(kt,{onClick:()=>{Ve||dt(),Fe.current=N.id},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:N.id,directory:N.directory,open:ke,Item:kt}),s.jsxs(kt,{onClick:()=>Ct(N.id),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ht,{}),Ve?s.jsxs(kt,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,Ve?Ge(kt):null,os?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(kt,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ht,{}),s.jsxs(kt,{onClick:Tt,children:[s.jsx(O,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ht,{}),s.jsxs(kt,{onClick:()=>st({action:"archive",sessionId:N.id}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(kt,{className:"text-destructive focus:text-destructive",onClick:()=>st({action:"delete",sessionId:N.id}),children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[Ct,ee,He,jt,Je,f,U,at,Ge,Oe,t]),or=()=>s.jsxs("div",{onMouseDown:Rn,className:Me("app-region-drag relative flex h-12 select-none items-center",T&&D==="right"?"pr-0":"pr-3",tr),style:sr,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:rn}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Ot?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Ae.getState().closeMainSurfaces(),children:s.jsx(O,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ot.title}),Ot.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Ot.subtitle}):null]})]}):U||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[Q?s.jsx(O,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):a?null:s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Xe}),we?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,At?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:At})]}):null,!a&&$e?s.jsxs("span",{className:Me("inline-flex min-w-0 items-center gap-0.5",$e==="attention"||$e==="invalid"||$e==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(O,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Le})]}):null]}):null]}),s.jsx("div",{className:Me("flex h-[18px] shrink-0 items-center justify-center",we?"self-start":"self-center"),children:d&&!a&&!me?s.jsxs(Is,{open:We,onOpenChange:V,onOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(O,{name:"more",className:"size-4"})})}),s.jsxs(Ds,{align:"end",className:"min-w-[190px]",children:[s.jsxs(_t,{onClick:()=>{Fe.current=d},children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:d,directory:Oe,open:We,Item:_t}),s.jsxs(_t,{onClick:()=>d&&Ct(d),children:[s.jsx(O,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{He()},children:[s.jsx(O,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Ge(_t),!U&&!jt&&ee&&!ee.parentId?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(_t,{disabled:!Oe||Je||f,onClick:at,className:"w-full",children:[s.jsx(O,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(wt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Je?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(gs,{}),s.jsxs(_t,{onClick:()=>{d&&st({action:"archive",sessionId:d})},children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(_t,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&st({action:"delete",sessionId:d})},children:[s.jsx(O,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Ql,{align:"start",children:s.jsx("button",{type:"button",className:En,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(O,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(dy,{renderMenu:kr,suppressActiveTabControls:me,onMenuOpenChangeComplete:N=>{!N&&Fe.current&&Fe.current===d&&(Fe.current=null,ot())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:me?s.jsxs("form",{ref:Re,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:N=>N.stopPropagation(),onSubmit:N=>{N.preventDefault(),gt()},children:[s.jsx("input",{ref:De,value:Ye,onChange:N=>Qe(N.target.value),onKeyDown:N=>Ui(N,()=>Ie(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Ie(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):Xe})})})]}),Ot||U||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G&&L?s.jsx(Qx,{reading:Xx(L),contextLimit:L.contextLimit,outputLimit:L.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Tn,pressed:er,className:rr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Dy,{visible:rr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:to,className:Me(En,"mr-1"),Icon:"picture-in-picture-2"}),U?null:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":ne,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:be,className:Me(zo,"mr-1",ne?"text-foreground":"text-muted-foreground/50"),children:s.jsx(O,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{side:"bottom",children:t(de&&!H?je?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":de?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),nr,s.jsx(Ju,{visible:T&&D==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:or()}),s.jsx(bs,{open:xe!==null,onOpenChange:N=>{N||st(null)},children:s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Us,{children:[s.jsx(Bs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Fs,{children:xe?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:Xe}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:Xe})})]}),s.jsxs(An,{children:[s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>st(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{Nt()},children:xe?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(qd,{open:ae,onOpenChange:re,info:he,downloading:!1,downloaded:!1,progress:null,error:pe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Ey(){}const ac=280,lc=264,cc=500,Ry=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=St(),l=Ae(v=>v.sidebarWidth),a=Ae(v=>v.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||ac),p=c.useRef(null),x=c.useRef(null),b=c.useRef(null),k=c.useCallback(v=>Math.min(cc,Math.max(lc,v)),[]),y=c.useCallback(v=>{const R=b.current;R&&(R.style.width=`${v}px`,R.style.minWidth=`${v}px`,R.style.maxWidth=`${v}px`,R.style.setProperty("--oc-left-sidebar-width",`${v}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(p.current=null,x.current=null)},[d]),e)return null;const m=Math.min(cc,Math.max(lc,l||ac)),g=t?m:0,j=v=>{if(t){try{v.currentTarget.setPointerCapture(v.pointerId)}catch{}x.current=v.pointerId,u(!0),h.current=v.clientX,f.current=g,p.current=g,y(g),v.preventDefault()}},S=v=>{if(e||!d||x.current!==v.pointerId)return;const R=v.clientX-h.current,T=k(f.current+R);p.current!==T&&(p.current=T,y(T))},w=v=>{if(x.current!==v.pointerId||e)return;try{v.currentTarget.releasePointerCapture(v.pointerId)}catch{}const R=k(p.current??g);x.current=null,p.current=null,u(!1),a(R)},C=d?p.current??g:g;return s.jsxs("aside",{ref:b,className:Me("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${C}px`,minWidth:`${C}px`,maxWidth:`${C}px`,"--oc-left-sidebar-width":`${d?C:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||g===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Me("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:j,onPointerMove:S,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Me("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(gn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(ps,{children:n})})]})]})},My=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},io="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",Oy=()=>{const t=Ze.c(37),{t:e}=St(),n=Ae(By),r=Ae(Fy),i=Ae(Ly),o=c.useRef(null),l=Hn(Jr("toggle_sidebar",i)),a=_y,{usesFramelessChrome:d,side:u}=Xu(),h=zy;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const L=o.current;if(!L)return;const X=()=>{const I=Math.max(L.getBoundingClientRect().width,L.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(I)}px`)};if(X(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(X);return Y.observe(L),()=>{Y.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),c.useEffect(f,p);const x="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let b;t[2]===Symbol.for("react.memo_cache_sentinel")?(b={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=b):b=t[2];const k="flex items-center gap-2";let y;t[3]!==d||t[4]!==u?(y=d&&u==="left"?s.jsx(Ju,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=y):y=t[5];let m;t[6]!==e||t[7]!==d?(m=d?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,"aria-label":e("header.actions.openAppMenuAria"),className:Me(io,"shrink-0"),children:s.jsx(O,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=m):m=t[8];const g=bt;let j;t[9]!==e?(j=e("header.actions.openSessionsAria"),t[9]=e,t[10]=j):j=t[10];let S,w;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=Me(io,"shrink-0"),w=s.jsx(O,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=w):(S=t[11],w=t[12]);let C;t[13]!==j||t[14]!==n?(C=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":j,className:S,children:w})}),t[13]=j,t[14]=n,t[15]=C):C=t[15];const v=wt,R=e("header.actions.openSessionsWithShortcut",{shortcut:l});let T;t[16]!==R?(T=s.jsx("p",{children:R}),t[16]=R,t[17]=T):T=t[17];let D;t[18]!==v||t[19]!==T?(D=s.jsx(v,{children:T}),t[18]=v,t[19]=T,t[20]=D):D=t[20];let F;t[21]!==g||t[22]!==C||t[23]!==D?(F=s.jsxs(g,{children:[C,D]}),t[21]=g,t[22]=C,t[23]=D,t[24]=F):F=t[24];let B;t[25]!==a||t[26]!==r||t[27]!==e?(B=r?s.jsxs("button",{type:"button",onClick:a,className:Me(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Me(io,"-ml-1 shrink-0"),children:s.jsx(O,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(wt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=B):B=t[28];let E;t[29]!==F||t[30]!==B||t[31]!==y||t[32]!==m?(E=s.jsxs("div",{ref:o,className:k,children:[y,m,F,B]}),t[29]=F,t[30]=B,t[31]=y,t[32]=m,t[33]=E):E=t[33];let $;return t[34]!==E||t[35]!==b?($=s.jsx("div",{className:x,style:b,children:E}),t[34]=E,t[35]=b,t[36]=$):$=t[36],$};function By(t){return t.toggleSidebar}function Fy(t){return t.isSidebarOpen}function Ly(t){return t.shortcutOverrides}function _y(){Ae.getState().closeMainSurfaces(),nt.getState().openNewSessionDraft()}function $y(t){console.warn("[titlebar] failed to open app menu",t)}function zy(t){const e=t.currentTarget.getBoundingClientRect();jn("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch($y)}function pf(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(O,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const dc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Wy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([Lp(t),_p(t)]).catch(Ky);if(d)return;const f=dc(u),p=dc(h);if(!f||!p||p===f)return;const x=n||"",b=p.split("/").filter(Boolean).pop()||p;o({source:"sdk",path:p,projectDirectory:f,branch:x,label:x||b,name:b,worktreeRoot:p,worktreeStatus:"ready",headState:x?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function Ky(){return["",""]}const uc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Vy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},fc=({className:t})=>{const{t:e}=St(),{github:n}=nn(),r=hn(x=>x.status),i=hn(x=>x.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async x=>{if(!(!x||o)){l(!0);try{i(await Vy(n,x))}catch(b){console.error("Failed to switch GitHub account:",b)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),p=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(O,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Me(uc,t),title:f,children:p}):s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(uc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:p})}),s.jsxs(Ds,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(gs,{}),h.map(x=>{const b=x.user,k=!!x.current,y=x.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(_t,{className:"gap-2",disabled:o,onSelect:()=>{k||a(x.id)},children:[b?.avatarUrl?s.jsx("img",{src:b.avatarUrl,alt:b.login?e("header.github.avatarWithLogin",{login:b.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(O,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:b?.name?.trim()||b?.login||"GitHub"}),b?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:b.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),k?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})};class mi extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const hi="/api/walkthrough",gf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),xf=()=>new mi("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Uy=t=>!gf(t)&&(t.ok||t.status===404),Za=async(t,e)=>{if(Uy(t))throw xf();const n=await t.json().catch(()=>null);throw new mi(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},bf=async t=>{if(!gf(t))throw xf();try{return await t.json()}catch{throw new mi("The server returned a malformed walkthrough response")}};async function Hy(t,e,n={}){const r=await ls(hi,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):Za(r,"Failed to load walkthrough")}async function Gy(t,e,n={}){const r=await ls(`${hi}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):Za(r,"Failed to generate walkthrough")}async function qy(t,e){const n=await ls(`${hi}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Za(n,"Failed to cancel walkthrough generation")}async function Yy(t,e,n){const r=await ls(`${hi}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Qy=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,bn=(t,e)=>`${Wt()}\0${t}\0${Qy(e)}`,mc=t=>t instanceof mi?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},$s=new Map,Ir=new Map,Xy=1e3,Jy=Zr()(xb((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[bn(n,r)],selectModel:(n,r,i)=>{const o=bn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[bn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[bn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);if(e().entries[o]?.status==="generating")return;$s.get(o)?.abort();const a=new AbortController;$s.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Hy(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{$s.get(o)===a&&$s.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=bn(n,r);$s.get(o)?.abort();const l=new AbortController;$s.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ir.get(o);d!==void 0&&(clearInterval(d),Ir.delete(o))};a(),Ir.set(o,setInterval(()=>{Yy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Xy));try{const d=await Gy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:mc(d)}}}))}finally{a(),$s.get(o)===l&&$s.delete(o)}},cancel:(n,r)=>{const i=bn(n,r);qy(n,r).catch(()=>{}),$s.get(i)?.abort(),$s.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of $s.values())n.abort();$s.clear();for(const n of Ir.values())clearInterval(n);Ir.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),Zy="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)]",e1=3e4,hc=20,yf=(t,e)=>JSON.stringify([Wt(),t,e]),t1=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},pc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,s1=t=>{const e=Object.entries(t);return e.length<=hc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,hc))},gc=Zr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=yf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<e1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,p=ao.get(`${l}::details`)??(a?null:ao.get(h));if(p&&!o?.force)return p;const x=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??pc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(k=>({entries:s1({...k.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const k=b instanceof Error?b.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??pc(),isLoading:!1,error:k}}})),null}finally{ao.delete(h)}})();return ao.set(h,x),x},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=t1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),n1=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},r1=35e3,Ii=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},Ti=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},xc=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"}},o1=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},i1=[2e3,5e3],a1=600,bc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),wn=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):""},l1=(t,e)=>{const n=wn(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},c1=(t,e)=>`${t}::${e}`,el=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Ei=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=el(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},d1=t=>t.startsWith("pr-"),u1=(t,e)=>{const n=el(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!d1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Tr=new Map,lo=Qr;function f1(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const m1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=St(),d=Ae(N=>N.timeFormatPreference),{github:u}=nn(),h=hn(N=>N.status),f=hn(N=>N.hasChecked),p=Ae(N=>N.setSettingsDialogOpen),x=Ae(N=>N.setSettingsPage),b=nt(N=>N.currentSessionId),k=nt(N=>!!N.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:g}=Nn(),j=Ae(N=>N.openContextSurface),S=Jy(N=>N.requestSource),w=!y&&g>=768&&!kn(),C=c.useCallback(()=>{x("integrations"),p(!0)},[p,x]),v=c.useMemo(()=>c1(t,e),[t,e]),R=c.useMemo(()=>Tr.get(v)??null,[v]),T=Ms(N=>N.ensureEntry),D=Ms(N=>N.setParams),F=Ms(N=>N.startWatching),B=Ms(N=>N.stopWatching),E=Ms(N=>N.refresh),$=Ms(N=>N.updateStatus),[L,X]=c.useState(()=>R?.title??bc(e)),[Y,I]=c.useState(()=>R?.body??""),[P,A]=c.useState(()=>R?.draft??!1),[q,K]=c.useState(()=>R?.additionalContext??""),[te,ae]=c.useState(()=>{const N=typeof R?.targetBaseBranch=="string"?wn(R.targetBaseBranch):"";return N||wn(n)}),[re,he]=c.useState("squash"),[ce,Te]=c.useState(!1),[ve,pe]=c.useState(!1),[Ne,U]=c.useState(!1),[Z,de]=c.useState(!1),[ye,H]=c.useState(!1),[je,Ee]=c.useState(!1),[ge,ne]=c.useState(null),[be,G]=c.useState(""),[z,J]=c.useState(""),[ue,le]=c.useState(!1),[W,M]=c.useState(!1),[_,ee]=c.useState(()=>Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r})),[oe,fe]=c.useState(!1),{detectedUpstream:ie,upstreamBranches:Le}=f1(t,u);c.useEffect(()=>{fe(!1)},[t]);const $e=i.some(N=>N.name==="upstream"),Oe=!!(t&&e&&n&&(e!==n||($e||ie!==null))),Q=c.useMemo(()=>Xo(t,e,_?.name??null),[t,e,_?.name]),Ce=Ms(N=>N.entries[Q]),Se=Ce?.isLoading??!1,Ke=Ce?.status??null,et=Ce?.error??null,it=Ce?.isInitialStatusResolved??!1,rt=c.useMemo(()=>{const N=oe?null:_?.name?.trim()||null,ke=new Set;for(const Tt of o){const Et=l1(Tt,N);!Et||Et==="HEAD"||ke.add(Et)}if(oe)for(const Tt of Le)Tt&&Tt!=="HEAD"&&ke.add(Tt);const Ve=wn(n);Ve&&Ve!=="HEAD"&&ke.add(Ve);const dt=wn(te);return dt&&dt!=="HEAD"&&ke.add(dt),Array.from(ke).sort((Tt,Et)=>Tt.localeCompare(Et))},[n,o,_?.name,te,Le,oe]);c.useEffect(()=>{if(i.length===0){_&&ee(null);return}(!_||!i.some(N=>N.name===_.name))&&ee(Ei(i,{selectedRemoteName:R?.selectedRemoteName,trackingBranch:r}))},[R?.selectedRemoteName,i,_,r]),c.useEffect(()=>{const N=wn(n);if(!te&&N){ae(N);return}if(rt.length!==0&&!rt.includes(te)){const ke=rt.includes(N)?N:rt[0];ke&&ae(ke)}},[rt,n,te]);const[pt,ht]=c.useState(()=>R?.activeSegment??"overview"),[tt,At]=c.useState(new Set),[jt,we]=c.useState(new Set),Xe=c.useRef(new Set),mt=c.useRef(null),qe=c.useRef(!1),ft=c.useRef(new Set),se=c.useRef([]);c.useEffect(()=>{ie&&!$e&&fe(!0)},[ie,$e]),c.useEffect(()=>{oe&&ie?.defaultBranch&&ae(ie.defaultBranch)},[oe,ie?.defaultBranch]);const me=Ke?.pr??null,Ie=me?.state==="merged"||me?.state==="closed",We=Ie?null:me,V=We?yf(t,We.number):null,Fe=gc(N=>V?N.entries[V]:void 0),Ye=gc(N=>N.ensure),Qe=Fe?.result??null,xe=Fe?.isLoading??!1,st=c.useCallback(N=>{ht(N);const ke=Tr.get(v);ke&&Tr.set(v,{...ke,activeSegment:N})},[v]);c.useEffect(()=>{!We||!u?.prContext||pt==="overview"||Ye(u,t,We.number,{includeCheckDetails:pt==="checks",sourceRepo:Ke?.repo??null})},[pt,t,Ye,u,We,Ke?.repo]);const Re=Ke?.checks??null,ot=(Re?.pending??0)>0,vt=Qe?.checkRuns??null,De=Qe?.fetchedAt;c.useEffect(()=>{if(!vt||vt.length===0)return;const N=n1(vt);$(Q,ke=>{if(!ke?.pr||typeof De=="number"&&typeof ke.fetchedAt=="number"&&De<ke.fetchedAt)return ke;const Ve=ke.checks;return Ve&&Ve.state===N.state&&Ve.total===N.total&&Ve.success===N.success&&Ve.failure===N.failure&&Ve.pending===N.pending&&Ve.inProgress===N.inProgress&&Ve.queued===N.queued&&Ve.startedAt===N.startedAt?ke:{...ke,checks:N,...typeof De=="number"?{fetchedAt:De}:{}}})},[vt,De,Q,$]),c.useEffect(()=>{if(pt!=="checks"||!ot||!me||!u?.prContext)return;const N=window.setInterval(()=>{Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null,force:!0})},r1);return()=>window.clearInterval(N)},[pt,ot,t,Ye,u,me,Ke?.repo]);const[gt,Ct]=c.useState(()=>Date.now());c.useEffect(()=>{if(!ot)return;Ct(Date.now());const N=window.setInterval(()=>Ct(Date.now()),3e4);return()=>window.clearInterval(N)},[ot]);const He=me?`${t}#${me.number}`:null,Ue=!!(He&&ge===He);c.useEffect(()=>{if(!u?.prContext||!me||typeof me.body=="string"&&me.body.length>0)return;const N=`${t}#${me.number}`;if(Xe.current.has(N))return;Xe.current.add(N),ne(N);let ke=!1;return Ye(u,t,me.number,{sourceRepo:Ke?.repo??null}).then(Ve=>{if(ke)return;const dt=Ve?.pr;dt&&$(Q,Tt=>!Tt?.pr||Tt.pr.number!==me.number?Tt:{...Tt,pr:{...Tt.pr,body:dt.body||""}})}).catch(()=>{}).finally(()=>{ke||ne(Ve=>Ve===N?null:Ve)}),()=>{ke=!0}},[t,Ye,u,me,Q,Ke?.repo,$]),c.useEffect(()=>{if(!me){Ee(!1),G(""),J(""),mt.current=null;return}const N=mt.current!==null&&mt.current!==me.number;N&&Ee(!1),(!je||N)&&(G(me.title||""),J(me.body||"")),mt.current=me.number},[je,me]);const lt=c.useCallback(N=>{if(!N)return"";const ke=Date.parse(N);return Number.isFinite(ke)?Su(ke,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):N},[d]),_e=c.useMemo(()=>{const N=h?.user?.login;return typeof N=="string"?N.trim():""},[h]),Ge=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),Je=c.useCallback(N=>{const ke=_e.toLowerCase(),Ve=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return N.replace(Ve,(dt,Tt,Et)=>{const kt=`@${Et}`,Ht=Et.toLowerCase();return`${Tt}[${kt}](https://github.com/${Ht}${ke&&Ht===ke?"?oc-self-mention=1":""})`})},[_e]),at=c.useMemo(()=>{const N=(Qe?.issueComments??[]).map(dt=>({id:`issue-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),ke=(Qe?.reviewComments??[]).map(dt=>({id:`review-${dt.id}`,body:dt.body||"",authorName:dt.author?.name||dt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:dt.author?.login||null,avatarUrl:dt.author?.avatarUrl||null,createdAt:dt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:dt.path||null,line:dt.line??null})),Ve=[...N,...ke];return Ve.sort((dt,Tt)=>{const Et=dt.createdAt?Date.parse(dt.createdAt):0,kt=Tt.createdAt?Date.parse(Tt.createdAt):0,Ht=Number.isFinite(Et)?Et:0,os=Number.isFinite(kt)?kt:0;return Ht-os}),Ve},[Qe,a]),Nt=c.useCallback(()=>{const N=b??(k?"draft":null);return N?{directory:t,sessionKey:N}:(ze.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,k,a]),Bt=c.useCallback((N,ke)=>{const Ve=ke.authorLogin?`@${ke.authorLogin}`:ke.authorName,dt=ke.path?` · ${ke.path}${ke.line?`:${ke.line}`:""}`:"";Yi.getState().addDraft(N,{source:"pr-comment",fileLabel:`PR #${me?.number??""} ${Ve}${dt}`,startLine:ke.line??0,endLine:ke.line??0,code:ke.body,language:"markdown",text:""})},[me?.number]),Ft=c.useCallback((N,ke)=>{const Ve=N.status||"unknown",dt=N.conclusion??void 0,Tt=dt?`${Ve} / ${dt}`:Ve,Et=N.app?.name||N.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:ke?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[ke?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:N.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Et?`${Et} · ${Tt}`:Tt})]}),N.detailsUrl?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:N.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),N.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:N.output.title}):null,N.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:N.output.summary}):null,N.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:N.output.text}):null,Array.isArray(N.annotations)&&N.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",N.annotations.length>20?` (showing 20/${N.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:N.annotations.slice(0,20).map((kt,Ht)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[kt.title||kt.level||"Issue",kt.path?` · ${kt.path}`:"",typeof kt.startLine=="number"?`:${kt.startLine}`:"",typeof kt.endLine=="number"&&kt.endLine!==kt.startLine?`-${kt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:kt.message}),kt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:kt.rawDetails}):null]},`${kt.path||"file"}:${kt.startLine||Ht}:${Ht}`))})]}):null,N.job?.steps&&N.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:N.job.steps.map((kt,Ht)=>{const os=(kt.conclusion||"").toLowerCase(),Xt=os&&!["success","neutral","skipped"].includes(os),Hs=`${N.id??"run"}:${N.job?.jobId??"job"}:${kt.number??Ht}:${kt.name}`,vs=tt.has(Hs);return Xt?s.jsxs(Qi,{open:vs,children:[s.jsxs("button",{type:"button",onClick:()=>{At(gi=>{const Mn=new Set(gi);return Mn.has(Hs)?Mn.delete(Hs):Mn.add(Hs),Mn})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Xt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[vs?s.jsx(O,{name:"arrow-down-s",className:"size-4"}):s.jsx(O,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]}),s.jsx(Xi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof kt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",kt.number]}):null,kt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",kt.status]}):null,kt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",kt.conclusion]}):null,kt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",lt(kt.startedAt)]}):null,kt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",lt(kt.completedAt)]}):null]})})]},Hs):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:kt.name}),kt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:kt.conclusion}):null]},Hs)})})]}):null]})},[tt,lt,a]),[Qt,Mt]=c.useState(!1),[Gt,$t]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Nt();if(N){Mt(!0);try{const ke=await Ye(u,t,me.number,{includeCheckDetails:!0,sourceRepo:Ke?.repo??null});if(!ke){ze.error(a("gitView.pr.toast.loadChecksFailed"));return}const dt=(ke.checkRuns??[]).filter(Et=>Ti(Et.conclusion));if(dt.length===0){ze.message(a("gitView.pr.toast.noFailedChecks"));return}const Tt=Yi.getState();for(const Et of dt){const kt=(Et.annotations??[]).map(Xt=>[[Xt.level,Xt.title].filter(Boolean).join(" "),Xt.path?`${Xt.path}${typeof Xt.startLine=="number"?`:${Xt.startLine}`:""}`:null,Xt.message,Xt.rawDetails].filter(Boolean).join(`
3
+ `)),Ht=(Et.job?.steps??[]).filter(Xt=>Ti(Xt.conclusion)).map(Xt=>`step ${Xt.number??"?"}: ${Xt.name} → ${Xt.conclusion}`),os=[`check: ${Et.job?.workflowName?`${Et.job.workflowName} / ${Et.name}`:Et.name}`,`status: ${Et.status??"unknown"} / ${Et.conclusion??"unknown"}`,Et.detailsUrl?`url: ${Et.detailsUrl}`:null,Et.output?.title?`title: ${Et.output.title}`:null,Et.output?.summary?`summary:
4
+ ${Et.output.summary}`:null,Ht.length>0?`failed steps:
5
+ ${Ht.join(`
6
+ `)}`:null,kt.length>0?`annotations:
7
+ ${kt.join(`
8
+ ---
9
+ `)}`:null].filter(Boolean).join(`
10
+
11
+ `);Tt.addDraft(N,{source:"pr-check",fileLabel:`PR #${me.number} · ${Et.name}`,startLine:0,endLine:0,code:os,language:"text",text:""})}}catch(ke){const Ve=ke instanceof Error?ke.message:String(ke);ze.error(a("gitView.pr.toast.loadChecksFailed"),{description:Ve})}finally{Mt(!1)}}},[t,Ye,u,me,Nt,Ke?.repo,a]),ts=c.useCallback(async()=>{if(!u?.prContext){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!me)return;const N=Nt();if(N){$t(!0);try{if(!await Ye(u,t,me.number,{sourceRepo:Ke?.repo??null})){ze.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(at.length===0){ze.message(a("gitView.pr.toast.noPrComments"));return}for(const Ve of at)Bt(N,Ve)}catch(ke){const Ve=ke instanceof Error?ke.message:String(ke);ze.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:Ve})}finally{$t(!1)}}},[Bt,t,Ye,u,me,Nt,Ke?.repo,a,at]),Ot=c.useCallback(async N=>{const ke=Nt();ke&&Bt(ke,N)},[Bt,Nt]),Dt=c.useCallback(async N=>{await E(Q,N)},[Q,E]),[Pt,fs]=c.useState(!1),Ts=c.useRef(!0);c.useEffect(()=>(Ts.current=!0,()=>{Ts.current=!1}),[]);const xn=c.useCallback(async()=>{if(Pt)return;fs(!0);const N=Date.now();try{await Dt({force:!0})}finally{const ke=a1-(Date.now()-N);ke>0&&await new Promise(Ve=>window.setTimeout(Ve,ke)),Ts.current&&fs(!1)}},[Pt,Dt]),ns=c.useCallback(()=>{se.current.forEach(N=>{window.clearTimeout(N)}),se.current=i1.map(N=>window.setTimeout(()=>{Dt({force:!0,silent:!0,markInitialResolved:!0})},N))},[Dt]);c.useEffect(()=>{if(!u?.prStatus||!Oe||i.length<=1||qe.current||Ke?.pr)return;const N=`${v}::${_?.name??""}`;if(ft.current.has(N))return;ft.current.add(N);const ke=u1(i,r).filter(Tt=>Tt.name!==_?.name);if(ke.length===0)return;let Ve=!1;return(async()=>{for(const Tt of ke){if(Ve)return;try{if(!(await u.prStatus(t,e,Tt.name))?.pr)continue;if(Ve)return;ee(kt=>kt?.name===Tt.name?kt:Tt);return}catch{}}})(),()=>{Ve=!0}},[e,Oe,t,u,i,_?.name,v,Ke?.pr,r]),c.useEffect(()=>{T(Q),D(Q,{directory:t,branch:e,remoteName:_?.name??null,canShow:Oe,github:u,githubAuthChecked:f,githubConnected:h?.connected??null})},[e,Oe,t,T,u,f,h?.connected,Q,_?.name,D]),c.useEffect(()=>(F(Q),()=>{B(Q)}),[Q,F,B]),c.useEffect(()=>{const N=Tr.get(v)??null;X(N?.title??bc(e)),I(N?.body??""),A(N?.draft??!1),ae(N?.targetBaseBranch?wn(N.targetBaseBranch):wn(n));const ke=Ei(i,{selectedRemoteName:N?.selectedRemoteName,trackingBranch:r});ee(Ve=>Ve?.name===ke?.name?Ve:ke)},[n,e,i,v,r]),c.useEffect(()=>{Dt({markInitialResolved:!0})},[Q,Dt]),c.useEffect(()=>{!Oe||!_?.name||Dt({force:!0,silent:!0,markInitialResolved:!0})},[Oe,Dt,_?.name]),c.useEffect(()=>{const N=Ke?.resolvedRemoteName?.trim();if(!N||qe.current)return;const ke=i.find(Ve=>Ve.name===N);ke&&ee(Ve=>Ve?.name===ke.name?Ve:ke)},[i,Ke?.resolvedRemoteName]),c.useEffect(()=>{const N=()=>{const Ve=Ms.getState().entries[Q]?.lastRefreshAt??0;Date.now()-Ve>6e4&&Dt({force:!0,silent:!0})},ke=()=>{document.visibilityState==="visible"&&N()};return window.addEventListener("focus",N),document.addEventListener("visibilitychange",ke),()=>{window.removeEventListener("focus",N),document.removeEventListener("visibilitychange",ke)}},[Q,Dt]),c.useEffect(()=>{f&&h?.connected===!1&&Dt({force:!0,silent:!0,markInitialResolved:!0})},[f,h,Dt]),c.useEffect(()=>{!t||!e||Tr.set(v,{title:L,body:Y,draft:P,additionalContext:q,targetBaseBranch:te,selectedRemoteName:_?.name,activeSegment:pt})},[v,L,Y,P,q,te,_?.name,t,e,pt]),c.useEffect(()=>{const N=se.current;return()=>{N.forEach(ke=>{window.clearTimeout(ke)}),se.current=[]}},[]);const In=c.useCallback(async()=>{if(!ce&&t){Te(!0);try{const ke={base:oe&&ie?.defaultBranchSha?ie.defaultBranchSha:te,head:e};q&&(ke.context=q);const Ve=await $p(t,ke);Ve.title?.trim()&&X(Ve.title.trim()),Ve.body?.trim()&&I(Ve.body.trim()),l?.()}catch(N){const ke=N instanceof Error?N.message:String(N);ze.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:ke})}finally{Te(!1)}}},[q,e,ie?.defaultBranchSha,t,ce,l,te,a,oe]),to=c.useCallback(async()=>{if(!u?.prCreate){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}const N=L.trim();if(!N){ze.error(a("gitView.pr.toast.titleRequired"));return}const ke=te.trim();if(!ke){ze.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!oe&&ke===e){ze.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}pe(!0);try{const Ve=el(r),dt=oe&&ie,Tt=await u.prCreate({directory:t,title:N,head:e,base:ke,...Y.trim()?{body:Y}:{},draft:P,...dt?{targetRepo:{owner:ie.owner,repo:ie.repo},headRemote:"origin"}:{..._?{remote:_.name}:{},...Ve&&Ve!==_?.name?{headRemote:Ve}:{}}});ze.success(a("gitView.pr.toast.prCreated")),$(Q,Et=>Et&&{...Et,pr:Tt}),await Dt({force:!0}),ns()}catch(Ve){const dt=Ve instanceof Error?Ve.message:String(Ve);ze.error(a("gitView.pr.toast.createPrFailed"),{description:dt})}finally{pe(!1)}},[Y,e,ie,t,P,u,Q,Dt,ns,_,te,L,r,$,oe,a]),Tn=c.useCallback(async N=>{if(!u?.prMerge){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}de(!0);try{const ke=await u.prMerge({directory:t,number:N.number,method:re});ke.merged?ze.success(a("gitView.pr.toast.prMerged")):ze.message(a("gitView.pr.toast.prNotMerged"),{description:ke.message||a("gitView.pr.notMergeable")}),await Dt({force:!0}),ns()}catch(ke){const Ve=ke instanceof Error?ke.message:String(ke);ze.error(a("gitView.pr.toast.mergeFailed"),{description:Ve}),N.url&&lo(N.url)}finally{de(!1)}},[t,u,re,Dt,ns,a]),er=c.useCallback(async N=>{if(!u?.prReady){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}H(!0);try{await u.prReady({directory:t,number:N.number}),ze.success(a("gitView.pr.toast.markedReady")),await Dt({force:!0}),ns()}catch(ke){const Ve=ke instanceof Error?ke.message:String(ke);ze.error(a("gitView.pr.toast.markReadyFailed"),{description:Ve}),N.url&&lo(N.url)}finally{H(!1)}},[t,u,Dt,ns,a]),En=c.useCallback(async N=>{if(!u?.prUpdate){ze.error(a("gitView.pr.toast.githubApiUnavailable"));return}const ke=be.trim();if(!ke){ze.error(a("gitView.pr.toast.titleRequired"));return}U(!0);try{const Ve=await u.prUpdate({directory:t,number:N.number,title:ke,body:z});$(Q,dt=>dt&&{...dt,pr:{...dt.pr??N,...Ve}}),Ee(!1),ze.success(a("gitView.pr.toast.prUpdated")),await Dt({force:!0}),ns()}catch(Ve){const dt=Ve instanceof Error?Ve.message:String(Ve);ze.error(a("gitView.pr.toast.updatePrFailed"),{description:dt})}finally{U(!1)}},[t,z,be,u,Q,Dt,ns,$,a]);if(!Oe)return s.jsx("section",{className:"border-0 bg-transparent rounded-none",children:s.jsxs("div",{className:"space-y-1 pt-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("gitView.pullRequest.title")}),s.jsx(fc,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const Xs=Ke?.repo?.url||null,rn=oe&&ie?.url?ie.url:Xs,on=!!Ke?.canMerge,tr=!!Ke?.connected,sr=f&&Ke?.connected===!1,ws=o1(Ke),Rn=ws?`var(--pr-${ws})`:"var(--status-info)",Es=ws==="draft"?"git-pr-draft":ws==="merged"?"git-merge":ws==="closed"?"git-close-pull-request":"git-pull-request",nr=me?[`${me.state}${me.draft?" (draft)":""}`,me.mergeable===!1?a("gitView.pr.notMergeable"):null,me.state==="open"&&typeof me.mergeableState=="string"&&me.mergeableState&&me.mergeableState!=="unknown"?me.mergeableState:null].filter(Boolean).join(" · "):"",rr=Re?Re.total>0?`${Re.success}/${Re.total} ${a("gitView.pr.checks.label")}`:`${Re.state} ${a("gitView.pr.checks.label")}`:"";return s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[s.jsxs("div",{className:"px-0 py-3 border-b border-border/40 flex flex-col gap-1",children:[s.jsxs("div",{className:"@container/pr-actions flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[me?s.jsxs(ut,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{lo(me.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(O,{name:Es,className:"size-4 shrink-0",style:{color:Rn}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(O,{name:Es,className:"size-4 shrink-0",style:{color:"var(--surface-muted-foreground)"}}),s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground truncate",children:a("gitView.pullRequest.title")}),me?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",me.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[me&&w?s.jsxs(ut,{variant:"outline",size:"sm",className:Me("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",Zy),onClick:()=>{S(t,{kind:"pr",number:me.number,sourceRepo:Ke?.repo?{owner:Ke.repo.owner,repo:Ke.repo.repo}:void 0}),j(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(O,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Se||Pt,onClick:()=>{xn()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Se||Pt?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(O,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(fc,{className:"h-7 w-7"})]})]}),me?s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{style:{color:Rn},children:nr}),Re?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${xc(Re.state)}`}),rr]}):null,r&&_&&r.split("/")[0]!==_.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",_.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[on&&me.draft&&me.state==="open"?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>er(me),disabled:ye||Z||Ne||je,"aria-label":a("gitView.pr.actions.markReadyAria"),children:ye?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,on?s.jsxs(s.Fragment,{children:[s.jsxs(ks,{value:re,onValueChange:N=>he(N),disabled:Z||me.state!=="open",children:[s.jsx(Cs,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(hs,{})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(Yt,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(Yt,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>Tn(me),disabled:Z||ye||me.state!=="open"||me.draft||Ne||je,"aria-label":a("gitView.pr.actions.mergePrAria"),children:Z?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"git-merge",className:"size-4"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[sr?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:C,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,et?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.statusUnavailable")}),s.jsx("div",{className:"typography-meta text-muted-foreground break-words",children:et}),rn?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:rn,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!me&&!it&&!et&&!sr?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):me&&!Ie?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(Yd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Re&&Re.total>0?`${a("gitView.pr.segment.checks")} ${Re.success}/${Re.total}`:a("gitView.pr.segment.checks"),icon:Re?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${xc(Re.state)}`}):void 0},{id:"comments",label:Qe?`${a("gitView.pr.segment.comments")} ${(Qe.issueComments?.length??0)+(Qe.reviewComments?.length??0)}`:a("gitView.pr.segment.comments")}],activeId:pt,onSelect:N=>st(N),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),pt==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[on&&me.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,on?null:s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.noMergePermission")}),s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:je?s.jsx(un,{value:be,onChange:N=>G(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:me.title})}),me.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:je?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Ee(!1),G(me.title||""),J(me.body||"")},disabled:Ne,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(O,{name:"close",className:"size-4"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>En(me),disabled:Ne||!be.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:Ne?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"check",className:"size-4"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Ee(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(O,{name:"edit",className:"size-4"})})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),je?s.jsx(fr,{value:z,onChange:N=>J(N.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m}):null,je?null:me.body?.trim()?s.jsx(Rl,{content:me.body,className:"typography-markdown-body min-w-0 text-muted-foreground break-words",enableFileReferences:!1}):s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:a(Ue?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,pt==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Re&&Re.total>0?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted/40",children:[Re.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Re.success/Re.total*100}%`}}):null,Re.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Re.failure/Re.total*100}%`}}):null,Re.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Re.pending/Re.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Re.success,"/",Re.total," ",a("gitView.pr.checks.label")]}),(Re.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}),Ii(Re.startedAt,void 0,gt)]}):null]}):null,Re?.failure?s.jsxs(ut,{variant:"outline",size:"sm",className:"w-fit gap-1.5 border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",onClick:Zt,disabled:Qt,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[Qt?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-4"}),a("gitView.pr.actions.resolveFailedChecks")]}):null,(Qe?.checkRuns?.length??0)>0?s.jsx("div",{className:"flex flex-col gap-1.5",children:(Qe?.checkRuns??[]).map((N,ke)=>{const Ve=`${N.id??"run"}:${N.name}:${ke}`,dt=N.status==="in_progress",Tt=N.status==="queued",Et=Ti(N.conclusion),kt=jt.has(Ve),Ht=!!(N.output?.title||N.output?.summary||N.output?.text||(N.annotations?.length??0)>0||(N.job?.steps?.length??0)>0||N.detailsUrl),os=N.job?.workflowName,Xt=dt?Ii(N.startedAt,void 0,gt):Ii(N.startedAt,N.completedAt);return s.jsxs("div",{className:Me("rounded-md border border-border/40",Et&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!Ht,onClick:()=>{we(Hs=>{const vs=new Set(Hs);return vs.has(Ve)?vs.delete(Ve):vs.add(Ve),vs})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[dt?s.jsx(O,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):Tt?s.jsx(O,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Et?s.jsx(O,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(O,{name:"checkbox-circle",className:"size-4 shrink-0 text-[var(--status-success)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:os&&os!==N.name?`${os} / ${N.name}`:N.name}),Xt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Xt}):null,Ht?s.jsx(O,{name:"arrow-down-s",className:Me("size-4 shrink-0 text-muted-foreground transition-transform",kt&&"rotate-180")}):null]}),kt&&Ht?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:Ft(N,{hideHeader:!0})}):null]},Ve)})}):xe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.checkDetails.empty")})]}):null,pt==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[at.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ut,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)]",onClick:ts,disabled:Gt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Gt?s.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,at.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:at.map((N,ke)=>{const Ve=(N.authorName||"?").charAt(0).toUpperCase(),dt=ke===at.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[dt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:N.avatarUrl?s.jsx("img",{src:N.avatarUrl,alt:N.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:Ve})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1 typography-micro text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-1 sm:gap-y-1",children:[s.jsxs("span",{className:"text-foreground whitespace-nowrap",children:[N.authorName,N.authorLogin&&N.authorLogin!==N.authorName?` · @${N.authorLogin}`:""]}),N.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:lt(N.createdAt)}):null,s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs(ut,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{Ot(N)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(O,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(wt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[N.context,N.path?` · ${N.path}`:"",N.line?`:${N.line}`:""]}),s.jsx(Rl,{content:Je(N.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",Ge].filter(Boolean).join(" "),enableFileReferences:!1})]})]},N.id)})})}):xe&&!Qe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.loading.loading")]}):s.jsx("div",{className:"py-6 text-center typography-micro text-muted-foreground",children:a("gitView.pr.comments.empty")})]}):null]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[me&&Ie?s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border/60 bg-surface-muted/40 px-2.5 py-2",children:[s.jsx(O,{name:me.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Rn}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:me.state==="merged"?a("gitView.pr.history.merged",{number:me.number,base:me.base||te}):a("gitView.pr.history.closed",{number:me.number})}),s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{lo(me.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(O,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",te," ",s.jsxs("span",{className:"opacity-60",children:["(",oe&&ie?"upstream":"remote",")"]})]})]}),rn?s.jsx(ut,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:rn,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(O,{name:"external-link",className:"size-4"}),a("gitView.pr.actions.repo")]})}):null]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.title")}),s.jsx(un,{value:L,onChange:N=>X(N.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),rt.length>0?s.jsxs(ks,{value:te,onValueChange:ae,children:[s.jsx(Cs,{size:"lg",children:s.jsx(hs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(Ns,{children:rt.map(N=>s.jsx(Yt,{value:N,children:N},N))})]}):s.jsx(un,{value:te,onChange:N=>ae(N.target.value),placeholder:a("gitView.pr.placeholder.main")})]}),s.jsxs("label",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.description")}),s.jsx(fr,{value:Y,onChange:N=>I(N.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:m?"on":"off",autoCapitalize:m?"sentences":"off",spellCheck:m})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":P,onClick:()=>A(N=>!N),onKeyDown:N=>{(N.key===" "||N.key==="Enter")&&(N.preventDefault(),A(ke=>!ke))},children:[s.jsx(hr,{size:"sm",checked:P,onChange:N=>A(N),ariaLabel:a("gitView.pr.actions.toggleDraftAria")}),s.jsx("span",{className:"typography-ui-label text-foreground select-none",children:a("gitView.pr.field.draft")})]}),y?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx(ut,{variant:"outline",size:"sm",onClick:()=>M(!0),children:q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),q.trim()&&s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--interactive-selection)] px-2 py-0.5 text-xs text-[var(--interactive-selection-foreground)]",children:a("gitView.pr.additionalContext.added")})})]}):s.jsxs(Qi,{open:ue,onOpenChange:le,children:[s.jsxs(ju,{className:"flex w-full items-center justify-between rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-2 hover:bg-[var(--interactive-hover)]",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.optional")}),s.jsx("span",{className:"typography-micro text-[var(--primary-base)]",children:ue?a("gitView.pr.actions.hide"):q.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Xi,{children:s.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[s.jsx(fr,{value:q,onChange:N=>K(N.target.value),className:"min-h-[100px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext")}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})})]}),s.jsx(Jo,{open:W,onClose:()=>M(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(ut,{size:"sm",onClick:()=>M(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(fr,{value:q,onChange:N=>K(N.target.value),className:"min-h-[200px] bg-transparent",placeholder:a("gitView.pr.placeholder.additionalContext"),autoFocus:!0}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.additionalContext.hint")})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:In,disabled:ce||ve,children:[ce?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ut,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:to,disabled:ve||!tr||!te.trim()||!oe&&te.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:ve?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(O,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},Ri=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),co=new Map,uo=new Map,yn=t=>`${Wt()}::${t}`,h1=()=>{const t=Ze.c(115),{t:e}=St(),{git:n}=nn(),r=Zn(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=zp(r??null),a=_a(o??null),d=ku(o??null),u=Cu(o??null),{ensureAll:h,ensureNestedRepos:f,selectNestedRepo:p}=pn(Qn(p1)),x=nt(g1),b=nt(x1),k=nt(b1),y=nt(y1);let m;t[0]!==r?(m=Ri(r),t[0]=r,t[1]=m):m=t[1];const g=m;let j;if(t[2]!==y||t[3]!==g||t[4]!==k){e:{if(!g){j=void 0;break e}let _;if(t[6]!==y||t[7]!==g){let oe;t[9]!==g?(oe=fe=>Ri(fe.path)===g,t[9]=g,t[10]=oe):oe=t[10],_=y.find(oe),t[6]=y,t[7]=g,t[8]=_}else _=t[8];const ee=_;if(ee){j=ee;break e}for(const oe of k.values())if(Ri(oe.path)===g){j=oe;break e}j=void 0}t[2]=y,t[3]=g,t[4]=k,t[5]=j}else j=t[5];const S=j;let w;t[11]!==x||t[12]!==S||t[13]!==b?.open||t[14]!==k?(w=()=>{if(x)return k.get(x)??S;if(b?.open)return S},t[11]=x,t[12]=S,t[13]=b?.open,t[14]=k,t[15]=w):w=t[15],b?.open;let C;t[16]!==w?(C=w(),t[16]=w,t[17]=C):C=t[17];const v=C;let R;t[18]!==x?(R=_=>x?_.getAttachment(x):void 0,t[18]=x,t[19]=R):R=t[19];const T=hu(R),D=T&&!T.degraded&&!T.legacy?T.worktreeRoot??void 0:void 0,F=Wy(r,v,a?.current??void 0);let B,E;t[20]!==h||t[21]!==n||t[22]!==o?(B=()=>{!o||!n||h(o,n)},E=[o,h,n],t[20]=h,t[21]=n,t[22]=o,t[23]=B,t[24]=E):(B=t[23],E=t[24]),c.useEffect(B,E);const[$,L]=c.useState(null);let X;t[25]!==D||t[26]!==F?.projectDirectory?(X=()=>{const _=D||F?.projectDirectory;if(!_){L(null);return}let ee=!1;return $a(_).then(oe=>{if(ee)return;const fe=oe.trim();L(fe&&fe!=="HEAD"?fe:null)}).catch(()=>{ee||L(null)}),()=>{ee=!0}},t[25]=D,t[26]=F?.projectDirectory,t[27]=X):X=t[27];const Y=F?.projectDirectory;let I;t[28]!==D||t[29]!==Y?(I=[D,Y],t[28]=D,t[29]=Y,t[30]=I):I=t[30],c.useEffect(X,I);let P;t[31]!==o?(P=()=>(o?co.get(yn(o)):void 0)??[],t[31]=o,t[32]=P):P=t[32];const[A,q]=c.useState(P);let K;t[33]!==o?(K=()=>(o?uo.get(yn(o)):void 0)??null,t[33]=o,t[34]=K):K=t[34];const[te,ae]=c.useState(K);let re,he;t[35]!==n||t[36]!==o?(re=()=>{if(!o||!n?.getRemotes){q([]);return}q(co.get(yn(o))??[]);let _=!1;return n.getRemotes(o).then(ee=>{_||(co.set(yn(o),ee??[]),q(ee??[]))}).catch(()=>{_||q(co.get(yn(o))??[])}),()=>{_=!0}},he=[o,n],t[35]=n,t[36]=o,t[37]=re,t[38]=he):(re=t[37],he=t[38]),c.useEffect(re,he);let ce,Te;t[39]!==n||t[40]!==o?(ce=()=>{if(!o||!n?.getRemoteUrl){ae(null);return}ae(uo.get(yn(o))??null);let _=!1;return n.getRemoteUrl(o).then(ee=>{_||(uo.set(yn(o),ee),ae(ee))}).catch(()=>{_||ae(uo.get(yn(o))??null)}),()=>{_=!0}},Te=[o,n],t[39]=n,t[40]=o,t[41]=ce,t[42]=Te):(ce=t[41],Te=t[42]),c.useEffect(ce,Te);let ve;e:{if(!d?.all){let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[43]=ee):ee=t[43],ve=ee;break e}let _;t[44]!==d.all?(_=d.all.filter(w1).sort(),t[44]=d.all,t[45]=_):_=t[45],ve=_}const pe=ve;let Ne;e:{if(!d?.all){let ee;t[46]===Symbol.for("react.memo_cache_sentinel")?(ee=[],t[46]=ee):ee=t[46],Ne=ee;break e}let _;t[47]!==d.all?(_=d.all.filter(v1).map(S1).sort(),t[47]=d.all,t[48]=_):_=t[48],Ne=_}const U=Ne;let Z;t[49]!==U||t[50]!==te||t[51]!==A||t[52]!==a?.tracking?(Z=()=>{if(A.length>0)return A;const _=new Set,ee=a?.tracking?.trim();ee&&ee.includes("/")&&_.add(ee.split("/")[0]);for(const oe of U){const fe=oe.indexOf("/");fe>0&&_.add(oe.slice(0,fe))}return _.size===0&&te&&_.add("origin"),Array.from(_).map(oe=>({name:oe,fetchUrl:te??"",pushUrl:te??""}))},t[49]=U,t[50]=te,t[51]=A,t[52]=a?.tracking,t[53]=Z):Z=t[53],a?.tracking;let de;t[54]!==Z?(de=Z(),t[54]=Z,t[55]=de):de=t[55];const ye=de,H=a?.current??null;a?.tracking;let je;t[56]!==a?.tracking?(je=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=je):je=t[57];const Ee=je,ge=(Ee&&d?.defaultBranches?.[Ee])??d?.defaultBranches?.origin;let ne;t[58]!==H||t[59]!==ge||t[60]!==ye||t[61]!==pe||t[62]!==$||t[63]!==F?.createdFromBranch?(ne=()=>Rh({remoteNames:new Set(ye.map(j1)),localBranches:pe,worktreeCreatedFromBranch:F?.createdFromBranch,rootBranchHint:$,defaultBranch:ge,headBranch:H}),t[58]=H,t[59]=ge,t[60]=ye,t[61]=pe,t[62]=$,t[63]=F?.createdFromBranch,t[64]=ne):ne=t[64],F?.createdFromBranch;let be;t[65]!==ne?(be=ne(),t[65]=ne,t[66]=be):be=t[66];const G=be;if(!r){let _;t[67]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(O,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=_):_=t[67];let ee;t[68]!==e?(ee=e("gitView.pullRequest.title"),t[68]=e,t[69]=ee):ee=t[69];let oe;t[70]!==ee?(oe=s.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[70]=ee,t[71]=oe):oe=t[71];let fe;t[72]!==e?(fe=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=fe):fe=t[73];let ie;t[74]!==fe?(ie=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:fe}),t[74]=fe,t[75]=ie):ie=t[75];let Le;return t[76]!==oe||t[77]!==ie?(Le=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[_,oe,ie]}),t[76]=oe,t[77]=ie,t[78]=Le):Le=t[78],Le}if(i===!1&&u!==!0){let _;t[79]!==r||t[80]!==f?(_=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=_):_=t[81];let ee;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==_?(ee=s.jsx(Mh,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:_}),t[82]=u,t[83]=l,t[84]=i,t[85]=_,t[86]=ee):ee=t[86],ee}if(!H){let _;t[87]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(O,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=_):_=t[87];let ee;t[88]!==e?(ee=e("gitView.pullRequest.title"),t[88]=e,t[89]=ee):ee=t[89];let oe;t[90]!==ee?(oe=s.jsx("div",{className:"typography-ui-header text-foreground",children:ee}),t[90]=ee,t[91]=oe):oe=t[91];let fe;t[92]!==e?(fe=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=fe):fe=t[93];let ie;t[94]!==fe?(ie=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:fe}),t[94]=fe,t[95]=ie):ie=t[95];let Le;return t[96]!==oe||t[97]!==ie?(Le=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[_,oe,ie]}),t[96]=oe,t[97]=ie,t[98]=Le):Le=t[98],Le}const z=i===!1&&Array.isArray(l)&&l.length>0;let J;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==p||t[103]!==z?(J=z?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Oh,{repositories:l,selectedRepository:o??null,onSelectRepository:_=>{r&&p(r,_)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=p,t[103]=z,t[104]=J):J=t[104];const ue=o??r,le=a?.tracking??void 0;let W;t[105]!==G||t[106]!==H||t[107]!==U||t[108]!==A||t[109]!==ue||t[110]!==le?(W=s.jsx(gn,{as:za,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(m1,{directory:ue,branch:H,baseBranch:G,trackingBranch:le,remotes:A,remoteBranches:U})}),t[105]=G,t[106]=H,t[107]=U,t[108]=A,t[109]=ue,t[110]=le,t[111]=W):W=t[111];let M;return t[112]!==J||t[113]!==W?(M=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[J,W]}),t[112]=J,t[113]=W,t[114]=M):M=t[114],M};function p1(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function g1(t){return t.currentSessionId}function x1(t){return t.newSessionDraft}function b1(t){return t.worktreeMetadata}function y1(t){return t.availableWorktrees}function w1(t){return!t.startsWith("remotes/")}function v1(t){return t.startsWith("remotes/")}function S1(t){return t.replace(/^remotes\//,"")}function j1(t){return t.name}const fa=2e4,k1=(t,e)=>{if(!t)return 1;let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&(n+=1,n>e))return n;return n},fo=(t,e)=>Hp(Gp.getState().dictionary,t,e),C1=t=>{const n=(t instanceof Error?t.message:String(t??"")).toLowerCase();return n.includes("file not found")||n.includes("not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")?"missing":"unreadable"},N1=async(t,e,n)=>{if(t.readFile)return(await t.readFile(e,{optional:!0,directory:n?.directory})).content??"";const r=new URLSearchParams({path:e,optional:"true"});n?.directory&&r.set("directory",n.directory);const i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store",headers:n?.directory?{"x-opencode-directory":n.directory}:void 0});if(!i.ok){const o=await i.json().catch(()=>({error:i.statusText}));throw new Error(o.error||"Failed to read file")}return i.text()},wf=async(t,e,n)=>{if(Wp(e)||Kp(e)||Vp(e))return{ok:!0};try{const r=await N1(t,e,n);return Up(r)?{ok:!1,reason:"binary"}:k1(r,fa)>fa?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:C1(r)}}},vf=t=>{if(t==="too-large"){const e=fa.toLocaleString(Nu());return fo("contextFileOpen.failure.tooLarge",{count:e})}return fo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},yc=8;let ma=null;const Sf=t=>{ma={x:t.clientX,y:t.clientY}},jf=t=>{const e=ma;return ma=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=yc&&Math.abs(t.clientY-e.y)<=yc},gr=t=>Array.from(t.types).includes("Files"),A1=t=>{const e=Array.from(t.items);return e.length===0?Array.from(t.files):e.flatMap(n=>{if(n.kind!=="file"||n.webkitGetAsEntry()?.isDirectory)return[];const r=n.getAsFile();return r?[r]:[]})},P1=t=>t.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),rs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},tl=(t,e)=>{const n=rs(e),r=rs(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},D1=(t,e)=>{const n=tl(t,e);if(n!==".")return n;const r=rs(t);return r.split("/").filter(Boolean).pop()??r},I1=t=>{const e=rs(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},T1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),E1=new Set(["node_modules"]),R1=t=>E1.has(t),M1=t=>{const e=rs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},O1=8,Zs=new Map,sl=t=>JSON.stringify([Wt(),t]),B1=t=>{const e=sl(t),n=Zs.get(e);return n?(n.touchedAt=Date.now(),Zs.delete(e),Zs.set(e,n),n):null},Mi=t=>{const e=sl(t),n=Zs.get(e);if(n)return n.touchedAt=Date.now(),n;if(Zs.size>=O1){const i=Zs.keys().next().value;i!==void 0&&Zs.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Zs.set(e,r),r},kf=(t,e)=>s.jsx(Wa,{filePath:t,extension:e}),F1=t=>{const e=Ze.c(3),{status:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=r):r=e[0];const i=r[n];let o;return e[1]!==i?(o=s.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:i}}),e[1]=i,e[2]=o):o=e[2],o},L1=t=>{const e=Ze.c(90),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:h,permissions:f,downloadFile:p,onSelect:x,onToggle:b,onRevealPath:k,onOpenDialog:y,onSetDropTarget:m,onDropFiles:g,onPickFiles:j}=t,{t:S}=St(),w=n.type==="directory";let C;e[0]!==w||e[1]!==n.path?(C=w?n.path:I1(n.path),e[0]=w,e[1]=n.path,e[2]=C):C=e[2];const v=C,{canRename:R,canCreateFile:T,canCreateFolder:D,canDelete:F,canReveal:B}=f,E=!w&&!!p,$=B&&!l,L=w&&h,X=R||T||D||L||F||E||$,[Y,I]=c.useState(!1),[P,A]=c.useState(!1);let q;e[3]!==X?(q=fe=>{X&&(fe?.preventDefault(),A(!0))},e[3]=X,e[4]=q):q=e[4];const K=q;let te;e[5]!==w||e[6]!==n||e[7]!==x||e[8]!==b?(te=()=>{w?b(n.path):x(n)},e[5]=w,e[6]=n,e[7]=x,e[8]=b,e[9]=te):te=e[9];const ae=te;let re;e[10]===Symbol.for("react.memo_cache_sentinel")?(re=fe=>{fe.stopPropagation(),A(!1),I(!0)},e[10]=re):re=e[10];const he=re;let ce;e[11]!==T||e[12]!==D||e[13]!==F||e[14]!==R||e[15]!==$||e[16]!==L||e[17]!==p||e[18]!==l||e[19]!==w||e[20]!==n||e[21]!==y||e[22]!==j||e[23]!==k||e[24]!==S?(ce=fe=>{const{Item:ie,Separator:Le}=fe;return s.jsxs(s.Fragment,{children:[R&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),y("rename",n)},children:[s.jsx(O,{name:"edit",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.rename")]}),s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),Jn(n.path).then(Pe=>{if(Pe.ok){ze.success(S("sidebarFilesTree.toast.pathCopied"));return}ze.error(S("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.copyPath")]}),!w&&p&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),p(n.path).catch(Pe=>{console.error("Download failed:",Pe),ze.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(O,{name:"download",className:"mr-2 h-4 w-4"})," ",S(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),$&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),k(n.path)},children:[s.jsx(O,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",S(qp())]}),w&&(T||D||L)&&s.jsxs(s.Fragment,{children:[s.jsx(Le,{}),T&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),y("createFile",n)},children:[s.jsx(O,{name:"file-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFile")]}),D&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),y("createFolder",n)},children:[s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFolder")]}),L&&s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),j(n.path)},children:[s.jsx(O,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.uploadFiles")]})]}),F&&s.jsxs(s.Fragment,{children:[s.jsx(Le,{}),s.jsxs(ie,{onClick:$e=>{$e.stopPropagation(),y("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.delete")]})]})]})},e[11]=T,e[12]=D,e[13]=F,e[14]=R,e[15]=$,e[16]=L,e[17]=p,e[18]=l,e[19]=w,e[20]=n,e[21]=y,e[22]=j,e[23]=k,e[24]=S,e[25]=ce):ce=e[25];const Te=ce;let ve;e[26]!==n.path||e[27]!==r?(ve=fe=>{Sf(fe);const ie=tl(r,n.path);!ie||ie==="."||(fe.dataTransfer.setData("application/x-openchamber-file-path",ie),fe.dataTransfer.effectAllowed="copy")},e[26]=n.path,e[27]=r,e[28]=ve):ve=e[28];const pe=ve;let Ne;e[29]!==ae?(Ne=fe=>{jf(fe)&&ae()},e[29]=ae,e[30]=Ne):Ne=e[30];const U=Ne;let Z;e[31]!==h||e[32]!==m||e[33]!==v?(Z=fe=>{!h||!v||!gr(fe.dataTransfer)||(fe.preventDefault(),fe.stopPropagation(),fe.dataTransfer.dropEffect="copy",m(v))},e[31]=h,e[32]=m,e[33]=v,e[34]=Z):Z=e[34];const de=Z;let ye;e[35]!==h||e[36]!==m||e[37]!==v?(ye=fe=>{!h||!v||!gr(fe.dataTransfer)||fe.relatedTarget instanceof Node&&fe.currentTarget.contains(fe.relatedTarget)||(fe.stopPropagation(),m(null))},e[35]=h,e[36]=m,e[37]=v,e[38]=ye):ye=e[38];const H=ye;let je;e[39]!==h||e[40]!==g||e[41]!==v?(je=fe=>{!h||!v||!gr(fe.dataTransfer)||(fe.preventDefault(),fe.stopPropagation(),g(v,fe.dataTransfer))},e[39]=h,e[40]=g,e[41]=v,e[42]=je):je=e[42];const Ee=je;let ge;e[43]===Symbol.for("react.memo_cache_sentinel")?(ge={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[43]=ge):ge=e[43];let ne;e[44]!==K||e[45]!==H||e[46]!==de||e[47]!==Ee?(ne=s.jsx("div",{className:"group relative flex items-center typography-meta",style:ge,onContextMenu:K,onDragEnter:de,onDragOver:de,onDragLeave:H,onDrop:Ee}),e[44]=K,e[45]=H,e[46]=de,e[47]=Ee,e[48]=ne):ne=e[48];const be=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let G;e[49]!==be?(G=Me("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",be),e[49]=be,e[50]=G):G=e[50];let z;e[51]!==w||e[52]!==i||e[53]!==n.extension||e[54]!==n.path?(z=w?i?s.jsx(O,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):kf(n.path,n.extension),e[51]=w,e[52]=i,e[53]=n.extension,e[54]=n.path,e[55]=z):z=e[55];let J;e[56]!==n.name||e[57]!==n.path?(J=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[56]=n.name,e[57]=n.path,e[58]=J):J=e[58];let ue;e[59]!==w||e[60]!==a?(ue=!w&&a&&s.jsx(F1,{status:a}),e[59]=w,e[60]=a,e[61]=ue):ue=e[61];let le;e[62]!==d||e[63]!==w?(le=w&&d&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[d.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",d.modified]}),d.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",d.added]})]}),e[62]=d,e[63]=w,e[64]=le):le=e[64];let W;e[65]!==K||e[66]!==U||e[67]!==pe||e[68]!==ae||e[69]!==G||e[70]!==z||e[71]!==J||e[72]!==ue||e[73]!==le?(W=s.jsxs("button",{type:"button",onClick:ae,onContextMenu:K,draggable:!0,onDragStart:pe,onDragEnd:U,className:G,children:[z,J,ue,le]}),e[65]=K,e[66]=U,e[67]=pe,e[68]=ae,e[69]=G,e[70]=z,e[71]=J,e[72]=ue,e[73]=le,e[74]=W):W=e[74];let M;e[75]!==Y||e[76]!==X||e[77]!==Te||e[78]!==S?(M=X&&s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:s.jsxs(Is,{open:Y,onOpenChange:I,children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:he,title:S("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":S("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(O,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:S("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(Ds,{align:"end",side:"bottom",onCloseAutoFocus:()=>I(!1),children:Te({Item:_t,Separator:gs})})]})}),e[75]=Y,e[76]=X,e[77]=Te,e[78]=S,e[79]=M):M=e[79];let _;e[80]!==ne||e[81]!==W||e[82]!==M?(_=s.jsxs(Xd,{render:ne,children:[W,M]}),e[80]=ne,e[81]=W,e[82]=M,e[83]=_):_=e[83];let ee;e[84]!==Te?(ee=s.jsx(Qd,{className:"min-w-[180px]",children:Te({Item:zn,Separator:Hi})}),e[84]=Te,e[85]=ee):ee=e[85];let oe;return e[86]!==P||e[87]!==_||e[88]!==ee?(oe=s.jsxs(Jd,{open:P,onOpenChange:A,children:[_,ee]}),e[86]=P,e[87]=_,e[88]=ee,e[89]=oe):oe=e[89],oe},_1=(t,e)=>t.node===e.node&&t.root===e.root&&t.isExpanded===e.isExpanded&&t.isActive===e.isActive&&t.isBrowserClient===e.isBrowserClient&&t.status===e.status&&t.badge===e.badge&&t.isDropTarget===e.isDropTarget&&t.canUpload===e.canUpload&&t.permissions===e.permissions&&t.downloadFile===e.downloadFile&&t.onSelect===e.onSelect&&t.onToggle===e.onToggle&&t.onRevealPath===e.onRevealPath&&t.onOpenDialog===e.onOpenDialog&&t.onSetDropTarget===e.onSetDropTarget&&t.onDropFiles===e.onDropFiles&&t.onPickFiles===e.onPickFiles,$1=c.memo(L1,_1),z1=t=>{const e=Ze.c(6),{visible:n}=t,r=n===void 0?!0:n,i=pn(K1),o=Zn();let l;e[0]!==o||e[1]!==i?(l=JSON.stringify([i,o]),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==l||e[4]!==r?(a=s.jsx(W1,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},W1=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=St(),{files:r,runtime:i}=nn(),o=sh(i.platform),l=Zn()??"",a=rs(l.trim()),d=sl(a),u=nh(),h=rh(),f=$d(we=>we.searchFiles),p=Ae(we=>we.openContextFile),x=_a(t?l:null),[b,k]=c.useState(""),y=Au(b,200),m=c.useRef(null),[g,j]=c.useState([]),[S,w]=c.useState(!1),[C,v]=c.useState(null),[R,T]=c.useState({}),[D,F]=c.useState({}),B=c.useRef(new Set),E=c.useMemo(()=>new sb,[]);c.useEffect(()=>()=>E.clear(),[E]);const $=c.useRef(null);c.useEffect(()=>{if(v(null),!a){T({}),F({}),B.current=new Set;return}const we=B1(a);we?(T({...we.childrenByDir}),F({...we.loadErrorsByDir}),B.current=new Set(we.loadedDirs)):(T({}),F({}),B.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const we=Mi(a);we.childrenByDir=R},[a,R]),c.useEffect(()=>{if(!a)return;const we=Mi(a);we.loadErrorsByDir=D},[a,D]),c.useEffect(()=>{if(!a)return;const we=Mi(a);we.loadedDirs=new Set(B.current)},[a,R,D]),c.useEffect(()=>()=>{if(!a)return;const we=Zs.get(d);we&&we.loadedDirs.size===0&&Object.keys(we.childrenByDir).length===0&&Zs.delete(d)},[d,a]);const L=c.useMemo(()=>[],[]),X=c.useMemo(()=>[],[]),Y=Js(we=>a?we.byRoot[a]?.expandedPaths??L:L),I=c.useMemo(()=>new Set(Y),[Y]),P=Js(we=>a?we.byRoot[a]?.selectedPath??null:null),A=Js(we=>we.setSelectedPath),q=Js(we=>we.addOpenPath),K=Js(we=>we.removeOpenPathsByPrefix),te=Js(we=>we.toggleExpandedPath),ae=Js(we=>we.collapseAllExpandedPaths),re=Ae(we=>a?we.contextPanelByDirectory[a]?.tabs??X:X),he=c.useMemo(()=>new Set(re.map(we=>we.mode==="file"?we.targetPath:null).filter(we=>typeof we=="string"&&we.length>0).map(we=>rs(we))),[re]),[ce,Te]=c.useState(null),[ve,pe]=c.useState(null),[Ne,U]=c.useState(""),[Z,de]=c.useState(!1),ye=!!r.writeFile,H=!!r.createDirectory,je=!!r.rename,Ee=!!r.delete,ge=!!r.revealPath,ne=c.useMemo(()=>({canRename:je,canCreateFile:ye,canCreateFolder:H,canDelete:Ee,canReveal:ge}),[je,ye,H,Ee,ge]),be=c.useCallback(we=>{r.revealPath&&r.revealPath(we).catch(()=>{ze.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),G=c.useCallback((we,Xe)=>{Te(we),pe(Xe),U(we==="rename"&&Xe.name||""),de(!1)},[]),z=c.useCallback((we,Xe)=>{const mt=Xe.filter(qe=>qe&&typeof qe.name=="string"&&qe.name.length>0).filter(qe=>u||!qe.name.startsWith(".")).filter(qe=>h||!R1(qe.name)).map(qe=>{const ft=qe.name,se=rs(qe.path||""),me=se?T1(se)?se:rs(`${we}/${se}`):rs(`${we}/${ft}`),Ie=qe.isDirectory?"directory":"file",We=Ie==="file"&&ft.includes(".")?ft.split(".").pop()?.toLowerCase():void 0;return{name:ft,path:me,type:Ie,extension:We}});return P1(mt)},[h,u]),J=c.useCallback(async(we,Xe,mt=!1)=>{if(!e.current||Xe?.())return;const qe=rs(we.trim());if(!qe||!mt&&B.current.has(qe))return;const ft=Wt();return E.run(qe,async se=>{const me=()=>!se()||Wt()!==ft;try{const Ie=r.listDirectory?(await r.listDirectory(qe)).entries:await Vs.listLocalDirectory(qe);if(me())return;const We=z(qe,Ie);B.current=new Set(B.current),B.current.add(qe),F(V=>{if(!V[qe])return V;const Fe={...V};return delete Fe[qe],Fe}),T(V=>V[qe]&&nb(V[qe],We)?V:{...V,[qe]:We})}catch(Ie){if(me())return;const We=Ie instanceof Error?Ie.message:String(Ie??"");console.error("Failed to load sidebar directory:",Ie),F(V=>({...V,[qe]:We}))}},mt)},[E,r,z]),ue=c.useCallback(async()=>{if(!a)return;$.current?.abort();const we=new AbortController;$.current=we,E.clear();try{const mt=(Js.getState().byRoot[a]?.expandedPaths??[]).map(se=>rs(se)).filter(se=>!!se&&se!==a&&se.startsWith(`${a}/`)),qe=[a,...mt];B.current=new Set(B.current);for(const se of qe)B.current.delete(se);F(se=>{if(Object.keys(se).length===0)return se;const me={...se};let Ie=!1;for(const We of qe)We in me&&(delete me[We],Ie=!0);return Ie?me:se});const ft=()=>we.signal.aborted;await J(a,ft);for(let se=0;se<mt.length&&!we.signal.aborted;se+=3){const me=mt.slice(se,se+3);await Promise.all(me.map(Ie=>J(Ie,ft)))}}catch(Xe){if(we.signal.aborted)return;console.error("Failed to refresh sidebar tree:",Xe)}finally{$.current===we&&($.current=null)}},[E,J,a]),le=c.useCallback(async we=>{if(!we){await ue();return}const Xe=rs(we);B.current=new Set(B.current),B.current.delete(Xe),await J(Xe,void 0,!0)},[J,ue]);c.useEffect(()=>{a&&($.current?.abort(),B.current=new Set,E.clear(),F({}),T(we=>Object.keys(we).length===0?we:{}),J(a))},[E,J,a,u,h]),c.useEffect(()=>{if(!t||!a||Y.length===0)return;const we=Y.map(qe=>rs(qe)).filter(qe=>!!qe&&qe!==a&&qe.startsWith(`${a}/`)&&!B.current.has(qe)&&!E.has(qe)).sort((qe,ft)=>qe.split("/").length-ft.split("/").length);if(we.length===0)return;let Xe=!1;const mt=()=>Xe;return(async()=>{for(let qe=0;qe<we.length&&!Xe;qe+=3){const ft=we.slice(qe,qe+3);await Promise.all(ft.map(se=>J(se,mt)))}})(),()=>{Xe=!0}},[E,Y,J,a,t]);const W=c.useRef(t);c.useEffect(()=>{const we=t&&!W.current;W.current=t,we&&ue()},[ue,t]),c.useEffect(()=>{if(!t)return;if(!l){j([]),w(!1);return}const we=y.trim();if(!we){j([]),w(!1);return}let Xe=!1;return w(!0),f(l,we,150,{includeHidden:u,respectGitignore:!h,type:"file"}).then(mt=>{if(Xe)return;const ft=mt.filter(se=>h||!M1(se.path)).map(se=>({name:se.name,path:rs(se.path),type:"file",extension:se.extension,relativePath:se.relativePath}));j(ft)}).catch(()=>{Xe||j([])}).finally(()=>{Xe||w(!1)}),()=>{Xe=!0}},[l,y,f,u,h,t]);const M=c.useMemo(()=>{const we=new Map;if(!x?.files)return we;for(const Xe of x.files)Xe.index==="A"||Xe.working_dir==="?"?we.set(Xe.path,"git-added"):Xe.index==="D"?we.set(Xe.path,"git-deleted"):(Xe.index==="M"||Xe.working_dir==="M")&&we.set(Xe.path,"git-modified");return we},[x]),_=c.useMemo(()=>{const we=new Map;if(!x?.files||!a)return we;for(const Xe of x.files){const mt=Xe.index==="M"||Xe.working_dir==="M",qe=Xe.index==="A"||Xe.working_dir==="?";if(!mt&&!qe)continue;const ft=Xe.path.split("/");if(ft.length<=1)continue;let se=a;for(let me=0;me<ft.length-1;me++){se=`${se}/${ft[me]}`;let Ie=we.get(se);Ie||(Ie={modified:0,added:0},we.set(se,Ie)),mt&&Ie.modified++,qe&&Ie.added++}}return we},[x,a]),ee=c.useCallback(we=>{if(he.has(we))return"open";if(M.size===0)return null;const Xe=we.startsWith(a+"/")?we.slice(a.length+1):we;return M.get(Xe)??null},[he,M,a]),oe=c.useCallback(we=>{if(_.size===0)return null;const Xe=_.get(we);return Xe&&Xe.modified+Xe.added>0?Xe:null},[_]),fe=c.useCallback(async we=>{if(!a)return;const Xe=await wf(r,we.path,{directory:a});if(!Xe.ok){ze.error(vf(Xe.reason));return}A(a,we.path),q(a,we.path),p(a,we.path)},[q,r,p,a,A]),ie=c.useCallback(async we=>{const Xe=rs(we);a&&(te(a,Xe),B.current.has(Xe)||await J(Xe))},[J,a,te]),{canUpload:Le,uploadingDirectory:$e,uploadFiles:Pe,pickFiles:Oe,uploadElements:Q}=Bh({root:a,refreshDirectory:le}),Ce=$e!==null,Se=$e??C,Ke=c.useCallback((we,Xe)=>{const mt=A1(Xe);mt.length!==0&&(v(null),Pe(we,mt))},[Pe]),et=c.useCallback(we=>{!Le||Ce||!a||!gr(we.dataTransfer)||(we.preventDefault(),we.dataTransfer.dropEffect="copy",v(a))},[Le,Ce,a]),it=c.useCallback(we=>{gr(we.dataTransfer)&&(we.relatedTarget instanceof Node&&we.currentTarget.contains(we.relatedTarget)||v(null))},[]),rt=c.useCallback(we=>{!Le||Ce||!a||!gr(we.dataTransfer)||(we.preventDefault(),Ke(a,we.dataTransfer))},[Le,Ke,Ce,a]),pt=c.useCallback(async we=>{if(we?.preventDefault(),!ve||!ce)return;de(!0);const Xe=()=>de(!1),mt=()=>Te(null);if(ce==="createFile"){if(!Ne.trim()){ze.error(n("sidebarFilesTree.toast.filenameRequired")),Xe();return}if(!r.writeFile){ze.error(n("sidebarFilesTree.toast.writeNotSupported")),Xe();return}const qe=ve.path,ft=qe?`${qe}/`:"",se=rs(`${ft}${Ne.trim()}`);await r.writeFile(se,"").then(async me=>{me.success&&(ze.success(n("sidebarFilesTree.toast.fileCreated")),await le(qe)),mt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Xe);return}if(ce==="createFolder"){if(!Ne.trim()){ze.error(n("sidebarFilesTree.toast.folderNameRequired")),Xe();return}const qe=ve.path,ft=qe?`${qe}/`:"",se=rs(`${ft}${Ne.trim()}`);await r.createDirectory(se).then(async me=>{me.success&&(ze.success(n("sidebarFilesTree.toast.folderCreated")),await le(qe)),mt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Xe);return}if(ce==="rename"){if(!Ne.trim()){ze.error(n("sidebarFilesTree.toast.nameRequired")),Xe();return}if(!r.rename){ze.error(n("sidebarFilesTree.toast.renameNotSupported")),Xe();return}const qe=ve.path,ft=qe.split("/").slice(0,-1).join("/"),se=ft?`${ft}/`:"",me=rs(`${se}${Ne.trim()}`);await r.rename(qe,me).then(async Ie=>{Ie.success&&(ze.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await le(ft),a&&K(a,qe),(P===qe||P&&P.startsWith(`${qe}/`))&&A(a,null)),mt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Xe);return}if(ce==="delete"){if(!r.delete){ze.error(n("sidebarFilesTree.toast.deleteNotSupported")),Xe();return}const qe=ve.path,ft=qe.split("/").slice(0,-1).join("/");await r.delete(qe).then(async se=>{se.success&&(ze.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await le(ft),a&&K(a,qe),(P===qe||P&&P.startsWith(qe+"/"))&&A(a,null)),mt()}).catch(()=>ze.error(n("sidebarFilesTree.toast.operationFailed"))).finally(Xe);return}Xe()},[ce,ve,Ne,r,le,K,a,P,A,n]);function ht(we,Xe){const mt=R[we]??[];return mt.map((qe,ft)=>{const se=qe.type==="directory",me=se&&I.has(qe.path),Ie=P===qe.path,We=ft===mt.length-1;return s.jsxs("li",{className:"relative",children:[Xe>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),We&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx($1,{node:qe,root:a,isExpanded:me,isActive:Ie,isBrowserClient:o,status:se?void 0:ee(qe.path),badge:se?oe(qe.path):void 0,isDropTarget:se&&Se===qe.path,canUpload:Le&&!Ce,permissions:ne,downloadFile:r.downloadFile,onSelect:fe,onToggle:ie,onRevealPath:be,onOpenDialog:G,onSetDropTarget:v,onDropFiles:Ke,onPickFiles:Oe}),se&&me&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[D[qe.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:D[qe.path],children:D[qe.path]}),s.jsxs(ut,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{le(qe.path)},children:[s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,ht(qe.path,Xe+1)]})]},qe.path)})}const tt=!!(a&&R[a]),At=a?D[a]:null,jt=Se?D1(a,Se):"";return s.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ye&&s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>G("createFile",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFileTitle"),"aria-label":n("sidebarFilesTree.actions.newFileTitle"),children:s.jsx(O,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),H&&s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>G("createFolder",{path:l,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.newFolderTitle"),"aria-label":n("sidebarFilesTree.actions.newFolderTitle"),children:s.jsx(O,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),Le&&s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Oe(a),disabled:!a||Ce,className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(O,{name:"upload-2",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{ue()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(O,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>{a&&ae(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.collapseAllTitle"),"aria-label":n("sidebarFilesTree.actions.collapseAllTitle"),children:s.jsx(O,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(O,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(un,{ref:m,value:b,onChange:we=>k(we.target.value),placeholder:n("sidebarFilesTree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),b.trim().length>0?s.jsx("button",{type:"button","aria-label":n("sidebarFilesTree.search.clearAria"),className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{k(""),m.current?.focus()},children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(gn,{outerClassName:"h-full min-h-0",className:Me("p-2",Se===a&&"bg-interactive-selection/10"),onDragEnter:et,onDragOver:et,onDragLeave:it,onDrop:rt,children:s.jsx("ul",{className:"flex flex-col",children:S?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):g.length>0?g.map(we=>{const Xe=P===we.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>fe(we),draggable:!0,onDragStart:mt=>{Sf(mt);const qe=we.relativePath||tl(a??"",we.path);!qe||qe==="."||(mt.dataTransfer.setData("application/x-openchamber-file-path",qe),mt.dataTransfer.effectAllowed="copy")},onDragEnd:mt=>{jf(mt)&&fe(we)},className:Me("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",Xe?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:we.path,children:[kf(we.path,we.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:we.relativePath??we.path})]})},we.path)}):At?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:At}),s.jsxs(ut,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ue()},children:[s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):tt&&a?ht(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),Se?s.jsxs("div",{className:"pointer-events-none absolute left-2 right-2 top-2 z-50 flex items-center gap-2 rounded-md border border-primary bg-background/95 px-2 py-1.5 shadow-sm",children:[s.jsx(O,{name:Ce?"loader-4":"folder-received",className:Me("size-4 flex-shrink-0",Ce&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:jt,children:n(Ce?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:jt})})]}):null]}),Q,s.jsx(bs,{open:!!ce,onOpenChange:we=>!we&&Te(null),children:s.jsxs(ys,{children:[s.jsxs(Us,{children:[s.jsxs(Bs,{children:[ce==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),ce==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),ce==="rename"&&n("sidebarFilesTree.dialog.rename.title"),ce==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(Fs,{children:[ce==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:ve?.path??n("sidebarFilesTree.dialog.rootFallback")}),ce==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:ve?.path??n("sidebarFilesTree.dialog.rootFallback")}),ce==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:ve?.name??""}),ce==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:ve?.name??""})]})]}),ce!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(un,{value:Ne,onChange:we=>U(we.target.value),placeholder:n(ce==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:we=>{we.key==="Enter"&&pt()},autoFocus:!0})}),s.jsxs(An,{children:[s.jsx(ut,{variant:"outline",onClick:()=>Te(null),disabled:Z,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(ut,{variant:ce==="delete"?"destructive":"default",onClick:()=>{pt()},disabled:Z||ce!=="delete"&&!Ne.trim(),children:Z?s.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):n(ce==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function K1(t){return t.runtimeKey}const wc=60,V1=t=>{try{return new URL(t).origin}catch{return""}},Oi=new Set,Cf=Zr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=V1(n);!i||!r||e().byOrigin[i]||Oi.has(i)||(Oi.add(i),pr("desktop_browser_fetch_favicon",{url:r}).then(o=>{const l=typeof o?.dataUrl=="string"?o.dataUrl:"";l&&t(a=>{const d={...a.byOrigin,[i]:l},u=Object.keys(d);if(u.length<=wc)return{byOrigin:d};for(const h of u.slice(0,u.length-wc))delete d[h];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Oi.delete(i)}))}})),nl=t=>t,ha=t=>{const e=nl(t).type;return typeof e=="string"?e:""},U1=t=>{const e=nl(t).tool;return typeof e=="string"?e:""},H1=t=>{const e=nl(t).text;return typeof e=="string"?e:""},G1=t=>{const e=ha(t);return e==="tool"?U1(t).trim().toLowerCase()||"tool":e||"unknown"},q1=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=G1(n);e.includes(r)||e.push(r)}return e.join(" + ")},Y1=t=>t.replace(/\s+/g," ").trim(),Q1=t=>{for(const n of t)if(ha(n)==="text"){const r=Y1(H1(n));if(r.length===0)continue;return r}const e=t.filter(n=>ha(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},X1=(t,e,n)=>`${n(t)} / ${n(e)}`,J1=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Z1=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=J1(e);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:n===!1?"2-digit":"numeric",minute:"2-digit",...n===void 0?{}:{hour12:n}})},pa={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Ao={user:0,assistant:0,tool:0,other:0},vn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,vc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(h=>h.tokens!==void 0)?.tokens;if(typeof n=="number")return{...pa,total:vn(n)};if(!n||typeof n!="object")return pa;const r=n,i=vn(r.input),o=vn(r.output),l=vn(r.reasoning),a=vn(r.cache?.read),d=vn(r.cache?.write),u=vn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},ew=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},Rs=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+Rs(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+Rs(n),0):0,tw=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Ao,assistant:Rs(n.text)+Rs(n.content)};const i=ew(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:Rs(n.input)+Rs(n.output)+Rs(n.error)+Rs(n.call?.input)+Rs(n.call?.output)+Rs(n.call?.error)+Rs(n.raw)+Math.round(Rs(n.metadata)*.25)+Math.round(Rs(n.state)*.1),other:0}:e==="user"?{user:i.length,assistant:0,tool:0,other:0}:e==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Sc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),sw=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",nw=(t,e)=>{if(t.length===0)return{...Ao};const n=t.reduce((r,i)=>{const o=sw(i);let l={...Ao};for(const a of i.parts)l=Sc(l,tw(a,o));return Sc(r,l)},{...Ao});return n.user+=e.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Ln=t=>t.toLocaleString(Nu()),rw=(t,e)=>!t||!Number.isFinite(t)?"-":Su(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),ow=(t,e,n)=>{const r=t.find(o=>o.id===e),i=r?.models?.find(o=>o.id===n);return{providerName:r?.name||e||"-",modelName:i?.name||n||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},iw=()=>{const t=Ze.c(209),{t:e}=St(),n=Ae(aw);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[i,o]=c.useState(r),[l,a]=c.useState(null),d=c.useRef(null),u=nt(lw),h=nt(cw),f=Pu(h??void 0),p=Yp(u??"",h??void 0),x=Lt(dw);let b;t[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(uw),a(null)},t[1]=b):b=t[1];let k;t[2]!==h||t[3]!==u?(k=[h,u],t[2]=h,t[3]=u,t[4]=k):k=t[4],c.useEffect(b,k);let y,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},m=[],t[5]=y,t[6]=m):(y=t[5],m=t[6]),c.useEffect(y,m);let g;t[7]===Symbol.for("react.memo_cache_sentinel")?(g=async(He,Ue)=>{(await Jn(Ue)).ok?(a(He),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(_e=>_e===He?null:_e),d.current=null},2e3)):a(null)},t[7]=g):g=t[7];const j=g;let S;t[8]!==u||t[9]!==f?(S=u?f.find(He=>He.id===u)??null:null,t[8]=u,t[9]=f,t[10]=S):S=t[10];const w=S;let C,v,R,T,D,F,B;if(t[11]!==p){C=p.filter(fw),B=p.filter(mw);const He=Qp(p.map(hw));R=He?p[He.index]??null:null,T=He?.state==="compacted";let Ue;t[19]!==R?(F=R?vc(R):pa,Ue=Xp({input:F.input,cache:{read:F.cacheRead,write:F.cacheWrite}}),t[19]=R,t[20]=Ue,t[21]=F):(Ue=t[20],F=t[21]),v=Ue,D=C.reduce(pw,0),t[11]=p,t[12]=C,t[13]=v,t[14]=R,t[15]=T,t[16]=D,t[17]=F,t[18]=B}else C=t[12],v=t[13],R=t[14],T=t[15],D=t[16],F=t[17],B=t[18];const E=D,$=R?.info??null,L=x,X=$?.providerID||"",Y=$?.modelID||"";let I;t[22]!==Y||t[23]!==L||t[24]!==X?(I=ow(L,X,Y),t[22]=Y,t[23]=L,t[24]=X,t[25]=I):I=t[25];const P=I,A=P.contextLimit,q=T?null:A&&A>0?Math.min(999,F.total/A*100):0;let K;if(t[26]!==p){const He=[...p].reverse().find(gw),Ue=He?.info.role==="system"?He.info.text:"";K=nw(p,Ue),t[26]=p,t[27]=K}else K=t[27];const te=K,ae=te.user,re=te.assistant,he=te.tool,ce=Math.max(0,F.input-ae-re-he),Te=ae+re+he+ce,ve=p[0]?.info?.time?.created,pe=p.length>0?p[p.length-1]?.info?.time?.created:null;let Ne;t[28]!==w?.title||t[29]!==e?(Ne=w?.title||e("contextSidebar.session.untitled"),t[28]=w?.title,t[29]=e,t[30]=Ne):Ne=t[30];const U=w?.time?.created??ve??null,Z=pe??w?.time?.created??null;let de;t[31]!==re||t[32]!==ce||t[33]!==he||t[34]!==ae?(de={user:ae,assistant:re,tool:he,other:ce},t[31]=re,t[32]=ce,t[33]=he,t[34]=ae,t[35]=de):de=t[35];let ye;t[36]!==C.length||t[37]!==Te||t[38]!==v||t[39]!==A||t[40]!==P||t[41]!==p.length||t[42]!==Ne||t[43]!==U||t[44]!==Z||t[45]!==de||t[46]!==F||t[47]!==E||t[48]!==q||t[49]!==B.length?(ye={sessionTitle:Ne,messagesCount:p.length,userMessagesCount:B.length,assistantMessagesCount:C.length,createdAt:U,lastActivityAt:Z,providerModel:P,tokenBreakdown:F,usagePercent:q,cacheHitRate:v,totalAssistantCost:E,contextLimit:A,breakdown:de,breakdownTotal:Te},t[36]=C.length,t[37]=Te,t[38]=v,t[39]=A,t[40]=P,t[41]=p.length,t[42]=Ne,t[43]=U,t[44]=Z,t[45]=de,t[46]=F,t[47]=E,t[48]=q,t[49]=B.length,t[50]=ye):ye=t[50];const H=ye;if(!u){let He;t[51]!==e?(He=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=He):He=t[52];let Ue;return t[53]!==He?(Ue=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:He}),t[53]=He,t[54]=Ue):Ue=t[54],Ue}let je;t[55]!==e?(je=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=je):je=t[56];let Ee;t[57]!==je||t[58]!==H.breakdown.user?(Ee={key:"user",label:je,value:H.breakdown.user,color:"var(--status-success)"},t[57]=je,t[58]=H.breakdown.user,t[59]=Ee):Ee=t[59];let ge;t[60]!==e?(ge=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=ge):ge=t[61];let ne;t[62]!==ge||t[63]!==H.breakdown.assistant?(ne={key:"assistant",label:ge,value:H.breakdown.assistant,color:"var(--primary-base)"},t[62]=ge,t[63]=H.breakdown.assistant,t[64]=ne):ne=t[64];let be;t[65]!==e?(be=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=be):be=t[66];let G;t[67]!==be||t[68]!==H.breakdown.tool?(G={key:"tool",label:be,value:H.breakdown.tool,color:"var(--status-warning)"},t[67]=be,t[68]=H.breakdown.tool,t[69]=G):G=t[69];let z;t[70]!==e?(z=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=z):z=t[71];let J;t[72]!==z||t[73]!==H.breakdown.other?(J={key:"other",label:z,value:H.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=z,t[73]=H.breakdown.other,t[74]=J):J=t[74];let ue;t[75]!==Ee||t[76]!==ne||t[77]!==G||t[78]!==J?(ue=[Ee,ne,G,J],t[75]=Ee,t[76]=ne,t[77]=G,t[78]=J,t[79]=ue):ue=t[79];const le=ue;let W;t[80]!==H.sessionTitle?(W=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:H.sessionTitle}),t[80]=H.sessionTitle,t[81]=W):W=t[81];let M;t[82]!==H.providerModel.modelName||t[83]!==H.providerModel.providerName?(M=s.jsxs("span",{children:[H.providerModel.providerName," / ",H.providerModel.modelName]}),t[82]=H.providerModel.modelName,t[83]=H.providerModel.providerName,t[84]=M):M=t[84];let _;t[85]!==n||t[86]!==H.createdAt?(_=H.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:rw(H.createdAt,n)})]}),t[85]=n,t[86]=H.createdAt,t[87]=_):_=t[87];let ee;t[88]!==M||t[89]!==_?(ee=s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[M,_]}),t[88]=M,t[89]=_,t[90]=ee):ee=t[90];let oe;t[91]!==W||t[92]!==ee?(oe=s.jsxs("div",{className:"mb-6",children:[W,ee]}),t[91]=W,t[92]=ee,t[93]=oe):oe=t[93];let fe;t[94]!==e?(fe=e("contextSidebar.section.context"),t[94]=e,t[95]=fe):fe=t[95];let ie;t[96]!==fe?(ie=s.jsx("span",{className:"typography-micro text-muted-foreground",children:fe}),t[96]=fe,t[97]=ie):ie=t[97];let Le;t[98]!==H.tokenBreakdown.total||t[99]!==H.usagePercent?(Le=H.usagePercent===null?"—":Ln(H.tokenBreakdown.total),t[98]=H.tokenBreakdown.total,t[99]=H.usagePercent,t[100]=Le):Le=t[100];let $e;t[101]!==H.contextLimit?($e=H.contextLimit?` / ${Ln(H.contextLimit)}`:"",t[101]=H.contextLimit,t[102]=$e):$e=t[102];let Pe;t[103]!==Le||t[104]!==$e?(Pe=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Le,$e]}),t[103]=Le,t[104]=$e,t[105]=Pe):Pe=t[105];let Oe;t[106]!==ie||t[107]!==Pe?(Oe=s.jsxs("div",{className:"flex items-baseline justify-between",children:[ie,Pe]}),t[106]=ie,t[107]=Pe,t[108]=Oe):Oe=t[108];let Q;t[109]!==H.usagePercent?(Q=H.usagePercent!==null&&H.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,H.usagePercent)}%`,backgroundColor:H.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=H.usagePercent,t[110]=Q):Q=t[110];let Ce;t[111]!==Q?(Ce=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:Q}),t[111]=Q,t[112]=Ce):Ce=t[112];let Se;t[113]!==e||t[114]!==H.usagePercent?(Se=H.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:H.usagePercent.toFixed(1)}),t[113]=e,t[114]=H.usagePercent,t[115]=Se):Se=t[115];let Ke;t[116]!==Se?(Ke=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Se}),t[116]=Se,t[117]=Ke):Ke=t[117];let et;t[118]!==Oe||t[119]!==Ce||t[120]!==Ke?(et=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[Oe,Ce,Ke]}),t[118]=Oe,t[119]=Ce,t[120]=Ke,t[121]=et):et=t[121];let it;t[122]!==e?(it=e("contextSidebar.stats.messages"),t[122]=e,t[123]=it):it=t[123];let rt;t[124]!==H.messagesCount?(rt=Ln(H.messagesCount),t[124]=H.messagesCount,t[125]=rt):rt=t[125];let pt;t[126]!==it||t[127]!==rt?(pt={label:it,value:rt},t[126]=it,t[127]=rt,t[128]=pt):pt=t[128];let ht;t[129]!==e?(ht=e("contextSidebar.stats.user"),t[129]=e,t[130]=ht):ht=t[130];let tt;t[131]!==H.userMessagesCount?(tt=Ln(H.userMessagesCount),t[131]=H.userMessagesCount,t[132]=tt):tt=t[132];let At;t[133]!==ht||t[134]!==tt?(At={label:ht,value:tt},t[133]=ht,t[134]=tt,t[135]=At):At=t[135];let jt;t[136]!==e?(jt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=jt):jt=t[137];let we;t[138]!==H.assistantMessagesCount?(we=Ln(H.assistantMessagesCount),t[138]=H.assistantMessagesCount,t[139]=we):we=t[139];let Xe;t[140]!==jt||t[141]!==we?(Xe={label:jt,value:we},t[140]=jt,t[141]=we,t[142]=Xe):Xe=t[142];let mt;t[143]!==e?(mt=e("contextSidebar.stats.cost"),t[143]=e,t[144]=mt):mt=t[144];let qe;t[145]!==H.totalAssistantCost?(qe=Jx(H.totalAssistantCost),t[145]=H.totalAssistantCost,t[146]=qe):qe=t[146];let ft;t[147]!==mt||t[148]!==qe?(ft={label:mt,value:qe},t[147]=mt,t[148]=qe,t[149]=ft):ft=t[149];let se;t[150]!==pt||t[151]!==At||t[152]!==Xe||t[153]!==ft?(se=[pt,At,Xe,ft],t[150]=pt,t[151]=At,t[152]=Xe,t[153]=ft,t[154]=se):se=t[154];const me=se;let Ie;t[155]!==me?(Ie=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:me.map(xw)}),t[155]=me,t[156]=Ie):Ie=t[156];let We;t[157]!==e?(We=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=We):We=t[158];let V;t[159]!==We?(V=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:We}),t[159]=We,t[160]=V):V=t[160];let Fe;t[161]!==e||t[162]!==H.cacheHitRate.hasInput||t[163]!==H.cacheHitRate.percent||t[164]!==H.tokenBreakdown.cacheRead||t[165]!==H.tokenBreakdown.cacheWrite||t[166]!==H.tokenBreakdown.input||t[167]!==H.tokenBreakdown.output||t[168]!==H.tokenBreakdown.reasoning?(Fe=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:H.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:H.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:H.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:H.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:H.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:H.cacheHitRate.hasInput?H.cacheHitRate.percent:null,format:"percent"}].map(bw)}),t[161]=e,t[162]=H.cacheHitRate.hasInput,t[163]=H.cacheHitRate.percent,t[164]=H.tokenBreakdown.cacheRead,t[165]=H.tokenBreakdown.cacheWrite,t[166]=H.tokenBreakdown.input,t[167]=H.tokenBreakdown.output,t[168]=H.tokenBreakdown.reasoning,t[169]=Fe):Fe=t[169];let Ye;t[170]!==V||t[171]!==Fe?(Ye=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[V,Fe]}),t[170]=V,t[171]=Fe,t[172]=Ye):Ye=t[172];let Qe;t[173]!==le||t[174]!==H.breakdownTotal?(Qe=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:le.map(He=>He.value<=0||H.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${He.value/H.breakdownTotal*100}%`,backgroundColor:He.color}},He.key))}),t[173]=le,t[174]=H.breakdownTotal,t[175]=Qe):Qe=t[175];let xe;t[176]!==le||t[177]!==H.breakdownTotal?(xe=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:le.map(He=>{const Ue=H.breakdownTotal>0?He.value/H.breakdownTotal*100:0;return s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:He.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[He.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ue.toFixed(0),"%"]})]})]},He.key)})}),t[176]=le,t[177]=H.breakdownTotal,t[178]=xe):xe=t[178];let st;t[179]!==Qe||t[180]!==xe?(st=s.jsxs("div",{className:"mb-6",children:[Qe,xe]}),t[179]=Qe,t[180]=xe,t[181]=st):st=t[181];let Re;t[182]!==e?(Re=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Re):Re=t[183];let ot;t[184]!==Re?(ot=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Re}),t[184]=Re,t[185]=ot):ot=t[185];let vt;if(t[186]!==l||t[187]!==i||t[188]!==p||t[189]!==e||t[190]!==n){let He;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(He=Ue=>{const lt=Ue.info.role,_e=lt==="assistant",Ge=lt==="user",Je=i[Ue.info.id]===!0,at=l===Ue.info.id,Nt=Ue.info.time?.created??null,Bt=q1(Ue.parts),Ft=_e?vc({info:Ue.info,parts:Ue.parts}):null,Qt=Ge?Q1(Ue.parts):"",Mt=Z1(Nt,n),Gt=Bt||"—",$t=Ft?X1(Ft.input,Ft.output,Ln):"",Zt=lt||"unknown",ts=Bt?`${Zt}: ${Bt}`:Zt,Ot=Je?JSON.stringify({info:Ue.info,parts:Ue.parts},null,2):"";return s.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[s.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":Je,onClick:()=>{o(Dt=>({...Dt,[Ue.info.id]:Dt[Ue.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:_e?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[Ge?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",Qt]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:_e?Gt:ts}),_e&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:$t})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:Mt})]})}),Je&&s.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:s.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[s.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:Dt=>{Dt.stopPropagation(),j(Ue.info.id,Ot)},"aria-label":e(at?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(at?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:at?s.jsx(O,{name:"check",className:"size-3.5"}):s.jsx(O,{name:"file-copy",className:"size-3.5"})})}),s.jsx(Jp,{language:"json",code:Ot,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ue.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=He):He=t[196],vt=[...p].reverse().map(He),t[186]=l,t[187]=i,t[188]=p,t[189]=e,t[190]=n,t[191]=vt}else vt=t[191];let De;t[197]!==vt?(De=s.jsx("div",{className:"mt-2.5 space-y-1",children:vt}),t[197]=vt,t[198]=De):De=t[198];let gt;t[199]!==ot||t[200]!==De?(gt=s.jsxs("div",{children:[ot,De]}),t[199]=ot,t[200]=De,t[201]=gt):gt=t[201];let Ct;return t[202]!==oe||t[203]!==et||t[204]!==Ie||t[205]!==Ye||t[206]!==st||t[207]!==gt?(Ct=s.jsx(gn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[oe,et,Ie,Ye,st,gt]})}),t[202]=oe,t[203]=et,t[204]=Ie,t[205]=Ye,t[206]=st,t[207]=gt,t[208]=Ct):Ct=t[208],Ct};function aw(t){return t.timeFormatPreference}function lw(t){return t.currentSessionId}function cw(t){return t.currentSessionDirectory}function dw(t){return t.providers}function uw(t){return Object.keys(t).length>0?{}:t}function fw(t){return t.info.role==="assistant"}function mw(t){return t.info.role==="user"}function hw(t){return t.info}function pw(t,e){const n=vn(e.info.cost);return t+n}function gw(t){return t.info.role==="system"}function xw(t){return s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value})]},t.label)}function bw(t){return s.jsxs("div",{children:[s.jsx("div",{className:"typography-micro text-muted-foreground/70",children:t.label}),s.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:t.value!==null&&t.value!==void 0?t.format==="percent"?`${t.value.toFixed(1)}%`:Ln(t.value):"—"})]},t.label)}const Nf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),yw=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Nf.has(n.toLowerCase())},Ks="about:blank",xr=t=>{const e=t.trim();if(!e)return Ks;const n=e.includes("://")?e:`${yw(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?Ks:r.toString()}catch{return Ks}},Sr=t=>{try{return Nf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},rl=t=>{if(!t||t===Ks)return"";try{return new URL(t).host||t}catch{return t}},ww=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),vw=(t,e)=>ww.has(t)&&Sr(e),Sw=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.port=="number"&&Number.isFinite(e.port)&&typeof e.url=="string"&&e.url.length>0&&typeof e.command=="string"},jw=async t=>{try{const e=await ls("/api/dev-servers",{signal:t});if(!e.ok)return{kind:"unavailable"};const n=await e.json();if(!n||typeof n!="object")return{kind:"unavailable"};const r=n.servers;return Array.isArray(r)?{kind:"ready",servers:r.filter(Sw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},kw=async t=>{try{const e=await ls("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!e.ok)return null;const n=await e.json();if(!n||typeof n!="object")return null;const r=n.status;return typeof r=="number"&&Number.isFinite(r)?r:null}catch{return null}},Cw=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:null}catch{return null}},Nw=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=Cw(r);i!==null&&!n.has(i)&&n.set(i,r)}return e?e.map(r=>{const i=n.get(r.port);return{url:i??r.url,port:r.port,announced:i!==void 0}}).sort((r,i)=>r.announced!==i.announced?r.announced?-1:1:r.port-i.port):[...n.entries()].map(([r,i])=>({url:i,port:r,announced:!0})).sort((r,i)=>r.port-i.port)},ga="__openchamberBrowserAnnotationActive",Aw=`(() => {
12
+ try {
13
+ var host = document.querySelector('[data-openchamber-annotation]');
14
+ if (host && host.parentNode) host.parentNode.removeChild(host);
15
+ } catch (error) { /* page navigated away */ }
16
+ try {
17
+ var cursor = document.getElementById('openchamber-annotation-cursor');
18
+ if (cursor && cursor.parentNode) cursor.parentNode.removeChild(cursor);
19
+ } catch (error) { /* page navigated away */ }
20
+ try { delete window['${ga}']; } catch (error) { /* non-configurable */ }
21
+ })();`,Pw=(t,e)=>{const n=JSON.stringify({theme:t,labels:e});return String.raw`new Promise((resolve) => {
22
+ var CONFIG = ${n};
23
+ var THEME = CONFIG.theme;
24
+ var LABELS = CONFIG.labels;
25
+ var OVERLAY_ATTR = 'data-openchamber-annotation';
26
+ var Z_OVERLAY = 2147483646;
27
+ var MAX_TEXT = 400;
28
+ var MIN_RECT = 3;
29
+ var EDITOR_GAP = 10;
30
+
31
+ try {
32
+ var stale = document.querySelector('[' + OVERLAY_ATTR + ']');
33
+ if (stale && stale.parentNode) stale.parentNode.removeChild(stale);
34
+ } catch (error) { /* nothing to clean */ }
35
+
36
+ window['${ga}'] = true;
37
+
38
+ var counter = 0;
39
+ var nextId = function (prefix) { counter += 1; return prefix + '-' + counter; };
40
+
41
+ var selected = null;
42
+ var regions = [];
43
+ var strokes = [];
44
+ var tool = 'select';
45
+ var settled = false;
46
+
47
+ // ---------------------------------------------------------------- geometry
48
+
49
+ var rectFrom = function (domRect) {
50
+ return { x: domRect.left, y: domRect.top, width: domRect.width, height: domRect.height };
51
+ };
52
+ var normalizeRect = function (ax, ay, bx, by) {
53
+ return { x: Math.min(ax, bx), y: Math.min(ay, by), width: Math.abs(bx - ax), height: Math.abs(by - ay) };
54
+ };
55
+ var usableRect = function (rect) { return rect.width >= MIN_RECT && rect.height >= MIN_RECT; };
56
+
57
+ // ------------------------------------------------------------- description
58
+
59
+ var isOverlayNode = function (element) {
60
+ var node = element;
61
+ while (node) {
62
+ if (node.nodeType === 1 && node.hasAttribute && node.hasAttribute(OVERLAY_ATTR)) return true;
63
+ node = node.parentNode || (node.host || null);
64
+ }
65
+ return false;
66
+ };
67
+
68
+ var elementFromPoint = function (x, y) {
69
+ var found = document.elementFromPoint(x, y);
70
+ if (!found || isOverlayNode(found)) return null;
71
+ return found;
72
+ };
73
+
74
+ var selectorPart = function (element) {
75
+ var part = element.tagName.toLowerCase();
76
+ if (element.id) return part + '#' + element.id;
77
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
78
+ if (className) {
79
+ var first = className.split(/\s+/).filter(Boolean).slice(0, 2).join('.');
80
+ if (first) part += '.' + first;
81
+ }
82
+ return part;
83
+ };
84
+
85
+ var buildSelector = function (element) {
86
+ if (element.id) return '#' + element.id;
87
+ var parts = [];
88
+ var node = element;
89
+ var depth = 0;
90
+ while (node && node.nodeType === 1 && depth < 5) {
91
+ var part = selectorPart(node);
92
+ var parent = node.parentElement;
93
+ if (parent) {
94
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
95
+ return child.tagName === node.tagName;
96
+ });
97
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
98
+ }
99
+ parts.unshift(part);
100
+ if (node.id) break;
101
+ node = parent;
102
+ depth += 1;
103
+ }
104
+ return parts.join(' > ');
105
+ };
106
+
107
+ var INTERESTING_ATTRS = ['id', 'class', 'name', 'type', 'href', 'src', 'alt', 'title', 'role', 'placeholder', 'aria-label', 'data-testid'];
108
+ var STYLE_PROPS = [
109
+ 'display', 'position', 'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontFamily',
110
+ 'lineHeight', 'padding', 'margin', 'border', 'borderRadius', 'width', 'height', 'opacity',
111
+ 'zIndex', 'flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign'
112
+ ];
113
+
114
+ var describe = function (element) {
115
+ var computed = window.getComputedStyle(element);
116
+ var attributes = {};
117
+ for (var i = 0; i < INTERESTING_ATTRS.length; i += 1) {
118
+ var name = INTERESTING_ATTRS[i];
119
+ var value = element.getAttribute(name);
120
+ if (value) attributes[name] = String(value).slice(0, 200);
121
+ }
122
+ var computedStyle = {};
123
+ for (var j = 0; j < STYLE_PROPS.length; j += 1) {
124
+ var prop = STYLE_PROPS[j];
125
+ computedStyle[prop] = String(computed[prop] == null ? '' : computed[prop]);
126
+ }
127
+ var ancestry = [];
128
+ var node = element.parentElement;
129
+ var depth = 0;
130
+ while (node && node.nodeType === 1 && depth < 4) {
131
+ var entry = { tag: node.tagName.toLowerCase(), selectorPart: selectorPart(node) };
132
+ if (node.id) entry.id = node.id;
133
+ var cls = typeof node.className === 'string' ? node.className.trim() : '';
134
+ if (cls) entry.className = cls.slice(0, 200);
135
+ ancestry.unshift(entry);
136
+ node = node.parentElement;
137
+ depth += 1;
138
+ }
139
+ var box = element.getBoundingClientRect();
140
+ var text = (element.textContent == null ? '' : String(element.textContent)).replace(/\s+/g, ' ').trim();
141
+ return {
142
+ tag: element.tagName.toLowerCase(),
143
+ text: text.slice(0, MAX_TEXT),
144
+ selector: buildSelector(element),
145
+ path: ancestry.map(function (e) { return e.selectorPart; }).concat([selectorPart(element)]).join(' > '),
146
+ bounds: rectFrom(box),
147
+ center: { x: box.left + box.width / 2, y: box.top + box.height / 2 },
148
+ attributes: attributes,
149
+ computedStyle: computedStyle,
150
+ ancestry: ancestry
151
+ };
152
+ };
153
+
154
+ // ------------------------------------------------------------------ chrome
155
+
156
+ var host = document.createElement('div');
157
+ host.setAttribute(OVERLAY_ATTR, '');
158
+ host.style.cssText = 'position:fixed;inset:0;z-index:' + Z_OVERLAY + ';pointer-events:none';
159
+ var shadow = host.attachShadow({ mode: 'closed' });
160
+
161
+ var style = document.createElement('style');
162
+ style.textContent = [
163
+ ':host{all:initial}',
164
+ '*{box-sizing:border-box;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}',
165
+ '.layer{position:fixed;inset:0;pointer-events:none}',
166
+ '.box{position:fixed;left:0;top:0;display:none;pointer-events:none;border:1.5px solid ' + THEME.primary + ';background:' + THEME.primarySoft + ';border-radius:2px}',
167
+ '.label{position:fixed;left:0;top:0;display:none;pointer-events:none;padding:1px 6px;border-radius:4px;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';font-size:11px;line-height:17px;white-space:nowrap;font-weight:600}',
168
+ '.tools{position:fixed;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:2px;padding:4px;border-radius:999px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 6px 20px rgba(0,0,0,.24);pointer-events:auto}',
169
+ '.tools button{appearance:none;border:none;background:transparent;color:' + THEME.mutedText + ';border-radius:999px;padding:5px 14px;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap}',
170
+ '.tools button:hover{background:' + THEME.primaryFaint + '}',
171
+ '.tools button[aria-pressed="true"]{background:' + THEME.primarySoft + ';color:' + THEME.primary + ';font-weight:600}',
172
+ '.editor{position:fixed;left:0;top:0;display:none;align-items:center;gap:8px;width:min(420px,calc(100vw - 24px));padding:6px;padding-left:16px;border-radius:22px;border:1px solid ' + THEME.border + ';background:' + THEME.glassSurface + ';-webkit-backdrop-filter:' + THEME.glassFilter + ';backdrop-filter:' + THEME.glassFilter + ';box-shadow:0 8px 28px rgba(0,0,0,.3);pointer-events:auto}',
173
+ '.editor textarea{flex:1;min-width:0;resize:none;border:none;background:transparent;color:' + THEME.text + ';font-size:13px;line-height:20px;outline:none;padding:6px 0;min-height:32px;max-height:104px;display:block}',
174
+ '.editor textarea::placeholder{color:' + THEME.mutedText + '}',
175
+ '.editor button{appearance:none;border:none;background:' + THEME.primary + ';color:' + THEME.primaryContrast + ';border-radius:999px;width:32px;height:32px;padding:0;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer}',
176
+ '.editor button svg{width:16px;height:16px;display:block}',
177
+ '.editor button[disabled]{opacity:.5;cursor:default}'
178
+ ].join('');
179
+ shadow.appendChild(style);
180
+
181
+ var cursorStyle = document.createElement('style');
182
+ cursorStyle.id = 'openchamber-annotation-cursor';
183
+ document.head.appendChild(cursorStyle);
184
+ var setCursor = function (value) {
185
+ cursorStyle.textContent = value ? '*{cursor:' + value + ' !important}' : '';
186
+ };
187
+
188
+ var svgNS = 'http://www.w3.org/2000/svg';
189
+ var svg = document.createElementNS(svgNS, 'svg');
190
+ svg.setAttribute('class', 'layer');
191
+ svg.style.overflow = 'visible';
192
+ shadow.appendChild(svg);
193
+
194
+ var hoverBox = document.createElement('div');
195
+ hoverBox.className = 'box';
196
+ var hoverLabel = document.createElement('div');
197
+ hoverLabel.className = 'label';
198
+ var marqueeBox = document.createElement('div');
199
+ marqueeBox.className = 'box';
200
+ shadow.append(hoverBox, hoverLabel, marqueeBox);
201
+
202
+ var positionBox = function (node, rect) {
203
+ node.style.display = 'block';
204
+ node.style.transform = 'translate(' + rect.x + 'px,' + rect.y + 'px)';
205
+ node.style.width = rect.width + 'px';
206
+ node.style.height = rect.height + 'px';
207
+ };
208
+
209
+ var tools = document.createElement('div');
210
+ tools.className = 'tools';
211
+ shadow.appendChild(tools);
212
+
213
+ var toolButtons = {};
214
+ [['select', LABELS.select], ['marquee', LABELS.marquee], ['draw', LABELS.draw]].forEach(function (entry) {
215
+ var button = document.createElement('button');
216
+ button.type = 'button';
217
+ button.textContent = entry[1];
218
+ button.addEventListener('click', function () { setTool(entry[0]); });
219
+ toolButtons[entry[0]] = button;
220
+ tools.appendChild(button);
221
+ });
222
+
223
+ var editor = document.createElement('div');
224
+ editor.className = 'editor';
225
+ shadow.appendChild(editor);
226
+
227
+ var comment = document.createElement('textarea');
228
+ comment.rows = 1;
229
+ comment.placeholder = LABELS.commentPlaceholder;
230
+ var submit = document.createElement('button');
231
+ submit.type = 'button';
232
+ // Icon-only attach button (Remix attachment-2), matching the chat comment
233
+ // input; the localized label stays available to assistive tech.
234
+ submit.setAttribute('aria-label', LABELS.submit);
235
+ submit.title = LABELS.submit;
236
+ submit.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.8287 7.75737L9.1718 13.4142C8.78127 13.8047 8.78127 14.4379 9.1718 14.8284C9.56232 15.219 10.1955 15.219 10.586 14.8284L16.2429 9.17158C17.4144 8.00001 17.4144 6.10052 16.2429 4.92894C15.0713 3.75737 13.1718 3.75737 12.0002 4.92894L6.34337 10.5858C4.39075 12.5384 4.39075 15.7042 6.34337 17.6569C8.29599 19.6095 11.4618 19.6095 13.4144 17.6569L19.0713 12L20.4855 13.4142L14.8287 19.0711C12.095 21.8047 7.66283 21.8047 4.92916 19.0711C2.19549 16.3374 2.19549 11.9053 4.92916 9.17158L10.586 3.51473C12.5386 1.56211 15.7045 1.56211 17.6571 3.51473C19.6097 5.46735 19.6097 8.63317 17.6571 10.5858L12.0002 16.2427C10.8287 17.4142 8.92916 17.4142 7.75759 16.2427C6.58601 15.0711 6.58601 13.1716 7.75759 12L13.4144 6.34316L14.8287 7.75737Z" fill="currentColor"/></svg>';
237
+ editor.append(comment, submit);
238
+
239
+ /**
240
+ * Grows the box with its content.
241
+ *
242
+ * A hidden element reports scrollHeight 0, so measuring one collapses the
243
+ * field to nothing — which is what left a sliver of a click target and an
244
+ * invisible caret. Measuring only while visible, and never below the CSS
245
+ * min-height, keeps it usable.
246
+ */
247
+ var resizeComment = function () {
248
+ if (editor.style.display === 'none') return;
249
+ comment.style.height = 'auto';
250
+ comment.style.height = Math.max(32, Math.min(comment.scrollHeight, 104)) + 'px';
251
+ };
252
+ comment.addEventListener('input', resizeComment);
253
+
254
+ // -------------------------------------------------------------- selection
255
+
256
+ var lastTargetRect = null;
257
+
258
+ /** Places the comment box under whatever was just marked, kept on screen. */
259
+ var positionEditor = function () {
260
+ if (!lastTargetRect) {
261
+ editor.style.display = 'none';
262
+ return;
263
+ }
264
+ var wasHidden = editor.style.display === 'none';
265
+ editor.style.display = 'flex';
266
+ // Measured now that it is laid out, not while it was still hidden.
267
+ if (wasHidden) resizeComment();
268
+ var box = editor.getBoundingClientRect();
269
+ var left = lastTargetRect.x + lastTargetRect.width / 2 - box.width / 2;
270
+ var top = lastTargetRect.y + lastTargetRect.height + EDITOR_GAP;
271
+ // Above the target when there is no room below, so the box is never left
272
+ // half off the bottom of the page.
273
+ if (top + box.height > window.innerHeight - 8) {
274
+ top = Math.max(8, lastTargetRect.y - box.height - EDITOR_GAP);
275
+ }
276
+ left = Math.max(8, Math.min(left, window.innerWidth - box.width - 8));
277
+ editor.style.transform = 'translate(' + Math.round(left) + 'px,' + Math.round(top) + 'px)';
278
+ };
279
+
280
+ /** Focus after layout: focusing a zero-height field puts the caret nowhere. */
281
+ var focusComment = function () {
282
+ requestAnimationFrame(function () {
283
+ try {
284
+ comment.focus({ preventScroll: true });
285
+ comment.setSelectionRange(comment.value.length, comment.value.length);
286
+ } catch (error) { /* field went away */ }
287
+ });
288
+ };
289
+
290
+ var hasTargets = function () {
291
+ return Boolean(selected) || regions.length > 0 || strokes.length > 0;
292
+ };
293
+
294
+ var syncChrome = function () {
295
+ submit.disabled = !hasTargets();
296
+ if (!hasTargets()) {
297
+ lastTargetRect = null;
298
+ editor.style.display = 'none';
299
+ return;
300
+ }
301
+ positionEditor();
302
+ };
303
+
304
+ var syncSelectionVisuals = function () {
305
+ if (!selected) return;
306
+ var rect = rectFrom(selected.element.getBoundingClientRect());
307
+ if (!usableRect(rect)) {
308
+ selected.outline.style.display = 'none';
309
+ selected.badge.style.display = 'none';
310
+ return;
311
+ }
312
+ positionBox(selected.outline, rect);
313
+ selected.badge.style.display = 'block';
314
+ selected.badge.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
315
+ lastTargetRect = rect;
316
+ };
317
+
318
+ var dropSelection = function () {
319
+ if (!selected) return;
320
+ selected.outline.remove();
321
+ selected.badge.remove();
322
+ selected = null;
323
+ };
324
+
325
+ var selectElement = function (element) {
326
+ var wasSelected = selected && selected.element === element;
327
+ dropSelection();
328
+ if (wasSelected) {
329
+ // Clicking the chosen element again clears it, so a misclick costs one
330
+ // click rather than starting over.
331
+ lastTargetRect = null;
332
+ syncChrome();
333
+ return;
334
+ }
335
+ var outline = document.createElement('div');
336
+ outline.className = 'box';
337
+ var badge = document.createElement('div');
338
+ badge.className = 'label';
339
+ badge.textContent = selectorPart(element);
340
+ shadow.append(outline, badge);
341
+ selected = { id: nextId('element'), element: element, outline: outline, badge: badge };
342
+ syncSelectionVisuals();
343
+ syncChrome();
344
+ focusComment();
345
+ };
346
+
347
+ var setTool = function (next) {
348
+ tool = next;
349
+ hoverBox.style.display = 'none';
350
+ hoverLabel.style.display = 'none';
351
+ marqueeBox.style.display = 'none';
352
+ setCursor(next === 'select' ? '' : 'crosshair');
353
+ for (var key in toolButtons) {
354
+ if (Object.prototype.hasOwnProperty.call(toolButtons, key)) {
355
+ toolButtons[key].setAttribute('aria-pressed', key === next ? 'true' : 'false');
356
+ }
357
+ }
358
+ };
359
+
360
+ // ------------------------------------------------------------- interaction
361
+
362
+ var drag = null;
363
+
364
+ var onPointerMove = function (event) {
365
+ if (drag) {
366
+ if (drag.kind === 'marquee') {
367
+ drag.rect = normalizeRect(drag.startX, drag.startY, event.clientX, event.clientY);
368
+ positionBox(marqueeBox, drag.rect);
369
+ } else if (drag.kind === 'draw') {
370
+ drag.points.push({ x: event.clientX, y: event.clientY });
371
+ drag.path.setAttribute('d', drag.points.map(function (point, index) {
372
+ return (index === 0 ? 'M' : 'L') + point.x + ' ' + point.y;
373
+ }).join(' '));
374
+ }
375
+ return;
376
+ }
377
+
378
+ if (tool !== 'select') return;
379
+ var element = elementFromPoint(event.clientX, event.clientY);
380
+ if (!element) {
381
+ hoverBox.style.display = 'none';
382
+ hoverLabel.style.display = 'none';
383
+ return;
384
+ }
385
+ var rect = rectFrom(element.getBoundingClientRect());
386
+ positionBox(hoverBox, rect);
387
+ hoverLabel.textContent = selectorPart(element);
388
+ hoverLabel.style.display = 'block';
389
+ hoverLabel.style.transform = 'translate(' + Math.max(2, rect.x) + 'px,' + Math.max(2, rect.y - 19) + 'px)';
390
+ };
391
+
392
+ var onPointerDown = function (event) {
393
+ if (event.button !== 0) return;
394
+ if (isOverlayNode(event.target)) return;
395
+ event.preventDefault();
396
+ event.stopPropagation();
397
+
398
+ if (tool === 'select') {
399
+ var element = elementFromPoint(event.clientX, event.clientY);
400
+ if (element) selectElement(element);
401
+ return;
402
+ }
403
+
404
+ if (tool === 'marquee') {
405
+ drag = { kind: 'marquee', startX: event.clientX, startY: event.clientY, rect: null };
406
+ return;
407
+ }
408
+
409
+ var path = document.createElementNS(svgNS, 'path');
410
+ path.setAttribute('fill', 'none');
411
+ path.setAttribute('stroke', THEME.primary);
412
+ path.setAttribute('stroke-width', '2.5');
413
+ path.setAttribute('stroke-linecap', 'round');
414
+ path.setAttribute('stroke-linejoin', 'round');
415
+ svg.appendChild(path);
416
+ drag = { kind: 'draw', path: path, points: [{ x: event.clientX, y: event.clientY }] };
417
+ };
418
+
419
+ var onPointerUp = function () {
420
+ if (!drag) return;
421
+ var finished = drag;
422
+ drag = null;
423
+
424
+ if (finished.kind === 'marquee') {
425
+ marqueeBox.style.display = 'none';
426
+ var rect = finished.rect;
427
+ if (!rect || !usableRect(rect)) return;
428
+ // A region marks an area, not the elements inside it: expanding it into a
429
+ // selection made the result depend on the page's markup rather than on
430
+ // what was drawn.
431
+ regions.push({ id: nextId('region'), rect: rect });
432
+ var outline = document.createElementNS(svgNS, 'rect');
433
+ outline.setAttribute('x', String(rect.x));
434
+ outline.setAttribute('y', String(rect.y));
435
+ outline.setAttribute('width', String(rect.width));
436
+ outline.setAttribute('height', String(rect.height));
437
+ outline.style.fill = THEME.primarySoft;
438
+ outline.setAttribute('stroke', THEME.primary);
439
+ outline.setAttribute('stroke-width', '1.5');
440
+ outline.setAttribute('rx', '2');
441
+ svg.appendChild(outline);
442
+ lastTargetRect = rect;
443
+ syncChrome();
444
+ focusComment();
445
+ return;
446
+ }
447
+
448
+ var points = finished.points;
449
+ if (points.length < 2) {
450
+ if (finished.path.parentNode) finished.path.parentNode.removeChild(finished.path);
451
+ return;
452
+ }
453
+ var minX = points[0].x, minY = points[0].y, maxX = points[0].x, maxY = points[0].y;
454
+ for (var p = 1; p < points.length; p += 1) {
455
+ minX = Math.min(minX, points[p].x);
456
+ minY = Math.min(minY, points[p].y);
457
+ maxX = Math.max(maxX, points[p].x);
458
+ maxY = Math.max(maxY, points[p].y);
459
+ }
460
+ var bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
461
+ strokes.push({ id: nextId('stroke'), points: points, bounds: bounds });
462
+ lastTargetRect = bounds;
463
+ syncChrome();
464
+ focusComment();
465
+ };
466
+
467
+ /**
468
+ * Swallows the page's own mouse handling while annotating.
469
+ *
470
+ * Blocking pointerdown is not enough: a click still follows it, so marking a
471
+ * button pressed that button and marking a link navigated away from the page
472
+ * being annotated. These are the events that reach page code, so these are
473
+ * the ones that have to stop.
474
+ */
475
+ var blockPageInteraction = function (event) {
476
+ if (isOverlayNode(event.target)) return;
477
+ event.preventDefault();
478
+ event.stopPropagation();
479
+ };
480
+ var BLOCKED_EVENTS = ['click', 'auxclick', 'dblclick', 'mousedown', 'mouseup', 'contextmenu'];
481
+
482
+ var onScrollOrResize = function () {
483
+ syncSelectionVisuals();
484
+ positionEditor();
485
+ };
486
+
487
+ var onKeyDown = function (event) {
488
+ if (event.isComposing || event.keyCode === 229) return;
489
+ if (event.key === 'Escape') {
490
+ event.preventDefault();
491
+ event.stopImmediatePropagation();
492
+ finish(null);
493
+ }
494
+ };
495
+
496
+ var onCommentKeyDown = function (event) {
497
+ // Do not let the annotated page treat typed letters as its own shortcuts.
498
+ event.stopPropagation();
499
+ // WebKit can report the composition-confirming Enter as keyCode 229.
500
+ if (event.isComposing || event.keyCode === 229) return;
501
+ if (event.key === 'Enter' && !event.shiftKey) {
502
+ event.preventDefault();
503
+ attach();
504
+ }
505
+ };
506
+
507
+ document.addEventListener('pointermove', onPointerMove, true);
508
+ document.addEventListener('pointerdown', onPointerDown, true);
509
+ document.addEventListener('pointerup', onPointerUp, true);
510
+ BLOCKED_EVENTS.forEach(function (name) {
511
+ window.addEventListener(name, blockPageInteraction, { capture: true, passive: false });
512
+ });
513
+ window.addEventListener('scroll', onScrollOrResize, true);
514
+ window.addEventListener('resize', onScrollOrResize, true);
515
+ window.addEventListener('keydown', onKeyDown, true);
516
+ comment.addEventListener('keydown', onCommentKeyDown);
517
+
518
+ // ------------------------------------------------------------------ finish
519
+
520
+ var teardown = function () {
521
+ document.removeEventListener('pointermove', onPointerMove, true);
522
+ document.removeEventListener('pointerdown', onPointerDown, true);
523
+ document.removeEventListener('pointerup', onPointerUp, true);
524
+ BLOCKED_EVENTS.forEach(function (name) {
525
+ window.removeEventListener(name, blockPageInteraction, true);
526
+ });
527
+ window.removeEventListener('scroll', onScrollOrResize, true);
528
+ window.removeEventListener('resize', onScrollOrResize, true);
529
+ window.removeEventListener('keydown', onKeyDown, true);
530
+ comment.removeEventListener('keydown', onCommentKeyDown);
531
+ setCursor('');
532
+ if (cursorStyle.parentNode) cursorStyle.parentNode.removeChild(cursorStyle);
533
+ if (host.parentNode) host.parentNode.removeChild(host);
534
+ try { delete window['${ga}']; } catch (error) { /* non-configurable */ }
535
+ };
536
+
537
+ var finish = function (payload) {
538
+ if (settled) return;
539
+ settled = true;
540
+ teardown();
541
+ // Removing the chrome is not enough: the host screenshots this page right
542
+ // after we resolve, and the compositor can still hold a frame containing
543
+ // our outlines. Yield two frames so the page has actually repainted.
544
+ requestAnimationFrame(function () {
545
+ requestAnimationFrame(function () { resolve(payload); });
546
+ });
547
+ };
548
+
549
+ var attach = function () {
550
+ if (!hasTargets()) return;
551
+ finish({
552
+ id: 'annotation-' + Date.now(),
553
+ pageUrl: String(location.href),
554
+ pageTitle: String(document.title || ''),
555
+ viewport: { width: window.innerWidth, height: window.innerHeight },
556
+ devicePixelRatio: window.devicePixelRatio || 1,
557
+ comment: comment.value,
558
+ // Zero or one element, never more. Kept as a list so elements, regions
559
+ // and strokes stay one uniform shape for everything downstream.
560
+ elements: selected ? [{ id: selected.id, element: describe(selected.element) }] : [],
561
+ regions: regions.map(function (entry) { return { id: entry.id, rect: entry.rect }; }),
562
+ strokes: strokes.map(function (entry) {
563
+ return { id: entry.id, points: entry.points, bounds: entry.bounds };
564
+ })
565
+ });
566
+ };
567
+
568
+ submit.addEventListener('click', attach);
569
+
570
+ (document.body || document.documentElement).appendChild(host);
571
+ setTool('select');
572
+ syncChrome();
573
+ });`},Dw={kind:"idle"},tn=t=>typeof t=="object"&&t!==null,dn=t=>typeof t=="number"&&Number.isFinite(t),jc=t=>tn(t)&&Object.values(t).every(e=>typeof e=="string"),ol=t=>tn(t)&&dn(t.x)&&dn(t.y)&&dn(t.width)&&dn(t.height),Af=t=>tn(t)&&dn(t.x)&&dn(t.y),Iw=t=>tn(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"),Tw=t=>tn(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&ol(t.bounds)&&Af(t.center)&&jc(t.attributes)&&jc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Iw),Ew=t=>tn(t)&&typeof t.id=="string"&&Tw(t.element),Rw=t=>tn(t)&&typeof t.id=="string"&&ol(t.rect),Mw=t=>tn(t)&&typeof t.id=="string"&&ol(t.bounds)&&Array.isArray(t.points)&&t.points.every(Af),Ow=t=>tn(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&tn(t.viewport)&&dn(t.viewport.width)&&dn(t.viewport.height)&&dn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(Ew)&&Array.isArray(t.regions)&&t.regions.every(Rw)&&Array.isArray(t.strokes)&&t.strokes.every(Mw),Bw=1600,Fw=t=>new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=()=>n(new Error("Failed to decode browser page capture")),r.src=t}),Lw=async({base64:t,mime:e,captureWidth:n,captureHeight:r,cssWidth:i,cssHeight:o,payload:l,accentColor:a,accentFill:d})=>{if(!t)return null;try{const u=await Fw(`data:${e};base64,${t}`),h=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),p=h/Math.max(1,i||h),x=f/Math.max(1,o||f),b=Math.min(1,Bw/h),k=document.createElement("canvas");k.width=Math.max(1,Math.floor(h*b)),k.height=Math.max(1,Math.floor(f*b));const y=k.getContext("2d");if(!y)return null;y.scale(b,b),y.drawImage(u,0,0,h,f);const m=w=>({x:w.x*p,y:w.y*x,width:w.width*p,height:w.height*x}),g=Math.max(2,2.5*p/Math.max(b,.2));y.strokeStyle=a,y.fillStyle=d;const j=w=>{const C=m(w);y.lineWidth=g,y.fillRect(C.x,C.y,C.width,C.height),y.strokeRect(C.x,C.y,C.width,C.height)};for(const w of l.elements)j(w.element.bounds);for(const w of l.regions)j(w.rect);for(const w of l.strokes)w.points.length<2||(y.beginPath(),w.points.forEach((C,v)=>{const R=C.x*p,T=C.y*x;v===0?y.moveTo(R,T):y.lineTo(R,T)}),y.lineCap="round",y.lineJoin="round",y.lineWidth=g*1.4,y.stroke());const S=await new Promise(w=>k.toBlob(w,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},_w="({ width: window.innerWidth, height: window.innerHeight })",$w=async t=>{try{const e=await t.executeJavaScript(_w,!0);if(!e||typeof e!="object")return null;const n=e;return typeof n.width!="number"||typeof n.height!="number"||!Number.isFinite(n.width)||!Number.isFinite(n.height)?null:{width:n.width,height:n.height}}catch{return null}},Po=async t=>{try{await t.executeJavaScript(Aw,!1)}catch{}},zw=async({host:t,theme:e,labels:n})=>{const r=Pw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!Ow(i))return await Po(t),null;const o=i;try{const l=await $w(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await Lw({base64:a.base64,mime:a.mime||"image/jpeg",captureWidth:a.width,captureHeight:a.height,cssWidth:l.width,cssHeight:l.height,payload:o,accentColor:e.primary,accentFill:e.primarySoft});return{payload:o,screenshot:d}}catch{return{payload:o,screenshot:null}}},zs={colorScheme:"dark",primary:"rgb(59, 130, 246)",primarySoft:"rgba(59, 130, 246, 0.16)",primaryFaint:"rgba(59, 130, 246, 0.10)",primaryContrast:"rgb(255, 255, 255)",surface:"rgb(24, 24, 27)",surfaceElevated:"rgb(32, 32, 36)",glassSurface:"rgba(32, 32, 36, 0.64)",glassFilter:"blur(26px) saturate(1.16)",border:"rgba(255, 255, 255, 0.14)",text:"rgb(244, 244, 245)",mutedText:"rgba(244, 244, 245, 0.62)"},Ww=()=>{if(typeof document>"u"||!document.body)return null;const t=document.createElement("div");return t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none",document.body.appendChild(t),{read:e=>{t.style.backgroundColor="",t.style.backgroundColor=e;const n=window.getComputedStyle(t).backgroundColor;return n&&n!=="rgba(0, 0, 0, 0)"?n:""},readVariable:e=>window.getComputedStyle(document.documentElement).getPropertyValue(e).trim(),dispose:()=>t.remove()}},Kw=t=>{const e=Ww();if(!e)return{...zs,colorScheme:t};try{const n=(a,d)=>e.read(`var(${a})`)||d,r=(a,d,u)=>e.read(`color-mix(in srgb, var(${a}) ${d}%, transparent)`)||u,i=e.readVariable("--oc-glass-tooltip-opacity")||"62%",o=e.readVariable("--oc-glass-blur")||"26px",l=e.readVariable("--oc-glass-saturation")||"1.16";return{colorScheme:t,glassSurface:e.read(`color-mix(in srgb, var(--surface-elevated) ${i}, transparent)`)||zs.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",zs.primary),primarySoft:r("--primary",16,zs.primarySoft),primaryFaint:r("--primary",10,zs.primaryFaint),primaryContrast:n("--primary-foreground",zs.primaryContrast),surface:n("--surface-background",zs.surface),surfaceElevated:n("--surface-elevated",zs.surfaceElevated),border:n("--border",zs.border),text:n("--foreground",zs.text),mutedText:n("--muted-foreground",zs.mutedText)}}catch{return{...zs,colorScheme:t}}finally{e.dispose()}},Vw=2e3,Uw=50,Hw=400,Os=new Map;let xa=null,Sn=null,zr=null;const ba=async t=>{try{const e=await ls("/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}},cn=async(t,e)=>{try{const n=await ls("/api/browser-control/result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,...e})});n.ok||console.warn(`[browser-control] the server rejected the result for ${t} (HTTP ${n.status}); the agent will see this action time out`)}catch(n){console.warn(`[browser-control] could not deliver the result for ${t}:`,n)}},Gw=async(t,e=Vw)=>{const n=Date.now()+e;for(;!Os.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,Uw));return Os.get(t)??null},Pf=()=>{const t=xa?Os.get(xa):void 0;if(t)return t;let e=null;for(const n of Os.values())e=n;return e},qw=()=>{const t=Pf();return[...Os.values()].map(e=>{let n={title:"",url:""};try{n=e.describe()}catch{}return{id:e.tabId,title:n.title,url:n.url,active:e===t}})},Yw=t=>`There is no browser tab with id ${t}. Call browser.snapshot to list the open tabs, or omit tabId to use the tab the user is looking at.`,Qw=async t=>{const e=t.action==="browser.open",{tabId:n,...r}=t.parameters,i=n===void 0?null:String(n);if(i!==null){const l=Os.get(i);if(!l){if(Os.size===0&&!Sn)return;if(await new Promise(a=>setTimeout(a,Hw)),Os.has(i)){await kc(t,Os.get(i),r);return}if(!await ba(t.requestId))return;await cn(t.requestId,{ok:!1,error:Yw(i)});return}await kc(t,l,r);return}const o=Pf();if(!(!o&&!(e&&Sn))&&await ba(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await cn(t.requestId,{ok:!1,error:"url is required"});return}const a=e&&Sn?Sn(l):null;if(e&&!a&&!o){await cn(t.requestId,{ok:!1,error:"There is no browser here to open the page in."});return}if(a){const d=typeof t.parameters.viewport=="string"?t.parameters.viewport:"";if(!d||d==="fill"){await cn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a}});return}const u=await Gw(a);if(!u){await cn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const h=await u.run("browser.resize",{viewport:d}),f=h&&typeof h=="object"?h.viewport??null:null;await cn(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!0,viewport:f}});return}await cn(t.requestId,await Df(o,t.action,r))}catch(l){await cn(t.requestId,{ok:!1,error:l instanceof Error?l.message:String(l)})}},kc=async(t,e,n)=>{await ba(t.requestId)&&await cn(t.requestId,await Df(e,t.action,n))},Df=async(t,e,n)=>{try{const r=await t.run(e,n);return e==="browser.snapshot"&&Object(r)===r?{ok:!0,data:{...Object(r),tabs:qw()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},If=()=>{zr||(zr=Pn(t=>{t.type==="browser-control-request"&&Qw({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},Tf=()=>{Os.size>0||Sn||!zr||(zr(),zr=null)},Xw=t=>(Os.set(t.tabId,t),If(),()=>{Os.get(t.tabId)===t&&Os.delete(t.tabId),Tf()}),Jw=t=>{xa=t},Zw=t=>(Sn=t,If(),()=>{Sn===t&&(Sn=null),Tf()}),ev=50,tv=6,sv=2048,nv=200,Ef=t=>{const e=xr(String(t??"").trim());if(!e||e.length>sv)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},rv=(t,e)=>{const n=Ef(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,nv)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,ev)},ov=(t,e)=>{const n=Ef(e);return t.filter(r=>r.url!==n)},iv=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Rf=(t,e,n=tv)=>{const r=String(e??"").trim().toLowerCase(),i=[...t].sort((l,a)=>a.lastVisitedAt-l.lastVisitedAt);if(!r)return i.slice(0,n);const o=r.replace(/^https?:\/\//,"");return i.filter(l=>{const a=iv(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Cc=20,Do=t=>{const e=xt((t||"").trim());return e?JSON.stringify([Wt(),e]):""},av=t=>{const e=Object.keys(t);if(e.length<=Cc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Cc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},br=Zr()(bb(t=>({byProject:{},recordVisit:(e,n)=>{const r=Do(e);r&&t(i=>{const o=i.byProject[r]??[],l=rv(o,{...n,at:Date.now()});return l===o?i:{byProject:av({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=Do(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:ov(o,n)}}:i})},clear:e=>{const n=Do(e);n&&t(r=>{if(!(n in r.byProject))return r;const i={...r.byProject};return delete i[n],{byProject:i}})}}),{name:"openchamber-browser-history",version:1,storage:oh(),partialize:t=>({byProject:t.byProject})})),lv=[],Mf=t=>e=>{const n=Do(t);return(n?e.byProject[n]:void 0)??lv},ya=new Map,pi=new Map,Gn=new Map,qn=new Set,cv=async(t,e)=>{if(!bl()){qn.delete(t),dr(t,{type:"close"});return}if(await ih(mn()),!qn.has(t)||!bl())return;const n=zd().websocket(`/api/dev-tunnel?port=${e}`),r=ah(n);Gn.set(t,r),r.binaryType="arraybuffer",r.onopen=()=>dr(t,{type:"ready"}),r.onmessage=i=>dr(t,{type:"data",data:i.data instanceof ArrayBuffer?i.data:new TextEncoder().encode(i.data)}),r.onerror=()=>dr(t,{type:"close"}),r.onclose=()=>{qn.delete(t),Gn.delete(t),dr(t,{type:"close"})}};Zp(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Gn.get(t);r&&n.data&&r.send(n.data);return}case"close":qn.delete(t),Gn.get(t)?.close(),Gn.delete(t);return;case"connect":qn.add(t),cv(t,e).catch(()=>{qn.delete(t),dr(t,{type:"close"})})}});const Of=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Bf=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),n=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return n&&e.origin===n?!1:!Sr(e.toString())}catch{return!1}},Ff=t=>{try{const e=new URL(t),n=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(n)&&n>0?n:0}catch{return 0}},Nc=(t,e)=>{try{const n=new URL(t);return n.protocol="http:",n.hostname="127.0.0.1",n.port=String(e),n.toString()}catch{return t}},Ac=(t,e)=>{try{pi.set(e,new URL(t).origin)}catch{}};class Wr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Pc=async t=>{if(!t||!Of()||!Sr(t))return t;const e=mn();if(!Bf(e))return t;const n=Ff(t);if(!n)return t;const r=`${e}|${n}`,i=ya.get(r);if(i)return Ac(t,i),Nc(t,i);try{const o=await pr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:lh(),targetKey:Wt(),clientToken:Ur(),requestHeaders:Wd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Wr(t);return ya.set(r,o.localPort),Ac(t,o.localPort),Nc(t,o.localPort)}catch(o){throw o instanceof Wr?o:new Wr(t)}},Dc=t=>{if(!t||!Of()||!Sr(t)||!Bf(mn()))return!1;const e=Ff(t);return e>0&&!pi.has(e)},ar=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!=="127.0.0.1")return t;const n=pi.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},dv=()=>{ya.clear(),pi.clear(),qn.clear();for(const t of Gn.values())t.close();Gn.clear(),pr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&vr(dv);const Ic=6e3,uv=120,fv=80,mv=`
574
+ var MAX_ELEMENTS = ${uv};
575
+ var MAX_LABEL_CHARS = ${fv};
576
+ var visible = function (element) {
577
+ var rect = element.getBoundingClientRect();
578
+ if (rect.width < 1 || rect.height < 1) return false;
579
+ var style = window.getComputedStyle(element);
580
+ return style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) !== 0;
581
+ };
582
+ var label = function (element) {
583
+ var aria = element.getAttribute('aria-label');
584
+ if (aria) return aria.trim();
585
+ var value = element.getAttribute('value');
586
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
587
+ if (text) return text.slice(0, MAX_LABEL_CHARS);
588
+ if (value) return String(value).slice(0, MAX_LABEL_CHARS);
589
+ var placeholder = element.getAttribute('placeholder');
590
+ return placeholder ? placeholder.trim().slice(0, MAX_LABEL_CHARS) : '';
591
+ };
592
+ var isUnique = function (selector) {
593
+ try {
594
+ return document.querySelectorAll(selector).length === 1;
595
+ } catch (error) {
596
+ return false;
597
+ }
598
+ };
599
+
600
+ /**
601
+ * Names an element by what it is, falling back to where it sits.
602
+ *
603
+ * A positional chain like 'main > section:nth-of-type(3) > div > a' survives
604
+ * only until the markup shifts, and says nothing about what it points at.
605
+ * Anything the page states about identity — an id, a test id, an accessible
606
+ * name — outlives edits and reads as the thing it selects. The chain remains
607
+ * as the last resort, because something always has to work.
608
+ */
609
+ var cssPath = function (element) {
610
+ var tag = element.tagName.toLowerCase();
611
+
612
+ if (element.id) {
613
+ var byId = '#' + CSS.escape(element.id);
614
+ if (isUnique(byId)) return byId;
615
+ }
616
+ var stableAttrs = ['data-testid', 'data-test-id', 'data-test', 'name', 'aria-label'];
617
+ for (var a = 0; a < stableAttrs.length; a += 1) {
618
+ var value = element.getAttribute(stableAttrs[a]);
619
+ if (!value) continue;
620
+ var raw = String(value);
621
+ // A value containing a quote would need escaping for no real gain: such
622
+ // attributes are rare, and the positional chain still covers them.
623
+ if (raw.indexOf('"') !== -1) continue;
624
+ var byAttr = tag + '[' + stableAttrs[a] + '="' + raw + '"]';
625
+ if (isUnique(byAttr)) return byAttr;
626
+ }
627
+ var className = typeof element.className === 'string' ? element.className.trim() : '';
628
+ if (className) {
629
+ var classes = className.split(/\\s+/).filter(Boolean);
630
+ for (var c = 0; c < classes.length; c += 1) {
631
+ var byClass = tag + '.' + CSS.escape(classes[c]);
632
+ if (isUnique(byClass)) return byClass;
633
+ }
634
+ }
635
+
636
+ var parts = [];
637
+ var node = element;
638
+ var depth = 0;
639
+ while (node && node.nodeType === 1 && depth < 6) {
640
+ var part = node.tagName.toLowerCase();
641
+ var parent = node.parentElement;
642
+ if (!parent) { parts.unshift(part); break; }
643
+ var siblings = Array.prototype.filter.call(parent.children, function (child) {
644
+ return child.tagName === node.tagName;
645
+ });
646
+ if (siblings.length > 1) part += ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')';
647
+ parts.unshift(part);
648
+ if (node.id) { parts[0] = '#' + CSS.escape(node.id); break; }
649
+ node = parent;
650
+ depth += 1;
651
+ }
652
+ return parts.join(' > ');
653
+ };
654
+
655
+ /** What a screen reader would announce, or '' when there is nothing to say. */
656
+ var accessibleName = function (element) {
657
+ var aria = element.getAttribute('aria-label');
658
+ if (aria && aria.trim()) return aria.trim();
659
+ var labelled = element.getAttribute('aria-labelledby');
660
+ if (labelled) {
661
+ var source = document.getElementById(labelled.split(/\\s+/)[0]);
662
+ if (source && (source.innerText || '').trim()) return source.innerText.trim();
663
+ }
664
+ var title = element.getAttribute('title');
665
+ if (title && title.trim()) return title.trim();
666
+ var alt = element.getAttribute('alt');
667
+ if (alt && alt.trim()) return alt.trim();
668
+ var text = (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim();
669
+ if (text) return text;
670
+ var value = element.getAttribute('value');
671
+ return value && String(value).trim() ? String(value).trim() : '';
672
+ };
673
+ var findByText = function (needle) {
674
+ var wanted = String(needle).replace(/\\s+/g, ' ').trim().toLowerCase();
675
+ var candidates = document.querySelectorAll('a, button, [role="button"], [role="link"], input[type="submit"], input[type="button"], summary, label');
676
+ var exact = null;
677
+ var partial = null;
678
+ for (var i = 0; i < candidates.length; i += 1) {
679
+ var element = candidates[i];
680
+ if (!visible(element)) continue;
681
+ var text = label(element).toLowerCase();
682
+ if (!text) continue;
683
+ if (text === wanted) { exact = element; break; }
684
+ if (!partial && text.indexOf(wanted) !== -1) partial = element;
685
+ }
686
+ return exact || partial;
687
+ };
688
+ `,eo=t=>`(() => {
689
+ ${mv}
690
+ ${t}
691
+ })()`,hv=({selector:t}={})=>eo(`
692
+ var scopeSelector = ${JSON.stringify(t??"")};
693
+ var root = document;
694
+ if (scopeSelector) {
695
+ try { root = document.querySelector(scopeSelector); }
696
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + scopeSelector }; }
697
+ if (!root) return { ok: false, error: 'No element matches ' + scopeSelector };
698
+ }
699
+ var interactive = root.querySelectorAll('a[href], button, input, select, textarea, [role="button"], [role="link"], [role="tab"], [contenteditable="true"]');
700
+ var elements = [];
701
+ var visibleTotal = 0;
702
+ for (var i = 0; i < interactive.length; i += 1) {
703
+ var element = interactive[i];
704
+ if (!visible(element)) continue;
705
+ visibleTotal += 1;
706
+ if (elements.length >= MAX_ELEMENTS) continue;
707
+
708
+ var rect = element.getBoundingClientRect();
709
+ // Empty and default-valued fields are left out rather than serialized as
710
+ // "" and false. Repeated across a hundred entries that overhead dwarfed
711
+ // the information it carried.
712
+ var entry = {
713
+ selector: cssPath(element),
714
+ tag: element.tagName.toLowerCase(),
715
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }
716
+ };
717
+ // The list covers the whole document so anything can be clicked without
718
+ // scrolling to it first, which means bounds alone do not say what is on
719
+ // screen — a negative y reads as a bug otherwise.
720
+ if (rect.bottom > 0 && rect.top < window.innerHeight) entry.inViewport = true;
721
+ var type = element.getAttribute('type');
722
+ if (type) entry.type = type;
723
+ var role = element.getAttribute('role');
724
+ if (role) entry.role = role;
725
+ var labelText = label(element);
726
+ if (labelText) entry.label = labelText;
727
+ if (element.disabled === true) entry.disabled = true;
728
+ // Flagged rather than described: reporting the accessible name of every
729
+ // element would cost more than it tells, while its absence on something
730
+ // clickable is a defect worth naming.
731
+ if (!accessibleName(element)) entry.missingAccessibleName = true;
732
+ elements.push(entry);
733
+ }
734
+ var body = document.body ? (document.body.innerText || '') : '';
735
+ var text = body.replace(/\\n{3,}/g, '\\n\\n').trim();
736
+ var docEl = document.documentElement;
737
+ var result = {
738
+ ok: true,
739
+ url: String(location.href),
740
+ title: String(document.title || ''),
741
+ scope: scopeSelector || 'document',
742
+ scrollY: Math.round(window.scrollY),
743
+ maxScrollY: Math.max(0, Math.round(docEl.scrollHeight - window.innerHeight)),
744
+ text: text.slice(0, ${Ic}),
745
+ elements: elements
746
+ };
747
+ // State what was dropped. A capped list that reports only its own length
748
+ // reads as the whole page, and the agent acts as if it had seen everything.
749
+ if (text.length > ${Ic}) {
750
+ result.textTruncated = true;
751
+ result.textTotalChars = text.length;
752
+ }
753
+ if (visibleTotal > elements.length) {
754
+ result.elementsTruncated = true;
755
+ result.interactiveElementsOnPage = visibleTotal;
756
+ }
757
+ return result;
758
+ `),pv=({selector:t,text:e})=>eo(`
759
+ var selector = ${JSON.stringify(t??"")};
760
+ var text = ${JSON.stringify(e??"")};
761
+ var target = null;
762
+ if (selector) {
763
+ try { target = document.querySelector(selector); }
764
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
765
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
766
+ } else {
767
+ target = findByText(text);
768
+ if (!target) return { ok: false, error: 'No clickable element has the label ' + text };
769
+ }
770
+ if (target.disabled === true) return { ok: false, error: 'Element is disabled' };
771
+ target.scrollIntoView({ block: 'center', inline: 'center' });
772
+ target.click();
773
+ return { ok: true, clicked: cssPath(target), label: label(target), url: String(location.href) };
774
+ `),gv=({selector:t,value:e,submit:n})=>eo(`
775
+ var selector = ${JSON.stringify(t)};
776
+ var value = ${JSON.stringify(e)};
777
+ var target = null;
778
+ try { target = document.querySelector(selector); }
779
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
780
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
781
+
782
+ var editable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
783
+ if (!editable) return { ok: false, error: selector + ' is not a text field' };
784
+ if (target.disabled === true || target.readOnly === true) return { ok: false, error: 'Field is not editable' };
785
+
786
+ target.scrollIntoView({ block: 'center' });
787
+ target.focus();
788
+ if (target.isContentEditable) {
789
+ target.textContent = value;
790
+ } else {
791
+ // Frameworks track the value through the native setter; assigning the
792
+ // property directly leaves React and friends unaware of the change.
793
+ var prototype = target.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
794
+ var setter = Object.getOwnPropertyDescriptor(prototype, 'value');
795
+ if (setter && setter.set) setter.set.call(target, value);
796
+ else target.value = value;
797
+ }
798
+ target.dispatchEvent(new Event('input', { bubbles: true }));
799
+ target.dispatchEvent(new Event('change', { bubbles: true }));
800
+
801
+ if (${n?"true":"false"}) {
802
+ var enter = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true };
803
+ target.dispatchEvent(new KeyboardEvent('keydown', enter));
804
+ target.dispatchEvent(new KeyboardEvent('keyup', enter));
805
+ var form = target.form;
806
+ if (form && typeof form.requestSubmit === 'function') form.requestSubmit();
807
+ }
808
+ return { ok: true, selector: cssPath(target), url: String(location.href) };
809
+ `),xv=({selector:t,direction:e})=>eo(`
810
+ var selector = ${JSON.stringify(t??"")};
811
+ var direction = ${JSON.stringify(e??"")};
812
+
813
+ var settle = function (extra) {
814
+ return new Promise(function (resolve) {
815
+ requestAnimationFrame(function () {
816
+ requestAnimationFrame(function () {
817
+ var doc = document.documentElement;
818
+ var maxScrollY = Math.max(0, doc.scrollHeight - window.innerHeight);
819
+ var scrollY = Math.round(window.scrollY);
820
+ var result = { ok: true, scrollY: scrollY, maxScrollY: Math.round(maxScrollY) };
821
+ result.atTop = scrollY <= 1;
822
+ result.atBottom = scrollY >= maxScrollY - 1;
823
+ for (var key in extra) {
824
+ if (Object.prototype.hasOwnProperty.call(extra, key)) result[key] = extra[key];
825
+ }
826
+ resolve(result);
827
+ });
828
+ });
829
+ });
830
+ };
831
+
832
+ if (selector) {
833
+ var target = null;
834
+ try { target = document.querySelector(selector); }
835
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
836
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
837
+ // Instant on purpose: the page's own smooth scrolling would still be
838
+ // animating when the next action runs against it.
839
+ target.scrollIntoView({ block: 'center', behavior: 'instant' });
840
+ return settle({ scrolledTo: cssPath(target) });
841
+ }
842
+
843
+ var doc = document.documentElement;
844
+ var page = Math.round(window.innerHeight * 0.85);
845
+ var bottom = Math.max(0, doc.scrollHeight - window.innerHeight);
846
+ if (direction === 'down') window.scrollTo({ top: window.scrollY + page, behavior: 'instant' });
847
+ else if (direction === 'up') window.scrollTo({ top: window.scrollY - page, behavior: 'instant' });
848
+ else if (direction === 'top') window.scrollTo({ top: 0, behavior: 'instant' });
849
+ else if (direction === 'bottom') window.scrollTo({ top: bottom, behavior: 'instant' });
850
+ else return { ok: false, error: 'Unknown scroll direction: ' + direction };
851
+ return settle({ direction: direction });
852
+ `),bv=["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"],yv=({selector:t})=>eo(`
853
+ var selector = ${JSON.stringify(t)};
854
+ var target = null;
855
+ try { target = document.querySelector(selector); }
856
+ catch (error) { return { ok: false, error: 'Invalid selector: ' + selector }; }
857
+ if (!target) return { ok: false, error: 'No element matches ' + selector };
858
+
859
+ var computed = window.getComputedStyle(target);
860
+ var styles = {};
861
+ var props = ${JSON.stringify(bv)};
862
+ for (var i = 0; i < props.length; i += 1) {
863
+ var value = computed.getPropertyValue(props[i]);
864
+ if (value) styles[props[i]] = String(value).trim();
865
+ }
866
+
867
+ var rect = target.getBoundingClientRect();
868
+ return {
869
+ ok: true,
870
+ selector: cssPath(target),
871
+ tag: target.tagName.toLowerCase(),
872
+ label: label(target),
873
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
874
+ inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
875
+ styles: styles
876
+ };
877
+ `),wv=t=>{const e=Ze.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=St();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(p,x)=>s.jsxs("div",{role:"option","aria-selected":x===r,className:Me("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",x===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:b=>{b.preventDefault(),i(p.url)},onPointerEnter:()=>l(x),children:[s.jsx(O,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:p.title||rl(p.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:p.url})]}),s.jsx("button",{type:"button",className:Me("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:b=>{b.preventDefault(),b.stopPropagation(),o(p.url)},children:s.jsx(O,{name:"close",className:"size-3","aria-hidden":"true"})})]},p.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let h;return e[15]!==d||e[16]!==u?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=h):h=e[17],h},Ws=t=>{const e=Ze.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Me("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 h;e[2]!==n?(h=s.jsx(O,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(yt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let p;e[12]!==r?(p=s.jsx(wt,{sideOffset:6,children:r}),e[12]=r,e[13]=p):p=e[13];let x;return e[14]!==f||e[15]!==p?(x=s.jsxs(bt,{children:[f,p]}),e[14]=f,e[15]=p,e[16]=x):x=e[16],x},Lf=t=>{const e=Ze.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:p,isLoading:x,onAnnotate:b,onOpenDevTools:k,isAnnotating:y,onHardReload:m,onZoomIn:g,onZoomOut:j,onZoomReset:S,zoomPercent:w,onClearCookies:C,onClearCache:v,onToggleDeviceBar:R,isDeviceBarOpen:T}=t;let D;e[0]!==r?(D=r===void 0?[]:r,e[0]=r,e[1]=D):D=e[1];const F=D,B=w===void 0?100:w,{t:E}=St(),[$,L]=c.useState(!1),[X,Y]=c.useState(-1);let I;e[2]!==$||e[3]!==F?(I=$?F:[],e[2]=$,e[3]=F,e[4]=I):I=e[4];const P=I;let A;e[5]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{Y(-1)},e[5]=A):A=e[5];let q;e[6]!==n||e[7]!==$?(q=[n,$],e[6]=n,e[7]=$,e[8]=q):q=e[8],c.useEffect(A,q);let K;e[9]!==l?(K=$e=>{L(!1),Y(-1),l($e)},e[9]=l,e[10]=K):K=e[10];const te=K;let ae;e[11]!==X||e[12]!==te||e[13]!==P?(ae=$e=>{if(P.length!==0){if($e.key==="ArrowDown"||$e.key==="ArrowUp"){$e.preventDefault();const Pe=$e.key==="ArrowDown"?1:-1,Oe=P.length;Y(Q=>{const Ce=Q+Pe;return Ce<-1?Oe-1:Ce>=Oe?-1:Ce});return}if($e.key==="Escape"&&X>=0){$e.preventDefault(),Y(-1);return}if($e.key==="Enter"&&X>=0){$e.preventDefault();const Pe=P[X];Pe&&te(Pe.url)}}},e[11]=X,e[12]=te,e[13]=P,e[14]=ae):ae=e[14];const re=ae;let he;e[15]!==E?(he=E("contextPanel.browser.back"),e[15]=E,e[16]=he):he=e[16];const ce=!f;let Te;e[17]!==a||e[18]!==ce||e[19]!==he?(Te=s.jsx(Ws,{icon:"arrow-left",label:he,onClick:a,disabled:ce}),e[17]=a,e[18]=ce,e[19]=he,e[20]=Te):Te=e[20];let ve;e[21]!==E?(ve=E("contextPanel.browser.forward"),e[21]=E,e[22]=ve):ve=e[22];const pe=!p;let Ne;e[23]!==d||e[24]!==ve||e[25]!==pe?(Ne=s.jsx(Ws,{icon:"arrow-right",label:ve,onClick:d,disabled:pe}),e[23]=d,e[24]=ve,e[25]=pe,e[26]=Ne):Ne=e[26];let U;e[27]!==x||e[28]!==E?(U=E(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=E,e[29]=U):U=e[29];let Z;e[30]!==u||e[31]!==U?(Z=s.jsx(Ws,{icon:"refresh",label:U,onClick:u}),e[30]=u,e[31]=U,e[32]=Z):Z=e[32];let de;e[33]!==m||e[34]!==E?(de=m?s.jsx(Ws,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=de):de=e[35];let ye;e[36]!==n||e[37]!==te?(ye=$e=>{$e.preventDefault(),te(n)},e[36]=n,e[37]=te,e[38]=ye):ye=e[38];let H;e[39]!==o?(H=$e=>o($e.target.value),e[39]=o,e[40]=H):H=e[40];let je,Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(je=()=>L(!0),Ee=()=>L(!1),e[41]=je,e[42]=Ee):(je=e[41],Ee=e[42]);const ge=P.length>0;let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=Me("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=ne):ne=e[43];let be;e[44]!==E?(be=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=be):be=e[45];let G;e[46]!==n||e[47]!==re||e[48]!==H||e[49]!==ge||e[50]!==be?(G=s.jsx("input",{value:n,onChange:H,onFocus:je,onBlur:Ee,onKeyDown:re,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ge,"aria-controls":"openchamber-browser-address-suggestions",className:ne,"aria-label":be}),e[46]=n,e[47]=re,e[48]=H,e[49]=ge,e[50]=be,e[51]=G):G=e[51];let z;e[52]!==i?(z=$e=>i?.($e),e[52]=i,e[53]=z):z=e[53];let J;e[54]!==X||e[55]!==te||e[56]!==z||e[57]!==P?(J=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(wv,{entries:P,activeIndex:X,onSelect:te,onForget:z,onHighlight:Y})}),e[54]=X,e[55]=te,e[56]=z,e[57]=P,e[58]=J):J=e[58];let ue;e[59]!==ye||e[60]!==G||e[61]!==J?(ue=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:ye,children:[G,J]}),e[59]=ye,e[60]=G,e[61]=J,e[62]=ue):ue=e[62];let le;e[63]!==g||e[64]!==j||e[65]!==S||e[66]!==E||e[67]!==B?(le=j&&g?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Ws,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:j}),B!==100&&S?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs(ut,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:S,"aria-label":E("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(wt,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(Ws,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:g})]}):null,e[63]=g,e[64]=j,e[65]=S,e[66]=E,e[67]=B,e[68]=le):le=e[68];let W;e[69]!==C||e[70]!==E?(W=C?s.jsx(Ws,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:C}):null,e[69]=C,e[70]=E,e[71]=W):W=e[71];let M;e[72]!==v||e[73]!==E?(M=v?s.jsx(Ws,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:v}):null,e[72]=v,e[73]=E,e[74]=M):M=e[74];let _;e[75]!==T||e[76]!==R||e[77]!==E?(_=R?s.jsx(Ws,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:R,pressed:T}):null,e[75]=T,e[76]=R,e[77]=E,e[78]=_):_=e[78];let ee;e[79]!==y||e[80]!==b||e[81]!==E?(ee=b?s.jsx(Ws,{icon:"markup",label:E("contextPanel.browser.annotate.toggle"),onClick:b,pressed:y}):null,e[79]=y,e[80]=b,e[81]=E,e[82]=ee):ee=e[82];let oe;e[83]!==k||e[84]!==E?(oe=k?s.jsx(Ws,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:k}):null,e[83]=k,e[84]=E,e[85]=oe):oe=e[85];let fe;e[86]!==E?(fe=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=fe):fe=e[87];let ie;e[88]!==h||e[89]!==fe?(ie=s.jsx(Ws,{icon:"external-link",label:fe,onClick:h}),e[88]=h,e[89]=fe,e[90]=ie):ie=e[90];let Le;return e[91]!==Te||e[92]!==Ne||e[93]!==Z||e[94]!==de||e[95]!==ue||e[96]!==le||e[97]!==W||e[98]!==M||e[99]!==_||e[100]!==ee||e[101]!==oe||e[102]!==ie?(Le=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Te,Ne,Z,de,ue,le,W,M,_,ee,oe,ie]}),e[91]=Te,e[92]=Ne,e[93]=Z,e[94]=de,e[95]=ue,e[96]=le,e[97]=W,e[98]=M,e[99]=_,e[100]=ee,e[101]=oe,e[102]=ie,e[103]=Le):Le=e[103],Le},Wo={kind:"fill"},Tc=240,vv=3840,_f=[{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}],Ec=t=>Number.isFinite(t)?Math.round(Math.min(vv,Math.max(Tc,t))):Tc,Ko=t=>t.kind==="fill"?null:{width:t.width,height:t.height},$f=t=>{const e=_f.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Sv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},jv=(t,e)=>{const n=Ko(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},kv=["mobile","tablet","desktop","fill"],Cv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Rc=t=>typeof t=="string"&&kv.includes(t),wa=t=>t==="fill"?Wo:$f(Cv[t])??Wo,mo=t=>{const e=Ko(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=wa(n),i=Ko(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Nv=t=>{const e=Ze.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=St();let d;e[0]!==n?(d=Ko(n),e[0]=n,e[1]=d):d=e[1];const u=d,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ce,Te)=>{const ve=Number.parseInt(Te,10);if(!Number.isFinite(ve))return;const pe=u??{width:1280,height:800};r({kind:"custom",width:Ec(ce==="width"?ve:pe.width),height:Ec(ce==="height"?ve:pe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const p=f;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=Me("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]=x):x=e[5];const b=x;let k;e[6]!==r?(k=ce=>{const Te=$f(ce.target.value);r(Te??Wo)},e[6]=r,e[7]=k):k=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Me("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]=m):m=e[10];let g;e[11]!==a?(g=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=g):g=e[12];let j;e[13]!==g?(j=s.jsx("option",{value:"",children:g}),e[13]=g,e[14]=j):j=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=_f.map(Av),e[15]=S):S=e[15];let w;e[16]!==h||e[17]!==k||e[18]!==y||e[19]!==j?(w=s.jsxs("select",{value:h,onChange:k,"aria-label":y,className:m,children:[j,S]}),e[16]=h,e[17]=k,e[18]=y,e[19]=j,e[20]=w):w=e[20];const C=u?String(u.width):"";let v;e[21]!==p?(v=ce=>p("width",ce.target.value),e[21]=p,e[22]=v):v=e[22];let R;e[23]!==a?(R=a("contextPanel.browser.device.width"),e[23]=a,e[24]=R):R=e[24];let T;e[25]!==C||e[26]!==v||e[27]!==R?(T=s.jsx("input",{value:C,onChange:v,placeholder:"—",inputMode:"numeric","aria-label":R,className:b}),e[25]=C,e[26]=v,e[27]=R,e[28]=T):T=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const F=u?String(u.height):"";let B;e[30]!==p?(B=ce=>p("height",ce.target.value),e[30]=p,e[31]=B):B=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let $;e[34]!==F||e[35]!==B||e[36]!==E?($=s.jsx("input",{value:F,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":E,className:b}),e[34]=F,e[35]=B,e[36]=E,e[37]=$):$=e[37];let L;e[38]!==r||e[39]!==n?(L=()=>r(Sv(n)),e[38]=r,e[39]=n,e[40]=L):L=e[40];const X=!u;let Y;e[41]!==a?(Y=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=Y):Y=e[42];let I;e[43]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(O,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=I):I=e[43];let P;e[44]!==L||e[45]!==X||e[46]!==Y?(P=s.jsx(yt,{asChild:!0,children:s.jsx(ut,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:L,disabled:X,"aria-label":Y,children:I})}),e[44]=L,e[45]=X,e[46]=Y,e[47]=P):P=e[47];let A;e[48]!==a?(A=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=A):A=e[49];let q;e[50]!==A?(q=s.jsx(wt,{sideOffset:6,children:A}),e[50]=A,e[51]=q):q=e[51];let K;e[52]!==P||e[53]!==q?(K=s.jsxs(bt,{children:[P,q]}),e[52]=P,e[53]=q,e[54]=K):K=e[54];let te;e[55]!==l||e[56]!==u?(te=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=te):te=e[57];let ae;e[58]===Symbol.for("react.memo_cache_sentinel")?(ae=["system","light","dark"],e[58]=ae):ae=e[58];let re;e[59]!==i||e[60]!==o||e[61]!==a?(re=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:ae.map(ce=>s.jsx(ut,{type:"button",variant:i===ce?"secondary":"ghost",size:"xs",className:Me("shrink-0 rounded-full px-2.5 typography-micro",i===ce?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ce),"aria-pressed":i===ce,children:a(ce==="system"?"contextPanel.browser.device.schemeSystem":ce==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ce))}),e[59]=i,e[60]=o,e[61]=a,e[62]=re):re=e[62];let he;return e[63]!==w||e[64]!==T||e[65]!==$||e[66]!==K||e[67]!==te||e[68]!==re?(he=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[w,T,D,$,K,te,re]}),e[63]=w,e[64]=T,e[65]=$,e[66]=K,e[67]=te,e[68]=re,e[69]=he):he=e[69],he};function Av(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Pv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Dv=2e3,Iv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=mn();if(!t)return!1;try{return!Sr(new URL(t,window.location.href).toString())}catch{return!1}},zf=t=>{const e=Ze.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=St();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=Kb(i),[h]=c.useState(Iv);let f,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let T=!0,D=null;const F=new AbortController,B=()=>{jw(F.signal).then(E=>{T&&(d(E),D=setTimeout(B,Dv))})};return B(),()=>{T=!1,D&&clearTimeout(D),F.abort()}},p=[],e[1]=f,e[2]=p):(f=e[1],p=e[2]),c.useEffect(f,p);const x=a.kind==="ready"?a.servers:null;let b;e[3]!==u||e[4]!==x?(b=Nw({announced:u,discovered:x}),e[3]=u,e[4]=x,e[5]=b):b=e[5];const k=b;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Du,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let g;e[9]!==m?(g=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=g):g=e[10];let j;e[11]!==o?(j=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=j):j=e[12];let S;e[13]!==j?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:j}),e[13]=j,e[14]=S):S=e[14];let w;e[15]!==S||e[16]!==g?(w=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[g,S]}),e[15]=S,e[16]=g,e[17]=w):w=e[17];let C;e[18]!==u||e[19]!==k||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(C=k.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:k.map(T=>s.jsxs(ut,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{$b(i),n(T.url)},children:[s.jsx(O,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:rl(T.url)||T.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Pv(T.url)})]},T.port))})]}):null,e[18]=u,e[19]=k,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=C):C=e[24];let v;e[25]!==k.length||e[26]!==a.kind||e[27]!==o?(v=k.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=k.length,e[26]=a.kind,e[27]=o,e[28]=v):v=e[28];let R;return e[29]!==w||e[30]!==C||e[31]!==v?(R=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[y,w,C,v]}),e[29]=w,e[30]=C,e[31]=v,e[32]=R):R=e[32],R},As=t=>Math.round(t),Tv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${As(l.x)}, y=${As(l.y)}, width=${As(l.width)}, height=${As(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},Ev=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${As(n.x)}, y=${As(n.y)}, width=${As(n.width)}, height=${As(n.height)}`},Rv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${As(n.x)}, y=${As(n.y)}, width=${As(n.width)}, height=${As(n.height)}`},Mv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${As(t.viewport.width)}x${As(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...Tv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(Ev(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(Rv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
+ `)},Ov=t=>{const e=Ze.c(7),{t:n}=St(),r=nt(Fv),i=nt(Lv),o=Yi(_v),l=eg($v);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){ze.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Mv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),ze.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},Bv=()=>{const t=Ze.c(16),{t:e}=St();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function Fv(t){return t.currentSessionId}function Lv(t){return t.newSessionDraft?.open}function _v(t){return t.addDraft}function $v(t){return t.addAttachedFile}const zv=3e4,Wv=3,Kv=250,Vv={attempts:0,windowStartedAt:null},Uv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=zv,r=n?0:t.attempts;return r>=Wv?null:{delayMs:Kv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},Hv=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",mr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Gv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,p]=c.useState(!1),x=c.useRef(n);x.current=n;const b=c.useRef(Vv);return c.useEffect(()=>{if(!t)return;const k=()=>{try{const D=t.getURL();return ho(D)?D:""}catch{return""}},y=()=>{try{h(t.canGoBack()),p(t.canGoForward())}catch{}},m=D=>{ho(D)&&(l(D),x.current(D))},g=()=>{const D=k();i({kind:"loading",url:D})},j=()=>{const D=k();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),y(),i(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},S=D=>{const F=mr(D);ho(F.url)&&(m(F.url),y())},w=D=>{const F=mr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=k();B&&E&&Cf.getState().resolve(E,B)},C=D=>{const F=mr(D);typeof F.title=="string"&&d(F.title)},v=D=>{const F=mr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==Hv&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:k(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let R=null;const T=()=>{const D=k(),F=Uv(b.current,Date.now());if(!F){i({kind:"failed",url:D,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:D}),R=setTimeout(()=>{R=null;try{t.reload()}catch{i({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",g),t.addEventListener("did-stop-loading",j),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",C),t.addEventListener("page-favicon-updated",w),t.addEventListener("did-fail-load",v),t.addEventListener("render-process-gone",T),t.addEventListener("crashed",T);try{!t.isLoading()&&k()&&j()}catch{}return()=>{R!==null&&clearTimeout(R),t.removeEventListener("render-process-gone",T),t.removeEventListener("crashed",T),t.removeEventListener("did-start-loading",g),t.removeEventListener("did-stop-loading",j),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",C),t.removeEventListener("page-favicon-updated",w),t.removeEventListener("did-fail-load",v)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},qv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Yv=4e4,po=.5,Qv=-3,Xv=4,Jv="persist:openchamber-browser",Mc=20,Zv=600,eS=2e4,tS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=St(),{currentTheme:i}=Cn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(W=>{o.current=W,a(W)},[]),u=Ae(W=>W.setContextPanelTabTargetPath),h=c.useRef(xr(t)),f=h.current!==Ks?h.current:"",[p,x]=c.useState(f?null:Ks),[b,k]=c.useState(f),[y,m]=c.useState(!1),[g,j]=c.useState(!1),[S,w]=c.useState(0),C=c.useRef(0),[v,R]=c.useState(!1),[T,D]=c.useState(Wo),F=c.useRef(T);F.current=T;const B=c.useRef([]),[E,$]=c.useState("system"),[L,X]=c.useState({width:0,height:0}),Y=c.useRef(null),I=c.useRef(null),P=c.useRef(!1),A=c.useRef(Date.now()),q=c.useCallback(W=>{!W||W===Ks||!e||!n||u(e,n,W)},[e,n,u]),K=Gv(l,{initialUrl:f,onUrlChange:c.useCallback(W=>{const M=ar(W);k(M),q(M)},[q])}),[te,ae]=c.useState(null),re=Ov(e),he=Bv(),ce=K.status.kind==="loading",Te=br(Mf(e)),ve=br(W=>W.recordVisit),pe=br(W=>W.forget);c.useEffect(()=>{K.status.kind==="ready"&&ve(e,{url:ar(K.status.url),title:K.status.title})},[e,K.status,ve]);const Ne=c.useMemo(()=>Rf(Te,b),[Te,b]),U=c.useCallback(W=>{const M=xr(W);M!==Ks&&(k(M),ae(null),Pc(M).then(_=>{const ee=o.current;if(!ee){x(_);return}try{ee.loadURL(_)}catch{x(_)}}).catch(_=>{_ instanceof Wr&&ae(M)}))},[]);c.useEffect(()=>{if(!f)return;let W=!0;return Pc(f).then(M=>{W&&x(M)}).catch(M=>{if(W){if(M instanceof Wr){ae(f),x(Ks);return}x(f)}}),()=>{W=!1}},[]);const Z=c.useMemo(()=>({executeJavaScript:async(W,M)=>{const _=o.current;if(!_)throw new Error("Browser view is not available");return _.executeJavaScript(W,M)},capturePage:async()=>{const W=o.current;if(!W)return null;const M=W.getWebContentsId();return Number.isFinite(M)?await pr("desktop_browser_capture_page",{webContentsId:M}):null}}),[]),de=c.useCallback(()=>{if(y){m(!1),Po(Z);return}if(!K.url){ze.error(r("contextPanel.browser.annotate.noPage"));return}const W=Kw(i.metadata.variant==="light"?"light":"dark");m(!0),zw({host:Z,theme:W,labels:he}).then(async M=>{m(!1),M&&await re(M)}).catch(()=>{m(!1),ze.error(r("contextPanel.browser.annotate.failed"))})},[Z,re,i,y,K.url,he,r]);c.useEffect(()=>{if(!y)return;const W=M=>{tg(M)||M.key!=="Escape"||(M.preventDefault(),M.stopImmediatePropagation(),m(!1),Po(Z))};return window.addEventListener("keydown",W,!0),()=>window.removeEventListener("keydown",W,!0)},[Z,y]);const ye=c.useCallback(async(W=8e3)=>{const M=Date.now();for(;;){const _=o.current;if(!_)return!1;let ee=!1;try{ee=_.isLoading()}catch{return!1}if(!ee)return!0;if(Date.now()-M>W)return!1;await new Promise(oe=>setTimeout(oe,120))}},[]),H=c.useCallback(async(W,M)=>{const _=o.current;if(!_)throw new Error("The browser panel is not ready");const ee=()=>{Rc(M.viewport)&&(D(wa(M.viewport)),R(!0))};if(W==="browser.back"||W==="browser.forward"){const Pe=W==="browser.back";if(!(Pe?_.canGoBack():_.canGoForward()))throw new Error(Pe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Pe?_.goBack():_.goForward(),await new Promise(Ce=>setTimeout(Ce,150)),await ye();let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:ar(_.getURL()),title:Q}}if(W==="browser.capture"){const Pe=Ae.getState(),Oe=$n(e),Q=Pe.contextPanelByDirectory[Oe],Ce=!!(Q?.isOpen&&Q.activeTabId===n);Ce||Pe.setActiveContextPanelTab(e,n);const Se=()=>{if(Ce||!Q)return;const Ke=Ae.getState(),et=Ke.contextPanelByDirectory[Oe];!et?.isOpen||et.activeTabId!==n||(Q.activeTabId&&Q.activeTabId!==n&&Ke.setActiveContextPanelTab(e,Q.activeTabId),Q.isOpen||Ke.closeContextPanel(e))};try{const Ke=Date.now()+1200;let et=0,it=0;for(;it<2&&Date.now()<Ke;){const ht=_.getBoundingClientRect().width;it=ht>=2&&Math.abs(ht-et)<.5?it+1:0,et=ht,await new Promise(tt=>setTimeout(tt,50))}await new Promise(ht=>{requestAnimationFrame(()=>requestAnimationFrame(()=>ht()))}),await ye();const rt=await Z.capturePage();if(!rt)throw new Error("The page could not be captured");let pt="";try{pt=_.getTitle()||""}catch{pt=""}return{...rt,url:ar(_.getURL()),title:pt,viewport:mo(F.current)}}finally{Se()}}if(W==="browser.resize"){if(!Rc(M.viewport))throw new Error("viewport is required");return ee(),await new Promise(Pe=>setTimeout(Pe,200)),await ye(),{viewport:mo(wa(M.viewport))}}if(W==="browser.open"){const Pe=typeof M.url=="string"?M.url:"";if(!Pe)throw new Error("url is required");ee(),U(Pe),await new Promise(Ce=>setTimeout(Ce,150));const Oe=await ye(25e3);let Q="";try{Q=_.getTitle()||""}catch{Q=""}return{url:xr(Pe),title:Q,opened:!0,settled:Oe,viewport:mo(F.current)}}await ye();const oe=Pe=>typeof Pe=="string"&&Pe?Pe:void 0,ie=(()=>{switch(W){case"browser.snapshot":return hv({selector:oe(M.selector)});case"browser.click":return pv({selector:oe(M.selector),text:oe(M.text)});case"browser.type":return gv({selector:String(M.selector??""),value:String(M.value??""),submit:M.submit===!0});case"browser.inspect":return yv({selector:String(M.selector??"")});case"browser.scroll":return xv({selector:oe(M.selector),direction:oe(M.direction)});default:return null}})();if(!ie)throw new Error(`Unsupported browser action: ${W}`);const Le=await _.executeJavaScript(ie,!0);if(!Le||typeof Le!="object")throw new Error("The page returned no result");const $e=Le;if($e.ok!==!0)throw new Error(typeof $e.error=="string"&&$e.error?$e.error:"Browser action failed");if(W==="browser.snapshot"){const Pe=B.current;return{...$e,viewport:mo(F.current),...Pe.length>0?{consoleProblems:[...Pe]}:{}}}return(W==="browser.click"||W==="browser.type"&&M.submit===!0)&&(await new Promise(Pe=>setTimeout(Pe,150)),await ye()),Le},[Z,e,U,n,ye]),je=c.useCallback(()=>{const W=o.current;if(!W)return{title:"",url:""};let M="",_="";try{M=W.getTitle()||""}catch{M=""}try{_=ar(W.getURL())}catch{_=""}return{title:M,url:_}},[]);c.useEffect(()=>Xw({tabId:n,describe:je,run:H}),[je,H,n]),c.useEffect(()=>{const W=Z;return()=>{Po(W)}},[Z]),c.useEffect(()=>{if(!l)return;const W=_=>{const ee=_;if(typeof ee.level!="number"||ee.level<2)return;const oe=ee.sourceId?`${ee.sourceId}${ee.line?`:${ee.line}`:""}`:"";B.current.push({level:ee.level>=3?"error":"warning",message:String(ee.message??"").slice(0,400),source:oe}),B.current.length>Mc&&B.current.splice(0,B.current.length-Mc)},M=()=>{B.current=[]};return l.addEventListener("console-message",W),l.addEventListener("did-start-loading",M),()=>{l.removeEventListener("console-message",W),l.removeEventListener("did-start-loading",M)}},[l]);const Ee=c.useRef(new Set),ge=c.useCallback(W=>{Ee.current.clear(),U(W)},[U]);c.useEffect(()=>{if(!l)return;const W=_=>{const ee=mr(_),oe=typeof ee.url=="string"?ee.url:"";!oe||!Dc(oe)||(_.preventDefault(),U(oe))},M=_=>{const ee=mr(_);if(ee.isMainFrame===!1||ee.errorCode===-3)return;const oe=typeof ee.validatedURL=="string"?ee.validatedURL:"";!oe||!Dc(oe)||Ee.current.has(oe)||(Ee.current.add(oe),U(oe))};return l.addEventListener("will-navigate",W),l.addEventListener("did-fail-load",M),()=>{l.removeEventListener("will-navigate",W),l.removeEventListener("did-fail-load",M)}},[U,l]),c.useEffect(()=>{if(!l)return;const W=M=>{const _=M.detail;M.preventDefault(),_?.url&&U(_.url)};return l.addEventListener("new-window",W),()=>l.removeEventListener("new-window",W)},[U,l]);const ne=c.useCallback(W=>{const M=Math.min(Xv,Math.max(Qv,W));C.current=M,w(M);try{o.current?.setZoomLevel(M)}catch{}},[]);c.useEffect(()=>{const W=M=>{if(!(M instanceof CustomEvent))return;const _=M.detail,ee=o.current;!ee||document.activeElement!==ee||(_==="zoom-in"?ne(C.current+po):_==="zoom-out"?ne(C.current-po):_==="zoom-reset"&&ne(0))};return window.addEventListener("openchamber:zoom",W),()=>window.removeEventListener("openchamber:zoom",W)},[ne]);const be=c.useCallback(W=>{pr("desktop_browser_clear_data",{partition:Jv,cookies:W==="cookies",cache:W==="cache"}).then(()=>{ze.success(r(W==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>ze.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const W=Y.current;if(!W||typeof ResizeObserver>"u")return;const M=new ResizeObserver(_=>{const ee=_[0]?.contentRect;ee&&X({width:ee.width,height:ee.height})});return M.observe(W),()=>M.disconnect()},[]);const G=c.useCallback(W=>{$(W);const M=o.current;if(!M)return;let _=-1;try{_=M.getWebContentsId()}catch{return}pr("desktop_browser_set_color_scheme",{webContentsId:_,scheme:W}).catch(ee=>{$("system"),ze.error(ee instanceof Error?ee.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),z=c.useCallback(()=>{try{ce?o.current?.stop():o.current?.reload()}catch{}},[ce]),J=K.status;c.useEffect(()=>{const W=()=>{j(!0);const ee=setTimeout(()=>{try{o.current?.reload()}catch{}},Zv);return()=>clearTimeout(ee)};if(J.kind==="failed"){if(!vw(J.code,J.url)){j(!1);return}const ee=Date.now(),oe=I.current?.url===J.url?I.current:{url:J.url,startedAt:ee};if(I.current=oe,ee-oe.startedAt>Yv){j(!1);return}return W()}if(J.kind==="loading")return;if(I.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){P.current=!0,j(!1);return}if(P.current||Date.now()-A.current>eS){P.current=!0,j(!1);return}let M=!1,_=null;return kw(ar(J.url)).then(ee=>{if(!M){if(ee===null||ee<500){P.current=!0,j(!1);return}_=W()}}),()=>{M=!0,_?.()}},[J]);const ue=K.status.kind==="failed"&&!g?K.status:null,le=jv(T,L);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Lf,{address:b,onAddressChange:k,onSubmit:ge,suggestions:Ne,onForgetSuggestion:W=>pe(e,W),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:z,onOpenExternal:()=>{Qr(K.url||b)},canGoBack:K.canGoBack,canGoForward:K.canGoForward,isLoading:ce,onAnnotate:de,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>ne(S+po),onZoomOut:()=>ne(S-po),onZoomReset:()=>ne(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>be("cookies"),onClearCache:()=>be("cache"),onToggleDeviceBar:()=>R(W=>!W),isDeviceBarOpen:v}),v?s.jsx(Nv,{viewport:T,onViewportChange:D,colorScheme:E,onColorSchemeChange:G,scale:le?.scale??1}):null,s.jsxs("div",{ref:Y,className:Me("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[p!==null?s.jsx("webview",{ref:d,src:p,partition:"persist:openchamber-browser",allowpopups:!0,style:le?{width:`${le.width}px`,height:`${le.height}px`,transform:`scale(${le.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,p!==null&&!f&&!K.url&&!ce?s.jsx(zf,{onOpen:ge,directory:e}):null,g?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:te})})]}):null,ue&&!te?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ue.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ue.crashed?r("contextPanel.browser.crashedHint"):ue.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ce?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},sS=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=St(),l=Ae(rS);let a;e[0]!==n?(a=xr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Ks?d:"",[h,f]=c.useState(u),[p,x]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[k,y]=c.useState(b),[m,g]=c.useState(u?0:-1),[j,S]=c.useReducer(oS,0);let w;e[4]!==r||e[5]!==l||e[6]!==i?(w=he=>{!he||he===Ks||!r||!i||l(r,i,he)},e[4]=r,e[5]=l,e[6]=i,e[7]=w):w=e[7];const C=w;let v;e[8]!==r?(v=Mf(r),e[8]=r,e[9]=v):v=e[9];const R=br(v),T=br(iS),D=br(aS);let F;e[10]!==h||e[11]!==R?(F=Rf(R,h),e[10]=h,e[11]=R,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==C||e[16]!==T?(E=he=>{const ce=xr(he);ce!==Ks&&(f(ce),x(ce),C(ce),T(r,{url:ce}),y(Te=>{const ve=m>=0?Te.slice(0,m+1):[];return ve[ve.length-1]===ce?(g(ve.length-1),ve):(g(ve.length),[...ve,ce])}))},e[13]=r,e[14]=m,e[15]=C,e[16]=T,e[17]=E):E=e[17];const $=E;let L;e[18]!==k||e[19]!==C?(L=he=>{const ce=k[he];ce&&(g(he),f(ce),x(ce),C(ce))},e[18]=k,e[19]=C,e[20]=L):L=e[20];const X=L;let Y;e[21]!==r||e[22]!==D?(Y=he=>D(r,he),e[21]=r,e[22]=D,e[23]=Y):Y=e[23];let I,P;e[24]!==X||e[25]!==m?(P=()=>X(m-1),I=()=>X(m+1),e[24]=X,e[25]=m,e[26]=I,e[27]=P):(I=e[26],P=e[27]);let A;e[28]!==h||e[29]!==p?(A=()=>{Qr(p||h)},e[28]=h,e[29]=p,e[30]=A):A=e[30];const q=m>0,K=m>=0&&m<k.length-1;let te;e[31]!==h||e[32]!==$||e[33]!==B||e[34]!==I||e[35]!==A||e[36]!==q||e[37]!==K||e[38]!==Y||e[39]!==P?(te=s.jsx(Lf,{address:h,onAddressChange:f,onSubmit:$,suggestions:B,onForgetSuggestion:Y,onBack:P,onForward:I,onReload:S,onOpenExternal:A,canGoBack:q,canGoForward:K,isLoading:!1}),e[31]=h,e[32]=$,e[33]=B,e[34]=I,e[35]=A,e[36]=q,e[37]=K,e[38]=Y,e[39]=P,e[40]=te):te=e[40];let ae;e[41]!==p||e[42]!==$||e[43]!==j||e[44]!==o?(ae=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:p?s.jsx("iframe",{src:p,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${p}|${j}`):s.jsx(zf,{onOpen:$})}),e[41]=p,e[42]=$,e[43]=j,e[44]=o,e[45]=ae):ae=e[45];let re;return e[46]!==te||e[47]!==ae?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=re):re=e[48],re},nS=t=>{const e=Ze.c(3),[n]=c.useState(qv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(tS,{...t}):s.jsx(sS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function rS(t){return t.setContextPanelTabTargetPath}function oS(t){return t+1}function iS(t){return t.recordVisit}function aS(t){return t.forget}const lS=Dn(()=>sn(()=>import("./WalkthroughView-BJicp0RC.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}))),cS=Dn(()=>sn(()=>import("./DiffView-uzNpHBlV.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,129,117,118,119,120,121,130,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),dS=Dn(()=>sn(()=>import("./FilesView-Bkq0sjNx.js"),__vite__mapDeps([131,1,2,4,5,6,7,8,9,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,132,133,134,135,136,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,137,138,120,121,118,139,125,119,140])).then(t=>({default:t.FilesView}))),uS=Dn(()=>sn(()=>import("./GitView-BmibZC7n.js"),__vite__mapDeps([141,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,142,130,117,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),fS=Dn(()=>sn(()=>import("./LinearIssuesView-D3Azksju.js"),__vite__mapDeps([143,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.LinearIssuesView}))),mS=Dn(()=>sn(()=>import("./PlanView-Bqc-xuDe.js"),__vite__mapDeps([144,1,2,4,5,6,7,8,9,132,57,58,59,60,61,62,79,55,56,63,133,134,135,3,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,140,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Wf=c.lazy(()=>sn(()=>import("./PluginPane-DQ0k41Q-.js").then(t=>t.p),__vite__mapDeps([86,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.PluginPane}))),Kf={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}},hS=t=>{const e=Ze.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Kf[r.dock],a=Math.max(lg,i??r.size),d=l.vertical?"max-h-[50%] transition-[height]":"max-w-[50%] transition-[width]";let u;e[0]!==l.page||e[1]!==d?(u=Me("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 h;e[3]!==l.vertical||e[4]!==a?(h=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=h):h=e[5];let f;e[6]!==n?(f=s.jsx(Wf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let p;return e[8]!==u||e[9]!==h||e[10]!==f?(p=s.jsx("div",{className:u,style:h,children:f}),e[8]=u,e[9]=h,e[10]=f,e[11]=p):p=e[11],p},Oc=c.lazy(()=>sn(()=>import("./GuestSurfacePane-PAcYaFzP.js"),__vite__mapDeps([145,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,86])).then(t=>({default:t.GuestSurfacePane}))),Vf=320,il=600,pS=400,gS=100,xS=24,Vo=new Map,bS=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Bc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Vf,Math.round(t))):il,Fc=t=>{const e=t??(typeof window<"u"?window.innerWidth:il*2);return Math.max(Vf,e-pS)},yS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},wS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Uf=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Un(t)?Fa.getState().guests.find(r=>r.id===Ro(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),vS=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},SS=(t,e,n)=>{if(t.mode==="chat"){const r=va(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?rl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?vS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Uf(t.mode,n)},jS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ka();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??cg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Lc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Wa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(pf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(O,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(O,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(O,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(O,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(O,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(O,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(O,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(O,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(O,{name:"chat-4",className:"h-3.5 w-3.5"});if(Un(t.mode))return s.jsx(jS,{mode:t.mode});if(t.mode==="browser"){const n=kS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(O,{name:"global",className:"h-3.5 w-3.5"})}},kS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},CS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=St(),i=Ae(g=>g.contextEditorTreeWidth),o=Ae(g=>g.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),p=c.useRef(null),x=c.useCallback(g=>{const j=p.current;j&&(j.style.width=`${g}px`,j.style.setProperty("--oc-editor-tree-width",`${g}px`))},[]),b=g=>{if(t){try{g.currentTarget.setPointerCapture(g.pointerId)}catch{}f.current=g.pointerId,a(!0),d.current=g.clientX,u.current=i,h.current=i,g.preventDefault()}},k=g=>{if(!l||f.current!==g.pointerId)return;const j=d.current-g.clientX,S=Wi(u.current+j);h.current!==S&&(h.current=S,x(S))},y=g=>{if(f.current!==g.pointerId)return;try{g.currentTarget.releasePointerCapture(g.pointerId)}catch{}const j=Wi(h.current??i);f.current=null,h.current=null,a(!1),o(j)},m=t?i:0;return s.jsxs("div",{ref:p,className:Me("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Me("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:b,onPointerMove:k,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Me("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(z1,{visible:t&&e})})]})},va=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,NS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},AS=(t,e)=>{if(e.length===0)return Vo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Vo:r},PS=(t,e)=>{const n=ag(t),r=c.useRef(Vo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=AS(n.getState().session,i.current);return NS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Vo)},DS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,IS=()=>{const{t}=St(),e=Zn()??"",n=c.useMemo(()=>bS(e),[e]),r=Ae(V=>n?V.contextPanelByDirectory[n]:void 0),i=Ae(V=>V.closeContextPanel),o=Ae(V=>V.closeContextPanelTab),l=Ae(V=>V.openContextPanelTab),a=Ae(V=>V.toggleContextPanelExpanded),d=Ae(V=>V.setContextPanelWidth),u=Ae(V=>V.setActiveContextPanelTab),h=Ae(V=>V.openAgentBrowserTab);c.useEffect(()=>{if(e)return Zw(V=>h(e,V))},[e,h]);const f=Ae(V=>V.openContextFile);c.useEffect(()=>Pn(V=>{if(V.type!=="file-open-request")return;const Fe=V.directory??e;Fe&&f(Fe,V.path)}),[e,f]);const p=Ae(V=>V.reorderContextPanelTabs),x=Js(V=>V.setSelectedPath),b=Ae(V=>V.contextEditorTreeVisible),k=Ae(V=>V.contextEditorTreeWidth),y=Ae(V=>V.setContextEditorTreeWidth),m=Ae(V=>V.toggleContextEditorTree),g=Ae(V=>V.contextEditorVisible),j=Ae(V=>V.toggleContextEditor),S=Ae(V=>V.openNewContextBrowserTab),w=Cf(V=>V.byOrigin),C=Ae(V=>V.allowPromptingSubagentSessions),{themeMode:v,setThemeMode:R,lightThemeId:T,darkThemeId:D,currentTheme:F}=Cn(),B=c.useMemo(()=>r?.tabs??[],[r?.tabs]),E=B.find(V=>V.id===r?.activeTabId)??B[B.length-1]??null,$=E?.mode==="browser"?E.id:null;c.useEffect(()=>{$&&Jw($)},[$]);const L=!!(r?.isOpen&&E),[X,Y]=c.useState(null),I=c.useMemo(()=>B.some(V=>V.mode==="file"&&V.targetPath),[B]),P=I&&(g||!b),A=E?.mode??null,q=A==="file"&&!P,K=!!(L&&r?.expanded&&!q),te=A?r?.widthByMode?.[A]:void 0,ae=A?r?.widthFractionByMode?.[A]:void 0,re=A?sg(A):.5,he=X??(typeof window<"u"?window.innerWidth:il*2),ce=ae!=null&&X!=null?Math.round(ae*X):te,Te=q?k:Bc(ce??Math.round(re*he),Fc(X??he));c.useEffect(()=>{!n||!A||q||ae!=null||te==null||X==null||d(n,A,te,X)},[A,X,n,q,te,ae,d]);const ve=c.useMemo(()=>{const V=[];for(const Fe of B){if(Fe.mode!=="chat")continue;const Ye=va(Fe.dedupeKey);Ye&&!V.includes(Ye)&&V.push(Ye)}return V},[B]),pe=PS(n||void 0,ve),[Ne,U]=c.useState(!1),Z=c.useRef(0),de=c.useRef(Te),ye=c.useRef(null),H=c.useRef(null),je=c.useRef(null),Ee=c.useRef(new Map),ge=c.useRef(new Map),ne=c.useRef(!1);c.useLayoutEffect(()=>{const V=je.current?.parentElement;if(!V||typeof ResizeObserver>"u")return;const Fe=new ResizeObserver(()=>{Y(V.clientWidth||null)});return Fe.observe(V),Y(V.clientWidth||null),()=>Fe.disconnect()},[]),c.useEffect(()=>{if(!L||ne.current){ne.current=L;return}const V=window.requestAnimationFrame(()=>{je.current?.focus({preventScroll:!0})});return ne.current=!0,()=>window.cancelAnimationFrame(V)},[L]);const be=c.useRef(null),G=c.useRef(null),z=c.useCallback(()=>{G.current=null;const V=je.current,Fe=ye.current;!V||Fe===null||V.style.setProperty("--oc-context-panel-width",`${Fe}px`)},[]);c.useEffect(()=>()=>{G.current!==null&&clearTimeout(G.current)},[]);const J=c.useCallback(V=>{const Fe=be.current,Ye=q?Wi(V):Bc(V,Fc(Fe));return Fe===null?Ye:Math.min(Ye,Math.max(1,Fe))},[q]),ue=c.useCallback(V=>{!L||K||!n||(H.current=V.pointerId,U(!0),Z.current=V.clientX,de.current=Te,ye.current=Te,be.current=yS(je.current),document.documentElement.style.cursor="col-resize",V.preventDefault())},[n,K,L,Te]),le=c.useCallback(()=>{const V=J(ye.current??Te),Fe=be.current;ye.current=null,be.current=null,G.current!==null&&(clearTimeout(G.current),G.current=null),document.documentElement.style.cursor="",q?y(V):n&&A&&d(n,A,V,Fe??void 0),U(!1),H.current=null},[A,J,n,q,y,d,Te]);c.useEffect(()=>{if(!Ne)return;const V=Qe=>{if(H.current!==Qe.pointerId)return;const xe=Z.current-Qe.clientX,st=J(de.current+xe);ye.current!==st&&(ye.current=st,G.current===null&&(G.current=setTimeout(z,gS)))},Fe=Qe=>{H.current===Qe.pointerId&&le()},Ye=()=>{le()};return window.addEventListener("pointermove",V),window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Ye),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Ye)}},[z,J,le,Ne]),c.useEffect(()=>{Ne||(ye.current=null,document.documentElement.style.cursor="")},[Ne]);const W=c.useCallback(()=>{n&&i(n)},[i,n]),M=c.useCallback(()=>{n&&a(n)},[n,a]),_=c.useCallback(V=>{V.key==="Escape"&&(V.target instanceof Node&&!V.currentTarget.contains(V.target)||ng(V.target)||rg(V.target)||(V.preventDefault(),V.stopPropagation(),W()))},[W]);c.useEffect(()=>{if(!(!n||!E)&&E.mode==="file"&&E.targetPath){x(n,E.targetPath,{allowOutsideRoot:!0});return}},[E,n,x]);const ee=c.useMemo(()=>B.filter(V=>V.mode==="chat"),[B]),oe=L&&E?.mode==="chat"?E.id:null,fe=L&&E?.mode==="chat"?va(E.dedupeKey):null,ie=yb(ee,oe);c.useEffect(()=>{if(!L||!n||!fe||typeof window>"u")return;const V=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){Ci(n,fe,!1);return}Iu(fe),Ci(n,fe,!0)};V();const Fe=window.setInterval(V,1e4);return window.addEventListener("focus",V),window.addEventListener("blur",V),document.addEventListener("visibilitychange",V),()=>{window.clearInterval(Fe),window.removeEventListener("focus",V),window.removeEventListener("blur",V),document.removeEventListener("visibilitychange",V),Ci(n,fe,!1)}},[fe,n,L]);const Le=c.useCallback((V,Fe,Ye)=>wb(ge.current,V,Fe,n||null,Ye,{mode:v,lightThemeId:T,darkThemeId:D,currentTheme:F},{allowPromptingSubagentSessions:C}),[C,F,D,n,T,v]),$e=ie&&fe?Le(ie.id,fe,ie.readOnly):null;c.useEffect(()=>{const V=new Set(B.map(Fe=>Fe.id));for(const Fe of ge.current.keys())V.has(Fe)||ge.current.delete(Fe)},[B]);const Pe=c.useCallback(V=>{!n||E?.mode!=="diff"||l(n,{mode:"diff",targetPath:E.targetPath,stagedDiff:V==="staged",diffScope:V})},[E,n,l]),Oe=c.useCallback(()=>{if(typeof window>"u")return;const V={themeMode:v,lightThemeId:T,darkThemeId:D,currentTheme:F};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:theme-sync",payload:V},window.location.origin)}},[F,D,T,v]),Q=c.useCallback(()=>{if(typeof window>"u")return;const V={allowPromptingSubagentSessions:C};for(const Fe of Ee.current.values()){const Ye=Fe.contentWindow;Ye&&Ye.postMessage({type:"openchamber:chat-settings-sync",payload:V},window.location.origin)}},[C]),Ce=c.useCallback((V,Fe,Ye)=>{const Qe=Fe.contentWindow;Qe&&Qe.postMessage({type:of,payload:{visible:oe===V}},Ye)},[oe]),Se=c.useCallback(()=>{if(!(typeof window>"u"))for(const[V,Fe]of Ee.current.entries())Ce(V,Fe,window.location.origin)},[Ce]);c.useEffect(()=>{if(typeof window>"u")return;const V=Fe=>{if(Fe.origin!==window.location.origin)return;const Ye=Array.from(Ee.current.entries()).find(([,ot])=>ot.contentWindow===Fe.source);if(!Ye)return;const Qe=Fe.data;if(Qe?.type===vb){const[ot,vt]=Ye;Ce(ot,vt,Fe.origin);return}if(Qe?.type===Sb){if(typeof Qe.requestId!="string"||!Qe.requestId)return;const ot=Wt(),vt={apiBaseUrl:mn(),clientToken:Ur(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:ot.startsWith("host:")?ot.slice(5):"",relay:ch()??void 0};Fe.source?.postMessage({type:jb,requestId:Qe.requestId,payload:vt},Fe.origin);return}if(Qe?.type==="openchamber:theme-sync-request"){Oe();return}if(Qe?.type==="openchamber:chat-settings-request"){Q();return}if(Qe?.type!=="openchamber:cycle-theme-request")return;const xe=["light","dark","system"],Re=(xe.indexOf(v)+1)%xe.length;R(xe[Re])};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[Q,Ce,Oe,R,v]),c.useLayoutEffect(()=>{B.some(Fe=>Fe.mode==="chat")&&(Oe(),Q(),Se())},[D,T,Q,Se,Oe,B,v]);const Ke=E?.mode==="file"||E?.mode==="chat"||E?.mode==="browser",et=c.useMemo(()=>E?B.filter(V=>V.mode===E.mode):[],[E,B]),it=c.useMemo(()=>et.map(V=>{const Fe=SS(V,pe,t),Ye=DS(Fe,xS),Qe=wS(V.targetPath,e);return{id:V.id,label:Ye,icon:Lc(V,w),title:Qe?`${Fe}: ${Qe}`:Fe,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ye})}}),[et,e,w,pe,t]),rt=E?.mode==="context"?s.jsx(iw,{}):E?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(uS,{isActive:L})}):E?.mode==="pr"?s.jsx(h1,{}):E?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(fS,{})}):E?.mode==="notes"?s.jsx(Fh,{}):E?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(mS,{targetPath:E.targetPath,savedProjectPlan:E.projectPlanId&&E.projectPlanRef?{projectRef:E.projectPlanRef,planId:E.projectPlanId}:null})}):null,pt=c.useMemo(()=>B.filter(V=>V.mode==="browser"),[B]),ht=c.useMemo(()=>B.filter(V=>V.mode==="diff"),[B]),tt=c.useMemo(()=>B.find(V=>V.mode==="terminal")??null,[B]),At=c.useMemo(()=>B.some(V=>V.mode==="walkthrough"),[B]),jt=c.useMemo(()=>B.filter(V=>Un(V.mode)),[B]),we=Fa(V=>V.guests),Xe=c.useMemo(()=>new Set(we.filter(og).map(V=>V.id)),[we]),mt=c.useMemo(()=>{const V=new Map;for(const Fe of we){const Ye=ig(Fe);Ye&&V.set(Fe.id,Ye)}return V},[we]),qe=c.useMemo(()=>B.some(V=>V.mode==="file"),[B]),ft=E?.mode==="file",se=Ae(V=>V.closeContextPanelTabs),me=c.useCallback(V=>{if(!n)return null;const{id:Fe,index:Ye,allIds:Qe,close:xe}=V,st=()=>se(n,Qe.filter(He=>He!==Fe)),Re=()=>se(n,Qe.slice(0,Ye)),ot=()=>se(n,Qe.slice(Ye+1)),vt=()=>se(n,Qe),De=Qe.length>1,gt=Ye===0,Ct=Ye===Qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(zn,{onClick:xe,children:[s.jsx(O,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:st,disabled:!De,children:[s.jsx(O,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(zn,{onClick:Re,disabled:gt,children:[s.jsx(O,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(zn,{onClick:ot,disabled:Ct,children:[s.jsx(O,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Hi,{}),s.jsxs(zn,{onClick:vt,disabled:!De,children:[s.jsx(O,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[se,n,t]),Ie=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[Ke?s.jsx(Yd,{items:it,activeId:E?.id??null,onSelect:V=>{n&&u(n,V)},onClose:V=>{n&&o(n,V)},onReorder:(V,Fe)=>{n&&p(n,V,Fe)},layoutMode:"scrollable",variant:"default",tabContextMenu:me}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[E?Lc(E,w):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:E?Uf(E.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[E?.mode==="browser"?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,ft&&I?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:j,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":P,children:s.jsx(O,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ft?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:m,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(O,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,q?null:s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:M,className:"h-7 w-7 p-0",title:t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(K?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:K?s.jsx(O,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:W,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]})]}),We=L?K?{"--oc-context-panel-width":X!==null?`${X}px`:"100%",width:X!==null?`${X}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Te}px`}:{"--oc-context-panel-width":`${Te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:je,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Me("flex min-h-0 flex-col overflow-hidden bg-background",K?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:_,style:We,children:[L&&!K&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!K&&s.jsx("div",{className:Me("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ne&&"bg-[var(--interactive-border)]"),onPointerDown:ue,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Me("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]",!L&&"pointer-events-none select-none opacity-0"),style:{width:K?X!==null?`${X}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ie,s.jsxs("div",{className:Me("relative min-h-0 flex-1 overflow-hidden",Ne&&"pointer-events-none"),children:[qe?s.jsxs("div",{className:Me("absolute inset-0 flex",ft?"flex":"hidden"),children:[I||!b?s.jsx("div",{className:Me("h-full min-w-0 flex-1",I&&!P&&"hidden"),children:I?s.jsx(c.Suspense,{fallback:null,children:s.jsx(dS,{mode:"editor-only",visible:L&&ft&&P})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(O,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(CS,{visible:b,active:L&&ft,fill:!P})]}):null,ie&&fe&&$e?s.jsx("iframe",{ref:V=>{if(!V){Ee.current.delete(ie.id);return}Ee.current.set(ie.id,V)},src:$e,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:fe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Oe(),Q(),Se()}},ie.id):null,pt.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"invisible pointer-events-none"),"aria-hidden":E?.id!==V.id||void 0,children:s.jsx(nS,{initialUrl:V.targetPath??"",directory:n,tabID:V.id})},V.id)),ht.map(V=>s.jsx("div",{className:Me("absolute inset-0",E?.id!==V.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(cS,{visible:L&&E?.id===V.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:V.diffScope??(V.stagedDiff?"staged":"working"),onDiffScopeChange:Pe,targetFilePath:V.targetPath,flushContent:!0})})},V.id)),tt?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="terminal"?"block":"hidden"),children:s.jsx(Lh,{visible:L&&E?.mode==="terminal",directory:tt.targetDirectory})}):null,At?s.jsx("div",{className:Me("absolute inset-0",E?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(lS,{directory:e,visible:L&&E?.mode==="walkthrough"})})}):null,jt.map(V=>{if(!Un(V.mode))return null;const Fe=Ro(V.mode),Ye=Xe.has(Fe),Qe=mt.get(Fe),xe=E?.id===V.id,st=xe&&L;return Ye&&!Qe&&!st?null:s.jsx("div",{className:Me("absolute inset-0",xe?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ye?Qe?s.jsxs("div",{className:Me("flex h-full",Kf[Qe.dock].container),children:[s.jsx(hS,{mode:V.mode,docking:Qe}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:st?s.jsx(Oc,{mode:V.mode}):null})]}):s.jsx(Oc,{mode:V.mode}):s.jsx(Wf,{mode:V.mode})})},V.id)}),E?.mode!=="chat"&&!ft&&E?.mode!=="browser"&&E?.mode!=="diff"&&E?.mode!=="terminal"&&E?.mode!=="walkthrough"&&!(E&&Un(E.mode))?rt:null]})]})]})},TS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=St(),o=Ae(ES),l=Ae(RS),a=Ae(MS),d=Ae(OS),u=Ka();let h;e[0]!==o||e[1]!==u?(h=Tu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,p=l.length===0;let x;if(e[3]!==l||e[4]!==f){let T;e[6]!==l?(T=D=>l.includes(D.id),e[6]=l,e[7]=T):T=e[7],x=f.every(T),e[3]=l,e[4]=f,e[5]=x}else x=e[5];const b=x;let k;e[8]!==i?(k=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=k):k=e[9];let y;e[10]!==k?(y=s.jsx(Bs,{children:k}),e[10]=k,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let g;e[14]!==m?(g=s.jsx(Fs,{children:m}),e[14]=m,e[15]=g):g=e[15];let j;e[16]!==y||e[17]!==g?(j=s.jsxs(Us,{children:[y,g]}),e[16]=y,e[17]=g,e[18]=j):j=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let T;e[24]!==l||e[25]!==a||e[26]!==i?(T=D=>s.jsx(dg,{settingsItem:`layout.context-rail.surface.${D.id}`,checked:!l.includes(D.id),onChange:F=>a(D.id,F),label:D.label??i(D.labelKey),ariaLabel:D.label??i(D.labelKey)},D.id),e[24]=l,e[25]=a,e[26]=i,e[27]=T):T=e[27],S=f.map(T),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let w;e[28]!==S?(w=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=w):w=e[29];let C;e[30]!==p||e[31]!==b||e[32]!==d||e[33]!==i?(C=p?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[b?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(ut,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=p,e[31]=b,e[32]=d,e[33]=i,e[34]=C):C=e[34];let v;e[35]!==C||e[36]!==j||e[37]!==w?(v=s.jsxs(ys,{className:"max-w-md",children:[j,w,C]}),e[35]=C,e[36]=j,e[37]=w,e[38]=v):v=e[38];let R;return e[39]!==r||e[40]!==n||e[41]!==v?(R=s.jsx(bs,{open:n,onOpenChange:r,children:v}),e[39]=r,e[40]=n,e[41]=v,e[42]=R):R=e[42],R};function ES(t){return t.contextRailOrder}function RS(t){return t.contextRailHiddenSurfaces}function MS(t){return t.setContextRailSurfaceVisible}function OS(t){return t.setContextRailHiddenSurfaces}const Hf=150,BS=500,FS=[],LS=t=>t>99?"99+":String(t),_S=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:p}=t;let x;e[0]!==n.id?(x={id:n.id},e[0]=n.id,e[1]=x):x=e[1];const{attributes:b,listeners:k,setNodeRef:y,transform:m,transition:g,isDragging:j}=di(x);let S;e[2]!==a?(S=a!=null&&a>0?LS(a):null,e[2]=a,e[3]=S):S=e[3];const w=S;let C;e[4]!==m?(C=ui.Translate.toString(m),e[4]=m,e[5]=C):C=e[5];let v;e[6]!==C||e[7]!==g?(v={transform:C,transition:g},e[6]=C,e[7]=g,e[8]=v):v=e[8];const R=j&&"z-10 opacity-70";let T;e[9]!==R?(T=Me("relative",R),e[9]=R,e[10]=T):T=e[10];let D;e[11]!==p||e[12]!==n?(D=()=>p(n),e[11]=p,e[12]=n,e[13]=D):D=e[13];const F=d??o,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=Me("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(pf,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let L;e[20]!==w||e[21]!==h||e[22]!==i||e[23]!==f?(L=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):w?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:w}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=w,e[21]=h,e[22]=i,e[23]=f,e[24]=L):L=e[24];let X;e[25]!==b||e[26]!==r||e[27]!==k||e[28]!==E||e[29]!==$||e[30]!==L||e[31]!==D||e[32]!==F?(X=s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...k,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[$,L]})}),e[25]=b,e[26]=r,e[27]=k,e[28]=E,e[29]=$,e[30]=L,e[31]=D,e[32]=F,e[33]=X):X=e[33];let Y;e[34]!==o?(Y=s.jsx("span",{children:o}),e[34]=o,e[35]=Y):Y=e[35];let I;e[36]!==l?(I=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=I):I=e[37];let P;e[38]!==u?(P=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=P):P=e[39];let A;e[40]!==Y||e[41]!==I||e[42]!==P?(A=s.jsx(wt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[Y,I,P]})}),e[40]=Y,e[41]=I,e[42]=P,e[43]=A):A=e[43];let q;e[44]!==X||e[45]!==A?(q=s.jsxs(bt,{delayDuration:Hf,children:[X,A]}),e[44]=X,e[45]=A,e[46]=q):q=e[46];let K;return e[47]!==y||e[48]!==q||e[49]!==v||e[50]!==T?(K=s.jsx("div",{ref:y,style:v,className:T,children:q}),e[47]=y,e[48]=q,e[49]=v,e[50]=T,e[51]=K):K=e[51],K},$S=()=>{const t=Ze.c(92),{t:e}=St(),n=Zn();let r;t[0]!==n?(r=n?$n(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=le=>i?le.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Ae(o),a=Ae(zS),d=Ae(WS),u=Ae(KS),h=Ae(VS),f=Ae(US),p=Ae(HS),x=Ae(GS),b=La(qS),k=Ji(YS),y=Ji(QS),m=hn(XS),g=hn(JS),{screenWidth:j}=Nn(),S=_a(i||null);let w;t[4]!==x?(w=Zi("switch_context_surface",x),t[4]=x,t[5]=w):w=t[5];const C=w,[v,R]=c.useState(!1);let T,D;t[6]!==C?(T=()=>{const le=new Set;let W=null,M=!1;const _=ZS,ee=()=>{Ol(C,le)?!M&&W===null&&(W=setTimeout(()=>R(!0),BS)):(M=!1,W!==null&&(clearTimeout(W),W=null),R(!1))},oe=Le=>{if(le.add(Le.key.toLowerCase()),_(Le.key)&&Ol(C,le)){M=!0,W!==null&&(clearTimeout(W),W=null),R(!1);return}ee()},fe=Le=>{le.delete(Le.key.toLowerCase()),ee()},ie=()=>{le.clear(),M=!1,W!==null&&(clearTimeout(W),W=null),R(!1)};return window.addEventListener("keydown",oe,!0),window.addEventListener("keyup",fe,!0),window.addEventListener("blur",ie),()=>{window.removeEventListener("keydown",oe,!0),window.removeEventListener("keyup",fe,!0),window.removeEventListener("blur",ie),W!==null&&clearTimeout(W)}},D=[C],t[6]=C,t[7]=T,t[8]=D):(T=t[7],D=t[8]),c.useEffect(T,D);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let B;t[10]===Symbol.for("react.memo_cache_sentinel")?(B={activationConstraint:{delay:200,tolerance:6}},t[10]=B):B=t[10];const E=oi(fn(ai,F),fn(ii,B)),$=Ka(),L=Ml(ej),X=Ml(tj),Y=l?.tabs??FS;let I;t[11]!==l?.activeTabId||t[12]!==Y?(I=Y.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=Y,t[13]=I):I=t[13];const P=I,A=l?.isOpen?P?.mode??null:null,q=S?.files.length??0;let K;t[14]!==u||t[15]!==d||t[16]!==g||t[17]!==$||t[18]!==y||t[19]!==b||t[20]!==j||t[21]!==Y?(K=ug({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:kn(),screenWidth:j,tabs:Y,linearConnected:y,githubConnected:g,extras:$}),t[14]=u,t[15]=d,t[16]=g,t[17]=$,t[18]=y,t[19]=b,t[20]=j,t[21]=Y,t[22]=K):K=t[22];const te=K;let ae,re;t[23]!==A||t[24]!==p||t[25]!==i||t[26]!==k||t[27]!==y?(re=()=>{!i||!k||y||A!=="linear"||p(i)},ae=[A,p,i,k,y],t[23]=A,t[24]=p,t[25]=i,t[26]=k,t[27]=y,t[28]=ae,t[29]=re):(ae=t[28],re=t[29]),c.useEffect(re,ae);let he,ce;t[30]!==A||t[31]!==p||t[32]!==i||t[33]!==m||t[34]!==g?(he=()=>{!i||!m||g||A!=="pr"||p(i)},ce=[A,p,i,m,g],t[30]=A,t[31]=p,t[32]=i,t[33]=m,t[34]=g,t[35]=he,t[36]=ce):(he=t[35],ce=t[36]),c.useEffect(he,ce);const[Te,ve]=c.useState(!1);let pe;t[37]!==$||t[38]!==h?(pe=le=>{const{active:W,over:M}=le;if(!M||W.id===M.id)return;const _=Tu(Ae.getState().contextRailOrder,$).map(sj),ee=_.indexOf(W.id),oe=_.indexOf(M.id);ee===-1||oe===-1||h(Zu(_,ee,oe))},t[37]=$,t[38]=h,t[39]=pe):pe=t[39];const Ne=pe;if(!i)return null;let U;t[40]!==e?(U=e("contextRail.aria.rail"),t[40]=e,t[41]=U):U=t[41];let Z;t[42]!==te?(Z=te.map(nj),t[42]=te,t[43]=Z):Z=t[43];let de;if(t[44]!==A||t[45]!==q||t[46]!==X||t[47]!==i||t[48]!==L||t[49]!==f||t[50]!==v||t[51]!==te||t[52]!==e||t[53]!==a){let le;t[55]!==A||t[56]!==q||t[57]!==X||t[58]!==i||t[59]!==L||t[60]!==f||t[61]!==v||t[62]!==e||t[63]!==a?(le=(W,M)=>{const _=W.label??e(W.labelKey),ee=W.id==="git"&&!a?q:0,oe=Un(W.mode)&&A!==W.mode?L[Ro(W.mode)]??0:0,fe=ee>0?ee:oe>0?oe:null,ie=fe!==null&&ee===0;return s.jsx(_S,{surface:W,isActive:A===W.mode,showActivityDot:!1,label:_,description:e(W.descriptionKey),badgeCount:fe,badgeAriaLabel:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":fe===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:_,count:fe}):null,badgeDescription:fe!==null?e(ie?fe===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":fe===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:fe}):null,orderNumber:M+1,showOrderNumber:v,onSelect:Le=>{Un(Le.mode)&&X(Ro(Le.mode)),f(i,Le.mode)}},W.id)},t[55]=A,t[56]=q,t[57]=X,t[58]=i,t[59]=L,t[60]=f,t[61]=v,t[62]=e,t[63]=a,t[64]=le):le=t[64],de=te.map(le),t[44]=A,t[45]=q,t[46]=X,t[47]=i,t[48]=L,t[49]=f,t[50]=v,t[51]=te,t[52]=e,t[53]=a,t[54]=de}else de=t[54];let ye;t[65]!==Z||t[66]!==de?(ye=s.jsx(Xa,{items:Z,strategy:ef,children:de}),t[65]=Z,t[66]=de,t[67]=ye):ye=t[67];let H;t[68]!==Ne||t[69]!==E||t[70]!==ye?(H=s.jsx(li,{sensors:E,collisionDetection:ci,onDragEnd:Ne,children:ye}),t[68]=Ne,t[69]=E,t[70]=ye,t[71]=H):H=t[71];let je;t[72]!==e?(je=e("contextRail.configure.open"),t[72]=e,t[73]=je):je=t[73];let Ee;t[74]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>ve(!0),t[74]=Ee):Ee=t[74];let ge;t[75]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsx(O,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=ge):ge=t[75];let ne;t[76]!==je?(ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":je,onClick:Ee,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ge})}),t[76]=je,t[77]=ne):ne=t[77];let be;t[78]!==e?(be=e("contextRail.configure.open"),t[78]=e,t[79]=be):be=t[79];let G;t[80]!==be?(G=s.jsx(wt,{side:"left",sideOffset:8,children:be}),t[80]=be,t[81]=G):G=t[81];let z;t[82]!==ne||t[83]!==G?(z=s.jsxs(bt,{delayDuration:Hf,children:[ne,G]}),t[82]=ne,t[83]=G,t[84]=z):z=t[84];let J;t[85]!==Te?(J=s.jsx(TS,{open:Te,onOpenChange:ve}),t[85]=Te,t[86]=J):J=t[86];let ue;return t[87]!==U||t[88]!==H||t[89]!==z||t[90]!==J?(ue=s.jsxs("nav",{"aria-label":U,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,z,J]}),t[87]=U,t[88]=H,t[89]=z,t[90]=J,t[91]=ue):ue=t[91],ue};function zS(t){return t.workStatusPanelVisible}function WS(t){return t.contextRailOrder}function KS(t){return t.contextRailHiddenSurfaces}function VS(t){return t.setContextRailOrder}function US(t){return t.openContextSurface}function HS(t){return t.closeContextPanel}function GS(t){return t.shortcutOverrides}function qS(t){return t.planModeEnabled}function YS(t){return t.hasChecked}function QS(t){return t.status?.connected===!0}function XS(t){return t.hasChecked}function JS(t){return t.status?.connected===!0}function ZS(t){return t.length===1&&t>="0"&&t<="9"}function ej(t){return t.countByGuest}function tj(t){return t.clearBadge}function sj(t){return t.id}function nj(t){return t.id}const rj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),oj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Or(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),ij=new Set,aj=[],Sa=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},lj=()=>{const t=Ze.c(183),{t:e}=St(),n=Ae(cj),r=Ae(dj),i=Ae(uj),o=Ae(fj),l=Ae(mj),a=Ae(hj),d=Ae(pj),u=Ae(gj),h=Ae(xj),f=Ae(bj),p=Ae(yj),x=Ae(wj),b=Ae(vj),k=nt(Sj),y=nt(jj),m=nt(kj),g=Hr(Cj);let j;t[0]!==n?(j=He=>n?He.activeSessions:aj,t[0]=n,t[1]=j):j=t[1];const S=us(j);let w;t[2]!==n?(w=He=>n?He.ids:ij,t[2]=n,t[3]=w):w=t[3];const C=Hr(w);let v;t[4]!==n?(v=He=>n?He.rankById:Ua,t[4]=n,t[5]=v):v=t[5];const R=Va(v),T=Jt(Nj),D=zt(Aj),F=zt(Pj),B=Zn(),E=$d(Dj),{files:$,git:L}=nn(),X=pn(Ij),{isMobile:Y}=Nn();let I;t[6]!==B?(I=B?Sa(B):null,t[6]=B,t[7]=I):I=t[7];const P=I,[A,q]=c.useState(""),te=Au(A,200).trim();let ae;t[8]!==A?(ae=A.trim(),t[8]=A,t[9]=ae):ae=t[9];const re=ae;let he,ce;t[10]!==n?(he=()=>{n&&q("")},ce=[n],t[10]=n,t[11]=he,t[12]=ce):(he=t[11],ce=t[12]),c.useEffect(he,ce);let Te,ve;t[13]!==S||t[14]!==X||t[15]!==L||t[16]!==n?(Te=()=>{if(!n||!L)return;const He=setTimeout(()=>{const Ue=new Set;for(const lt of S){const _e=xs(lt);!_e||Ue.has(_e)||(Ue.add(_e),X(_e,L))}},0);return()=>clearTimeout(He)},ve=[n,S,L,X],t[13]=S,t[14]=X,t[15]=L,t[16]=n,t[17]=Te,t[18]=ve):(Te=t[17],ve=t[18]),c.useEffect(Te,ve);let pe;t[19]!==r?(pe=()=>r(!1),t[19]=r,t[20]=pe):pe=t[20];const Ne=pe;let U;t[21]!==Ne?(U=He=>()=>{Ne(),He()},t[21]=Ne,t[22]=U):U=t[22];const Z=U;let de;t[23]!==D?.id||t[24]!==D?.path||t[25]!==T||t[26]!==m||t[27]!==Y||t[28]!==d||t[29]!==u||t[30]!==p||t[31]!==k||t[32]!==Z||t[33]!==x||t[34]!==b||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==g||t[39]!==a?(de=()=>{const He=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(O,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Z(()=>{l(!1),k()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(O,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Z(Tj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(O,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Z(Ej)},{id:"toggle-sidebar",title:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(O,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(Y?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Z(()=>{if(Y){const{isSessionSwitcherOpen:Ue}=Ae.getState();l(!Ue)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(O,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Z(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(O,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Z(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(O,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:Z(Rj)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(O,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:Z(Mj)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(O,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Z(()=>i(!0))}];return He.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(O,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:Z(()=>{m&&T&&g({directory:T,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(O,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:Z(()=>{m&&Jn(m).then(Ue=>{if(Ue.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(O,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:Z(()=>{l(!1),p()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(O,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:Z(()=>{l(!1),x(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(O,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:Z(()=>{T&&(b("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(O,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:Z(()=>{T&&(b("todos"),u(T,"notes"))})}),kn()||He.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(O,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:Z(()=>{$h(e)})}),He.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(O,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:Z(Oj)}),Vr()&&He.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(O,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Z(()=>{jn("desktop_open_draft_mini_chat_window",{directory:Sa(T||D?.path||""),projectId:D?.id??null}).catch(Bj)})}),He},t[23]=D?.id,t[24]=D?.path,t[25]=T,t[26]=m,t[27]=Y,t[28]=d,t[29]=u,t[30]=p,t[31]=k,t[32]=Z,t[33]=x,t[34]=b,t[35]=l,t[36]=i,t[37]=e,t[38]=g,t[39]=a,t[40]=de):de=t[40],D?.id,D?.path;let ye;t[41]!==de?(ye=de(),t[41]=de,t[42]=ye):ye=t[42];const H=ye,je=Ae(Fj);let Ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(Ee=en(),t[43]=Ee):Ee=t[43];const ge=Ee;let ne,be;t[44]===Symbol.for("react.memo_cache_sentinel")?(ne=kn(),be=!ge&&Ra(),t[44]=ne,t[45]=be):(ne=t[44],be=t[45]);let G;t[46]!==Y||t[47]!==je?(G={isVSCode:ne,isWeb:be,isDesktop:ge,isMobile:Y,routingAvailable:je},t[46]=Y,t[47]=je,t[48]=G):G=t[48];const z=G;let J;if(t[49]!==Z||t[50]!==i||t[51]!==o||t[52]!==z){let He;t[54]!==z?(He=lt=>lt.isAvailable?lt.isAvailable(z):!0,t[54]=z,t[55]=He):He=t[55];let Ue;t[56]!==Z||t[57]!==i||t[58]!==o?(Ue=lt=>{const _e=zh(lt.slug)??"settings-3",Ge=(lt.keywords??[]).join(" ");return{id:`settings:${lt.slug}`,title:lt.title,icon:lt.slug==="mcp"?s.jsx(gg,{className:"mr-2 h-4 w-4"}):s.jsx(O,{name:_e,className:"mr-2 h-4 w-4"}),searchText:`${lt.title} ${lt.group} ${Ge}`,onSelect:Z(()=>{o(lt.slug),i(!0)})}},t[56]=Z,t[57]=i,t[58]=o,t[59]=Ue):Ue=t[59],J=_h.filter(Lj).filter(He).map(Ue),t[49]=Z,t[50]=i,t[51]=o,t[52]=z,t[53]=J}else J=t[53];const ue=J;let le;if(t[60]!==S||t[61]!==C||t[62]!==R){const He=S.filter(_j);le=fg(He,C,R),t[60]=S,t[61]=C,t[62]=R,t[63]=le}else le=t[63];const W=le,M=Eu(),_=nt($j);let ee;t[64]!==M||t[65]!==_?(ee=(He,Ue)=>{const lt=_.get(He);return lt?.branch?lt.branch.trim()||null:Ue&&M.get(Ue)?.trim()||null},t[64]=M,t[65]=_,t[66]=ee):ee=t[66];const oe=ee;let fe;t[67]===Symbol.for("react.memo_cache_sentinel")?(fe=[],t[67]=fe):fe=t[67];const[ie,Le]=c.useState(fe),[$e,Pe]=c.useState(""),Oe=rj(P,te);let Q;t[68]!==P||t[69]!==Oe||t[70]!==n||t[71]!==E||t[72]!==Le||t[73]!==Pe||t[74]!==te?(Q=()=>{if(!n){Le([]),Pe("");return}if(!Oe){Le([]),Pe("");return}if(!P){Le([]),Pe("");return}let He=!1;return E(P,te,40,{type:"file"}).then(Ue=>{He||(Le(Ue.map(zj)),Pe(Oe))}).catch(()=>{He||(Le([]),Pe(Oe))}),()=>{He=!0}},t[68]=P,t[69]=Oe,t[70]=n,t[71]=E,t[72]=Le,t[73]=Pe,t[74]=te,t[75]=Q):Q=t[75];let Ce;t[76]!==P||t[77]!==Oe||t[78]!==n||t[79]!==E||t[80]!==te?(Ce=[n,P,te,Oe,E],t[76]=P,t[77]=Oe,t[78]=n,t[79]=E,t[80]=te,t[81]=Ce):Ce=t[81],c.useEffect(Q,Ce);const Se=re.length>0;let Ke;e:{if(!Se){let Ue;t[82]!==H?(Ue=H.filter(Wj).map(Kj),t[82]=H,t[83]=Ue):Ue=t[83],Ke=Ue;break e}let He;t[84]!==H||t[85]!==re?(He=Or(H,re,Vj,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=re,t[86]=He):He=t[86],Ke=He}const et=Ke;let it;e:{if(!Se){let Ue;t[87]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[87]=Ue):Ue=t[87],it=Ue;break e}let He;t[88]!==re||t[89]!==ue?(He=Or(ue,re,Uj,{limit:7,noFuzzy:!0}),t[88]=re,t[89]=ue,t[90]=He):He=t[90],it=He}const rt=it;let pt;e:{if(!Se){let Ue;t[91]!==W?(Ue=W.slice(0,5).map(Hj),t[91]=W,t[92]=Ue):Ue=t[92],pt=Ue;break e}let He;t[93]!==re||t[94]!==W?(He=Or(W,re,Gj,{limit:7,threshold:.2}),t[93]=re,t[94]=W,t[95]=He):He=t[95],pt=He}const ht=pt;let tt;e:{if(!n){let Ue;t[96]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[96]=Ue):Ue=t[96],tt=Ue;break e}let He;t[97]!==ie||t[98]!==$e||t[99]!==Oe||t[100]!==te?(He=oj(ie,te,Oe,$e),t[97]=ie,t[98]=$e,t[99]=Oe,t[100]=te,t[101]=He):He=t[101],tt=He}const At=tt,jt=n&&Oe.length>0&&$e!==Oe;let we;e:{if(!Se){let Ue;t[102]===Symbol.for("react.memo_cache_sentinel")?(Ue=[],t[102]=Ue):Ue=t[102],we=Ue;break e}let He;if(t[103]!==re||t[104]!==F){const Ue=F.map(qj);He=Or(Ue,re,Yj,{limit:7,threshold:.4}),t[103]=re,t[104]=F,t[105]=He}else He=t[105];we=He}const Xe=we;let mt,qe,ft,se,me,Ie,We,V,Fe,Ye,Qe,xe,st,Re;if(t[106]!==oe||t[107]!==Ne||t[108]!==P||t[109]!==$||t[110]!==Se||t[111]!==n||t[112]!==h||t[113]!==k||t[114]!==A||t[115]!==et||t[116]!==At||t[117]!==Xe||t[118]!==ht||t[119]!==rt||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const He=et.map(Qj),Ue=rt.map(Xj),lt=ht.map(Jj),_e=Se?At.map(Zj):[],Ge=Se?Xe.map(e0):[];let Je;e:{if(!Se){Je=["commands","sessions"];break e}const Dt=t0,Pt=[{key:"commands",score:Dt(et)},{key:"settings",score:Dt(rt)},{key:"sessions",score:Dt(ht)},{key:"files",score:Dt(At)},{key:"projects",score:Dt(Xe)}];Pt.sort(s0),Je=Pt.map(n0)}const at=Je,Nt=Dt=>{Ne(),y(Dt.id,xs(Dt))},Bt=async Dt=>{if(!P)return;const Pt=await wf($,Dt,{directory:P});if(!Pt.ok){ze.error(vf(Pt.reason));return}h(P,Dt),Ne()},Ft=(Dt,Pt)=>{Ne(),k({selectedProjectId:Dt,directoryOverride:Pt})},Qt=Dt=>Hn(Jr(Dt,f));se=bs,xe=n,st=r;let Mt;t[138]!==e?(Mt=e("commandPalette.title"),t[138]=e,t[139]=Mt):Mt=t[139];let Gt;t[140]!==Mt?(Gt=s.jsx(Bs,{children:Mt}),t[140]=Mt,t[141]=Gt):Gt=t[141];let $t;t[142]!==e?($t=e("commandPalette.description"),t[142]=e,t[143]=$t):$t=t[143];let Zt;t[144]!==$t?(Zt=s.jsx(Fs,{children:$t}),t[144]=$t,t[145]=Zt):Zt=t[145],t[146]!==Gt||t[147]!==Zt?(Re=s.jsxs(Us,{className:"sr-only",children:[Gt,Zt]}),t[146]=Gt,t[147]=Zt,t[148]=Re):Re=t[148],ft=ys,Ye="overflow-hidden p-0",Qe=!0,qe=xg,We=!1,V="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let ts;t[149]!==e?(ts=e("commandPalette.input.placeholder"),t[149]=e,t[150]=ts):ts=t[150],t[151]!==A||t[152]!==ts?(Fe=s.jsx(bg,{value:A,onValueChange:q,placeholder:ts}),t[151]=A,t[152]=ts,t[153]=Fe):Fe=t[153],mt=yg;let Ot;t[154]!==e?(Ot=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Ot):Ot=t[155],t[156]!==Ot?(me=s.jsx(wg,{children:Ot}),t[156]=Ot,t[157]=me):me=t[157],Ie=at.map(Dt=>Dt==="commands"&&He.length>0?s.jsx(Pr,{children:He.map(Pt=>s.jsxs(Br,{value:Pt.id,onSelect:Pt.onSelect,children:[Pt.icon,s.jsx("span",{children:Pt.title}),Pt.shortcutId?s.jsx(mg,{children:Qt(Pt.shortcutId)}):null]},Pt.id))},"commands"):Dt==="settings"&&Ue.length>0?s.jsx(Pr,{children:Ue.map(r0)},"settings"):Dt==="sessions"&&lt.length>0?s.jsx(Pr,{children:lt.map(Pt=>{const fs=Pt.title||e("commandPalette.session.untitled"),Ts=xs(Pt),xn=oe(Pt.id,Ts);return s.jsxs(Br,{value:`session:${Pt.id}`,onSelect:()=>Nt(Pt),children:[s.jsx(O,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),xn?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:xn})]}):null]},Pt.id)})},"sessions"):Dt==="files"&&_e.length>0?s.jsx(Pr,{children:_e.map(Pt=>{const fs=hg(Pt.relativePath||Pt.name,{maxLength:80});return s.jsxs(Br,{value:`file:${Pt.path}`,onSelect:()=>{Bt(Pt.path)},children:[s.jsx(Wa,{filePath:Pt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Pt.relativePath,children:fs})]},`file:${Pt.path}`)})},"files"):Dt==="projects"&&Ge.length>0?s.jsx(Pr,{children:Ge.map(Pt=>{const fs=Pt.displayName;return s.jsxs(Br,{value:`project:${Pt.id}`,onSelect:()=>Ft(Pt.id,Pt.path),children:[s.jsx(O,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:fs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Pt.path})]},`project:${Pt.id}`)})},"projects"):null),t[106]=oe,t[107]=Ne,t[108]=P,t[109]=$,t[110]=Se,t[111]=n,t[112]=h,t[113]=k,t[114]=A,t[115]=et,t[116]=At,t[117]=Xe,t[118]=ht,t[119]=rt,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=mt,t[125]=qe,t[126]=ft,t[127]=se,t[128]=me,t[129]=Ie,t[130]=We,t[131]=V,t[132]=Fe,t[133]=Ye,t[134]=Qe,t[135]=xe,t[136]=st,t[137]=Re}else mt=t[124],qe=t[125],ft=t[126],se=t[127],me=t[128],Ie=t[129],We=t[130],V=t[131],Fe=t[132],Ye=t[133],Qe=t[134],xe=t[135],st=t[136],Re=t[137];let ot;t[158]!==jt||t[159]!==e?(ot=jt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=jt,t[159]=e,t[160]=ot):ot=t[160];let vt;t[161]!==mt||t[162]!==me||t[163]!==Ie||t[164]!==ot?(vt=s.jsxs(mt,{children:[me,Ie,ot]}),t[161]=mt,t[162]=me,t[163]=Ie,t[164]=ot,t[165]=vt):vt=t[165];let De;t[166]!==qe||t[167]!==We||t[168]!==V||t[169]!==Fe||t[170]!==vt?(De=s.jsxs(qe,{shouldFilter:We,className:V,children:[Fe,vt]}),t[166]=qe,t[167]=We,t[168]=V,t[169]=Fe,t[170]=vt,t[171]=De):De=t[171];let gt;t[172]!==ft||t[173]!==Ye||t[174]!==Qe||t[175]!==De?(gt=s.jsx(ft,{className:Ye,showCloseButton:Qe,children:De}),t[172]=ft,t[173]=Ye,t[174]=Qe,t[175]=De,t[176]=gt):gt=t[176];let Ct;return t[177]!==se||t[178]!==xe||t[179]!==st||t[180]!==Re||t[181]!==gt?(Ct=s.jsxs(se,{open:xe,onOpenChange:st,children:[Re,gt]}),t[177]=se,t[178]=xe,t[179]=st,t[180]=Re,t[181]=gt,t[182]=Ct):Ct=t[182],Ct};function cj(t){return t.isCommandPaletteOpen}function dj(t){return t.setCommandPaletteOpen}function uj(t){return t.setSettingsDialogOpen}function fj(t){return t.setSettingsPage}function mj(t){return t.setSessionSwitcherOpen}function hj(t){return t.toggleSidebar}function pj(t){return t.openContextOverview}function gj(t){return t.openContextSurface}function xj(t){return t.openContextFile}function bj(t){return t.shortcutOverrides}function yj(t){return t.openMultiRunLauncher}function wj(t){return t.setArchivePageOpen}function vj(t){return t.setProjectContextTab}function Sj(t){return t.openNewSessionDraft}function jj(t){return t.setCurrentSession}function kj(t){return t.currentSessionId}function Cj(t){return t.toggle}function Nj(t){return t.currentDirectory}function Aj(t){return t.getActiveProject()}function Pj(t){return t.projects}function Dj(t){return t.searchFiles}function Ij(t){return t.ensureStatus}function Tj(){Ru()}function Ej(){Qs.requestDirectoryDialog()}function Rj(){vg.invoke("cycle_theme")}function Mj(){Mu()}function Oj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Bj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Fj(t){return t.routingFeatureAvailable}function Lj(t){return t.slug!=="home"}function _j(t){return!pg(t)}function $j(t){return t.worktreeMetadata}function zj(t){return{path:Sa(t.path),name:t.name,relativePath:t.relativePath}}function Wj(t){return!t.secondary}function Kj(t){return{item:t,score:0}}function Vj(t){return t.searchText}function Uj(t){return t.searchText}function Hj(t){return{item:t,score:0}}function Gj(t){return t.title||""}function qj(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Yj(t){return t.searchText}function Qj(t){return t.item}function Xj(t){return t.item}function Jj(t){return t.item}function Zj(t){return t.item}function e0(t){return t.item}function t0(t){return t.length?t[0].score:1/0}function s0(t,e){return t.score-e.score}function n0(t){return t.key}function r0(t){return s.jsxs(Br,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const _c=(t,e,n)=>Hn(Jr(t,e),n),o0=()=>{const t=Ze.c(73),{t:e}=St(),n=Ae(i0),r=Ae(a0),i=Ae(l0);let o,l,a,d,u,h,f,p,x,b,k,y;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const X=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[Hn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${Hn(Zi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${Hn(Zi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];a=bs,k=n,y=r,l=ys,x="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let Y;t[16]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(O,{name:"command",className:"h-5 w-5"}),t[16]=Y):Y=t[16];let I;t[17]!==e?(I=e("helpDialog.title"),t[17]=e,t[18]=I):I=t[18];let P;t[19]!==I?(P=s.jsxs(Bs,{className:"flex items-center gap-2",children:[Y,I]}),t[19]=I,t[20]=P):P=t[20];let A;t[21]!==e?(A=e("helpDialog.description"),t[21]=e,t[22]=A):A=t[22];let q;t[23]!==A?(q=s.jsx(Fs,{children:A}),t[23]=A,t[24]=q):q=t[24],t[25]!==P||t[26]!==q?(b=s.jsxs(Us,{children:[P,q]}),t[25]=P,t[26]=q,t[27]=b):b=t[27],o=gn,h="flex-1 min-h-0 mt-3",f="pr-1",p=!0,d="space-y-4",u=X.map(K=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(K.categoryKey)}),s.jsx("div",{className:"space-y-1",children:K.items.map(te=>{const ae=te.id?Sg(te.id):void 0,re=te.descriptionKey??(ae?.customizable?ae.settingsLabelKey:void 0);if(!re||te.id&&!Jr(te.id,i))return null;const he=te.id?_c(te.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(te.keys)?te.keys:te.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[te.icon&&s.jsx(O,{name:te.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(re)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(he)?he:[he]).map((ce,Te)=>s.jsxs(c.Fragment,{children:[Te>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:ce})]},`${ce}-${Te}`))})]},te.id||re)})})]},K.categoryKey)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=h,t[10]=f,t[11]=p,t[12]=x,t[13]=b,t[14]=k,t[15]=y}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],h=t[9],f=t[10],p=t[11],x=t[12],b=t[13],k=t[14],y=t[15];let m;t[28]!==d||t[29]!==u?(m=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=m):m=t[30];let g;t[31]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(O,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[31]=g):g=t[31];let j;t[32]!==e?(j=e("helpDialog.proTips.title"),t[32]=e,t[33]=j):j=t[33];let S;t[34]!==j?(S=s.jsx("p",{className:"font-medium mb-1",children:j}),t[34]=j,t[35]=S):S=t[35];let w;t[36]!==i||t[37]!==e?(w=e("helpDialog.proTips.commandPalette",{shortcut:_c("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[36]=i,t[37]=e,t[38]=w):w=t[38];let C;t[39]!==w?(C=s.jsxs("li",{children:["• ",w]}),t[39]=w,t[40]=C):C=t[40];let v;t[41]!==e?(v=e("helpDialog.proTips.recentSessions"),t[41]=e,t[42]=v):v=t[42];let R;t[43]!==v?(R=s.jsxs("li",{children:["• ",v]}),t[43]=v,t[44]=R):R=t[44];let T;t[45]!==e?(T=e("helpDialog.proTips.leaderSequences"),t[45]=e,t[46]=T):T=t[46];let D;t[47]!==T?(D=s.jsxs("li",{children:["• ",T]}),t[47]=T,t[48]=D):D=t[48];let F;t[49]!==C||t[50]!==R||t[51]!==D?(F=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[C,R,D]}),t[49]=C,t[50]=R,t[51]=D,t[52]=F):F=t[52];let B;t[53]!==S||t[54]!==F?(B=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[S,F]})]})}),t[53]=S,t[54]=F,t[55]=B):B=t[55];let E;t[56]!==o||t[57]!==h||t[58]!==B||t[59]!==f||t[60]!==p||t[61]!==m?(E=s.jsxs(o,{outerClassName:h,className:f,disableHorizontal:p,children:[m,B]}),t[56]=o,t[57]=h,t[58]=B,t[59]=f,t[60]=p,t[61]=m,t[62]=E):E=t[62];let $;t[63]!==l||t[64]!==E||t[65]!==x||t[66]!==b?($=s.jsxs(l,{className:x,children:[b,E]}),t[63]=l,t[64]=E,t[65]=x,t[66]=b,t[67]=$):$=t[67];let L;return t[68]!==a||t[69]!==$||t[70]!==k||t[71]!==y?(L=s.jsx(a,{open:k,onOpenChange:y,children:$}),t[68]=a,t[69]=$,t[70]=k,t[71]=y,t[72]=L):L=t[72],L};function i0(t){return t.isHelpDialogOpen}function a0(t){return t.setHelpDialogOpen}function l0(t){return t.shortcutOverrides}const c0=()=>{const t=Ze.c(32),{t:e}=St(),n=Ae(d0),r=Ae(u0),i=Ae(f0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Jn(i)).ok){ze.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}ze.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Bs,{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 h;t[9]!==u?(h=s.jsx(Fs,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Us,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let p;t[14]!==e?(p=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=p):p=t[15];let x;t[16]!==l||t[17]!==p?(x=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:p})}),t[16]=l,t[17]=p,t[18]=x):x=t[18];let b;t[19]!==i||t[20]!==e?(b=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=b):b=t[21];let k;t[22]!==b?(k=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:b}),t[22]=b,t[23]=k):k=t[23];let y;t[24]!==f||t[25]!==x||t[26]!==k?(y=s.jsxs(ys,{className:"max-w-2xl",children:[f,x,k]}),t[24]=f,t[25]=x,t[26]=k,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(bs,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function d0(t){return t.isOpenCodeStatusDialogOpen}function u0(t){return t.setOpenCodeStatusDialogOpen}function f0(t){return t.openCodeStatusText}const m0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const b=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(b)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const b=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",b),()=>window.removeEventListener("openchamber:sidebar-session-search",b)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let p,x;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(p=()=>{if(!a||!r||typeof document>"u")return;const b=k=>{l.current&&(l.current.contains(k.target)||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},x=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=p,e[15]=x):(p=e[14],x=e[15]),c.useEffect(p,x)},h0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(p0)),u=[];a.forEach(p=>{const x=d.get(p);x&&(u.push(x),d.delete(p))});const h=[],f=[];return l.forEach(p=>{d.has(p.id)&&(p.isArchivedBucket?f.push(p):h.push(p))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function p0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",$c="oc.sessions.groupOrder",zc="oc.sessions.groupCollapse",Wc=t=>{if(!t)return new Set;try{const e=Ja(Xn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},g0=t=>{if(!t)return new Map;try{const e=af(Xn(),Ja(Xn())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},x0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Mo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Wc(o.getItem(go)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Wc(o.getItem(zc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=()=>g0(o.getItem($c)),e[3]=p):p=e[3];const[x,b]=c.useState(p),k=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),g=c.useRef(null),j=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const pe=j.current;if(j.current=null,g.current=null,!pe)return;const{projects:Ne}=zt.getState(),U=Ne.map(Z=>({...Z,sidebarCollapsed:pe.has(Z.id)}));lr({projects:U}).catch(b0)},e[4]=n,e[5]=S):S=e[5];const w=S;let C;e[6]!==w||e[7]!==n?(C=pe=>{!globalThis.window||n||(j.current=pe,g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{w()},700))},e[6]=w,e[7]=n,e[8]=C):C=e[8];const v=C;let R,T;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=()=>()=>{globalThis.window&&g.current!==null&&window.clearTimeout(g.current),g.current=null,j.current=null},T=[],e[9]=R,e[10]=T):(R=e[9],T=e[10]),c.useEffect(R,T);let D,F;e[11]!==x?(F=()=>{if(m.current)try{o.setItem($c,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},D=[x,o],e[11]=x,e[12]=D,e[13]=F):(D=e[12],F=e[13]),c.useEffect(F,D);let B,E;e[14]!==h?(B=()=>{if(y.current)try{o.setItem(zc,JSON.stringify(Array.from(h)))}catch{}},E=[h,o],e[14]=h,e[15]=B,e[16]=E):(B=e[15],E=e[16]),c.useEffect(B,E);let $;e[17]!==r||e[18]!==v?($=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set(r.map(y0));try{o.setItem(go,JSON.stringify(Array.from(pe)))}catch{}return v(pe),pe})},e[17]=r,e[18]=v,e[19]=$):$=e[19];const L=$;let X;e[20]!==v?(X=()=>{k.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const pe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return v(pe),pe})},e[20]=v,e[21]=X):X=e[21];const Y=X;let I;e[22]!==v?(I=pe=>{k.current=Date.now()+150,d(Ne=>{const U=new Set(Ne);U.has(pe)?U.delete(pe):U.add(pe);try{o.setItem(go,JSON.stringify(Array.from(U)))}catch{}return v(U),U})},e[22]=v,e[23]=I):I=e[23];const P=I;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=pe=>{y.current=!0,f(Ne=>{const U=new Set(Ne);return U.has(pe)?U.delete(pe):U.add(pe),U})},e[24]=A):A=e[24];const q=A;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=pe=>{m.current=!0,b(pe)},e[25]=K):K=e[25];const te=K,{getOrderedGroups:ae}=h0(x);let re;e[26]!==h||e[27]!==a||e[28]!==x?(re={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:x},e[26]=h,e[27]=a,e[28]=x,e[29]=re):re=e[29];const he=re;let ce;e[30]!==L||e[31]!==Y||e[32]!==ae||e[33]!==v||e[34]!==P?(ce={setCollapsedProjects:d,toggleProject:P,collapseAllProjects:L,expandAllProjects:Y,scheduleCollapsedProjectsPersist:v,setCollapsedGroups:f,toggleGroup:q,setGroupOrderByProject:te,getOrderedGroups:ae},e[30]=L,e[31]=Y,e[32]=ae,e[33]=v,e[34]=P,e[35]=ce):ce=e[35];const Te=ce;let ve;return e[36]!==Te||e[37]!==he?(ve={state:he,actions:Te},e[36]=Te,e[37]=he,e[38]=ve):ve=e[38],ve};function b0(){}function y0(t){return t.id}const w0=5*6e4,v0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=nn(),u=pn(S0);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(C=>{ea(()=>u(C.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let p,x;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(p=()=>{if(!a)return;const C=new Map;n.forEach(v=>{C.set(v.id,i.get(v.normalizedPath)?.isGitRepo??null)}),o(C)},x=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=p,e[12]=x):(p=e[11],x=e[12]),c.useEffect(p,x);let b;if(e[13]!==i||e[14]!==n){let C;e[16]!==i?(C=v=>{const R=i.get(v.normalizedPath)?.branch??"";return`${v.id}:${R}`},e[16]=i,e[17]=C):C=e[17],b=n.map(C).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const k=b;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let g;e[19]===Symbol.for("react.memo_cache_sentinel")?(g=new Map,e[19]=g):g=e[19];const j=c.useRef(g);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let C=!1;const v=setTimeout(()=>{(async()=>{const T=new Set(n.map(j0));for(const L of m.current.keys())T.has(L)||(m.current.delete(L),j.current.delete(L));const D=Date.now(),F=n.filter(L=>{const X=i.get(L.normalizedPath);if(X?.isGitRepo===!1)return m.current.delete(L.id),j.current.delete(L.id),!1;if(X?.isGitRepo!==!0||X.branch===null)return!1;const Y=X.branch.trim(),I=`${L.normalizedPath}\0${Y}`,P=m.current.get(L.id);if(P===I){const A=j.current.get(L.id);return A&&(A.at=D),!1}return!(P!==void 0&&D-(j.current.get(L.id)?.at??0)<w0)});if(F.length===0)return;const B=await jg(F,2,async L=>{const X=i.get(L.normalizedPath)?.branch?.trim()??"",Y=`${L.normalizedPath}\0${X}`,I=await ea(()=>$a(L.normalizedPath,X?{knownBranch:X}:void 0)).catch(k0);return{id:L.id,inputKey:Y,branch:I}});if(C)return;const E=B.filter(C0);if(E.length===0)return;const $=Date.now();l(L=>{const X=new Map(L);return E.forEach(Y=>{const{id:I,branch:P}=Y;P&&X.set(I,P)}),X}),E.forEach(L=>{const{id:X,inputKey:Y,branch:I}=L;m.current.set(X,Y),I&&j.current.set(X,{branch:I,at:$})})})()},150);return()=>{C=!0,clearTimeout(v)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let w;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==k||e[29]!==l?(w=[a,n,k,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=k,e[29]=l,e[30]=w):w=e[30],c.useEffect(S,w)};function S0(t){return t.ensureStatus}function j0(t){return t.id}function k0(){return null}function C0(t){return t.branch}const N0=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Wh,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ys,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(gn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(bs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function A0(t){const e=Ze.c(199),{t:n}=St(),r=Ou(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:p,headerActionButtonClass:x,isSessionSearchOpen:b,setIsSessionSearchOpen:k,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:g,hasSessionSearchQuery:j,searchMatchCount:S,collapseAllProjects:w,expandAllProjects:C}=t,v=ss(z0),R=ss($0),T=as(_0),D=as(L0),F=as(F0),B=as(B0),E=as(O0),$=as(M0),L=as(R0),X=as(E0),Y=as(T0),I=as(I0),P=o&&Y==="single",A=o&&L==="timeline";if(i)return null;let q;e[0]!==x?(q=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=x,e[1]=q):q=e[1];let K;e[2]!==n?(K=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=K):K=e[3];let te;e[4]!==p?(te=s.jsx(O,{name:"folder-add",className:p}),e[4]=p,e[5]=te):te=e[5];let ae;e[6]!==a||e[7]!==q||e[8]!==K||e[9]!==te?(ae=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:q,"aria-label":K,children:te})}),e[6]=a,e[7]=q,e[8]=K,e[9]=te,e[10]=ae):ae=e[10];let re;e[11]!==n?(re=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=re):re=e[12];let he;e[13]!==re?(he=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:re})}),e[13]=re,e[14]=he):he=e[14];let ce;e[15]!==ae||e[16]!==he?(ce=s.jsxs(bt,{children:[ae,he]}),e[15]=ae,e[16]=he,e[17]=ce):ce=e[17];let Te;e[18]!==x?(Te=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=x,e[19]=Te):Te=e[19];let ve;e[20]!==n?(ve=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=ve):ve=e[21];let pe;e[22]!==p?(pe=s.jsx(O,{name:"calendar-schedule",className:p}),e[22]=p,e[23]=pe):pe=e[23];let Ne;e[24]!==d||e[25]!==Te||e[26]!==ve||e[27]!==pe?(Ne=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:Te,"aria-label":ve,children:pe})}),e[24]=d,e[25]=Te,e[26]=ve,e[27]=pe,e[28]=Ne):Ne=e[28];let U;e[29]!==n?(U=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=U):U=e[30];let Z;e[31]!==U?(Z=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:U})}),e[31]=U,e[32]=Z):Z=e[32];let de;e[33]!==Ne||e[34]!==Z?(de=s.jsxs(bt,{children:[Ne,Z]}),e[33]=Ne,e[34]=Z,e[35]=de):de=e[35];let ye;e[36]!==x?(ye=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=x,e[37]=ye):ye=e[37];let H;e[38]!==n?(H=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=H):H=e[39];const je=!h;let Ee;e[40]!==p?(Ee=s.jsx(Ng,{className:p}),e[40]=p,e[41]=Ee):Ee=e[41];let ge;e[42]!==u||e[43]!==ye||e[44]!==H||e[45]!==je||e[46]!==Ee?(ge=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:ye,"aria-label":H,disabled:je,children:Ee})}),e[42]=u,e[43]=ye,e[44]=H,e[45]=je,e[46]=Ee,e[47]=ge):ge=e[47];let ne;e[48]!==n?(ne=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ne):ne=e[49];let be;e[50]!==ne?(be=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ne})}),e[50]=ne,e[51]=be):be=e[51];let G;e[52]!==ge||e[53]!==be?(G=s.jsxs(bt,{children:[ge,be]}),e[52]=ge,e[53]=be,e[54]=G):G=e[54];let z;e[55]!==x?(z=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=x,e[56]=z):z=e[56];let J;e[57]!==n?(J=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=J):J=e[58];let ue;e[59]!==p?(ue=s.jsx(O,{name:"archive",className:p}),e[59]=p,e[60]=ue):ue=e[60];let le;e[61]!==f||e[62]!==z||e[63]!==J||e[64]!==ue?(le=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:z,"aria-label":J,children:ue})}),e[61]=f,e[62]=z,e[63]=J,e[64]=ue,e[65]=le):le=e[65];let W;e[66]!==n?(W=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=W):W=e[67];let M;e[68]!==W?(M=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[68]=W,e[69]=M):M=e[69];let _;e[70]!==le||e[71]!==M?(_=s.jsxs(bt,{children:[le,M]}),e[70]=le,e[71]=M,e[72]=_):_=e[72];let ee;e[73]!==r||e[74]!==p||e[75]!==n?(ee=r.length>0&&s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsx(ut,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(O,{name:"apps",className:p})})}),s.jsxs(Ds,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(D0)]})]}),e[73]=r,e[74]=p,e[75]=n,e[76]=ee):ee=e[76];let oe;e[77]!==de||e[78]!==G||e[79]!==_||e[80]!==ee||e[81]!==ce?(oe=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ce,de,G,_,ee]}),e[77]=de,e[78]=G,e[79]=_,e[80]=ee,e[81]=ce,e[82]=oe):oe=e[82];let fe;e[83]!==k?(fe=()=>k(P0),e[83]=k,e[84]=fe):fe=e[84];let ie;e[85]!==x?(ie=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=x,e[86]=ie):ie=e[86];let Le;e[87]!==n?(Le=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Le):Le=e[88];let $e;e[89]!==p?($e=s.jsx(O,{name:"search",className:p}),e[89]=p,e[90]=$e):$e=e[90];let Pe;e[91]!==b||e[92]!==fe||e[93]!==ie||e[94]!==Le||e[95]!==$e?(Pe=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:fe,className:ie,"aria-label":Le,"aria-expanded":b,children:$e})}),e[91]=b,e[92]=fe,e[93]=ie,e[94]=Le,e[95]=$e,e[96]=Pe):Pe=e[96];let Oe;e[97]!==n?(Oe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=Oe):Oe=e[98];let Q;e[99]!==Oe?(Q=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[99]=Oe,e[100]=Q):Q=e[100];let Ce;e[101]!==Pe||e[102]!==Q?(Ce=s.jsxs(bt,{children:[Pe,Q]}),e[101]=Pe,e[102]=Q,e[103]=Ce):Ce=e[103];const Se=v&&"bg-interactive-hover text-primary";let Ke;e[104]!==x||e[105]!==Se?(Ke=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent",Se),e[104]=x,e[105]=Se,e[106]=Ke):Ke=e[106];let et;e[107]!==v||e[108]!==n?(et=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=v,e[108]=n,e[109]=et):et=e[109];let it;e[110]!==p?(it=s.jsx(O,{name:"checkbox-multiple",className:p}),e[110]=p,e[111]=it):it=e[111];let rt;e[112]!==v||e[113]!==Ke||e[114]!==et||e[115]!==it||e[116]!==R?(rt=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:R,className:Ke,"aria-label":et,"aria-pressed":v,children:it})}),e[112]=v,e[113]=Ke,e[114]=et,e[115]=it,e[116]=R,e[117]=rt):rt=e[117];let pt;e[118]!==v||e[119]!==n?(pt=n(v?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=v,e[119]=n,e[120]=pt):pt=e[120];let ht;e[121]!==pt?(ht=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:pt})}),e[121]=pt,e[122]=ht):ht=e[122];let tt;e[123]!==rt||e[124]!==ht?(tt=s.jsxs(bt,{children:[rt,ht]}),e[123]=rt,e[124]=ht,e[125]=tt):tt=e[125];let At;e[126]!==x?(At=Me(x,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=x,e[127]=At):At=e[127];let jt;e[128]!==n?(jt=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=jt):jt=e[129];let we;e[130]!==p?(we=s.jsx(O,{name:"equalizer-2",className:p}),e[130]=p,e[131]=we):we=e[131];let Xe;e[132]!==At||e[133]!==jt||e[134]!==we?(Xe=s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:At,"aria-label":jt,children:we})})}),e[132]=At,e[133]=jt,e[134]=we,e[135]=Xe):Xe=e[135];let mt;e[136]!==n?(mt=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=mt):mt=e[137];let qe;e[138]!==mt?(qe=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:mt})}),e[138]=mt,e[139]=qe):qe=e[139];let ft;e[140]!==Xe||e[141]!==qe?(ft=s.jsxs(bt,{children:[Xe,qe]}),e[140]=Xe,e[141]=qe,e[142]=ft):ft=e[142];let se;e[143]!==X||e[144]!==o||e[145]!==L||e[146]!==n||e[147]!==A?(se=o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.viewMode.label")}),[["projects","sessions.sidebar.header.viewMode.projects"],["timeline","sessions.sidebar.header.viewMode.timeline"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{X(ot),lr({sidebarViewMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),L===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),A?null:s.jsx(gs,{})]}):null,e[143]=X,e[144]=o,e[145]=L,e[146]=n,e[147]=A,e[148]=se):se=e[148];let me;e[149]!==Y||e[150]!==F||e[151]!==I||e[152]!==B||e[153]!==$||e[154]!==o||e[155]!==n||e[156]!==A||e[157]!==E?(me=A?null:s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortProjects")}),[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{B(ot),lr({sidebarProjectSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),F===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{}),o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.sortWorktrees")}),[["recent","sessions.sidebar.header.worktreeSort.recent"],["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{$(ot),lr({sidebarWorktreeSortOrder:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),E===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(cr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Re=>{const[ot,vt]=Re;return s.jsxs(_t,{onClick:()=>{I(ot),lr({sidebarProjectDisplayMode:ot})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(vt)}),Y===ot?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]},ot)}),s.jsx(gs,{})]}):null]}),e[149]=Y,e[150]=F,e[151]=I,e[152]=B,e[153]=$,e[154]=o,e[155]=n,e[156]=A,e[157]=E,e[158]=me):me=e[158];let Ie;e[159]!==P||e[160]!==l||e[161]!==T||e[162]!==n||e[163]!==A||e[164]!==D?(Ie=!A&&l&&!P?s.jsxs(_t,{onClick:()=>{D(),lr({sidebarShowRecentSection:!T})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),T?s.jsx(O,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[159]=P,e[160]=l,e[161]=T,e[162]=n,e[163]=A,e[164]=D,e[165]=Ie):Ie=e[165];let We;e[166]!==w||e[167]!==C||e[168]!==P||e[169]!==n||e[170]!==A?(We=!A&&!P?s.jsxs(s.Fragment,{children:[s.jsx(gs,{}),s.jsxs(_t,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(O,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(_t,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(O,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[166]=w,e[167]=C,e[168]=P,e[169]=n,e[170]=A,e[171]=We):We=e[171];let V;e[172]!==se||e[173]!==me||e[174]!==Ie||e[175]!==We?(V=s.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[se,me,Ie,We]}),e[172]=se,e[173]=me,e[174]=Ie,e[175]=We,e[176]=V):V=e[176];let Fe;e[177]!==ft||e[178]!==V?(Fe=s.jsxs(Is,{children:[ft,V]}),e[177]=ft,e[178]=V,e[179]=Fe):Fe=e[179];let Ye;e[180]!==Ce||e[181]!==tt||e[182]!==Fe?(Ye=s.jsxs("div",{className:"flex items-center gap-1.5",children:[Ce,tt,Fe]}),e[180]=Ce,e[181]=tt,e[182]=Fe,e[183]=Ye):Ye=e[183];let Qe;e[184]!==oe||e[185]!==Ye?(Qe=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[oe,Ye]}),e[184]=oe,e[185]=Ye,e[186]=Qe):Qe=e[186];let xe;e[187]!==j||e[188]!==b||e[189]!==S||e[190]!==y||e[191]!==m||e[192]!==k||e[193]!==g||e[194]!==n?(xe=b?s.jsx("div",{className:"pb-1",children:s.jsx(Zd,{inputRef:y,value:m,onSearch:g,onClose:()=>k(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:j?S===1?n("sessions.sidebar.header.search.matchCountSingle",{count:S}):n("sessions.sidebar.header.search.matchCountPlural",{count:S}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[187]=j,e[188]=b,e[189]=S,e[190]=y,e[191]=m,e[192]=k,e[193]=g,e[194]=n,e[195]=xe):xe=e[195];let st;return e[196]!==Qe||e[197]!==xe?(st=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[Qe,xe]})}),e[196]=Qe,e[197]=xe,e[198]=st):st=e[198],st}function P0(t){return!t}function D0(t){return s.jsxs(_t,{onSelect:()=>Ae.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:Cg(t.icon),iconSrc:kg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function I0(t){return t.setProjectDisplayMode}function T0(t){return t.projectDisplayMode}function E0(t){return t.setSidebarViewMode}function R0(t){return t.sidebarViewMode}function M0(t){return t.setWorktreeSortOrder}function O0(t){return t.worktreeSortOrder}function B0(t){return t.setProjectSortOrder}function F0(t){return t.projectSortOrder}function L0(t){return t.toggleRecentSection}function _0(t){return t.showRecentSection}function $0(t){return t.toggleMode}function z0(t){return t.enabled}const xo="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function W0(t){const e=Ze.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,h=d===void 0?!0:d,{t:f}=St();if(!u&&!h)return null;let p;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(p=u?s.jsxs(s.Fragment,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:xo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(O,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:xo,"aria-label":f("usageStats.openAction"),children:s.jsx(O,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:xo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(O,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:xo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(O,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(wt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=r,e[4]=u,e[5]=f,e[6]=p):p=e[6];let x;e[7]!==l||e[8]!==h||e[9]!==f?(x=h?s.jsx(ut,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=h,e[9]=f,e[10]=x):x=e[10];let b;return e[11]!==p||e[12]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[p,x]}),e[11]=p,e[12]=x,e[13]=b):b=e[13],b}const K0=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},V0=()=>{const t=Ze.c(4),{terminal:e}=nn(),n=Rt(K0);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=U0,l=H0;if(n)return Vi(e,"",l,o);let a=G0;return a=Vi(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function U0(t){const e=Rt.getState(),n=Kh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function H0(){return new Map(Rt.getState().actionMutationRevisions)}function G0(){}const q0=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,p=r===void 0?!0:r;let x,b;e[0]!==f||e[1]!==h||e[2]!==p||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(x=()=>{!p||o||!l||a||n.forEach(k=>{if(d.has(k.normalizedPath))return;const y=Bu(k.normalizedPath),m=i.archivedSessionsByProject.get(k.id)??[],g=u[y]??[],j=new Map(g.map(Y0));m.forEach(S=>{const w=Ag(S,k.normalizedPath),C=w.toLowerCase();let v=j.get(C);v||(v=h(y,w),j.set(C,v)),v.sessionIds.includes(S.id)||f(y,v.id,S.id)})})},b=[n,p,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=p,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=x,e[11]=b):(x=e[10],b=e[11]),c.useEffect(x,b)};function Y0(t){return[t.name.toLowerCase(),t]}function Q0({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const X0=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:p}=t;let x,b;if(e[0]!==n){b=new Map,x=new Map;const C=(v,R,T,D)=>{b.has(v)||b.set(v,new Map);const F=b.get(v);D.forEach(B=>{const E=xt(B.worktree?.path??B.session.directory??T??R);F.set(B.session.id,{directory:E}),x.has(v)||x.set(v,{id:B.session.id,directory:E}),B.children.length>0&&C(v,R,E,B.children)})};n.forEach(v=>{v.groups.forEach(R=>{C(v.project.id,v.project.normalizedPath,R.directory,R.sessions)})}),e[0]=n,e[1]=x,e[2]=b}else x=e[1],b=e[2];let k;e[3]!==x||e[4]!==b?(k={metaByProject:b,firstSessionByProject:x},e[3]=x,e[4]=b,e[5]=k):k=e[5];const y=k,m=c.useRef(null);let g,j;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==p?(g=()=>{if(!r||u||Ae.getState().isNewWorktreeDialogOpen||m.current===r)return;const C=n.find(D=>D.project.id===r);if(!C)return;const v=y.metaByProject.get(r);if(l&&v&&v.has(l)){m.current=r,o(D=>{if(D.get(r)===l)return D;const F=new Map(D);return F.set(r,l),F});return}const R=Q0({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:v,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(R.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,R.kind==="open-draft"){h&&p(!1),f({selectedProjectId:C.project.id,directoryOverride:C.project.normalizedPath});return}if(R.kind!=="select-session")return;const T=v?.get(R.sessionId)?.directory??null;d(R.sessionId,T)},j=[r,i,l,a,d,u,h,f,n,y,p,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=p,e[18]=g,e[19]=j):(g=e[18],j=e[19]),c.useLayoutEffect(g,j);let S,w;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(S=()=>{if(!r||!l)return;const C=y.metaByProject.get(r);!C||!C.has(l)||o(v=>{if(v.get(r)===l)return v;const R=new Map(v);return R.set(r,l),R})},w=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=S,e[25]=w):(S=e[24],w=e[25]),c.useEffect(S,w)},J0=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=nt(Z0),a=nt(e2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,p]=c.useState(h);let x;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(x={...n,activeSessionByProject:f,setActiveSessionByProject:p,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=x):x=e[15],X0(x);let b,k;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},k=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=k):(b=e[18],k=e[19]),c.useEffect(b,k),null};function Z0(t){return t.currentSessionId}function e2(t){return!!t.newSessionDraft?.open}const t2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},_n=(t,e)=>`${t}\0${e}`,Kn=(t,e)=>t??Ha(e)??xt(e??null),qr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??xt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},al=t=>t.startsWith("__archived__:"),s2=(t,e)=>t.map(n=>{const r=xt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
+ `),n2=[],r2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:p,buildGroupSearchText:x,foldersMap:b,standaloneGroups:k}=t,y=c.useRef(new Map),m=c.useMemo(()=>{const T=y.current,D=new Map;let F=0,B=0;const E=(L,X)=>L.length===X.length&&L.every((Y,I)=>Y===X[I]),$=e.map(L=>{const X=n(L.id),Y=r(L.id),I=i.get(L.normalizedPath)??n2,P=o.has(L.id)?!!o.get(L.id):d,A=l.get(L.id)??null,q=s2(I,a),K=T.get(L.id);if(K&&K.project===L&&E(K.activeSessions,X)&&E(K.archivedSessions,Y)&&K.availableWorktrees===I&&K.rootBranch===A&&K.worktreeBranchesKey===q&&K.isRepo===P&&K.buildGroupedSessions===u)return F+=1,D.set(L.id,K),K.section;if(B+=1,K){const he=K.project!==L?"project":E(K.activeSessions,X)?E(K.archivedSessions,Y)?K.availableWorktrees!==I?"worktrees":K.rootBranch!==A?"branch":K.worktreeBranchesKey!==q?"worktreeBranches":K.isRepo!==P?"repo":"builder":"archived":"sessions";js(`ui.sidebar.project_section.rebuilt_reason.${he}`)}const te=Fu([...X,...Y]),ae=u(te,L.normalizedPath,I,A,P),re={project:L,groups:ae};return D.set(L.id,{project:L,activeSessions:X,archivedSessions:Y,availableWorktrees:I,rootBranch:A,worktreeBranchesKey:q,isRepo:P,buildGroupedSessions:u,section:re}),re});return y.current=D,F>0&&js("ui.sidebar.project_section.reused",F),B>0&&js("ui.sidebar.project_section.rebuilt",B),$},[e,n,r,i,o,d,u,l,a]),g=c.useMemo(()=>m,[m]),j=c.useMemo(()=>{const T=new WeakMap;if(!h)return T;const D=f.trim().toLowerCase(),F=D.startsWith("ses_"),B=$=>$.reduce((L,X)=>L+(!F||X.session.id.toLowerCase()===D?1:0)+B(X.children),0),E=$=>{const L=p($.sessions,f),X=B(L),Y=!F&&Bo([x($)],f),I=qr($).flatMap(({scopeKey:A})=>b[A]??[]),P=F?0:I.filter(A=>Bo([A.name],f)).length;T.set($,{filteredNodes:L,matchedSessionCount:X,folderNameMatchCount:P,groupMatches:Y,hasMatch:Y||X>0||P>0})};return g.forEach($=>{$.groups.forEach(E)}),k.forEach(E),T},[h,g,k,p,f,x,b]),S=c.useMemo(()=>h?g.map(T=>({...T,groups:T.groups.filter(D=>j.get(D)?.hasMatch===!0)})).filter(T=>T.groups.length>0):g,[h,g,j]),w=h?S:g,C=c.useRef(new WeakMap),v=c.useMemo(()=>{const T=C.current;return w.map(D=>{const F=T.get(D);if(F&&F.query===f)return F.section;const B=D.groups.filter(P=>!P.isArchivedBucket),E=D.groups.filter(P=>P.isArchivedBucket),$=B.flatMap(P=>h?j.get(P)?.filteredNodes??[]:P.sessions),L=B.map(P=>({scopeKey:P.folderScopeKey??xt(P.directory??null),directory:P.directory??null})).filter(P=>!!P.scopeKey),X=B.find(P=>P.isMain)??null,Y={id:"flat",label:X?.label??"",branch:X?.branch??null,description:X?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:X?.directory??D.project.normalizedPath,folderScopeKey:X?.folderScopeKey??D.project.normalizedPath,folderScopes:L,sessions:$};if(h){const P=B.map(A=>j.get(A)).filter(A=>!!A);j.set(Y,{filteredNodes:$,matchedSessionCount:P.reduce((A,q)=>A+q.matchedSessionCount,0),folderNameMatchCount:P.reduce((A,q)=>A+q.folderNameMatchCount,0),groupMatches:P.some(A=>A.groupMatches),hasMatch:P.some(A=>A.hasMatch)})}const I={project:D.project,groups:[Y,...E]};return T.set(D,{query:f,section:I}),I})},[j,h,f,w]),R=c.useMemo(()=>{if(!h)return 0;const T=(F,B)=>{const E=j.get(B);if(!E)return F;const $=E.folderNameMatchCount+(E.groupMatches?1:0);return F+E.matchedSessionCount+$},D=w.reduce((F,B)=>B.groups.reduce(T,F),0);return k.reduce(T,D)},[h,w,k,j]);return{projectSections:m,visibleProjectSections:g,groupSearchDataByGroup:j,searchableProjectSections:S,sectionsForRender:w,flatSectionsForRender:v,searchMatchCount:R}},o2=180,Kc=150,i2=2,a2=8,Vc=[-1,1],Bi=t=>`${t.directory}
880
+ ${t.sessionId}`,l2=t=>t?.directory?.trim()||null,c2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>kn(),[]),h=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(x=>window.clearTimeout(x)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<i2&&l.current.length>0;){const x=l.current.shift();if(!x)break;if(x.generation!==d.current||nt.getState().currentSessionId===x.sessionId||ta(x.sessionId,x.directory).renderable)continue;const k=Bi(x);a.current.add(k),i({directory:x.directory,sessionID:x.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(k),f()})}},[t,u,i]),p=c.useCallback(x=>{const b=x?.id,k=l2(x);if(!t||u||!b||!k||b===e)return;const y={sessionId:b,directory:k,generation:d.current},m=Bi(y);if(ta(b,k).renderable||a.current.has(m)||l.current.some(S=>Bi(S)===m))return;const g=o.current.get(m);g!==void 0&&window.clearTimeout(g);const j=window.setTimeout(()=>{if(o.current.delete(m),y.generation!==d.current)return;const S=l.current;S.length>=a2&&S.shift(),S.push(y),f()},o2);o.current.set(m,j)},[e,t,u,f]);c.useEffect(()=>{h()},[h,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const x=window.setTimeout(()=>{const b=n.findIndex(k=>k.id===e);if(!(b<0))for(const k of Vc)p(n[b+k])},Kc);return()=>window.clearTimeout(x)},[e,t,u,p,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const x=window.setTimeout(()=>{const b=r.findIndex(k=>k.id===e);if(!(b<0))for(const k of Vc)p(r[b+k])},Kc);return()=>window.clearTimeout(x)},[e,t,u,r,p]),c.useEffect(()=>h,[h])},d2=t=>{const e=Ze.c(3),n=nt(u2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],c2(r),null};function u2(t){return t.currentSessionId}const f2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},ll=t=>{const e=Ze.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=f2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=k=>{if(!o)return null;for(const y of d.active){const m=k.statusById.get(y)?.status.type;if(m==="busy"||m==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const h=Zo(u);let f;e[9]!==o||e[10]!==d.unread?(f=k=>{if(!o)return null;for(const y of d.unread)if((k.index.session.unseenCount[y]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const p=Ga(f);let x;return e[12]!==o||e[13]!==d.active?(x=k=>{if(!o)return null;let y=null;for(const m of d.active){const g=k.bySession.get(m);if(g){if(g.permissions.length>0)return"permission";g.forms.length>0&&(y="form")}}return y},e[12]=o,e[13]=d.active,e[14]=x):x=e[14],qa(x)??h??p};function Gf(t){const e=Ze.c(19),{state:n,className:r}=t,{t:i}=St();if(n==="permission"||n==="form"){let u;e[0]!==n||e[1]!==i?(u=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=u):u=e[2];const h=u,f=n==="permission"?"text-destructive":"text-status-info";let p;e[3]!==r||e[4]!==f?(p=Me("inline-flex shrink-0 items-center",f,r),e[3]=r,e[4]=f,e[5]=p):p=e[5];const x=n==="permission"?"shield":"question";let b;e[6]!==x?(b=s.jsx(O,{name:x,className:"h-3 w-3"}),e[6]=x,e[7]=b):b=e[7];let k;return e[8]!==h||e[9]!==p||e[10]!==b?(k=s.jsx("span",{className:p,"aria-label":h,title:h,children:b}),e[8]=h,e[9]=p,e[10]=b,e[11]=k):k=e[11],k}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"running":"unread";let d;return e[15]!==r||e[16]!==l||e[17]!==a?(d=s.jsx(Oa,{state:a,label:l,className:r}),e[15]=r,e[16]=l,e[17]=a,e[18]=d):d=e[18],d}const m2=t=>{const e=Ze.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=ll(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx(Gf,{state:o}),e[3]=o,e[4]=l):l=e[4],l},h2=t=>{const e=Ze.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,children:f,renderBody:p,mobileVariant:x,alwaysShowActions:b,isRenaming:k,renameDraft:y,onRenameDraftChange:m,onRenameSave:g,onRenameCancel:j,droppableRef:S,isDropTarget:w,onNewSession:C,depth:v,hideActions:R,archivedBucket:T}=t,D=a===void 0?null:a,F=p===void 0?!0:p,E=b===void 0?x===void 0?!1:x:b,$=k===void 0?!1:k,L=y===void 0?"":y,X=w===void 0?!1:w,Y=R===void 0?!1:R,I=T===void 0?!1:T,{t:P}=St(),[A,q]=c.useState(!1),[K,te]=c.useState(""),ae=c.useRef(null),re=$||A,he=$?L:K;let ce;e[0]!==n.name?(ce=()=>{te(n.name),q(!0)},e[0]=n.name,e[1]=ce):ce=e[1];const Te=ce;let ve;e[2]!==he||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==g?(ve=()=>{const Pe=he.trim();Pe&&Pe!==n.name&&u(Pe),$&&g&&g(),q(!1),te("")},e[2]=he,e[3]=n.name,e[4]=$,e[5]=u,e[6]=g,e[7]=ve):ve=e[7];const pe=ve;let Ne;e[8]!==$||e[9]!==j?(Ne=()=>{$&&j&&j(),q(!1),te("")},e[8]=$,e[9]=j,e[10]=Ne):Ne=e[10];const U=Ne;let Z;e[11]!==$||e[12]!==m?(Z=Pe=>{$&&m?m(Pe):te(Pe)},e[11]=$,e[12]=m,e[13]=Z):Z=e[13];const de=Z;let ye,H;e[14]!==$?(ye=()=>{if(!$)return;const Pe=()=>{const Ce=ae.current;Ce&&(Ce.focus(),Ce.select())},Oe=requestAnimationFrame(Pe),Q=window.setTimeout(Pe,0);return()=>{cancelAnimationFrame(Oe),window.clearTimeout(Q)}},H=[$],e[14]=$,e[15]=ye,e[16]=H):(ye=e[15],H=e[16]),c.useEffect(ye,H);const je=l?"folder":"folder-open",Ee=X&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ge;e[17]!==Ee?(ge=Me("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Ee),e[17]=Ee,e[18]=ge):ge=e[18];let ne;e[19]!==d||e[20]!==re?(ne=re?void 0:Pe=>{Pe.currentTarget.blur(),d()},e[19]=d,e[20]=re,e[21]=ne):ne=e[21];const be=re?void 0:"button",G=re?void 0:0;let z;e[22]!==d||e[23]!==re?(z=re?void 0:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),d())},e[22]=d,e[23]=re,e[24]=z):z=e[24];let J;e[25]!==n.name||e[26]!==l||e[27]!==P?(J=l?P("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):P("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=P,e[28]=J):J=e[28];const ue=I?E?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":E?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==ue?(le=Me("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ue),e[29]=ue,e[30]=le):le=e[30];const W=X?"text-primary":"text-muted-foreground";let M;e[31]!==W?(M=Me("h-3.5 w-3.5 flex-shrink-0",W),e[31]=W,e[32]=M):M=e[32];let _;e[33]!==je||e[34]!==M?(_=s.jsx(O,{name:je,className:M}),e[33]=je,e[34]=M,e[35]=_):_=e[35];let ee;e[36]!==D||e[37]!==r||e[38]!==he||e[39]!==n.name||e[40]!==U||e[41]!==de||e[42]!==pe||e[43]!==l||e[44]!==X||e[45]!==re||e[46]!==i||e[47]!==P?(ee=re?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:p2,onMouseDown:g2,onSubmit:Pe=>{Pe.preventDefault(),pe()},children:[s.jsx("input",{ref:ae,value:he,onChange:Pe=>de(Pe.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:P("sessions.sidebar.folderItem.namePlaceholder"),onClick:x2,onPointerDown:b2,onMouseDown:y2,onKeyDown:Pe=>{if(Pe.key==="Escape"){Pe.stopPropagation(),U();return}(Pe.key===" "||Pe.key==="Enter")&&Pe.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:w2,onPointerDown:v2,onMouseDown:S2,children:s.jsx(O,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),U()},onPointerDown:j2,onMouseDown:k2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("span",{className:Me("typography-ui-label font-semibold truncate",X?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),D?s.jsx(Gf,{state:D}):null,l?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=D,e[37]=r,e[38]=he,e[39]=n.name,e[40]=U,e[41]=de,e[42]=pe,e[43]=l,e[44]=X,e[45]=re,e[46]=i,e[47]=P,e[48]=ee):ee=e[48];let oe;e[49]!==le||e[50]!==_||e[51]!==ee?(oe=s.jsxs("div",{className:le,children:[_,ee]}),e[49]=le,e[50]=_,e[51]=ee,e[52]=oe):oe=e[52];let fe;e[53]!==E||e[54]!==I||e[55]!==n.name||e[56]!==Te||e[57]!==Y||e[58]!==h||e[59]!==C||e[60]!==re||e[61]!==P?(fe=!re&&(!Y||I)?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",E?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!I&&C?s.jsx("button",{type:"button",onClick:Pe=>{Pe.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":P("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:P("sessions.sidebar.project.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),Te()},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":P("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(O,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:Pe=>{Pe.stopPropagation(),h()},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?P("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):P("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=E,e[54]=I,e[55]=n.name,e[56]=Te,e[57]=Y,e[58]=h,e[59]=C,e[60]=re,e[61]=P,e[62]=fe):fe=e[62];let ie;e[63]!==S||e[64]!==ge||e[65]!==ne||e[66]!==be||e[67]!==G||e[68]!==z||e[69]!==J||e[70]!==oe||e[71]!==fe?(ie=s.jsxs("div",{ref:S,className:ge,onClick:ne,role:be,tabIndex:G,onKeyDown:z,"aria-label":J,children:[oe,fe]}),e[63]=S,e[64]=ge,e[65]=ne,e[66]=be,e[67]=G,e[68]=z,e[69]=J,e[70]=oe,e[71]=fe,e[72]=ie):ie=e[72];let Le;e[73]!==f||e[74]!==l||e[75]!==F||e[76]!==i||e[77]!==o||e[78]!==P?(Le=!l&&F?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:P("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=F,e[76]=i,e[77]=o,e[78]=P,e[79]=Le):Le=e[79];let $e;return e[80]!==ie||e[81]!==Le?($e=s.jsxs("div",{className:"oc-folder",children:[ie,Le]}),e[80]=ie,e[81]=Le,e[82]=$e):$e=e[82],$e},qf=c.memo(h2);function p2(t){return t.stopPropagation()}function g2(t){return t.stopPropagation()}function x2(t){return t.stopPropagation()}function b2(t){return t.stopPropagation()}function y2(t){return t.stopPropagation()}function w2(t){return t.stopPropagation()}function v2(t){return t.stopPropagation()}function S2(t){return t.stopPropagation()}function j2(t){return t.stopPropagation()}function k2(t){return t.stopPropagation()}function C2(t){const e=Ze.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=ll(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(qf,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const Yr=t=>{const e=Ze.c(13),{directory:n,className:r}=t,{t:i}=St();let o;e[0]!==n?(o=dh(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=k=>k.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Rt(a)?.tabs.some(Kd))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let p;e[6]!==r?(p=Me("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=p):p=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(O,{name:"pulse",className:"size-3.5"}),e[8]=x):x=e[8];let b;return e[9]!==l||e[10]!==f||e[11]!==p?(b=s.jsx("span",{className:p,role:"img","aria-label":f,title:f,"data-action-directory":l,children:x}),e[9]=l,e[10]=f,e[11]=p,e[12]=b):b=e[12],b},N2=t=>{const e=Ze.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,h=a===void 0?!1:a,f=`session-drag:${r??n}`;let p;e[0]!==h||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(p={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:h},e[0]=h,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=p):p=e[5];let x;e[6]!==h||e[7]!==f||e[8]!==p?(x={id:f,disabled:h,data:p},e[6]=h,e[7]=f,e[8]=p,e[9]=x):x=e[9];const{attributes:b,listeners:k,setNodeRef:y,isDragging:m}=cb(x);let g;e[10]!==k?(g=C=>{C.stopPropagation(),k?.onPointerDown&&k.onPointerDown(C)},e[10]=k,e[11]=g):g=e[11];const j=g,S=`touch-pan-y select-none${m?" opacity-30":""}`;let w;return e[12]!==b||e[13]!==d||e[14]!==j||e[15]!==k||e[16]!==y||e[17]!==S?(w=s.jsx("div",{ref:y,...b,...k,onPointerDown:j,className:S,children:d}),e[12]=b,e[13]=d,e[14]=j,e[15]=k,e[16]=y,e[17]=S,e[18]=w):w=e[18],w},Yf=t=>{const e=Ze.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=_n(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let h;e[3]!==a||e[4]!==r?(h=a||al(r),e[3]=a,e[4]=r,e[5]=h):h=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let p;e[10]!==u||e[11]!==h||e[12]!==f?(p={id:u,disabled:h,data:f},e[10]=u,e[11]=h,e[12]=f,e[13]=p):p=e[13];const{setNodeRef:x,isOver:b}=db(p);let k;e[14]!==l||e[15]!==b||e[16]!==x?(k=l(x,b),e[14]=l,e[15]=b,e[16]=x,e[17]=k):k=e[17];let y;return e[18]!==k?(y=s.jsx(s.Fragment,{children:k}),e[18]=k,e[19]=y):y=e[19],y},A2=t=>{const e=Ze.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const h=oi(fn(ai,d),fn(ii,u)),[f,p]=c.useState(null),[x,b]=c.useState("Session"),[k,y]=c.useState(null),[m,g]=c.useState(null);if(!n){let D;return e[2]!==l?(D=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=D):D=e[3],D}let j;e[4]!==o||e[5]!==a?(j=D=>{p(null),y(null),g(null);const{active:F,over:B}=D;if(!B)return;const E=F.data.current,$=B.data.current;E?.type!=="session"||!E.sessionId||!E.ownerKey||E.archivedBucket===!0||a&&E.ownerKey!==a||$?.type!=="folder"||!$.folderId||!$.scopeKey||!$.ownerKey||al($.scopeKey)||$.ownerKey!==E.ownerKey||o(E.sessionId,{folderId:$.folderId,scopeKey:$.scopeKey,ownerKey:$.ownerKey},E.ownerKey)},e[4]=o,e[5]=a,e[6]=j):j=e[6];const S=j;let w,C;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{const F=D.active.data.current;if(F?.type==="session"&&F.sessionId){p(F.sessionId),b(F.sessionTitle??"Session");const B=D.active.rect.current.initial?.width,E=D.active.rect.current.initial?.height;y(B??null),g(E??null)}},C=()=>{p(null),y(null),g(null)},e[7]=w,e[8]=C):(w=e[7],C=e[8]);let v;e[9]!==m||e[10]!==f||e[11]!==x||e[12]!==k||e[13]!==i?(v=f&&i?s.jsxs("div",{style:{width:k?`${k}px`:"auto",height:m?`${m}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(O,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:x})]}):null,e[9]=m,e[10]=f,e[11]=x,e[12]=k,e[13]=i,e[14]=v):v=e[14];let R;e[15]!==v?(R=s.jsx(ub,{children:v}),e[15]=v,e[16]=R):R=e[16];let T;return e[17]!==l||e[18]!==S||e[19]!==h||e[20]!==R?(T=s.jsxs(li,{sensors:h,collisionDetection:ci,onDragStart:w,onDragCancel:C,onDragEnd:S,children:[l,R]}),e[17]=l,e[18]=S,e[19]=h,e[20]=R,e[21]=T):T=e[21],T},Qf=c.createContext(null),P2=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Qf.Provider,{value:a.current,children:r})},Xf=()=>c.useContext(Qf),D2=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const h of u)l.has(h)||(l.add(h),o.push(h))}return o.length>0?{ids:o,scopeKey:i}:null},Jf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},Uc=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},wr=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(wr(n,e))return!0;return!1},I2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!Pg(r),T2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,E2=(t,e,n)=>{const r=new Map,i=o=>{const l=xs(o.session)??xt(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ja=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},Zf=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},em=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const p=i.get(u.parentId)??[];p.push(u.id),i.set(u.parentId,p)}const h=new Set;let f=u.id;for(;f;){if(h.has(f)){o.add(u.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const h=r.get(u);if(!h)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Bo([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Hc=new WeakMap;let Gc=1;const R2=t=>{const e=Hc.get(t);if(e!==void 0)return e;const n=Gc;return Gc+=1,Hc.set(t,n),n},Uo=t=>t.children.length===0?"":t.children.map(n=>{const r=R2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Uo(n)}`}).join("|"),tm=(t,e,n,r,i,o)=>{const l=Wt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??i,f=u.session.directory??o,p=Bl(l,h??"",d.session.id),x=Bl(l,f??"",u.session.id);return(p?n.has(p):!1)!==(x?r.has(x):!1)?!0:d.children.some((b,k)=>a(b,u.children[k]))};return a(t,e)},M2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,O2=(t,e)=>t?t.branchLabel??null:e??null,B2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=xt(t?.path??null);return n&&r?Xo(r,n):null},Ho=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},F2=t=>{const e=Ze.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[h,f]=c.useState(!1),p=i===n&&!h,x=r?i===r&&!h:d;let b;e[0]!==l||e[1]!==i||e[2]!==o?(b=T=>{if(i===T){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=b):b=e[3];const k=b;let y;e[4]!==n||e[5]!==k||e[6]!==o?(y=T=>{if(T){u(!1),f(!1),o(n);return}k(n)},e[4]=n,e[5]=k,e[6]=o,e[7]=y):y=e[7];const m=y;let g;e[8]!==r||e[9]!==k||e[10]!==o?(g=T=>{if(!r){u(T);return}if(T){f(!1),o(r);return}k(r)},e[8]=r,e[9]=k,e[10]=o,e[11]=g):g=e[11];const j=g;let S;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(S=T=>{T||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=S):S=e[17];const w=S;let C;e[18]!==p||e[19]!==n||e[20]!==o?(C=()=>{f(!1),o(p?null:n)},e[18]=p,e[19]=n,e[20]=o,e[21]=C):C=e[21];const v=C;let R;return e[22]!==j||e[23]!==m||e[24]!==w||e[25]!==x||e[26]!==p||e[27]!==v?(R={isMenuOpen:p,isContextMenuOpen:x,handleMenuOpenChange:m,handleContextMenuOpenChange:j,handleMenuOpenChangeComplete:w,toggleMenu:v},e[22]=j,e[23]=m,e[24]=w,e[25]=x,e[26]=p,e[27]=v,e[28]=R):R=e[28],R},L2=t=>{const e=Ze.c(10),{project:n,fallback:r}=t,{currentTheme:i}=Cn(),o=n.iconImage??null;let l;e[0]!==n.id||e[1]!==o?(l={id:n.id,iconImage:o},e[0]=n.id,e[1]=o,e[2]=l):l=e[2];let a;e[3]!==i.colors.surface.foreground||e[4]!==i.metadata.variant?(a={themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},e[3]=i.colors.surface.foreground,e[4]=i.metadata.variant,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==l||e[8]!==a?(d=s.jsx(si,{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},_2=t=>{const e=Ze.c(13),{project:n}=t,r=n?.icon?ei[n.icon]:null,i=n?.color?ti[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(O,{name:r,className:Me("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let h;return e[3]!==l?(h=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=h):h=e[4],h}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(L2,{project:n,fallback:l}),e[7]=l,e[8]=n,e[9]=d):d=e[9];let u;return e[10]!==a||e[11]!==d?(u=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:a,children:d}),e[10]=a,e[11]=d,e[12]=u):u=e[12],u},qc=t=>{const e=Ze.c(44),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,statusDot:d,pinnedMarker:u,timeSlot:h,directoryIndicator:f,prBadge:p,zombieIndicator:x,badges:b,providerId:k,metaPaddingClass:y,hideMetaOnHoverClass:m}=t,g=n===void 0?!1:n,j=!g&&(!!a||!!p||!!x||!!b||!!k);let S;e[0]!==m||e[1]!==y?(S=Me("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",y,m),e[0]=m,e[1]=y,e[2]=S):S=e[2];const w=g?b:null;let C;e[3]!==h?(C=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:h}),e[3]=h,e[4]=C):C=e[4];let v;e[5]!==f||e[6]!==u||e[7]!==d||e[8]!==S||e[9]!==w||e[10]!==C?(v=s.jsxs("span",{className:S,children:[w,f,u,d,C]}),e[5]=f,e[6]=u,e[7]=d,e[8]=S,e[9]=w,e[10]=C,e[11]=v):v=e[11];const R=v;if(g){let X;e[12]!==l?(X=Me("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[12]=l,e[13]=X):X=e[13];let Y;e[14]!==X||e[15]!==o?(Y=s.jsx("div",{className:X,children:o}),e[14]=X,e[15]=o,e[16]=Y):Y=e[16];let I;return e[17]!==R||e[18]!==Y?(I=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[Y,R]}),e[17]=R,e[18]=Y,e[19]=I):I=e[19],I}let T;e[20]!==r?(T=s.jsx(_2,{project:r}),e[20]=r,e[21]=T):T=e[21];let D;e[22]!==i?(D=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[22]=i,e[23]=D):D=e[23];let F;e[24]!==R||e[25]!==T||e[26]!==D?(F=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[T,D,R]}),e[24]=R,e[25]=T,e[26]=D,e[27]=F):F=e[27];let B;e[28]!==l?(B=Me("w-full min-w-0 truncate typography-ui-label font-normal",l),e[28]=l,e[29]=B):B=e[29];let E;e[30]!==B||e[31]!==o?(E=s.jsx("div",{className:B,children:o}),e[30]=B,e[31]=o,e[32]=E):E=e[32];let $;e[33]!==b||e[34]!==a||e[35]!==j||e[36]!==p||e[37]!==k||e[38]!==x?($=j?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[a?s.jsxs(s.Fragment,{children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40"}),s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:a})]}):null,s.jsxs("span",{className:"ml-auto flex flex-shrink-0 items-center gap-1",children:[x??p,b,k?s.jsx(Fo,{providerId:k,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[33]=b,e[34]=a,e[35]=j,e[36]=p,e[37]=k,e[38]=x,e[39]=$):$=e[39];let L;return e[40]!==E||e[41]!==$||e[42]!==F?(L=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[F,E,$]}),e[40]=E,e[41]=$,e[42]=F,e[43]=L):L=e[43],L};let ka=!1;const Ca=new Set;let Yc=!1;function $2(){for(const t of Ca)t()}function cl(t){ka!==t&&(ka=t,$2())}function z2(t){t.key==="Shift"&&cl(!0)}function W2(t){t.key==="Shift"&&cl(!1)}function K2(){cl(!1)}function V2(){Yc||typeof window>"u"||(Yc=!0,window.addEventListener("keydown",z2),window.addEventListener("keyup",W2),window.addEventListener("blur",K2))}function U2(t){return V2(),Ca.add(t),()=>{Ca.delete(t)}}function H2(){return ka}function G2(){return!1}function q2(){return ct.useSyncExternalStore(U2,H2,G2)}async function Y2(t,e,n){const r=await Promise.all(t.map(async i=>{n();const o=i.directory??i.session.directory,l=await Vs.getSession(i.session.id,o);if(n(),!eu(e,Oo(l,i.projectDirectory??l.directory)))throw new Error("Fusion source membership changed");const a=await Vs.getSessionMessages(i.session.id,{limit:50},o);n();let d="";for(const u of a.items)if(u.info.role==="assistant"){d=Dg(u.parts).trim();break}return{source:{...i,session:l},text:d}}));return n(),r.filter(i=>i.text.length>0)}const sm=t=>{const e=Ze.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=St(),u=Lt(Q2),h=Lt(X2),f=Lt(J2);let p;e[0]!==u?(p=u(),e[0]=u,e[1]=p):p=e[1];const x=p;let b;e[2]!==x?(b=x.filter(Z2),e[2]=x,e[3]=b):b=e[3];const k=b;let y,m;e[4]!==x.length||e[5]!==h?(y=()=>{x.length===0&&h()},m=[x.length,h],e[4]=x.length,e[5]=h,e[6]=y,e[7]=m):(y=e[6],m=e[7]),c.useEffect(y,m);let g,j;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==k||e[12]!==n?(g=()=>{if(o)return;const B=n.trim();if(B.length>0&&k.some(L=>L.name===B))return;const E=typeof f=="string"&&f.trim().length>0?f.trim():null;if(E&&k.some(L=>L.name===E)){r(E);return}const $=k[0]?.name;$&&r($)},j=[f,o,r,k,n],e[8]=f,e[9]=o,e[10]=r,e[11]=k,e[12]=n,e[13]=g,e[14]=j):(g=e[13],j=e[14]),c.useEffect(g,j);const S=n.trim().length>0?n:void 0;let w;e[15]!==i?(w=Me("max-w-full",i),e[15]=i,e[16]=w):w=e[16];let C;e[17]!==d?(C=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=C):C=e[18];let v;e[19]!==C?(v=s.jsx(hs,{placeholder:C}),e[19]=C,e[20]=v):v=e[20];let R;e[21]!==l||e[22]!==w||e[23]!==v?(R=s.jsx(Cs,{id:l,size:"lg",className:w,children:v}),e[21]=l,e[22]=w,e[23]=v,e[24]=R):R=e[24];let T;e[25]!==k?(T=k.length>0&&s.jsx(sa,{children:k.map(ek)}),e[25]=k,e[26]=T):T=e[26];let D;e[27]!==a||e[28]!==T?(D=s.jsx(Ns,{fitContent:!0,portalToBody:a,children:T}),e[27]=a,e[28]=T,e[29]=D):D=e[29];let F;return e[30]!==o||e[31]!==r||e[32]!==S||e[33]!==R||e[34]!==D?(F=s.jsxs(ks,{value:S,onValueChange:r,disabled:o,children:[R,D]}),e[30]=o,e[31]=r,e[32]=S,e[33]=R,e[34]=D,e[35]=F):F=e[35],F};function Q2(t){return t.getVisibleAgents}function X2(t){return t.loadAgents}function J2(t){return t.currentAgentName}function Z2(t){return Lu(t.mode)}function ek(t){return s.jsx(Yt,{value:t.name,className:"w-auto whitespace-nowrap",children:Ig(t)},t.name)}const tk="h-7",Kr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,sk=t=>{const e=Ze.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Me("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",tk),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(Fo,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(O,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let p;e[6]!==o?(p=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=p):p=e[7];let x;return e[8]!==u||e[9]!==h||e[10]!==p?(x=s.jsxs("div",{className:d,children:[u,h,p]}),e[8]=u,e[9]=h,e[10]=p,e[11]=x):x=e[11],x},nm=t=>{const e=Ze.c(119),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:p,containerClassName:x,triggerIcon:b}=t,k=d===void 0?!0:d,y=f===void 0?"top":f,{t:m}=St(),g=Lt(nk),j=Ae(rk),S=Ae(ok),{favoriteModelsList:w,recentModelsList:C}=Tg(),v=Ae(ik),R=Ae(ak),[T,D]=c.useState(!1),[F,B]=c.useState(""),[E,$]=c.useState(null),L=c.useRef(null),X=c.useRef(null),Y=u===1,I=u===void 0||n.length<u||Y;let P;if(e[0]!==n){P=new Map;for(const Se of n){const Ke=`${Se.providerID}:${Se.modelID}`;P.set(Ke,(P.get(Ke)||0)+1)}e[0]=n,e[1]=P}else P=e[1];const A=P;let q;e[2]!==n?(q=Se=>n.filter(et=>et.providerID===Se.providerID&&et.modelID===Se.modelID).findIndex(et=>et.instanceId===Se.instanceId)+1,e[2]=n,e[3]=q):q=e[3];const K=q;let te,ae;e[4]!==y||e[5]!==T?(te=()=>{if(!T||!X.current)return;const Se=X.current.getBoundingClientRect();if(y==="bottom"){const ht=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Se.bottom-16-112;$(Math.max(160,Math.min(320,ht)));return}let Ke=X.current.parentElement;for(;Ke&&!Ke.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const rt=getComputedStyle(Ke);if(rt.overflow==="auto"||rt.overflow==="hidden"||rt.overflowY==="auto"||rt.overflowY==="hidden")break;Ke=Ke.parentElement}const et=Ke?Ke.getBoundingClientRect().top:0,it=Se.top-et-16;$(Math.max(150,Math.min(300,it)))},ae=[y,T],e[4]=y,e[5]=T,e[6]=te,e[7]=ae):(te=e[6],ae=e[7]),c.useEffect(te,ae);let re,he;e[8]!==I||e[9]!==T?(re=()=>{!I&&T&&(D(!1),B(""))},he=[I,T],e[8]=I,e[9]=T,e[10]=re,e[11]=he):(re=e[10],he=e[11]),c.useEffect(re,he);let ce,Te;e[12]!==T?(ce=()=>{if(!T)return;const Se=Ke=>{L.current&&!L.current.contains(Ke.target)&&(D(!1),B(""))};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},Te=[T],e[12]=T,e[13]=ce,e[14]=Te):(ce=e[13],Te=e[14]),c.useEffect(ce,Te);let ve;e[15]!==Y||e[16]!==r||e[17]!==o||e[18]!==n.length?(ve=Se=>{const Ke={providerID:Se.providerID,modelID:Se.modelID,displayName:Se.model.name||Se.modelID,instanceId:Kr()};Y&&n.length>0&&o?o(0,Ke):r(Ke),Y&&(D(!1),B(""))},e[15]=Y,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ve):ve=e[19];const pe=ve;let Ne;e[20]!==m?(Ne=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=Ne):Ne=e[21];let U;e[22]!==m?(U=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=U):U=e[23];let Z;e[24]!==m?(Z=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=Z):Z=e[25];let de;e[26]!==m?(de=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=de):de=e[27];let ye;e[28]!==m?(ye=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=ye):ye=e[29];let H;e[30]!==m?(H=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=H):H=e[31];let je;e[32]!==m?(je=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=je):je=e[33];let Ee;e[34]!==m?(Ee=m("chat.modelControls.capabilities"),e[34]=m,e[35]=Ee):Ee=e[35];let ge;e[36]!==m?(ge=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=ge):ge=e[37];let ne;e[38]!==m?(ne=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=ne):ne=e[39];let be;e[40]!==m?(be=m("chat.modelControls.input"),e[40]=m,e[41]=be):be=e[41];let G;e[42]!==m?(G=m("chat.modelControls.output"),e[42]=m,e[43]=G):G=e[43];let z;e[44]!==m?(z=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=z):z=e[45];let J;e[46]!==Ne||e[47]!==U||e[48]!==Z||e[49]!==de||e[50]!==ye||e[51]!==H||e[52]!==je||e[53]!==Ee||e[54]!==ge||e[55]!==ne||e[56]!==be||e[57]!==G||e[58]!==z?(J={searchPlaceholder:Ne,noResults:U,favorites:Z,recent:de,keyboardHint:ye,favorite:H,unfavorite:je,capabilities:Ee,capabilityToolCalling:ge,capabilityReasoning:ne,input:be,output:G,costPerMillion:z},e[46]=Ne,e[47]=U,e[48]=Z,e[49]=de,e[50]=ye,e[51]=H,e[52]=je,e[53]=Ee,e[54]=ge,e[55]=ne,e[56]=be,e[57]=G,e[58]=z,e[59]=J):J=e[59];const ue=J;let le;e[60]!==x?(le=Me("relative",x),e[60]=x,e[61]=le):le=e[61];const W=T?"":void 0;let M;e[62]!==h?(M=Me(_u({size:"default"}),"w-fit",h),e[62]=h,e[63]=M):M=e[63];const _=!I;let ee;e[64]!==T?(ee=()=>{D(!T)},e[64]=T,e[65]=ee):ee=e[65];let oe;e[66]!==b?(oe=b??s.jsx(O,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=b,e[67]=oe):oe=e[67];let fe;e[68]!==a||e[69]!==m?(fe=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=fe):fe=e[70];let ie;e[71]!==W||e[72]!==M||e[73]!==_||e[74]!==ee||e[75]!==oe||e[76]!==fe?(ie=s.jsxs("button",{ref:X,type:"button","data-popup-open":W,className:M,disabled:_,onClick:ee,children:[oe,fe]}),e[71]=W,e[72]=M,e[73]=_,e[74]=ee,e[75]=oe,e[76]=fe,e[77]=ie):ie=e[77];let Le;e[78]!==E||e[79]!==I||e[80]!==p||e[81]!==y||e[82]!==w||e[83]!==pe||e[84]!==v||e[85]!==S||e[86]!==T||e[87]!==ue||e[88]!==A||e[89]!==R||e[90]!==g||e[91]!==C||e[92]!==F||e[93]!==j?(Le=T?s.jsx("div",{className:Me("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",y==="top"?"bottom-full mb-1":"top-full mt-1",p),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(Eg,{providers:g,providerOrder:R,favoriteModels:w,recentModels:C,hiddenModels:v,searchQuery:F,onSearchQueryChange:B,onSelect:pe,labels:ue,selectionCount:Se=>A.get(`${Se.providerID}:${Se.modelID}`)||0,disabled:!I,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:E?`${E}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:T,isFavorite:Se=>S(Se.providerID,Se.modelID),onToggleFavorite:Se=>j(Se.providerID,Se.modelID),onEscape:()=>{D(!1),B("")}})}):null,e[78]=E,e[79]=I,e[80]=p,e[81]=y,e[82]=w,e[83]=pe,e[84]=v,e[85]=S,e[86]=T,e[87]=ue,e[88]=A,e[89]=R,e[90]=g,e[91]=C,e[92]=F,e[93]=j,e[94]=Le):Le=e[94];let $e;e[95]!==le||e[96]!==ie||e[97]!==Le?($e=s.jsxs("div",{className:le,ref:L,children:[ie,Le]}),e[95]=le,e[96]=ie,e[97]=Le,e[98]=$e):$e=e[98];let Pe;e[99]!==K||e[100]!==A||e[101]!==i||e[102]!==o||e[103]!==g||e[104]!==n||e[105]!==k||e[106]!==m?(Pe=k&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Se,Ke)=>{const et=`${Se.providerID}:${Se.modelID}`,it=A.get(et)||1,rt=K(Se),ht=g.find(we=>we.id===Se.providerID)?.models?.find(we=>we.id===Se.modelID),tt=Ya(ht?.variants),At=tt.length>0,jt=Se.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(sk,{model:Se,instanceIndex:rt,totalSameModel:it,onRemove:()=>i(Ke)}),At&&s.jsxs(ks,{value:jt,onValueChange:we=>{if(!o)return;o(Ke,{...Se,variant:we==="__default__"?void 0:we})},children:[s.jsxs(Cs,{size:"sm",className:"gap-1.5",children:[s.jsx(O,{name:"brain-ai-3",className:Me("h-3.5 w-3.5 flex-shrink-0",jt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(hs,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:we=>we==="__default__"?m("multirun.modelMultiSelect.variant.default"):we})]}),s.jsxs(Ns,{fitContent:!0,children:[s.jsx(Yt,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),tt.map(lk)]})]})]},Se.instanceId)})}),e[99]=K,e[100]=A,e[101]=i,e[102]=o,e[103]=g,e[104]=n,e[105]=k,e[106]=m,e[107]=Pe):Pe=e[107];let Oe;e[108]!==$e||e[109]!==Pe?(Oe=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[$e,Pe]}),e[108]=$e,e[109]=Pe,e[110]=Oe):Oe=e[110];let Q;e[111]!==u||e[112]!==l||e[113]!==n.length||e[114]!==m?(Q=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[111]=u,e[112]=l,e[113]=n.length,e[114]=m,e[115]=Q):Q=e[115];let Ce;return e[116]!==Oe||e[117]!==Q?(Ce=s.jsxs("div",{className:"space-y-2",children:[Oe,Q]}),e[116]=Oe,e[117]=Q,e[118]=Ce):Ce=e[118],Ce};function nk(t){return t.providers}function rk(t){return t.toggleFavoriteModel}function ok(t){return t.isFavoriteModel}function ik(t){return t.hiddenModels}function ak(t){return t.providerOrder}function lk(t){return s.jsx(Yt,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const ck=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
881
+
882
+ --- RESULT ${n+1}: ${r} ---
883
+ ${e.trim()}
884
+ --- END RESULT ${n+1} ---`},Qc=(t,e)=>nt.getState().getWorktreeMetadata(t)?.projectDirectory??e;function dk({session:t,open:e,onOpenChange:n}){const{t:r}=St(),i=Rg(),o=us(A=>A.activeSessions),l=us(A=>A.archivedSessions),a=us(A=>A.status==="ready"),d=Lt(A=>A.providers),u=Lt(A=>A.currentProviderId),h=Lt(A=>A.currentModelId),f=Lt(A=>A.currentAgentName),[p,x]=c.useState(u??""),[b,k]=c.useState(h??""),[y,m]=c.useState(()=>u&&h?[{providerID:u,modelID:h,instanceId:Kr()}]:[]),[g,j]=c.useState(""),[S,w]=c.useState(f??""),[C,v]=c.useState([]),[R,T]=c.useState(!1),D=c.useMemo(()=>Oo(t,Qc(t.id,t.directory)??t.directory),[t]),F=c.useMemo(()=>{const A=new Map;for(const q of i)A.set(q.id,q);for(const q of o)A.set(q.id,q);for(const q of l)A.set(q.id,q);return t.id&&A.set(t.id,t),Array.from(A.values())},[o,l,i,t]);c.useEffect(()=>{v([])},[e,t.id]);const B=c.useMemo(()=>!e||!D?[]:F.map(A=>{if(C.includes(A.id))return null;const q=nt.getState().getDirectoryForSession(A.id)??xs(A),K=Qc(A.id,q),te=Oo(A,K??A.directory);return!te||!eu(D,te)?null:{session:A,directory:q,projectDirectory:K,identity:te}}).filter(A=>A!==null).sort((A,q)=>(A.session.time?.created??0)-(q.session.time?.created??0)),[F,e,D,C]),$=d.find(A=>A.id===p)?.models.find(A=>A.id===b),L=Ya($?.variants),X=!!(D&&a&&p&&b&&B.length>0&&!R),Y=c.useCallback(A=>{m([A]),x(A.providerID),k(A.modelID),j("")},[]),I=y[0]?.displayName||y[0]?.modelID||r("multirun.fusion.model.placeholder"),P=async()=>{if(!D||!X)return;const A=Wt(),q=Vs.getSdkClient(),K=()=>{if(Wt()!==A||Vs.getSdkClient()!==q)throw new Error("Runtime changed")};T(!0);try{const te=await Y2(B,D,K);if(te.length===0){ze.error(r("multirun.fusion.toast.noOutputs"));return}const ae=B[0]?.projectDirectory??B[0]?.directory??null;if(!ae)throw new Error("Fusion requires a session directory");const re=Vh(D.groupSlug,p,b,D.runGroup),[he,ce]=await Promise.all([Fl("session.fusion.visible"),Fl("session.fusion.instructions")]),Te=await Uh({title:re,directory:ae,identity:{group:D.group,groupSlug:D.groupSlug,runGroup:D.runGroup,role:"fusion",providerID:p,modelID:b},selection:{model:{providerID:p,id:b,variant:g||void 0},agent:S||void 0}},K);Hh(Te,ae),nt.getState().setCurrentSession(Te.id,ae),n(!1),K(),await Vs.sendMessage({runtimeKey:A,id:Te.id,providerID:p,model:{providerID:p,id:b,variant:g||void 0},agent:S||void 0,text:he,context:[{text:ce},...te.map((ve,pe)=>({text:ck(ve.source,ve.text,pe)})),{text:`
885
+
886
+ --- FUSION INPUTS END ---
887
+ Now write the final fused answer.`}],directory:ae})}catch(te){if(Wt()!==A||Vs.getSdkClient()!==q)return;console.error("[MultiRunFusion] Failed to start fusion",te),ze.error(r("multirun.fusion.toast.failed"))}finally{T(!1)}};return s.jsx(bs,{open:e,onOpenChange:n,children:s.jsxs(ys,{className:"max-w-xl overflow-visible",children:[s.jsxs(Us,{children:[s.jsx(Bs,{children:r("multirun.fusion.title")}),s.jsx(Fs,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(nm,{selectedModels:y,onAdd:Y,onUpdate:(A,q)=>Y(q),onRemove:()=>{m([]),x(""),k(""),j("")},maxModels:1,addButtonLabel:I,showChips:!1,addButtonClassName:"w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:p?s.jsx(Fo,{providerId:p,className:"h-3.5 w-3.5 mr-1"}):void 0})}),L.length>0?s.jsxs(ks,{value:g||"__default__",onValueChange:A=>j(A==="__default__"?"":A),children:[s.jsxs(Cs,{size:"lg",className:"w-fit",children:[s.jsx(O,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(hs,{children:A=>A==="__default__"?r("multirun.modelMultiSelect.variant.default"):A})]}),s.jsxs(Ns,{fitContent:!0,portalToBody:!0,children:[s.jsx(Yt,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),L.map(A=>s.jsx(Yt,{value:A,children:A},A))]})]}):null,s.jsx(sm,{value:S,onChange:w,portalToBody:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:B.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:B.map(A=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Fo,{providerId:A.identity.providerID,className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:A.session.title||A.session.id}),s.jsx("button",{type:"button",onClick:()=>v(q=>[...q,A.session.id]),className:"text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"h-4 w-4"})})]},A.session.id))})]}),s.jsxs(An,{children:[s.jsx(ut,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx(ut,{onClick:P,disabled:!X,children:r(R?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function uk(t){const e=Ze.c(7);let n,r,i,o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),i=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),o=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),l=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=i,e[3]=o,e[4]=l):(n=e[0],r=e[1],i=e[2],o=e[3],l=e[4]);let a;return e[5]!==t?(a=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,i,o,l]}),e[5]=t,e[6]=a):a=e[6],a}const rm=async(t,e,n)=>{const r=n.getRuntimeKey(),i=xt(t.path);if(!i)throw new Error("Unable to resolve worktree project");const o=await n.listProjectWorktrees(t,{force:!0});if(n.getRuntimeKey()!==r)throw new Error("Runtime changed during worktree refresh");const l=n.getCurrentProjects(),a=l.find(b=>b.id===t.id)??null;if(!a||xt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=dl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(b=>Go(b));u.sort((b,k)=>om({metadata:b},{metadata:k}));const h=Mg(d.worktreesByProject,i,u,e?.projectDirectory);fk(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:h};const f=n.getPublishedWorktreesByProject(),p=Og(n.partitionWorktreesByRegisteredProject(l,h),f),x=[...p.values()].flat();return n.recordWorktreesSeen(x.map(b=>b.path),n.now()),n.worktreeMapsEqual(p,f)||n.publishTopology({availableWorktrees:x,availableWorktreesByProject:p}),u},fk=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),mk=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Go(r))])),dl=t=>((t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey||t.rawWorktreesByProjectRef.current.worktreesByProject.size===0&&t.publishedWorktreesByProject.size>0)&&(t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.rawWorktreesByProjectRef.current.runtimeKey===t.runtimeKey?t.rawWorktreesByProjectRef.current.revision:0,worktreesByProject:mk(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),om=(t,e)=>{const n=t.metadata.branch||t.metadata.name||t.metadata.label||t.metadata.path,r=e.metadata.branch||e.metadata.name||e.metadata.label||e.metadata.path,i=n.localeCompare(r,void 0,{sensitivity:"base"});return i!==0?i:t.metadata.path.localeCompare(e.metadata.path,void 0,{sensitivity:"base"})},Xc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Go=t=>({...t,path:xt(t.path)??t.path,projectDirectory:xt(t.projectDirectory)??t.projectDirectory,worktreeRoot:xt(t.worktreeRoot??t.path)??t.worktreeRoot}),Jc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=xt(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Xc(n):i||Xc(n),name:l?e?.name:void 0,worktreeRoot:l?xt(e?.worktreeRoot??n)??n:n,worktreeStatus:l?e?.worktreeStatus??"ready":"ready",worktreeSource:l?e?.worktreeSource??"existing":"existing",headState:l?e?.headState:i?"branch":void 0};return l&&e?{...e,...d}:d},Zc=t=>{const e=xt(t.projectPath??null),n=xt(t.sourceDirectory??null)??xt(t.currentWorktree?.path??null),r=xt(t.discoveredWorktrees.find(h=>xt(h.projectDirectory??null))?.projectDirectory??null),i=xt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=h=>{const f=xt(h.metadata.path??null);!f||l.has(f)||l.set(f,{...h,metadata:Go({...h.metadata,path:f})})};for(const h of t.discoveredWorktrees){const f=xt(h.path??null);f&&a({metadata:Go({...h,path:f,projectDirectory:xt(h.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Jc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Jc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const h of l.values()){if(h.isPrimary){d.push(h);continue}u.push(h)}return d.sort((h,f)=>h.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(om),[...d,...u]},im=(t,e)=>{const n=t.projectId?e.projects.find(o=>o.id===t.projectId)??null:null;if(n)return n;const r=t.sourceDirectory?e.resolveProject(t.sourceDirectory):null;if(r)return r;const i=t.currentWorktree?.projectDirectory??null;return i?e.resolveProject(i):null},hk=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=dl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),o=im(t,e),l=xt(o?.path??null);return{cachedTargets:Zc({projectPath:l,discoveredWorktrees:l?i.worktreesByProject.get(l)??[]:[],sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch}),refreshTargets:(async()=>{if(!o||!l)throw new Error("Unable to resolve worktree project");const d=await rm(o,t.currentWorktree,e);return Zc({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},pk=t=>{if(t.rawWorktreesByProjectRef.current.runtimeKey!==t.runtimeKey)return!1;if(t.rawWorktreesByProjectRef.current.revision!==t.capturedRevision)return t.requestRediscovery(),!1;const e=t.partitionWorktreesByRegisteredProject(t.projects,t.nextRawWorktreesByProject),n=[...e.values()].flat();return t.recordWorktreesSeen(n.map(r=>r.path),t.now()),t.rawWorktreesByProjectRef.current={runtimeKey:t.runtimeKey,revision:t.capturedRevision,worktreesByProject:new Map(t.nextRawWorktreesByProject)},t.worktreeMapsEqual(e,t.publishedWorktreesByProject)||t.publishTopology({availableWorktrees:n,availableWorktreesByProject:e}),!0},gk=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),xk=(t,e)=>xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Lr=6,bo=14,ed=Lr+14+6,Fi=new WeakMap,bk=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Fi.get(n)?.();const r=e.getBoundingClientRect().top;let i=3,o=!1,l=null;const a=()=>{o=!0,l!==null&&window.cancelAnimationFrame(l),l=null,Fi.delete(n),n.removeEventListener("wheel",a),n.removeEventListener("touchstart",a)},d=()=>{if(o||!e.isConnected||!n.isConnected){a();return}const u=e.getBoundingClientRect().top-r;if(Math.abs(u)>.5&&(n.scrollTop+=u,js("ui.sidebar.selection_scroll_anchor_adjustment")),i-=1,i<=0){a();return}l=window.requestAnimationFrame(d)};n.addEventListener("wheel",a,{passive:!0}),n.addEventListener("touchstart",a,{passive:!0}),Fi.set(n,a),l=window.requestAnimationFrame(d)},yk=c.memo(function(e){const n=Ze.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:h}=e,f=q2(),p=f?i:r;let x;n[0]!==u||n[1]!==h||n[2]!==f?(x=C=>{if(f||C.shiftKey){h(C);return}u(C)},n[0]=u,n[1]=h,n[2]=f,n[3]=x):x=n[3];const b=x,k=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;n[4]!==o||n[5]!==k?(y=Me("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",k,o),n[4]=o,n[5]=k,n[6]=y):y=n[6];const m=f?"delete-bin":"archive";let g;n[7]!==l||n[8]!==m?(g=s.jsx(O,{name:m,className:l}),n[7]=l,n[8]=m,n[9]=g):g=n[9];let j;n[10]!==b||n[11]!==p||n[12]!==d||n[13]!==a||n[14]!==y||n[15]!==g?(j=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:y,"aria-label":p,onPointerDown:a,onMouseDown:d,onClick:b,onKeyDown:Pk,children:g})}),n[10]=b,n[11]=p,n[12]=d,n[13]=a,n[14]=y,n[15]=g,n[16]=j):j=n[16];let S;n[17]!==p?(S=s.jsx(wt,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=S):S=n[18];let w;return n[19]!==j||n[20]!==S?(w=s.jsxs(bt,{children:[j,S]}),n[19]=j,n[20]=S,n[21]=w):w=n[21],w});function wk(t){js("ui.sidebar_session_node.render");const{t:e}=St(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:h,hasSessionSearchQuery:f,normalizedSessionSearchQuery:p,notifyOnSubtasks:x,editingId:b,editingRowKey:k,setEditingId:y,setEditingRowKey:m,editTitle:g,setEditTitle:j,handleSaveEdit:S,handleCancelEdit:w,toggleParent:C,handleSessionSelect:v,handleSessionDoubleClick:R,handleCopySessionId:T,openSidebarMenuKey:D,setOpenSidebarMenuKey:F,createFolderAndStartRename:B,handleDeleteSession:E,handleRestoreSession:$,startSessionWorktreeMenuLoad:L,onEditProject:X,mobileVariant:Y,alwaysShowActions:I,secondaryMeta:P,renderContext:A="project",rowKey:q,dragKey:K,children:te}=t,ae=Hr(Be=>Be.toggle),re=Ut(Be=>Be.getFoldersForScope),he=Ut(Be=>Be.getSessionFolderId),ce=Ut(Be=>Be.removeSessionFromFolder),Te=Ut(Be=>Be.addSessionToFolder),ve=Ae(Be=>Be.openContextPanelTab),pe=c.useMemo(()=>kn(),[]),Ne=c.useMemo(()=>Vr(),[]),U=c.useContext(Bg),Z=pe?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-has-[:focus-visible]:opacity-100 group-has-[:focus-visible]:pointer-events-auto",de=pe?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",ye=pe,H=!d&&!Y,je=pe?H&&ye?"group-hover:pr-18":H||ye?"group-hover:pr-14":"group-hover:pr-8":H?"group-hover:pr-7 group-has-[:focus-visible]:pr-7":"group-hover:pr-3 group-has-[:focus-visible]:pr-3",Ee=H?"pr-13":"pr-7",ge=pe?H?"pr-18":"pr-14":H?"pr-7":"pr-3",ne=c.useRef(!1),[be,G]=c.useState(!1),z=c.useRef(b);z.current=b;const J=c.useRef(null),ue=c.useRef(!1),le=c.useRef(S);le.current=S;const W=g,M=c.useRef(W);M.current=W;const _=c.useRef(null),ee=c.useRef(!1),oe=c.useRef(null),fe=c.useRef(null),ie=n.session,Le=ie,$e=zt(c.useCallback(Be=>{if(P?.projectLabel||!o)return null;const It=Be.projects.find(Kt=>Kt.id===o);return It?It.label?.trim()||Yn(xt(It.path)??It.path,null)||It.path:null},[o,P?.projectLabel])),Pe=A==="timeline"||A==="timeline-chat",Oe=A==="timeline-chat",Q=zt(c.useCallback(Be=>!Pe||!o?null:Be.projects.find(It=>It.id===o)??null,[Pe,o])),Ce=P?.projectLabel??($e?$u($e):null),Se=O2(P,n.worktree?.branch??null),Ke=c.useMemo(()=>B2(n.worktree,pe),[pe,n.worktree]),et=zu(Ke),it=et?`var(--pr-${et.visualState})`:void 0,rt=!!Se&&A==="recent",pt=c.useMemo(()=>{if(!et)return null;switch(et.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return et.canMerge===!0||et.mergeableState==="clean"||et.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return et.mergeableState==="dirty"?e("sessions.sidebar.group.pr.status.mergeConflicts"):e("sessions.sidebar.group.pr.status.mergeBlocked");case"draft":return e("sessions.sidebar.group.pr.status.draft");case"closed":return e("sessions.sidebar.group.pr.status.closed");default:return null}},[et,e]),ht=nt(Be=>Be.currentSessionId===ie.id),tt=xt(ie.directory??null)??xt(i??null),At=a!==void 0?a:o??tt??null,jt=pu(),we=Wu(),Xe=pe,mt=ss(Be=>Be.enabled),qe=ss(c.useCallback(Be=>Be.selectedIds.has(ie.id),[ie.id])),ft=ss(Be=>Be.toggleSelected),se=ss(Be=>Be.setRange),me=Xf(),Ie=q??ie.id,We=b===ie.id&&k===Ie,V=c.useCallback(Be=>{const It=[],Kt=es=>{es.children.forEach(cs=>{It.push(cs.session.id),Kt(cs)})};return Kt(Be),It},[]),Fe=c.useCallback(Be=>{const It=[],Kt=es=>{es.children.forEach(cs=>{It.push(cs.session),Kt(cs)})};return Kt(Be),It},[]),[Ye,Qe]=c.useState(!1),[xe,st]=c.useState(!0),Re=`${A}:${d?"archived":"active"}:${ie.id}`,ot=q?`session-menu:${q}`:Re,vt=q?`session-context:${q}`:null,De=Ku(c.useCallback(Be=>!!Be.sessionMemoryState.get(Fg(ie.id))?.isZombie,[ie.id])),gt=iu(ie.id),Ct=Lg(ie.id,gt),He=mf(ie.id),Ue=Ma(ie.id,tt),lt=He||Ue,_e=n.worktree??nt.getState().getWorktreeMetadata(ie.id)??null,[Ge,Je]=c.useState([]),[at,Nt]=c.useState(!1),[Bt,Ft]=c.useState(!1),Qt=c.useRef(!1),Mt=c.useRef(0),Gt=_g(ie.id,tt??void 0,{bootstrap:!1}),$t=$g(Le),Zt=Ae(Be=>Be.sessionSuggestionEnabled),ts=$t?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Ll[$t.status]),"aria-label":e(Ll[$t.status]),children:s.jsx(O,{name:"target",className:"h-3 w-3",style:{color:zg[$t.status]}})}):null,Ot=Le.title||e("sessions.sidebar.session.untitled"),Dt=!Pe&&n.children.length>0,Pt=Vu(u,tt,ie.id),fs=Re,Ts=f?!0:h.has(fs),xn=c.useMemo(()=>E2(n,Ts,tt),[Ts,n,tt]),ns=Wg(xn),In=!!Le.parentID,Tn=au(ie.id)>0&&(!In||x),er=Le.time?.updated||Le.time?.created||Date.now(),En=Uu(er),Xs=Kg(er),{isMenuOpen:rn,isContextMenuOpen:on,handleMenuOpenChange:tr,handleContextMenuOpenChange:sr,handleMenuOpenChangeComplete:ws,toggleMenu:Rn}=F2({menuInstanceKey:ot,contextMenuInstanceKey:vt,openSidebarMenuKey:D,setOpenSidebarMenuKey:F,hasDeferredCloseWork:()=>J.current!==null,onCloseComplete:()=>{if(!J.current)return;const{id:Be,title:It}=J.current;J.current=null,y(Be),m(Ie),j(It)}}),Es=rn||on,nr=c.useMemo(()=>Oo(Le)!==null,[Le]),[rr,kr]=c.useState(!1),or=c.useMemo(()=>V(n).length,[V,n]),Cr=c.useCallback(async Be=>{const It=[];let Kt=0;for(const es of Be)try{if(!tt)throw new Error("Session directory is required for export");const cs=await jt({directory:tt,sessionID:es.session.id});if(!cs)throw new Error("Session runtime changed during export");const Vt=es.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Ls=es.session.agent,qt=await Cr(es.children);Kt+=qt.skipped,It.push({title:Vt,agent:Ls,records:cs,children:qt.children})}catch{Kt+=V(es).length+1}return{children:It,skipped:Kt}},[V,jt,tt,e]),N=c.useCallback(Be=>{Be<=0||ze.warning(Be===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Be}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Be}))},[e]),ke=c.useCallback(async Be=>{if(!tt){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}const It=await jt({directory:tt,sessionID:ie.id}).catch(()=>null);if(!It){ze.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(It.length===0){ze.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Kt,es=0;if(Be&&n.children.length>0){const qt=await Cr(n.children);Kt=qt.children,es=qt.skipped}const cs=gu(It,Le.title??null,Kt),Vt=xu(Le.title??null),Ls=await bu(cs,Vt);if(Ls){ze.success(e("sessions.sidebar.session.export.success"),{action:{label:e(Ug()),onClick:()=>{Vg(Ls).then(qt=>{qt||ze.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),N(es);return}yu(cs,Vt),ze.success(e("sessions.sidebar.session.export.success")),N(es)},[Cr,jt,n.children,Le.title,ie.id,tt,N,e]),Ve=wu(),dt=c.useMemo(()=>vu(Ve),[Ve]),Tt=c.useCallback(Be=>{uf({entry:Be,t:e,session:{id:ie.id,title:Le.title,directory:tt},loadRecords:()=>tt?jt({directory:tt,sessionID:ie.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>ze.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[jt,Le.title,ie.id,tt,e]),Et=c.useCallback(async()=>{if(n.children.length>0){st(!0),Qe(!0);return}await ke(!1)},[ke,n.children.length]),kt=c.useCallback(()=>{tt&&jn("desktop_open_session_mini_chat_window",{sessionId:ie.id,directory:tt,apiBaseUrl:mn(),clientToken:Ur()}).catch(Be=>{console.warn("[session-sidebar] failed to open mini chat window",Be)})},[ie.id,tt]);if(c.useEffect(()=>{if(!We)return;const Be=It=>{const es=(It.target instanceof HTMLElement?It.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Ie)}"]`);fe.current&&!es&&le.current(M.current)};return document.addEventListener("mousedown",Be),()=>document.removeEventListener("mousedown",Be)},[We,Ie]),c.useLayoutEffect(()=>{if(!We){_.current===Ie&&(_.current=null);return}_.current!==Ie&&(_.current=Ie,ee.current=!0)},[g,We,Ie]),c.useLayoutEffect(()=>{if(!We||!ee.current)return;const Be=oe.current;!Be||Be.value!==g||(ee.current=!1,Be.focus(),Be.select())},[g,We,W]),We){const Be=s.jsxs("form",{ref:fe,"data-session-rename-form":Ie,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:It=>{It.preventDefault(),S(W)},children:[s.jsx("input",{ref:oe,value:W,onChange:It=>j(It.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:It=>Ui(It,w)}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:w,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(O,{name:"close",className:"size-3.5"})})]});return Pe?s.jsx("div",{style:{paddingLeft:Lr+4},className:Me("group relative my-0.5 flex items-center rounded-md pr-2.5",Oe?"py-1":"py-1.5",ht&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(qc,{compact:Oe,project:Q,projectLabel:Ce,title:Be,titleClassName:"text-foreground",branchLabel:Se,statusDot:null,pinnedMarker:null,timeSlot:Xs,directoryIndicator:null,prBadge:et?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 typography-micro",style:it?{color:it}:void 0,children:[s.jsx(O,{name:"git-pull-request",className:"h-3 w-3",style:it?{color:it}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",et.number]})]}):null,zombieIndicator:null,badges:null,hideMetaOnHoverClass:""})},ie.id):s.jsx("div",{style:{paddingLeft:ed+r*bo},className:"group relative my-0.5 flex items-center rounded-sm py-1 pr-1.5",children:s.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:Be})},ie.id)}const Ht=Gt.length,os=ns===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:ns}),Xt=M2({actionsAlwaysVisible:I&&!pe,menuOpen:Es,hideOnHoverClass:de}),Hs=!lt&&!gt&&Tn&&!ht,vs=gt||Hs,gi=e(gt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),Mn=s.jsx(Oa,{state:gt?"running":"unread",label:gi}),so=(gt||Hs)&&Ct,km=!I&&Dt&&(lt||vs||Pt),ul=Pt&&!lt&&!vs,fl=s.jsx(O,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),Cm=lt||vs||ul?s.jsx("span",{style:{left:Lr+r*bo},className:Me("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",km?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:lt?s.jsx(O,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Ue?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):vs?Mn:ul?fl:null}):null,Nm=Dt&&!I&&(lt||vs||Pt),Am=Dt?s.jsx("span",{role:"button",tabIndex:0,onClick:Be=>{Be.stopPropagation(),Be.currentTarget.blur(),C(fs)},onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),Be.stopPropagation(),C(fs))},style:{minWidth:14,minHeight:14,left:Lr+r*bo},className:Me("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",Nm?"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(Ts?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:Ts?s.jsx(O,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(O,{name:"arrow-right-s",className:"h-3 w-3"})}):null,xi=De?s.jsx(O,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Pm=Be=>{Be.preventDefault(),Be.stopPropagation(),Rn()},Dm=Be=>{Be.preventDefault(),Be.stopPropagation()},Im=Be=>{Be.preventDefault(),Be.stopPropagation()},bi=Be=>{Be.preventDefault(),Be.stopPropagation()},yi=Be=>{Be.preventDefault(),Be.stopPropagation()},Tm=Be=>{Be.preventDefault(),Be.stopPropagation(),F(null),E(ie,{archivedBucket:d})},Em=Be=>{Be.preventDefault(),Be.stopPropagation(),F(null),E(ie,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Rm=Be=>{Be.preventDefault(),Be.stopPropagation()},Mm=Be=>{Be.preventDefault(),Be.stopPropagation()},Om=Be=>{Be.preventDefault(),Be.stopPropagation(),U?.vscode?.executeCommand("openchamber.openSessionInEditor",ie.id,Ot)},ml=Be=>{if(ne.current){ne.current=!1;return}if(mt){if(Be?.preventDefault(),Be?.stopPropagation(),Be?.shiftKey){const It=me?.getEntries(),Kt=It??Array.from(document.querySelectorAll("[data-session-row]")).map(Vt=>Vt.getAttribute("data-session-row")).filter(Vt=>!!Vt).map(Vt=>({id:Vt,rowKey:Vt,scopeKey:At,archived:d})),es=It?ss.getState().anchorRowKey:ss.getState().anchorId,cs=new Map;cs.set(ie.id,V(n)),se(es,Ie,Kt,me?.getDescendantIds()??[],At,cs);return}ft(ie.id,At,V(n),Ie);return}Be?.currentTarget&&bk(Be.currentTarget),v(ie.id,tt)},Bm=Be=>{Be.defaultPrevented||(Be.target instanceof HTMLElement?Be.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||ml(Be)},Fm=Be=>{(Be.button===2||Be.button===0&&Be.ctrlKey&&!mt)&&(ne.current=!0)},Lm=Be=>{Y&&Be.pointerType==="touch"&&G(!0),Be.button===0&&!ht&&!mt&&!Xe&&tt&&!ta(ie.id,tt).renderable&&we({directory:tt,sessionID:ie.id}).catch(()=>{})},hl=Be=>{Y&&Be.pointerType==="touch"&&G(!1)},_m=Be=>{Qt.current=Be,Mt.current+=1;const It=Mt.current;if(!Be){Nt(!1),Ft(!1);return}const Kt=L({projectId:o??null,sourceDirectory:tt,currentWorktree:_e});Je(Kt.cachedTargets),Nt(!0),Ft(!1),Kt.refreshTargets.then(es=>{!Qt.current||Mt.current!==It||(Je(es),Nt(!1),Ft(!1))}).catch(()=>{!Qt.current||Mt.current!==It||(Nt(!1),Ft(!0))})},pl=({Item:Be,Separator:It,Sub:Kt,SubTrigger:es,SubContent:cs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Be,{onClick:()=>{J.current={id:ie.id,title:Ot}},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(ca,{sessionID:ie.id,directory:tt,open:Es,Item:Be}),s.jsxs(Be,{onClick:()=>T(ie.id),className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Be,{onClick:()=>tt&&ae({directory:tt,sessionId:ie.id}),className:"[&>svg]:mr-1",children:[Pt?s.jsx(O,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(O,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(Pt?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),s.jsxs(Be,{onClick:()=>{Et()},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),dt.map(Vt=>s.jsxs(Be,{onClick:()=>Tt(Vt),className:"[&>svg]:mr-1",children:[s.jsx(Xr,{icon:Vt.icon,iconSrc:Vt.iconSrc,className:"mr-1 size-4"}),Vt.action.label]},`${Vt.guest.id}:${Vt.action.id}`)),Pe&&o&&X?s.jsxs(Be,{onClick:()=>X(o),className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,I2({isSubtaskSession:In,archivedBucket:!!d,isVSCode:pe,sessionDirectory:tt})?(()=>{const Vt=T2({sessionDirectory:tt,isStreaming:gt,isMovingToWorktree:He}),Ls=gk({targets:Ge,isRefreshing:at,loadFailed:Bt});return s.jsxs(Kt,{onOpenChange:_m,children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs(es,{disabled:Vt,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":ie.id,children:[s.jsx(O,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(wt,{side:"right",className:"max-w-72",children:e(He?"sessions.sidebar.session.moveToWorktree.tooltipMoving":gt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(cs,{className:"min-w-[220px]","data-session-worktree-submenu":ie.id,children:[Ge.map(qt=>{const _s=xt(qt.metadata.path??null)??qt.metadata.path,Ar=qt.isPrimary?e("sessions.sidebar.session.moveToWorktree.main"):qt.metadata.label||qt.metadata.branch||qt.metadata.name||qt.metadata.path,is=qt.isCurrent||qt.metadata.worktreeStatus!=="ready";return s.jsxs(Be,{disabled:is,title:qt.metadata.path,"data-session-worktree-target":_s,onClick:()=>{is||!tt||ua({kind:"existing",root:Le,descendants:Fe(n),sourceDirectory:tt,destination:qt.metadata,messages:da(e,{success:"sessions.sidebar.session.moveToWorktree.existingSuccess",failure:"sessions.sidebar.session.moveToWorktree.existingFailed"})})},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate",children:[s.jsx("span",{className:"truncate",children:Ar}),qt.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),qt.isCurrent?s.jsx(O,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},_s)}),Ls.refreshState==="loading"?s.jsx(Be,{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,Ls.refreshState==="error"?s.jsx(Be,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(It,{}),s.jsxs(Be,{disabled:Vt,"data-session-worktree-new-action":"true",onClick:()=>{Vt||!tt||ua({kind:"quick",root:Le,descendants:Fe(n),sourceDirectory:tt,messages:da(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,nr?s.jsxs(Be,{onClick:()=>kr(!0),className:"[&>svg]:mr-1",children:[s.jsx(uk,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,tt&&!d&&!Pe?(()=>{const Vt=[],Ls=is=>{const ms=xt(is??null);ms&&!Vt.includes(ms)&&Vt.push(ms)};if(o&&!pe){const is=zt.getState().projects.find(ir=>ir.id===o),ms=xt(is?.path??null);Ls(ms),ms&&(nt.getState().availableWorktreesByProject.get(ms)??[]).forEach(ir=>Ls(ir.path))}Ls(Ha(tt)),Ls(tt);const qt=Vt.flatMap(is=>re(is).map(ms=>({scope:is,folder:ms}))),_s=qt.find(({scope:is,folder:ms})=>he(is,ie.id)===ms.id)??null,Ar=Vt[0]??tt;return s.jsxs(s.Fragment,{children:[s.jsx(It,{}),s.jsxs(Kt,{children:[s.jsxs(es,{className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(cs,{className:"min-w-[180px]",children:[qt.length===0?s.jsx(Be,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):qt.map(({scope:is,folder:ms})=>{const ir=_s?.folder.id===ms.id;return s.jsxs(Be,{onClick:()=>{if(ir){ce(is,ie.id);return}_s&&_s.scope!==is&&ce(_s.scope,ie.id),Te(is,ms.id,ie.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:ms.name}),ir?s.jsx(O,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ms.id)}),s.jsx(It,{}),s.jsxs(Be,{onClick:()=>{const is=B(Ar);is&&(ue.current=!0,_s&&_s.scope!==Ar&&ce(_s.scope,ie.id),Te(Ar,is.id,ie.id))},children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),_s?s.jsxs(Be,{onClick:()=>{ce(_s.scope,ie.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,pe?null:s.jsxs(Be,{disabled:!tt,onClick:()=>{tt&&ve(tt,{mode:"chat",dedupeKey:`session:${ie.id}`,label:Ot,sessionTitleFallback:Ot})},className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),Ne?s.jsxs(Be,{disabled:!tt,onClick:kt,className:"[&>svg]:mr-1",children:[s.jsx(O,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(It,{}),d?null:s.jsxs(Be,{className:"[&>svg]:mr-1",onClick:()=>E(ie,{archivedBucket:d}),children:[s.jsx(O,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Be,{className:"[&>svg]:mr-1",onClick:()=>$(ie),children:[s.jsx(O,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Be,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>E(ie,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(O,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),$m=Be=>{Be.preventDefault(),Be.stopPropagation(),tt&&ae({directory:tt,sessionId:ie.id})},wi=I?"h-6 w-6":Pe&&!Oe?"h-5 w-5":"h-4 w-4",no=I?"h-3.5 w-3.5":Pe&&!Oe?"h-3 w-3":"h-2.5 w-2.5",Nr=Zt&&!gt&&!ht?Hg(Le):null,vi=Nr?e("sessions.sidebar.session.status.nextStep",{suggestion:Nr}):"",zm=Pe&&!Oe,gl=Be=>{if(!Nr)return null;const It=s.jsx("span",{className:Me("inline-flex flex-shrink-0 items-center text-status-info",Be),"aria-label":vi,children:s.jsx(O,{name:"pencil-ai-2",className:"h-3 w-3"})});return zm?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:It}),s.jsx(wt,{side:"top",sideOffset:6,className:"max-w-xs",children:s.jsx("p",{children:vi})})]}):It},Wm=Ht>0||ns>0||Nr?s.jsxs(s.Fragment,{children:[gl(),Ht>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(O,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ht})]}):null,ns>0?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 rounded bg-status-info/10 px-1 py-0.5 text-[0.7rem] text-status-info",title:os,"aria-label":os,children:[s.jsx(O,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:ns})]}):null]}):null,Km=Pe&&et?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 items-center gap-1 rounded typography-micro hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:no-underline",style:it?{color:it}:void 0,disabled:!et.url,"aria-label":pt?`#${et.number} · ${pt}`:`#${et.number}`,onPointerDown:bi,onMouseDown:yi,onClick:Be=>{Be.preventDefault(),Be.stopPropagation(),et.url&&Qr(et.url)},onKeyDown:Be=>Be.stopPropagation(),children:[s.jsx(O,{name:"git-pull-request",className:"h-3 w-3",style:it?{color:it}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",et.number]})]})}),s.jsx(wt,{side:"top",sideOffset:6,children:s.jsx("p",{children:pt?`#${et.number} · ${pt}`:`#${et.number}`})})]}):null,Vm=Pe?s.jsx(qc,{compact:Oe,project:Q,projectLabel:Ce,title:$r(Ot,p),titleClassName:ht||qe?"text-interactive-selection-foreground":Tn?"text-foreground":"text-foreground/80",branchLabel:Se,statusDot:vs?Mn:null,pinnedMarker:Pt&&!lt?fl:null,timeSlot:so?s.jsx(ji,{sessionId:ie.id,running:gt,className:"typography-micro"}):Xs,directoryIndicator:!d&&tt?s.jsx(Yr,{directory:tt}):null,prBadge:Km,zombieIndicator:xi,badges:Wm,providerId:Le.model?.providerID??null,metaPaddingClass:I?H?"pr-19":"pr-13":void 0,hideMetaOnHoverClass:I&&!pe?"":Me(de,Es&&"opacity-0")}):null,Um=s.jsx(Ds,{align:"end",className:"min-w-[180px]",finalFocus:()=>ue.current?(ue.current=!1,!1):!z.current,children:pl({Item:_t,Separator:gs,Sub:qg,SubTrigger:Yg,SubContent:Qg})}),Hm=s.jsx(oa,{children:s.jsx(ia,{className:"app-region-no-drag z-50",children:s.jsx(aa,{"data-slot":"dropdown-menu-content",finalFocus:()=>ue.current?(ue.current=!1,!1):!z.current,style:{color:"var(--surface-elevated-foreground)"},className:Me(Gi,"min-w-[180px]"),children:pl({Item:({className:Be,...It})=>s.jsx(sf,{className:Me(cu,Be),...It}),Separator:({className:Be,...It})=>s.jsx(tf,{className:Me(lu,Be),...It}),Sub:pb,SubTrigger:({className:Be,children:It,...Kt})=>s.jsxs(gb,{className:Me(Gg,Be),...Kt,children:[It,s.jsx(O,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Be,children:It,...Kt})=>s.jsx(oa,{children:s.jsx(ia,{className:"app-region-no-drag z-50",children:s.jsx(aa,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Me(Gi,Be),...Kt,children:It})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(N2,{sessionId:ie.id,dragKey:K??Ie,ownerKey:l??At,sessionDirectory:tt??null,sessionTitle:Ot,archivedBucket:d,children:s.jsxs(rf,{open:on,onOpenChange:sr,onOpenChangeComplete:ws,children:[s.jsxs(nf,{render:s.jsx("div",{"data-session-row":ie.id,"data-session-scope":At??"","data-session-archived":d?"1":"0","aria-current":ht?"page":void 0,onClick:Bm,style:{paddingLeft:Pe?Lr+4:ed+r*bo},className:Me("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",Pe&&!Oe?"py-1.5":"py-1",Pe&&!(ht||qe)&&"hover:bg-interactive-hover/60",(ht||qe)&&"bg-interactive-selection/70 text-interactive-selection-foreground",qe&&"ring-1 ring-inset ring-border")}),children:[Pe?null:Cm,Pe?null:Am,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":mt?qe:void 0,onPointerDown:Lm,onPointerUp:hl,onPointerCancel:hl,onMouseDown:Fm,onClick:Be=>ml(Be),onDoubleClick:Be=>{Be.stopPropagation(),R(ie.id,Ot)},className:Me("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring text-foreground select-none transition-[padding]",be&&"bg-interactive-hover/70",Pe?void 0:I?pe?je:Ee:Es?ge:je),children:Pe?Vm:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Me("block min-w-0 flex-1 truncate typography-ui-label font-normal",ht||qe?"text-interactive-selection-foreground":Tn?"text-foreground":"text-foreground/80"),children:$r(Ot,p)}),!d&&tt&&A==="recent"?s.jsx(Yr,{directory:tt,className:I?void 0:Es?"mr-1":pe?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,I?s.jsx("span",{className:"ml-2 inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",children:so?s.jsx(ji,{sessionId:ie.id,running:gt}):s.jsxs(s.Fragment,{children:[ts,rt?s.jsx(O,{name:"git-branch",className:Me("h-3 w-3",!it&&"text-muted-foreground/60"),style:it?{color:it}:void 0}):null,Xs]})}):so||ts||rt||A==="recent"?s.jsx("div",{className:Me("relative ml-1 flex h-4 flex-shrink-0 items-center justify-end",Es?"hidden":pe?"group-hover:hidden":"group-hover:hidden group-has-[:focus-visible]:hidden"),children:s.jsx("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-right",children:so?s.jsx(ji,{sessionId:ie.id,running:gt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[ts,rt?s.jsx(O,{name:"git-branch",className:Me("h-3 w-3",!it&&"text-muted-foreground/60"),style:it?{color:it}:void 0}):null,A==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:Xs}):null]})})}):null,gl(Xt),Ht>0?s.jsxs("span",{className:Me("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",Xt),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(O,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Ht})]}):null,ns>0?s.jsxs("span",{className:Me("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",Xt),title:os,"aria-label":os,children:[s.jsx(O,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:ns})]}):null]})})}),!pe&&!Pe?s.jsx(wt,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex min-w-44 flex-col gap-1.5 text-left text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:Ot}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:En,children:Xs})]}),Ce&&!Pe?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(O,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:Ce})]}):null,Se?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(O,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:it?{color:it}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:Se})]}):null,et&&pt?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(O,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:it?{color:it}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:it?{color:it}:void 0,children:["#",et.number," · ",pt]})]}):null,Nr?s.jsxs("div",{className:"flex min-w-0 items-start gap-1.5 text-status-info",children:[s.jsx(O,{name:"pencil-ai-2",className:"mt-0.5 h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 line-clamp-3",children:vi})]}):null]})}):null]})}),xi&&!Y&&!Pe?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:xi}):null,s.jsxs("div",{className:Me("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",Pe&&!Oe?"top-1.5 h-5":"top-1/2 -translate-y-1/2",Es||I&&!pe?"opacity-100":Me("opacity-0",Z)),children:[Pe?s.jsx("button",{type:"button",className:Me("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",wi,Pt?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-label":e(Pt?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin"),onPointerDown:bi,onMouseDown:yi,onClick:$m,onKeyDown:Be=>Be.stopPropagation(),children:s.jsx(O,{name:"pushpin",className:no})}):null,H?s.jsx(yk,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:wi,iconSizeClass:no,onPointerDown:bi,onMouseDown:yi,onArchive:Tm,onDelete:Em}):null,ye?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("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",wi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Rm,onMouseDown:Mm,onClick:Om,onKeyDown:Be=>Be.stopPropagation(),children:s.jsx(O,{name:"external-link",className:no})})}),s.jsx(wt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(Is,{open:rn,onOpenChange:tr,onOpenChangeComplete:ws,children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("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":Es?"h-4 w-4 opacity-100":Me("h-4 w-4 opacity-0",Z)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Dm,onMouseDown:Im,onClick:Pm,onKeyDown:Be=>Be.stopPropagation(),children:s.jsx(O,{name:"more-2",className:no})})}),Um]})]})]}),Hm]})}),Dt&&Ts?te:null,s.jsx(bs,{open:Ye,onOpenChange:Qe,children:s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Us,{children:[s.jsx(Bs,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(Fs,{children:or===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:or}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:or})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:xe,onChange:Be=>st(Be.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(An,{children:[s.jsx(ut,{type:"button",onClick:()=>Qe(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{type:"button",onClick:()=>{Qe(!1),ke(xe)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),nr?s.jsx(dk,{session:Le,open:rr,onOpenChange:kr}):null]},ie.id)}const td=t=>xt(t.session.directory??null),vk=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),Sk=t=>{if(!t.openSidebarMenuKey)return null;if(t.rowKey&&(t.openSidebarMenuKey===`session-menu:${t.rowKey}`||t.openSidebarMenuKey===`session-context:${t.rowKey}`))return t.node.session.id;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},sd=t=>t.menuOpenSessionId??Sk(t),yo=(t,e,n)=>e?n.has(t.node.session.id)?!0:wr(t.node,e):!1,Na=(t,e,n,r,i)=>{if(t.session.id!==e.session.id)return!0;const o=i(t);if(n.has(o)!==r.has(o)||t.children.length!==e.children.length)return!0;for(let l=0;l<t.children.length;l+=1)if(Na(t.children[l],e.children[l],n,r,i))return!0;return!1},jk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Na(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||Na(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},kk=(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&&tu(t,e),Ck=(t,e)=>{if(t.node.session.id!==e.node.session.id||!kk(t.node.session,e.node.session)||!xk(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(td(t.node)!==td(e.node))return"nodeDirectory";if(!vk(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&tm(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&jk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(yo(t,t.editingId,t.subtreeContainsEditing)||yo(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&&(yo(t,t.editingId,t.subtreeContainsEditing)||yo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=sd(t),i=sd(e);if(wr(t.node,r)||wr(e.node,i))return"openSidebarMenuKey"}return t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.handleCopySessionId===e.handleCopySessionId&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.handleDeleteSession===e.handleDeleteSession&&t.handleRestoreSession===e.handleRestoreSession&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.onEditProject===e.onEditProject&&t.children===e.children?null:"callbacks"},Nk=(t,e)=>{const n=Ck(t,e);return n===null?!0:(js(`ui.sidebar_session_node.props_changed.${n}`),!1)},Ak=c.memo(wk,Nk);function Pk(t){return t.stopPropagation()}const Dk=t=>{const{t:e}=St(),n=c.useRef(null),r=c.useRef(t.editingId),i=c.useRef(t.editTitle),o=c.useRef(t.deleteSessionConfirm);r.current=t.editingId,i.current=t.editTitle,o.current=t.deleteSessionConfirm;const l=Ae(P=>P.setSessionSwitcherOpen),a=nt(P=>P.setCurrentSession),d=nt(P=>P.updateSessionTitle),u=nt(P=>P.deleteSession),h=nt(P=>P.deleteSessions),f=nt(P=>P.archiveSession),p=nt(P=>P.archiveSessions),x=nt(P=>P.unarchiveSession),{mobileVariant:b,allowReselect:k,onSessionSelected:y,resetSessionSearch:m,descendantIds:g,showDeletionDialog:j,setDeleteSessionConfirm:S,setEditingId:w,setEditingRowKey:C,editingSessionId:v,editingOccurrenceKey:R,setEditTitle:T}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const D=c.useCallback((P,A)=>{if(Ki("navigation.session_select"),Ae.getState().closeMainSurfaces(),b&&l(!1),P===nt.getState().currentSessionId){k&&y?.(P),m();return}Ki("navigation.session_state_set"),a(P,A??null),y?.(P),m()},[k,b,y,m,a,l]),F=c.useCallback((P,A)=>{w(P),C(R),T(A)},[R,T,w,C]),B=c.useCallback(async P=>{if(!r.current)return;const q=(P??i.current).trim();if(q)try{await d(v,q)}catch(K){console.error("[session-actions] rename failed",K),ze.error(e("sessions.sidebar.session.rename.error",{detail:su(K instanceof Error?K:new Error(String(K)),e)}))}w(null),C(null),T("")},[v,T,w,C,e,d]),E=c.useCallback(()=>{w(null),C(null),T("")},[T,w,C]),$=c.useCallback(P=>{Jn(P).then(A=>{if(A.ok){ze.success(e("sessions.sidebar.session.copyId.success"));return}ze.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>ze.error(e("sessions.sidebar.session.copyId.error")))},[e]),L=c.useCallback(async(P,A,q)=>{const K=A?.archivedBucket===!0||A?.hardDelete===!0,te=q?.descendantIds??g;await Gh(K?"delete":"archive",P,te,{archiveSession:f,archiveSessions:p,deleteSession:u,deleteSessions:h},e)},[f,p,u,h,g,e]),X=c.useCallback((P,A)=>{const q=A?.archivedBucket===!0||A?.hardDelete===!0,K=Gd(P.id,g,q);if(!j||A?.skipConfirm===!0){L(P,A,{descendantIds:K});return}S({session:P,descendantCount:K.length,descendantIds:K,archivedBucket:q})},[g,L,S,j]),Y=c.useCallback(async()=>{const P=o.current;if(!P)return;const{session:A,archivedBucket:q,descendantIds:K}=P;S(null),await L(A,{archivedBucket:q},{descendantIds:K})},[L,S]),I=c.useCallback(async P=>{await x(P.id)?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))},[e,x]);return c.useMemo(()=>({handleSessionSelect:D,handleSessionDoubleClick:F,handleSaveEdit:B,handleCancelEdit:E,handleCopySessionId:$,handleDeleteSession:X,handleRestoreSession:I,confirmDeleteSession:Y}),[E,$,X,I,B,F,D,Y])};function Ik(t){const e=Ze.c(71),{t:n}=St(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,h,f,p,x,b,k,y,m;if(e[0]!==i||e[1]!==n||e[2]!==r){const P=n("sessions.sidebar.session.untitled");f=bs,y=!!r,e[13]!==i?(m=q=>{q||i(null)},e[13]=i,e[14]=m):m=e[14],h=ys,b=!1,k="max-w-sm gap-5",u=Us;let A;e[15]!==n||e[16]!==r?.archivedBucket?(A=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=A):A=e[17],e[18]!==A?(x=s.jsx(Bs,{children:A}),e[18]=A,e[19]=x):x=e[19],d=Fs,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||P,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||P,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||P}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||P}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=h,e[6]=f,e[7]=p,e[8]=x,e[9]=b,e[10]=k,e[11]=y,e[12]=m}else d=e[3],u=e[4],h=e[5],f=e[6],p=e[7],x=e[8],b=e[9],k=e[10],y=e[11],m=e[12];let g;e[20]!==d||e[21]!==p?(g=s.jsx(d,{children:p}),e[20]=d,e[21]=p,e[22]=g):g=e[22];let j;e[23]!==u||e[24]!==x||e[25]!==g?(j=s.jsxs(u,{children:[x,g]}),e[23]=u,e[24]=x,e[25]=g,e[26]=j):j=e[26];let S;e[27]!==l||e[28]!==o?(S=()=>l(!o),e[27]=l,e[28]=o,e[29]=S):S=e[29];const w=!o;let C;e[30]!==o?(C=o?s.jsx(O,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(O,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=C):C=e[31];let v;e[32]!==n?(v=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=v):v=e[33];let R;e[34]!==C||e[35]!==v||e[36]!==S||e[37]!==w?(R=s.jsxs("button",{type:"button",onClick:S,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":w,children:[C,v]}),e[34]=C,e[35]=v,e[36]=S,e[37]=w,e[38]=R):R=e[38];let T;e[39]!==i?(T=()=>i(null),e[39]=i,e[40]=T):T=e[40];let D;e[41]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=D):D=e[42];let F;e[43]!==T||e[44]!==D?(F=s.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:D}),e[43]=T,e[44]=D,e[45]=F):F=e[45];let B;e[46]!==a?(B=()=>{a()},e[46]=a,e[47]=B):B=e[47];let E;e[48]!==n||e[49]!==r?.archivedBucket?(E=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=E):E=e[50];let $;e[51]!==B||e[52]!==E?($=s.jsx("button",{type:"button",onClick:B,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:E}),e[51]=B,e[52]=E,e[53]=$):$=e[53];let L;e[54]!==F||e[55]!==$?(L=s.jsxs("div",{className:"flex items-center gap-2",children:[F,$]}),e[54]=F,e[55]=$,e[56]=L):L=e[56];let X;e[57]!==R||e[58]!==L?(X=s.jsxs(An,{className:"w-full sm:items-center sm:justify-between",children:[R,L]}),e[57]=R,e[58]=L,e[59]=X):X=e[59];let Y;e[60]!==h||e[61]!==b||e[62]!==X||e[63]!==k||e[64]!==j?(Y=s.jsxs(h,{showCloseButton:b,className:k,children:[j,X]}),e[60]=h,e[61]=b,e[62]=X,e[63]=k,e[64]=j,e[65]=Y):Y=e[65];let I;return e[66]!==f||e[67]!==Y||e[68]!==y||e[69]!==m?(I=s.jsx(f,{open:y,onOpenChange:m,children:Y}),e[66]=f,e[67]=Y,e[68]=y,e[69]=m,e[70]=I):I=e[70],I}function Tk(t){const e=Ze.c(57),{t:n}=St(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let h;e[0]!==d||e[1]!==u||e[2]!==n?(h=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=h):h=e[3];const f=h;let p;e[4]!==d||e[5]!==u||e[6]!==n?(p=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=p):p=e[7];const x=p,b=!!r;let k;e[8]!==i?(k=I=>{I||i(null)},e[8]=i,e[9]=k):k=e[9];let y;e[10]!==f?(y=s.jsx(Bs,{children:f}),e[10]=f,e[11]=y):y=e[11];let m;e[12]!==x?(m=s.jsx(Fs,{children:x}),e[12]=x,e[13]=m):m=e[13];let g;e[14]!==y||e[15]!==m?(g=s.jsxs(Us,{children:[y,m]}),e[14]=y,e[15]=m,e[16]=g):g=e[16];let j;e[17]!==l||e[18]!==o?(j=()=>l(!o),e[17]=l,e[18]=o,e[19]=j):j=e[19];const S=!o;let w;e[20]!==o?(w=o?s.jsx(O,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(O,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=w):w=e[21];let C;e[22]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=C):C=e[23];let v;e[24]!==C||e[25]!==j||e[26]!==S||e[27]!==w?(v=s.jsxs("button",{type:"button",onClick:j,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":S,children:[w,C]}),e[24]=C,e[25]=j,e[26]=S,e[27]=w,e[28]=v):v=e[28];let R;e[29]!==i?(R=()=>i(null),e[29]=i,e[30]=R):R=e[30];let T;e[31]!==n?(T=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=T):T=e[32];let D;e[33]!==R||e[34]!==T?(D=s.jsx("button",{type:"button",onClick:R,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:T}),e[33]=R,e[34]=T,e[35]=D):D=e[35];let F;e[36]!==a?(F=()=>{a()},e[36]=a,e[37]=F):F=e[37];let B;e[38]!==d||e[39]!==n?(B=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=B):B=e[40];let E;e[41]!==F||e[42]!==B?(E=s.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:B}),e[41]=F,e[42]=B,e[43]=E):E=e[43];let $;e[44]!==D||e[45]!==E?($=s.jsxs("div",{className:"flex items-center gap-2",children:[D,E]}),e[44]=D,e[45]=E,e[46]=$):$=e[46];let L;e[47]!==v||e[48]!==$?(L=s.jsxs(An,{className:"w-full sm:items-center sm:justify-between",children:[v,$]}),e[47]=v,e[48]=$,e[49]=L):L=e[49];let X;e[50]!==L||e[51]!==g?(X=s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,L]}),e[50]=L,e[51]=g,e[52]=X):X=e[52];let Y;return e[53]!==b||e[54]!==X||e[55]!==k?(Y=s.jsx(bs,{open:b,onOpenChange:k,children:X}),e[53]=b,e[54]=X,e[55]=k,e[56]=Y):Y=e[56],Y}function am(t){const e=Ze.c(36),{t:n}=St(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=w=>{w||i(null)},e[0]=i,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Bs,{children:d}),e[4]=d,e[5]=u):u=e[5];let h;e[6]!==n||e[7]!==r?(h=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=h):h=e[8];let f;e[9]!==h?(f=s.jsx(Fs,{children:h}),e[9]=h,e[10]=f):f=e[10];let p;e[11]!==u||e[12]!==f?(p=s.jsxs(Us,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let x;e[14]!==i?(x=()=>i(null),e[14]=i,e[15]=x):x=e[15];let b;e[16]!==n?(b=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=b):b=e[17];let k;e[18]!==x||e[19]!==b?(k=s.jsx("button",{type:"button",onClick:x,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:b}),e[18]=x,e[19]=b,e[20]=k):k=e[20];let y;e[21]!==n?(y=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=y):y=e[22];let m;e[23]!==o||e[24]!==y?(m=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=o,e[24]=y,e[25]=m):m=e[25];let g;e[26]!==m||e[27]!==k?(g=s.jsxs(An,{children:[k,m]}),e[26]=m,e[27]=k,e[28]=g):g=e[28];let j;e[29]!==g||e[30]!==p?(j=s.jsxs(ys,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,g]}),e[29]=g,e[30]=p,e[31]=j):j=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==j?(S=s.jsx(bs,{open:l,onOpenChange:a,children:j}),e[32]=l,e[33]=a,e[34]=j,e[35]=S):S=e[35],S}const Ek=new Set;function Rk(t){const e=Ze.c(113),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:h,rowKey:f,dragKey:p,renderExtras:x,pinnedSessionIds:b,expandedParents:k,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:j,editingRowKey:S,setEditingId:w,setEditingRowKey:C,editTitle:v,setEditTitle:R,toggleParent:T,openSidebarMenuKey:D,setOpenSidebarMenuKey:F,allowReselect:B,onSessionSelected:E,resetSessionSearch:$,deleteSessionConfirm:L,setDeleteSessionConfirm:X,startFolderRename:Y,startSessionWorktreeMenuLoad:I,onEditProject:P,mobileVariant:A,alwaysShowActions:q,renderChildren:K}=t,te=r===void 0?0:r,ae=d===void 0?!1:d,re=h===void 0?"project":h,he=K===void 0?!0:K;js("ui.sidebar_tree_item.render");const ce=f??`${re}:${ae?"archived":"active"}:${n.session.id}`,Te=Ut(Fk),ve=Ut(Bk),pe=Ae(Ok),Ne=Ae(Mk);let U;if(e[0]!==n){U=[];const ie=Le=>Le.children.forEach($e=>{U.push($e.session.id),ie($e)});ie(n),e[0]=n,e[1]=U}else U=e[1];const Z=U.join(`
888
+ `);let de;e[2]!==Z?(de=Z?Z.split(`
889
+ `):[],e[2]=Z,e[3]=de):de=e[3];const ye=de;let H;e[4]!==Te||e[5]!==Y||e[6]!==ve?(H=(ie,Le)=>{if(!ie)return null;Le&&Ut.getState().collapsedFolderIds.has(Le)&&ve(Le);const $e=Te(ie,"New folder",Le);return Y(ie,$e),$e},e[4]=Te,e[5]=Y,e[6]=ve,e[7]=H):H=e[7];const je=H;let Ee;e[8]!==B||e[9]!==L||e[10]!==ye||e[11]!==v||e[12]!==j||e[13]!==ce||e[14]!==A||e[15]!==n.session.id||e[16]!==E||e[17]!==$||e[18]!==X||e[19]!==R||e[20]!==w||e[21]!==C||e[22]!==pe?(Ee={mobileVariant:A,allowReselect:B,onSessionSelected:E,resetSessionSearch:$,descendantIds:ye,showDeletionDialog:pe,setDeleteSessionConfirm:X,deleteSessionConfirm:L,editingId:j,setEditingId:w,setEditingRowKey:C,editingSessionId:n.session.id,editingOccurrenceKey:ce,editTitle:v,setEditTitle:R},e[8]=B,e[9]=L,e[10]=ye,e[11]=v,e[12]=j,e[13]=ce,e[14]=A,e[15]=n.session.id,e[16]=E,e[17]=$,e[18]=X,e[19]=R,e[20]=w,e[21]=C,e[22]=pe,e[23]=Ee):Ee=e[23];const ge=Dk(Ee),ne=x?.childRenderExtrasFor,be=n.session.directory??i;let G;e[24]!==ae||e[25]!==o||e[26]!==re||e[27]!==be?(G={groupDirectory:be,projectId:o,archivedBucket:ae,renderContext:re},e[24]=ae,e[25]=o,e[26]=re,e[27]=be,e[28]=G):G=e[28];const z=G,J=p??f??n.session.id,ue=x?.subtreeContainsEditing??Ek,le=x?.menuOpenSessionId??null,W=x?.nodeStructureKey??"",M=x?.relativeTimeTick;let _;e[29]!==B||e[30]!==q||e[31]!==z||e[32]!==ne||e[33]!==L||e[34]!==te||e[35]!==v||e[36]!==j||e[37]!==S||e[38]!==k||e[39]!==l||e[40]!==y||e[41]!==A||e[42]!==n.children||e[43]!==m||e[44]!==g||e[45]!==E||e[46]!==D||e[47]!==b||e[48]!==he||e[49]!==$||e[50]!==a||e[51]!==X||e[52]!==R||e[53]!==w||e[54]!==C||e[55]!==F||e[56]!==Y||e[57]!==I||e[58]!==T?(_=he?n.children.map(ie=>s.jsx(qo,{node:ie,pinnedSessionIds:b,expandedParents:k,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:j,editingRowKey:S,setEditingId:w,setEditingRowKey:C,editTitle:v,setEditTitle:R,toggleParent:T,openSidebarMenuKey:D,setOpenSidebarMenuKey:F,allowReselect:B,onSessionSelected:E,resetSessionSearch:$,deleteSessionConfirm:L,setDeleteSessionConfirm:X,startFolderRename:Y,startSessionWorktreeMenuLoad:I,mobileVariant:A,alwaysShowActions:q,depth:te+1,folderOwnerKey:l,selectionScopeKey:a,...z,renderExtras:ne?.(ie)},ie.session.id)):null,e[29]=B,e[30]=q,e[31]=z,e[32]=ne,e[33]=L,e[34]=te,e[35]=v,e[36]=j,e[37]=S,e[38]=k,e[39]=l,e[40]=y,e[41]=A,e[42]=n.children,e[43]=m,e[44]=g,e[45]=E,e[46]=D,e[47]=b,e[48]=he,e[49]=$,e[50]=a,e[51]=X,e[52]=R,e[53]=w,e[54]=C,e[55]=F,e[56]=Y,e[57]=I,e[58]=T,e[59]=_):_=e[59];let ee;e[60]!==q||e[61]!==ae||e[62]!==je||e[63]!==te||e[64]!==v||e[65]!==j||e[66]!==S||e[67]!==ce||e[68]!==k||e[69]!==l||e[70]!==i||e[71]!==y||e[72]!==A||e[73]!==n||e[74]!==m||e[75]!==g||e[76]!==P||e[77]!==D||e[78]!==b||e[79]!==o||e[80]!==re||e[81]!==u||e[82]!==a||e[83]!==ge.handleCancelEdit||e[84]!==ge.handleCopySessionId||e[85]!==ge.handleDeleteSession||e[86]!==ge.handleRestoreSession||e[87]!==ge.handleSaveEdit||e[88]!==ge.handleSessionDoubleClick||e[89]!==ge.handleSessionSelect||e[90]!==R||e[91]!==w||e[92]!==C||e[93]!==F||e[94]!==I||e[95]!==J||e[96]!==ue||e[97]!==le||e[98]!==W||e[99]!==M||e[100]!==_||e[101]!==T?(ee=s.jsx(Ak,{expandedParents:k,hasSessionSearchQuery:y,normalizedSessionSearchQuery:m,notifyOnSubtasks:g,editingId:j,editingRowKey:S,setEditingId:w,setEditingRowKey:C,editTitle:v,setEditTitle:R,handleSaveEdit:ge.handleSaveEdit,handleCancelEdit:ge.handleCancelEdit,toggleParent:T,handleSessionSelect:ge.handleSessionSelect,handleSessionDoubleClick:ge.handleSessionDoubleClick,handleCopySessionId:ge.handleCopySessionId,openSidebarMenuKey:D,setOpenSidebarMenuKey:F,createFolderAndStartRename:je,handleDeleteSession:ge.handleDeleteSession,handleRestoreSession:ge.handleRestoreSession,startSessionWorktreeMenuLoad:I,onEditProject:P,mobileVariant:A,alwaysShowActions:q,pinnedSessionIds:b,node:n,depth:te,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:ae,secondaryMeta:u,renderContext:re,rowKey:ce,dragKey:J,subtreeContainsEditing:ue,menuOpenSessionId:le,nodeStructureKey:W,relativeTimeTick:M,children:_}),e[60]=q,e[61]=ae,e[62]=je,e[63]=te,e[64]=v,e[65]=j,e[66]=S,e[67]=ce,e[68]=k,e[69]=l,e[70]=i,e[71]=y,e[72]=A,e[73]=n,e[74]=m,e[75]=g,e[76]=P,e[77]=D,e[78]=b,e[79]=o,e[80]=re,e[81]=u,e[82]=a,e[83]=ge.handleCancelEdit,e[84]=ge.handleCopySessionId,e[85]=ge.handleDeleteSession,e[86]=ge.handleRestoreSession,e[87]=ge.handleSaveEdit,e[88]=ge.handleSessionDoubleClick,e[89]=ge.handleSessionSelect,e[90]=R,e[91]=w,e[92]=C,e[93]=F,e[94]=I,e[95]=J,e[96]=ue,e[97]=le,e[98]=W,e[99]=M,e[100]=_,e[101]=T,e[102]=ee):ee=e[102];let oe;e[103]!==L||e[104]!==n.session.id||e[105]!==ge.confirmDeleteSession||e[106]!==X||e[107]!==Ne||e[108]!==pe?(oe=L?.session.id===n.session.id?s.jsx(Ik,{value:L,setValue:X,showDeletionDialog:pe,setShowDeletionDialog:Ne,onConfirm:ge.confirmDeleteSession}):null,e[103]=L,e[104]=n.session.id,e[105]=ge.confirmDeleteSession,e[106]=X,e[107]=Ne,e[108]=pe,e[109]=oe):oe=e[109];let fe;return e[110]!==ee||e[111]!==oe?(fe=s.jsxs(s.Fragment,{children:[ee,oe]}),e[110]=ee,e[111]=oe,e[112]=fe):fe=e[112],fe}function Mk(t){return t.setShowDeletionDialog}function Ok(t){return t.showDeletionDialog}function Bk(t){return t.toggleFolderCollapse}function Fk(t){return t.createFolder}const Lk=(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&&tu(t.session,e.session)&&xt(t.worktree?.path??null)===xt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,_k=(t,e)=>{if(t.node!==e.node&&!Lk(t.node,e.node)||(t.renderExtras?.nodeStructureKey??"")!==(e.renderExtras?.nodeStructureKey??"")||(t.renderExtras?.menuOpenSessionId??null)!==(e.renderExtras?.menuOpenSessionId??null)||t.renderExtras?.relativeTimeTick!==e.renderExtras?.relativeTimeTick)return!1;const n=e.node.session.id;if((t.renderExtras?.subtreeContainsEditing?.has(n)??!1)!==(e.renderExtras?.subtreeContainsEditing?.has(n)??!1)||(t.secondaryMeta?.projectLabel??null)!==(e.secondaryMeta?.projectLabel??null)||(t.secondaryMeta?.branchLabel??null)!==(e.secondaryMeta?.branchLabel??null))return!1;const r=["depth","groupDirectory","projectId","folderOwnerKey","selectionScopeKey","archivedBucket","renderContext","rowKey","dragKey","renderChildren","hasSessionSearchQuery","normalizedSessionSearchQuery","notifyOnSubtasks","editingId","editingRowKey","editTitle","openSidebarMenuKey","mobileVariant","alwaysShowActions","allowReselect","pinnedSessionIds","expandedParents","deleteSessionConfirm","setEditingId","setEditingRowKey","setEditTitle","toggleParent","setOpenSidebarMenuKey","startSessionWorktreeMenuLoad","onEditProject","onSessionSelected","resetSessionSearch","setDeleteSessionConfirm","startFolderRename"];for(const i of r)if(t[i]!==e[i])return!1;return!0},qo=c.memo(Rk,_k),$k=24,zk=t=>Array.from({length:Math.min(t,$k)},(e,n)=>n),Wk=(t,e,n)=>{const r=new Set(t);for(const i of e)i>=0&&i<n&&r.add(i);return[...r].sort((i,o)=>i-o)},Kk=(t,e)=>t.find(n=>n.end>e)?.index??0;function nd(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function Vk({model:t,scrollElement:e,pinnedRowIndexes:n,renderRow:r,onFirstVisibleIndexChange:i}){const o=t.rows,l=c.useCallback(()=>e,[e]),a=c.useCallback(y=>o[y]?.estimateSize??32,[o]),d=c.useCallback(y=>o[y]?.key??y,[o]),u=c.useCallback(y=>Wk(Pb(y),n,o.length),[n,o.length]),h=Ab({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=h.getVirtualItems(),p=e?h.getTotalSize():0,x=e?Math.max(p-e.clientHeight,0):0,b=e?Math.min(e.scrollTop,x):0,k=Kk(f,b);if(c.useLayoutEffect(()=>{i(k)},[k,i]),!e){const y=zk(o.length),m=y.reduce((j,S)=>j+(o[S]?.estimateSize??0),0),g=o.reduce((j,S)=>j+S.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[y.map(j=>{const S=o[j];return S?s.jsx("div",{className:nd(S,o[j+1]),children:r(S,j)},S.key):null}),g>m?s.jsx("div",{"aria-hidden":"true",style:{height:g-m}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:p,position:"relative"},children:f.map(y=>{const m=o[y.index];return m?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${nd(m,o[y.index+1])??""}`,"data-index":y.index,"data-sidebar-virtual-start":y.start,ref:h.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${y.start}px)`},children:r(m,y.index)},m.key):null})})}const Uk={chats:"chat-4","active-now":"history",timeline:"folder"},rd={chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},Hk=t=>{const e=Ze.c(48),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:h}=St(),f=n==="chats";if(u){const B=i?void 0:l;let E;e[0]===Symbol.for("react.memo_cache_sentinel")?(E=Me("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]=E):E=e[0];const $=!r,L=rd[n];let X;e[1]!==h||e[2]!==L?(X=h(L),e[1]=h,e[2]=L,e[3]=X):X=e[3];let Y;e[4]!==X?(Y=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:X}),e[4]=X,e[5]=Y):Y=e[5];let I;e[6]!==r||e[7]!==i?(I=i?null:s.jsx(O,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5 text-muted-foreground"}),e[6]=r,e[7]=i,e[8]=I):I=e[8];let P;return e[9]!==i||e[10]!==B||e[11]!==$||e[12]!==Y||e[13]!==I?(P=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:B,disabled:i,className:E,"aria-expanded":$,children:[Y,I]})}),e[9]=i,e[10]=B,e[11]=$,e[12]=Y,e[13]=I,e[14]=P):P=e[14],P}const p=i?void 0:l,x=f?"pr-10":"pr-3.5";let b;e[15]!==x?(b=Me("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",x),e[15]=x,e[16]=b):b=e[16];const k=!r,y=Uk[n],m=!i&&"group-hover:hidden";let g;e[17]!==m?(g=Me("h-3.5 w-3.5 text-muted-foreground/80",m),e[17]=m,e[18]=g):g=e[18];let j;e[19]!==y||e[20]!==g?(j=s.jsx(O,{name:y,className:g}),e[19]=y,e[20]=g,e[21]=j):j=e[21];let S;e[22]!==r||e[23]!==i?(S=i?null:s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:s.jsx(O,{name:r?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}),e[22]=r,e[23]=i,e[24]=S):S=e[24];let w;e[25]!==S||e[26]!==j?(w=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[j,S]}),e[25]=S,e[26]=j,e[27]=w):w=e[27];const C=rd[n];let v;e[28]!==h||e[29]!==C?(v=h(C),e[28]=h,e[29]=C,e[30]=v):v=e[30];let R;e[31]!==v?(R=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:v}),e[31]=v,e[32]=R):R=e[32];let T;e[33]!==i||e[34]!==w||e[35]!==R||e[36]!==p||e[37]!==b||e[38]!==k?(T=s.jsxs("button",{type:"button",onClick:p,disabled:i,className:b,"aria-expanded":k,children:[w,R]}),e[33]=i,e[34]=w,e[35]=R,e[36]=p,e[37]=b,e[38]=k,e[39]=T):T=e[39];let D;e[40]!==o||e[41]!==f||e[42]!==a||e[43]!==h?(D=f?s.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),a()},className:Me("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":h("sessions.sidebar.header.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=f,e[42]=a,e[43]=h,e[44]=D):D=e[44];let F;return e[45]!==T||e[46]!==D?(F=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[T,D]}),e[45]=T,e[46]=D,e[47]=F):F=e[47],F},Gk=(t,e)=>{const n=t.groups.find(o=>o.isMain&&o.sessions.length>0)??t.groups.find(o=>o.sessions.length>0)??t.groups.find(o=>o.isMain)??t.groups[0];if(!n)return[];const r=t.groups.find(o=>o.isArchivedBucket&&o.id!==n.id);return(e.mainWorkspaceOnly?[n,...r?[r]:[]]:[...t.groups.find(o=>o.isMain)?[t.groups.find(o=>o.isMain)]:[],...t.groups.filter(o=>!o.isMain)]).map(o=>({group:o,groupKey:`${t.project.id}:${o.id}`,projectId:t.project.id,hideGroupLabel:e.mainWorkspaceOnly?o.id===n.id:o.isMain}))},qk=[],Yk=32,Qk=64,Xk=3,Jk=7,wo=32,Bn=28,od=(t,e,n,r)=>{const i=r.get(t.session.id),o=r.get(e.session.id);if(i!==void 0||o!==void 0){if(i===void 0)return 1;if(o===void 0)return-1;if(i!==o)return i-o}return Qa(t.session,e.session,n,Ua)},Li=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const h=l.node.children[u];h&&o.push({node:h,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},Zk=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,e3=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},t3=t=>{const e=[],n=[],r=[],i=[],o=[],l=new Map,a=new Map,d=t.mode==="search",u=t.pinnedSessionIds instanceof Set?t.pinnedSessionIds:new Set(t.pinnedSessionIds);let h=0;const p=[...[...t.authoritativeSections.flatMap(w=>w.groups.flatMap(C=>C.sessions)),...t.chatGroup?.sessions??[]]];for(;p.length>0;){const w=p.pop();w&&(l.set(w.session.id,w.session),p.push(...w.children))}const x=w=>{const C=a.get(w)??0;return a.set(w,C+1),C===0?w:`${w}:${C}`},b=w=>{e.push(Object.freeze(w))},k=w=>{const C=[...w.nodes].reverse().map(v=>({node:v,depth:0,directory:w.groupDirectory}));for(;C.length>0;){const v=C.pop();if(!v)continue;const R=x(`${w.containerKey}:session:${v.node.session.id}`),T=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),b({kind:"session",key:R,estimateSize:w.renderContext==="timeline"?Qk:Yk,node:v.node,depth:v.depth,projectId:w.projectId,groupDirectory:v.directory,ownerKey:w.ownerKey,selectionScopeKey:w.selectionScopeKey,archived:w.archived,renderContext:w.renderContext,secondaryMeta:w.getSecondaryMeta?w.getSecondaryMeta(v.node.session.id):w.secondaryMeta??null});const D=w.indexedNodes?.subtreeRangeByNode.get(v.node),F=D&&D[1]>D[0]+1?Object.freeze([(w.selectionPoolOffset??0)+D[0]+1,(w.selectionPoolOffset??0)+D[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:R,scopeKey:w.selectionScopeKey,archived:w.archived,descendantRange:F})),!(!d&&!t.expandedParents.has(Zk(w.renderContext,w.archived,v.node.session.id))))for(let B=v.node.children.length-1;B>=0;B-=1){const E=v.node.children[B];E&&C.push({node:E,depth:v.depth+1,directory:T})}}},y=(w,C,v,R,T)=>{const D=t.groupSearchDataByGroup.get(w);if(d&&D?.hasMatch!==!0)return;d&&D&&(h+=D.matchedSessionCount+D.folderNameMatchCount+(D.groupMatches?1:0));const F=[...d?D?.filteredNodes??[]:w.sessions].sort((ne,be)=>od(ne,be,u,t.sessionOrderIndex)),B=Li(F),E=r.length;r.push(...B.preorderIds);for(const[ne,be]of B.sessionsById)l.set(ne,be);const $=Kn(v,w.directory),L=!d&&t.collapsedGroups.has(C);if(!R){const ne=B.preorderIds.flatMap(be=>B.sessionsById.get(be)??[]);b({kind:"group-header",key:`${C}:header`,estimateSize:wo,group:w,groupKey:C,projectId:v,collapsed:L,forceExpanded:d,allSessions:Object.freeze(ne)})}if(L)return;const X=qr(w).flatMap(({scopeKey:ne,directory:be})=>(t.foldersMap[ne]??qk).map(G=>({folder:G,scopeKey:ne,scopeDirectory:be,ownerKey:$,nodes:ja(G.sessionIds,B.byId).sort((z,J)=>od(z,J,u,t.sessionOrderIndex))}))),Y=em(X.map(ne=>({id:ne.folder.id,name:ne.folder.name,parentId:ne.folder.parentId,nodeCount:ne.nodes.length})),{archivedBucket:w.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),I=X.filter(ne=>Y.has(ne.folder.id)),P=new Map(I.map(ne=>[_n(ne.scopeKey,ne.folder.id),ne])),A=new Map;for(const ne of I){if(!ne.folder.parentId)continue;const be=_n(ne.scopeKey,ne.folder.parentId),G=A.get(be)??[];G.push(ne),A.set(be,G)}const q=Zf(I.map(ne=>({...ne.folder,scopeKey:ne.scopeKey}))).map(ne=>P.get(_n(ne.scopeKey??"",ne.id))).filter(ne=>!!ne),K=new Set(I.flatMap(ne=>ne.folder.sessionIds)),te=F.filter(ne=>!K.has(ne.session.id)),ae=new Map,re=q.map(ne=>({folder:ne,visited:!1})),he=new Set;for(;re.length>0;){const ne=re.pop();if(!ne)continue;const be=_n(ne.folder.scopeKey,ne.folder.folder.id);if(!ne.visited){if(he.has(be))continue;he.add(be),re.push({folder:ne.folder,visited:!0});for(const z of A.get(be)??[])re.push({folder:z,visited:!1});continue}const G=ne.folder.nodes.flatMap(z=>{const J=B.subtreeRangeByNode.get(z);return J?B.preorderIds.slice(J[0],J[1]).flatMap(ue=>B.sessionsById.get(ue)??[]):[z.session]});for(const z of A.get(be)??[])G.push(...ae.get(_n(z.scopeKey,z.folder.id))??[]);ae.set(be,Object.freeze(G))}const ce=new Set,Te=(ne,be)=>{const G=_n(ne.scopeKey,ne.folder.id);if(ce.has(G))return;ce.add(G);const z=be?`${be} / ${ne.folder.name}`:ne.folder.name,J=`${C}:folder:${G}`,ue=!d&&t.collapsedFolders.has(ne.folder.id),le=ae.get(G)??[],W=ue&&!w.isArchivedBucket?ja([...new Set(le.map(ee=>ee.id))],B.byId):[],M=$?t.folderAuthorityByOwner.get($):void 0,_=!!$&&!w.isArchivedBucket&&!al(ne.scopeKey)&&M?.complete===!0&&M.scopeKeys.includes(ne.scopeKey);if(b({kind:"folder-header",key:J,estimateSize:wo,group:w,folder:ne.folder,displayName:z,scopeKey:ne.scopeKey,scopeDirectory:ne.scopeDirectory,ownerKey:$,nodes:ne.nodes,activityNodes:W,projectId:v,archived:w.isArchivedBucket===!0,collapsed:ue,forceExpanded:d,deleteSessions:le,subFolderCount:A.get(G)?.length??0,dropEnabled:_}),$&&o.push(Object.freeze({rowKey:J,scopeKey:ne.scopeKey,folderId:ne.folder.id,ownerKey:$,enabled:_})),!ue){k({nodes:ne.nodes,containerKey:J,projectId:v,groupDirectory:ne.scopeDirectory??w.directory,ownerKey:$,selectionScopeKey:$,archived:w.isArchivedBucket===!0,renderContext:"project",indexedNodes:B,selectionPoolOffset:E});for(const ee of A.get(G)??[])Te(ee,z)}};for(const ne of q)Te(ne,"");const ve=v?t.sessionBatchSize:void 0,pe=T?.initial??ve??(t.hideDirectoryControls?10:5),Ne=T?.increment??ve??7,U=Math.max(pe,t.visibleCountByContainer.get(C)??pe),Z=ne=>T?.pinnedAlwaysVisible===!0&&Vu(u,ne.session.directory??w.directory,ne.session.id),de=te.filter(ne=>!Z(ne));let ye=U;const H=w.isArchivedBucket||d?te:te.filter(ne=>Z(ne)?!0:ye<=0?!1:(ye-=1,!0));k({nodes:H,containerKey:C,projectId:v,groupDirectory:w.directory,ownerKey:$,selectionScopeKey:$,archived:w.isArchivedBucket===!0,renderContext:T?.renderContext??"project",indexedNodes:B,selectionPoolOffset:E});const je=te.length-H.length,Ee=U-ye;!d&&!w.isArchivedBucket&&je>0?b({kind:"show-control",key:`${C}:more`,estimateSize:Bn,control:"more",containerKey:C,currentCount:Ee,increment:Ne}):!d&&!w.isArchivedBucket&&de.length>pe&&je===0&&b({kind:"show-control",key:`${C}:fewer`,estimateSize:Bn,control:"fewer",containerKey:C,currentCount:Ee,increment:Ne});const ge=t.groupStatusByKey.get(C);F.length===0&&I.length===0?ge&&ge.state!=="ready"?b({kind:"status",key:`${C}:status`,estimateSize:Bn,status:ge,group:w,groupKey:C}):b({kind:"empty",key:`${C}:empty`,estimateSize:Bn,emptyKind:w.isArchivedBucket?"archived":"group",group:w,projectId:v}):ge&&ge.state!=="ready"&&ge.state!=="loading"&&b({kind:"status",key:`${C}:status`,estimateSize:Bn,status:ge,group:w,groupKey:C})},m=w=>{const C=!d&&t.collapsedActivities.has(w),v=e.length;return b({kind:"activity-header",key:`activity:${w}:header`,estimateSize:wo,activityKey:w,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:v,kind:"activity",id:w})),C},g=t.viewMode==="timeline";if(t.chatGroup){const w=t.groupSearchDataByGroup.get(t.chatGroup);(!d||w?.hasMatch===!0)&&(m("chats")||y(t.chatGroup,"activity:chats",null,!0,g?{initial:Xk,increment:Jk,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0))}if(g){const w=t.timelineItems??[];if(w.length>0&&!m("timeline")){const v="activity:timeline";for(const R of w){const T=Li([R.node]),D=r.length;r.push(...T.preorderIds);const F=Kn(R.projectId,R.groupDirectory);k({nodes:[R.node],containerKey:v,projectId:R.projectId,groupDirectory:R.groupDirectory,ownerKey:F,selectionScopeKey:null,archived:!1,renderContext:"timeline",secondaryMeta:R.secondaryMeta,indexedNodes:T,selectionPoolOffset:D}),d&&(h+=1)}}}if(!g&&t.showRecentSection)for(const w of t.recentSections){if(w.items.length===0||m("active-now"))continue;const v=`activity:${w.key}`,R=7,T=Math.max(R,t.visibleCountByContainer.get(v)??R),D=d?w.items:w.items.slice(0,T);for(const B of D){const E=Li([B.node]),$=r.length;r.push(...E.preorderIds),k({nodes:[B.node],containerKey:v,projectId:B.projectId,groupDirectory:B.groupDirectory,ownerKey:Kn(B.projectId,B.groupDirectory),selectionScopeKey:Kn(B.projectId,B.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:B.secondaryMeta,getSecondaryMeta:B.getSecondaryMeta,indexedNodes:E,selectionPoolOffset:$}),d&&(h+=1)}const F=w.items.length-D.length;!d&&F>0?b({kind:"show-control",key:`${v}:more`,estimateSize:Bn,control:"more",containerKey:v,currentCount:D.length,increment:7}):!d&&w.items.length>R&&b({kind:"show-control",key:`${v}:fewer`,estimateSize:Bn,control:"fewer",containerKey:v,currentCount:D.length,increment:7})}let j=g?[]:t.singleProjectMode?t.sections.filter(w=>w.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const w=j.find(C=>C.project.id===t.activeProjectId)??j[0];j=w?[w]:[]}for(const w of j){const C=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(w.project.id);if(!t.showOnlyMainWorkspace){const R=e.length;b({kind:"project-header",key:`project:${w.project.id}:header`,estimateSize:wo,section:w,collapsed:C,forceExpanded:d}),i.push(Object.freeze({rowIndex:R,kind:"project",id:w.project.id}))}if(C)continue;const v=Gk(w,{mainWorkspaceOnly:t.showOnlyMainWorkspace});for(const R of v)y(R.group,R.groupKey,R.projectId,R.hideGroupLabel)}e.length===0&&b({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const S=new Map;return e.forEach((w,C)=>S.set(w.key,C)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:S,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?h:0})},lm=c.createContext(null);function id(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function s3(t){const e=Ze.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const h=c.useRef(u),f=c.useRef(null);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=g=>(h.current.add(g),f.current?.(),()=>{h.current.delete(g),f.current?.()}),e[1]=p):p=e[1];const x=p;let b;e[2]!==n||e[3]!==o||e[4]!==a?(b=()=>{const g=o.current;if(!n||a||!g)return;const j=document.createElement("div");j.dataset.sidebarCrossfadeLayer="true",j.className="pointer-events-none sticky top-0 z-30 h-0",j.style.marginBlock="0px",g.prepend(j);let S=null,w=null,C=null,v=0;const R=new Set;let T=[];const D=window.matchMedia("(prefers-reduced-motion: reduce)"),F=r3,B=()=>{C?.cancel(),C=null,w?.remove(),w=null},E=()=>{let I=null,P=-1/0;for(const{entry:A,top:q}of T)q<=g.scrollTop&&q>=P&&(P=q,I=A);if(S!==I){if(B(),S&&I&&!D.matches){const A=S.host.cloneNode(!0);A instanceof HTMLElement&&(A.inert=!0,A.setAttribute("aria-hidden","true"),A.querySelectorAll("[id]").forEach(n3),A.className="pointer-events-none absolute inset-x-0 top-0 z-30",w=A)}S&&(F(S,S.slot),S.slot.style.removeProperty("height")),S=I,j.hidden=!I,I&&(I.slot.style.height=`${I.host.getBoundingClientRect().height}px`,F(I,j),w&&(j.append(w),C=w.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),C.onfinish=B))}},$=()=>{S&&(S.slot.style.height=`${S.host.getBoundingClientRect().height}px`);const I=id(g)+g.clientTop;T=Array.from(h.current,P=>({entry:P,top:id(P.slot)-I})),E()},L=new ResizeObserver($),X=new MutationObserver(()=>{cancelAnimationFrame(v),v=requestAnimationFrame($)});L.observe(g);const Y=()=>{X.disconnect();for(const I of R)h.current.has(I)||(L.unobserve(I.host),I.slot.parentElement&&L.unobserve(I.slot.parentElement),R.delete(I));for(const I of h.current){const P=I.slot.closest("[data-sidebar-virtual-start]");P&&X.observe(P,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),R.has(I)||(L.observe(I.host),I.slot.parentElement&&L.observe(I.slot.parentElement),R.add(I))}cancelAnimationFrame(v),v=requestAnimationFrame($)};return f.current=Y,g.addEventListener("scroll",E,{passive:!0}),Y(),$(),()=>{f.current=null,cancelAnimationFrame(v),g.removeEventListener("scroll",E),L.disconnect(),X.disconnect(),B(),j.hidden=!0,S&&(F(S,S.slot),S.slot.style.removeProperty("height")),j.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=b):b=e[5];let k;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(k=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=k):k=e[10],c.useLayoutEffect(b,k);const y=n?x:null;let m;return e[11]!==l||e[12]!==y?(m=s.jsx(lm.Provider,{value:y,children:l}),e[11]=l,e[12]=y,e[13]=m):m=e[13],m}function n3(t){return t.removeAttribute("id")}function r3(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function o3(t){const e=Ze.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(i3);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const p=i.current;if(!p)return;p.append(o);const x=r({slot:p,host:o});return()=>{x(),o.remove()}},a=[o,r],e[3]=o,e[4]=r,e[5]=l,e[6]=a):(l=e[5],a=e[6]),c.useLayoutEffect(l,a);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("div",{ref:i}),e[7]=d):d=e[7];let u;e[8]!==n?(u=s.jsx("div",{...n}),e[8]=n,e[9]=u):u=e[9];let h;e[10]!==o||e[11]!==u?(h=Gm.createPortal(u,o),e[10]=o,e[11]=u,e[12]=h):h=e[12];let f;return e[13]!==h?(f=s.jsxs(s.Fragment,{children:[d,h]}),e[13]=h,e[14]=f):f=e[14],f}function i3(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function cm(t){const e=Ze.c(3),n=c.useContext(lm);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(o3,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const a3=t=>{const e=Ze.c(3),[n,r]=c.useState(!1);let i,o;return e[0]!==t?(i=()=>{if(!t){r(!1);return}let l=!0;const a=()=>{Vs.getDirectoryAvailability(t).then(d=>{l&&d!=="unknown"&&r(d==="missing")})};return a(),window.addEventListener("focus",a),()=>{l=!1,window.removeEventListener("focus",a)}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),c.useEffect(i,o),n},_i=t=>{const e=Ze.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,h=u===void 0?!1:u,{currentTheme:f}=Cn(),p=i?ei[i]:null,x=o?ti[o]??null:null,b=d!==void 0,k=b?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let y;e[0]!==h||e[1]!==b||e[2]!==d?(y=b?s.jsx("span",{className:Me("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(O,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=b,e[2]=d,e[3]=y):y=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==b||e[7]!==x||e[8]!==k||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==p?(m=l?s.jsx("span",{className:Me("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",b&&h?"hidden":"inline-flex",k),style:a?{backgroundColor:a}:void 0,children:s.jsx(si,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:p?s.jsx(O,{name:p,className:"h-3.5 w-3.5",style:x?{color:x}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:x?{color:x}:void 0})})}):p?s.jsx(O,{name:p,className:Me("h-3.5 w-3.5",k),style:x?{color:x}:void 0}):s.jsx(O,{name:"folder",className:Me("h-3.5 w-3.5 text-muted-foreground/80",k),style:x?{color:x}:void 0}),e[4]=h,e[5]=f,e[6]=b,e[7]=x,e[8]=k,e[9]=n,e[10]=a,e[11]=l,e[12]=p,e[13]=m):m=e[13];let g;e[14]!==y||e[15]!==m?(g=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[y,m]}),e[14]=y,e[15]=m,e[16]=g):g=e[16];let j;e[17]!==r?(j=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=j):j=e[18];let S;return e[19]!==g||e[20]!==j?(S=s.jsxs(s.Fragment,{children:[g,j]}),e[19]=g,e[20]=j,e[21]=S):S=e[21],S},l3=t=>{const e=Ze.c(61),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h,isCollapsed:f,isRepo:p,hideDirectoryControls:x,alwaysShowActions:b,onToggle:k,onNewSession:y,onNewWorktreeSession:m,onManageWorktrees:g,onRenameStart:j,onClose:S,children:w,showCreateButtons:C,hideHeader:v,statusIndicator:R,openSidebarMenuKey:T,setOpenSidebarMenuKey:D,projectPickerOptions:F,onProjectSelect:B}=t,E=r===void 0?!1:r,$=C===void 0?!0:C,L=v===void 0?!1:v,X=R===void 0?null:R,{t:Y}=St(),I=a3(l);let P;e[0]!==E||e[1]!==n?(P={id:n,disabled:E},e[0]=E,e[1]=n,e[2]=P):P=e[2];const{attributes:A,listeners:q,setNodeRef:K,transform:te,transition:ae,isDragging:re}=di(P),he=c.useRef(!1),ce=`project:${n}`,Te=T===ce,[ve,pe]=c.useState(!1),Ne=!!(F&&B);let U;e[3]!==ce||e[4]!==D?(U=_=>{_&&pe(!1),D(_?ce:null)},e[3]=ce,e[4]=D,e[5]=U):U=e[5];const Z=U;let de;e[6]!==x||e[7]!==p||e[8]!==S||e[9]!==g||e[10]!==y||e[11]!==j||e[12]!==$||e[13]!==Y?(de=_=>s.jsxs(s.Fragment,{children:[$&&!p&&!x&&y&&s.jsxs(_,{onClick:y,children:[s.jsx(O,{name:"add",className:"mr-1.5 h-4 w-4"}),Y("sessions.sidebar.project.actions.newSession")]}),p&&!x&&g&&s.jsxs(_,{onClick:g,children:[s.jsx(O,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),Y("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(_,{onClick:j,children:[s.jsx(O,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),Y("sessions.sidebar.project.actions.edit")]}),s.jsxs(_,{onClick:S,className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1.5 h-4 w-4"}),Y("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=x,e[7]=p,e[8]=S,e[9]=g,e[10]=y,e[11]=j,e[12]=$,e[13]=Y,e[14]=de):de=e[14];const ye=de,H=u3,je=f3,Ee=m3;let ge;e[15]===Symbol.for("react.memo_cache_sentinel")?(ge=_=>{(_.button===2||_.button===0&&_.ctrlKey)&&(he.current=!0)},e[15]=ge):ge=e[15];const ne=ge;let be;e[16]!==k?(be=_=>{if(_.currentTarget.blur(),he.current){he.current=!1;return}k()},e[16]=k,e[17]=be):be=e[17];const G=be;let z;e[18]!==te?(z=ui.Transform.toString(te),e[18]=te,e[19]=z):z=e[19];let J;e[20]!==z||e[21]!==ae?(J={transform:z,transition:ae},e[20]=z,e[21]=ae,e[22]=J):J=e[22];const ue=re&&"opacity-30";let le;e[23]!==ue?(le=Me("relative",ue),e[23]=ue,e[24]=le):le=e[24];let W;e[25]!==b||e[26]!==A||e[27]!==I||e[28]!==Z||e[29]!==G||e[30]!==x||e[31]!==L||e[32]!==n||e[33]!==f||e[34]!==ve||e[35]!==Te||e[36]!==Ne||e[37]!==p||e[38]!==q||e[39]!==y||e[40]!==m||e[41]!==B||e[42]!==d||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==h||e[47]!==u||e[48]!==i||e[49]!==F||e[50]!==ye||e[51]!==$||e[52]!==X||e[53]!==Y?(W=L?null:s.jsx(s.Fragment,{children:s.jsxs(Jd,{open:ve,onOpenChange:pe,children:[s.jsx(Xd,{render:s.jsx(cm,{className:Me("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:_=>{x||(_.preventDefault(),pe(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...A,children:[Ne?s.jsxs(Is,{children:[s.jsx(Ps,{asChild:!0,children:s.jsxs("button",{type:"button",className:Me("flex min-w-0 flex-1 items-center gap-1.5 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-[padding]",p&&!x?b||Te?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Te?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":Y("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(_i,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h}),s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(Yr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(Ds,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:F?.map(_=>s.jsxs(_t,{onClick:()=>B?.(_.id),className:"flex items-center justify-between gap-3",title:_.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(_i,{..._})}),_.id===n?s.jsx(O,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},_.id))})]}):s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:ne,onClick:G,...q,className:Me("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md cursor-grab active:cursor-grabbing transition-[padding]",p&&!x?b||Te?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Te?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(_i,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:h,isCollapsed:f,alwaysShowActions:b}),I?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:Y("sessions.sidebar.project.folderMissing"),"aria-label":Y("sessions.sidebar.project.folderMissing"),children:s.jsx(O,{name:"alert",className:"h-3 w-3"})}):null,X?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:X}):null,l?s.jsx(Yr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(wt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Me("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",$?"right-7":"right-0.5"),children:[$&&p&&!x&&m?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),m()},className:Me("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground transition-opacity",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":Y("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(O,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Y("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,x?null:s.jsxs(Is,{open:Te,onOpenChange:Z,children:[s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:Me("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",Te?"opacity-100 pointer-events-auto":b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":Y("sessions.sidebar.project.actions.projectMenu"),onPointerDown:je,onMouseDown:Ee,onClick:H,children:s.jsx(O,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Ds,{align:"end",className:"min-w-[180px]",children:ye(_t)})]})]}),$&&y?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),y()},className:Me("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",b?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":Y(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(O,{name:"add",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Y(p?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Qd,{className:"min-w-[180px]",children:ye(zn)})]})}),e[25]=b,e[26]=A,e[27]=I,e[28]=Z,e[29]=G,e[30]=x,e[31]=L,e[32]=n,e[33]=f,e[34]=ve,e[35]=Te,e[36]=Ne,e[37]=p,e[38]=q,e[39]=y,e[40]=m,e[41]=B,e[42]=d,e[43]=o,e[44]=l,e[45]=a,e[46]=h,e[47]=u,e[48]=i,e[49]=F,e[50]=ye,e[51]=$,e[52]=X,e[53]=Y,e[54]=W):W=e[54];let M;return e[55]!==w||e[56]!==K||e[57]!==J||e[58]!==le||e[59]!==W?(M=s.jsxs("div",{ref:K,style:J,className:le,children:[W,w]}),e[55]=w,e[56]=K,e[57]=J,e[58]=le,e[59]=W,e[60]=M):M=e[60],M},c3=t=>{const e=Ze.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:h,transition:f,isDragging:p}=di(l);let x;e[3]!==a||e[4]!==u?(x={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=x):x=e[5];const b=x;let k;e[6]!==h?(k=ui.Transform.toString(h),e[6]=h,e[7]=k):k=e[7];let y;e[8]!==k||e[9]!==f?(y={transform:k,transition:f},e[8]=k,e[9]=f,e[10]=y):y=e[10];const m=p&&"opacity-50";let g;e[11]!==m?(g=Me("space-y-0.5 rounded-md",m),e[11]=m,e[12]=g):g=e[12];let j;e[13]!==i||e[14]!==b?(j=i(b),e[13]=i,e[14]=b,e[15]=j):j=e[15];let S;return e[16]!==d||e[17]!==y||e[18]!==g||e[19]!==j?(S=s.jsx("div",{ref:d,style:y,className:g,children:j}),e[16]=d,e[17]=y,e[18]=g,e[19]=j,e[20]=S):S=e[20],S},d3=c.memo(c3);function u3(t){t.stopPropagation()}function f3(t){t.stopPropagation()}function m3(t){t.stopPropagation()}const ad=[],h3=t=>{const e=Ze.c(6),{nodes:n,includeUnreadSubtasks:r,children:i}=t;let o;e[0]!==r||e[1]!==n?(o={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=o):o=e[2];const l=ll(o);let a;return e[3]!==i||e[4]!==l?(a=i(l),e[3]=i,e[4]=l,e[5]=a):a=e[5],a},$i=(t,e)=>e?t.sessions.some(n=>wr(n,e)):!1,p3=(t,e,n)=>t.sessions.some(r=>tm(r,r,e,n,t.directory,t.directory)),g3=(t,e,n)=>{const r=i=>{const o=i.session.id;return e.get(o)!==n.get(o)?!0:i.children.some(r)};return t.sessions.some(r)},x3=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",i=o=>{const l=`project:${r}:${o.session.id}`;return e.has(l)!==n.has(l)?!0:o.children.some(i)};return t.sessions.some(i)},b3=(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&&p3(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&g3(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&x3(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 n=e.group.isArchivedBucket===!0,r=Ho(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Ho(e.group.sessions,e.openSidebarMenuKey,"project",n);if(r||i)return!1}if(t.folderRename!==e.folderRename){const n=e.group.folderScopes?.map(r=>r.scopeKey)??[e.group.folderScopeKey??xt(e.group.directory??null)];if(n.includes(t.folderRename?.scopeKey??null)||n.includes(e.folderRename?.scopeKey??null))return!1}return t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.renderBody===e.renderBody&&t.notifyOnSubtasks===e.notifyOnSubtasks&&t.setEditingId===e.setEditingId&&t.setEditingRowKey===e.setEditingRowKey&&t.setEditTitle===e.setEditTitle&&t.toggleParent===e.toggleParent&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.allowReselect===e.allowReselect&&t.onSessionSelected===e.onSessionSelected&&t.resetSessionSearch===e.resetSessionSearch&&t.deleteSessionConfirm===e.deleteSessionConfirm&&t.setDeleteSessionConfirm===e.setDeleteSessionConfirm&&t.startFolderRename===e.startFolderRename&&t.startSessionWorktreeMenuLoad===e.startSessionWorktreeMenuLoad&&t.setFolderRenameDraft===e.setFolderRenameDraft&&t.clearFolderRename===e.clearFolderRename};function y3(t){const{t:e}=St(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:h,sessionBatchSize:f,collapsedGroups:p,hideDirectoryControls:x,showMoreGroupSessions:b,resetGroupSessionLimit:k,mobileVariant:y,alwaysShowActions:m,activeProjectId:g,setActiveProjectIdOnly:j,setSessionSwitcherOpen:S,openNewSessionDraft:w,pinnedSessionIds:C,sessionOrderIndex:v,notifyOnSubtasks:R,onToggleCollapsedGroup:T,dragHandleProps:D,compactBodyPadding:F=!1,expandedParents:B,editingId:E,editingRowKey:$,openSidebarMenuKey:L,editTitle:X,folderRename:Y,setFolderRenameDraft:I,clearFolderRename:P}=t,A=Ut(_e=>_e.toggleFolderCollapse),q=Ut(_e=>_e.renameFolder),K=Ut(_e=>_e.deleteFolder),te=Ut(_e=>_e.addSessionToFolder),ae=Ae(_e=>_e.showDeletionDialog),[re,he]=c.useState(null),ce=c.useCallback((_e,Ge)=>{const Je=v.get(_e.session.id),at=v.get(Ge.session.id);if(Je!==void 0||at!==void 0){if(Je===void 0)return 1;if(at===void 0)return-1;if(Je!==at)return Je-at}return Qa(_e.session,Ge.session,C,Ua)},[C,v]),Te=a?u.get(n):null,ve=a?!1:p.has(r),pe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const _e=xt(n.directory??null),Ge=n.branch?.trim();return _e&&Ge?Xo(_e,Ge):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),Ne=zu(pe),U=Ne?`var(--pr-${Ne.visualState})`:void 0,Z=ni(),de=c.useMemo(()=>{const _e=n.folderScopes?.map(Ge=>xt(Ge.directory))??[xt(n.directory??null)];return[...new Set(_e.filter(Ge=>!!Ge))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(_e=>de.length>0?Z.subscribeBootstrap(_e):()=>{},[de.length,Z]),c.useCallback(()=>de.map(_e=>`${_e}\0${Z.getBootstrapState(_e)??""}\0${Z.getBootstrapFailure(_e)??""}\0${Z.getInitializationState(_e)??""}\0${Z.getInitializationFailure(_e)??""}`).join(""),[de,Z]),c.useCallback(()=>"",[]));const ye=de.some(_e=>{const Ge=Z.getBootstrapState(_e);return Ge==="queued"||Ge==="running"}),H=de.find(_e=>Z.getBootstrapState(_e)==="failed"||Z.getInitializationState(_e)==="failed")??null,je=H!==null&&Z.getBootstrapState(H)==="failed",Ee=H?je?Z.getBootstrapFailure(H):Z.getInitializationFailure(H):void 0,ge=Ee==="os-permission"&&Vd(),[ne,be]=c.useState(!1),G=c.useCallback(()=>{H&&Z.requestBootstrap({directory:H,priority:ve?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Z,H,n.isMain,ve]),z=c.useCallback(async()=>{if(!(!H||!ge||ne)){be(!0);try{(await Ud(H)).success&&G()}finally{be(!1)}}},[ge,H,ne,G]),J=f??(x?10:5),ue=Math.max(J,h??J),le=a?Te?.groupMatches===!0:!1,W=a,M=c.useMemo(()=>[...W?Te?.filteredNodes??[]:n.sessions].sort(ce),[ce,n.sessions,Te?.filteredNodes,W]),_=n.folderScopeKey??xt(n.directory??null),ee=Kn(i,n.directory),oe=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:_?[{scopeKey:_,directory:n.directory??null}]:[],[_,n.directory,n.folderScopes]),fe=Ut(Qn(c.useCallback(_e=>oe.map(({scopeKey:Ge})=>_e.foldersMap[Ge]??ad),[oe]))),ie=c.useMemo(()=>oe.flatMap(({scopeKey:_e,directory:Ge},Je)=>(fe[Je]??ad).map(Nt=>({folder:Nt,scopeKey:_e,scopeDirectory:Ge}))),[fe,oe]),Le=Ut(Qn(c.useCallback(_e=>new Set(fe.flatMap(Ge=>Ge.filter(Je=>_e.collapsedFolderIds.has(Je.id)).map(Je=>Je.id))),[fe]))),$e=c.useMemo(()=>{const _e=new Map,Ge=Je=>{Je.forEach(at=>{_e.set(at.session.id,at),at.children.length>0&&Ge(at.children)})};return Ge(M),_e},[M]),Pe=c.useMemo(()=>ie.map(({folder:_e,scopeKey:Ge,scopeDirectory:Je})=>{const at=ja(_e.sessionIds,$e).sort(ce);return{folder:_e,scopeKey:Ge,scopeDirectory:Je,nodes:at}}),[ie,$e,ce]),Oe=c.useMemo(()=>{const _e=em(Pe.map(({folder:Ge,nodes:Je})=>({id:Ge.id,name:Ge.name,parentId:Ge.parentId,nodeCount:Je.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return Pe.filter(({folder:Ge})=>_e.has(Ge.id))},[Pe,n.isArchivedBucket,a,d]),Q=E,Ce=L,Se=c.useMemo(()=>new Set(Oe.flatMap(_e=>_e.folder.sessionIds)),[Oe]),Ke=c.useMemo(()=>M.filter(_e=>!Se.has(_e.session.id)),[M,Se]),et=c.useMemo(()=>{const _e=new Map(Oe.map(Ge=>[Ge.folder.id,Ge]));return Zf(Oe.map(Ge=>Ge.folder)).map(Ge=>_e.get(Ge.id)).filter(Ge=>!!Ge)},[Oe]),it=c.useMemo(()=>{const _e=new Map;return Oe.forEach(Ge=>{if(!Ge.folder.parentId)return;const Je=_e.get(Ge.folder.parentId)??[];Je.push(Ge),_e.set(Ge.folder.parentId,Je)}),_e},[Oe]),rt=c.useMemo(()=>{const _e=new Map(Oe.map(at=>[at.folder.id,at])),Ge=new Map,Je=(at,Nt)=>{const Bt=Ge.get(at);if(Bt!==void 0)return Bt;if(Nt.has(at))return[];Nt.add(at);const Ft=_e.get(at),Qt=Ft?[...Ft.nodes]:[];for(const Mt of it.get(at)??[])Qt.push(...Je(Mt.folder.id,Nt));return Ge.set(at,Qt),Qt};return Oe.forEach(({folder:at})=>Je(at.id,new Set)),Ge},[Oe,it]),pt="project",ht=c.useMemo(()=>{const _e=new Set;return Uc(M,Q,_e),Oe.forEach(({nodes:Ge})=>{Uc(Ge,Q,_e)}),_e},[M,Oe,Q]),tt=c.useMemo(()=>{if(!Ce)return null;const _e=Ho(M,Ce,pt,!!n.isArchivedBucket);if(_e)return _e;for(const{nodes:Ge}of Oe){const Je=Ho(Ge,Ce,pt,!!n.isArchivedBucket);if(Je)return Je}return null},[Ce,M,Oe,n.isArchivedBucket]),At=c.useCallback(_e=>{const Ge=new WeakMap,Je=at=>{Ge.set(at,Uo(at));for(const Nt of at.children)Je(Nt)};return _e.forEach(Je),Ge},[]),jt=c.useMemo(()=>At(M),[At,M]),we=c.useMemo(()=>{const _e=new WeakMap;return Oe.forEach(({nodes:Ge})=>{Ge.forEach(Je=>_e.set(Je,Uo(Je)))}),_e},[Oe]),Xe=c.useCallback(_e=>jt.get(_e)??we.get(_e)??"",[jt,we]),mt=c.useCallback(_e=>({subtreeContainsEditing:ht,menuOpenSessionId:tt,nodeStructureKey:Xe(_e)}),[ht,tt,Xe]),qe=Ke.length,ft=n.isArchivedBucket||a?Ke:Ke.slice(0,ue),se=qe-ft.length,me=!n.isArchivedBucket&&!a&&qe>J&&se===0,Ie=c.useCallback(_e=>{const Ge=[],Je=at=>{at.forEach(Nt=>{Ge.push(Nt.session),Nt.children.length>0&&Je(Nt.children)})};return Je(_e),Ge},[]),We=c.useMemo(()=>Ie(M),[Ie,M]),V=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const _e=new Map,Ge=new Map;for(const{folder:at}of Oe){if(!at.parentId)continue;const Nt=Ge.get(at.parentId)??[];Nt.push(at.id),Ge.set(at.parentId,Nt)}const Je=(at,Nt)=>{if(Nt.has(at))return[];Nt.add(at);const Bt=Oe.find(({folder:Mt})=>Mt.id===at),Ft=Bt?Ie(Bt.nodes):[],Qt=Ge.get(at)??[];for(const Mt of Qt)Ft.push(...Je(Mt,Nt));return Ft};for(const{folder:at}of Oe)_e.set(at.id,Je(at.id,new Set));return _e},[Oe,Ie,n.isArchivedBucket]);if(a&&!le&&et.length===0&&Ke.length===0)return null;const Fe=!n.isMain&&!!n.branch,Ye=n.branch&&Xg(n.branch,n.label)?{label:n.branch}:null,Qe=ve?s.jsx(m2,{nodes:M,includeUnreadSubtasks:R}):null,xe=(_e,Ge)=>{const{folder:Je,scopeKey:at,scopeDirectory:Nt,nodes:Bt}=_e,Ft=V.get(Je.id)??[],Qt=Y?.folderId===Je.id&&Y?.scopeKey===at,Mt=a?!1:Le.has(Je.id),Gt=$t=>s.jsx(Yf,{folderId:Je.id,scopeKey:at,ownerKey:ee,children:(Zt,ts)=>s.jsx(qf,{folder:Je,displayName:Ge,sessions:Bt,isCollapsed:Mt,collapsedActivityState:$t,onToggle:()=>A(Je.id),onRename:Ot=>{q(at,Je.id,Ot)},onDelete:()=>{if(n.isArchivedBucket){Qs.requestDelete({sessions:Ft,mode:"session"});return}if(!ae){K(at,Je.id);return}const Ot=Oe.filter(({folder:Pt})=>Pt.parentId===Je.id).length,Dt=Bt.length;he({scopeKey:at,folderId:Je.id,folderName:Je.name,subFolderCount:Ot,sessionCount:Dt})},groupDirectory:Nt??n.directory,projectId:i,mobileVariant:y,alwaysShowActions:m,isRenaming:Qt,renameDraft:Qt?Y?.draft:void 0,onRenameDraftChange:I,onRenameSave:()=>{const Ot=Y?.draft.trim()??"";Ot&&q(at,Je.id,Ot),P()},onRenameCancel:P,droppableRef:Zt,isDropTarget:ts,depth:0,onNewSession:()=>{i&&i!==g&&j(i),y&&S(!1),w({selectedProjectId:i,directoryOverride:Nt??n.directory,targetFolderId:Je.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:Bt.map(Ot=>s.jsx(qo,{node:Ot,pinnedSessionIds:C,expandedParents:B,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:R,editingId:E,editingRowKey:$,editTitle:X,openSidebarMenuKey:L,mobileVariant:y,alwaysShowActions:m,groupDirectory:Nt??n.directory,projectId:i,folderOwnerKey:ee,selectionScopeKey:ee,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:tt,nodeStructureKey:Xe(Ot),childRenderExtrasFor:mt},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},Ot.session.id))})},Je.id);return Mt?s.jsx(h3,{nodes:rt.get(Je.id)??Bt,includeUnreadSubtasks:R,children:Gt},Je.id):Gt(null)},st=()=>{const _e=new Map;for(const Nt of Oe){const Bt=Nt.folder.parentId;if(!Bt)continue;const Ft=_e.get(Bt);Ft?Ft.push(Nt):_e.set(Bt,[Nt])}const Ge=[],Je=new Set,at=(Nt,Bt)=>{if(Je.has(Nt.folder.id))return;Je.add(Nt.folder.id);const Ft=Bt?`${Bt} / ${Nt.folder.name}`:Nt.folder.name;Ge.push(xe(Nt,Ft)),!(!a&&Le.has(Nt.folder.id))&&(_e.get(Nt.folder.id)??[]).forEach(Mt=>at(Mt,Ft))};return et.forEach(Nt=>at(Nt,"")),Ge},Re=!!(!n.isMain&&n.worktree),ot=n.worktree?.worktreeStatus==="missing"?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:e("sessions.sidebar.group.worktreeMissing"),"aria-label":e("sessions.sidebar.group.worktreeMissing"),children:s.jsx(O,{name:"alert",className:"h-3 w-3"})}):null,vt=n.space&&n.space.state!=="complete"?s.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:s.jsx(O,{name:"alert",className:"h-3 w-3"})}):null,De=m?Re?"pr-14":"pr-7":Re?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",gt=H?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Ee==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":je?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),ge?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ne,onClick:()=>{z()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:G,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ct=_e=>s.jsx(qo,{node:_e,pinnedSessionIds:C,expandedParents:B,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:R,editingId:E,editingRowKey:$,editTitle:X,openSidebarMenuKey:L,mobileVariant:y,alwaysShowActions:m,groupDirectory:n.directory,projectId:i,folderOwnerKey:ee,selectionScopeKey:ee,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:ht,menuOpenSessionId:tt,nodeStructureKey:Xe(_e),childRenderExtrasFor:mt},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},_e.session.id),He=s.jsxs(A2,{scopeKey:oe[0]?.scopeKey??_,ownerKey:ee,hasFolders:Oe.length>0,onSessionDroppedOnFolder:(_e,Ge)=>{const Je=Oe.find(({folder:Nt,scopeKey:Bt})=>Nt.id===Ge.folderId&&Bt===Ge.scopeKey);if(!Je)return;const at=Ut.getState();for(const{scopeKey:Nt}of oe)Nt!==Je.scopeKey&&at.getSessionFolderId(Nt,_e)&&at.removeSessionFromFolder(Nt,_e);te(Je.scopeKey,Ge.folderId,_e)},children:[st(),ft.map(Ct),qe===0&&Oe.length===0?!n.isArchivedBucket&&!ye&&!gt&&n.directory&&!n.emptyMessage?s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{i&&i!==g&&j(i),y&&S(!1),w({selectedProjectId:i,directoryOverride:n.directory,target:n.draftTarget})},children:e("sessions.sidebar.group.empty.startSession")}):s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):ye?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):gt||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,qe>0&&gt?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:gt}):null,se>0?s.jsx("button",{type:"button",onClick:()=>b(r,ft.length,f??7),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,me?s.jsx("button",{type:"button",onClick:()=>k(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),Ue="pb-2",lt=s.jsx(am,{value:re,setValue:he,onConfirm:()=>{const _e=re;_e&&(K(_e.scopeKey,_e.folderId),he(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Me("oc-group-body",Ue),children:He})}),lt]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Me("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>T(r),role:"button",tabIndex:0,onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),T(r))},"aria-label":ve?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!ve,children:[s.jsxs("div",{ref:D?.setActivatorNodeRef,className:Me("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",De),...D?.listeners??{},children:[s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"typography-ui-label font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(O,{name:"archive",className:Me("h-3.5 w-3.5 shrink-0 text-muted-foreground",m?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Me("text-muted-foreground h-3.5 w-3.5 items-center justify-center",m?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ve?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:$r(n.label,d)}),ot,Qe]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(O,{name:n.space?"box-3":"git-branch",className:Me("h-3.5 w-3.5 shrink-0",!U&&"text-muted-foreground",m?"hidden":"group-hover/gh:hidden"),style:U?{color:U}:void 0,"aria-label":n.space?e("sessions.sidebar.group.space"):void 0}),s.jsx("span",{className:Me("text-muted-foreground h-3.5 w-3.5 items-center justify-center",m?"inline-flex":"hidden group-hover/gh:inline-flex"),children:ve?s.jsx(O,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(O,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:$r(n.label,d)}),ot,vt,Qe,Ne?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:U?{color:U}:void 0,children:["#",Ne.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:$r(n.label,d)}),Qe]})}),Fe&&Ye?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(O,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(O,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Ye.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(Yr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&We.length>0?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),Qs.requestDelete({sessions:We,mode:"session"})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(O,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:Me("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),Qs.requestDelete({sessions:We,mode:"worktree",worktree:n.worktree})},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(O,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:Me("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",m?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),i&&i!==g&&j(i),y&&S(!1),w({selectedProjectId:i,directoryOverride:n.directory,preserveDirectoryOverride:!!n.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:n.label}),children:s.jsx(O,{name:"add",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),!ve&&l?s.jsx("div",{className:Me("oc-group-body",Ue),children:He}):null]}),lt]})}const w3=c.memo(y3,b3),vo=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},ld=(t,e)=>$u(t.label?.trim()||Yn(t.normalizedPath,e)||t.normalizedPath);function v3(t){const e=Ze.c(104),{model:n,view:r,actions:i}=t;js("ui.sidebar_projects_list.render");const{t:o}=St(),l=ni(),a=Ut(E3),d=Ut(T3),u=Ut(I3),h=Ut(D3),f=Ae(P3),[p,x]=c.useState(null),[b,k]=c.useState(null),[y,m]=c.useState(null),[g,j]=c.useState(null),[S,w]=c.useState(!1),C=c.useRef(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={activationConstraint:{distance:8}},e[0]=v):v=e[0];let R;e[1]===Symbol.for("react.memo_cache_sentinel")?(R={activationConstraint:{delay:200,tolerance:6}},e[1]=R):R=e[1];let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:hb},e[2]=T):T=e[2];const D=oi(fn(ai,v),fn(ii,R),fn(fb,T));let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=z=>{C.current=z,j(z)},e[3]=F):F=e[3];const B=F;let E;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let z;e[7]!==r.homeDirectory?(z=J=>({id:J.project.id,projectLabel:ld(J.project,r.homeDirectory),projectDescription:Gr(J.project.normalizedPath,r.homeDirectory),projectIcon:J.project.icon,projectColor:J.project.color,projectIconImage:J.project.iconImage,projectIconBackground:J.project.iconBackground}),e[7]=r.homeDirectory,e[8]=z):z=e[8],E=n.projectSections.map(z),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=E}else E=e[6];const $=E;let L;e:{if(!r.stickyZoneHeaders){L=-1;break e}let z;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==b){let J;e[12]!==b?(J=ue=>`${ue.kind}:${ue.id}`===b,e[12]=b,e[13]=J):J=e[13],z=n.rowModel.stickyHeaders.findIndex(J),e[9]=n.rowModel.stickyHeaders,e[10]=b,e[11]=z}else z=e[11];L=z}const X=L;let Y;if(e[14]!==y||e[15]!==n.groupProps.editingRowKey||e[16]!==n.rowModel.rowIndexByKey||e[17]!==n.rowModel.rows||e[18]!==n.rowModel.stickyHeaders||e[19]!==n.state.openSidebarMenuKey||e[20]!==X){if(Y=new Set,y){let z;e[22]!==y||e[23]!==n.rowModel.rowIndexByKey?(z=n.rowModel.rowIndexByKey.get(y),e[22]=y,e[23]=n.rowModel.rowIndexByKey,e[24]=z):z=e[24];const J=z;J!==void 0&&Y.add(J)}for(let z=0;z<n.rowModel.rows.length;z=z+1,z){const J=n.rowModel.rows[z];J?.kind==="session"&&(n.groupProps.editingRowKey===J.key||n.state.openSidebarMenuKey===`session-menu:${J.key}`||n.state.openSidebarMenuKey===`session-context:${J.key}`)&&Y.add(z)}if(X>=0){const z=Math.max(0,X-1),J=Math.min(n.rowModel.stickyHeaders.length-1,X+1);for(let ue=z;ue<=J;ue=ue+1,ue){const le=n.rowModel.stickyHeaders[ue];le&&Y.add(le.rowIndex)}}e[14]=y,e[15]=n.groupProps.editingRowKey,e[16]=n.rowModel.rowIndexByKey,e[17]=n.rowModel.rows,e[18]=n.rowModel.stickyHeaders,e[19]=n.state.openSidebarMenuKey,e[20]=X,e[21]=Y}else Y=e[21];const I=Y;let P;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(P=z=>{const J=r.stickyZoneHeaders?e3(n.rowModel.stickyHeaders,z):null,ue=J?`${J.kind}:${J.id}`:null;k(le=>le===ue?le:ue)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=P):P=e[27];const A=P;let q;e[28]!==l||e[29]!==o?(q=z=>{const J=()=>{if(!z.status.directory){ri();return}l.requestBootstrap({directory:z.status.directory,priority:"expanded",reason:z.group.isMain?"project-expanded":"worktree-expanded",force:!0})},ue=async()=>{if(!z.status.directory)return;(await Ud(z.status.directory)).success&&J()};let le;e:switch(z.status.state){case"permission-denied":{le=o("sessions.sidebar.group.empty.permissionDenied");break e}case"load-failed":{le=o("sessions.sidebar.group.empty.loadFailed");break e}case"initialization-failed":{le=o("sessions.sidebar.group.empty.initializationFailed");break e}default:le=o("sessions.sidebar.group.empty.loadingSessions")}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[z.status.state==="loading"?s.jsx(O,{name:"loader-4",className:"size-3 animate-spin"}):null,le,z.status.canGrantAccess?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{ue()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,z.status.state!=="loading"?s.jsx(ut,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:J,children:o("sessions.sidebar.group.empty.retry")}):null]})})},e[28]=l,e[29]=o,e[30]=q):q=e[30];const K=q;let te;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==$||e[40]!==d||e[41]!==K||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders||e[51]!==r.timelineView||e[52]!==r.worktreeSortOrder?(te=z=>{if(z.kind==="activity-header")return s.jsx(cm,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(Hk,{activityKey:z.activityKey,collapsed:z.collapsed,forceExpanded:z.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!z.collapsed){const J=`activity:${z.activityKey}`;i.group.resetGroupSessionLimit(J),n.state.setVisibleActivityCountByKey(ue=>{if(!ue.has(J))return ue;const le=new Map(ue);return le.delete(J),le})}n.state.setCollapsedActivityKeys(J=>{const ue=new Set(J);return ue.has(z.activityKey)?ue.delete(z.activityKey):ue.add(z.activityKey),ue})},onNewChat:()=>{Ae.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:Jg,directoryOverride:null})}})});if(z.kind==="project-header"){const J=z.section.project,ue=ld(J,r.homeDirectory);return s.jsx(l3,{id:J.id,disabled:n.singleProjectMode||z.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:ue,projectDescription:Gr(J.normalizedPath,r.homeDirectory),projectDirectory:J.normalizedPath,projectIcon:J.icon,projectColor:J.color,projectIconImage:J.iconImage,projectIconBackground:J.iconBackground,isCollapsed:z.collapsed,isRepo:!!n.projectRepoStatus.get(J.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:z.collapsed?i.renderProjectStatusIndicator?.(J.id,z.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?$:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!z.forceExpanded&&!n.singleProjectMode&&i.toggleProject(J.id)},onNewSession:()=>{vo({projectId:J.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:J.id,directoryOverride:J.normalizedPath})},onNewWorktreeSession:()=>{vo({projectId:J.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!1,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewWorktreeDialog()},onManageWorktrees:()=>i.openWorktreesPage(J.id),onRenameStart:()=>i.openProjectEditDialog(J.id),onClose:()=>i.removeProject(J.id),showCreateButtons:!0})}if(z.kind==="group-header")return s.jsx(d3,{id:z.groupKey,disabled:z.forceExpanded||n.state.editingId!==null||r.worktreeSortOrder!=="manual",children:J=>s.jsx(w3,{...n.groupProps,...i.group,group:z.group,groupKey:z.groupKey,projectId:z.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get(z.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:J,renderBody:!1})});if(z.kind==="folder-header"){const J=n.groupProps.folderRename?.folderId===z.folder.id&&n.groupProps.folderRename.scopeKey===z.scopeKey;return s.jsx(Yf,{folderId:z.folder.id,scopeKey:z.scopeKey,ownerKey:z.ownerKey,disabled:!z.dropEnabled,children:(ue,le)=>s.jsx(C2,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:z.activityNodes,folder:z.folder,displayName:z.displayName,sessions:z.nodes,isCollapsed:z.collapsed,onToggle:z.forceExpanded?A3:()=>a(z.folder.id),onRename:W=>d(z.scopeKey,z.folder.id,W),onDelete:()=>{z.archived?Qs.requestDelete({sessions:[...z.deleteSessions],mode:"session"}):f?x({scopeKey:z.scopeKey,folderId:z.folder.id,folderName:z.folder.name,subFolderCount:z.subFolderCount,sessionCount:z.nodes.length}):u(z.scopeKey,z.folder.id)},renderBody:!1,groupDirectory:z.scopeDirectory??z.group.directory,projectId:z.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:J,renameDraft:J?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const W=n.groupProps.folderRename?.draft.trim();W&&d(z.scopeKey,z.folder.id,W),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:ue,isDropTarget:le,onNewSession:()=>{vo({projectId:z.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:z.scopeDirectory??z.group.directory,targetFolderId:z.folder.id,target:z.group.draftTarget})},archivedBucket:z.archived})})}if(z.kind==="session"){const J=new Set;return wr(z.node,n.state.editingId)&&J.add(z.node.session.id),s.jsx("div",{onFocusCapture:()=>m(z.key),onBlurCapture:()=>m(ue=>ue===z.key?null:ue),children:s.jsx(qo,{...n.groupProps,node:z.node,depth:z.depth,groupDirectory:z.groupDirectory,projectId:z.projectId,folderOwnerKey:z.ownerKey,selectionScopeKey:z.selectionScopeKey,archivedBucket:z.archived,renderContext:z.renderContext,rowKey:z.key,dragKey:z.key,secondaryMeta:z.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:J,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${z.key}`||n.state.openSidebarMenuKey===`session-context:${z.key}`?z.node.session.id:null,nodeStructureKey:Uo(z.node)}})})}if(z.kind==="show-control")return s.jsx("button",{type:"button",className:Me("mt-0.5 flex items-center justify-start rounded-md pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",r.timelineView?"pl-[10px]":"pl-[26px]"),onClick:()=>{z.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(J=>{const ue=new Map(J);return z.control==="more"?ue.set(z.containerKey,z.currentCount+z.increment):ue.delete(z.containerKey),ue}):z.control==="more"?i.group.showMoreGroupSessions(z.containerKey,z.currentCount,z.increment):i.group.resetGroupSessionLimit(z.containerKey)},children:o(z.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if(z.kind==="status")return K(z);if(z.emptyKind==="sidebar")return n.emptyState;if(z.emptyKind==="search")return n.searchEmptyState;if(z.emptyKind==="group"&&z.group?.directory&&!z.group.emptyMessage){const J=z.group;return s.jsx(ut,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{vo({projectId:z.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:z.projectId,directoryOverride:J.directory,target:J.draftTarget})},children:o("sessions.sidebar.group.empty.startSession")})}return s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:z.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):z.group?.emptyMessage??o("sessions.sidebar.group.empty.noSessionsInWorkspace")})},e[31]=i,e[32]=u,e[33]=n.emptyState,e[34]=n.groupProps,e[35]=n.projectRepoStatus,e[36]=n.searchEmptyState,e[37]=n.singleProjectMode,e[38]=n.state,e[39]=$,e[40]=d,e[41]=K,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=r.timelineView,e[52]=r.worktreeSortOrder,e[53]=te):te=e[53];const ae=te;let re;e[54]!==n.rowModel.rows?(re=n.rowModel.rows.flatMap(N3),e[54]=n.rowModel.rows,e[55]=re):re=e[55];const he=re;let ce;e[56]!==n.sectionsForRender?(ce=new Set(n.sectionsForRender.map(C3)),e[56]=n.sectionsForRender,e[57]=ce):ce=e[57];const Te=ce;let ve;e[58]!==n.rowModel.stickyHeaders?(ve=n.rowModel.stickyHeaders.map(k3).join(""),e[58]=n.rowModel.stickyHeaders,e[59]=ve):ve=e[59];const pe=ve,Ne=!r.timelineView;let U;e[60]!==Te?(U=z=>{w(Te.has(String(z.active.id)))},e[60]=Te,e[61]=U):U=e[61];let Z;e[62]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>w(!1),e[62]=Z):Z=e[62];let de;e[63]!==i||e[64]!==h||e[65]!==n.rowModel.folderAuthorityByOwner||e[66]!==n.rowModel.folderDropTargets||e[67]!==n.rowModel.rows||e[68]!==n.sectionsForRender||e[69]!==n.state||e[70]!==r.hasSessionSearchQuery||e[71]!==r.projectSortOrder?(de=z=>{if(w(!1),!z.over)return;const J=z.active.data.current,ue=z.over.data.current;if(J?.type==="session"&&J.sessionId&&J.ownerKey&&J.archivedBucket!==!0&&ue?.type==="folder"&&ue.folderId&&ue.scopeKey&&ue.ownerKey===J.ownerKey){const Oe=n.rowModel.folderDropTargets.find(Se=>Se.folderId===ue.folderId&&Se.scopeKey===ue.scopeKey&&Se.ownerKey===J.ownerKey),Q=n.rowModel.folderAuthorityByOwner.get(J.ownerKey);if(!Oe?.enabled||Q?.complete!==!0)return;const Ce=Ut.getState();for(const Se of Q.scopeKeys)Se!==ue.scopeKey&&Ce.removeSessionFromFolder(Se,J.sessionId);h(ue.scopeKey,ue.folderId,J.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||z.active.id===z.over.id)return;const le=String(z.active.id),W=String(z.over.id),M=n.sectionsForRender.map(j3),_=M.indexOf(le),ee=M.indexOf(W);if(_>=0&&ee>=0&&r.projectSortOrder==="manual"){i.reorderProjects(_,ee);return}const oe=n.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===le),fe=n.rowModel.rows.find(Oe=>Oe.kind==="group-header"&&Oe.groupKey===W);if(!oe||!fe||oe.projectId!==fe.projectId||!oe.projectId)return;const ie=oe.projectId,Le=n.sectionsForRender.find(Oe=>Oe.project.id===ie);if(!Le)return;const $e=Le.groups.findIndex(Oe=>Oe.id===oe.group.id),Pe=Le.groups.findIndex(Oe=>Oe.id===fe.group.id);$e<0||Pe<0||i.setGroupOrderByProject(Oe=>new Map(Oe).set(ie,Zu(Le.groups,$e,Pe).map(S3)))},e[63]=i,e[64]=h,e[65]=n.rowModel.folderAuthorityByOwner,e[66]=n.rowModel.folderDropTargets,e[67]=n.rowModel.rows,e[68]=n.sectionsForRender,e[69]=n.state,e[70]=r.hasSessionSearchQuery,e[71]=r.projectSortOrder,e[72]=de):de=e[72];let ye;e[73]!==A||e[74]!==n.rowModel||e[75]!==I||e[76]!==ae||e[77]!==g?(ye=s.jsx(Vk,{model:n.rowModel,scrollElement:g,pinnedRowIndexes:I,renderRow:ae,onFirstVisibleIndexChange:A}),e[73]=A,e[74]=n.rowModel,e[75]=I,e[76]=ae,e[77]=g,e[78]=ye):ye=e[78];let H;e[79]!==he||e[80]!==ye?(H=s.jsx(Xa,{items:he,strategy:ef,children:ye}),e[79]=he,e[80]=ye,e[81]=H):H=e[81];let je;e[82]!==D||e[83]!==U||e[84]!==de||e[85]!==H?(je=s.jsx(li,{sensors:D,collisionDetection:ci,onDragStart:U,onDragCancel:Z,onDragEnd:de,children:H}),e[82]=D,e[83]=U,e[84]=de,e[85]=H,e[86]=je):je=e[86];let Ee;e[87]!==Ne||e[88]!==je?(Ee=s.jsx(gn,{ref:B,useScrollShadow:!0,hideTopScrollShadow:Ne,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:je}),e[87]=Ne,e[88]=je,e[89]=Ee):Ee=e[89];let ge;e[90]!==S||e[91]!==Ee||e[92]!==r.stickyZoneHeaders||e[93]!==pe?(ge=s.jsx(s3,{enabled:r.stickyZoneHeaders,suspended:S,layoutKey:pe,scrollRef:C,children:Ee}),e[90]=S,e[91]=Ee,e[92]=r.stickyZoneHeaders,e[93]=pe,e[94]=ge):ge=e[94];let ne;e[95]!==u||e[96]!==p?(ne=()=>{p&&(u(p.scopeKey,p.folderId),x(null))},e[95]=u,e[96]=p,e[97]=ne):ne=e[97];let be;e[98]!==p||e[99]!==ne?(be=s.jsx(am,{value:p,setValue:x,onConfirm:ne}),e[98]=p,e[99]=ne,e[100]=be):be=e[100];let G;return e[101]!==ge||e[102]!==be?(G=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ge,be]}),e[101]=ge,e[102]=be,e[103]=G):G=e[103],G}function S3(t){return t.id}function j3(t){return t.project.id}function k3(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function C3(t){return t.project.id}function N3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function A3(){}function P3(t){return t.showDeletionDialog}function D3(t){return t.addSessionToFolder}function I3(t){return t.deleteFolder}function T3(t){return t.renameFolder}function E3(t){return t.toggleFolderCollapse}const R3=c.memo(v3),Aa=new Map,cd=(t,e)=>{for(const n of t){const r=xt(n??null);r&&!Aa.has(r)&&Aa.set(r,e)}},dd=t=>{const e=xt(t??null);return e?Aa.get(e)??0:0},Er=t=>!!t.time?.archived,M3=t=>{const{t:e}=St(),n=c.useRef(t.gitBranches);n.current=t.gitBranches;const r=c.useCallback(a=>[a.label,a.branch??"",a.description??"",a.directory??""].join(" ").toLowerCase(),[]),i=c.useCallback(a=>{const d=xt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),h=u.startsWith("ses_");return a.flatMap(f=>{if(h&&Er(f.session))return[];if(h?f.session.id.toLowerCase()===u:Bo([i(f.session)],d))return[f];const x=o(f.children,d);return x.length===0?[]:[{...f,children:x}]})},[i]),l=c.useCallback((a,d,u,h,f)=>{const p=xt(d??null),x=Fu(a),b=new Map(x.map(P=>[P.id,P])),k=new Map;x.forEach(P=>{const A=P.parentID;if(!A)return;const q=b.get(A);if(!q||Er(q)!==Er(P))return;const K=k.get(A)??[];K.push(P),k.set(A,K)});const y=Zg(u,p),m=(p&&!t.isVSCode?t.spacesByProject?.get(p):void 0)??[],g=new Map;for(const P of m){const A=xt(P.directory);A&&g.set(A,P)}const j=P=>{const A=xt(P.directory??null),q=t.worktreeMetadata.get(P.id)??null;if(q)return q;if(A){const K=y.get(A)??null;if(K&&A!==p)return K}return null},S=new Set,w=P=>{S.add(P.id);const A=k.get(P.id)??[],q=[];for(const K of A)S.has(K.id)||q.push(w(K));return{session:P,children:q,worktree:j(P)}},C=x.filter(P=>{const A=P.parentID;if(!A)return!0;const q=b.get(A);return q?Er(q)!==Er(P):!0}),v=[],R=P=>{S.has(P.id)||v.push(w(P))};C.forEach(R),x.forEach(R);const T=new Map,D="__archived__",F=P=>{if(P.time?.archived)return D;if(t.isVSCode)return p??"__project_root__";const A=t.sessionOwners?.get(P.id)?.scopeDirectory;if(A){if(A===p)return p??"__project_root__";if(y.has(A)||g.has(A))return A}const K=xt(t.worktreeMetadata.get(P.id)?.path??null)??xs(P);return K&&K!==p&&y.has(K)?K:p??"__project_root__"};v.forEach(P=>{const A=F(P.session);T.has(A)||T.set(A,[]),T.get(A)?.push(P)});const B=p??"__project_root__",E=[{id:"root",label:f&&h&&h!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:h}):e("sessions.sidebar.grouping.projectRoot"),branch:h??null,description:p?Gr(p,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:p,folderScopeKey:p,sessions:T.get(B)??[]}],$=new Map;u.forEach(P=>{const A=xt(P.path)??P.path,q=T.get(A)??[],K=q.length>0,te=q.reduce((ae,re)=>{const he=ex(re.session,t.sessionOrderRanks);return Number.isFinite(he)?Math.max(ae,he):ae},0);$.set(A,{hasActiveSession:K,lastUpdatedAt:te})});const L=(P,A)=>{const q=(P.label||P.branch||P.name||P.path||"").toLowerCase(),K=(A.label||A.branch||A.name||A.path||"").toLowerCase();return q.localeCompare(K)},X=t.worktreeSortOrder!=="recent"?[...u].sort(L):[...u].sort((P,A)=>{const q=xt(P.path)??P.path,K=xt(A.path)??A.path,te=$.get(q)??{hasActiveSession:!1,lastUpdatedAt:0},ae=$.get(K)??{hasActiveSession:!1,lastUpdatedAt:0};if(te.hasActiveSession!==ae.hasActiveSession)return te.hasActiveSession?-1:1;if(te.hasActiveSession&&ae.hasActiveSession)return ae.lastUpdatedAt-te.lastUpdatedAt;const re=dd(P.path),he=dd(A.path);return re!==he?he-re:L(P,A)});(t.isVSCode?[]:X).forEach(P=>{const A=xt(P.path)??P.path,q=n.current.get(A)?.trim()||null,K=P.branch?.trim()||null,ae=!!(q&&K&&P.label&&_l(P.label)===_l(K))?q:P.label||P.name||Yn(A,t.homeDirectory)||A;E.push({id:`worktree:${A}`,label:ae,branch:q||K,description:Gr(A,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:P,directory:A,folderScopeKey:A,sessions:T.get(A)??[]})});for(const[P,A]of g)E.push({id:`space:${A.id}`,label:A.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:A,directory:P,folderScopeKey:P,sessions:T.get(P)??[]});const I=T.get(D)??[];return I.length>0&&E.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&p?Bu(p):null,sessions:I}),E},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},O3=t=>{const e=Ze.c(60),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:h,onArchive:f,onDelete:p,onDone:x}=t,{t:b}=St(),k=n>0,y=k&&!!r&&!o;let m;e[0]!==n||e[1]!==b?(m=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=b,e[2]=m):m=e[2];let g;e[3]!==m?(g=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:m}),e[3]=m,e[4]=g):g=e[4];let j;e[5]!==y||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==b?(j=y?s.jsxs(Is,{children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(Ps,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(O,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(Ds,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(_t,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map(K=>s.jsx(_t,{onClick:()=>l(K.id),children:s.jsx("span",{className:"flex-1 truncate",children:K.name})},K.id)),s.jsx(gs,{}),s.jsxs(_t,{onClick:a,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(_t,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(O,{name:"close",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[5]=y,e[6]=u,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=b,e[12]=j):j=e[12];let S;e[13]!==o||e[14]!==k||e[15]!==h||e[16]!==b?(S=o?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:h,disabled:!k,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.restore"),children:s.jsx(O,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=k,e[15]=h,e[16]=b,e[17]=S):S=e[17];let w;e[18]!==o||e[19]!==k||e[20]!==f||e[21]!==b?(w=o?null:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!k,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":b("sessions.sidebar.bulkActions.archive"),children:s.jsx(O,{name:"archive",className:"h-4 w-4"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=k,e[20]=f,e[21]=b,e[22]=w):w=e[22];const C=!k;let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=Me("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50 disabled:pointer-events-none disabled:opacity-40"),e[23]=v):v=e[23];let R;e[24]!==b?(R=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=R):R=e[25];let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(O,{name:"delete-bin",className:"h-4 w-4"}),e[26]=T):T=e[26];let D;e[27]!==p||e[28]!==C||e[29]!==R?(D=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:p,disabled:C,className:v,"aria-label":R,children:T})}),e[27]=p,e[28]=C,e[29]=R,e[30]=D):D=e[30];let F;e[31]!==b?(F=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=F):F=e[32];let B;e[33]!==F?(B=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:F})}),e[33]=F,e[34]=B):B=e[34];let E;e[35]!==D||e[36]!==B?(E=s.jsxs(bt,{children:[D,B]}),e[35]=D,e[36]=B,e[37]=E):E=e[37];let $;e[38]!==b?($=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=$):$=e[39];let L;e[40]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(O,{name:"close",className:"h-4 w-4"}),e[40]=L):L=e[40];let X;e[41]!==x||e[42]!==$?(X=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:x,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40","aria-label":$,children:L})}),e[41]=x,e[42]=$,e[43]=X):X=e[43];let Y;e[44]!==b?(Y=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=Y):Y=e[45];let I;e[46]!==Y?(I=s.jsx(wt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Y})}),e[46]=Y,e[47]=I):I=e[47];let P;e[48]!==X||e[49]!==I?(P=s.jsxs(bt,{children:[X,I]}),e[48]=X,e[49]=I,e[50]=P):P=e[50];let A;e[51]!==E||e[52]!==P||e[53]!==j||e[54]!==S||e[55]!==w?(A=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[j,S,w,E,P]}),e[51]=E,e[52]=P,e[53]=j,e[54]=S,e[55]=w,e[56]=A):A=e[56];let q;return e[57]!==g||e[58]!==A?(q=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[g,A]}),e[57]=g,e[58]=A,e[59]=q):q=e[59],q},ud=new Map,B3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},F3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||Jf(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},L3=t=>{const e=Ze.c(89),{t:n}=St();let r;e[0]!==n?(r=le=>{const W=tx(le);return W?{description:su(W,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:h,createFolderAndStartRename:f,archiveSessions:p,unarchiveSessions:x,deleteSessions:b,bulkDeleteConfirm:k,setBulkDeleteConfirm:y}=t,m=ss(_3),g=ss($3),j=g>0,S=ss(z3),w=ss(W3),C=Xf(),v=K3,R=V3;let T;e[2]!==j||e[3]!==C||e[4]!==S?(T=j&&Jf(S,C?.getSessionsById()??ud),e[2]=j,e[3]=C,e[4]=S,e[5]=T):T=e[5];const D=T;let F;e:{if(w){F=w;break e}F=null}const B=F;let E;e[6]!==B||e[7]!==d?(E=B3(B,d),e[6]=B,e[7]=d,e[8]=E):E=e[8];const $=E;let L;if(e[9]!==a||e[10]!==$){let le;e[12]!==a?(le=W=>a[W]??[],e[12]=a,e[13]=le):le=e[13],L=$.flatMap(le),e[9]=a,e[10]=$,e[11]=L}else L=e[11];const X=L;let Y;e[14]!==a||e[15]!==$?(Y=le=>{for(const W of $)if((a[W]??[]).some(M=>M.id===le))return W;return null},e[14]=a,e[15]=$,e[16]=Y):Y=e[16];const I=Y;let P;e:{if(!j){P=!1;break e}for(const le of $)for(const W of a[le]??[])for(const M of W.sessionIds)if(S.has(M)){P=!0;break e}P=!1}const A=P;let q;e[17]!==u||e[18]!==h||e[19]!==S||e[20]!==$?(q=(le,W)=>{const M=Array.from(S);for(const _ of $)_!==le&&h(_,M);u(le,W,M)},e[17]=u,e[18]=h,e[19]=S,e[20]=$,e[21]=q):q=e[21];const K=q;let te;e[22]!==j||e[23]!==K||e[24]!==I?(te=le=>{if(!j)return;const W=I(le);W&&K(W,le)},e[22]=j,e[23]=K,e[24]=I,e[25]=te):te=e[25];const ae=te;let re;e[26]!==f||e[27]!==j||e[28]!==K||e[29]!==$?(re=()=>{const le=$[0];if(!le||!j)return;const W=f(le);W&&K(le,W.id)},e[26]=f,e[27]=j,e[28]=K,e[29]=$,e[30]=re):re=e[30];const he=re;let ce;e[31]!==j||e[32]!==h||e[33]!==S||e[34]!==$?(ce=()=>{if(!j)return;const le=Array.from(S);for(const W of $)h(W,le)},e[31]=j,e[32]=h,e[33]=S,e[34]=$,e[35]=ce):ce=e[35];const Te=ce;let ve;e[36]!==p||e[37]!==b||e[38]!==i||e[39]!==n?(ve=async(le,W)=>{if(le.length!==0)if(W){const{deletedIds:M,failedIds:_}=await b(le);M.length>0&&ze.success(M.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:M.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:M.length})),_.length>0&&ze.error(_.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:_.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:_.length}),i(_)),ss.getState().removeMany(M)}else{const{archivedIds:M,failedIds:_}=await p(le);M.length>0&&ze.success(M.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:M.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:M.length})),_.length>0&&ze.error(_.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:_.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:_.length}),i(_)),ss.getState().removeMany(M)}},e[36]=p,e[37]=b,e[38]=i,e[39]=n,e[40]=ve):ve=e[40];const pe=ve;let Ne;e[41]!==pe||e[42]!==j||e[43]!==S||e[44]!==y||e[45]!==l?(Ne=le=>{if(!j)return;const W=Array.from(S);if(!l){pe(W,le);return}y({sessionIds:W,sessionCount:W.length,archivedBucket:le})},e[41]=pe,e[42]=j,e[43]=S,e[44]=y,e[45]=l,e[46]=Ne):Ne=e[46];const U=Ne;let Z;e[47]!==D||e[48]!==U?(Z=()=>U(D),e[47]=D,e[48]=U,e[49]=Z):Z=e[49];const de=Z;let ye;e[50]!==U?(ye=()=>U(!1),e[50]=U,e[51]=ye):ye=e[51];const H=ye;let je;e[52]!==U?(je=()=>U(!0),e[52]=U,e[53]=je):je=e[53];const Ee=je;let ge;e[54]!==D||e[55]!==i||e[56]!==j||e[57]!==S||e[58]!==n||e[59]!==x?(ge=async()=>{if(!j||!D)return;const le=Array.from(S),{restoredIds:W,failedIds:M}=await x(le);W.length>0&&ze.success(W.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:W.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:W.length})),M.length>0&&ze.error(M.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:M.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:M.length}),i(M)),ss.getState().removeMany(W)},e[54]=D,e[55]=i,e[56]=j,e[57]=S,e[58]=n,e[59]=x,e[60]=ge):ge=e[60];const ne=ge;let be;e[61]!==k||e[62]!==pe||e[63]!==C||e[64]!==y?(be=async()=>{if(!k)return;const le=C?.getSessionsById()??ud,W=F3(k,le);if(!W.ready){y(W.value);return}y(null),await pe(W.value.sessionIds,W.value.archivedBucket)},e[61]=k,e[62]=pe,e[63]=C,e[64]=y,e[65]=be):be=e[65];const G=be;let z,J;e[66]!==k||e[67]!==de||e[68]!==o||e[69]!==C||e[70]!==m?(z=()=>{if(!m)return;const le=/Macintosh|Mac OS X/.test(navigator.userAgent||""),W=M=>{if(k||o)return;const _=M.target instanceof HTMLElement?M.target:null;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.isContentEditable))return;const ee=le?M.metaKey:M.ctrlKey;if(M.key==="Escape"){M.preventDefault(),ss.getState().disable();return}if(ee&&M.key==="Backspace"){M.preventDefault(),de();return}if(ee&&(M.key==="a"||M.key==="A")){const oe=D2(C?.getEntries()??[],C?.getDescendantIds()??[],ss.getState().scopeKey);if(!oe)return;M.preventDefault(),ss.getState().replaceAll(oe.ids,oe.scopeKey)}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},J=[k,de,o,C,m],e[66]=k,e[67]=de,e[68]=o,e[69]=C,e[70]=m,e[71]=z,e[72]=J):(z=e[71],J=e[72]),c.useEffect(z,J);let ue;return e[73]!==A||e[74]!==X||e[75]!==D||e[76]!==G||e[77]!==B||e[78]!==H||e[79]!==he||e[80]!==de||e[81]!==Ee||e[82]!==ae||e[83]!==Te||e[84]!==ne||e[85]!==j||e[86]!==g||e[87]!==m?(ue={selectionModeEnabled:m,hasSelection:j,selectedIdsSize:g,bulkScopeIsArchived:D,derivedSelectionScope:B,bulkScopeFolders:X,bulkCanRemoveFromFolder:A,handleToggleSelectionMode:v,handleExitSelectionMode:R,handleBulkMoveToFolder:ae,handleBulkCreateFolderAndMove:he,handleBulkRemoveFromFolder:Te,handleBulkDelete:de,handleBulkArchive:H,handleBulkHardDelete:Ee,handleBulkRestore:ne,confirmBulkDelete:G},e[73]=A,e[74]=X,e[75]=D,e[76]=G,e[77]=B,e[78]=H,e[79]=he,e[80]=de,e[81]=Ee,e[82]=ae,e[83]=Te,e[84]=ne,e[85]=j,e[86]=g,e[87]=m,e[88]=ue):ue=e[88],ue};function _3(t){return t.enabled}function $3(t){return t.selectedIds.size}function z3(t){return t.selectedIds}function W3(t){return t.scopeKey}function K3(){ss.getState().toggleMode()}function V3(){ss.getState().disable()}function U3(t){const e=Ze.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=Ae(e4),d=Ae(Z3),u=Ut(J3),h=Ut(X3),f=Ut(Q3),p=Ut(Y3),x=nt(q3),b=nt(G3),k=nt(H3);let y;e[0]!==h||e[1]!==i?(y=C=>{const v=h(C,"New folder");return i(C,v),v},e[0]=h,e[1]=i,e[2]=y):y=e[2];let m;e[3]!==f||e[4]!==x||e[5]!==o||e[6]!==k||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==p||e[11]!==a||e[12]!==y||e[13]!==b?(m={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:p,createFolderAndStartRename:y,archiveSessions:x,unarchiveSessions:b,deleteSessions:k,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=x,e[5]=o,e[6]=k,e[7]=u,e[8]=n,e[9]=r,e[10]=p,e[11]=a,e[12]=y,e[13]=b,e[14]=m):m=e[14];const g=L3(m);let j;e[15]!==g.bulkCanRemoveFromFolder||e[16]!==g.bulkScopeFolders||e[17]!==g.bulkScopeIsArchived||e[18]!==g.derivedSelectionScope||e[19]!==g.handleBulkArchive||e[20]!==g.handleBulkCreateFolderAndMove||e[21]!==g.handleBulkHardDelete||e[22]!==g.handleBulkMoveToFolder||e[23]!==g.handleBulkRemoveFromFolder||e[24]!==g.handleBulkRestore||e[25]!==g.handleExitSelectionMode||e[26]!==g.selectedIdsSize||e[27]!==g.selectionModeEnabled?(j=g.selectionModeEnabled?s.jsx(O3,{selectedCount:g.selectedIdsSize,scopeKey:g.derivedSelectionScope,scopeFolders:g.bulkScopeFolders,archivedBucket:g.bulkScopeIsArchived,onMoveToFolder:g.handleBulkMoveToFolder,onCreateFolderAndMove:g.handleBulkCreateFolderAndMove,onRemoveFromFolder:g.handleBulkRemoveFromFolder,canRemoveFromFolder:g.bulkCanRemoveFromFolder,onRestore:g.handleBulkRestore,onArchive:g.handleBulkArchive,onDelete:g.handleBulkHardDelete,onDone:g.handleExitSelectionMode}):null,e[15]=g.bulkCanRemoveFromFolder,e[16]=g.bulkScopeFolders,e[17]=g.bulkScopeIsArchived,e[18]=g.derivedSelectionScope,e[19]=g.handleBulkArchive,e[20]=g.handleBulkCreateFolderAndMove,e[21]=g.handleBulkHardDelete,e[22]=g.handleBulkMoveToFolder,e[23]=g.handleBulkRemoveFromFolder,e[24]=g.handleBulkRestore,e[25]=g.handleExitSelectionMode,e[26]=g.selectedIdsSize,e[27]=g.selectionModeEnabled,e[28]=j):j=e[28];let S;e[29]!==g.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(S=s.jsx(Tk,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:g.confirmBulkDelete}),e[29]=g.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=S):S=e[33];let w;return e[34]!==j||e[35]!==S?(w=s.jsxs(s.Fragment,{children:[j,S]}),e[34]=j,e[35]=S,e[36]=w):w=e[36],w}function H3(t){return t.deleteSessions}function G3(t){return t.unarchiveSessions}function q3(t){return t.archiveSessions}function Y3(t){return t.removeSessionsFromFolders}function Q3(t){return t.addSessionsToFolder}function X3(t){return t.createFolder}function J3(t){return t.foldersMap}function Z3(t){return t.setShowDeletionDialog}function e4(t){return t.showDeletionDialog}const dm="oc.sessions.expandedParents.v3",t4=Ja(Xn()),s4=()=>{try{const t=globalThis.localStorage.getItem(dm);if(t===null)return new Set;const e=t4.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},n4=()=>{const[t,e]=c.useState(s4),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=sx(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(dm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},r4=t=>{const e=Ze.c(22),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t,l=us(o4),a=us(i4);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(a4),...i?[{key:"activity:chats",group:i}]:[]].map(d4),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let h;e[3]!==u?(h=new Set(u.flatMap(u4)),e[3]=u,e[4]=h):h=e[4];let f;e[5]!==h?(f=[...h],e[5]=h,e[6]=f):f=e[6];const p=f;let x;e[7]!==n||e[8]!==p.length?(x=j=>p.length>0?n.subscribeBootstrap(j):f4,e[7]=n,e[8]=p.length,e[9]=x):x=e[9];let b;e[10]!==n||e[11]!==p?(b=()=>p.map(j=>`${j}\0${n.getBootstrapState(j)??""}\0${n.getBootstrapFailure(j)??""}\0${n.getInitializationState(j)??""}\0${n.getInitializationFailure(j)??""}`).join(""),e[10]=n,e[11]=p,e[12]=b):b=e[12];const k=c.useSyncExternalStore(x,b,m4);let y;if(e[13]!==o||e[14]!==n||e[15]!==l||e[16]!==u||e[17]!==a){y=new Map;for(const{key:j,archived:S,directories:w}of u){const C=w.find(v=>n.getBootstrapState(v)==="failed"||n.getInitializationState(v)==="failed");if(C){const v=n.getBootstrapState(C)==="failed",R=v?n.getBootstrapFailure(C):n.getInitializationFailure(C);y.set(j,{state:R==="os-permission"?"permission-denied":v?"load-failed":"initialization-failed",directory:C,canGrantAccess:R==="os-permission"&&o})}else{const v=a||!S&&w.length>0&&w.every(R=>n.getBootstrapState(R)==="complete");y.set(j,{state:v?"ready":l==="error"?"load-failed":"loading",directory:v?w[0]??null:null,canGrantAccess:!1})}}e[13]=o,e[14]=n,e[15]=l,e[16]=u,e[17]=a,e[18]=y}else y=e[18];const m=y;let g;return e[19]!==k||e[20]!==m?(g={groupStatusByKey:m,bootstrapSnapshot:k},e[19]=k,e[20]=m,e[21]=g):g=e[21],g};function o4(t){return t.status}function i4(t){return t.hasLoaded}function a4(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function l4(t){return xt(t.directory)}function c4(t){return!!t}function d4(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:qr(n).map(l4).filter(c4)}}function u4(t){return t.directories}function f4(){}function m4(){return""}const h4=5*6e4,p4=[],g4=[],x4=t=>!t.parentID,b4=({topology:t,view:e,actions:n})=>{const{alwaysShowActions:r,notifyOnSubtasks:i,projectViewActions:o,rowActions:l,...a}=n,d=Ut(xe=>xe.foldersMap),u=Ut(xe=>xe.collapsedFolderIds),h=Ut(xe=>xe.createFolder),f=Ut(xe=>xe.addSessionToFolder),p=e.projectView,{getOrderedGroups:x,setGroupOrderByProject:b,toggleGroup:k,toggleProject:y}=o,m=qh({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),g=nx(xe=>xe.projects),j=Hd(xe=>xe.spaces),S=c.useMemo(()=>Array.from(j.values()),[j]),w=c.useMemo(()=>new Map(S.map(xe=>[xe.id,xe.name])),[S]),C=c.useMemo(()=>{const xe=new Map;for(const st of S){const Re=xt(st.projectDirectory);if(!Re)continue;const ot=xe.get(Re);ot?ot.push(st):xe.set(Re,[st])}return xe},[S]),v=c.useMemo(()=>Yh(m.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,m.archivedSessions,g,S),[g,m.archivedSessions,m.sessions,S,t.availableWorktreesByProject,t.isVSCode,t.projects]),[R,T]=c.useState(new Map),[D,F]=c.useState(new Set),[B,E]=c.useState(new Map),$=c.useCallback((xe,st,Re=7)=>{T(ot=>new Map(ot).set(xe,st+Re))},[]),L=c.useCallback(xe=>{T(st=>{if(!st.has(xe))return st;const Re=new Map(st);return Re.delete(xe),Re})},[]),X=as(xe=>xe.showRecentSection),Y=as(xe=>xe.projectDisplayMode),I=as(xe=>xe.singleProjectId),P=as(xe=>xe.setSingleProjectId),q=!t.isVSCode&&!uh()&&Y==="single",K=e.sidebarViewMode==="timeline"&&!t.isVSCode,te=Qh({enabled:X&&!q&&!K,isVSCode:t.isVSCode,pinnedSessionIds:m.pinnedSessionIds,sessionOrderRanks:m.sessionOrderRanks,sessions:m.rootSessions}),[ae,re]=c.useState(null),[he,ce]=c.useState(null),[Te,ve]=c.useState(""),[pe,Ne]=c.useState(null),[U,Z]=c.useState(null),[de,ye]=c.useState(null),H=c.useCallback((xe,st)=>{ye({scopeKey:xe,folderId:st.id,draft:st.name})},[]),je=c.useCallback(xe=>{ye(st=>st?{...st,draft:xe}:null)},[]),Ee=c.useCallback(()=>ye(null),[]),{expandedParents:ge,toggleParent:ne}=n4(),be=nt(xe=>xe.setCurrentSession),G=c.useCallback((xe,st)=>{xe!==nt.getState().currentSessionId&&be(xe,st)},[be]),z=Wu(),J=as(xe=>xe.worktreeSortOrder),{buildGroupedSessions:ue,filterSessionNodesForSearch:le,buildGroupSearchText:W}=M3({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:m.pinnedSessionIds,sessionOrderRanks:m.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:J,sessionOwners:v.bySessionId,spacesByProject:C}),{getSessionsForProject:M,getArchivedSessionsForProject:_}=t2({ownership:v}),ee=c.useMemo(()=>{if(t.isVSCode)return null;const xe=rx(e.homeDirectory)??m.chatSessions.map(Re=>Ha(Re.directory)).find(Boolean)??null;if(!xe)return null;const st=Array.from(new Set([xe,...m.chatSessions.map(Re=>xt(Re.directory??null)).filter(Boolean)])).filter(Re=>!!Re).map(Re=>({scopeKey:Re,directory:Re}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:xe,folderScopeKey:xe,folderScopes:st,draftTarget:"chat",sessions:m.chatSessions.filter(Re=>!Re.time?.archived&&x4(Re)).map(Re=>ro(m.childrenMap,Re))}},[m.chatSessions,m.childrenMap,t.isVSCode,e.homeDirectory]),oe=c.useMemo(()=>ee?[ee]:p4,[ee]),{projectSections:fe,groupSearchDataByGroup:ie,sectionsForRender:Le,flatSectionsForRender:$e}=r2({normalizedProjects:t.projects,getSessionsForProject:M,getArchivedSessionsForProject:_,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:ue,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:le,buildGroupSearchText:W,foldersMap:d,standaloneGroups:oe}),Pe=e.onSearchMatchCountChange;c.useEffect(()=>()=>Pe(0),[Pe]);const Oe=ni(),Q=e.useGroupedSections?Le:$e,Ce=c.useMemo(()=>e.showInlineArchived?Q:Q.map(xe=>xe.groups.some(st=>st.isArchivedBucket)?{...xe,groups:xe.groups.filter(st=>!st.isArchivedBucket)}:xe),[Q,e.showInlineArchived]),Se=c.useCallback(xe=>$e.find(Re=>Re.project.id===xe)?.groups.find(Re=>!Re.isArchivedBucket)?.folderScopes??[],[$e]);q0({enabled:!0,normalizedProjects:t.projects,ownership:v,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:m.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:h,addSessionToFolder:f});const{github:Ke}=nn(),et=hn(xe=>xe.status),it=hn(xe=>xe.hasChecked),rt=Ms(xe=>xe.ensureEntry),pt=Ms(xe=>xe.setParams),ht=Ms(xe=>xe.refreshTargets),tt=c.useRef(new Set);c.useEffect(()=>{if(!Ke||!it||!et?.connected)return;const xe=new Map,st=Date.now();fe.forEach(Re=>{p.collapsedProjects.has(Re.project.id)||Re.groups.forEach(ot=>{if(ot.isArchivedBucket||ot.isMain)return;const vt=xt(ot.directory??null),De=ot.branch?.trim()||t.gitBranches.get(vt||"")?.trim();if(!vt||!De)return;const gt=Xo(vt,De),Ct=Ms.getState().entries[gt],He=Ct?.status?.pr?.state==="closed"||Ct?.status?.pr?.state==="merged",Ue=`${vt}::${De}`,lt=Math.max(Ct?.lastRefreshAt??0,Ct?.lastDiscoveryPollAt??0),_e=!!(Ct?.isInitialStatusResolved&&(!Ct.status?.pr||He)&&(!tt.current.has(Ue)||st-lt>=h4));(!Ct||!Ct.isInitialStatusResolved||_e)&&(_e&&tt.current.add(Ue),xe.set(gt,{directory:vt,branch:De}))})}),xe.forEach((Re,ot)=>{rt(ot),pt(ot,{...Re,remoteName:null,canShow:!0,github:Ke,githubAuthChecked:it,githubConnected:et.connected})}),xe.size&&ht([...xe.values()],{silent:!0,markInitialResolved:!0})},[rt,Ke,it,et?.connected,fe,p.collapsedProjects,ht,pt,t.gitBranches]);const At=c.useMemo(()=>new Map(m.orderedSessions.map((xe,st)=>[xe.id,st])),[m.orderedSessions]),jt=c.useMemo(()=>J!=="manual"?Ce:Ce.map(xe=>{const st=x(xe.project.id,xe.groups);return st===xe.groups?xe:{...xe,groups:st}}),[x,Ce,J]),we=c.useMemo(()=>{const xe=new Map(te.map(vt=>[vt.id,ro(m.childrenMap,vt)])),st=[...xe.values()],Re=[];for(;st.length>0;){const vt=st.pop();if(!vt)break;Re.push(vt.session),st.push(...vt.children)}const ot=Al({sessions:Re,projects:t.projects,ownerBySessionId:v.bySessionId,spaceLabelById:w,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return Xh({sessions:te,getSessionLocation:vt=>ot.get(vt)??null,getSessionNode:vt=>xe.get(vt.id)??ro(m.childrenMap,vt),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[m.childrenMap,v.bySessionId,te,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Xe=c.useMemo(()=>{if(!K)return g4;const xe=new Set(m.rootSessions.map(ot=>ot.id)),st=m.orderedSessions.filter(ot=>xe.has(ot.id)&&!ot.time?.archived),Re=Al({sessions:st,projects:t.projects,ownerBySessionId:v.bySessionId,spaceLabelById:w,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return Jh({sessions:st,getSessionLocation:ot=>Re.get(ot)??null,getSessionNode:ot=>({...ro(m.childrenMap,ot),children:[],worktree:Re.get(ot.id)?.worktree??null}),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[m.childrenMap,m.orderedSessions,m.rootSessions,v.bySessionId,K,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),{groupStatusByKey:mt,bootstrapSnapshot:qe}=r4({childStores:Oe,sections:jt,chatGroup:ee,canGrantAccess:Vd()});let ft=null;q&&(fe.some(xe=>xe.project.id===I)?ft=I:fe.some(xe=>xe.project.id===e.activeProjectId)?ft=e.activeProjectId:ft=fe[0]?.project.id??null);const se=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:ie,collapsedGroups:p.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:i,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:At,expandedParents:ge,editingId:ae,editingRowKey:he,editTitle:Te,sessionBatchSize:q&&!e.useGroupedSections?20:void 0,setEditingId:re,setEditingRowKey:ce,setEditTitle:ve,toggleParent:ne,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:U,setDeleteSessionConfirm:Z,startFolderRename:H,startSessionWorktreeMenuLoad:n.startSessionWorktreeMenuLoad,onEditProject:K?a.openProjectEditDialog:void 0,folderRename:de,setFolderRenameDraft:je,clearFolderRename:Ee}),[m.pinnedSessionIds,r,i,p.collapsedGroups,ie,At,Te,ae,he,ge,de,je,Ee,H,U,n.startSessionWorktreeMenuLoad,a.openProjectEditDialog,K,l,ne,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,q]),me=c.useMemo(()=>({showMoreGroupSessions:$,resetGroupSessionLimit:L,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:k}),[L,$,k,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),Ie=c.useMemo(()=>{const xe=new Map;for(const st of jt)for(const Re of st.groups){const ot=Kn(st.project.id,Re.directory);if(!ot)continue;const vt=qr(Re),De=xe.get(ot),gt=[...new Set([...De?.scopeKeys??[],...vt.map(He=>He.scopeKey)])],Ct=m.hasAuthoritativeGlobalSessions&&vt.every(He=>{const Ue=xt(He.directory);return!Ue||Oe.getBootstrapState(Ue)==="complete"});xe.set(ot,{scopeKeys:gt,complete:(De?.complete??!0)&&Ct})}if(ee){const st=Kn(null,ee.directory);st&&xe.set(st,{scopeKeys:qr(ee).map(Re=>Re.scopeKey),complete:m.hasAuthoritativeGlobalSessions})}return xe},[qe,ee,Oe,m.hasAuthoritativeGlobalSessions,jt]),We=c.useMemo(()=>new Map([...R,...B]),[B,R]),V=c.useMemo(()=>t3({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:K?"timeline":"projects",sections:jt,authoritativeSections:fe,chatGroup:ee,recentSections:we,timelineItems:Xe,showRecentSection:X&&!q&&!K,foldersMap:d,groupSearchDataByGroup:ie,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:p.collapsedProjects,collapsedGroups:p.collapsedGroups,collapsedFolders:u,collapsedActivities:D,expandedParents:ge,visibleCountByContainer:We,pinnedSessionIds:m.pinnedSessionIds,sessionOrderIndex:At,groupStatusByKey:mt,folderAuthorityByOwner:Ie,activeProjectId:e.activeProjectId,singleProjectMode:q&&!K,singleProjectId:ft,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:q&&!e.useGroupedSections?20:void 0}),[ee,D,Xe,K,u,m.pinnedSessionIds,ge,Ie,d,ie,mt,jt,fe,p.collapsedGroups,p.collapsedProjects,we,ft,At,X,q,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,We]);c.useEffect(()=>{Pe(V.searchMatchCount)},[Pe,V.searchMatchCount]);const Fe=c.useMemo(()=>({rowModel:V,sectionsForRender:jt,projectSections:fe,singleProjectMode:q,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ae,openSidebarMenuKey:pe,setOpenSidebarMenuKey:Ne,visibleSessionCountByGroup:R,collapsedActivityKeys:D,setCollapsedActivityKeys:F,visibleActivityCountByKey:B,setVisibleActivityCountByKey:E},groupProps:se}),[se,ae,pe,fe,jt,V,t.projectRepoStatus,e.emptyState,e.searchEmptyState,R,B,D,q]),Ye=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:J,timelineView:K}),[K,J,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),Qe=c.useMemo(()=>({group:me,toggleProject:y,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,openNewWorktreeDialog:a.openNewWorktreeDialog,openWorktreesPage:a.openWorktreesPage,openProjectEditDialog:a.openProjectEditDialog,removeProject:a.removeProject,reorderProjects:a.reorderProjects,setGroupOrderByProject:b,renderProjectStatusIndicator:a.renderProjectStatusIndicator,setSingleProjectId:P}),[me,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,b,y,a.renderProjectStatusIndicator,P]);return s.jsxs(s.Fragment,{children:[s.jsx(V0,{}),s.jsx(J0,{projectSections:fe,activeProjectId:e.activeProjectId,initialActiveSessionByProject:n.initialActiveSessionByProject,persistActiveSessionByProject:n.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:n.openNewSessionDraft,setSessionSwitcherOpen:n.setSessionSwitcherOpen,sessionOwnerBySessionId:v.bySessionId,handleSessionSelect:G}),s.jsx(d2,{sortedSessions:m.orderedSessions,recentSessions:te,prefetchSession:z}),s.jsxs(P2,{entries:V.selectionEntries,descendantIds:V.selectionDescendantIds,sessionsById:V.sessionById,children:[s.jsx(U3,{getFolderScopesForProject:Se,isInlineEditing:ae!==null,startFolderRename:H}),s.jsx(R3,{model:Fe,view:Ye,actions:Qe})]})]})},y4=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(b4,{...t}):null,e[0]=t,e[1]=n):n=e[1],n},um=(t,e,n)=>{const r=new Set;for(const i of t){const o=xt(i.path);o&&r.add(o)}if(n?.includeWorktrees===!1)return r;for(const i of e.values())for(const o of i){const l=xt(o.path);l&&r.add(l)}return r},fd="oc.sessions.activeSessionByProject",w4=[],v4=af(Xn(),Xn().min(1).catch("")),S4=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{Ki("react.session_sidebar_render"),js("ui.session_sidebar.render"),js(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),js(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=St(),[a,d]=c.useState(!1),[u,h]=c.useState(""),f=c.useCallback(()=>{h(""),d(!1)},[]),[p,x]=c.useState(0),b=c.useRef(null),k=c.useRef(null),[y,m]=c.useState(null),g=c.useMemo(()=>Mo(),[]),[j,S]=c.useState(new Map),w=Ae(De=>De.isNewWorktreeDialogOpen),C=Ae(De=>De.setNewWorktreeDialogOpen),[v,R]=c.useState(!1),T=c.useMemo(()=>{try{const De=g.getItem(fd);if(!De)return new Map;const gt=v4.safeParse(JSON.parse(De));if(!gt.success)return new Map;const Ct=new Map;return Object.entries(gt.data).forEach(([He,Ue])=>{Ue&&Ct.set(He,Ue)}),Ct}catch{return new Map}},[g]),D=c.useCallback(De=>{try{g.setItem(fd,JSON.stringify(Object.fromEntries(De.entries())))}catch{}},[g]),[F,B]=c.useState(new Map),E=Jt(De=>De.homeDirectory),$=zt(De=>De.projects),L=zt(De=>De.activeProjectId),X=zt(De=>De.removeProject),Y=zt(De=>De.setActiveProjectIdOnly),I=zt(De=>De.updateProjectMeta),P=zt(De=>De.reorderProjects),A=Ae(De=>De.setSettingsDialogOpen),q=Ae(De=>De.toggleHelpDialog),K=Ae(De=>De.setAboutDialogOpen),te=Ae(De=>De.setSessionSwitcherOpen),ae=Ae(De=>De.setScheduledTasksDialogOpen),re=Ae(De=>De.setArchivePageOpen),he=Ae(De=>De.setUsageStatsPageOpen),ce=Ae(De=>De.setWorktreesPageProjectId),Te=Ae(De=>De.openMultiRunLauncher),ve=Ae(De=>De.notifyOnSubtasks),pe=c.useMemo(()=>u.trim().toLowerCase(),[u]),Ne=pe.length>0;m0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchContainerRef:b});const U=Eu(t),Z=c.useMemo(()=>kn(),[]),de=nt(De=>De.setCurrentSession),ye=nt(De=>De.worktreeMetadata),H=nt(De=>De.availableWorktreesByProject),je=nt(De=>De.openNewSessionDraft),Ee=c.useMemo(()=>um($,H,{includeWorktrees:!Z}),[H,Z,$]),ge=c.useCallback(De=>{Ae.getState().closeMainSurfaces(),je(De),Z&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[Z,je]),ne=_r(Qn(De=>({checkForUpdates:De.checkForUpdates,available:De.available,runtimeType:De.runtimeType,info:De.info,downloading:De.downloading,downloaded:De.downloaded,progress:De.progress,error:De.error,downloadUpdate:De.downloadUpdate,restartToUpdate:De.restartToUpdate}))),be=Wt(),G=c.useMemo(()=>`${be}|${$.map(De=>`${De.id}:${xt(De.path)??""}`).join("|")}`,[$,be]),[z,J]=c.useState(Z?G:null),[ue,le]=c.useReducer(De=>De+1,0),W=!Z&&z!==G,[M,_]=c.useState(new Set),ee=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let De=!1;return(async()=>{const Ct=be,He=zt.getState().projects;if(nt.setState({worktreeDiscoveryByProject:new Map(He.map(Mt=>[xt(Mt.path)??Mt.path,"loading"]))}),He.length===0||Z){De||(ee.current={runtimeKey:null,revision:0,worktreesByProject:new Map},_(new Set),J(G));return}const Ue=nt.getState().availableWorktreesByProject,lt=dl({rawWorktreesByProjectRef:ee,publishedWorktreesByProject:Ue,runtimeKey:Ct}),_e=lt.revision,Ge=new Map(lt.worktreesByProject),Je=new Set,at=3;let Nt=0;const Bt=Array.from({length:at},async()=>{for(;;){const Mt=Nt;if(Nt+=1,Mt>=He.length)return;const Gt=He[Mt],$t=xt(Gt.path);if($t)try{const Zt=await ea(async()=>pn.getState().directories.get($t)?.isGitRepo??await uu($t)?Wl({id:Gt.id,path:$t}):null);if(Zt===null){Ge.delete($t);continue}if(De)return;Zt.length===0?Ge.delete($t):Ge.set($t,Zt)}catch{Je.add($t)}}});if(await Promise.all(Bt),De||Wt()!==Ct)return;const Ft=new Set(He.map(Mt=>xt(Mt.path)).filter(Boolean));for(const Mt of Ge.keys())Ft.has(Mt)||Ge.delete(Mt);pk({rawWorktreesByProjectRef:ee,runtimeKey:Ct,capturedRevision:_e,nextRawWorktreesByProject:Ge,publishedWorktreesByProject:Ue,partitionWorktreesByRegisteredProject:zl,projects:He,worktreeMapsEqual:$l,recordWorktreesSeen:cd,publishTopology:Mt=>{nt.setState(Mt)},requestRediscovery:()=>{le()},now:()=>Date.now()})&&(_(Je),nt.setState({worktreeDiscoveryByProject:new Map(He.map(Mt=>{const Gt=xt(Mt.path)??Mt.path;return[Gt,Je.has(Gt)?"error":"ready"]}))}),J(G))})(),()=>{De=!0}},[Z,G,be,ue]);const oe=c.useMemo(()=>en(),[]),{isTablet:fe}=Nn(),ie=e||fe,Le=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noSessions.description")})]}),[l]),$e=c.useMemo(()=>$.find(De=>De.id===y)??null,[$,y]),Pe=c.useCallback(De=>{y&&I(y,{label:De.label,icon:De.icon,color:De.color,iconBackground:De.iconBackground,defaultAgent:De.defaultAgent??null,defaultModel:De.defaultModel??null,defaultVariant:De.defaultVariant??null})},[y,I]),Oe=c.useCallback(()=>{C(!0)},[C]),Q=c.useCallback(()=>{const De=_r.getState();if(De.available&&De.info){R(!0);return}ne.checkForUpdates().then(()=>{const{available:gt,error:Ct}=_r.getState();if(Ct){ze.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:Ct});return}if(!gt){ze.success(l("sessions.sidebar.updateCheck.latestVersion"));return}R(!0)})},[l,ne]),Ce=c.useCallback(()=>{e&&te(!1),A(!0)},[e,te,A]),Se=ne.available&&(ne.runtimeType==="desktop"||ne.runtimeType==="web"),Ke=c.useCallback(()=>{Qs.requestDirectoryDialog()},[]),et=c.useMemo(()=>$.flatMap(De=>{const gt=xt(De.path);return gt?[{id:De.id,path:De.path,label:De.label,normalizedPath:gt,icon:De.icon??void 0,color:De.color??void 0,iconImage:De.iconImage??void 0,iconBackground:De.iconBackground??void 0,addedAt:De.addedAt,lastOpenedAt:De.lastOpenedAt,sidebarCollapsed:De.sidebarCollapsed}]:[]}),[$]),it=c.useMemo(()=>et.map(De=>De.normalizedPath),[et]),rt=ox(t?it:w4);v0({enabled:t,normalizedProjects:et,gitRepoStatus:rt,setProjectRepoStatus:S,setProjectRootBranches:B});const pt=nt(De=>De.isLoading),ht=c.useRef(!1);L&&j.has(L)&&(ht.current=!!j.get(L));const tt=as(De=>De.showArchivedSessions),At=as(De=>De.projectSortOrder),jt=as(De=>De.sidebarViewMode),we=zt(De=>De.manualProjectOrder),Xe={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:fe,projects:$,activeProjectId:L,manualProjectOrder:we,worktreeMetadata:ye,availableWorktreesByProject:H,gitBranches:U,gitRepoStatus:rt,updateStore:ne,showArchivedSessions:tt,projectSortOrder:At,projectRepoStatus:j,projectRootBranches:F,resolvedWorktreeTopologyKey:z,unresolvedWorktreeProjectPaths:M,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:y,updateDialogOpen:v},mt=c.useRef(null),qe=mt.current;if(qe){let De=!1;for(const gt of Object.keys(Xe))Object.is(qe[gt],Xe[gt])||(js(`ui.session_sidebar.source.${gt}`),De=!0);De||js("ui.session_sidebar.source.parent_or_context")}mt.current=Xe;const ft=c.useMemo(()=>Zh(et,At,we),[et,At,we]),se=x0({isVSCode:Z,projects:ft}),me=c.useMemo(()=>s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:l("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:l("sessions.sidebar.empty.noMatches.description")})]}),[l]),Ie=Z&&tt,We=!Z,V=Z?"projects":jt,Fe=V==="projects",xe=e?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed",st="h-4.5 w-4.5",Re=c.useCallback(()=>{e&&te(!1),Te()},[e,Te,te]),ot=c.useMemo(()=>({projects:$,getCurrentProjects:()=>zt.getState().projects,rawWorktreesByProjectRef:ee,getPublishedWorktreesByProject:()=>nt.getState().availableWorktreesByProject,resolveProject:De=>qi(De),listProjectWorktrees:Wl,partitionWorktreesByRegisteredProject:zl,worktreeMapsEqual:$l,recordWorktreesSeen:cd,publishTopology:De=>{nt.setState(De)},getRuntimeKey:Wt,now:()=>Date.now()}),[$]),vt=c.useCallback(De=>{const gt=im(De,{projects:$,resolveProject:qi});return hk(De,{...ot,projectRootBranch:gt?F.get(gt.id)??null:null})},[F,$,ot]);return c.useEffect(()=>{if(!Z)return Pn(De=>{if(De.type==="session-created"){le();return}if(De.type==="worktree-changed")for(const gt of ix(De.directories)){const Ct=xt(gt.path),He=Wt(),Ue=lt=>{!Ct||Wt()!==He||nt.setState(_e=>({worktreeDiscoveryByProject:new Map(_e.worktreeDiscoveryByProject).set(Ct,lt)}))};Ue("loading"),rm(gt,null,ot).then(()=>{!Ct||Wt()!==He||(Ue("ready"),_(lt=>{if(!lt.has(Ct))return lt;const _e=new Set(lt);return _e.delete(Ct),_e}))}).catch(()=>{!Ct||Wt()!==He||(Ue("error"),_(lt=>new Set(lt).add(Ct)))})}})},[Z,ot]),s.jsx(na,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:b,className:Me("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(A0,{hideDirectoryControls:i,showProjectDisplayControls:!Z,showRecentControls:!Z,handleOpenDirectoryDialog:Ke,onOpenScheduled:()=>{e&&te(!1),ae(!0)},onOpenMultiRun:Re,canOpenMultiRun:$.length>0,onOpenArchive:()=>{e&&te(!1),re(!0)},headerActionIconClass:st,headerActionButtonClass:xe,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:k,sessionSearchQuery:u,setSessionSearchQuery:h,hasSessionSearchQuery:Ne,searchMatchCount:p,collapseAllProjects:se.actions.collapseAllProjects,expandAllProjects:se.actions.expandAllProjects}),s.jsx(y4,{topology:{projects:ft,availableWorktreesByProject:H,knownDirectories:Ee,isVSCode:Z,worktreeMetadata:ye,gitBranches:U,projectRepoStatus:j,projectRootBranches:F,lastRepoStatus:ht.current},view:{isVisible:t,hasSessionSearchQuery:Ne,normalizedSessionSearchQuery:pe,activeProjectId:L,showInlineArchived:Ie,useGroupedSections:We,homeDirectory:E,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:oe,stickyZoneHeaders:Fe,projectSortOrder:At,sidebarViewMode:V,emptyState:Le,searchEmptyState:me,isSessionsLoading:pt,isWorktreeTopologyLoading:W,unresolvedWorktreeProjectPaths:M,projectView:se.state,onSearchMatchCountChange:x},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:ie,notifyOnSubtasks:ve,setActiveProjectIdOnly:Y,setSessionSwitcherOpen:te,openNewSessionDraft:ge,openNewWorktreeDialog:Oe,openWorktreesPage:De=>{e&&te(!1),ce(De)},openProjectEditDialog:m,removeProject:X,reorderProjects:P,startSessionWorktreeMenuLoad:vt,initialActiveSessionByProject:T,persistActiveSessionByProject:D,projectViewActions:se.actions}}),s.jsx(W0,{onOpenSettings:Ce,onOpenUsage:()=>he(!0),onOpenShortcuts:q,onOpenAbout:()=>K(!0),onOpenUpdate:Q,showRuntimeButtons:!Z,showUpdateButton:Se}),s.jsx(qd,{open:v,onOpenChange:R,info:ne.info,downloading:ne.downloading,downloaded:ne.downloaded,progress:ne.progress,error:ne.error,onDownload:ne.downloadUpdate,onRestart:ne.restartToUpdate,runtimeType:ne.runtimeType}),s.jsx(N0,{open:!!$e,onOpenChange:De=>{De||m(null)},project:$e,onSave:Pe}),s.jsx(ep,{open:w,onOpenChange:C,onWorktreeCreated:(De,gt)=>{if(Ae.getState().closeMainSurfaces(),e&&te(!1),gt?.sessionId){de(gt.sessionId,De);return}je({directoryOverride:De,preserveDirectoryOverride:!0})}})]})})},j4=c.memo(S4),ln=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,qs=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},k4=()=>{const{t}=St(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,h]=c.useState(!1),[f,p]=c.useState(!1),[x,b]=c.useState(!1),[k,y]=c.useState(!1),[m,g]=c.useState(new Set),j=nt(G=>G.getWorktreeMetadata),S=nt(G=>G.newSessionDraft),w=nt(G=>G.setNewSessionDraftTarget),C=nt(G=>G.setDraftBootstrapPendingDirectory),v=ax,R=nt(G=>G.deleteSessions),T=nt(G=>G.archiveSessions),D=Ae(G=>G.showDeletionDialog),F=Ae(G=>G.setShowDeletionDialog),B=Jt(G=>G.currentDirectory),E=Jt(G=>G.homeDirectory),$=Jt(G=>G.isHomeReady),L=zt(G=>G.projects),X=zt(G=>G.activeProjectId),{isMobile:Y,isTablet:I,hasTouchInput:P}=Nn(),A=Y||I||P,q=c.useMemo(()=>{const z=(X?L.find(J=>J.id===X)??null:null)?.path??B;return qs(z)},[X,B,L]),K=c.useCallback(G=>{const J=qs(G.projectDirectory)||q;return{id:(L.find(le=>qs(le.path)===J)??null)?.id??`path:${J}`,path:J}},[q,L]),te=k&&m.size>0,ae=c.useMemo(()=>{const G=o?.worktree;return G&&typeof G.branch=="string"&&G.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:z})=>typeof z.branch=="string"&&z.branch.trim().length>0)},[o?.worktree,a]),re=o?.mode==="worktree",he=re,ce=x||!re||!ae,Te=x||!re;c.useEffect(()=>{r||!$||L.length>0||(i(!0),n(!0))},[r,$,L.length]);const ve=c.useCallback(G=>{l({sessions:G.sessions,dateLabel:G.dateLabel,mode:G.mode??"session",worktree:G.worktree??null})},[]),pe=c.useCallback(()=>{l(null),d([]),h(!1),p(!1),b(!1),y(!1),g(new Set)},[]),Ne=c.useCallback(async G=>{if(G.sessions.length===0)return;if(G.sessions.length===1){const le=G.sessions[0];await v(le.id)?ze.success(t("sessions.sidebar.session.delete.success")):ze.error(t("sessions.sidebar.session.delete.error"));return}const z=G.sessions.map(le=>le.id),{deletedIds:J,failedIds:ue}=await R(z);if(J.length>0){const le=ue.length>0?ue.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ue.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ue.length}):G.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:G.dateLabel}):void 0;ze.success(J.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:J.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:J.length}),{description:ln(le)})}ue.length>0&&ze.error(ue.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ue.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[v,R,t]);c.useEffect(()=>Qs.onDeleteRequest(G=>{if(!D&&(G.mode??"session")==="session"){Ne(G);return}ve(G)}),[ve,D,Ne]),c.useEffect(()=>Qs.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),h(!1),p(!1),y(!1),g(new Set);return}const G=o.sessions.map(ue=>{const le=j(ue.id);return le?{session:ue,metadata:le}:null}).filter(ue=>!!ue);d(G),h(!1),y(!1),g(new Set);const z=new Map;if(o.worktree?.path&&z.set(qs(o.worktree.path),o.worktree),G.forEach(({metadata:ue})=>{ue.path&&z.set(qs(ue.path),ue)}),z.size===0){y(!0);return}let J=!1;return(async()=>{const ue=new Map,le=new Set;await Promise.all(Array.from(z.entries()).map(async([W,M])=>{try{const _=await lx(M.path);ue.set(W,_),_?.isDirty&&le.add(W)}catch{M.status&&(ue.set(W,M.status),M.status.isDirty&&le.add(W))}})).catch(W=>{console.warn("Failed to inspect worktree status before deletion:",W)}),!J&&(g(le),y(!0),l(W=>{if(!W?.worktree?.path)return W;const M=qs(W.worktree.path),_=ue.get(M);if(!_)return W;const ee=W.worktree.status;return ee?.isDirty===_.isDirty&&ee?.ahead===_.ahead&&ee?.behind===_.behind&&ee?.upstream===_.upstream?W:{...W,worktree:{...W.worktree,status:_}}}),d(W=>W.map(M=>{const _=qs(M.metadata.path),ee=ue.get(_);return ee?{session:M.session,metadata:{...M.metadata,status:ee}}:M})))})(),()=>{J=!0}},[o,j]),c.useEffect(()=>{ae||h(!1)},[ae]);const U=c.useCallback(async(G,z,J)=>{const ue=u&&ae,le=K(G),W=qs(G.path),M=qs(le.path);try{await fu(le,G,{deleteRemoteBranch:ue,deleteLocalBranch:z});const _=qs(S?.directoryOverride);return S?.open&&W&&_===W&&M&&(C(null),w({projectId:le.id,directoryOverride:M},{force:!0})),qs(B)===W&&M&&Jt.getState().setDirectory(M,{showOverlay:!1}),!0}catch(_){return ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Ni(G)}),{id:J,description:ln(_ instanceof Error?_.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[ae,B,u,K,S?.directoryOverride,S?.open,C,w,t]),Z=c.useCallback((G,z,J)=>{const ue=u&&ae,le=ze.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Ni(G)}));(async()=>{try{if(z.length>0){const{failedIds:_}=await T(z);if(_.length>0){ze.error(_.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:_.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:_.length}),{id:le,description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await U(G,J,le))return;const M=t(ue?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");ze.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Ni(G)}),{id:le,description:ln(M)})}catch(W){ze.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:ln(W instanceof Error?W.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[T,ae,u,U,t]),de=c.useCallback(async()=>{if(o){b(!0);try{const G=he,z=G&&u,J=G&&f;if(re&&o.worktree){Z(o.worktree,o.sessions.map(ue=>ue.id),J),pe();return}if(o.sessions.length===1){const ue=o.sessions[0];if(!await v(ue.id)){ze.error(t("sessions.sidebar.session.delete.error")),b(!1);return}const W=!re&&G?t(z?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;ze.success(t("sessions.sidebar.session.delete.success"),{description:ln(W),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const ue=o.sessions.map(_=>_.id);let le=[],W=[];const M=await R(ue);if(le=M.deletedIds,W=M.failedIds,le.length>0){const _=!re&&G?t(z?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,oe=[W.length>0?W.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:W.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:W.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,_].filter(Boolean).join(" ");ze.success(le.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:le.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:le.length}),{description:ln(oe||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(W.length>0&&(ze.error(W.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:W.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:W.length}),{description:ln(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),le.length===0)){b(!1);return}}pe()}finally{b(!1)}}},[o,u,f,v,R,pe,he,re,Z,t]),ye=o?.worktree??a[0]?.metadata??null,H=o?o.mode==="worktree"?o.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):o.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:o.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:o.sessions.length}):o.sessions.length===1?o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):o.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:o.sessions.length,dateLabel:o.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:o.sessions.length}):"",je=o?s.jsxs("div",{className:Me(re?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Me(re?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[re&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:o.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:o.sessions.length})]}),s.jsxs("ul",{className:Me(re?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(G=>s.jsxs("li",{className:Me(re?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Me(!re&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:G.title||t("sessions.sidebar.session.untitled")})]},G.id)),o.sessions.length>5&&s.jsx("li",{className:Me(re?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),re?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),ye?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:ye.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:ye?Gr(ye.path,E):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),te&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Ee=re?ae?s.jsxs("button",{type:"button",onClick:()=>{ce||h(G=>!G)},disabled:ce,className:Me("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ce?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(O,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,ge=re?s.jsxs("button",{type:"button",onClick:()=>{Te||p(G=>!G)},disabled:Te,className:Me("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Te?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(O,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,ne=re?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[ge,Ee]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:pe,disabled:x,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:de,disabled:x,children:t(x?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>F(!D),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":!D,children:[D?s.jsx(O,{name:"checkbox-blank",className:"size-4"}):s.jsx(O,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ut,{variant:"ghost",onClick:pe,disabled:x,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ut,{variant:"destructive",onClick:de,disabled:x,children:x?t("sessions.sidebar.sessionDialogs.actions.deleting"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),be=re?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):o?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[A?s.jsx(Jo,{open:!!o,onClose:()=>{x||pe()},title:be,footer:s.jsx("div",{className:"flex justify-end gap-2",children:ne}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[H&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:H}),je]})}):s.jsx(bs,{open:!!o,onOpenChange:G=>{if(!G){if(x)return;pe()}},children:s.jsxs(ys,{className:Me(re?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Us,{children:[s.jsxs(Bs,{className:Me(re&&"flex items-center gap-2"),children:[re&&s.jsx(O,{name:"delete-bin",className:"h-5 w-5"}),be]}),H&&s.jsx(Fs,{children:H})]}),s.jsx("div",{className:Me(re&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:je}),s.jsx(An,{className:"mt-2 gap-2 pt-1 pb-1",children:ne})]})}),s.jsx(tp,{open:e,onOpenChange:n})]})};function fm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return lf.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function C4(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=lf.CronExpressionParser.parse(t,r),o=[];for(let l=0;l<n;l+=1){const a=i.next();a&&o.push(a.toDate())}return o}catch{return[]}}const N4=[{expression:"*/5 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.every5min"},{expression:"0 * * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.everyHour"},{expression:"0 9 * * 1",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.monday9am"},{expression:"0 9,17 * * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.9am5pm"},{expression:"0 0 1 * *",labelKey:"sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth"}],A4={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Rangoon":"Asia/Yangon","Asia/Katmandu":"Asia/Kathmandu","America/Godthab":"America/Nuuk","Atlantic/Faeroe":"Atlantic/Faroe","Pacific/Enderbury":"Pacific/Kanton"},Vn=t=>A4[t]??t,mm=[0,1,2,3,4,5,6],md="flex h-6 w-6 cursor-pointer items-center justify-center text-foreground transition-none outline-none focus:outline-none flex-shrink-0",Pa=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(Vn))]:["UTC","Europe/Kyiv","Europe/London","Europe/Berlin","America/New_York","America/Los_Angeles","Asia/Tokyo"],hd=()=>{const t=new Date,e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},Io=t=>{const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),o=new Date(n,r-1,i);return Number.isNaN(o.getTime())||o.getFullYear()!==n||o.getMonth()!==r-1||o.getDate()!==i?null:o},pd=t=>{const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`},P4=(t,e,n)=>{const r=Io(t);return r?new Intl.DateTimeFormat(n,{month:"short",day:"numeric",year:"numeric"}).format(r):e},gd=(t,e)=>new Date(t.getFullYear(),t.getMonth()+e,1),D4=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let h=0;h<42;h+=1){const f=h-l+1;if(f<=0){const p=d+f;u.push({date:new Date(n,r-1,p),inCurrentMonth:!1});continue}if(f>a){u.push({date:new Date(n,r+1,f-a),inCurrentMonth:!1});continue}u.push({date:new Date(n,r,f),inCurrentMonth:!0})}return u},I4=t=>{const e=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(t);if(!e)return{hour24:"00",hour12:"12",minute:"00",meridiem:"AM"};const n=Number(e[1]),r=e[2],i=n>=12?"PM":"AM",o=n%12===0?12:n%12;return{hour24:String(n).padStart(2,"0"),hour12:String(o).padStart(2,"0"),minute:r,meridiem:i}},Fn=(t,e,n)=>{const r=Number(t),i=Number(e),o=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,l=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0;let a=o%12;return n==="PM"&&(a+=12),`${String(a).padStart(2,"0")}:${String(l).padStart(2,"0")}`},jr=(t,e)=>{const{max:n,min:r=0,loop:i=!1}=e;let o=Number.parseInt(t,10);return Number.isFinite(o)?(i?(o>n&&(o=r),o<r&&(o=n)):(o>n&&(o=n),o<r&&(o=r)),String(o).padStart(2,"0")):"00"},xd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:jr(t,{min:1,max:12}),So=t=>/^[0-5][0-9]$/.test(t)?t:jr(t,{max:59}),T4=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),bd=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),E4=t=>{try{const e=Intl.Locale;if(typeof e!="function")return 1;const r=new e(t).weekInfo?.firstDay;return typeof r!="number"?1:r%7}catch{return 1}},R4=t=>{try{const e=new Intl.DateTimeFormat(t,{hour:"numeric"}).resolvedOptions();return typeof e.hour12=="boolean"?!e.hour12:e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!0}},M4=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return mm.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},O4=(t,e)=>[...t.slice(e),...t.slice(0,e)],Ss=t=>{const e=Ze.c(6),{htmlFor:n,required:r,children:i}=t;let o;e[0]!==r?(o=r&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"}),e[0]=r,e[1]=o):o=e[1];let l;return e[2]!==i||e[3]!==n||e[4]!==o?(l=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,o]})}),e[2]=i,e[3]=n,e[4]=o,e[5]=l):l=e[5],l},yd=t=>{const e=Ze.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let h;e[0]!==n?(h=I4(n),e[0]=n,e[1]=h):h=e[1];const f=h,p=ct.useRef(null),x=ct.useRef(null),[b,k]=ct.useState(null),[y,m]=ct.useState(null),g=ct.useRef(null),j=ct.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=G=>{g.current=G,k(G)},e[2]=S):S=e[2];const w=S;let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C=G=>{j.current=G,m(G)},e[3]=C):C=e[3];const v=C,R=W4,T=K4,D=V4;let F;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(F=G=>{const z=G.replace(/\D/g,"").slice(0,2);w(z),z.length===2&&(r(i?D(R(z),f.minute):Fn(xd(z),f.minute,f.meridiem)),w(null),x.current?.focus())},e[4]=r,e[5]=f.meridiem,e[6]=f.minute,e[7]=i,e[8]=F):F=e[8];const B=F;let E;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(E=()=>{const G=g.current;if(G!==null&&(w(null),G.length!==0)){if(i){r(D(R(G.padStart(2,"0")),f.minute));return}r(Fn(xd(G.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=E):E=e[13];const $=E;let L;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(L=G=>{const z=G.replace(/\D/g,"").slice(0,2);v(z),z.length===2&&(r(i?D(f.hour24,So(z)):Fn(f.hour12,So(z),f.meridiem)),v(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=L):L=e[19];const X=L;let Y;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(Y=()=>{const G=j.current;G!==null&&(v(null),G.length!==0&&r(i?D(f.hour24,So(G.padStart(2,"0"))):Fn(f.hour12,So(G.padStart(2,"0")),f.meridiem)))},e[20]=r,e[21]=f.hour12,e[22]=f.hour24,e[23]=f.meridiem,e[24]=i,e[25]=Y):Y=e[25];const I=Y;let P;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(P=G=>r(i?D(T(f.hour24,G),f.minute):Fn(T4(f.hour12,G),f.minute,f.meridiem)),e[26]=r,e[27]=f.hour12,e[28]=f.hour24,e[29]=f.meridiem,e[30]=f.minute,e[31]=i,e[32]=P):P=e[32];const A=P;let q;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(q=G=>r(i?D(f.hour24,bd(f.minute,G)):Fn(f.hour12,bd(f.minute,G),f.meridiem)),e[33]=r,e[34]=f.hour12,e[35]=f.hour24,e[36]=f.meridiem,e[37]=f.minute,e[38]=i,e[39]=q):q=e[39];const K=q;let te;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(te=G=>{G!==f.meridiem&&r(Fn(f.hour12,f.minute,G))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=te):te=e[44];const ae=te;let re;e[45]!==$||e[46]!==A?(re=G=>{if(G.key==="ArrowRight"){G.preventDefault(),$(),x.current?.focus();return}(G.key==="ArrowUp"||G.key==="ArrowDown")&&(G.preventDefault(),w(null),A(G.key==="ArrowUp"?1:-1))},e[45]=$,e[46]=A,e[47]=re):re=e[47];const he=re;let ce;e[48]!==I||e[49]!==K?(ce=G=>{if(G.key==="ArrowLeft"&&(G.currentTarget.selectionStart??0)===0){G.preventDefault(),I(),p.current?.focus();return}(G.key==="ArrowUp"||G.key==="ArrowDown")&&(G.preventDefault(),v(null),K(G.key==="ArrowUp"?1:-1))},e[48]=I,e[49]=K,e[50]=ce):ce=e[50];const Te=ce,ve=i?"px-2":"pl-2 pr-1";let pe;e[51]!==ve?(pe=Me("oc-surface-elevated inline-flex h-9 w-fit items-center gap-1 rounded-md border border-border bg-surface-elevated focus-within:ring-1 focus-within:ring-ring focus-within:border-ring",ve),e[51]=ve,e[52]=pe):pe=e[52];const Ne=b??(i?f.hour24:f.hour12);let U;e[53]!==B?(U=G=>B(G.target.value),e[53]=B,e[54]=U):U=e[54];let Z;e[55]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>w(""),e[55]=Z):Z=e[55];let de;e[56]!==$||e[57]!==o||e[58]!==he||e[59]!==Ne||e[60]!==U?(de=s.jsx("input",{ref:p,inputMode:"numeric",value:Ne,onChange:U,onKeyDown:he,onFocus:Z,onBlur:$,maxLength:2,"aria-label":o,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[56]=$,e[57]=o,e[58]=he,e[59]=Ne,e[60]=U,e[61]=de):de=e[61];let ye;e[62]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=ye):ye=e[62];const H=y??f.minute;let je;e[63]!==X?(je=G=>X(G.target.value),e[63]=X,e[64]=je):je=e[64];let Ee;e[65]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>v(""),e[65]=Ee):Ee=e[65];let ge;e[66]!==I||e[67]!==l||e[68]!==Te||e[69]!==H||e[70]!==je?(ge=s.jsx("input",{ref:x,inputMode:"numeric",value:H,onChange:je,onKeyDown:Te,onFocus:Ee,onBlur:I,maxLength:2,"aria-label":l,className:"h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover"}),e[66]=I,e[67]=l,e[68]=Te,e[69]=H,e[70]=je,e[71]=ge):ge=e[71];let ne;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==ae||e[77]!==i?(ne=i?null:s.jsxs(ks,{value:f.meridiem,onValueChange:G=>ae(G),children:[s.jsx(Cs,{"aria-label":a,className:"ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0",children:s.jsx(hs,{})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"AM",children:d}),s.jsx(Yt,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=ae,e[77]=i,e[78]=ne):ne=e[78];let be;return e[79]!==pe||e[80]!==de||e[81]!==ge||e[82]!==ne?(be=s.jsxs("div",{className:pe,children:[de,ye,ge,ne]}),e[79]=pe,e[80]=de,e[81]=ge,e[82]=ne,e[83]=be):be=e[83],be},wd=t=>new Date(t.getFullYear(),t.getMonth(),1),B4=()=>{const t=new Date;return new Date(t.getFullYear(),t.getMonth(),t.getDate())},vd=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),F4=t=>{if(!t)return["09:00"];const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(i=>typeof i=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(i)).map(i=>i.trim()),r=Array.from(new Set(n)).sort((i,o)=>i.localeCompare(o));return r.length>0?r:["09:00"]},Sd=(t,e)=>{const n=Vn(Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC");return t?{id:t.id,name:t.name,enabled:t.enabled,schedule:{kind:t.schedule.kind==="cron"?"cron":t.schedule.kind==="once"?"once":t.schedule.kind==="weekly"?"weekly":"daily",times:F4(t),onceDate:typeof t.schedule.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.date)?t.schedule.date:hd(),onceTime:typeof t.schedule.time=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.time)?t.schedule.time:"09:00",weekdays:Array.isArray(t.schedule.weekdays)?t.schedule.weekdays:[1],timezone:Vn(t.schedule.timezone||n),cronExpression:t.schedule.kind==="cron"&&typeof t.schedule.cron=="string"?t.schedule.cron:""},execution:{prompt:t.execution.prompt,providerID:t.execution.providerID,modelID:t.execution.modelID,variant:t.execution.variant||"",agent:t.execution.agent||"",goalEnabled:t.execution.goalEnabled===!0,goalTokenBudget:typeof t.execution.goalTokenBudget=="number"&&t.execution.goalTokenBudget>0?t.execution.goalTokenBudget:null,permissionAutoAccept:t.execution.permissionAutoAccept===!0},state:t.state}:{name:"",enabled:!0,schedule:{kind:"daily",times:["09:00"],onceDate:hd(),onceTime:"09:00",weekdays:[1],timezone:n,cronExpression:""},execution:{prompt:"",providerID:e.providerID,modelID:e.modelID,variant:e.variant,agent:e.agent,goalEnabled:!1,goalTokenBudget:null,permissionAutoAccept:!1}}},L4=(t,e)=>{if(!t.name.trim())return e("sessions.scheduledTasks.editor.validation.taskNameRequired");if(!t.execution.prompt.trim())return e("sessions.scheduledTasks.editor.validation.promptRequired");if(!t.execution.providerID.trim()||!t.execution.modelID.trim())return e("sessions.scheduledTasks.editor.validation.modelRequired");if(t.schedule.kind==="once"){if(!/^\d{4}-\d{2}-\d{2}$/.test(t.schedule.onceDate))return e("sessions.scheduledTasks.editor.validation.dateFormat");if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.schedule.onceTime))return e("sessions.scheduledTasks.editor.validation.timeFormat")}else if(t.schedule.kind==="cron"){if(!t.schedule.cronExpression.trim())return e("sessions.scheduledTasks.editor.validation.cronRequired");if(!fm(t.schedule.cronExpression).valid)return e("sessions.scheduledTasks.editor.validation.cronInvalid")}else if(t.schedule.times.filter(r=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)).length===0)return e("sessions.scheduledTasks.editor.validation.atLeastOneTime");return t.schedule.kind==="weekly"&&t.schedule.weekdays.length===0?e("sessions.scheduledTasks.editor.validation.atLeastOneWeekday"):t.schedule.timezone.trim()?null:e("sessions.scheduledTasks.editor.validation.timezoneRequired")},_4=t=>{const e=t.filter(n=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(n));return Array.from(new Set(e)).sort((n,r)=>n.localeCompare(r))},$4=t=>{const e=Ze.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?fm(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let P;e[2]===Symbol.for("react.memo_cache_sentinel")?(P=[],e[2]=P):P=e[2],u=P;break e}let I;e[3]!==l||e[4]!==n.schedule.timezone?(I=C4(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=I):I=e[5],u=I}const h=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=I=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(I),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const p=f;let x;e[9]!==o?(x=o("sessions.scheduledTasks.editor.cronExpression.label"),e[9]=o,e[10]=x):x=e[10];let b;e[11]!==x?(b=s.jsx(Ss,{htmlFor:"sched-cron",required:!0,children:x}),e[11]=x,e[12]=b):b=e[12];let k;e[13]!==r?(k=I=>r(P=>({...P,schedule:{...P.schedule,cronExpression:I.target.value}})),e[13]=r,e[14]=k):k=e[14];let y;e[15]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=y):y=e[16];let m;e[17]!==l||e[18]!==k||e[19]!==y?(m=s.jsx(un,{id:"sched-cron",value:l,onChange:k,placeholder:y,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=k,e[19]=y,e[20]=m):m=e[20];let g;e[21]!==l||e[22]!==d||e[23]!==o?(g=d&&!d.valid&&l.trim()?s.jsx("span",{className:"typography-micro text-destructive",children:o("sessions.scheduledTasks.editor.validation.cronInvalid")}):null,e[21]=l,e[22]=d,e[23]=o,e[24]=g):g=e[24];let j;e[25]!==b||e[26]!==m||e[27]!==g?(j=s.jsxs("div",{className:"flex flex-col gap-1",children:[b,m,g]}),e[25]=b,e[26]=m,e[27]=g,e[28]=j):j=e[28];let S;e[29]!==p||e[30]!==h||e[31]!==o?(S=h.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:h.map(p).join(", ")})]}):null,e[29]=p,e[30]=h,e[31]=o,e[32]=S):S=e[32];let w;e[33]!==o?(w=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=w):w=e[34];let C;e[35]!==w?(C=s.jsx("span",{className:"typography-meta text-muted-foreground",children:w}),e[35]=w,e[36]=C):C=e[36];let v;e[37]!==r||e[38]!==o?(v=N4.map(I=>s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover",onClick:()=>r(P=>({...P,schedule:{...P.schedule,cronExpression:I.expression}})),children:[s.jsx("span",{className:"font-mono",children:I.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(I.labelKey)})]},I.expression)),e[37]=r,e[38]=o,e[39]=v):v=e[39];let R;e[40]!==v?(R=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:v}),e[40]=v,e[41]=R):R=e[41];let T;e[42]!==C||e[43]!==R?(T=s.jsxs("div",{className:"flex flex-col gap-1",children:[C,R]}),e[42]=C,e[43]=R,e[44]=T):T=e[44];let D;e[45]!==o?(D=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=D):D=e[46];let F;e[47]!==D?(F=s.jsx(Ss,{children:D}),e[47]=D,e[48]=F):F=e[48];let B;e[49]!==r?(B=I=>{r(P=>({...P,schedule:{...P.schedule,timezone:I}}))},e[49]=r,e[50]=B):B=e[50];let E;e[51]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{})}),e[51]=E):E=e[51];let $;e[52]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(Ns,{children:Pa.map(U4)}),e[52]=$):$=e[52];let L;e[53]!==n.schedule.timezone||e[54]!==B?(L=s.jsxs(ks,{value:n.schedule.timezone,onValueChange:B,children:[E,$]}),e[53]=n.schedule.timezone,e[54]=B,e[55]=L):L=e[55];let X;e[56]!==F||e[57]!==L?(X=s.jsxs("div",{className:"flex flex-col gap-1",children:[F,L]}),e[56]=F,e[57]=L,e[58]=X):X=e[58];let Y;return e[59]!==j||e[60]!==S||e[61]!==T||e[62]!==X?(Y=s.jsxs("div",{className:"flex flex-col gap-3",children:[j,S,T,X]}),e[59]=j,e[60]=S,e[61]=T,e[62]=X,e[63]=Y):Y=e[63],Y};function z4(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=St(),a=Lt(Q=>Q.loadProviders),d=Lt(Q=>Q.loadAgents),u=Lt(Q=>Q.providers),h=Lt(Q=>Q.currentProviderId),f=Lt(Q=>Q.currentModelId),p=Lt(Q=>Q.currentVariant||""),x=Lt(Q=>Q.currentAgentName||""),b=Ae(Q=>Q.timeFormatPreference),k=Ae(Q=>Q.weekStartPreference),y=Ae(Q=>Q.isMobile),[m,g]=ct.useState(()=>Sd(n,{providerID:h,modelID:f,variant:p,agent:x})),[j,S]=ct.useState(!1),[w,C]=ct.useState(!1),[v,R]=ct.useState(!1),[T,D]=ct.useState(""),[F,B]=ct.useState(!1),[E,$]=ct.useState(""),[L,X]=ct.useState(!1),[Y,I]=ct.useState(""),[P,A]=ct.useState(()=>{const Q=Io(n?.schedule?.date||"")||new Date;return new Date(Q.getFullYear(),Q.getMonth(),1)}),q=ct.useRef(null),K=ct.useRef(null),te=ct.useRef(null),ae=ct.useRef(null),re=ct.useRef(null),he=ct.useMemo(()=>R4(l),[l]),ce=ct.useMemo(()=>E4(l),[l]),Te=ct.useMemo(()=>b==="24h"?!0:b==="12h"?!1:he,[b,he]),ve=ct.useMemo(()=>k==="sunday"?0:k==="monday"?1:ce,[k,ce]),pe=ct.useMemo(()=>{const Q=M4(l);return O4(mm.map(Ce=>({value:Ce,label:Q[Ce]||""})),ve)},[l,ve]);ct.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),ct.useEffect(()=>{if(!e)return;g(Sd(n,{providerID:h,modelID:f,variant:p,agent:x}));const Q=Io(n?.schedule?.date||"")||new Date;A(new Date(Q.getFullYear(),Q.getMonth(),1)),C(!1),B(!1),R(!1),$(""),D("")},[e,n,h,f,p,x]),ct.useEffect(()=>{if(!w)return;const Q=Ce=>{q.current&&!q.current.contains(Ce.target)&&C(!1)};return document.addEventListener("mousedown",Q),()=>{document.removeEventListener("mousedown",Q)}},[w]);const Ne=ct.useMemo(()=>{const Ce=u.find(Se=>Se.id===m.execution.providerID)?.models?.find(Se=>Se.id===m.execution.modelID);return Ya(Ce?.variants)},[u,m.execution.providerID,m.execution.modelID]),U=Ne.length>0,Z=ct.useMemo(()=>!U||!m.execution.variant?"__default":Ne.includes(m.execution.variant)?m.execution.variant:"__default",[m.execution.variant,U,Ne]);ct.useEffect(()=>{U||!m.execution.variant||g(Q=>({...Q,execution:{...Q.execution,variant:""}}))},[U,m.execution.variant]);const de=ct.useCallback((Q,Ce)=>{g(Se=>{const Ke=new Set(Se.schedule.weekdays);return Ce?Ke.add(Q):Ke.delete(Q),{...Se,schedule:{...Se.schedule,weekdays:Array.from(Ke).sort((et,it)=>et-it)}}})},[]),ye=ct.useCallback((Q,Ce)=>{g(Se=>{const Ke=Se.schedule.times.slice();return Ke[Q]=Ce,{...Se,schedule:{...Se.schedule,times:Ke}}})},[]),H=ct.useCallback(Q=>{g(Ce=>{const Se=Ce.schedule.times.filter((Ke,et)=>et!==Q);return{...Ce,schedule:{...Ce.schedule,times:Se.length>0?Se:["09:00"]}}})},[]),je=ct.useCallback(()=>{g(Q=>({...Q,schedule:{...Q.schedule,times:[...Q.schedule.times,"12:00"]}}))},[]),Ee=ct.useMemo(()=>B4(),[]),ge=ct.useMemo(()=>wd(Ee),[Ee]),ne=ct.useMemo(()=>{const Q=Io(m.schedule.onceDate);return Q?vd(Q,Ee)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(Q):null},[m.schedule.onceDate,l,o,Ee]),be=ct.useMemo(()=>wd(P).getTime()<=ge.getTime(),[P,ge]),G=ct.useMemo(()=>pe.map(Q=>Q.label),[pe]),z=ct.useCallback(Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,onceDate:Q}}))},[]),J=ct.useCallback((Q,Ce)=>{if(Q.startsWith("/")){const it=Q.indexOf(" "),rt=Q.indexOf(`
890
+ `),pt=Math.min(it===-1?Q.length:it,rt===-1?Q.length:rt);if(Ce<=pt&&it===-1){$(Q.substring(1,pt)),B(!0),R(!1),X(!1);return}}B(!1);const Se=Q.substring(0,Ce),Ke=Se.lastIndexOf("#");if(Ke!==-1){const it=Ke>0?Se[Ke-1]:null,rt=Se.substring(Ke+1);if((!it||/\s/.test(it))&&!rt.includes(" ")&&!rt.includes(`
891
+ `)){I(rt),X(!0),R(!1);return}}X(!1);const et=Se.lastIndexOf("@");if(et!==-1){const it=et>0?Se[et-1]:null,rt=Se.substring(et+1);(!it||/\s/.test(it))&&!rt.includes(" ")&&!rt.includes(`
892
+ `)?(D(rt),R(!0)):R(!1);return}R(!1)},[]),ue=ct.useCallback(Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,prompt:Q}}))},[]),le=ct.useCallback(Q=>{const Ce=m.execution.prompt,Ke=K.current?.selectionStart??Ce.length,it=Ce.substring(0,Ke).lastIndexOf("@"),rt=Q.relativePath&&Q.relativePath.trim().length>0?Q.relativePath.trim():Q.path||Q.name,pt=it!==-1?it:Ke,ht=`${Ce.substring(0,pt)}@${rt} ${Ce.substring(Ke)}`,tt=pt+rt.length+2;ue(ht),R(!1),D(""),requestAnimationFrame(()=>{const At=K.current;At&&(At.selectionStart=tt,At.selectionEnd=tt,At.focus()),J(ht,tt)})},[m.execution.prompt,ue,J]),W=ct.useCallback(Q=>{const Ce=m.execution.prompt,Ke=K.current?.selectionStart??Ce.length,it=Ce.substring(0,Ke).lastIndexOf("@"),rt=it!==-1?it:Ke,pt=`${Ce.substring(0,rt)}@${Q} ${Ce.substring(Ke)}`,ht=rt+Q.length+2;ue(pt),R(!1),D(""),requestAnimationFrame(()=>{const tt=K.current;tt&&(tt.selectionStart=ht,tt.selectionEnd=ht,tt.focus()),J(pt,ht)})},[m.execution.prompt,ue,J]),M=ct.useCallback(Q=>{const Ce=`/${Q.name} `;ue(Ce),B(!1),$(""),X(!1),requestAnimationFrame(()=>{const Se=K.current;Se&&(Se.focus(),Se.selectionStart=Se.value.length,Se.selectionEnd=Se.value.length),J(Ce,Ce.length)})},[ue,J]),_=ct.useCallback((Q,Ce)=>{const Se=m.execution.prompt,et=K.current?.selectionStart??Se.length,rt=Se.substring(0,et).lastIndexOf("#"),pt=rt!==-1?rt:et,ht=`${Se.substring(0,pt)}#${Ce} ${Se.substring(et)}`,tt=pt+Ce.length+2;ue(ht),X(!1),I(""),requestAnimationFrame(()=>{const At=K.current;At&&(At.selectionStart=tt,At.selectionEnd=tt,At.focus()),J(ht,tt)})},[m.execution.prompt,ue,J]),ee=ct.useCallback(Q=>{if(F&&ae.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")){Q.preventDefault(),ae.current.handleKeyDown(Q.key);return}v&&te.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),te.current.handleKeyDown(Q.key)),L&&re.current&&(Q.key==="Enter"||Q.key==="ArrowUp"||Q.key==="ArrowDown"||Q.key==="Escape"||Q.key==="Tab")&&(Q.preventDefault(),re.current.handleKeyDown(Q.key))},[F,v,L]),oe=ct.useCallback(async()=>{const Q=L4(m,o);if(Q){ze.error(Q);return}const Ce={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:_4(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};S(!0);try{await i(Ce),r(!1)}catch(Se){ze.error(Se instanceof Error?Se.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[m,r,i,o]),fe=ct.useId(),ie=ct.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Le=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),$e=o("sessions.scheduledTasks.editor.description"),Pe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(un,{id:"sched-name",value:m.name,onChange:Q=>g(Ce=>({...Ce,name:Q.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(ks,{value:m.schedule.kind,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,kind:Q,...Q==="cron"&&!Ce.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{children:Q=>o(Q==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":Q==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":Q==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(Yt,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(Yt,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(Yt,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx($4,{draft:m,setDraft:g,locale:l,t:o}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:q,children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Me(_u({size:"default"}),"w-fit max-w-full"),onClick:()=>C(Q=>!Q),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(O,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:P4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(O,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),w?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>A(Q=>gd(Q,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:be,children:s.jsx(O,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(P)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>A(Q=>gd(Q,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(O,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:G.map((Q,Ce)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:Q},`${Q}-${Ce}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:D4(P,ve).map(({date:Q,inCurrentMonth:Ce})=>{const Se=pd(Q),Ke=Se===m.schedule.onceDate,et=vd(Q,Ee),it=Q.getTime()<Ee.getTime(),rt=Ke?"bg-interactive-selection text-interactive-selection-foreground":it?"text-muted-foreground/40":Ce?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{it||(z(Se),C(!1))},disabled:it,className:["h-8 rounded-md typography-ui-label",rt,et&&!Ke?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",it?"cursor-not-allowed opacity-45":""].join(" "),children:Q.getDate()},Se)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:ne||""}),s.jsx(ut,{type:"button",size:"xs",variant:"ghost",onClick:()=>{z(pd(Ee)),A(new Date(Ee.getFullYear(),Ee.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(yd,{value:m.schedule.onceTime,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Q=>g(Ce=>({...Ce,schedule:{...Ce.schedule,onceTime:Q}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ks,{value:m.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{})}),s.jsx(Ns,{children:Pa.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:pe.map(Q=>{const Ce=m.schedule.weekdays.includes(Q.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",Ce?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(hr,{checked:Ce,onChange:Se=>de(Q.value,Se),ariaLabel:Q.label}),s.jsx("button",{type:"button",onClick:()=>de(Q.value,!Ce),className:"group-hover:text-foreground",children:Q.label})]},Q.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((Q,Ce)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yd,{value:Q,use24Hour:Te,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Se=>ye(Ce,Se)}),m.schedule.times.length>1?s.jsx(ut,{type:"button",size:"icon",variant:"ghost",onClick:()=>H(Ce),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null]},Ce))}),s.jsx("div",{children:s.jsxs(ut,{type:"button",size:"sm",variant:"outline",onClick:je,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(ks,{value:m.schedule.timezone,onValueChange:Q=>{g(Ce=>({...Ce,schedule:{...Ce.schedule,timezone:Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{})}),s.jsx(Ns,{children:Pa.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(cx,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(Q,Ce)=>{g(Se=>({...Se,execution:{...Se.execution,providerID:Q,modelID:Ce,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(ks,{value:Z,disabled:!U,onValueChange:Q=>{g(Ce=>({...Ce,execution:{...Ce.execution,variant:Q==="__default"?"":Q}}))},children:[s.jsx(Cs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(hs,{children:Q=>Q==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):Q})}),s.jsxs(Ns,{children:[s.jsx(Yt,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ne.map(Q=>s.jsx(Yt,{value:Q,children:Q},Q))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ss,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(dx,{agentName:m.execution.agent,filter:Q=>Lu(Q.mode),onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,agent:Q}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ss,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(fr,{id:"sched-prompt",ref:K,value:m.execution.prompt,onChange:Q=>{const Ce=Q.target.value;ue(Ce);const Se=Q.target.selectionStart??Ce.length;J(Ce,Se)},onKeyDown:ee,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(Hu,{ref:ae,searchQuery:E,onCommandSelect:M,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,v?s.jsx(Gu,{ref:te,searchQuery:T,onFileSelect:le,onAgentSelect:W,onClose:()=>R(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,L?s.jsx(qu,{ref:re,searchQuery:Y,onSnippetSelect:_,onClose:()=>X(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(hr,{checked:m.execution.goalTokenBudget!==null,onChange:Q=>g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Q?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(ux,{value:m.execution.goalTokenBudget,onValueChange:Q=>{typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&g(Ce=>({...Ce,execution:{...Ce.execution,goalTokenBudget:Math.floor(Q)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),Oe=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(hr,{checked:m.enabled,onChange:Q=>g(Ce=>({...Ce,enabled:Q})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(md),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,permissionAutoAccept:!Q.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(O,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(O,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(wt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",className:Me(md,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>g(Q=>({...Q,execution:{...Q.execution,goalEnabled:!Q.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(O,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(O,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(wt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:j,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ut,{type:"button",size:"sm",onClick:oe,disabled:j,children:o(j?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return y?s.jsx(Jo,{open:e,title:Le,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:Q=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:Le}),Q]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:$e})]}),footer:Oe,children:Pe}):s.jsx(bs,{open:e,onOpenChange:Q=>{!Q&&ie()||r(Q)},children:s.jsxs(ys,{"aria-describedby":fe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Fs,{id:fe,className:"sr-only",children:$e}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Bs,{className:"typography-ui-label font-medium text-foreground",children:Le}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:$e})]})}),s.jsx(za,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:Pe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:Oe})})]})})}function W4(t){return jr(t,{min:0,max:23})}function K4(t,e){return jr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function V4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function U4(t){return s.jsx(Yt,{value:t,children:t},t)}const H4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},G4=(t,e)=>{const n=H4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Vn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},q4=(t,e)=>!t||!Number.isFinite(t)?"":fx(t,e),jd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),p=Math.round(r%o/i),x=p>0?`${f}h ${p}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:x}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:x})}const d=Math.floor(r/l),u=Math.round(r%l/o),h=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},Y4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},Q4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function X4(){const{t}=St(),e=Ae(I=>I.isScheduledTasksDialogOpen),n=Ae(I=>I.setScheduledTasksDialogOpen),r=Ae(I=>I.isMobile),i=Ae(I=>I.timeFormatPreference),o=zt(I=>I.projects),l=zt(I=>I.getActiveProject()),a=Jt(I=>I.homeDirectory),{currentTheme:d}=Cn(),[u,h]=ct.useState(""),[f,p]=ct.useState([]),[x,b]=ct.useState(!0),[k,y]=ct.useState(!1),[m,g]=ct.useState(null),[j,S]=ct.useState(null),w=ct.useMemo(()=>o.find(I=>I.id===u)||null,[o,u]),C=ct.useCallback(I=>{const P=I.label?.trim()||Yn(I.path,a||void 0),A=I.icon?ei[I.icon]:null,q=I.color?ti[I.color]:void 0,K=A?s.jsx(O,{name:A,className:"h-3.5 w-3.5 shrink-0",style:q?{color:q}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:q?{color:q}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[I.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:I.iconBackground?{backgroundColor:I.iconBackground}:void 0,children:s.jsx(si,{project:{id:I.id,iconImage:I.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:K})}):K,s.jsx("span",{className:"truncate",children:P})]})},[a,d.metadata.variant,d.colors.surface.foreground]),v=ct.useCallback(async(I,P)=>{if(!I){p([]);return}P?.silent||b(!0);try{const A=await rb(I);A.sort((q,K)=>{if(q.enabled!==K.enabled)return q.enabled?-1:1;const te=q.name.localeCompare(K.name);return te!==0?te:(q.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(K.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),p(A)}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),P?.silent||p([])}finally{P?.silent||b(!1)}},[t]);ct.useEffect(()=>{if(!e)return;const I=l?.id||o[0]?.id||"";h(I),I?v(I):(p([]),b(!1))},[e,l,o,v]),ct.useEffect(()=>{if(!e)return;let I=null;const P=Pn(A=>{A.type==="scheduled-task-ran"&&A.projectId===u&&(I&&clearTimeout(I),I=setTimeout(()=>{v(u,{silent:!0})},400))});return()=>{I&&clearTimeout(I),P()}},[e,u,v]);const R=ct.useCallback(async I=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Jl(u,I),await v(u),ze.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,v,t]),T=ct.useCallback(async(I,P)=>{if(u){S(I.id),p(A=>A.map(q=>q.id===I.id?{...q,enabled:P}:q));try{I.loopFile?await ob(u,I.id,P):await Jl(u,{...I,enabled:P}),await v(u,{silent:!0})}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await v(u,{silent:!0})}finally{S(null)}}},[u,v,t]),D=ct.useCallback(async I=>{if(!(!u||!window.confirm(I.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:I.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:I.name})))){S(I.id);try{I.loopFile?await ib(u,I.id):await ab(u,I.id),await v(u,{silent:!0}),ze.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(A){ze.error(A instanceof Error?A.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[u,v,t]),F=ct.useCallback(I=>{if(!I.loopFile){g(I),y(!0);return}w?.path&&(n(!1),Js.getState().setSelectedPath(w.path,I.loopFile,{allowOutsideRoot:!0}),Ae.getState().openContextFile(w.path,I.loopFile))},[w?.path,n]),B=ct.useCallback(async I=>{if(u){S(I.id);try{const{sessionId:P,persistError:A}=await lb(u,I.id);if(await Promise.all([v(u,{silent:!0}),ri()]),A?ze.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):ze.success(t("sessions.scheduledTasks.dialog.toast.started")),P){const q=o.find(K=>K.id===u);nt.getState().setCurrentSession(P,q?.path??null)}}catch(P){ze.error(P instanceof Error?P.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[u,o,v,t]),E=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(ks,{value:u||"__none",onValueChange:I=>{const P=I==="__none"?"":I;h(P),P?v(P):p([])},children:[s.jsx(Cs,{size:"lg",className:r?"w-full":void 0,children:w?s.jsx(hs,{children:C(w)}):s.jsx(hs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(Ns,{children:[o.length===0?s.jsx(Yt,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(I=>s.jsx(Yt,{value:I.id,children:C(I)},I.id))]})]})]}),$=()=>{g(null),y(!0)},L=I=>{h(I),I?v(I):p([])},X=s.jsx("div",{className:"min-h-[280px]",children:x?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(O,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(I=>{const P=j===I.id,A=I.state?.lastStatus||"idle",q=Y4[A],K=t(A==="success"?"sessions.scheduledTasks.dialog.status.success":A==="error"?"sessions.scheduledTasks.dialog.status.error":A==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),te=I.state?.nextRunAt,ae=I.state?.lastRunAt;return s.jsxs("div",{className:Me("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Me("min-w-0",!I.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:I.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:G4(I,t)}),I.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:I.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:I.loopFile})}):null]}),s.jsxs("div",{className:Me("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!I.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),te?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:jd(te,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:q4(te,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(O,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),A==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(O,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):ae?s.jsxs(s.Fragment,{children:[q.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${q.tone})`},children:[s.jsx(O,{name:q.Icon,className:"h-3.5 w-3.5"}),K]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:jd(ae,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),I.state?.lastError?s.jsxs("div",{className:Me("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!I.enabled&&"opacity-60"),style:Q4("error"),children:[s.jsx(O,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:I.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Me("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",I.enabled?"text-foreground":"text-muted-foreground",P&&"cursor-not-allowed opacity-50"),children:[s.jsx(hr,{checked:I.enabled,onChange:re=>{T(I,re)},ariaLabel:I.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:I.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:I.name}),disabled:P}),I.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>{B(I)},disabled:P,children:[s.jsx(O,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ut,{variant:"outline",size:"sm",onClick:()=>F(I),disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:I.name}),children:[s.jsx(O,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ut,{variant:"destructive",size:"sm",onClick:()=>{D(I)},disabled:P,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:I.name}),children:s.jsx(O,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},I.id)})})}),Y=s.jsxs("div",{className:"space-y-4",children:[E,X]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Jo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:I=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),I]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ut,{className:"w-full",onClick:$,disabled:!u,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:Y}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(I=>s.jsx("button",{type:"button",onClick:()=>L(I.id),className:Me("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===I.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:C(I)},I.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(ut,{size:"sm",onClick:$,disabled:!u,children:[s.jsx(O,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:X})})]})]})}):null,s.jsx(z4,{open:k,task:m,onOpenChange:y,onSave:R})]})}const To=100;function J4(){const t=Ze.c(108),{t:e}=St(),n=Ae(aC),r=Ae(iC),i=nt(oC),o=nt(rC),l=Jt(nC);let a;t[0]!==n?(a=te=>n?te.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=us(Qn(a)),[u,h]=c.useState(""),[f,p]=c.useState(null),[x,b]=c.useState(To);let k;t[2]!==u?(k=u.trim().toLowerCase(),t[2]=u,t[3]=k):k=t[3];const y=k;let m;e:{if(!n){let ae;t[4]===Symbol.for("react.memo_cache_sentinel")?(ae=[],t[4]=ae):ae=t[4],m=ae;break e}let te;t[5]!==d?(te=[...d].sort(sC),t[5]=d,t[6]=te):te=t[6],m=te}const g=m;let j;if(t[7]!==l||t[8]!==g||t[9]!==e){const te=new Map;for(const ae of g){const re=xt(xs(ae))??"",he=te.get(re);if(he){he.sessions.push(ae);continue}te.set(re,{directory:re,label:re?Yn(re,l)||re:e("sessions.archivePage.otherProjects"),sessions:[ae]})}j=[...te.values()].sort(tC),t[7]=l,t[8]=g,t[9]=e,t[10]=j}else j=t[10];const S=j;let w;e:{if(y){if(y.startsWith("ses_")){let re;if(t[11]!==y||t[12]!==g){let he;t[14]!==y?(he=ce=>ce.id.toLowerCase()===y,t[14]=y,t[15]=he):he=t[15],re=g.filter(he),t[11]=y,t[12]=g,t[13]=re}else re=t[13];w=re;break e}let ae;t[16]!==y||t[17]!==g?(ae=mx(g,y,eC),t[16]=y,t[17]=g,t[18]=ae):ae=t[18],w=ae;break e}if(f===null){w=g;break e}let te;t[19]!==S||t[20]!==f?(te=S.find(ae=>ae.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=te):te=t[21],w=te}const C=w;let v,R,T,D,F,B,E,$,L,X;if(t[22]!==d.length||t[23]!==S||t[24]!==C||t[25]!==l||t[26]!==y||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==x){F=Symbol.for("react.early_return_sentinel");e:{const te=C.slice(0,x);v=C.length-te.length;const ae=d.length;let re;t[45]===Symbol.for("react.memo_cache_sentinel")?(re=be=>{p(be),b(To)},t[45]=re):re=t[45];const he=re;let ce;t[46]!==i||t[47]!==r?(ce=be=>{const G=xt(xs(be));i(be.id,G??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ce):ce=t[48];const Te=ce;let ve;t[49]!==e||t[50]!==o?(ve=be=>{o(be.id).then(G=>{G?ze.success(e("sessions.sidebar.session.restore.success")):ze.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=ve):ve=t[51];const pe=ve;if(!n){F=null;break e}let Ne;t[52]!==e?(Ne=(be,G,z,J,ue,le,W)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:ue,title:le,className:Me("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",W?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",J?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:z})]}),W?s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>Qs.requestDelete({sessions:W,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:G}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(wt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},be),t[52]=e,t[53]=Ne):Ne=t[53];const U=Ne;D="absolute inset-0 z-10 flex flex-col bg-background",R="flex min-h-0 flex-1";let Z;if(t[54]!==U||t[55]!==f||t[56]!==e||t[57]!==ae){let be;t[59]===Symbol.for("react.memo_cache_sentinel")?(be=()=>he(null),t[59]=be):be=t[59],Z=U("__all__",e("sessions.archivePage.allDirectories"),ae,f===null,be),t[54]=U,t[55]=f,t[56]=e,t[57]=ae,t[58]=Z}else Z=t[58];let de;if(t[60]!==S||t[61]!==U||t[62]!==f){let be;t[64]!==U||t[65]!==f?(be=G=>U(G.directory||"__none__",G.label,G.sessions.length,f===G.directory,()=>he(G.directory),G.directory||void 0,G.sessions),t[64]=U,t[65]=f,t[66]=be):be=t[66],de=S.map(be),t[60]=S,t[61]=U,t[62]=f,t[63]=de}else de=t[63];t[67]!==Z||t[68]!==de?(T=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[Z,de]})}),t[67]=Z,t[68]=de,t[69]=T):T=t[69],L="flex min-w-0 flex-1 flex-col";let ye;t[70]===Symbol.for("react.memo_cache_sentinel")?(ye=be=>{h(be),b(To)},t[70]=ye):ye=t[70];let H;t[71]!==e?(H=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=H):H=t[72];let je;t[73]!==e?(je=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=je):je=t[74];let Ee;t[75]!==u||t[76]!==H||t[77]!==je?(Ee=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Zd,{value:u,onSearch:ye,placeholder:H,clearLabel:je})}),t[75]=u,t[76]=H,t[77]=je,t[78]=Ee):Ee=t[78];let ge;t[79]!==C.length||t[80]!==e?(ge=C.length===1?e("sessions.archivePage.countSingle",{count:C.length}):e("sessions.archivePage.countPlural",{count:C.length}),t[79]=C.length,t[80]=e,t[81]=ge):ge=t[81];let ne;t[82]!==ge?(ne=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:ge}),t[82]=ge,t[83]=ne):ne=t[83],t[84]!==Ee||t[85]!==ne?(X=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ee,ne]}),t[84]=Ee,t[85]=ne,t[86]=X):X=t[86],$="min-h-0 flex-1 overflow-y-auto px-6 py-3",B="mx-auto w-full max-w-3xl space-y-0.5",E=te.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(y?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):te.map(be=>{const G=xt(xs(be))??"",z=G?Yn(G,l)||G:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Te(be),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),Te(be))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:be.title||e("sessions.sidebar.session.untitled")}),y&&z?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:G,children:z}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Uu(be.time?.archived??be.time?.updated??be.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),pe(be)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),Qs.requestDelete({sessions:[be],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:be.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(O,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},be.id)})}t[22]=d.length,t[23]=S,t[24]=C,t[25]=l,t[26]=y,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=x,t[35]=v,t[36]=R,t[37]=T,t[38]=D,t[39]=F,t[40]=B,t[41]=E,t[42]=$,t[43]=L,t[44]=X}else v=t[35],R=t[36],T=t[37],D=t[38],F=t[39],B=t[40],E=t[41],$=t[42],L=t[43],X=t[44];if(F!==Symbol.for("react.early_return_sentinel"))return F;let Y;t[87]!==v||t[88]!==e?(Y=v>0?s.jsx("button",{type:"button",onClick:()=>b(Z4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=v,t[88]=e,t[89]=Y):Y=t[89];let I;t[90]!==Y||t[91]!==B||t[92]!==E?(I=s.jsxs("div",{className:B,children:[E,Y]}),t[90]=Y,t[91]=B,t[92]=E,t[93]=I):I=t[93];let P;t[94]!==I||t[95]!==$?(P=s.jsx("div",{className:$,children:I}),t[94]=I,t[95]=$,t[96]=P):P=t[96];let A;t[97]!==P||t[98]!==L||t[99]!==X?(A=s.jsxs("div",{className:L,children:[X,P]}),t[97]=P,t[98]=L,t[99]=X,t[100]=A):A=t[100];let q;t[101]!==R||t[102]!==T||t[103]!==A?(q=s.jsxs("div",{className:R,children:[T,A]}),t[101]=R,t[102]=T,t[103]=A,t[104]=q):q=t[104];let K;return t[105]!==D||t[106]!==q?(K=s.jsx("div",{className:D,children:q}),t[105]=D,t[106]=q,t[107]=K):K=t[107],K}function Z4(t){return t+To}function eC(t){return[t.title]}function tC(t,e){return e.sessions.length-t.sessions.length}function sC(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function nC(t){return t.homeDirectory}function rC(t){return t.unarchiveSession}function oC(t){return t.setCurrentSession}function iC(t){return t.setArchivePageOpen}function aC(t){return t.isArchivePageOpen}function lC(){const t=Ze.c(18),{t:e}=St(),n=Ae(uC),r=Ae(dC),i=zt(cC);let o;t[0]!==n?(o=x=>x.projects.find(b=>b.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=zt(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(O,{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 h;t[9]!==a||t[10]!==u?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(ut,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(sp,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let p;return t[15]!==h||t[16]!==f?(p=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=p):p=t[17],p}function cC(t){return t.setActiveProjectIdOnly}function dC(t){return t.setNewWorktreeDialogOpen}function uC(t){return t.worktreesPageProjectId}function hm(t){const e=Ze.c(30),{git:n}=nn(),r=ku(t),i=Cu(t),o=hx(t),l=px(t),a=pn(gC),d=pn(pC);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},h=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=h):(u=e[5],h=e[6]),c.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const p=r?.all;let x;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==p?(x=[t,n,i,p,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=p,e[18]=x):x=e[18],c.useEffect(f,x);const b=o||i===!0&&l;let k;e:{if(!r?.all){let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[19]=v):v=e[19],k=v;break e}let C;e[20]!==r.all?(C=r.all.filter(hC).sort(),e[20]=r.all,e[21]=C):C=e[21],k=C}const y=k;let m;e:{if(!r?.all){let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[22]=v):v=e[22],m=v;break e}let C;e[23]!==r.all?(C=r.all.filter(mC).map(fC).sort(),e[23]=r.all,e[24]=C):C=e[24],m=C}const g=m;let j;e:{if(!t){j=null;break e}if(i!==null){j=i;break e}if(b){j=null;break e}j=r?.all?!0:null}const S=j;let w;return e[25]!==S||e[26]!==b||e[27]!==y||e[28]!==g?(w={localBranches:y,remoteBranches:g,isLoading:b,isGitRepository:S},e[25]=S,e[26]=b,e[27]=y,e[28]=g,e[29]=w):w=e[29],w}function fC(t){return t.replace(/^remotes\//,"")}function mC(t){return t.startsWith("remotes/")}function hC(t){return!t.startsWith("remotes/")}function pC(t){return t.fetchStatus}function gC(t){return t.fetchBranches}const xC=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=St(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=hm(t),f=c.useMemo(()=>[...a,...d.map(x=>`remotes/${x}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const x=e;let b=!1;return(async()=>{try{const y=t?await $a(t).catch(()=>null):null;if(b)return;const m=localStorage.getItem(Pl),{sourceBranch:g,shouldClearSavedSourceBranch:j}=np({branches:f,savedSourceBranch:m,rootBranch:y});if(j&&localStorage.removeItem(Pl),b||x&&f.includes(x))return;g&&n(g)}catch{}})(),()=>{b=!0}},[f,t,i,u,n,e]);const p=i||!h||u;return s.jsxs("div",{children:[s.jsxs(ks,{value:e,onValueChange:n,disabled:p,children:[s.jsx(Cs,{id:o,size:"lg",className:Me("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(hs,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Ns,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(sa,{children:[s.jsx(Kl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(x=>s.jsx(Yt,{value:x,className:"whitespace-normal break-all",children:x},x))]}),a.length>0&&d.length>0&&s.jsx(gx,{}),d.length>0&&s.jsxs(sa,{children:[s.jsx(Kl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(x=>s.jsx(Yt,{value:`remotes/${x}`,className:"whitespace-normal break-all",children:x},`remotes/${x}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},bC=10*1024*1024,Eo=t=>{const e=Ze.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(O,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(bt,{children:[r,s.jsx(wt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Wn=t=>{const e=Ze.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},yC=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=St(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Kr(),prompt:"",models:[]}]),[u,h]=c.useState(""),[f,p]=c.useState([]),[x,b]=c.useState(!1),[k,y]=c.useState([]),[m,g]=c.useState(!1),[j,S]=c.useState(!1),[w,C]=c.useState(!0),v=c.useRef(null),R=Jt(M=>M.currentDirectory??null),T=Jt(M=>M.homeDirectory??null),D=c.useMemo(()=>{if(typeof window>"u")return null;const M=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof M=="string"&&M.trim().length>0?M.trim():null},[]),F=zt(M=>M.activeProjectId),B=zt(M=>M.setActiveProjectIdOnly),E=zt(M=>M.projects),[$,L]=c.useState(()=>F??null);c.useEffect(()=>{if(F){L(F);return}!$&&E.length>0&&L(E[0].id)},[F,E,$]);const X=c.useMemo(()=>$?E.find(M=>M.id===$)??null:null,[E,$]),Y=X?.path??R,I=c.useCallback(M=>{L(M),M!==F&&B(M)},[F,B]),{currentTheme:P}=Cn(),A=c.useCallback(M=>{const _=M.label?.trim()||Yn(M.path,T),ee=M.icon?ei[M.icon]:null,oe=M.color?ti[M.color]:void 0,fe=ee?s.jsx(O,{name:ee,className:"h-3.5 w-3.5 shrink-0",style:oe?{color:oe}:void 0}):s.jsx(O,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:oe?{color:oe}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[M.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:M.iconBackground?{backgroundColor:M.iconBackground}:void 0,children:s.jsx(si,{project:{id:M.id,iconImage:M.iconImage??null},options:{themeVariant:P.metadata.variant,iconColor:P.colors.surface.foreground},className:"h-full w-full object-contain",fallback:fe})}):fe,s.jsx("span",{className:"truncate",children:_})]})},[T,P.metadata.variant,P.colors.surface.foreground]),q=c.useMemo(()=>{if(X?.path)return{id:X.id,path:X.path};const M=R??D;return M?{id:`path:${M}`,path:M}:null},[X,R,D]),[K]=c.useState(()=>typeof window<"u"?en():!1),te=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),ae=mu(),re=c.useMemo(()=>{if(typeof window>"u")return null;const M=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof M=="number"&&Number.isFinite(M)&&M>0)return M;if(typeof navigator>"u")return null;const _=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!_)return null;const ee=Number.parseInt(_[1],10),oe=Number.parseInt(_[2],10);return Number.isNaN(ee)?null:ee===10?oe:ee},[]),he=c.useMemo(()=>K&&te||ae?"pl-[88px]":"pl-3",[K,te,ae]),ce=c.useMemo(()=>!K||!te||re===null?"":re>=26?"h-12":re<=15?"h-14":"",[K,te,re]),Te=c.useCallback(async M=>{M.target.closest("button, a, input, select, textarea")||M.button===0&&K&&await xx()},[K]);c.useEffect(()=>{if(!n)return;const M=_=>{_.key==="Escape"&&(_.preventDefault(),_.stopPropagation(),n())};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[n]);const[ve,pe]=c.useState(""),{isLoading:Ne,isGitRepository:U}=hm(Y),Z=c.useRef(!1),de=U===!0,ye=de&&w;c.useEffect(()=>{if(U===!1){Z.current=!0,C(!1);return}U===!0&&Z.current&&(Z.current=!1,C(!0))},[U]);const H=ki(M=>M.createMultiRun),je=ki(M=>M.error),Ee=ki(M=>M.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(M=>{const _=[...M];return _.length>0&&!_[0].prompt.trim()&&(_[0]={..._[0],prompt:t}),_})},[t]),c.useEffect(()=>{if(!q)return;let M=!1;return S(!0),(async()=>{try{const _=await bx(q);M||y(_)}catch{}finally{M||S(!1)}})(),()=>{M=!0}},[q]);const ge=c.useCallback((M,_)=>{d(ee=>ee.map(oe=>oe.id===M?{...oe,..._}:oe))},[]),ne=c.useCallback(M=>{d(_=>_.filter(ee=>ee.id!==M))},[]),be=c.useCallback(()=>{d(M=>[...M,{id:Kr(),prompt:"",models:[]}])},[]),G=async M=>{const _=M.target.files;if(!_)return;let ee=0;for(let oe=0;oe<_.length;oe++){const fe=_[oe];if(fe.size>bC){ze.error(i("multirun.launcher.toast.fileTooLarge",{fileName:fe.name}));continue}try{const ie=await new Promise((Le,$e)=>{const Pe=new FileReader;Pe.onload=()=>Le(Pe.result),Pe.onerror=$e,Pe.readAsDataURL(fe)});p(Le=>[...Le,{id:Kr(),filename:fe.name,mimeType:fe.type||"application/octet-stream",size:fe.size,dataUrl:ie}]),ee++}catch(ie){console.error("File attach failed",ie),ze.error(i("multirun.launcher.toast.attachFailed",{fileName:fe.name}))}}ee>0&&ze.success(ee===1?i("multirun.launcher.toast.attachedSingle",{count:ee}):i("multirun.launcher.toast.attachedPlural",{count:ee})),v.current&&(v.current.value="")},z=M=>{p(_=>_.filter(ee=>ee.id!==M))},J=c.useMemo(()=>a.reduce((M,_)=>M+_.models.length,0),[a]),ue=async M=>{M.preventDefault();const _=a.filter(ee=>ee.prompt.trim()&&ee.models.length>=1);if(_.length!==0&&!(J<1)){b(!0),Ee();try{$&&$!==F&&B($);const ee=f.map($e=>({mime:$e.mimeType,filename:$e.filename,url:$e.dataUrl})),oe=k.filter($e=>$e.trim().length>0),fe=_.map($e=>({prompt:$e.prompt.trim(),models:$e.models.map(Pe=>({providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.displayName,variant:Pe.variant}))})),ie={name:o.trim(),groups:fe,agent:u||void 0,worktreeBaseBranch:ye?ve:void 0,isolateRuns:ye,files:ee.length>0?ee:void 0,setupCommands:oe.length>0?oe:void 0},Le=await H(ie);Le&&(Le.failedCount>0&&ze.error(i("multirun.launcher.toast.partialFailure",{failed:Le.failedCount})),Le.firstSessionId&&nt.getState().setCurrentSession(Le.firstSessionId),e?.())}finally{b(!1)}}},le=!!(o.trim()&&a.some(M=>M.prompt.trim()&&M.models.length>=1)&&J>=1&&Y&&!Ne&&(U===!1||!ye||ve)),W=k.filter(M=>M.trim()).length;return s.jsxs("form",{onSubmit:ue,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Te,className:Me("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",he,ce),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(O,{name:"close",className:"h-5 w-5"})})}),s.jsx(wt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(za,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),E.length>0?s.jsxs(ks,{value:$??void 0,onValueChange:I,children:[s.jsx(Cs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:X?s.jsx(hs,{children:A(X)}):s.jsx(hs,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(Ns,{fitContent:!0,children:E.map(M=>s.jsx(Yt,{value:M.id,className:"max-w-[24rem]",children:A(M)},M.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"group-name",required:!0,info:s.jsx(Eo,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(un,{id:"group-name",value:o,onChange:M=>l(M.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Eo,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(xC,{directory:Y,value:ve,onChange:pe,disabled:!ye,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(hr,{checked:w,onChange:C,disabled:!de,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Wn,{htmlFor:"multirun-agent",info:s.jsx(Eo,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(sm,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Qi,{open:m,onOpenChange:g,children:[s.jsxs(ju,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(O,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),W>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:W}),s.jsx(O,{name:"arrow-down-s",className:Me("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Xi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:j?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[k.map((M,_)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(un,{value:M,onChange:ee=>{const oe=[...k];oe[_]=ee.target.value,y(oe)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>y(k.filter((ee,oe)=>oe!==_)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})})]},`${M}-${_}`)),s.jsxs("button",{type:"button",onClick:()=>y([...k,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(O,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Wn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:G,accept:"*/*"}),s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>v.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(O,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(wt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(M=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[M.mimeType.startsWith("image/")?s.jsx(O,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(O,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:M.filename,children:M.filename}),s.jsx("button",{type:"button",onClick:()=>z(M.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(O,{name:"close",className:"h-3 w-3"})})]},M.id))]})]}),a.map((M,_)=>s.jsx(wC,{group:M,groupIndex:_,canRemove:a.length>1,onUpdate:ge,onRemove:ne},M.id)),s.jsxs("button",{type:"button",onClick:be,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(O,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),je&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:je})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!ye&&U!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(O,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(ut,{type:"submit",size:"sm",disabled:!le||x,children:x?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:J})})})]})})]})},wC=t=>{const e=Ze.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=St(),[d,u]=c.useState(!1),[h,f]=c.useState(""),[p,x]=c.useState(!1),[b,k]=c.useState(""),[y,m]=c.useState(!1),[g,j]=c.useState(""),S=c.useRef(null),w=c.useRef(null),C=c.useRef(null),v=c.useRef(null);let R;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(R=oe=>{o(n.id,{models:[...n.models,oe]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=R):R=e[3];const T=R;let D;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(D=oe=>{o(n.id,{models:n.models.filter((fe,ie)=>ie!==oe)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=D):D=e[7];const F=D;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(B=(oe,fe)=>{o(n.id,{models:n.models.map((ie,Le)=>Le===oe?fe:ie)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=B):B=e[11];const E=B;let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(oe,fe)=>{if(oe.startsWith("/")){const Pe=oe.indexOf(" "),Oe=oe.indexOf(`
893
+ `),Q=Math.min(Pe===-1?oe.length:Pe,Oe===-1?oe.length:Oe);if(fe<=Q&&Pe===-1){k(oe.substring(1,Q)),x(!0),u(!1),m(!1);return}}x(!1);const ie=oe.substring(0,fe),Le=ie.lastIndexOf("#");if(Le!==-1){const Pe=Le>0?ie[Le-1]:null,Oe=ie.substring(Le+1);if((!Pe||/\s/.test(Pe))&&!Oe.includes(" ")&&!Oe.includes(`
894
+ `)){j(Oe),m(!0),u(!1);return}}m(!1);const $e=ie.lastIndexOf("@");if($e!==-1){const Pe=$e>0?ie[$e-1]:null,Oe=ie.substring($e+1);(!Pe||/\s/.test(Pe))&&!Oe.includes(" ")&&!Oe.includes(`
895
+ `)?(f(Oe),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const L=$;let X;e[13]!==n.id||e[14]!==o?(X=oe=>{o(n.id,{prompt:oe})},e[13]=n.id,e[14]=o,e[15]=X):X=e[15];const Y=X;let I;e[16]!==n.prompt||e[17]!==Y?(I=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=oe.relativePath&&oe.relativePath.trim().length>0?oe.relativePath.trim():oe.path||oe.name,Q=Pe!==-1?Pe:Le,Ce=`${fe.substring(0,Q)}@${Oe} ${fe.substring(Le)}`,Se=Q+Oe.length+2;Y(Ce),u(!1),f(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[16]=n.prompt,e[17]=Y,e[18]=I):I=e[18];const P=I;let A;e[19]!==n.prompt||e[20]!==Y?(A=oe=>{const fe=n.prompt,Le=S.current?.selectionStart??fe.length,Pe=fe.substring(0,Le).lastIndexOf("@"),Oe=Pe!==-1?Pe:Le,Q=`${fe.substring(0,Oe)}@${oe} ${fe.substring(Le)}`,Ce=Oe+oe.length+2;Y(Q),u(!1),f(""),requestAnimationFrame(()=>{const Se=S.current;Se&&(Se.selectionStart=Ce,Se.selectionEnd=Ce,Se.focus()),L(Q,Ce)})},e[19]=n.prompt,e[20]=Y,e[21]=A):A=e[21];const q=A;let K;e[22]!==Y?(K=oe=>{const fe=`/${oe.name} `;Y(fe),x(!1),k(""),m(!1),requestAnimationFrame(()=>{const ie=S.current;ie&&(ie.focus(),ie.selectionStart=ie.value.length,ie.selectionEnd=ie.value.length),L(fe,fe.length)})},e[22]=Y,e[23]=K):K=e[23];const te=K;let ae;e[24]!==n.prompt||e[25]!==Y?(ae=(oe,fe)=>{const ie=n.prompt,$e=S.current?.selectionStart??ie.length,Oe=ie.substring(0,$e).lastIndexOf("#"),Q=Oe!==-1?Oe:$e,Ce=`${ie.substring(0,Q)}#${fe} ${ie.substring($e)}`,Se=Q+fe.length+2;Y(Ce),m(!1),j(""),requestAnimationFrame(()=>{const Ke=S.current;Ke&&(Ke.selectionStart=Se,Ke.selectionEnd=Se,Ke.focus()),L(Ce,Se)})},e[24]=n.prompt,e[25]=Y,e[26]=ae):ae=e[26];const re=ae;let he;e[27]!==p||e[28]!==d||e[29]!==y?(he=oe=>{if(p&&C.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")){oe.preventDefault(),C.current.handleKeyDown(oe.key);return}d&&w.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),w.current.handleKeyDown(oe.key)),y&&v.current&&(oe.key==="Enter"||oe.key==="ArrowUp"||oe.key==="ArrowDown"||oe.key==="Escape"||oe.key==="Tab")&&(oe.preventDefault(),v.current.handleKeyDown(oe.key))},e[27]=p,e[28]=d,e[29]=y,e[30]=he):he=e[30];const ce=he,Te=r+1;let ve;e[31]!==a||e[32]!==Te?(ve=a("multirun.launcher.groups.groupLabel",{index:Te}),e[31]=a,e[32]=Te,e[33]=ve):ve=e[33];let pe;e[34]!==ve?(pe=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ve}),e[34]=ve,e[35]=pe):pe=e[35];let Ne;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ne=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(O,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ne):Ne=e[40];let U;e[41]!==pe||e[42]!==Ne?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[pe,Ne]}),e[41]=pe,e[42]=Ne,e[43]=U):U=e[43];let Z;e[44]!==a?(Z=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=Z):Z=e[45];let de;e[46]!==Z?(de=s.jsx(Wn,{required:!0,children:Z}),e[46]=Z,e[47]=de):de=e[47];const ye=n.prompt;let H;e[48]!==Y?(H=oe=>{const fe=oe.target.value;Y(fe);const ie=oe.target.selectionStart??fe.length;L(fe,ie)},e[48]=Y,e[49]=H):H=e[49];let je;e[50]!==a?(je=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=je):je=e[51];let Ee;e[52]!==n.prompt||e[53]!==ce||e[54]!==H||e[55]!==je?(Ee=s.jsx(fr,{ref:S,value:ye,onChange:H,onKeyDown:ce,placeholder:je,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ce,e[54]=H,e[55]=je,e[56]=Ee):Ee=e[56];let ge;e[57]!==b||e[58]!==te||e[59]!==p?(ge=p?s.jsx(Hu,{ref:C,searchQuery:b,onCommandSelect:te,onClose:()=>x(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=b,e[58]=te,e[59]=p,e[60]=ge):ge=e[60];let ne;e[61]!==q||e[62]!==P||e[63]!==h||e[64]!==d?(ne=d?s.jsx(Gu,{ref:w,searchQuery:h,onFileSelect:P,onAgentSelect:q,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=q,e[62]=P,e[63]=h,e[64]=d,e[65]=ne):ne=e[65];let be;e[66]!==re||e[67]!==y||e[68]!==g?(be=y?s.jsx(qu,{ref:v,searchQuery:g,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=y,e[68]=g,e[69]=be):be=e[69];let G;e[70]!==Ee||e[71]!==ge||e[72]!==ne||e[73]!==be?(G=s.jsxs("div",{className:"relative",children:[Ee,ge,ne,be]}),e[70]=Ee,e[71]=ge,e[72]=ne,e[73]=be,e[74]=G):G=e[74];let z;e[75]!==de||e[76]!==G?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,G]}),e[75]=de,e[76]=G,e[77]=z):z=e[77];let J;e[78]!==a?(J=a("multirun.launcher.models.info"),e[78]=a,e[79]=J):J=e[79];let ue;e[80]!==J?(ue=s.jsx(Eo,{children:J}),e[80]=J,e[81]=ue):ue=e[81];let le;e[82]!==a?(le=a("multirun.launcher.models.label"),e[82]=a,e[83]=le):le=e[83];let W;e[84]!==ue||e[85]!==le?(W=s.jsx(Wn,{required:!0,info:ue,children:le}),e[84]=ue,e[85]=le,e[86]=W):W=e[86];let M;e[87]!==n.models||e[88]!==T||e[89]!==F||e[90]!==E?(M=s.jsx(nm,{selectedModels:n.models,onAdd:T,onRemove:F,onUpdate:E,minModels:1}),e[87]=n.models,e[88]=T,e[89]=F,e[90]=E,e[91]=M):M=e[91];let _;e[92]!==W||e[93]!==M?(_=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[W,M]}),e[92]=W,e[93]=M,e[94]=_):_=e[94];let ee;return e[95]!==U||e[96]!==z||e[97]!==_?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[U,z,_]}),e[95]=U,e[96]=z,e[97]=_,e[98]=ee):ee=e[98],ee};function vC(t){const e=[],n=(r,i)=>{const o=xt(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const SC=t=>{const e=new Map;for(const n of t){const r=xs(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},jC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},kC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=Wt(),h=SC(i),f=l.current?.runtimeKey===u?l.current.identities:null,p=Hd.getState().spaces;for(const x of jC(f,h)){const b=fh(x.directory),k=b===null?null:p.get(b);k&&k.state!=="complete"||yx({runtimeKey:u,...x})}l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},CC=new Map,NC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=ni(),i=zt(AC),o=Jt(PC),l=nt(DC);let a;e[0]!==n?(a=T=>n?CC:T.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=nt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=um(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,p=us(IC),x=us(TC),b=us(EC),k=`session-list-sync:${c.useId()}`;let y,m;e[6]!==k||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(k,vC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(k)),m=[k,r,o,l],e[6]=k,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const g=c.useRef(null);let j,S;e[12]!==n||e[13]!==f?(j=()=>{const T=new Set(f),D=g.current;g.current=T;const F=D?[...T].filter(B=>!D.has(B)):n?[...T]:[];F.length&&Ba(F,Lo())},S=[n,f],e[12]=n,e[13]=f,e[14]=j,e[15]=S):(j=e[14],S=e[15]),c.useEffect(j,S);let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=[],e[16]=w):w=e[16],c.useEffect(RC,w);let C;e[17]!==x||e[18]!==p?(C=[...p,...x],e[17]=x,e[18]=p,e[19]=C):C=e[19];const v=C;let R;e[20]!==v||e[21]!==b?(R={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:v},e[20]=v,e[21]=b,e[22]=R):R=e[22],kC(R)};function AC(t){return t.projects}function PC(t){return t.currentDirectory}function DC(t){return t.currentSessionDirectory}function IC(t){return t.activeSessions}function TC(t){return t.archivedSessions}function EC(t){return t.status==="ready"}function RC(){let t=null,e=!1;const n=new Set,r=Pn(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),ri(Lo());return}const o=[...n];n.clear(),o.length&&Ba(o,Lo())},500)});return()=>{t&&clearTimeout(t),r()}}const MC=Dn(()=>sn(()=>import("./SettingsWindow-DuC4ecLw.js"),__vite__mapDeps([146,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,147,84,85,86,148,132,133,134,135,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,149,150,151])).then(t=>({default:t.SettingsWindow}))),OC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],NC(e),rp();const n=Ae(BC),r=Ae(FC),i=Ae(LC),o=Ae(_C),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Ae($C),f=Ae(zC),p=Ae(WC),x=Ae(KC),b=Ae(VC),k=Ae(UC),y=Ae(HC),m=Ae(GC),g=Ou();let j;if(t[4]!==g||t[5]!==m){let G;t[7]!==m?(G=z=>z.id===m,t[7]=m,t[8]=G):G=t[8],j=g.find(G),t[4]=g,t[5]=m,t[6]=j}else j=t[6];const S=j;let w,C;t[9]!==S||t[10]!==m?(w=()=>{m&&!S&&Ae.getState().setOpenGuestPage(null)},C=[m,S],t[9]=S,t[10]=m,t[11]=w,t[12]=C):(w=t[11],C=t[12]),c.useEffect(w,C);let v;t[13]===Symbol.for("react.memo_cache_sentinel")?(v=[],t[13]=v):v=t[13],c.useEffect(YC,v);const R=x||b||k||!!y||h||!!S;let T;t[14]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[14]=T):T=t[14],c.useEffect(XC,T);const{isMobile:D}=Nn();op();let F,B;t[15]!==D||t[16]!==r?(F=()=>{Ae.getState().isMobile!==D&&r(D)},B=[D,r],t[15]=D,t[16]=r,t[17]=F,t[18]=B):(F=t[17],B=t[18]),c.useEffect(F,B);let E,$,L,X,Y;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(lj,{}),$=s.jsx(o0,{}),L=s.jsx(c0,{}),X=s.jsx(k4,{}),Y=s.jsx(Oy,{}),t[19]=E,t[20]=$,t[21]=L,t[22]=X,t[23]=Y):(E=t[19],$=t[20],L=t[21],X=t[22],Y=t[23]);let I;t[24]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(My,{}),t[24]=I):I=t[24];let P;t[25]!==n?(P=s.jsx(j4,{isVisible:n}),t[25]=n,t[26]=P):P=t[26];let A;t[27]!==D||t[28]!==n||t[29]!==P?(A=s.jsx(Ry,{isOpen:n,isMobile:D,className:"border-border",topBar:I,children:P}),t[27]=D,t[28]=n,t[29]=P,t[30]=A):A=t[30];let q;t[31]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Ty,{}),t[31]=q):q=t[31];const K=R&&"invisible";let te;t[32]!==K?(te=Me("absolute inset-0",K),t[32]=K,t[33]=te):te=t[33];const ae=!i&&!R;let re;t[34]!==ae?(re=s.jsx(ps,{children:s.jsx(nu,{active:ae})}),t[34]=ae,t[35]=re):re=t[35];let he;t[36]!==te||t[37]!==re?(he=s.jsx("div",{className:te,children:re}),t[36]=te,t[37]=re,t[38]=he):he=t[38];let ce;t[39]!==h||t[40]!==p||t[41]!==f?(ce=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(yC,{isWindowed:!0,initialPrompt:p,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[39]=h,t[40]=p,t[41]=f,t[42]=ce):ce=t[42];let Te;t[43]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(ps,{children:s.jsx(X4,{})}),t[43]=Te):Te=t[43];let ve;t[44]===Symbol.for("react.memo_cache_sentinel")?(ve=s.jsx(ps,{children:s.jsx(J4,{})}),t[44]=ve):ve=t[44];let pe;t[45]!==k?(pe=k&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(ip,{})})}),t[45]=k,t[46]=pe):pe=t[46];let Ne;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ne=s.jsx(ps,{children:s.jsx(lC,{})}),t[47]=Ne):Ne=t[47];let U;t[48]!==S?(U=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(ps,{children:s.jsx(Nb,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:JC})})}),t[48]=S,t[49]=U):U=t[49];let Z;t[50]!==he||t[51]!==ce||t[52]!==pe||t[53]!==U?(Z=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[he,ce,Te,ve,pe,Ne,U]}),t[50]=he,t[51]=ce,t[52]=pe,t[53]=U,t[54]=Z):Z=t[54];let de;t[55]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(IS,{}),t[55]=de):de=t[55];let ye;t[56]!==Z?(ye=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[Z,de]})})}),t[56]=Z,t[57]=ye):ye=t[57];let H;t[58]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(ps,{children:s.jsx($S,{})})}),t[58]=H):H=t[58];let je;t[59]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(ps,{children:s.jsx(Zx,{})}),t[59]=je):je=t[59];let Ee;t[60]!==ye?(Ee=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[q,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ye,H,je]})]}),t[60]=ye,t[61]=Ee):Ee=t[61];let ge;t[62]!==A||t[63]!==Ee?(ge=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[A,Ee]}),t[62]=A,t[63]=Ee,t[64]=ge):ge=t[64];let ne;t[65]!==i||t[66]!==o||t[67]!==l?(ne=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(MC,{open:i,onOpenChange:o})}):null,t[65]=i,t[66]=o,t[67]=l,t[68]=ne):ne=t[68];let be;return t[69]!==ge||t[70]!==ne?(be=s.jsx(ap,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[E,$,L,X,Y,ge,ne]})}),t[69]=ge,t[70]=ne,t[71]=be):be=t[71],be};function BC(t){return t.isSidebarOpen}function FC(t){return t.setIsMobile}function LC(t){return t.isSettingsDialogOpen}function _C(t){return t.setSettingsDialogOpen}function $C(t){return t.isMultiRunLauncherOpen}function zC(t){return t.setMultiRunLauncherOpen}function WC(t){return t.multiRunLauncherPrefillPrompt}function KC(t){return t.isScheduledTasksDialogOpen}function VC(t){return t.isArchivePageOpen}function UC(t){return t.isUsageStatsPageOpen}function HC(t){return t.worktreesPageProjectId}function GC(t){return t.openGuestPageId}function qC(){return Ae.getState().setOpenGuestPage(null)}function YC(){return vr(qC)}function QC(){return Ae.getState().closeMainSurfaces()}function XC(){const t=QC,e=nt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function JC(){return Ae.getState().setOpenGuestPage(null)}const pm=12,ZC=[{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"}],e5=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?ZC:l,f=ct.useRef(!1);let p,x;e[0]!==n||e[1]!==a?(p=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},x=[n,a],e[0]=n,e[1]=a,e[2]=p,e[3]=x):(p=e[2],x=e[3]),ct.useEffect(p,x);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:pm},t5),e[4]=b):b=e[4];const k=b;if(!n)return null;let y;e[5]!==i?(y=Me("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let j;e[11]!==d||e[12]!==u?(j=S=>{const w={"--burst-delay":`${S.delay}ms`,"--burst-x":`${S.x}%`,"--burst-y":`${S.y}%`,"--firework-color":`var(${S.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:w,children:k.map((C,v)=>{const R=C.x*S.radius,T=C.y*S.radius,D={"--translate-x":`${R}px`,"--translate-y":`${T}px`,"--particle-delay":`${C.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${S.id}-${v}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=j):j=e[13],m=h.map(j),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let g;return e[14]!==d||e[15]!==y||e[16]!==m?(g=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=g):g=e[17],g};function t5(t,e){const n=Math.PI*2*e/pm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const s5=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=ct.useState(o),d=ct.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(n5)},e[4]=f):f=e[4];const p=f;let x;e[5]!==i?(x=()=>{h(),a(r5),d.current=window.setTimeout(()=>{a(o5),d.current=null},i)},e[5]=i,e[6]=x):x=e[6];const b=x;let k,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>h(),y=[h],e[7]=k,e[8]=y):(k=e[7],y=e[8]),ct.useEffect(k,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:p},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=m):m=e[12],m};function n5(t){return t.isActive?{...t,isActive:!1}:t}function r5(t){return{isActive:!0,cycle:t.cycle+1}}function o5(t){return t.isActive?{...t,isActive:!1}:t}const gm=c.createContext(void 0),i5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=s5();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(e5,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(gm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},rA=()=>{const t=c.useContext(gm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Da="openchamber_requests_in_flight",xm=1e3,a5=300*1e3,Yo=Math.ceil(a5/xm),l5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Da)==="1"}catch{return!1}},bm=()=>({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 c5=1;const d5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},u5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},ym=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},yr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=c5++;d5(o,Date.now());try{return await e(r,i)}finally{u5(o)}};window.fetch=n},kd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Rr=t=>{t.length>Yo&&t.splice(0,t.length-Yo)},m5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=ym(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(yr(e,50)),t.p90Samples.push(yr(e,90)),t.p99Samples.push(yr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Rr(t.samples),Rr(t.p50Samples),Rr(t.p90Samples),Rr(t.p99Samples),Rr(t.maxSamples),t.lastSampleAt=Date.now()},h5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(m5,xm))},Cd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},Nd=t=>{if(!(typeof window>"u"))try{if(t){Cd(),kd(),window.localStorage.setItem(Da,"1"),window.__openchamberRequestsInFlight__=bm(),f5(),h5();return}window.localStorage.removeItem(Da),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},p5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=bm();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},Ia=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!l5()||!t)return Ad();const e=ym(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:yr(e,50),ageP90:yr(e,90),ageP99:yr(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:Yo}},Ad=()=>({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:Yo});function g5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const wm=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},Ta=t=>`${(t/1e3).toFixed(2)} s`,ds=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},Pd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=St();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(y5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?wm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let x;e[18]!==h||e[19]!==p?(x=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,p]}),e[18]=h,e[19]=p,e[20]=x):x=e[20];let b;e[21]!==o?(b=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=b):b=e[22];let k;e[23]!==r.entries.length||e[24]!==b?(k=s.jsx(ds,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=k):k=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(ds,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let g;e[31]!==o?(g=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=g):g=e[32];let j;e[33]!==r.lastUpdatedAt||e[34]!==o?(j=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=j):j=e[35];let S;e[36]!==g||e[37]!==j?(S=s.jsx(ds,{label:g,value:j}),e[36]=g,e[37]=j,e[38]=S):S=e[38];let w;e[39]!==m||e[40]!==S||e[41]!==k?(w=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[k,m,S]}),e[39]=m,e[40]=S,e[41]=k,e[42]=w):w=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[x,w,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(gn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(C=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:C.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:C.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:C.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:C.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:C.total})})]})]},C.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},Dd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(w5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=S=>a-d+S,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let p;e[3]!==u?(p=S=>56-S*u,e[3]=u,e[4]=p):p=e[4];const x=p;let b;e[5]!==l?(b=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=b):b=e[6];const k=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==x){let S;e[13]!==f||e[14]!==x?(S=(w,C)=>{const v=w.samples.length;if(v===0)return null;const R=w.samples.map((D,F)=>`${f(F)},${x(D).toFixed(2)}`),T=`M ${R.join(" L ")}`;return s.jsxs(c.Fragment,{children:[w.filled?s.jsx("path",{d:`M ${f(0)},56 L ${R.join(" L ")} L ${f(v-1)},56 Z`,fill:`color-mix(in srgb, ${w.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:T,fill:"none",stroke:w.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},C)},e[13]=f,e[14]=x,e[15]=S):S=e[15],m=n.map(S),e[9]=n,e[10]=f,e[11]=x,e[12]=m}else m=e[12];let g;e[16]!==o||e[17]!==k||e[18]!==y||e[19]!==m?(g=s.jsxs("svg",{viewBox:k,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=k,e[18]=y,e[19]=m,e[20]=g):g=e[20];let j;return e[21]!==b||e[22]!==g?(j=s.jsxs("div",{className:"relative w-full",children:[b,g]}),e[21]=b,e[22]=g,e[23]=j):j=e[23],j},x5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=St(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=nt(v5),u=Ku(S5),h=Pu(),f=wx(j5),p=Ms(k5),[x,b]=c.useState(C5),[k,y]=c.useState(N5),[m,g]=c.useState(A5),j=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let S;e[0]!==m.samples?(S=m.samples.reduce(P5,0),e[0]=m.samples,e[1]=S):S=e[1];const w=S,C=j.reduce(I5,0);let v;e[2]!==x.entries?(v=new Map,x.entries.forEach(Se=>{v.set(Se.metric,Se.count)}),e[2]=x.entries,e[3]=v):v=e[3];let R;e[4]!==v?(R=v.get("ui.message_list.render")??0,e[4]=v,e[5]=R):R=e[5];let T;e[6]!==v?(T=v.get("ui.message_list.render.streaming")??0,e[6]=v,e[7]=T):T=e[7];let D;e[8]!==v?(D=v.get("ui.chat_message.render")??0,e[8]=v,e[9]=D):D=e[9];let F;e[10]!==v?(F=v.get("ui.chat_message.render.streaming")??0,e[10]=v,e[11]=F):F=e[11];let B;e[12]!==v?(B=v.get("ui.chat_message.render.static_during_stream")??0,e[12]=v,e[13]=B):B=e[13];let E;e[14]!==v?(E=v.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=v,e[15]=E):E=e[15];let $;e[16]!==R||e[17]!==T||e[18]!==D||e[19]!==F||e[20]!==B||e[21]!==E?($={messageListRender:R,messageListRenderStreaming:T,chatMessageRender:D,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:B,chatMessageRenderStaticOutsideActiveTurnDuringStream:E},e[16]=R,e[17]=T,e[18]=D,e[19]=F,e[20]=B,e[21]=E,e[22]=$):$=e[22];const L=$;let X,Y;e[23]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>{const Se=()=>{b(ko()),y(Co()),g(Ia())};Se();const Ke=window.setInterval(Se,500);return()=>window.clearInterval(Ke)},X=[],e[23]=X,e[24]=Y):(X=e[23],Y=e[24]),c.useEffect(Y,X);let I,P;e[25]!==l?(I=()=>{if(l==="idle")return;const Se=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Se)},P=[l],e[25]=l,e[26]=I,e[27]=P):(I=e[26],P=e[27]),c.useEffect(I,P);let A=0,q=0,K=0;for(const Se of Object.keys(f)){const Ke=f[Se]??[];q=q+Ke.length;for(const et of Ke)et.role==="user"?K=K+1:et.role==="assistant"&&(A=A+1)}let te;e[28]!==A||e[29]!==q||e[30]!==K?(te={assistant:A,total:q,user:K},e[28]=A,e[29]=q,e[30]=K,e[31]=te):te=e[31];const ae=te;let re;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Se;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Se=Ke=>{const et=f[Ke.id]??[];let it=0,rt=0;for(const ht of et)ht.role==="user"?rt=rt+1:ht.role==="assistant"&&(it=it+1);const pt=u.get(Ke.id);return{id:Ke.id,title:Ke.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:it,messageCount:et.length,userMessageCount:rt,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:Ke.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Se):Se=e[42],re=h.map(Se).sort(T5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=re}else re=e[37];const he=re;let ce;e[43]!==f?(ce=Object.keys(f),e[43]=f,e[44]=ce):ce=e[44];const Te=ce.length;let ve;e[45]===Symbol.for("react.memo_cache_sentinel")?(ve=async()=>{try{const Se={generatedAt:new Date().toISOString(),ui:ko(),vscode:Co()};await navigator.clipboard.writeText(JSON.stringify(Se,null,2)),a("copied")}catch{a("error")}},e[45]=ve):ve=e[45];const pe=ve,Ne=Sx,U="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let Z;e[46]===Symbol.for("react.memo_cache_sentinel")?(Z={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=Z):Z=e[46];let de;e[47]!==i?(de=g5(i),e[47]=i,e[48]=de):de=e[48];let ye;e[49]!==de?(ye=s.jsx(O,{name:de,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=de,e[50]=ye):ye=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let je;e[53]!==H?(je=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=je):je=e[54];let Ee;e[55]!==ye||e[56]!==je?(Ee=s.jsxs("div",{className:"flex items-center gap-2",children:[ye,je]}),e[55]=ye,e[56]=je,e[57]=Ee):Ee=e[57];let ge;e[58]!==i?(ge=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ut,{size:"xs",variant:"ghost",onClick:pe,children:s.jsx(O,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{mh(),b(ko()),y(Co())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=ge):ge=e[59];let ne;e[60]!==i?(ne=i==="requests"?s.jsx(ut,{size:"xs",variant:"ghost",onClick:()=>{p5(),g(Ia())},children:s.jsx(O,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=ne):ne=e[61];let be;e[62]!==n?(be=n?s.jsx(ut,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(O,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=be):be=e[63];let G;e[64]!==ge||e[65]!==ne||e[66]!==be?(G=s.jsxs("div",{className:"flex items-center gap-1",children:[ge,ne,be]}),e[64]=ge,e[65]=ne,e[66]=be,e[67]=G):G=e[67];let z;e[68]!==Ee||e[69]!==G?(z=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Ee,G]}),e[68]=Ee,e[69]=G,e[70]=z):z=e[70];let J;e[71]===Symbol.for("react.memo_cache_sentinel")?(J={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=J):J=e[71];const ue=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let W;e[73]!==r?(W=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=W):W=e[74];let M;e[75]!==ue||e[76]!==W?(M=s.jsx(ut,{size:"sm",variant:ue,className:"flex-1",onClick:le,children:W}),e[75]=ue,e[76]=W,e[77]=M):M=e[77];const _=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let oe;e[79]!==r?(oe=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=oe):oe=e[80];let fe;e[81]!==_||e[82]!==oe?(fe=s.jsx(ut,{size:"sm",variant:_,className:"flex-1",onClick:ee,children:oe}),e[81]=_,e[82]=oe,e[83]=fe):fe=e[83];const ie=i==="requests"?"secondary":"ghost";let Le;e[84]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>o("requests"),e[84]=Le):Le=e[84];let $e;e[85]!==r?($e=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=$e):$e=e[86];let Pe;e[87]!==ie||e[88]!==$e?(Pe=s.jsx(ut,{size:"sm",variant:ie,className:"flex-1",onClick:Le,children:$e}),e[87]=ie,e[88]=$e,e[89]=Pe):Pe=e[89];let Oe;e[90]!==M||e[91]!==fe||e[92]!==Pe?(Oe=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[M,fe,Pe]}),e[90]=M,e[91]=fe,e[92]=Pe,e[93]=Oe):Oe=e[93];const Q=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.totalMessages"),value:ae.total}),s.jsx(ds,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Te} / ${Vl.MAX_SESSIONS}`}),s.jsx(ds,{label:r("memoryDebugPanel.metric.userMessages"),value:ae.user}),s.jsx(ds,{label:r("memoryDebugPanel.metric.assistantMessages"),value:ae.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:vx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Vl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(gn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:he.map(Se=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Se.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Se.title}),Se.isStreaming?s.jsx(O,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Se.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Se.assistantMessageCount,user:Se.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Se.messageCount})}),Se.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Se.backgroundCount]}):null]})]},Se.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(bt,{children:[s.jsx(yt,{asChild:!0,children:s.jsx(ut,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(E5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:ae,sessionMessageRoleCounts:he.map(R5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(wt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(ut,{size:"xs",variant:"outline",onClick:pe,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(ds,{label:r("memoryDebugPanel.metric.uiMetrics"),value:x.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:k.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListRenders"),value:L.messageListRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:L.messageListRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:L.chatMessageRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:L.chatMessageRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:L.chatMessageRenderStaticDuringStream}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:L.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),k.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:k,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(ds,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(ds,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?wm(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(Dd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:w,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${w}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(m.peakAgeMs)})]}),s.jsx(Dd,{series:j.map(M5),peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Ta(C)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:j.map(O5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let Ce;return e[94]!==Ne||e[95]!==Z||e[96]!==z||e[97]!==Oe||e[98]!==Q?(Ce=s.jsxs(Ne,{className:U,style:Z,children:[z,Oe,Q]}),e[94]=Ne,e[95]=Z,e[96]=z,e[97]=Oe,e[98]=Q,e[99]=Ce):Ce=e[99],Ce},b5=x5;function y5(t,e){return t+e.count}function w5(t,e){return Math.max(t,e.samples.length)}function v5(t){return t.currentSessionId}function S5(t){return t.sessionMemoryState}function j5(t){return t.message}function k5(t){return t.totalRequestCount}function C5(){return ko()}function N5(){return Co()}function A5(){return Ia()}function P5(t,e){return Math.max(t,e)}function D5(t,e){return Math.max(t,e)}function I5(t,e){return e.samples.reduce(D5,t)}function T5(t,e){return e.lastAccessed-t.lastAccessed}function E5(t){return{id:t.id,title:t.title}}function R5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function M5(t){return{samples:t.samples,color:t.color}}function O5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:Ta(t.current)})]},t.label)}const B5=()=>{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()??"":""},F5=async()=>{const t=B5()||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")},Id="openchamber:menu-action",zi="openchamber:check-for-updates",L5=t=>{const e=nt(m=>m.openNewSessionDraft),n=Ae(m=>m.toggleCommandPalette),r=Ae(m=>m.setCommandPaletteOpen),i=Ae(m=>m.toggleHelpDialog),o=Ae(m=>m.toggleSidebar),l=Ae(m=>m.setSessionSwitcherOpen),a=Ae(m=>m.setSettingsDialogOpen),d=Ae(m=>m.setAboutDialogOpen),u=_r(m=>m.checkForUpdates),{setThemeMode:h}=Cn(),f=c.useRef(!1),p=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:g}=_r.getState();if(g){ze.error("Failed to check for updates",{description:g});return}m||ze.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),x=c.useCallback(()=>{Qs.requestDirectoryDialog()},[]),b=c.useCallback(m=>{const g=jx();if(g.length===0)return;const j=nt.getState().currentSessionId,S=g.findIndex(v=>v.id===j);let w=m>0?0:g.length-1;S>=0&&(w=(S+m+g.length)%g.length);const C=g[w];C&&(l(!1),nt.getState().setCurrentSession(C.id))},[l]),k=c.useCallback(m=>{const{activeProjectId:g,projects:j,setActiveProject:S}=zt.getState();if(j.length===0)return;const w=j.findIndex(R=>R.id===g);let C=m>0?0:j.length-1;w>=0&&(C=(w+m+j.length)%j.length);const v=j[C];v&&S(v.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const g=nt.getState(),j=Jt.getState().currentDirectory;e(g.currentSessionId&&j?{directoryOverride:j}:void 0)}break;case"new-worktree-session":l(!1),Ru();break;case"change-workspace":x();break;case"toggle-right-sidebar":{const g=Jt.getState().currentDirectory;if(!g)break;const j=Ae.getState(),S=$n(g),w=j.contextPanelByDirectory[S];w?.isOpen?j.closeContextPanel(S):w?.activeTabId?j.setActiveContextPanelTab(S,w.activeTabId):j.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"git");break}case"open-right-sidebar-files":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"file");break}case"toggle-terminal":{const g=Jt.getState().currentDirectory;if(!g)break;Ae.getState().openContextSurface($n(g),"terminal");break}case"toggle-terminal-expanded":{const g=Jt.getState().currentDirectory;if(!g)break;const j=$n(g),S=Ae.getState(),w=S.contextPanelByDirectory[j];(w?.isOpen?w.tabs.find(v=>v.id===w.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(j,"terminal"),S.toggleContextPanelExpanded(j);break}case"copy":{const g=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(g)||F5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":kx();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":Jt.getState().goBack();break;case"go-forward":Jt.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":k(-1);break;case"next-project":k(1);break;case"help-dialog":i();break;case"download-logs":{Mu().catch(()=>{ze.error("Failed to collect OpenCode status")});break}}},[x,k,b,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=j=>{const S=j.detail;S&&y(S)},g=()=>{p()};return window.addEventListener(Id,m),window.addEventListener(zi,g),()=>{window.removeEventListener(Id,m),window.removeEventListener(zi,g)}},[y,p]),c.useEffect(()=>{if(typeof window>"u")return;const g=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof g!="function")return;let j=null,S=null;return g("openchamber:menu-action",w=>{const C=w?.payload;typeof C=="string"&&y(C)}).then(w=>{j=w}).catch(()=>{}),g("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(zi))}).then(w=>{S=w}).catch(()=>{}),()=>{(async()=>{try{const C=j?.();C instanceof Promise&&await C}catch{}try{const C=S?.();C instanceof Promise&&await C}catch{}})()}},[y])},_5="openchamber:tray-action",$5=5e3,z5=500,W5=20,Td=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},Ed=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,vm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},Sm=t=>t.title.trim()||"Question",K5=(t,e)=>Qa(t,e,Hr.getState().ids,Va.getState().rankById),V5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},U5=(t,e,n,r,i)=>{if(!t)return"";const o=ou(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||V5(t),d=No(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of pn.getState().directories)if(No(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(p=>No(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},H5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Nx){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Px(h),value:Ax(f.valueLabel,p)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},G5=async()=>{try{if(Qo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=mn();if(e&&yl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?yl(e,hh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},q5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=ra()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(No(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:vm(h),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"form",id:h.id,sessionId:f,sessionTitle:"",label:Sm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Y5=(t,e)=>{const n=Ga.getState().index.session,r=us.getState().activeSessions,i=new Map;for(const g of r)if(g?.id&&g.parentID){const j=i.get(g.parentID)??[];j.push(g.id),i.set(g.parentID,j)}const o=g=>{const j=[],S=[...i.get(g)??[]],w=new Set;for(;S.length;){const C=S.pop();w.has(C)||(w.add(C),j.push(C),S.push(...i.get(C)??[]))}return j},l=Ae.getState();let a=0;if(l.dockBadgeEnabled)for(const g of r){if(!g?.id||g.parentID)continue;let j=n.unseenCount[g.id]??0;j===0&&l.notifyOnSubtasks&&(j=o(g.id).reduce((S,w)=>S+(n.unseenCount[w]??0),0)),j>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=q5(),u=new Map(d.titleById);for(const g of r)g?.id&&g.title&&u.set(g.id,g.title);const h=Zo.getState().statusById,f=g=>{const j=d.statusById.get(g);return j&&j!=="idle"?j:h.get(g)?.status.type??j??"idle"},p=g=>{const j=g.map(S=>f(S));return j.includes("busy")?"busy":j.includes("retry")?"retry":"idle"},x=zt.getState().projects,b=nt.getState().availableWorktreesByProject,k=r.filter(g=>g?.id&&!g.parentID).slice().sort(K5).slice(0,W5).map(g=>{const j=[g.id,...o(g.id)],S=xs(g)??"";return{id:g.id,title:g.title||"Untitled session",status:p(j),branch:S?d.branchByDirectory.get(S)??"":"",unseen:j.reduce((w,C)=>w+(n.unseenCount[C]??0),0),hasError:j.some(w=>n.unseenHasError[w]??!1),directory:S,subtitle:U5(S,g,x,b,d.branchByDirectory)}}),y=d.approvals.map(g=>({...g,sessionTitle:u.get(g.sessionId)||""})),m=new Set(y.map(g=>g.id));for(const[g,j]of qa.getState().bySession){const S=u.get(g)||"";for(const w of j.permissions)m.has(w.id)||(m.add(w.id),y.push({kind:"permission",id:w.id,sessionId:g,sessionTitle:S,label:vm(w),directory:j.directory}));for(const w of j.forms)m.has(w.id)||(m.add(w.id),y.push({kind:"form",id:w.id,sessionId:g,sessionTitle:S,label:Sm(w),directory:j.directory}))}return{sessions:k,approvals:y,instanceName:t,usage:H5(),dockBadgeCount:a}},Q5=()=>{c.useEffect(()=>{if(!Td()||!Vr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const v=Y5(i,t),R=JSON.stringify(v);R!==n&&(n=R,jn("desktop_tray_update",v))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},z5))},a=Ga.subscribe(()=>l()),d=us.subscribe(()=>l()),u=Ae.subscribe((v,R)=>{(v.dockBadgeEnabled!==R.dockBadgeEnabled||v.notifyOnSubtasks!==R.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;G5().then(v=>{e||(i=v,o())});const f=new Map,p=()=>{if(e)return;let v;try{v=ra()}catch{return}const R=new Set;for(const[T,D]of v.children.entries())R.add(T),f.has(T)||f.set(T,D.subscribe(()=>l()));for(const[T,D]of f)R.has(T)||(D(),f.delete(T))};let x=null;try{x=ra().subscribeRegistry(()=>{p(),l()})}catch{}p();const b=zt.subscribe(()=>l()),k=nt.subscribe(()=>l()),y=pn.subscribe(()=>l()),m=Zo.subscribe(()=>l()),g=qa.subscribe(()=>l()),j=Va.subscribe(()=>l()),S=Hr.subscribe(()=>l()),w=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:v,results:R}=ur.getState();v.length>0&&v.some(D=>!R.some(F=>F.providerId===D))&&ur.getState().fetchQuotas(v)});const C=window.setInterval(()=>{p(),o()},$5);return o(),()=>{h(),window.clearInterval(C),b(),k(),y(),m(),g(),j(),S(),w(),x?.();for(const v of f.values())v();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Vr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Cx(i.sessionId,i.id,i.response).catch(()=>{ze.error("Failed to respond to permission request")})};let r=null;return e(_5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},X5=30*6e4,J5=(t,e,n=X5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Mr=null;const Z5=()=>{if(Mr)return Mr;const t=Wt();return Mr=(async()=>{const e=await Vs.getHostSessionStatusSnapshot();if(!e||Wt()!==t)return;const n=Zo.getState(),r=us.getState().entityById,i=J5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?xs(a):null}});for(const[l,a]of i)Dx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?xs(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Ix(o)})().finally(()=>{Mr=null}),Mr},eN=45e3,tN=[1e3,2e3,4e3],sN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const h=await u().catch(()=>!1);if(i)return;a||=h;const f=a?void 0:tN[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??eN)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},nN=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=rN;let o=i();const l=vr(()=>{o(),o=i()});return()=>{l(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function rN(){const t=Wt();let e=!0;const n=async i=>(i?await Tx(Lo()):await ri(),!e||Wt()!==t?!1:(Z5(),us.getState().status==="ready")),r=sN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const oN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||en()||!Ra()||!globalThis.window))return Pn(aN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){if(t.type!=="notification")return;const e=Ae.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&oN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Ae(dN),r=Ex(uN),o=lp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return Pn(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const fN=()=>{const t=Ze.c(4),{t:e}=St(),n=Ae(mN);let r,i;t[0]!==n||t[1]!==e?(r=()=>Pn(o=>{o.type==="browser-provider-reset"&&(n("builtin"),ze.info(e("settings.openchamber.tools.browserProvider.toast.reset",{name:o.guestName})))}),i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i)};function mN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",hN=()=>{const t=Ze.c(6),{browserTab:e}=cp(),{t:n}=St(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!Ra()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(ze.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,h(),await b.prompt();const{outcome:k}=await b.userChoice;k==="accepted"&&ze.success(r.current("pwa.installPrompt.started"))},p=b=>{const k=b;if(typeof k.prompt!="function")return;k.preventDefault(),d=k;const y=Mo(),m=ph();dp({dismissed:y.getItem(Md),sessionShown:m.getItem(Rd),hasActiveToast:u!==null})&&(m.setItem(Rd,"true"),u=ze.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Mo().setItem(Md,"true"),h()}}}))},x=()=>{d=null,h(),ze.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",x),()=>{h(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",x)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},pN=({open:t,onOpenChange:e})=>{const{t:n}=St(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[p,x]=c.useState(null),[b,k]=c.useState(!1);c.useCallback(async()=>{},[p,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const g=await ls("/api/system/info");if(g.ok){const j=await g.json();if(typeof j.openchamberVersion=="string"&&j.openchamberVersion.trim()){o(j.openchamberVersion);return}}}catch{}o(await Rx())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const j=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!j.ok)return;const S=await j.json().catch(()=>null),w=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!m&&w&&a(w)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{x(null),k(!1);return}},[t,r]);const y=i;return s.jsx(bs,{open:t,onOpenChange:e,children:s.jsx(ys,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Du,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(O,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ea="project-config-invalid",gN=()=>{const t=Ze.c(9),{t:e}=St(),n=Lt(xN);let r;t[0]!==n?(r=p=>p.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Lt(r),[o,l]=ct.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const p=Lt.getState(),x=p.activeDirectoryKey;l(!0),Promise.all([p.loadProviders({directory:x,source:"projectConfigError:retry"}),p.loadAgents({directory:x,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,h;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){ze.dismiss(Ea);return}ze.error(e("projectConfigError.toast.title"),{id:Ea,duration:1/0,description:s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"break-all font-mono typography-meta",children:i.path??e("projectConfigError.toast.unknownFile")}),i.message&&s.jsx("span",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta",children:i.message}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("projectConfigError.toast.hint")})]}),action:{label:e(o?"projectConfigError.toast.retrying":"projectConfigError.toast.retry"),onClick:p=>{p.preventDefault(),o||d()}}})},h=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=h):(u=t[6],h=t[7]),ct.useEffect(u,h);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],ct.useEffect(yN,f),null};function xN(t){return t.activeDirectoryKey}function bN(){ze.dismiss(Ea)}function yN(){return bN}const wN="\x1B",vN=new RegExp(`${wN}\\[[0-9;?]*[ -/]*[@-~]`,"g"),jo=Xn().transform(t=>t.replace(vN,"").trim()).nullish(),SN=Zl({isOpenCodeReady:ec().optional(),openCodeRunning:ec().optional(),lastOpenCodeError:jo,opencodeBinaryResolved:jo,lastOpenCodeLaunchDiagnostics:Zl({sourceBinary:jo,binary:jo}).nullish()}),jN=async(t,e=ls)=>{const n=await e("/health",{signal:t,headers:{Accept:"application/json"},cache:"no-store"});if(!n.ok)throw new Error(`Startup diagnostics request failed (${n.status})`);const r=SN.parse(await n.json());return r.isOpenCodeReady===!0||r.isOpenCodeReady!==!1&&r.openCodeRunning!==!1?null:{error:r.lastOpenCodeError||null,binary:r.lastOpenCodeLaunchDiagnostics?.sourceBinary||r.opencodeBinaryResolved||r.lastOpenCodeLaunchDiagnostics?.binary||null}},kN=(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"}},Od=Dn(()=>sn(()=>import("./OnboardingScreen-D_41H2qC.js"),__vite__mapDeps([152,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(t=>({default:t.OnboardingScreen}))),CN=()=>{const t=Ze.c(3),e=Ae(TN),n=Ae(EN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(pN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},NN=t=>{const e=Ze.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=St(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const w=new AbortController,C=Wt(),v=setTimeout(()=>w.abort(),5e3);return jN(w.signal).then(R=>{!w.signal.aborted&&Wt()===C&&l(R)}).catch(RN).finally(()=>clearTimeout(v)),()=>{w.abort(),clearTimeout(v)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Lt(MN),h=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==f?(p=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=p):p=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==i?(x=i(kN(o,u)),e[6]=o,e[7]=u,e[8]=i,e[9]=x):x=e[9];let b;e[10]!==x?(b=s.jsx("p",{className:"typography-body text-muted-foreground",children:x}),e[10]=x,e[11]=b):b=e[11];let k;e[12]!==p||e[13]!==b?(k=s.jsxs("div",{className:"flex flex-col gap-2",children:[p,b]}),e[12]=p,e[13]=b,e[14]=k):k=e[14];let y;e[15]!==h||e[16]!==i?(y=h&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:h})]}),e[15]=h,e[16]=i,e[17]=y):y=e[17];let m;e[18]!==o||e[19]!==i?(m=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=m):m=e[20];let g;e[21]!==r||e[22]!==i?(g=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=g):g=e[23];let j;e[24]!==r||e[25]!==n||e[26]!==g?(j=s.jsx(ut,{type:"button",onClick:n,disabled:r,children:g}),e[24]=r,e[25]=n,e[26]=g,e[27]=j):j=e[27];let S;return e[28]!==j||e[29]!==k||e[30]!==y||e[31]!==m?(S=s.jsx("div",{className:"flex h-full flex-col items-center overflow-y-auto bg-background px-6 py-6 text-foreground",children:s.jsxs("div",{className:"my-auto flex w-full max-w-xl shrink-0 flex-col items-center gap-4 text-center",children:[k,y,m,j]})}),e[28]=j,e[29]=k,e[30]=y,e[31]=m,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",AN=()=>{if(typeof window>"u"||!Cb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},PN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=Jt(ON),l=nt(BN),a=nt(FN),d=_x(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Bd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let p;e[2]!==o?(p=Bd(o),e[2]=o,e[3]=p):p=e[3];const x=p;let b,k;if(e[4]!==x||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(b=()=>{if(r||f&&x!==f)return;const w=`${f}
896
+ ${n.sessionId}`;u.current===w&&l||(u.current=w,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},k=[x,l,n.directory,n.sessionId,f,r,a,d],e[4]=x,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=b,e[13]=k):(b=e[12],k=e[13]),c.useEffect(b,k),f&&x!==f)return null;let y;e[14]!==i?(y=s.jsx(Yu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(ru,{}),e[16]=m):m=e[16];let g;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(g=s.jsx(nu,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(Qu,{}),e[21]=j):j=e[21];let S;return e[22]!==y||e[23]!==g?(S=s.jsxs(s.Fragment,{children:[y,m,g,j]}),e[22]=y,e[23]=g,e[24]=S):S=e[24],S};function DN({apis:t}){c.useEffect(()=>{gh("App:mounted"),xh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Lt(U=>U.initializeApp),n=Lt(U=>U.isInitialized),r=Lt(U=>U.isConnected),i=Lt(U=>U.providers.length),o=Lt(U=>U.agents.length),l=Lt(U=>U.loadProviders),a=Lt(U=>U.loadAgents),d=nt(U=>U.error),u=nt(U=>U.clearError),h=Jt(U=>U.currentDirectory),f=Jt(U=>U.setDirectory),p=Jt(U=>U.isSwitchingDirectory),[x,b]=c.useState(!1),k=hn(U=>U.refreshStatus),y=Ji(U=>U.refreshStatus),[m,g]=c.useState(()=>t.runtime.isVSCode),[j,S]=c.useState(!1),[w,C]=c.useState(!1),[v,R]=c.useState(0),[T,D]=c.useState(0),[F,B]=c.useState(!1),E=Ae(U=>U.wideChatLayoutEnabled),$=Ae(U=>U.mobileKeyboardMode),L=c.useMemo(()=>en(),[]),X=La(U=>U.setPlanModeEnabled),[Y,I]=c.useState(()=>wl()),[P,A]=c.useState(()=>{const U=vl();return U!==null?Sl({isDesktopShell:!0,bootOutcome:U}):null}),q=c.useRef(!1),K=c.useMemo(()=>AN(),[]),te=!K||j;c.useEffect(()=>(jl(x),Nd(x),()=>{jl(!1),Nd(!1)}),[x]),c.useEffect(()=>{bh($)},[$]),c.useEffect(()=>{g(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>vr(U=>{fp(U),D(Z=>Z+1),C(!1),R(Z=>Z+1)}),[]);const ae=Ul(U=>{const Z=Wt();return Object.values(U.runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===Z).map(de=>`${de.originalSessionID}:${de.phase}:${de.lastForwardedMessageID??""}:${de.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(K)return;const U=Wt(),Z=Object.values(Ul.getState().runsByOriginalSessionID).filter(de=>de.status==="running"&&de.runtimeKey===U);for(const de of Z)Mx(de.originalSessionID)},[ae,K,T]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",E),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[E]),c.useEffect(()=>(kl(t),()=>kl(null)),[t]),c.useEffect(()=>{K||(k(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,K,r,k,y,T]),Ox();const re=Y==="valid",he=P?.screen==="main";c.useEffect(()=>{if(!yh({isDesktopShell:L,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:he}))return;const U=setTimeout(()=>{const Z=document.getElementById("initial-loading");Z&&(Z.classList.add("fade-out"),setTimeout(()=>{Z.remove()},300))},150);return()=>clearTimeout(U)},[L,n,re,he]),c.useEffect(()=>{if(!L||Y!=="malformed")return;const U=document.getElementById("initial-loading");U&&(U.textContent="Desktop startup failed — please restart the app.")},[L,Y]),c.useEffect(()=>{if(L)return;const U=setTimeout(()=>{const Z=document.getElementById("initial-loading");Z&&!n&&(Z.classList.add("fade-out"),setTimeout(()=>{Z.remove()},300))},5e3);return()=>clearTimeout(U)},[L,n]),c.useEffect(()=>{let U=!1;return(async()=>{const de=await ls("/health",{method:"GET"}).catch(()=>null);if(!de||!de.ok||U)return;const ye=await de.json().catch(()=>null);if(!ye||U)return;const H=ye.planModeExperimentalEnabled;X(H===!0||H===1||H==="1"||H==="true")})(),()=>{U=!0}},[X]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let U=!0,Z,de=0;const ye=10,H=1e3,je=async()=>{if(!U)return;if(de>=ye){C(!0);return}const Ee=Lt.getState();if(Ee.isInitialized){C(!1);return}de+=1,await Ee.initializeApp();const ge=Lt.getState();if(!U)return;if(ge.isInitialized){C(!1);return}if(de>=ye){C(!0);return}const ne=Math.min(H*Math.pow(2,de-1),16e3);Z=setTimeout(je,ne)};return Z=setTimeout(je,H),()=>{U=!1,Z&&clearTimeout(Z)}},[v,n,m]),c.useEffect(()=>{n&&C(!1)},[n]),c.useEffect(()=>{if(!w)return;const U=document.getElementById("initial-loading");U&&(U.classList.add("fade-out"),setTimeout(()=>{U.remove()},300))},[w]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let U=!0,Z=0;const de=15,ye=async()=>{const je=Lt.getState();if(!(je.providers.length>0&&je.agents.length>0))try{je.providers.length===0&&await l({source:"startupRecovery"}),Lt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};ye();const H=setInterval(()=>{if(U){if(++Z>=de){clearInterval(H);return}ye()}},2e3);return()=>{U=!1,clearInterval(H)}},[r,m,a,l,i,o]),c.useEffect(()=>{p||m||r&&Vs.setDirectory(h)},[h,p,r,m]),c.useEffect(()=>{if(!K||typeof window>"u")return;const U=ye=>{S(ye?.visible===!0)},Z=ye=>{if(ye.origin!==window.location.origin||ye.source!==window.parent)return;const H=ye.data;H?.type===of&&U(H.payload)},de=window;return de.__openchamberSetEmbeddedVisibility=U,window.addEventListener("message",Z),kb(),()=>{window.removeEventListener("message",Z),de.__openchamberSetEmbeddedVisibility===U&&delete de.__openchamberSetEmbeddedVisibility}},[K]),c.useEffect(()=>{!K?.directory||m||h!==K.directory&&f(K.directory,{showOverlay:!1})},[h,K,m,f]),c.useEffect(()=>{if(!K||typeof window>"u")return;const U=Z=>{Z.storageArea===window.localStorage&&Z.key==="ui-store"&&Ae.persist.rehydrate()};return window.addEventListener("storage",U),()=>{window.removeEventListener("storage",U)}},[K]),c.useEffect(()=>{if(typeof window>"u")return;const U=Z=>{const de=Z.detail,ye=typeof de?.sessionId=="string"?de.sessionId.trim():"";if(!ye)return;const H=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null;nt.getState().setCurrentSession(ye,H)};return window.addEventListener("openchamber:open-session",U),()=>window.removeEventListener("openchamber:open-session",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=()=>{jn("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",U),()=>window.removeEventListener("openchamber:open-mini-chat",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=()=>{const Z=nt.getState().currentSessionId;Z&&Iu(Z)};return window.addEventListener("focus",U),()=>window.removeEventListener("focus",U)},[]),c.useEffect(()=>{if(typeof window>"u")return;const U=Z=>{const de=Z.detail,ye=typeof de?.directory=="string"&&de.directory.trim().length>0?de.directory.trim():null,H=typeof de?.projectId=="string"&&de.projectId.trim().length>0?de.projectId.trim():null,je=!!(ye||H);Ae.getState().setSessionSwitcherOpen(!1),nt.getState().openNewSessionDraft({target:je?"project":"chat",selectedProjectId:je?H:null,directoryOverride:je?ye:null,preserveDirectoryOverride:!!ye})};return window.addEventListener("openchamber:open-draft-session",U),()=>window.removeEventListener("openchamber:open-draft-session",U)},[]),c.useEffect(()=>{typeof window>"u"||!n||p||q.current||(q.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),Bx({enabled:te}),iN({enabled:te}),cN(h||null),fN(),Fx(),hN(),Lx(),eb(),mp();const ce=c.useCallback(()=>{b(U=>!U)},[]);L5(ce),Q5(),nN(!K),c.useEffect(()=>{if(K)return;const U=()=>b(Z=>!Z);return window.addEventListener("openchamber:memory-debug-toggle",U),()=>window.removeEventListener("openchamber:memory-debug-toggle",U)},[K]),c.useEffect(()=>{K||d&&setTimeout(()=>u(),5e3)},[u,K,d]),c.useEffect(()=>{if(!L||Y!=="not-injected")return;let U=!1,Z=0;const de=200,ye=2e3,H=50,je=()=>{if(U)return;Z++;const Ee=wl();if(Ee!=="not-injected"){if(U=!0,I(Ee),Ee==="valid"){const ne=vl();ne&&A(Sl({isDesktopShell:!0,bootOutcome:ne}))}return}const ge=Math.min(de*Math.pow(1.1,Z),ye);if(Z>=H){const ne=document.getElementById("initial-loading");ne&&!ne.textContent?.includes("taking longer")&&(ne.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(je,ge)};return window.setTimeout(je,de),()=>{U=!0}},[L,Y]);const Te=c.useCallback(async()=>{if(wh({isDesktopShell:en(),isDesktopLocalOriginActive:Qo()})){await vh();return}window.location.reload()},[]),ve=c.useCallback(async()=>{if(!F){C(!1),B(!0);try{await Lt.getState().initializeApp()}finally{B(!1)}Lt.getState().isInitialized||R(U=>U+1)}},[F]),pe=U=>{if(U.screen==="recovery")return U.variant};if(L&&P&&P.screen!=="main"){if(P.screen==="chooser")return s.jsx(ps,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"first-launch",localAvailable:P.localAvailable!==!1,onCliAvailable:Te,onChooseRemote:()=>{}})})})});const U=pe(P),Z=P.screen==="recovery"&&"url"in P?P.url:void 0;return s.jsx(ps,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Od,{mode:"recovery",recoveryVariant:U,recoveryHostUrl:Z,recoveryHostLabel:void 0,localAvailable:P.localAvailable!==!1,onCliAvailable:Te})})})})}if(K)return s.jsx(ps,{children:s.jsx(Hl,{sdk:Vs.getSdkClient(),directory:h||"",children:s.jsx(Gl,{apis:t,children:s.jsx(na,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(PN,{embeddedSessionChat:K,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:te}),s.jsx(ql,{}),s.jsx(Yl,{})]})})})},T)});if(w&&!n&&!m&&!K)return s.jsx(ps,{children:s.jsx(NN,{onRetry:()=>{ve()},isRetrying:F},T)});const Ne=!n&&!L;return s.jsx(ps,{children:s.jsx(Hl,{sdk:Vs.getSdkClient(),directory:h||"",children:s.jsx(Gl,{apis:t,children:s.jsx(i5,{children:s.jsx(na,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:L?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Yu,{embeddedBackgroundWorkEnabled:te}),s.jsx(ru,{}),s.jsx(gN,{}),s.jsx(OC,{}),s.jsx(hp,{ready:n&&(!L||re&&he)}),s.jsx(Qu,{}),s.jsx(ql,{}),s.jsx(Yl,{}),!Ne&&s.jsxs(s.Fragment,{children:[s.jsx(pp,{}),s.jsx(CN,{}),x&&s.jsx(b5,{onClose:()=>b(!1)})]})]})})})})},T)})}function IN(t){const e=Ze.c(2);let n;return e[0]!==t?(n=s.jsx(up,{children:s.jsx(DN,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function TN(t){return t.isAboutDialogOpen}function EN(t){return t.setAboutDialogOpen}function RN(){}function MN(t){return t.lastInitFailure}function ON(t){return t.currentDirectory}function BN(t){return t.currentSessionId}function FN(t){return t.setCurrentSession}const LN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();$x();Sh().then(()=>{Promise.all([jh(),zx()]).catch(t=>{console.error("[main] settings init failed:",t)}),Wx(),Kx(),Vx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const jm=document.getElementById("root");if(!jm)throw new Error("Root element not found");Ux();qm.createRoot(jm).render(s.jsx(ct.StrictMode,{children:s.jsx(Hx,{children:s.jsx(Gx,{children:s.jsx(qx,{children:s.jsx(Yx,{children:s.jsx(IN,{apis:LN})})})})})}));const oA=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Zy as W,Wy as a,rA as b,vf as g,oA as m,Jy as u,wf as v};