@openchamber/web 2.0.2 → 2.0.4

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 (257) hide show
  1. package/bin/lib/DOCUMENTATION.md +1 -1
  2. package/bin/lib/commands-connect-url.js +6 -5
  3. package/bin/lib/commands-tunnel.js +24 -5
  4. package/dist/assets/{CodeMirrorCommentWidgets-CmKmyb9T.js → CodeMirrorCommentWidgets-C_zL-eri.js} +1 -1
  5. package/dist/assets/{DiffView-8-PFpZ2p.js → DiffView-BeN2_YYF.js} +3 -3
  6. package/dist/assets/FilesView-CN34wm_N.js +17 -0
  7. package/dist/assets/{GitView-DNUSu00w.js → GitView-DLDazOo1.js} +4 -4
  8. package/dist/assets/{GuestAttachDialog-Cv6QzjHC.js → GuestAttachDialog-C0xe_Lyy.js} +1 -1
  9. package/dist/assets/{GuestSurfacePane-Bt3jB_Ye.js → GuestSurfacePane-BdaurnDr.js} +1 -1
  10. package/dist/assets/{JsonTreeView-BlyHTRhM.js → JsonTreeView-B1Xq-k2t.js} +1 -1
  11. package/dist/assets/LinearIssuesView-BryoAHow.js +1 -0
  12. package/dist/assets/{MarkdownImageGallery-2UXJF-5B.js → MarkdownImageGallery-DfuEoaGq.js} +1 -1
  13. package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +12 -0
  14. package/dist/assets/OnboardingScreen-C22bGmnP.js +1 -0
  15. package/dist/assets/{PatchDiff-ByvnbG5T.js → PatchDiff-0xd6UeFB.js} +1 -1
  16. package/dist/assets/{PierreDiffViewer-BXieg0mH.js → PierreDiffViewer-BC950e3F.js} +3 -3
  17. package/dist/assets/PlanView-B7Xgihqk.js +5 -0
  18. package/dist/assets/PluginPane-2C71F8uF.js +3 -0
  19. package/dist/assets/SettingsView-m_zoFiaT.js +30 -0
  20. package/dist/assets/{SettingsWindow-BIz224xs.js → SettingsWindow-CofS020b.js} +1 -1
  21. package/dist/assets/{SubmoduleDiffSummary-CXKmlps9.js → SubmoduleDiffSummary-BSA9gnIO.js} +1 -1
  22. package/dist/assets/{ToolOutputDialog-BsgAK8xu.js → ToolOutputDialog-DprkVKcj.js} +7 -7
  23. package/dist/assets/{ToolPartDiffPreview-vdPObXOf.js → ToolPartDiffPreview-Dq0go_fX.js} +2 -2
  24. package/dist/assets/{VirtualizedFileDiff-BkFNKWS5.js → VirtualizedFileDiff-Kp8hKJdT.js} +1 -1
  25. package/dist/assets/WalkthroughView-DGnTzqIU.js +4 -0
  26. package/dist/assets/{appThemeRegistry-aHUNHoqP.js → appThemeRegistry-BdEHBA4s.js} +1 -1
  27. package/dist/assets/{commitAndPush-Bon9r94r.js → commitAndPush-LwtVa2Oc.js} +1 -1
  28. package/dist/assets/{computeVirtualFileMetrics-DKqr_1AQ.js → computeVirtualFileMetrics-6V1xNpO9.js} +2 -2
  29. package/dist/assets/de-DlgBHUAI.js +10 -0
  30. package/dist/assets/es-BC8G41U8.js +16 -0
  31. package/dist/assets/fr-I0z3vVjy.js +14 -0
  32. package/dist/assets/index-CgR5rJq_.js +41 -0
  33. package/dist/assets/{index-DpFttslC.js → index-CmNPYddV.js} +1 -1
  34. package/dist/assets/index-adyy_sEk.css +1 -0
  35. package/dist/assets/{isDiffPlainText-kzAgpIgi.js → isDiffPlainText-1bXcWCrw.js} +1 -1
  36. package/dist/assets/{isFilePlainText-Uj6y-jzz.js → isFilePlainText-CBAppvy1.js} +1 -1
  37. package/dist/assets/ja-BIElEsY8.js +16 -0
  38. package/dist/assets/ko-DRnnHetA.js +16 -0
  39. package/dist/assets/{main-CbfMxn-I.js → main-CzjTMTfW.js} +2 -2
  40. package/dist/assets/main-DVX34beR.js +886 -0
  41. package/dist/assets/markdownCore-Cxbkn5NR.js +7 -0
  42. package/dist/assets/{miniChat-CiAKBC10.js → miniChat-CP68IL8Q.js} +2 -2
  43. package/dist/assets/{mobile-CsT4sJwC.js → mobile-BrlBrNfZ.js} +2 -2
  44. package/dist/assets/nl-DzUV-kwp.js +16 -0
  45. package/dist/assets/{patchFileDiff-DeaE08W0.js → patchFileDiff-pqRSHLHI.js} +2 -2
  46. package/dist/assets/pl-Bb-cb7k7.js +16 -0
  47. package/dist/assets/pt-BR-CyIWrTcE.js +16 -0
  48. package/dist/assets/renderElectronMiniChatApp-DKIilR7N.js +2 -0
  49. package/dist/assets/renderMobileApp-B0z6-x58.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +52 -0
  51. package/dist/assets/{scheduledTasksApi-BZCNJ588.js → scheduledTasksApi-BuzWT445.js} +1 -1
  52. package/dist/assets/{shikiHighlight-BSUEa3yF.js → shikiHighlight-BWGrY5YU.js} +1 -1
  53. package/dist/assets/{textMateThemeFromAppTheme-CsATFZIV.js → textMateThemeFromAppTheme-BSUFChBY.js} +1 -1
  54. package/dist/assets/tr-DXEDSoYO.js +7 -0
  55. package/dist/assets/uk-C8hN--q_.js +16 -0
  56. package/dist/assets/useAppFontEffects-Dsl_sLrj.js +7366 -0
  57. package/dist/assets/useInlineCommentController-d5vntsQ_.js +2 -0
  58. package/dist/assets/{useRootScrollLock-Cp1eFoM2.js → useRootScrollLock-2rd5Y6gR.js} +2 -2
  59. package/dist/assets/{vendor-base-ui-CsXYnR5c.js → vendor-base-ui-DnNniUWp.js} +1 -1
  60. package/dist/assets/{vendor-codemirror-language-data-BwwommM0.js → vendor-codemirror-language-data-B1EetJur.js} +2 -2
  61. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +12 -0
  62. package/dist/assets/{vendor-tanstack-react-virtual-ClYN8CzB.js → vendor-tanstack-react-virtual--0sBrLRh.js} +1 -1
  63. package/dist/assets/{vendor-tanstack-virtual-core-BewVQryB.js → vendor-tanstack-virtual-core-BoA4iGMw.js} +1 -1
  64. package/dist/assets/{vendor-zod-BSoePkpP.js → vendor-zod-CxRSdNoV.js} +4 -4
  65. package/dist/assets/{web-components-D3Yjr4Zx.js → web-components-ngpHPEDU.js} +1 -1
  66. package/dist/assets/zh-CN-CtzXdjMZ.js +16 -0
  67. package/dist/assets/zh-TW-Ds0CADSz.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 +5 -5
  72. package/server/index.js +82 -4
  73. package/server/lib/agent-tool/DOCUMENTATION.md +8 -1
  74. package/server/lib/agent-tool/runtime.js +13 -4
  75. package/server/lib/agent-tool/runtime.test.js +15 -0
  76. package/server/lib/context-obligatory/DOCUMENTATION.md +10 -7
  77. package/server/lib/context-obligatory/runtime.js +2 -1
  78. package/server/lib/context-obligatory/runtime.test.js +76 -30
  79. package/server/lib/dictation/DOCUMENTATION.md +4 -1
  80. package/server/lib/dictation/openai-compatible-session.js +7 -0
  81. package/server/lib/enterprise-mode.d.ts +30 -0
  82. package/server/lib/enterprise-mode.js +253 -0
  83. package/server/lib/enterprise-mode.test.js +247 -0
  84. package/server/lib/event-stream/translate-v2.js +6 -0
  85. package/server/lib/event-stream/translate-v2.test.js +6 -0
  86. package/server/lib/git/DOCUMENTATION.md +2 -1
  87. package/server/lib/git/routes.js +44 -1
  88. package/server/lib/git/routes.test.js +98 -1
  89. package/server/lib/git/service.js +146 -11
  90. package/server/lib/git/service.test.js +195 -0
  91. package/server/lib/github/routes.js +9 -19
  92. package/server/lib/github/routes.test.js +112 -0
  93. package/server/lib/guests/DOCUMENTATION.md +4 -2
  94. package/server/lib/guests/background.test.js +1 -1
  95. package/server/lib/guests/catalog.js +56 -2
  96. package/server/lib/guests/catalog.test.js +24 -1
  97. package/server/lib/guests/clone-network.test.js +52 -0
  98. package/server/lib/guests/clone.js +30 -4
  99. package/server/lib/guests/enterprise.js +68 -0
  100. package/server/lib/guests/enterprise.test.js +106 -0
  101. package/server/lib/guests/grant-scope.js +8 -2
  102. package/server/lib/guests/grant-scope.test.js +9 -0
  103. package/server/lib/guests/html-styles.js +16 -2
  104. package/server/lib/guests/html-styles.test.js +53 -4
  105. package/server/lib/guests/install.js +10 -0
  106. package/server/lib/guests/persist.js +1 -0
  107. package/server/lib/guests/routes.js +40 -5
  108. package/server/lib/guests/updates.js +9 -2
  109. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  110. package/server/lib/notifications/runtime.js +22 -8
  111. package/server/lib/notifications/trigger-runtime.test.js +45 -0
  112. package/server/lib/openchamber-sessions/session-metadata-store.js +27 -0
  113. package/server/lib/openchamber-sessions/session-metadata-store.test.js +18 -0
  114. package/server/lib/opencode/DOCUMENTATION.md +13 -9
  115. package/server/lib/opencode/auth-state-runtime.js +2 -2
  116. package/server/lib/opencode/config-paths.test.js +1 -0
  117. package/server/lib/opencode/env-runtime.js +26 -3
  118. package/server/lib/opencode/env-runtime.test.js +57 -0
  119. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  120. package/server/lib/opencode/hmr-state-runtime.js +4 -3
  121. package/server/lib/opencode/lifecycle.js +10 -5
  122. package/server/lib/opencode/lifecycle.test.js +6 -2
  123. package/server/lib/opencode/managed-config-file.js +2 -1
  124. package/server/lib/opencode/managed-config-file.test.js +18 -0
  125. package/server/lib/opencode/npm-registry-config.d.ts +1 -0
  126. package/server/lib/opencode/npm-registry-config.js +123 -0
  127. package/server/lib/opencode/npm-registry-config.test.js +167 -0
  128. package/server/lib/opencode/npm-registry.js +5 -6
  129. package/server/lib/opencode/npm-registry.test.js +30 -0
  130. package/server/lib/opencode/openchamber-routes.js +8 -0
  131. package/server/lib/opencode/project-icon-routes.js +2 -2
  132. package/server/lib/opencode/project-icon-routes.test.js +44 -0
  133. package/server/lib/opencode/provider-source-route.test.js +32 -0
  134. package/server/lib/opencode/routes.js +17 -2
  135. package/server/lib/opencode/settings-helpers.js +26 -3
  136. package/server/lib/opencode/settings-helpers.test.js +12 -5
  137. package/server/lib/opencode/settings-registry.json +35 -1
  138. package/server/lib/opencode/settings-runtime.js +1 -0
  139. package/server/lib/opencode/shutdown-runtime.js +2 -0
  140. package/server/lib/opencode/static-routes-runtime.js +9 -1
  141. package/server/lib/opencode/static-routes-runtime.test.js +58 -1
  142. package/server/lib/package-manager.js +4 -1
  143. package/server/lib/package-manager.test.js +24 -0
  144. package/server/lib/permission-auto-accept/DOCUMENTATION.md +23 -15
  145. package/server/lib/permission-auto-accept/modes.js +26 -0
  146. package/server/lib/permission-auto-accept/runtime.js +146 -40
  147. package/server/lib/permission-auto-accept/runtime.test.js +93 -9
  148. package/server/lib/quota/DOCUMENTATION.md +6 -0
  149. package/server/lib/quota/providers/zhipuai-coding-plan.js +74 -30
  150. package/server/lib/quota/providers/zhipuai-coding-plan.test.js +124 -0
  151. package/server/lib/relay/DOCUMENTATION.md +1 -1
  152. package/server/lib/relay/service.js +32 -12
  153. package/server/lib/relay/service.test.js +30 -0
  154. package/server/lib/routing/DOCUMENTATION.md +150 -41
  155. package/server/lib/routing/classifier.js +156 -0
  156. package/server/lib/routing/defaults.js +27 -0
  157. package/server/lib/routing/jev.js +5 -17
  158. package/server/lib/routing/routes.http.test.js +9 -0
  159. package/server/lib/routing/routes.js +27 -1
  160. package/server/lib/routing/runtime.js +199 -33
  161. package/server/lib/routing/runtime.test.js +299 -15
  162. package/server/lib/routing/store.js +57 -0
  163. package/server/lib/routing/store.test.js +37 -0
  164. package/server/lib/session-assist/DOCUMENTATION.md +17 -7
  165. package/server/lib/session-assist/context.js +42 -2
  166. package/server/lib/session-assist/context.test.js +38 -1
  167. package/server/lib/session-assist/runtime.js +57 -13
  168. package/server/lib/session-assist/runtime.test.js +45 -0
  169. package/server/lib/session-goal/DOCUMENTATION.md +47 -22
  170. package/server/lib/session-goal/audit.js +112 -0
  171. package/server/lib/session-goal/audit.test.js +58 -0
  172. package/server/lib/session-goal/runtime.js +113 -134
  173. package/server/lib/session-goal/runtime.test.js +146 -13
  174. package/server/lib/session-lineage.js +52 -0
  175. package/server/lib/session-lineage.test.js +45 -0
  176. package/server/lib/session-work/DOCUMENTATION.md +108 -0
  177. package/server/lib/session-work/questions.js +126 -0
  178. package/server/lib/session-work/runtime.js +278 -0
  179. package/server/lib/session-work/runtime.test.js +255 -0
  180. package/server/lib/session-work/state.js +48 -0
  181. package/server/lib/session-work/state.test.js +34 -0
  182. package/server/lib/small-model/DOCUMENTATION.md +14 -7
  183. package/server/lib/small-model/client.js +7 -4
  184. package/server/lib/small-model/index.js +11 -21
  185. package/server/lib/small-model/index.test.js +13 -26
  186. package/server/lib/spaces/DOCUMENTATION.md +79 -25
  187. package/server/lib/spaces/gatekeeper-channel.js +63 -11
  188. package/server/lib/spaces/gatekeeper-channel.test.js +34 -4
  189. package/server/lib/spaces/gatekeeper-program.cjs +64 -13
  190. package/server/lib/spaces/gatekeeper-program.test.js +115 -3
  191. package/server/lib/spaces/host.js +58 -13
  192. package/server/lib/spaces/host.test.js +34 -1
  193. package/server/lib/spaces/idle-stop.js +98 -0
  194. package/server/lib/spaces/idle-stop.test.js +130 -0
  195. package/server/lib/spaces/journey.js +427 -17
  196. package/server/lib/spaces/journey.test.js +592 -5
  197. package/server/lib/spaces/layout.js +27 -6
  198. package/server/lib/spaces/manager.test.js +1 -1
  199. package/server/lib/spaces/places/contract-suite.js +4 -2
  200. package/server/lib/spaces/places/docker-live-support.js +27 -4
  201. package/server/lib/spaces/places/docker.js +32 -5
  202. package/server/lib/spaces/places/docker.test.js +38 -8
  203. package/server/lib/spaces/places/escape-suite.js +32 -0
  204. package/server/lib/spaces/places/fake-docker.js +3 -1
  205. package/server/lib/spaces/places/grants.docker.live.test.js +197 -0
  206. package/server/lib/spaces/places/memory-place.js +3 -3
  207. package/server/lib/spaces/places/sessions.docker.live.test.js +4 -2
  208. package/server/lib/spaces/routes.js +49 -1
  209. package/server/lib/spaces/routes.test.js +31 -3
  210. package/server/lib/spaces/space-opencode.js +52 -0
  211. package/server/lib/spaces/space-opencode.test.js +41 -0
  212. package/server/lib/spaces/space-records.js +90 -2
  213. package/server/lib/spaces/space-records.test.js +58 -1
  214. package/server/lib/spaces/space-server.js +13 -1
  215. package/server/lib/spaces/space-server.test.js +13 -0
  216. package/server/lib/spaces/space-setup.js +173 -0
  217. package/server/lib/spaces/space-setup.test.js +174 -0
  218. package/server/lib/tts/DOCUMENTATION.md +3 -0
  219. package/server/lib/tts/base-url.js +8 -0
  220. package/server/lib/tts/routes.js +13 -1
  221. package/server/lib/tts/routes.test.js +26 -0
  222. package/server/lib/tunnels/DOCUMENTATION.md +2 -0
  223. package/server/lib/tunnels/routes.js +14 -0
  224. package/server/lib/tunnels/routes.test.js +26 -0
  225. package/server/lib/walkthrough/index.js +11 -7
  226. package/server/lib/walkthrough/jobs.test.js +8 -0
  227. package/server/lib/walkthrough/languages.js +1 -0
  228. package/server/lib/walkthrough/routes.js +7 -1
  229. package/dist/assets/FilesView-0Ie20mEk.js +0 -17
  230. package/dist/assets/LinearIssuesView-CSl2MUfA.js +0 -1
  231. package/dist/assets/MarkdownRendererImpl-DVHqZoug.js +0 -12
  232. package/dist/assets/OnboardingScreen-CIdXJpfc.js +0 -1
  233. package/dist/assets/PlanView-DEIi3Q7M.js +0 -5
  234. package/dist/assets/PluginPane-BEPUWVho.js +0 -3
  235. package/dist/assets/SettingsView-CiNh-RbW.js +0 -30
  236. package/dist/assets/WalkthroughView-6oE-MuDL.js +0 -4
  237. package/dist/assets/de-CgAJ51z7.js +0 -10
  238. package/dist/assets/es-zGi_ravM.js +0 -16
  239. package/dist/assets/fr-CPfogrWx.js +0 -14
  240. package/dist/assets/index-CHfphYL3.js +0 -41
  241. package/dist/assets/index-DvMJ3w6V.css +0 -1
  242. package/dist/assets/ja-DMk6wd-U.js +0 -16
  243. package/dist/assets/ko-BFpzJ8jc.js +0 -16
  244. package/dist/assets/main-anyZFMIs.js +0 -896
  245. package/dist/assets/markdownCore-CmM47cAE.js +0 -7
  246. package/dist/assets/pl-VdRPcZrB.js +0 -16
  247. package/dist/assets/pt-BR-BRys_lOW.js +0 -16
  248. package/dist/assets/renderElectronMiniChatApp-C5677jy0.js +0 -2
  249. package/dist/assets/renderMobileApp-D4dBBAqQ.js +0 -25
  250. package/dist/assets/runtimeEndpointReset-5r0hkd-2.js +0 -27
  251. package/dist/assets/tr-CA9ckNnm.js +0 -7
  252. package/dist/assets/uk-byjR-y8D.js +0 -16
  253. package/dist/assets/useAppFontEffects-BWQZ5DeI.js +0 -7341
  254. package/dist/assets/useInlineCommentController-DlFyVfBu.js +0 -2
  255. package/dist/assets/vendor-opencode-client-DYdsLbCM.js +0 -12
  256. package/dist/assets/zh-CN-DRabgxdG.js +0 -16
  257. package/dist/assets/zh-TW-rbY5c9UK.js +0 -16
@@ -0,0 +1,886 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-DGnTzqIU.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-Dsl_sLrj.js","assets/index-CgR5rJq_.js","assets/vendor-zod-CxRSdNoV.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-DSZl7jSi.js","assets/index-adyy_sEk.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-base-ui-DnNniUWp.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual--0sBrLRh.js","assets/vendor-tanstack-virtual-core-BoA4iGMw.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-B1EetJur.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-pqRSHLHI.js","assets/runtimeEndpointReset-uu1DBwLL.js","assets/GuestAttachDialog-C0xe_Lyy.js","assets/PluginPane-2C71F8uF.js","assets/VirtualizedFileDiff-Kp8hKJdT.js","assets/web-components-ngpHPEDU.js","assets/computeVirtualFileMetrics-6V1xNpO9.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-1bXcWCrw.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-BC950e3F.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-d5vntsQ_.js","assets/appThemeRegistry-BdEHBA4s.js","assets/textMateThemeFromAppTheme-BSUFChBY.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-2rd5Y6gR.js","assets/scheduledTasksApi-BuzWT445.js","assets/vendor-cron-parser-CjvYVigk.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-BeN2_YYF.js","assets/SubmoduleDiffSummary-BSA9gnIO.js","assets/changesTree-CePHbFcj.js","assets/FilesView-CN34wm_N.js","assets/shikiHighlight-BWGrY5YU.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-B1Xq-k2t.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CBAppvy1.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-C_zL-eri.js","assets/GitView-DLDazOo1.js","assets/commitAndPush-LwtVa2Oc.js","assets/LinearIssuesView-BryoAHow.js","assets/PlanView-B7Xgihqk.js","assets/GuestSurfacePane-BdaurnDr.js","assets/SettingsWindow-CofS020b.js","assets/SettingsView-m_zoFiaT.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-C22bGmnP.js"])))=>i.map(i=>d[i]);
2
+ import{f as nt,R as c,j as s,r as at,c as Um,h as Hm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{H as hn,I as Yo,J as Gm,K as qm,h as ls,z as Fd,u as ye,L as Rt,N as hl,a as Yt,A as vr,o as gt,O as ws,P as Kr,Q as Pn,R as Ld,S as Ym,T as Qm,U as Xm,V as Jm,W as _d,n as ts,X as An,Y as Vr,e as pn,Z as Zm,_ as eh,$ as th,a0 as sh,a1 as $d,y as Xs,D as mr,a2 as nh,a3 as pl,a4 as rh,a5 as zd,a6 as oh,a7 as Wd,f as ih,a8 as Fn,a9 as $n,aa as Oo,ab as Li,ac as ah,ad as Da,d as Bo,x as lr,q as as,ae as Kd,af as lh,ag as _i,ah as Vd,ai as Ud,v as ch,t as dh,i as uh,aj as Ao,ak as Po,al as fh,am as gl,an as mh,ao as hh,ap as ph,aq as gh,ar as bl,as as xl,at as yl,au as wl,av as bh,C as vl,aw as xh,ax as yh,ay as wh,E as vh,F as Sh}from"./index-CgR5rJq_.js";import{_ as tn}from"./vendor-vite-runtime-DD1OZmLC.js";import{W as Sl,X as xi,Y as Ws,Z as $i,_ as jl,$ as jh,a0 as kh,a1 as Ch,a2 as Nh,a3 as Ah,a4 as Ph,a5 as Dh,a6 as Ih,a7 as Th,a8 as Ia,d as Eh,l as Hd,a as Rh,b as Mh,a9 as Gd,h as zi,v as qd,aa as Oh,q as Bh,o as Fh,ab as Yd,ac as Wi,ad as Ln,ae as Qd,af as Xd,t as Lh,P as _h,T as $h,ag as zh,ah as Wh,ai as Kh,aj as Vh,ak as Uh,al as Hh,i as Jd,am as Gh,an as qh,C as Yh,c as Zd,S as yi,ao as eu,k as Qh,ap as tu,aq as Xh,j as Jh,ar as Zh,e as ep,f as tp,as as ir,r as wi,at as sp,au as kl,av as np,u as Fr,s as rp,N as op,D as ip,aw as ap,w as lp,M as cp,z as dp,ax as up,H as fp,I as mp,J as hp,K as pp,Q as su,R as gp,U as bp,V as xp,ay as yp,az as wp,aA as vp,O as Sp,y as jp,A as kp,E as Cp,G as nu,F as Np,L as Ap}from"./runtimeEndpointReset-uu1DBwLL.js";import{f as At,h as Ie,br as zt,I as B,g as Gn,t as Fe,aD as Ss,bs as ps,aF as js,aC as ks,T as qn,a4 as bn,as as Yn,bt as Dn,o as Yr,bu as Cl,bv as Pp,bw as Dp,ao as vt,ap as St,aq as jt,b as Kt,z as rt,H as Ip,bx as ru,by as oo,u as gs,r as Is,D as ou,C as iu,bz as Ki,bA as Tp,bB as au,bC as lu,S as cu,bD as Ep,bE as Rp,bF as Nl,bG as Al,bH as du,bI as Mp,bJ as Pl,bK as Op,bL as Bp,bM as Ta,bN as Vi,bO as uu,bP as Fp,bQ as Lp,bR as _p,Q as fu,bS as $p,bT as zp,bU as Wp,n as ur,bV as Kp,bW as Vp,bX as Up,p as Hp,bY as mu,bZ as Gp,b_ as qp,b$ as Yp,c0 as hu,c1 as pu,c2 as gu,c3 as bu,c4 as xu,c5 as yu,c6 as wu,c7 as Qr,c8 as Ea,aT as Ra,c9 as zn,ca as Xr,cb as Qp,cc as Cs,cd as Ns,ce as Hs,cf as Ls,cg as _s,ch as Qn,B as ft,ci as xn,aL as hs,cj as Xp,ck as Jp,aR as gn,cl as cr,cm as Ps,cn as Qo,co as vu,cp as Ui,cq as Dl,cr as Il,cs as Zp,ct as cn,cu as dn,cv as Zs,cw as un,cx as us,a1 as Wn,cy as Er,cz as Tl,cA as Lr,cB as eg,R as Xo,at as tg,au as Ma,av as sg,J as ng,K as Xn,cC as Su,ah as ju,cD as rg,cE as og,aJ as ig,cF as ag,cG as ku,cH as lg,cI as cg,aK as Oa,cJ as dg,cK as Cu,cL as hr,cM as Nu,cN as ug,l as Vt,s as fg,cO as mg,cP as hg,aY as In,cQ as pg,cR as dr,O as Au,cS as gg,cT as bg,cU as Jn,cV as xg,cW as yg,aN as wg,cX as vi,cY as vg,cZ as Sg,c_ as jg,c$ as Pu,d0 as kg,d1 as Ba,d2 as Cg,d3 as Du,d4 as Ng,aS as Hi,d5 as Gi,d6 as El,d7 as Ag,d8 as Rl,d9 as Rr,c as Ur,d as Fa,ac as Pg,a7 as Iu,da as Cr,db as Mr,dc as Dg,dd as Ig,de as Tg,a5 as La,df as Eg,aM as Rg,dg as Mg,dh as Og,di as Bg,dj as Fg,dk as Tu,dl as Us,dm as Lg,dn as Eu,dp as _g,ag as qi,dq as $g,dr as Ru,ds as ns,dt as zg,du as Wg,dv as Mu,dw as Kg,dx as _a,a9 as $a,dy as Ml,ae as Fo,e as za,dz as Vg,ad as Ou,dA as Bu,dB as Yi,P as Fu,U as Wa,V as Ka,W as Va,dC as Ug,dD as Hg,dE as Gt,dF as Gg,dG as yr,dH as Lu,dI as _u,dJ as $u,dK as zu,dL as qg,E as Yg,dM as Qg,X as Xg,$ as Wu,ak as Jg,Z as Zg,Y as Ol,dN as eb,dO as Ku,F as Vu,dP as tb,dQ as sb,dR as nb,dS as rb,dT as _r,a0 as Qi,dU as ob,dV as ib,dW as ab,dX as lb,al as cb,dY as Uu,dZ as Jo,d_ as db,d$ as Hr,ab as ub,G as Zo,e0 as fb,e1 as mb,e2 as Bl,e3 as hb,e4 as pb,a6 as gb,aa as bb,e5 as xb,e6 as yb,b9 as Fl,aj as Ll,ai as _l,e7 as wb,b4 as Xi,e8 as vb,M as Sb,N as Si,e9 as jb,aE as kb,ea as Cb,eb as Nb,ec as Ab,ed as Pb,ee as Db,ef as Ib,eg as Tb,eh as Eb,af as Rb,ei as Mb,ej as Lo,ek as Ob,el as $l,em as Bb,en as Fb,eo as Lb,ep as _b,a as Hu,eq as Ji,er as Ua,_ as Gu,es as $b,et as Do,eu as zb,i as Wb,ev as Kb,ew as Vb,ex as Ub,ey as Hb,ez as Gb,eA as qb,eB as zl,eC as Yb,aZ as Qb,a_ as Xb,b0 as Jb,a$ as Zb,b2 as Wl,b3 as Kl,b6 as Vl,b7 as Ul,b5 as qu,b8 as Yu,eD as ex,bm as tx,bn as sx,bo as nx,bp as rx,bq as ox,bg as ix,bi as ax,bj as lx,bk as cx,bl as dx}from"./useAppFontEffects-Dsl_sLrj.js";import{u as Qu,S as Hl,C as ux,t as fx,W as Xu,f as mx,G as hx,a as px}from"./useRootScrollLock-2rd5Y6gR.js";import{u as En,O as Gl,D as gx,a as bx,b as xx,f as yx,c as ql,s as wx,d as vx,e as Sx,r as jx}from"./scheduledTasksApi-BuzWT445.js";import{f as ei,h as mn,T as ti,M as si,D as ni,j as ri,d as kx,b as Cx,k as Nx,i as Ax}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as oi,S as Ha,h as Px,a as Ju,v as Zu,s as Dx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as ii}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as ef,M as tf,C as sf,a as Zi,b as ea,c as ta,d as nf,e as Ix,f as Tx}from"./vendor-base-ui-DnNniUWp.js";import{c as Jr,u as Un,d as Ex,p as Rx}from"./vendor-zustand-BAGL70zf.js";import{g as Mx,a as Ox,E as rf,b as Bx,c as Fx,d as Lx,e as _x,i as $x}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as zx}from"./PluginPane-2C71F8uF.js";import{a as Ga,s as Hn,r as of,o as Yl,b as Ql}from"./vendor-zod-CxRSdNoV.js";import{u as Wx}from"./vendor-tanstack-react-virtual--0sBrLRh.js";import{d as Kx}from"./vendor-tanstack-virtual-core-BoA4iGMw.js";import{d as af}from"./vendor-cron-parser-CjvYVigk.js";const Vx="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",Ux="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",ji=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?Vx:t.id==="terminal"?Ux:void 0}),Xl=t=>{const e=nt.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 g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l(!0),e[2]=g):g=e[2];let x;return e[3]!==u?(x=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=x):x=e[4],x}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Ie("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},Hx=t=>{const e=nt.c(75),{directory:n,className:r}=t,{t:i}=At(),o=En(Gx),l=En(qx),a=En(Yx),d=En(Qx),u=En(Xx),m=En(Jx),f=En(Zx);let g,x;e[0]!==u?(g=()=>{u()},x=[u],e[0]=u,e[1]=g,e[2]=x):(g=e[1],x=e[2]),c.useEffect(g,x);const b=hn()&&Yo();let j;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(L=>L.id===o)??l.find(ey)??l[0]??Gl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const fe=we;if(fe){let L;e[6]!==fe?(L=ji(fe),e[6]=fe,e[7]=L):L=e[7],j=L;break e}let Pe;e[8]===Symbol.for("react.memo_cache_sentinel")?(Pe=ji(Gl[0]),e[8]=Pe):Pe=e[8],j=Pe}const y=j;if(!b||!n||l.length===0)return null;let h;e[9]!==n?(h=async we=>{await Gm(n,we.id,we.appName)||await qm(n,we.appName)},e[9]=n,e[10]=h):h=e[10];const p=h;let w;e[11]!==p||e[12]!==f?(w=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=w):w=e[13];const S=w;let N;e[14]!==n||e[15]!==i?(N=async()=>{(await Gn(n)).ok&&Fe.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=N):N=e[16];const P=N;let C;e[17]!==r?(C=Ie("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]=C):C=e[18];let T;e[19]!==p||e[20]!==y?(T=()=>{p(y)},e[19]=p,e[20]=y,e[21]=T):T=e[21];const O=d&&"animate-pulse";let M;e[22]!==O?(M=Ie("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",O),e[22]=O,e[23]=M):M=e[23];let 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 K;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(K=s.jsx(Xl,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=K):K=e[30];let D;e[31]!==M||e[32]!==F||e[33]!==K||e[34]!==T?(D=s.jsx("button",{type:"button",onClick:T,className:M,"aria-label":F,children:K}),e[31]=M,e[32]=F,e[33]=K,e[34]=T,e[35]=D):D=e[35];let U;e[36]===Symbol.for("react.memo_cache_sentinel")?(U=Ie("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=U):U=e[36];let A;e[37]!==i?(A=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=A):A=e[38];let E;e[39]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=E):E=e[39];let W;e[40]!==A?(W=s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:U,"aria-label":A,children:E})}),e[40]=A,e[41]=W):W=e[41];let k;e[42]!==P?(k=()=>{P()},e[42]=P,e[43]=k):k=e[43];let v;e[44]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(B,{name:"file-copy",className:"h-4 w-4"}),e[44]=v):v=e[44];let I;e[45]!==i?(I=i("openInApp.actions.copyPath"),e[45]=i,e[46]=I):I=e[46];let H;e[47]!==I?(H=s.jsx("span",{className:"typography-ui-label text-foreground",children:I}),e[47]=I,e[48]=H):H=e[48];let _;e[49]!==k||e[50]!==H?(_=s.jsxs(zt,{className:"flex items-center gap-2",onClick:k,children:[v,H]}),e[49]=k,e[50]=H,e[51]=_):_=e[51];let se;e[52]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(ps,{}),e[52]=se):se=e[52];let te;if(e[53]!==l||e[54]!==S||e[55]!==y.id){let we;e[57]!==S||e[58]!==y.id?(we=fe=>{const Pe=ji(fe);return s.jsxs(zt,{className:"flex items-center gap-2",onClick:()=>{S(fe)},children:[s.jsx(Xl,{label:fe.label,iconDataUrl:fe.iconDataUrl,fallbackIconDataUrl:Pe.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:fe.label}),y.id===fe.id?s.jsx(B,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},fe.id)},e[57]=S,e[58]=y.id,e[59]=we):we=e[59],te=l.map(we),e[53]=l,e[54]=S,e[55]=y.id,e[56]=te}else te=e[56];let ee;e[60]!==a||e[61]!==m||e[62]!==i?(ee=a?s.jsxs(zt,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(B,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=m,e[62]=i,e[63]=ee):ee=e[63];let ue;e[64]!==_||e[65]!==te||e[66]!==ee?(ue=s.jsxs(js,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[_,se,te,ee]}),e[64]=_,e[65]=te,e[66]=ee,e[67]=ue):ue=e[67];let de;e[68]!==W||e[69]!==ue?(de=s.jsxs(ks,{children:[W,ue]}),e[68]=W,e[69]=ue,e[70]=de):de=e[70];let Re;return e[71]!==D||e[72]!==de||e[73]!==C?(Re=s.jsxs("div",{className:C,children:[D,de]}),e[71]=D,e[72]=de,e[73]=C,e[74]=Re):Re=e[74],Re};function Gx(t){return t.selectedAppId}function qx(t){return t.availableApps}function Yx(t){return t.isCacheStale}function Qx(t){return t.isScanning}function Xx(t){return t.initialize}function Jx(t){return t.loadInstalledApps}function Zx(t){return t.selectApp}function ey(t){return t.id===gx}const _o=new Map,sa=new Set,lf=()=>{for(const t of sa)t()},ki=(t,e)=>{const n=t.trim();n&&(e.length===0?_o.delete(n):_o.set(n,[...e]),lf())},ty=t=>{_o.delete(t.trim())&&lf()},cf=[],sy=t=>_o.get(t.trim())??cf,ny=t=>(sa.add(t),()=>{sa.delete(t)}),ry=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=()=>sy(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(ny,n,oy)};function oy(){return cf}const iy=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],ay=["dev","start","preview","serve"];async function ly(t,e,n){if(!t)return null;const r=uy(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=fy(n);if(i){const o=await my(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 cy(t)){const i=await dy(),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 cy(t){const e=`${t}/index.html`,n=await $o(e,t);return typeof n=="string"&&n.trim().length>0}async function dy(){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 uy(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(ay.some(i=>n.includes(i)))return e}return null}function fy(t){for(const{pattern:e}of iy)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function my(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 hy(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 Vs="__openchamber_auto_discover_preview__",py=15e3,gy=3e3,Ci=t=>t.id===Vs?"scan-2":Ih.find(n=>n.key===t.icon)?.Icon??"play",by=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}},xy=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=At(),{currentTheme:l}=qn(),{terminal:a,runtime:d}=bn(),u=Yn(),{isMobile:m}=Dn(),f=c.useMemo(()=>hn(),[]),g=Sl(X=>X.instances),x=Sl(X=>X.load),b=ye(X=>X.terminalShell),j=ye(X=>X.terminalLoginShells.includes(X.terminalShell)),y=ye(X=>X.setSettingsPage),h=ye(X=>X.setSettingsDialogOpen),p=ye(X=>X.setSettingsProjectsSelectedId),w=ye(X=>X.openContextPreview),S=Rt(X=>X.ensureDirectory),N=Rt(X=>X.reconcileServerSessions),P=Rt(X=>X.setTabLabel),C=Rt(X=>X.setTabIconKey),T=Rt(X=>X.setActiveTab),O=Rt(X=>X.setConnecting),M=Rt(X=>X.setTabSessionId),F=Rt(X=>X.setTabPurpose),K=Rt(X=>X.allocateActionExecution),D=Rt(X=>X.setTabLifecycle),U=Rt(X=>X.setTabPreviewUrl),A=Rt(X=>X.matchesActionExecution),E=Rt(X=>X.captureStartedActionMutationRevisions),[W,k]=c.useState([]),v=c.useRef(null),[I,H]=c.useState(null),[_,se]=c.useState(!1),te=c.useRef({}),ee=c.useRef({}),ue=c.useRef({}),de=c.useRef(new Set),Re=c.useRef(0),[we,fe]=c.useState({}),Pe=t?.id??null,L=t?.path??"",oe=c.useMemo(()=>Pe?{id:Pe,path:L}:null,[Pe,L]);c.useEffect(()=>{f&&x().catch(()=>{})},[f,x]);const ce=c.useCallback(async X=>{await Yr(X)},[]),he=c.useCallback(async()=>{if(!oe)return;const X=Re.current+1;Re.current=X,se(!0);try{const ae=await Cl(oe);if(Re.current!==X)return;v.current=ae;const De=ae.projectActions;k(De),H(Ke=>Ke===Vs||Ke&&De.some(q=>q.id===Ke)?Ke:null)}catch{if(Re.current!==X)return}finally{Re.current===X&&se(!1)}},[oe]),Y=c.useMemo(()=>xi(e||oe?.path||""),[e,oe?.path]),ve=c.useMemo(()=>xi(oe?.path||""),[oe?.path]),Te=c.useMemo(()=>xi(u||"")||Y,[u,Y]),ke=c.useRef(Te);c.useEffect(()=>{ke.current=Te},[Te]);const xe=Rt(X=>Y?X.getDirectoryState(Y):void 0),ge=Rt(X=>ve&&ve!==Y?X.getDirectoryState(ve):void 0),Q=c.useMemo(()=>{const X=Y?[{directory:Y,state:xe}]:[];return ve&&ve!==Y&&X.push({directory:ve,state:ge}),X},[xe,Y,ve,ge]),$=c.useMemo(()=>{const X=Y?[Y]:[];return ve&&ve!==Y&&X.push(ve),X},[Y,ve]),J=c.useCallback(X=>X.id!==Vs&&X.runIn==="parent"&&ve||Y,[Y,ve]),me=c.useCallback((X,ae,De)=>`${X}::${ae}::${De}`,[]),le=c.useCallback((X,ae,De=Rt.getState())=>X?De.getDirectoryState(X)?.tabs.find(Ke=>Ke.purpose.type==="project-action"&&Ke.purpose.actionId===ae)??null:null,[]),V=c.useMemo(()=>{const X={};for(const{directory:ae,state:De}of Q)for(const Ke of De?.tabs??[]){if(Ke.purpose.type!=="project-action"||!Ke.purpose.executionId||!Ke.terminalSessionId||Ke.lifecycle==="idle"||Ke.lifecycle==="exited")continue;const q=Ws(ae,Ke.purpose.actionId),Be=me(ae,Ke.purpose.actionId,Ke.purpose.executionId);X[q]={directory:ae,actionId:Ke.purpose.actionId,tabId:Ke.id,sessionId:Ke.terminalSessionId,executionId:Ke.purpose.executionId,status:Ke.lifecycle==="stopping"?"stopping":we[Be]?"waiting-for-preview":"running"}}return X},[me,we,Q]),Z=c.useCallback((X,ae,De)=>{const Ke=Ws(X,ae),q=me(X,ae,De),Ze=te.current[Ke]?.executionId===De,Qe=globalThis.window,et=Ct=>{Qe?.clearTimeout(ue.current[Ct]),delete ue.current[Ct]};Ze&&(delete te.current[Ke],et(Ke)),ee.current[q]?.(),delete ee.current[q],et(q),fe(Ct=>{if(!Ct[q])return Ct;const Ge={...Ct};return delete Ge[q],Ge})},[me]),G=c.useCallback(X=>{ee.current[X]?.(),delete ee.current[X]},[]),ie=c.useCallback(X=>{window.clearTimeout(ue.current[X]),delete ue.current[X]},[]);c.useEffect(()=>{const X=ee.current,ae=ue.current;return()=>{for(const De of Object.keys(X))G(De);for(const De of Object.keys(ae))ie(De)}},[ie,G]),c.useEffect(()=>{const X=new Set($);for(const ae of Object.values(te.current))X.has(ae.directory)||Z(ae.directory,ae.actionId,ae.executionId);for(const ae of Object.keys(ee.current)){const De=ae.split("::",1)[0]??"";X.has(De)||G(ae)}},[Z,G,$]);const je=c.useCallback((X,ae)=>{ye.getState().openContextPanelTab(X,{mode:"terminal",targetDirectory:ae===X?null:ae})},[]),ne=c.useMemo(()=>I?W.find(X=>X.id===I)??null:null,[W,I]),Oe=c.useMemo(()=>({id:Vs,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),Ve=!m,ze=c.useMemo(()=>Ve?[Oe,...W]:W,[W,Oe,Ve]);c.useEffect(()=>{he()},[he]),c.useEffect(()=>{const X=$.map(ae=>$i(a,ae,E,De=>N(ae,De.sessions,{startedActionMutationRevisions:De.startedActionMutationRevisions})));return()=>{for(const ae of X)ae()}},[E,N,a,$]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)if(X)for(const De of ae?.tabs??[]){if(De.purpose.type!=="project-action")continue;const Ke=De.purpose.actionId,q=ze.find(Qe=>Qe.id===Ke),Be=q?.name??Ke,Ze=q?.icon||"play";De.label!==Be&&P(X,De.id,Be),De.iconKey!==Ze&&C(X,De.id,Ze)}},[ze,C,P,Q]),c.useEffect(()=>{const X=globalThis.window;if(!X)return;const ae=De=>{const Ke=De.detail;Pe&&(Ke?.projectId&&Ke.projectId!==Pe||he())};return X.addEventListener(jl,ae),()=>{X.removeEventListener(jl,ae)}},[he,Pe]),c.useEffect(()=>{I&&(I===Vs&&Ve||W.some(X=>X.id===I)||H(null))},[W,Ve,I]),c.useEffect(()=>{const X=De=>{delete ue.current[De];const Ke=te.current[De];if(!Ke||Ke.openedUrl)return;const q=me(Ke.directory,Ke.actionId,Ke.executionId),Be=Ke.announced;if(Be.length!==0){if(window.clearTimeout(ue.current[q]),delete ue.current[q],Ke.openedUrl=!0,fe(Ze=>{if(!Ze[q])return Ze;const Qe={...Ze};return delete Qe[q],Qe}),Be.length===1){ki(Ke.directory,[]),U(Ke.directory,Ke.tabId,Be[0],{locked:!1,autoOpened:!0}),w(Ke.directory,Be[0]);return}Ke.offering=!0,ki(Ke.directory,Be),ye.getState().openContextSurface(Ke.directory,"browser"),Fe.info(o("projectActions.toast.multipleServers"))}},ae=()=>{const De=Rt.getState(),Ke=De.sessions,q=V;for(const[Be,Ze]of Object.entries(q)){const et=Ke.get(Ze.directory)?.tabs.find(We=>We.id===Ze.tabId);if(!et||et.terminalSessionId!==Ze.sessionId){Z(Ze.directory,Ze.actionId,Ze.executionId);continue}const Ct=te.current[Be],Ge=Ct?.executionId===Ze.executionId?Ct:{hostDirectory:ke.current||Ze.directory,directory:Ze.directory,tabId:Ze.tabId,actionId:Ze.actionId,executionId:Ze.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};te.current[Be]=Ge;const Tt=ze.find(We=>We.id===Ze.actionId),Bt=De.getBuffer(Ze.directory,Ze.tabId).chunks;if(!Tt||Bt.length===0)continue;const Ce=Bt.filter(We=>Ge.lastSeenChunkId===null||We.id>Ge.lastSeenChunkId);if(Ce.length===0)continue;const Me=Ce.map(We=>We.data).join(""),st=`${Ge.tail}${Me}`;if(Ge.openInPreview&&(!Ge.openedUrl||Ge.offering)){const We=Ph(st),dt=Ge.announced.length;for(const Se of We)Ge.announced.includes(Se)||Ge.announced.push(Se);const bt=Ge.announced.length-dt;Ge.offering&&bt>0?ki(Ze.directory,Ge.announced):!Ge.openedUrl&&dt===0&&Ge.announced.length>0&&(window.clearTimeout(ue.current[Be]),ue.current[Be]=window.setTimeout(()=>X(Be),gy))}const Xe=!Ge.openedUrl&&Tt.autoOpenUrl===!0&&!Ge.openInPreview?Dh(st):null,Ne=Ce[Ce.length-1]?.id??Ge.lastSeenChunkId;if(Ge.lastSeenChunkId=Ne,Ge.tail=st.slice(-512),Xe)if(Ge.openedUrl=!0,Ge.openInPreview){const We=q[Be];We&&(U(We.directory,We.tabId,Xe,{locked:!1,autoOpened:!1,expectedExecutionId:We.executionId}),We.status==="waiting-for-preview"&&fe(dt=>{const bt=me(We.directory,We.actionId,We.executionId);if(!dt[bt])return dt;const Se={...dt};return delete Se[bt],Se}),window.clearTimeout(ue.current[Be]),delete ue.current[Be],w(We.directory,Xe))}else ce(Xe),Fe.success(o("projectActions.toast.openedUrlFromOutput"));te.current[Be]=Ge}for(const Be of Object.keys(te.current))if(!q[Be]){const Ze=te.current[Be],Qe=Ze?Ke.get(Ze.directory)?.tabs.find(Ct=>Ct.id===Ze.tabId):void 0;if(Qe?.purpose.type==="project-action"&&Qe.purpose.executionId===Ze?.executionId&&!!Qe.terminalSessionId&&Qe.lifecycle!=="idle"&&Qe.lifecycle!=="exited")continue;delete te.current[Be],window.clearTimeout(ue.current[Be]),delete ue.current[Be]}};return ae(),Rt.subscribe((De,Ke)=>{(De.sessions!==Ke.sessions||De.buffers!==Ke.buffers)&&ae()})},[Z,ke,ze,me,w,ce,V,U,o]),c.useEffect(()=>{for(const{directory:X,state:ae}of Q)for(const De of ae?.tabs??[]){if(De.purpose.type!=="project-action"||!De.purpose.executionId||!De.terminalSessionId||De.lifecycle!=="running")continue;const Ke=De.purpose.actionId,q=De.purpose.executionId,Be=me(X,Ke,q);if(ee.current[Be])continue;const Ze=a.connect(De.terminalSessionId,{onEvent:Qe=>{if(!A(X,De.id,q))return;Qe.type==="snapshot"&&(Rt.getState().replaceBuffer(X,De.id,Qe.data??"",Qe.sequence??0,hl(Qe)),Qe.status==="running"&&Rt.getState().setTabLifecycle(X,De.id,"running",{expectedExecutionId:q}),Qe.status==="exited"&&(Rt.getState().setTabLifecycle(X,De.id,"exited",{expectedExecutionId:q}),Rt.getState().setTabPurpose(X,De.id,{type:"project-action",actionId:Ke,executionId:null}),Z(X,Ke,q)));const et=Qe.type==="data"?Qe.data??"":"";et&&Rt.getState().appendToBuffer(X,De.id,et,Qe.sequence,Qe.replayData),Qe.type==="exit"&&(Rt.getState().setTabLifecycle(X,De.id,"exited",{expectedExecutionId:q}),Rt.getState().setTabPurpose(X,De.id,{type:"project-action",actionId:Ke,executionId:null}),Z(X,Ke,q))},onError:(Qe,et)=>{!et||!A(X,De.id,q)||(Rt.getState().setTabLifecycle(X,De.id,"exited",{expectedExecutionId:q}),Rt.getState().setTabSessionId(X,De.id,null,{expectedExecutionId:q}),Rt.getState().setTabPurpose(X,De.id,{type:"project-action",actionId:Ke,executionId:null}),Z(X,Ke,q))}},X);ee.current[Be]=Ze.close}},[Z,me,A,a,Q]);const He=c.useCallback(async X=>{const ae=J(X);if(!ae)throw new Error(o("projectActions.error.noActiveDirectory"));const De=Ws(ae,X.id);S(ae);const Ke=Rt.getState(),q=le(ae,X.id,Ke),Be=q?.id??Ke.createTab(ae);P(ae,Be,X.name),C(ae,Be,X.icon||"play"),q||F(ae,Be,{type:"project-action",actionId:X.id,executionId:null}),T(ae,Be);const Qe=Rt.getState().getDirectoryState(ae)?.tabs.find(et=>et.id===Be);return{executionDirectory:ae,key:De,tabId:Be,sessionId:Qe?.terminalSessionId??null,executionId:Qe?.purpose.type==="project-action"?Qe.purpose.executionId:null}},[S,J,le,T,C,P,F,o]),$e=c.useCallback(async X=>{if(d.isVSCode||!i&&m)return;if(!Y){Fe.error(o("projectActions.error.noActiveDirectoryForAction"));return}const ae=Ws(J(X),X.id),De=V[ae];if(De&&De.status==="running"||de.current.has(ae))return;de.current.add(ae);let Ke=null;try{const q=X.id===Vs?await(async()=>{const[bt,Se]=await Promise.all([Pp({id:oe?.id??"",path:Y}),hy(Y)]),Je=await ly(Y,bt.actions,Se);if(!Je)throw new Error(o("contextPanel.preview.noDevServer"));return{id:Vs,name:o("projectActions.actions.autoDiscover"),command:Je.command,icon:"scan-2",autoOpenUrl:!0,openUrl:Je.previewUrlHint||""}})():X,Be=q.autoOpenUrl===!0&&(q.openUrl||"").trim().length>0,Ze=!Be&&X.id!==Vs,Qe=ke.current||Y,{executionDirectory:et,key:Ct,tabId:Ge}=await He(q),Tt=jh(q.command);if(!Tt)throw new Error(o("projectActions.error.failedToRunAction"));const Bt=q.autoOpenUrl===!0&&f&&(q.desktopOpenSshForward||"").trim().length>0,Ce=q.autoOpenUrl?by(q.openUrl):null,Me=q.autoOpenUrl&&f?kh(q.desktopOpenSshForward,g):null;if(a.listSessions){const bt=le(et,q.id);if(bt?.purpose.type==="project-action"&&bt.purpose.executionId===null){const Se=await Ch(a,et,{captureStartedActionMutationRevisions:E});Se&&N(et,Se.sessions,{startedActionMutationRevisions:Se.startedActionMutationRevisions})}}const st=le(et,q.id);let Xe,Ne;if(st?.lifecycle==="running"&&st.terminalSessionId&&st.purpose.type==="project-action"&&st.purpose.executionId)Xe=st.terminalSessionId,Ne=st.purpose.executionId;else{const bt=st?.purpose.type==="project-action"?st.purpose.executionId:null;bt&&Z(et,q.id,bt);const Se=K(et,Ge,q.id);if(!Se)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ke={directory:et,tabId:Ge,id:Se},O(et,Ge,!0,{expectedExecutionId:Se});const Je=await Nh({terminal:a,createOptions:{cwd:et,shell:b,loginShell:j,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Tt,isRunStillExpected:()=>A(et,Ge,Se),purpose:{type:"project-action",actionId:q.id,executionId:Se}});if(!A(et,Ge,Se)){Je.sessionId===Se&&await a.close(Je.sessionId).catch(()=>{});return}Ne=Je.purpose?.type==="project-action"?Je.purpose.executionId:Se,Xe=Je.sessionId,F(et,Ge,{type:"project-action",actionId:q.id,executionId:Ne}),M(et,Ge,Xe,{expectedExecutionId:Ne}),O(et,Ge,!1,{expectedExecutionId:Ne})}Ze&&Qe&&je(Qe,et),te.current[Ct]={hostDirectory:Qe,directory:et,tabId:Ge,actionId:q.id,executionId:Ne,lastSeenChunkId:null,openedUrl:!!Me||!!Ce||Be,tail:"",openInPreview:q.id===Vs,announced:[],offering:!1};const We=me(et,q.id,Ne);O(et,Ge,!0,{expectedExecutionId:Ne});const dt=a.connect(Xe,{onEvent:bt=>{if(!A(et,Ge,Ne)||bt.purpose?.type==="project-action"&&bt.purpose.executionId!==Ne)return;bt.type==="snapshot"&&(Rt.getState().replaceBuffer(et,Ge,bt.data??"",bt.sequence??0,hl(bt)),Rt.getState().setConnecting(et,Ge,!1,{expectedExecutionId:Ne}),bt.purpose?.type==="project-action"&&Rt.getState().setTabPurpose(et,Ge,{type:"project-action",actionId:bt.purpose.actionId,executionId:bt.purpose.executionId}),bt.status==="running"&&Rt.getState().setTabLifecycle(et,Ge,"running",{expectedExecutionId:Ne}),bt.status==="exited"&&(Rt.getState().setTabLifecycle(et,Ge,"exited",{expectedExecutionId:Ne}),Rt.getState().setTabPurpose(et,Ge,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ne)));const Se=bt.type==="data"?bt.data??"":"";Se&&Rt.getState().appendToBuffer(et,Ge,Se,bt.sequence,bt.replayData),bt.type==="exit"&&(Rt.getState().setTabLifecycle(et,Ge,"exited",{expectedExecutionId:Ne}),Rt.getState().setConnecting(et,Ge,!1,{expectedExecutionId:Ne}),Rt.getState().setTabPurpose(et,Ge,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ne))},onError:(bt,Se)=>{A(et,Ge,Ne)&&(Rt.getState().setConnecting(et,Ge,!1,{expectedExecutionId:Ne}),Se&&(Rt.getState().setTabLifecycle(et,Ge,"exited",{expectedExecutionId:Ne}),Rt.getState().setTabSessionId(et,Ge,null,{expectedExecutionId:Ne}),Rt.getState().setTabPurpose(et,Ge,{type:"project-action",actionId:q.id,executionId:null}),Z(et,q.id,Ne)))}},et);if(!A(et,Ge,Ne)){dt.close();return}ee.current[We]?.(),ee.current[We]=dt.close,window.clearTimeout(ue.current[We]),delete ue.current[We],q.id===Vs&&!Ce&&(fe(bt=>({...bt,[We]:!0})),ue.current[We]=window.setTimeout(()=>{delete ue.current[We];const bt=te.current[Ct];!bt||bt.executionId!==Ne||bt.openedUrl||bt.offering||A(et,Ge,Ne)&&(fe(Se=>{if(!Se[We])return Se;const Je={...Se};return delete Je[We],Je}),Rt.getState().setActiveTab(et,Ge),je(bt.hostDirectory,et))},py)),Me?(U(et,Ge,null,{locked:!0,expectedExecutionId:Ne}),ce(Me),Fe.success(o("projectActions.toast.openedForwardedUrl"))):Ce?(U(et,Ge,Ce,{locked:!0,autoOpened:!0,expectedExecutionId:Ne}),w(Qe,Ce),Fe.success(o("projectActions.toast.openedActionUrl"))):Be?(U(et,Ge,null,{locked:!0,expectedExecutionId:Ne}),Fe.error(o("projectActions.error.invalidCustomUrlFormat"))):Bt?(U(et,Ge,null,{locked:!0,expectedExecutionId:Ne}),Fe.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):U(et,Ge,null,{locked:!1,autoOpened:!1,expectedExecutionId:Ne})}catch(q){if(Ke&&A(Ke.directory,Ke.tabId,Ke.id)){const{directory:Be,tabId:Ze,id:Qe}=Ke;Z(Be,X.id,Qe),D(Be,Ze,"exited",{expectedExecutionId:Qe}),F(Be,Ze,{type:"project-action",actionId:X.id,executionId:null})}if(q instanceof Error&&q.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(q instanceof Error&&(q.message==="COMMAND_MODE_UNSUPPORTED"||q.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Fe.error(o("projectActions.error.failedToCreateTerminalSession"));return}Fe.error(q instanceof Error?q.message:o("projectActions.error.failedToRunAction"))}finally{de.current.delete(ae)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,ke,g,He,i,m,f,Y,j,b,ce,w,V,je,d.isVSCode,J,A,Z,me,le,N,K,E,O,D,F,U,M,oe?.id,o,a]),R=c.useCallback(async X=>{const ae=Ws(J(X),X.id),De=V[ae];De&&await Ah({terminal:a,sessionId:De.sessionId,isExecutionStillCurrent:()=>A(De.directory,De.tabId,De.executionId),markStopping:()=>{D(De.directory,De.tabId,"stopping",{expectedExecutionId:De.executionId})},restoreRunning:()=>{D(De.directory,De.tabId,"running",{expectedExecutionId:De.executionId})},clearSession:()=>{M(De.directory,De.tabId,null,{expectedExecutionId:De.executionId})},finalizeExit:()=>{D(De.directory,De.tabId,"exited",{expectedExecutionId:De.executionId}),F(De.directory,De.tabId,{type:"project-action",actionId:De.actionId,executionId:null}),Z(De.directory,De.actionId,De.executionId)}})},[Z,J,A,V,D,F,M,a]),pe=c.useCallback(()=>{const X=ne??ze[0];if(!X)return;const ae=Ws(J(X),X.id),De=V[ae];if(De?.status!=="stopping"){if(De){R(X);return}$e(X)}},[ze,J,$e,V,ne,R]),Le=c.useCallback(async X=>{if(X.source==="shared"&&oe){const ae=v.current?.trust.trusted?v.current:await Cl(oe);if(v.current=ae,!await Dp(oe,ae))return;v.current={...ae,trust:{...ae.trust,trusted:!0}}}await $e(X)},[$e,oe]),_e=c.useCallback((X,ae=!1)=>{if(H(X.id),!ae){Le(X);return}const De=Ws(J(X),X.id),Ke=V[De];if(Ke?.status!=="stopping"){if(Ke){R(X);return}Le(X)}},[J,Le,V,R]),lt=c.useCallback(()=>{oe?.id&&(p(oe.id),y("projects"),h(!0))},[h,y,p,oe?.id]),ht=ne??ze[0]??null,ot=ht?V[Ws(J(ht),ht.id)]:null,ut=Rt(X=>ot?X.getDirectoryState(ot.directory)?.tabs.find(ae=>ae.id===ot.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&m||!oe||!Y)return null;const yt=ne??ze[0]??null;if(!yt)return null;const mt=Ci(yt),xt=Ws(J(yt),yt.id),Dt=V[xt],be=Dt?.status==="stopping",qe=Dt?.status==="waiting-for-preview",Ye=!!(Dt&&ut),Ue=()=>{!Dt||!ut||w(Dt.directory,ut)},ct=yt.id===Vs;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",disabled:_||be,className:Ie("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:pe,"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:be||qe?s.jsx(B,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(B,{name:mt,className:"h-5 w-5"})})}),ct?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ye?s.jsxs(vt,{children:[s.jsx(St,{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:Ue,children:s.jsx(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(ks,{children:[s.jsx(Ss,{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(B,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(js,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(zt,{className:"flex items-center gap-2",onClick:lt,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(ps,{}),ze.map(X=>{const ae=Ci(X),De=Ws(J(X),X.id),Ke=V[De],q=!!Ke,Be=Ke?.status==="stopping";return s.jsxs(zt,{className:"flex items-center gap-2",onClick:()=>{_e(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Be||Ke?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:Ie("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(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:pe,disabled:_||be,className:Ie("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":Dt?o("projectActions.actions.stopNamedAria",{name:yt.name}):o("projectActions.actions.runNamedAria",{name:yt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:be||qe?s.jsx(B,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Dt?s.jsx(B,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(B,{name:mt,className:"h-4 w-4"})})})}),ct?s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ye?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ue,className:Ie(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(B,{name:"global",className:"h-4 w-4"})})}),s.jsx(jt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(ks,{children:[s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(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(B,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(js,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(zt,{className:"flex items-center gap-2",onClick:lt,children:[s.jsx(B,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(ps,{}),ze.map(X=>{const ae=Ci(X),De=Ws(J(X),X.id),Ke=V[De],q=!!Ke,Be=Ke?.status==="stopping";return s.jsxs(zt,{className:"flex items-center gap-2",onClick:()=>{_e(X,!0)},children:[s.jsx(B,{name:ae,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),X.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Be||Ke?.status==="waiting-for-preview"?s.jsx(B,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):q?s.jsx(B,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})},Or=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},yy=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=Or(n??"");if(i){const o=ru(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function wy(){const t=Kt(b=>b.projects),e=Kt(b=>b.activeProjectId),n=rt(b=>b.availableWorktreesByProject),r=rt(b=>b.currentSessionId),i=Ip(r??null),o=rt(b=>r?b.worktreeMetadata.get(r)?.path??"":""),l=rt(b=>b.newSessionDraft?.open?Or(b.newSessionDraft.bootstrapPendingDirectory??b.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>Or(o||""),[o]),d=c.useMemo(()=>{const b=typeof i?.directory=="string"?i.directory:"";return Or(b||"")},[i?.directory]),u=a||d||l,m=c.useMemo(()=>yy({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>Or(u||m?.path||""),[u,m?.path]),g=c.useMemo(()=>m?{id:m.id,path:m.path}:null,[m]),x=c.useRef(null);return c.useEffect(()=>{g&&f&&(x.current={projectRef:g,directory:f})},[f,g]),c.useMemo(()=>g&&f?{projectRef:g,directory:f}:x.current,[g,f])}const vy=({transform:t})=>({...t,y:0}),Sy={Item:zt,Separator:ps},jy={Item:({className:t,...e})=>s.jsx(tf,{className:Ie(lu,t),...e}),Separator:({className:t,...e})=>s.jsx(ef,{className:Ie(au,t),...e})},ky=t=>{const e=nt.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:m}=t,{t:f}=At(),[g,x]=c.useState(!1),[b,j]=c.useState(!1),[y,h]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:w,listeners:S,setNodeRef:N,transform:P,transition:C,isDragging:T}=oi(p);let O;e[2]!==f||e[3]!==n.session.title?(O=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=O):O=e[4];const M=O,F=!i&&(g||b),K=n.id;let D;e[5]!==n.session?(D=Is(n.session),e[5]=n.session,e[6]=D):D=e[6];const U=Ia(K,D),A=ou(n.id),W=iu(n.id)>0&&!r&&!A,k=A||W;let v;e[7]!==A||e[8]!==f?(v=f(A?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=A,e[8]=f,e[9]=v):v=e[9];const I=v;let H;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==g||e[14]!==o||e[15]!==n?(H=ve=>({session:n.session,open:g||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ve}),e[10]=d,e[11]=y,e[12]=r,e[13]=g,e[14]=o,e[15]=n,e[16]=H):H=e[16];const _=H;let se;e[17]!==P?(se=ii.Translate.toString(P),e[17]=P,e[18]=se):se=e[18];let te;e[19]!==se||e[20]!==C?(te={transform:se,transition:C},e[19]=se,e[20]=C,e[21]=te):te=e[21];const ee=T&&"z-10 opacity-60";let ue;e[22]!==ee?(ue=Ie("session-tab-slot flex h-7 w-44 shrink-0 touch-none",ee),e[22]=ee,e[23]=ue):ue=e[23];const de=r?"true":"false";let Re;e[24]!==r?(Re=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=Re):Re=e[25];let we;e[26]!==u?(we=ve=>u?.(ve),e[26]=u,e[27]=we):we=e[27];let fe;e[28]!==m||e[29]!==I||e[30]!==r||e[31]!==U||e[32]!==A||e[33]!==_||e[34]!==g||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==F||e[39]!==a||e[40]!==k||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==M?(fe=s.jsx(sf,{render:ve=>s.jsxs("div",{...ve,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),o(n))},onAuxClick:Te=>{Te.button===1&&(Te.preventDefault(),l(n.id))},"data-controls-open":F?"true":"false",className:Ie("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":Ie("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",F&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Ie("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",F&&"pr-10"),children:[s.jsx("div",{className:Ie("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?m:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:M})})}),U?s.jsx(B,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):k?s.jsx(cu,{state:A?"running":"unread",label:I,className:Ie("ml-1.5 shrink-0",!i&&"group-hover/session-tab:opacity-0",F&&"opacity-0")}):null]}),i?null:s.jsxs("div",{onClick:Ny,onPointerDown:Ay,className:Ie("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(ks,{open:g,onOpenChange:Te=>{x(Te),Te&&j(!0)},onOpenChangeComplete:Te=>{Te||j(!1),u?.(Te)},children:[s.jsx(Ss,{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(B,{name:"more",className:"size-4"})})}),s.jsx(js,{align:"start",className:"min-w-[190px]",children:a(_(Sy))})]}),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(B,{name:"close",className:"size-4"})})]})]})}),e[28]=m,e[29]=I,e[30]=r,e[31]=U,e[32]=A,e[33]=_,e[34]=g,e[35]=l,e[36]=u,e[37]=o,e[38]=F,e[39]=a,e[40]=k,e[41]=i,e[42]=f,e[43]=n,e[44]=M,e[45]=fe):fe=e[45];let Pe,L;e[46]===Symbol.for("react.memo_cache_sentinel")?(Pe={color:"var(--surface-elevated-foreground)"},L=Ie(Ki,"min-w-[190px]"),e[46]=Pe,e[47]=L):(Pe=e[46],L=e[47]);let oe;e[48]!==_||e[49]!==a?(oe=a(_(jy)),e[48]=_,e[49]=a,e[50]=oe):oe=e[50];let ce;e[51]!==oe?(ce=s.jsx(Zi,{children:s.jsx(ea,{className:"app-region-no-drag z-50",children:s.jsx(ta,{"data-slot":"dropdown-menu-content",style:Pe,className:L,children:oe})})}),e[51]=oe,e[52]=ce):ce=e[52];let he;e[53]!==y||e[54]!==we||e[55]!==fe||e[56]!==ce?(he=s.jsxs(nf,{open:y,onOpenChange:h,onOpenChangeComplete:we,children:[fe,ce]}),e[53]=y,e[54]=we,e[55]=fe,e[56]=ce,e[57]=he):he=e[57];let Y;return e[58]!==w||e[59]!==S||e[60]!==N||e[61]!==ue||e[62]!==de||e[63]!==Re||e[64]!==he||e[65]!==te?(Y=s.jsx("div",{ref:N,style:te,className:ue,"data-active":de,...Re,...w,...S,children:he}),e[58]=w,e[59]=S,e[60]=N,e[61]=ue,e[62]=de,e[63]=Re,e[64]=he,e[65]=te,e[66]=Y):Y=e[66],Y},Cy=t=>{const e=nt.c(65),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=At(),d=oo(Py),u=oo(Dy),m=oo(Iy),f=oo(Ty),g=rt(Ey),x=rt(Ry),b=gs(My),j=Th(g);let y,h;e[0]!==j||e[1]!==g||e[2]!==u?(y=()=>{g&&u(g,j)},h=[g,j,u],e[0]=j,e[1]=g,e[2]=u,e[3]=y,e[4]=h):(y=e[3],h=e[4]),c.useEffect(y,h);let p;if(e[5]!==b){p=new Map;for(const xe of b)p.set(xe.id,xe);e[5]=b,e[6]=p}else p=e[6];const w=p;let S;if(e[7]!==w||e[8]!==d){S=[];for(const xe of d){const ge=w.get(xe);ge&&S.push({id:xe,session:ge})}e[7]=w,e[8]=d,e[9]=S}else S=e[9];const N=S;let P;e[10]!==x?(P=xe=>{x(xe.id,Is(xe.session))},e[10]=x,e[11]=P):P=e[11];const C=P,T=Oy;let O;e[12]!==m||e[13]!==g||e[14]!==C||e[15]!==N?(O=xe=>{if(m(xe),g&&g!==xe){const ge=N.find(Q=>Q.id===xe);ge&&C(ge)}},e[12]=m,e[13]=g,e[14]=C,e[15]=N,e[16]=O):O=e[16];const M=O;let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},e[17]=F):F=e[17];let K;e[18]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},e[18]=K):K=e[18];const D=ei(mn(si,F),mn(ti,K));let U;e[19]!==f?(U=xe=>{const{active:ge,over:Q}=xe;Q&&ge.id!==Q.id&&f(String(ge.id),String(Q.id))},e[19]=f,e[20]=U):U=e[20];const A=U,E=c.useRef(null);let W;e[21]===Symbol.for("react.memo_cache_sentinel")?(W={left:!1,right:!1},e[21]=W):W=e[21];const[k,v]=c.useState(W);let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{const xe=E.current;if(!xe)return;const ge=xe.scrollLeft>2,Q=xe.scrollLeft+xe.clientWidth<xe.scrollWidth-2;v($=>$.left===ge&&$.right===Q?$:{left:ge,right:Q})},e[22]=I):I=e[22];const H=I;let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{H();const xe=E.current;if(!xe||!globalThis.ResizeObserver)return;const ge=new ResizeObserver(H);return ge.observe(xe),()=>ge.disconnect()},e[23]=_):_=e[23];let se;e[24]!==N.length?(se=[H,N.length],e[24]=N.length,e[25]=se):se=e[25],c.useEffect(_,se);let te;e[26]===Symbol.for("react.memo_cache_sentinel")?(te=()=>{E.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[26]=te):te=e[26];let ee;e[27]!==g?(ee=[g],e[27]=g,e[28]=ee):ee=e[28],c.useEffect(te,ee);const ue=k.left&&k.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":k.left?"linear-gradient(to right, transparent, black 24px)":k.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let de;e[29]!==N?(de=N.map(By),e[29]=N,e[30]=de):de=e[30];const Re=de;let we;e[31]!==g||e[32]!==N?(we=!g||!N.some(xe=>xe.id===g),e[31]=g,e[32]=N,e[33]=we):we=e[33];const fe=we;let Pe;e[34]!==a?(Pe=a("header.sessionTabs.stripAria"),e[34]=a,e[35]=Pe):Pe=e[35];let L;e[36]!==ue?(L=ue?{maskImage:ue,WebkitMaskImage:ue}:void 0,e[36]=ue,e[37]=L):L=e[37];let oe;e[38]===Symbol.for("react.memo_cache_sentinel")?(oe=[vy],e[38]=oe):oe=e[38];let ce;e[39]!==o||e[40]!==g||e[41]!==M||e[42]!==C||e[43]!==r||e[44]!==n||e[45]!==l||e[46]!==N?(ce=N.map(xe=>s.jsx(ky,{tab:xe,isActive:xe.id===g,suppressControls:xe.id===g&&l,onSelect:C,onClose:T,renderMenu:n,closeOtherTabs:M,onMenuOpenChangeComplete:r,children:xe.id===g?o:null},xe.id)),e[39]=o,e[40]=g,e[41]=M,e[42]=C,e[43]=r,e[44]=n,e[45]=l,e[46]=N,e[47]=ce):ce=e[47];let he;e[48]!==ce||e[49]!==Re?(he=s.jsx(Ha,{items:Re,strategy:Px,children:ce}),e[48]=ce,e[49]=Re,e[50]=he):he=e[50];let Y;e[51]!==A||e[52]!==D||e[53]!==he?(Y=s.jsx(ni,{sensors:D,collisionDetection:ri,modifiers:oe,onDragEnd:A,children:he}),e[51]=A,e[52]=D,e[53]=he,e[54]=Y):Y=e[54];let ve;e[55]!==o||e[56]!==fe?(ve=fe?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[55]=o,e[56]=fe,e[57]=ve):ve=e[57];let Te;e[58]!==L||e[59]!==Y||e[60]!==ve?(Te=s.jsxs("div",{ref:E,onScroll:H,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:L,children:[Y,ve]}),e[58]=L,e[59]=Y,e[60]=ve,e[61]=Te):Te=e[61];let ke;return e[62]!==Pe||e[63]!==Te?(ke=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":Pe,children:Te}),e[62]=Pe,e[63]=Te,e[64]=ke):ke=e[64],ke};function Ny(t){return t.stopPropagation()}function Ay(t){return t.stopPropagation()}function Py(t){return t.tabIds}function Dy(t){return t.ensureTab}function Iy(t){return t.closeOtherTabs}function Ty(t){return t.reorderTabs}function Ey(t){return t.currentSessionId}function Ry(t){return t.setCurrentSession}function My(t){return t.activeSessions}function Oy(t){Tp(t)}function By(t){return t.id}function Jl(t){const e=nt.c(20),{sessionId:n,onArchive:r,Item:i}=t,{t:o}=At();let l;e[0]!==n?(l=h=>!!h.entityById.get(n)?.time.archived,e[0]=n,e[1]=l):l=e[1];const a=gs(l),d=rt(Fy);let u;e[2]!==n||e[3]!==o||e[4]!==d?(u=async()=>{await d(n)?Fe.success(o("sessions.sidebar.session.restore.success")):Fe.error(o("sessions.sidebar.session.restore.error"))},e[2]=n,e[3]=o,e[4]=d,e[5]=u):u=e[5];const m=u;let f;e[6]!==a||e[7]!==r||e[8]!==m?(f=a?()=>{m()}:r,e[6]=a,e[7]=r,e[8]=m,e[9]=f):f=e[9];const g=a?"inbox-unarchive":"inbox-archive";let x;e[10]!==g?(x=s.jsx(B,{name:g,className:"mr-1 size-4"}),e[10]=g,e[11]=x):x=e[11];const b=a?"sessions.sidebar.bulkActions.restore":"sessions.sidebar.bulkActions.archive";let j;e[12]!==o||e[13]!==b?(j=o(b),e[12]=o,e[13]=b,e[14]=j):j=e[14];let y;return e[15]!==i||e[16]!==f||e[17]!==x||e[18]!==j?(y=s.jsxs(i,{onClick:f,children:[x,j]}),e[15]=i,e[16]=f,e[17]=x,e[18]=j,e[19]=y):y=e[19],y}function Fy(t){return t.unarchiveSession}const df=async t=>{const{entry:e,session:n}=t,r=Yt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(Ep(e.action)&&Rp(e.guest,"conversation"))){await Nl(e,Al(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 Nl(e,Al(e.action.id,i,d),t.t,r)}};function na(t){const e=nt.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=At(),{pending:a,disabled:d,hint:u,run:m}=Eh(n,r,i),f=a?"loader-4":"ai-generate-2",g=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let x;e[0]!==f||e[1]!==g?(x=s.jsx(B,{name:f,className:g}),e[0]=f,e[1]=g,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 j;e[5]!==o||e[6]!==d||e[7]!==m||e[8]!==x||e[9]!==b?(j=s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:m,className:"w-full",children:[x,b]})})}),e[5]=o,e[6]=d,e[7]=m,e[8]=x,e[9]=b,e[10]=j):j=e[10];let y;e[11]!==u?(y=s.jsx(jt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let h;return e[13]!==j||e[14]!==y?(h=s.jsxs(vt,{children:[j,y]}),e[13]=j,e[14]=y,e[15]=h):h=e[15],h}const ra=(t,e)=>({success:t(e.success),failure:t(e.failure),outcomeUnknown:t("sessions.sidebar.session.moveToWorktree.outcomeUnknown")});class uf extends Error{constructor(e){super(e.message,{cause:e}),this.name="SessionMoveOutcomeUnknownError"}}const ai=Jr(()=>({pendingSessionIds:new Set})),ff=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],ai(n)},Zl=(t,e)=>{ai.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}})},Ly=async(t,e)=>{try{const d=(await _p(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=gt(t),r=gt(e)??e,i=rt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>gt(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ec=t=>{for(const e of t){const n=Op(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class _y extends Error{constructor(e,n){super(e,{cause:n}),this.name="IncompleteRollbackError"}}const $y=(t,e)=>{const n=e.map(({sessionId:r,error:i})=>`${r}: ${i.message}`).join(", ");return new _y(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${n}`,{moveError:t,rollbackFailures:e})},zy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(Bp(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await du(o,n,e),rt.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},tc=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},sc=async(t,e)=>{const n=e?[t,e]:[t];try{await Ta(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},mf=async(t,e)=>{if(ai.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Zl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,rt.getState().getWorktreeMetadata(a.id)]));ec(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ec(n.slice(a));try{await du(d,t.sourceDirectory,i.directory)}catch(u){throw Mp(u)&&(l=!0),u}o.push(d),d.id!==t.root.id&&rt.getState().setWorktreeMetadata(d.id,Pl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await zy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await sc(t.sourceDirectory,i?.directory),u.length>0)throw $y(d,u);if(i?.onMoveFailure&&!l)return i.onMoveFailure(d);throw i?.onMoveFailure&&l?new uf(d):d}return rt.getState().setWorktreeMetadata(t.root.id,Pl(i.metadata)),await sc(t.sourceDirectory,i.directory),i.directory}finally{Zl(t.root.id,!1)}},Wy=async t=>{const e=gt(t.sourceDirectory)??t.sourceDirectory,n=gt(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 mf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},Ky=async t=>mf(t,async()=>{const e=Vi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await uu(t.sourceDirectory)?await Ly(t.sourceDirectory,e.path):null,r=await Fp(e,n?{startRef:n}:{});try{await Lp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return tc(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>tc(e,r,i)}}),Vy=t=>{(t.kind==="existing"?Wy({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination}):Ky({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory})).then(()=>Fe.success(t.messages.success)).catch(n=>{const r=n instanceof Error?n:new Error(String(n));Fe.error(t.messages.failure,{description:r instanceof uf?t.messages.outcomeUnknown:r.message})})},oa=t=>{ai.getState().pendingSessionIds.has(t.root.id)||Vy(t)},$r="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",Uy=c.memo(function(e){const n=nt.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,g=m===void 0?!1:m;if(!f)return null;const x=a??$r,b=g&&"bg-interactive-selection text-interactive-selection-foreground";let j;n[0]!==x||n[1]!==b?(j=Ie(x,b),n[0]=x,n[1]=b,n[2]=j):j=n[2];const y=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==y?(h=s.jsx(B,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=h):h=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==g||n[9]!==j||n[10]!==h?(p=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":g,className:j,children:h})}),n[6]=o,n[7]=l,n[8]=g,n[9]=j,n[10]=h,n[11]=p):p=n[11];let w;n[12]!==i?(w=s.jsx(jt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=w):w=n[13];let S;return n[14]!==p||n[15]!==w?(S=s.jsxs(vt,{children:[p,w]}),n[14]=p,n[15]=w,n[16]=S):S=n[16],S}),Hy=c.memo(function(e){const n=nt.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:m,remoteUpdateChecking:f,remoteUpdateError:g,onOpenRemoteUpdate:x}=e,{t:b}=At();let j;n[0]!==d||n[1]!==a?(j=K=>{a(K),K&&d()},n[0]=d,n[1]=a,n[2]=j):j=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 h=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==h?(p=Ie($r,h),n[7]=h,n[8]=p):p=n[8];let w;n[9]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(B,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=w):w=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 N;n[13]!==y||n[14]!==p||n[15]!==S?(N=s.jsx(St,{asChild:!0,children:s.jsx(Ss,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:p,children:[w,S]})})}),n[13]=y,n[14]=p,n[15]=S,n[16]=N):N=n[16];let P;n[17]!==i||n[18]!==u||n[19]!==b?(P=b("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=b,n[20]=P):P=n[20];let C;n[21]!==P?(C=s.jsx(jt,{children:s.jsx("p",{children:P})}),n[21]=P,n[22]=C):C=n[22];let T;n[23]!==N||n[24]!==C?(T=s.jsxs(vt,{children:[N,C]}),n[23]=N,n[24]=C,n[25]=T):T=n[25];let O;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==x||n[30]!==f||n[31]!==g||n[32]!==m||n[33]!==a||n[34]!==b?(O=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:m?.available?b("header.services.remoteUpdate.available",{version:m.version||""}):f?b("header.services.remoteUpdate.checking"):g||b("header.services.remoteUpdate.upToDate")})]}),m?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:x,children:b("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx($p,{embedded:!0,open:l,onOpenChange:qy,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=x,n[30]=f,n[31]=g,n[32]=m,n[33]=a,n[34]=b,n[35]=O):O=n[35];let M;n[36]!==O?(M=s.jsx(js,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:O}),n[36]=O,n[37]=M):M=n[37];let F;return n[38]!==l||n[39]!==j||n[40]!==T||n[41]!==M?(F=s.jsxs(ks,{open:l,onOpenChange:j,children:[T,M]}),n[38]=l,n[39]=j,n[40]=T,n[41]=M,n[42]=F):F=n[42],F}),on=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},nc=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,Gy=()=>{ws("ui.header.render");const{t}=At(),e=ye(z=>z.isSidebarOpen),n=ye(z=>z.openContextOverview),r=ye(z=>z.closeContextPanel),i=ye(z=>z.shortcutOverrides),o=ye(z=>z.sessionTabsEnabled),l=rt(z=>z.getContextUsage),a=rt(z=>!!z.newSessionDraft?.open),d=rt(z=>z.currentSessionId),u=zp(d??""),m=Wp(d??""),f=ff(d??""),g=gs(Un(c.useCallback(z=>{if(!d)return null;const Ee=[...z.activeSessions,...z.archivedSessions].find(wt=>wt.id===d);if(!Ee)return null;const tt=Ee;return{title:Ee.title??null,directory:tt.directory??null,created:Ee.time?.created??null,slug:tt.slug??null,parentId:Ee.parentID??null}},[d]))),x=Kt(Un(z=>{if(!z.activeProjectId)return null;const Ee=z.projects.find(tt=>tt.id===z.activeProjectId);return Ee?{id:Ee.id,path:Ee.path,label:Ee.label}:null})),b=c.useMemo(()=>{if(!x)return null;const z=x.label?.trim();if(z)return z;const Ee=x.path.split(/[\\/]/).filter(Boolean);return Ee[Ee.length-1]??null},[x]),j=ur(z=>z.loadSettings),{isMobile:y}=Dn(),h=c.useRef(null),[p,w]=c.useState(()=>typeof window>"u"?!1:hn()),S=c.useMemo(()=>Kr(),[]),N=Kp(),[P,C]=c.useState(!1),T=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:O,side:M}=Qu(),F=c.useMemo(()=>{if(typeof window>"u")return null;const z=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof z=="number"&&Number.isFinite(z)&&z>0)return z;if(typeof navigator>"u")return null;const Ee=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Ee)return null;const tt=Number.parseInt(Ee[1],10),wt=Number.parseInt(Ee[2],10);return Number.isNaN(tt)?null:tt===10?wt:tt},[]);at.useEffect(()=>{typeof window>"u"||w(hn())},[]);const{context:K,output:D}=Vp(d),U=l(K,D),[A,E]=c.useState(null),W=!d||u;at.useEffect(()=>{if(!d){E(z=>z===null?z:null);return}if(U){E(z=>Up(z,U)?z:U);return}W&&E(z=>z===null?z:null)},[U,d,W]);const[k,v]=c.useState(!1),[I,H]=c.useState("Local"),[_,se]=c.useState(!0),[te,ee]=c.useState(!1),[ue,de]=c.useState(null),[Re,we]=c.useState(!1),[fe,Pe]=c.useState(null),L=c.useMemo(()=>Pn(),[]),oe=ye(z=>z.workStatusPanelVisible),ce=ye(z=>z.workStatusPanelEnabled),he=ye(z=>z.setWorkStatusPanelEnabled),Y=ye(z=>z.workStatusPanelFits),ve=ye(z=>z.workStatusOverlayOpen),Te=ye(z=>z.setWorkStatusOverlayOpen),xe=ce&&Y||ve,ge=c.useCallback(()=>{if(ce&&!Y){Te(!ve);return}he(!ce)},[Te,he,ve,ce,Y]),Q=!L&&!oe&&!!A,$=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(Yo()){H("Local"),se(!0);return}se(!1);const z=await Ld(),Ee=Ym(),tt=Qm([Xm(Ee),...z.hosts]);if(tt.id===Jm){H("Local"),se(!0);return}H(_d(tt.label.trim()||"Instance"))}catch{H("Local"),se(!0)}},[p]);at.useEffect(()=>($(),vr(()=>{$()})),[$]);const J=c.useCallback(async()=>{if(_){de(null),Pe(null);return}we(!0),Pe(null);try{const z=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Ee=await ls(`/api/openchamber/update-check?${z.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Ee.ok)throw new Error(`Server responded with ${Ee.status}`);const tt=await Ee.json();de({available:tt.available??!1,version:tt.version,currentVersion:tt.currentVersion??"unknown",body:tt.body,nextSuggestedCheckInSec:typeof tt.nextSuggestedCheckInSec=="number"?tt.nextSuggestedCheckInSec:void 0,packageManager:tt.packageManager,updateCommand:tt.updateCommand})}catch(z){de(null),Pe(z instanceof Error?z.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[_,t]);c.useEffect(()=>{de(null),Pe(null),ee(!1)},[_,I]),c.useEffect(()=>{if(!p||_)return;const z=3e3,Ee=3600*1e3;let tt=!1,wt=null;const Pt=Nt=>{wt=window.setTimeout(()=>{if(tt||typeof document<"u"&&document.visibilityState!=="visible"){Pt(Ee);return}J().finally(()=>{tt||Pt(Ee)})},Nt)};return Pt(z),()=>{tt=!0,wt!==null&&window.clearTimeout(wt)}},[J,_,I,p]);const me=c.useCallback(()=>{if(ue?.available){ee(!0);return}J()},[J,ue?.available]);Hp(),c.useEffect(()=>{j()},[j]);const le=d?g??null:null,V=c.useRef(null),[Z,G]=c.useState(0);c.useEffect(()=>{if(!d){V.current&&(V.current=null,G(wt=>wt+1));return}if(le){V.current={sessionId:d,session:le,expiresAt:Date.now()+2e3};return}const z=V.current;if(!z||z.sessionId!==d)return;const Ee=z.expiresAt-Date.now();if(Ee<=0){V.current=null,G(wt=>wt+1);return}const tt=window.setTimeout(()=>{V.current?.sessionId===d&&(V.current=null),G(wt=>wt+1)},Ee);return()=>{window.clearTimeout(tt)}},[d,le]);const ie=(()=>{if(le)return le;if(!d)return null;const z=V.current;return z&&z.sessionId===d&&z.expiresAt>Date.now()?z.session:null})(),je=rt(z=>d?z.worktreeMetadata.get(d)?.path??"":""),ne=rt(z=>d?z.worktreeMetadata.get(d)?.branch?.trim()??null:null),Oe=mu(z=>d?z.getAttachment(d):void 0),Ve=c.useMemo(()=>Oe?Gp(Oe,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Oe]),ze=c.useMemo(()=>Oe?Oe.legacy?"legacy":Oe.degraded?"degraded":Oe.worktreeStatus==="pending"?"pending":Oe.worktreeStatus==="missing"?"missing":Oe.worktreeStatus==="invalid"?"invalid":Oe.attentionReason?"attention":null:null,[Oe]),He=c.useMemo(()=>on(je||""),[je]),$e=c.useMemo(()=>{const z=typeof ie?.directory=="string"?ie.directory:"";return on(z||"")},[ie?.directory]),R=Ia(d??"",$e),pe=rt(z=>z.newSessionDraft?.open?on(z.newSessionDraft.bootstrapPendingDirectory??z.newSessionDraft.directoryOverride??""):""),Le=rt(z=>z.newSessionDraft.target),_e=rt(z=>z.newSessionDraft.selectedProjectId),lt=rt(z=>z.currentSessionDirectory),ht=ts(z=>z.homeDirectory),ot=c.useMemo(()=>He||$e||pe,[pe,$e,He]),ut=ye(c.useCallback(z=>{const Ee=on(ot||"");return Ee?nc(z.contextPanelByDirectory[Ee]):null},[ot])),yt=rt(z=>{const Ee=on(He||$e||"");if(!Ee)return null;for(const tt of z.availableWorktreesByProject.values()){const Pt=tt.find(Nt=>on(Nt.path)===Ee)?.branch?.trim();if(Pt)return Pt}return null}),xt=qp(ot||null)||ne||yt,Dt=a?Le==="chat":Yp($e||lt,ht),be=!Dt&&!oe&&!!(b||xt||!a&&ze),qe=c.useMemo(()=>{if(!d)return b??"OpenChamber";const z=ie?.title?.trim();return z&&z.length>0?z:"Untitled Session"},[b,ie?.title,d]),Ye=hu(),Ue=rt(z=>z.updateSessionTitle),ct=rt(z=>z.archiveSessions),X=rt(z=>z.deleteSessions),[ae,De]=c.useState(!1),[Ke,q]=c.useState(!1),Be=c.useRef(null),[Ze,Qe]=c.useState(""),[et,Ct]=c.useState(null),Ge=c.useRef(null),Tt=c.useCallback(()=>{d&&(Qe(ie?.title?.trim()||qe),De(!0))},[ie?.title,d,qe]),Bt=c.useRef(Tt);Bt.current=Tt;const Ce=c.useCallback(z=>{z&&(z.focus(),z.select())},[]);c.useEffect(()=>{if(q(!1),Ct(null),d&&Be.current===d){Be.current=null,Bt.current();return}De(!1),Qe("")},[d]);const Me=c.useCallback(async()=>{if(!d)return;const z=Ze.trim();z&&z!==ie?.title?.trim()&&await Ue(d,z),De(!1)},[ie?.title,d,Ze,Ue]);c.useEffect(()=>{if(!ae)return;const z=Ee=>{const tt=Ee.target;(!tt||!Ge.current?.contains(tt))&&Me()};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[ae,Me]);const st=c.useCallback(z=>{z&&Gn(z).then(Ee=>{Fe[Ee.ok?"success":"error"](t(Ee.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Fe.error(t("sessions.sidebar.session.copyId.error")))},[t]),Xe=c.useCallback(async()=>{if(!d||!ot){Fe.error(t("sessions.sidebar.session.export.nothingToExport"));return}const z=await Ye({sessionID:d,directory:ot}).catch(()=>null);if(!z){Fe.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}if(z.length===0){Fe.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Ee=pu(z,ie?.title??null),tt=gu(ie?.title??null);await bu(Ee,tt)||xu(Ee,tt),Fe.success(t("sessions.sidebar.session.export.success"))},[ie?.title,d,Ye,ot,t]),Ne=yu(),We=c.useMemo(()=>wu(Ne),[Ne]),dt=c.useCallback(z=>{d&&df({entry:z,t,session:{id:d,title:ie?.title,directory:$e??ot},loadRecords:async()=>{if(!ot)return null;try{return await Ye({sessionID:d,directory:ot})}catch{return null}},onLoadFailed:()=>Fe.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ie?.title,d,Ye,ot,$e,t]),bt=c.useCallback(z=>We.map(Ee=>s.jsxs(z,{onClick:()=>dt(Ee),children:[s.jsx(Qr,{icon:Ee.icon,iconSrc:Ee.iconSrc,className:"mr-1 size-4"}),Ee.action.label]},`${Ee.guest.id}:${Ee.action.id}`)),[We,dt]),Se=m?.type==="busy"||m?.type==="retry",Je=c.useCallback(()=>{if(!d||!$e||Se||f)return;const z=gs.getState().activeSessions,Ee=z.find(Pt=>Pt.id===d);if(!Ee)return;const tt=[],wt=[d];for(let Pt=0;Pt<wt.length;Pt+=1){const Nt=wt[Pt];for(const $t of z)$t.parentID===Nt&&(tt.push($t),wt.push($t.id))}oa({kind:"quick",root:Ee,descendants:tt,sourceDirectory:$e,messages:ra(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,Se,f,$e,t]),it=c.useCallback(async()=>{if(!et)return;const z=et.action,Ee=[et.sessionId,...Hd(et.sessionId,[],z==="delete")];if(Ct(null),(z==="archive"?await ct(Ee):await X(Ee)).failedIds.length>0){Fe.error(t(z==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Fe.success(t(z==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[ct,X,et,t]),pt=ye(z=>z.openGuestPageId),kt=Ea(z=>z.guests.find(Ee=>Ee.id===pt)),_t=ye(z=>z.isScheduledTasksDialogOpen),qt=ye(z=>z.isArchivePageOpen),Mt=ye(z=>z.isUsageStatsPageOpen),Lt=ye(z=>z.worktreesPageProjectId),Wt=ye(z=>z.runOverviewKey),Jt=Rh(Wt),Zt=Kt(z=>{if(!Lt)return null;const Ee=z.projects.find(tt=>tt.id===Lt);return Ee?.label?.trim()||Ee?.path?.split("/").pop()||null}),Ft=c.useMemo(()=>kt?{title:kt.pageTitle??kt.name,subtitle:null}:_t?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:qt?{title:t("sessions.archivePage.title"),subtitle:null}:Mt?{title:t("usageStats.title"),subtitle:null}:Lt?{title:t("sessions.worktreesPage.title",{project:Zt??""}),subtitle:null}:Wt?{title:Jt??t("multirun.overview.headerTitle"),subtitle:t("multirun.overview.headerTitle")}:null,[kt,qt,Jt,Wt,_t,Mt,t,Lt,Zt]),Ot=c.useMemo(()=>on(ot||x?.path||""),[x?.path,ot]),It=wy(),ss=Ra(z=>z.planModeEnabled),yn=rt(z=>z.isSessionPlanAvailable),fs=ss&&d?yn(d):!1,Gs=c.useRef("");c.useEffect(()=>{if(!ss||!d)return;const z=`${d||"none"}:${$e||"none"}:${ie?.created||0}:${ie?.slug||"none"}`;Gs.current!==z&&(Gs.current=z)},[ss,fs,ie?.slug,ie?.created,d,$e]);const bs=c.useCallback(()=>{An("desktop_open_draft_mini_chat_window",{directory:Dt?"":pe,projectId:Dt?null:_e,apiBaseUrl:pn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open draft mini chat window",z)})},[pe,_e,Dt]),wn=c.useCallback(()=>{if(a){bs();return}d&&An("desktop_open_session_mini_chat_window",{sessionId:d,directory:$e||on(lt||"")||He,apiBaseUrl:pn(),clientToken:Vr()}).catch(z=>{console.warn("[header] failed to open session mini chat window",z)})},[d,bs,a,lt,$e,He]),qs=c.useCallback(()=>{const z=on(ot||"");if(!z)return;const Ee=ye.getState().contextPanelByDirectory[z];if(nc(Ee)==="context"){r(z);return}n(z)},[r,n,ot]),Tn=ut==="context",$s=$r,sn=c.useMemo(()=>p&&T&&!P?"88px":N?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||O)&&!L?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,P,T,N,L,O]);at.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",sn)},[sn]);const xs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Zn=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";at.useEffect(()=>{if(!p||!T){C(!1);return}let z=!1;const Ee=async()=>{try{const wt=await An("desktop_is_window_fullscreen");z||C(wt===!0)}catch{z||C(!1)}},tt=()=>{Ee()};return Ee(),window.addEventListener("openchamber:window-resized",tt),()=>{z=!0,window.removeEventListener("openchamber:window-resized",tt)}},[p,T]);const er=c.useMemo(()=>!p||!T||F===null?"":F>=26?"h-12":F<=15?"h-14":"",[p,T,F]),zs=c.useMemo(()=>{if(!(p&&!O||L)&&!(O&&M==="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))"}},[p,L,O,M]),Ts=c.useCallback(()=>{if(typeof document>"u")return;const z=h.current?.getBoundingClientRect().height;z&&document.documentElement.style.setProperty("--oc-header-height",`${z}px`)},[]);at.useEffect(()=>{if(typeof window>"u")return;Ts();const z=h.current;if(!z||typeof ResizeObserver>"u")return()=>{};let Ee=0;const tt=()=>{Ee||(Ee=requestAnimationFrame(()=>{Ee=0,Ts()}))},wt=new ResizeObserver(tt);return wt.observe(z),window.addEventListener("resize",tt),window.addEventListener("orientationchange",tt),()=>{Ee&&cancelAnimationFrame(Ee),wt.disconnect(),window.removeEventListener("resize",tt),window.removeEventListener("orientationchange",tt)}},[Ts]),at.useEffect(()=>{Ts()},[Ts,y,er]);const tr=c.useCallback(async z=>{const Ee=z.target;Ee.closest(".app-region-no-drag")||Ee.closest("button, a, input, select, textarea")||z.button===0&&p&&await Zm()},[p]),nn=c.useCallback(z=>zn(Xr(z,i)),[i]);Qp({rename_current_session:()=>{if(!d||y)return!1;Tt()},toggle_services_menu:()=>{if(k){v(!1);return}v(!0),$()}});const sr=s.jsxs(s.Fragment,{children:[It?s.jsx(xy,{projectRef:It.projectRef,directory:It.directory,className:"mr-2"}):null,s.jsx(Mh,{directory:ot,className:Ie($r,"mr-1 text-muted-foreground hover:text-foreground"),iconClassName:"h-[18px] w-[18px]"}),s.jsx(Hx,{directory:Ot,className:"mr-1"}),p?s.jsx(Hy,{isDesktopApp:p,currentInstanceLabel:I,currentInstanceIsLocal:_,isDesktopServicesOpen:k,setIsDesktopServicesOpen:v,refreshCurrentInstanceLabel:$,shortcutLabel:nn,remoteUpdateInfo:ue,remoteUpdateChecking:Re,remoteUpdateError:fe,onOpenRemoteUpdate:me}):null]}),nr=S&&(a||!!d),eo=c.useCallback(({session:z,open:Ee,isActive:tt,select:wt,closeOtherTabs:Pt,components:Nt})=>{const{Item:$t,Separator:os}=Nt,Xt=tt&&!L&&!Dt&&ie&&!ie.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs($t,{onClick:()=>{tt||wt(),Be.current=z.id},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(na,{sessionID:z.id,directory:z.directory,open:Ee,Item:$t}),s.jsxs($t,{onClick:()=>st(z.id),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(os,{}),tt?s.jsxs($t,{onClick:()=>{Xe()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,tt?bt($t):null,Xt?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs($t,{disabled:!$e||Se||f,onClick:Je,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Se?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(os,{}),s.jsxs($t,{onClick:Pt,children:[s.jsx(B,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(os,{}),s.jsx(Jl,{sessionId:z.id,Item:$t,onArchive:()=>Ct({action:"archive",sessionId:z.id})}),s.jsxs($t,{className:"text-destructive focus:text-destructive",onClick:()=>Ct({action:"delete",sessionId:z.id}),children:[s.jsx(B,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[st,ie,Xe,Dt,Se,f,L,Je,bt,$e,t]),to=()=>s.jsxs("div",{onMouseDown:tr,className:Ie("app-region-drag relative flex h-12 select-none items-center",O&&M==="right"?"pr-0":"pr-3",er),style:zs,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:xs}}),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:Zn}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[Ft?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>ye.getState().closeMainSurfaces(),children:s.jsx(B,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(jt,{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:Ft.title}),Ft.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:Ft.subtitle}):null]})]}):L||!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:[R?s.jsx(B,{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(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[ae?s.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Me()},children:[s.jsx("input",{ref:Ce,value:Ze,onChange:z=>Qe(z.target.value),onKeyDown:z=>zi(z,()=>De(!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(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(B,{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:qe}),be?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[b?s.jsx("span",{className:"truncate",children:b}):null,xt?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:xt})]}):null,!a&&ze?s.jsxs("span",{className:Ie("inline-flex min-w-0 items-center gap-0.5",ze==="attention"||ze==="invalid"||ze==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(B,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Ve})]}):null]}):null]}),s.jsx("div",{className:Ie("flex h-[18px] shrink-0 items-center justify-center",be?"self-start":"self-center"),children:d&&!a&&!ae?s.jsxs(ks,{open:Ke,onOpenChange:q,onOpenChangeComplete:z=>{!z&&Be.current&&Be.current===d&&(Be.current=null,Tt())},children:[s.jsx(Ss,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(B,{name:"more",className:"size-4"})})}),s.jsxs(js,{align:"end",className:"min-w-[190px]",children:[s.jsxs(zt,{onClick:()=>{Be.current=d},children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(na,{sessionID:d,directory:$e,open:Ke,Item:zt}),s.jsxs(zt,{onClick:()=>d&&st(d),children:[s.jsx(B,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(ps,{}),s.jsxs(zt,{onClick:()=>{Xe()},children:[s.jsx(B,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),bt(zt),!L&&!Dt&&ie&&!ie.parentId?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(zt,{disabled:!$e||Se||f,onClick:Je,className:"w-full",children:[s.jsx(B,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(jt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":Se?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(ps,{}),s.jsx(Jl,{sessionId:d,Item:zt,onArchive:()=>Ct({action:"archive",sessionId:d})}),s.jsxs(zt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&Ct({action:"delete",sessionId:d})},children:[s.jsx(B,{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(Hl,{align:"start",children:s.jsx("button",{type:"button",className:$s,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(B,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Cy,{renderMenu:eo,suppressActiveTabControls:ae,onMenuOpenChangeComplete:z=>{!z&&Be.current&&Be.current===d&&(Be.current=null,Tt())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:ae?s.jsxs("form",{ref:Ge,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:z=>z.stopPropagation(),onSubmit:z=>{z.preventDefault(),Me()},children:[s.jsx("input",{ref:Ce,value:Ze,onChange:z=>Qe(z.target.value),onKeyDown:z=>zi(z,()=>De(!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(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>De(!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(B,{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"):qe})})})]}),Ft||L||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Q&&A?s.jsx(ux,{reading:fx(A),contextLimit:A.contextLimit,outputLimit:A.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:qs,pressed:Tn,className:nr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(Uy,{visible:nr,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:wn,className:Ie($s,"mr-1"),Icon:"picture-in-picture-2"}),L?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":xe,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:ge,className:Ie($r,"mr-1",xe?"text-foreground":"text-muted-foreground/50"),children:s.jsx(B,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{side:"bottom",children:t(ce&&!Y?ve?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":ce?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),sr,s.jsx(Xu,{visible:O&&M==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:h,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:to()}),s.jsx(Cs,{open:et!==null,onOpenChange:z=>{z||Ct(null)},children:s.jsxs(Ns,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ls,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(_s,{children:et?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:qe}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:qe})})]}),s.jsxs(Qn,{children:[s.jsx(ft,{variant:"outline",size:"sm",onClick:()=>Ct(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{it()},children:et?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Gd,{open:te,onOpenChange:ee,info:ue,downloading:!1,downloaded:!1,progress:null,error:fe,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function qy(){}const rc=280,oc=264,ic=500,Yy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=At(),l=ye(C=>C.sidebarWidth),a=ye(C=>C.setSidebarWidth),[d,u]=c.useState(!1),m=c.useRef(0),f=c.useRef(l||rc),g=c.useRef(null),x=c.useRef(null),b=c.useRef(null),j=c.useCallback(C=>Math.min(ic,Math.max(oc,C)),[]),y=c.useCallback(C=>{const T=b.current;T&&(T.style.width=`${C}px`,T.style.minWidth=`${C}px`,T.style.maxWidth=`${C}px`,T.style.setProperty("--oc-left-sidebar-width",`${C}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(g.current=null,x.current=null)},[d]),e)return null;const h=Math.min(ic,Math.max(oc,l||rc)),p=t?h:0,w=C=>{if(t){try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}x.current=C.pointerId,u(!0),m.current=C.clientX,f.current=p,g.current=p,y(p),C.preventDefault()}},S=C=>{if(e||!d||x.current!==C.pointerId)return;const T=C.clientX-m.current,O=j(f.current+T);g.current!==O&&(g.current=O,y(O))},N=C=>{if(x.current!==C.pointerId||e)return;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}const T=j(g.current??p);x.current=null,g.current=null,u(!1),a(T)},P=d?g.current??p:p;return s.jsxs("aside",{ref:b,className:Ie("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:`${P}px`,minWidth:`${P}px`,maxWidth:`${P}px`,"--oc-left-sidebar-width":`${d?P:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===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:Ie("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:w,onPointerMove:S,onPointerUp:N,onPointerCancel:N,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Ie("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(xn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(hs,{children:n})})]})]})},Qy=()=>{const t=nt.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",Xy=()=>{const t=nt.c(37),{t:e}=At(),n=ye(Jy),r=ye(Zy),i=ye(e1),o=c.useRef(null),l=zn(Xr("toggle_sidebar",i)),a=t1,{usesFramelessChrome:d,side:u}=Qu(),m=n1;let f,g;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const A=o.current;if(!A)return;const E=()=>{const k=Math.max(A.getBoundingClientRect().width,A.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(k)}px`)};if(E(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(E);return W.observe(A),()=>{W.disconnect()}},g=[],t[0]=f,t[1]=g):(f=t[0],g=t[1]),c.useEffect(f,g);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 j="flex items-center gap-2";let y;t[3]!==d||t[4]!==u?(y=d&&u==="left"?s.jsx(Xu,{visible:!0,position:"left"}):null,t[3]=d,t[4]=u,t[5]=y):y=t[5];let h;t[6]!==e||t[7]!==d?(h=d?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Ie(io,"shrink-0"),children:s.jsx(B,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=d,t[8]=h):h=t[8];const p=vt;let w;t[9]!==e?(w=e("header.actions.openSessionsAria"),t[9]=e,t[10]=w):w=t[10];let S,N;t[11]===Symbol.for("react.memo_cache_sentinel")?(S=Ie(io,"shrink-0"),N=s.jsx(B,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=S,t[12]=N):(S=t[11],N=t[12]);let P;t[13]!==w||t[14]!==n?(P=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":w,className:S,children:N})}),t[13]=w,t[14]=n,t[15]=P):P=t[15];const C=jt,T=e("header.actions.openSessionsWithShortcut",{shortcut:l});let O;t[16]!==T?(O=s.jsx("p",{children:T}),t[16]=T,t[17]=O):O=t[17];let M;t[18]!==C||t[19]!==O?(M=s.jsx(C,{children:O}),t[18]=C,t[19]=O,t[20]=M):M=t[20];let F;t[21]!==p||t[22]!==P||t[23]!==M?(F=s.jsxs(p,{children:[P,M]}),t[21]=p,t[22]=P,t[23]=M,t[24]=F):F=t[24];let K;t[25]!==a||t[26]!==r||t[27]!==e?(K=r?s.jsxs("button",{type:"button",onClick:a,className:Ie(io,"-ml-1 w-auto shrink-0 px-2 font-normal"),children:[s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.header.actions.newSession")})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,"aria-label":e("sessions.sidebar.header.actions.newSession"),className:Ie(io,"-ml-1 shrink-0"),children:s.jsx(B,{name:"chat-new",className:"h-[18px] w-[18px]"})})}),s.jsx(jt,{children:s.jsx("p",{children:e("sessions.sidebar.header.actions.newSession")})})]}),t[25]=a,t[26]=r,t[27]=e,t[28]=K):K=t[28];let D;t[29]!==F||t[30]!==K||t[31]!==y||t[32]!==h?(D=s.jsxs("div",{ref:o,className:j,children:[y,h,F,K]}),t[29]=F,t[30]=K,t[31]=y,t[32]=h,t[33]=D):D=t[33];let U;return t[34]!==D||t[35]!==b?(U=s.jsx("div",{className:x,style:b,children:D}),t[34]=D,t[35]=b,t[36]=U):U=t[36],U};function Jy(t){return t.toggleSidebar}function Zy(t){return t.isSidebarOpen}function e1(t){return t.shortcutOverrides}function t1(){ye.getState().closeMainSurfaces(),rt.getState().openNewSessionDraft()}function s1(t){console.warn("[titlebar] failed to open app menu",t)}function n1(t){const e=t.currentTarget.getBoundingClientRect();An("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(s1)}function hf(t){const e=nt.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(B,{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 ac=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function r1(t,e,n){const r=nt.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Xp(t),Jp(t)]).catch(o1);if(d)return;const f=ac(u),g=ac(m);if(!f||!g||g===f)return;const x=n||"",b=g.split("/").filter(Boolean).pop()||g;o({source:"sdk",path:g,projectDirectory:f,branch:x,label:x||b,name:b,worktreeRoot:g,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 o1(){return["",""]}const lc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",i1=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},cc=({className:t})=>{const{t:e}=At(),{github:n}=bn(),r=gn(x=>x.status),i=gn(x=>x.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async x=>{if(!(!x||o)){l(!0);try{i(await i1(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,m=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),g=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(B,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return m.length<=1?s.jsx("div",{className:Ie(lc,t),title:f,children:g}):s.jsxs(ks,{children:[s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(lc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:g})}),s.jsxs(js,{align:"end",className:"w-64",children:[s.jsx(cr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(ps,{}),m.map(x=>{const b=x.user,j=!!x.current,y=x.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(zt,{className:"gap-2",disabled:o,onSelect:()=>{j||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(B,{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]}),j?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},x.id)})]})]})};class li 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 ci="/api/walkthrough",pf=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),gf=()=>new li("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),a1=t=>!pf(t)&&(t.ok||t.status===404),qa=async(t,e)=>{if(a1(t))throw gf();const n=await t.json().catch(()=>null);throw new li(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(!pf(t))throw gf();try{return await t.json()}catch{throw new li("The server returned a malformed walkthrough response")}};async function l1(t,e,n={}){const r=await ls(ci,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.providerID?{providerID:n.providerID}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?bf(r):qa(r,"Failed to load walkthrough")}async function c1(t,e,n={}){const r=await ls(`${ci}/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.providerID?{providerID:n.providerID}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?bf(r):qa(r,"Failed to generate walkthrough")}async function d1(t,e){const n=await ls(`${ci}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await qa(n,"Failed to cancel walkthrough generation")}async function u1(t,e,n){const r=await ls(`${ci}/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 Nr={status:"idle",stage:null,result:null,readiness:null,error:null},f1=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}`,vn=(t,e)=>`${Yt()}\0${t}\0${f1(e)}`,dc=t=>t instanceof li?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Ms=new Map,Ar=new Map,m1=1e3,h1=Jr()(Ex((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=vn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[vn(n,r)],selectModel:(n,r,i)=>{const o=vn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[vn(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[vn(n,r)]??Nr,load:async(n,r,i={})=>{if(!n)return;const o=vn(n,r);if(e().entries[o]?.status==="generating")return;Ms.get(o)?.abort();const a=new AbortController;Ms.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"loading",error:null}}}));try{const d=await l1(n,r,{model:e().selectedModel[o],providerID:i.providerID,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,providerID:i.providerID})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{Ms.get(o)===a&&Ms.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=vn(n,r);Ms.get(o)?.abort();const l=new AbortController;Ms.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Nr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Ar.get(o);d!==void 0&&(clearInterval(d),Ar.delete(o))};a(),Ar.set(o,setInterval(()=>{u1(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const m=u.entries[o];return!m||m.status!=="generating"||m.stage===d?u:{entries:{...u.entries,[o]:{...m,stage:d}}}})}).catch(()=>{})},m1));try{const d=await c1(n,r,{force:i.force,model:e().selectedModel[o],providerID:i.providerID,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]??Nr,status:"error",stage:null,error:dc(d)}}}))}finally{a(),Ms.get(o)===l&&Ms.delete(o)}},cancel:(n,r)=>{const i=vn(n,r);d1(n,r).catch(()=>{}),Ms.get(i)?.abort(),Ms.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 Ms.values())n.abort();Ms.clear();for(const n of Ar.values())clearInterval(n);Ar.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),p1="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)]",g1=3e4,uc=20,xf=(t,e)=>JSON.stringify([Yt(),t,e]),b1=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}},fc=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ao=new Map,x1=t=>{const e=Object.entries(t);return e.length<=uc?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,uc))},mc=Jr()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=xf(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<g1&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const m=`${l}::${a?"details":"plain"}`,g=ao.get(`${l}::details`)??(a?null:ao.get(m));if(g&&!o?.force)return g;const x=(async()=>{t(b=>({entries:{...b.entries,[l]:{...b.entries[l]??fc(),isLoading:!0,error:null}}}));try{const b=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(j=>({entries:x1({...j.entries,[l]:{result:b,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),b}catch(b){const j=b instanceof Error?b.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??fc(),isLoading:!1,error:j}}})),null}finally{ao.delete(m)}})();return ao.set(m,x),x},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=b1(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),y1=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}:{}}},w1=35e3,Ni=(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`},Ai=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},hc=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"}},v1=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"},S1=[2e3,5e3],j1=600,pc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),jn=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):""},k1=(t,e)=>{const n=jn(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}`,Ya=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},Pi=(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=Ya(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)},N1=t=>t.startsWith("pr-"),A1=(t,e)=>{const n=Ya(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=>!N1(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Pr=new Map,lo=Yr;function P1(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 D1=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=At(),d=ye(re=>re.timeFormatPreference),{github:u}=bn(),m=gn(re=>re.status),f=gn(re=>re.hasChecked),g=ye(re=>re.setSettingsDialogOpen),x=ye(re=>re.setSettingsPage),b=rt(re=>re.currentSessionId),j=rt(re=>!!re.newSessionDraft?.open),{isMobile:y,hasTouchInput:h,screenWidth:p}=Dn(),w=ye(re=>re.openContextSurface),S=h1(re=>re.requestSource),N=!y&&p>=768&&!Pn(),P=c.useCallback(()=>{x("integrations"),g(!0)},[g,x]),C=c.useMemo(()=>C1(t,e),[t,e]),T=c.useMemo(()=>Pr.get(C)??null,[C]),O=Ps(re=>re.ensureEntry),M=Ps(re=>re.setParams),F=Ps(re=>re.startWatching),K=Ps(re=>re.stopWatching),D=Ps(re=>re.refresh),U=Ps(re=>re.updateStatus),[A,E]=c.useState(()=>T?.title??pc(e)),[W,k]=c.useState(()=>T?.body??""),[v,I]=c.useState(()=>T?.draft??!1),[H,_]=c.useState(()=>T?.additionalContext??""),[se,te]=c.useState(()=>{const re=typeof T?.targetBaseBranch=="string"?jn(T.targetBaseBranch):"";return re||jn(n)}),[ee,ue]=c.useState("squash"),[de,Re]=c.useState(!1),[we,fe]=c.useState(!1),[Pe,L]=c.useState(!1),[oe,ce]=c.useState(!1),[he,Y]=c.useState(!1),[ve,Te]=c.useState(!1),[ke,xe]=c.useState(null),[ge,Q]=c.useState(""),[$,J]=c.useState(""),[me,le]=c.useState(!1),[V,Z]=c.useState(!1),[G,ie]=c.useState(()=>Pi(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r})),[je,ne]=c.useState(!1),{detectedUpstream:Oe,upstreamBranches:Ve}=P1(t,u);c.useEffect(()=>{ne(!1)},[t]);const ze=i.some(re=>re.name==="upstream"),$e=!!(t&&e&&n&&(e!==n||(ze||Oe!==null))),R=c.useMemo(()=>Qo(t,e,G?.name??null),[t,e,G?.name]),pe=Ps(re=>re.entries[R]),Le=pe?.isLoading??!1,_e=pe?.status??null,lt=pe?.error??null,ht=pe?.isInitialStatusResolved??!1,ot=c.useMemo(()=>{const re=je?null:G?.name?.trim()||null,z=new Set;for(const wt of o){const Pt=k1(wt,re);!Pt||Pt==="HEAD"||z.add(Pt)}if(je)for(const wt of Ve)wt&&wt!=="HEAD"&&z.add(wt);const Ee=jn(n);Ee&&Ee!=="HEAD"&&z.add(Ee);const tt=jn(se);return tt&&tt!=="HEAD"&&z.add(tt),Array.from(z).sort((wt,Pt)=>wt.localeCompare(Pt))},[n,o,G?.name,se,Ve,je]);c.useEffect(()=>{if(i.length===0){G&&ie(null);return}(!G||!i.some(re=>re.name===G.name))&&ie(Pi(i,{selectedRemoteName:T?.selectedRemoteName,trackingBranch:r}))},[T?.selectedRemoteName,i,G,r]),c.useEffect(()=>{const re=jn(n);if(!se&&re){te(re);return}if(ot.length!==0&&!ot.includes(se)){const z=ot.includes(re)?re:ot[0];z&&te(z)}},[ot,n,se]);const[ut,yt]=c.useState(()=>T?.activeSegment??"overview"),[mt,xt]=c.useState(new Set),[Dt,be]=c.useState(new Set),qe=c.useRef(new Set),Ye=c.useRef(null),Ue=c.useRef(!1),ct=c.useRef(new Set),X=c.useRef([]);c.useEffect(()=>{Oe&&!ze&&ne(!0)},[Oe,ze]),c.useEffect(()=>{je&&Oe?.defaultBranch&&te(Oe.defaultBranch)},[je,Oe?.defaultBranch]);const ae=_e?.pr??null,De=ae?.state==="merged"||ae?.state==="closed",Ke=De?null:ae,q=Ke?xf(t,Ke.number):null,Be=mc(re=>q?re.entries[q]:void 0),Ze=mc(re=>re.ensure),Qe=Be?.result??null,et=Be?.isLoading??!1,Ct=c.useCallback(re=>{yt(re);const z=Pr.get(C);z&&Pr.set(C,{...z,activeSegment:re})},[C]);c.useEffect(()=>{!Ke||!u?.prContext||ut==="overview"||Ze(u,t,Ke.number,{includeCheckDetails:ut==="checks",sourceRepo:_e?.repo??null})},[ut,t,Ze,u,Ke,_e?.repo]);const Ge=_e?.checks??null,Tt=(Ge?.pending??0)>0,Bt=Qe?.checkRuns??null,Ce=Qe?.fetchedAt;c.useEffect(()=>{if(!Bt||Bt.length===0)return;const re=y1(Bt);U(R,z=>{if(!z?.pr||typeof Ce=="number"&&typeof z.fetchedAt=="number"&&Ce<z.fetchedAt)return z;const Ee=z.checks;return Ee&&Ee.state===re.state&&Ee.total===re.total&&Ee.success===re.success&&Ee.failure===re.failure&&Ee.pending===re.pending&&Ee.inProgress===re.inProgress&&Ee.queued===re.queued&&Ee.startedAt===re.startedAt?z:{...z,checks:re,...typeof Ce=="number"?{fetchedAt:Ce}:{}}})},[Bt,Ce,R,U]),c.useEffect(()=>{if(ut!=="checks"||!Tt||!ae||!u?.prContext)return;const re=window.setInterval(()=>{Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null,force:!0})},w1);return()=>window.clearInterval(re)},[ut,Tt,t,Ze,u,ae,_e?.repo]);const[Me,st]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Tt)return;st(Date.now());const re=window.setInterval(()=>st(Date.now()),3e4);return()=>window.clearInterval(re)},[Tt]);const Xe=ae?`${t}#${ae.number}`:null,Ne=!!(Xe&&ke===Xe);c.useEffect(()=>{if(!u?.prContext||!ae||typeof ae.body=="string"&&ae.body.length>0)return;const re=`${t}#${ae.number}`;if(qe.current.has(re))return;qe.current.add(re),xe(re);let z=!1;return Ze(u,t,ae.number,{sourceRepo:_e?.repo??null}).then(Ee=>{if(z)return;const tt=Ee?.pr;tt&&U(R,wt=>!wt?.pr||wt.pr.number!==ae.number?wt:{...wt,pr:{...wt.pr,body:tt.body||""}})}).catch(()=>{}).finally(()=>{z||xe(Ee=>Ee===re?null:Ee)}),()=>{z=!0}},[t,Ze,u,ae,R,_e?.repo,U]),c.useEffect(()=>{if(!ae){Te(!1),Q(""),J(""),Ye.current=null;return}const re=Ye.current!==null&&Ye.current!==ae.number;re&&Te(!1),(!ve||re)&&(Q(ae.title||""),J(ae.body||"")),Ye.current=ae.number},[ve,ae]);const We=c.useCallback(re=>{if(!re)return"";const z=Date.parse(re);return Number.isFinite(z)?vu(z,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):re},[d]),dt=c.useMemo(()=>{const re=m?.user?.login;return typeof re=="string"?re.trim():""},[m]),bt=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)]",[]),Se=c.useCallback(re=>{const z=dt.toLowerCase(),Ee=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return re.replace(Ee,(tt,wt,Pt)=>{const Nt=`@${Pt}`,$t=Pt.toLowerCase();return`${wt}[${Nt}](https://github.com/${$t}${z&&$t===z?"?oc-self-mention=1":""})`})},[dt]),Je=c.useMemo(()=>{const re=(Qe?.issueComments??[]).map(tt=>({id:`issue-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),z=(Qe?.reviewComments??[]).map(tt=>({id:`review-${tt.id}`,body:tt.body||"",authorName:tt.author?.name||tt.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:tt.author?.login||null,avatarUrl:tt.author?.avatarUrl||null,createdAt:tt.createdAt,context:a("gitView.pr.comments.reviewContext"),path:tt.path||null,line:tt.line??null})),Ee=[...re,...z];return Ee.sort((tt,wt)=>{const Pt=tt.createdAt?Date.parse(tt.createdAt):0,Nt=wt.createdAt?Date.parse(wt.createdAt):0,$t=Number.isFinite(Pt)?Pt:0,os=Number.isFinite(Nt)?Nt:0;return $t-os}),Ee},[Qe,a]),it=c.useCallback(()=>{const re=b??(j?"draft":null);return re?{directory:t,sessionKey:re}:(Fe.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[b,t,j,a]),pt=c.useCallback((re,z)=>{const Ee=z.authorLogin?`@${z.authorLogin}`:z.authorName,tt=z.path?` · ${z.path}${z.line?`:${z.line}`:""}`:"";Ui.getState().addDraft(re,{source:"pr-comment",fileLabel:`PR #${ae?.number??""} ${Ee}${tt}`,startLine:z.line??0,endLine:z.line??0,code:z.body,language:"markdown",text:""})},[ae?.number]),kt=c.useCallback((re,z)=>{const Ee=re.status||"unknown",tt=re.conclusion??void 0,wt=tt?`${Ee} / ${tt}`:Ee,Pt=re.app?.name||re.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:z?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[z?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:re.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:Pt?`${Pt} · ${wt}`:wt})]}),re.detailsUrl?s.jsx(ft,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:re.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(B,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),re.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:re.output.title}):null,re.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:re.output.summary}):null,re.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:re.output.text}):null,Array.isArray(re.annotations)&&re.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",re.annotations.length>20?` (showing 20/${re.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:re.annotations.slice(0,20).map((Nt,$t)=>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:[Nt.title||Nt.level||"Issue",Nt.path?` · ${Nt.path}`:"",typeof Nt.startLine=="number"?`:${Nt.startLine}`:"",typeof Nt.endLine=="number"&&Nt.endLine!==Nt.startLine?`-${Nt.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Nt.message}),Nt.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Nt.rawDetails}):null]},`${Nt.path||"file"}:${Nt.startLine||$t}:${$t}`))})]}):null,re.job?.steps&&re.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:re.job.steps.map((Nt,$t)=>{const os=(Nt.conclusion||"").toLowerCase(),Xt=os&&!["success","neutral","skipped"].includes(os),Ys=`${re.id??"run"}:${re.job?.jobId??"job"}:${Nt.number??$t}:${Nt.name}`,rn=mt.has(Ys);return Xt?s.jsxs(Dl,{open:rn,children:[s.jsxs("button",{type:"button",onClick:()=>{xt(ui=>{const Qs=new Set(ui);return Qs.has(Ys)?Qs.delete(Ys):Qs.add(Ys),Qs})},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:[rn?s.jsx(B,{name:"arrow-down-s",className:"size-4"}):s.jsx(B,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]}),s.jsx(Il,{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 Nt.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Nt.number]}):null,Nt.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Nt.status]}):null,Nt.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Nt.conclusion]}):null,Nt.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",We(Nt.startedAt)]}):null,Nt.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",We(Nt.completedAt)]}):null]})})]},Ys):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:Nt.name}),Nt.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Nt.conclusion}):null]},Ys)})})]}):null]})},[mt,We,a]),[_t,qt]=c.useState(!1),[Mt,Lt]=c.useState(!1),Wt=c.useCallback(async()=>{if(!u?.prContext){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!ae)return;const re=it();if(re){qt(!0);try{const z=await Ze(u,t,ae.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null});if(!z){Fe.error(a("gitView.pr.toast.loadChecksFailed"));return}const tt=(z.checkRuns??[]).filter(Pt=>Ai(Pt.conclusion));if(tt.length===0){Fe.message(a("gitView.pr.toast.noFailedChecks"));return}const wt=Ui.getState();for(const Pt of tt){const Nt=(Pt.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
+ `)),$t=(Pt.job?.steps??[]).filter(Xt=>Ai(Xt.conclusion)).map(Xt=>`step ${Xt.number??"?"}: ${Xt.name} → ${Xt.conclusion}`),os=[`check: ${Pt.job?.workflowName?`${Pt.job.workflowName} / ${Pt.name}`:Pt.name}`,`status: ${Pt.status??"unknown"} / ${Pt.conclusion??"unknown"}`,Pt.detailsUrl?`url: ${Pt.detailsUrl}`:null,Pt.output?.title?`title: ${Pt.output.title}`:null,Pt.output?.summary?`summary:
4
+ ${Pt.output.summary}`:null,$t.length>0?`failed steps:
5
+ ${$t.join(`
6
+ `)}`:null,Nt.length>0?`annotations:
7
+ ${Nt.join(`
8
+ ---
9
+ `)}`:null].filter(Boolean).join(`
10
+
11
+ `);wt.addDraft(re,{source:"pr-check",fileLabel:`PR #${ae.number} · ${Pt.name}`,startLine:0,endLine:0,code:os,language:"text",text:""})}}catch(z){const Ee=z instanceof Error?z.message:String(z);Fe.error(a("gitView.pr.toast.loadChecksFailed"),{description:Ee})}finally{qt(!1)}}},[t,Ze,u,ae,it,_e?.repo,a]),Jt=c.useCallback(async()=>{if(!u?.prContext){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!ae)return;const re=it();if(re){Lt(!0);try{if(!await Ze(u,t,ae.number,{sourceRepo:_e?.repo??null})){Fe.error(a("gitView.pr.toast.loadPrCommentsFailed"));return}if(Je.length===0){Fe.message(a("gitView.pr.toast.noPrComments"));return}for(const Ee of Je)pt(re,Ee)}catch(z){const Ee=z instanceof Error?z.message:String(z);Fe.error(a("gitView.pr.toast.loadPrCommentsFailed"),{description:Ee})}finally{Lt(!1)}}},[pt,t,Ze,u,ae,it,_e?.repo,a,Je]),Zt=c.useCallback(async re=>{const z=it();z&&pt(z,re)},[pt,it]),Ft=c.useCallback(async re=>{await D(R,re)},[R,D]),[Ot,It]=c.useState(!1),ss=c.useRef(!0);c.useEffect(()=>(ss.current=!0,()=>{ss.current=!1}),[]);const yn=c.useCallback(async()=>{if(Ot)return;It(!0);const re=Date.now();try{await Ft({force:!0})}finally{const z=j1-(Date.now()-re);z>0&&await new Promise(Ee=>window.setTimeout(Ee,z)),ss.current&&It(!1)}},[Ot,Ft]),fs=c.useCallback(()=>{X.current.forEach(re=>{window.clearTimeout(re)}),X.current=S1.map(re=>window.setTimeout(()=>{Ft({force:!0,silent:!0,markInitialResolved:!0})},re))},[Ft]);c.useEffect(()=>{if(!u?.prStatus||!$e||i.length<=1||Ue.current||_e?.pr)return;const re=`${C}::${G?.name??""}`;if(ct.current.has(re))return;ct.current.add(re);const z=A1(i,r).filter(wt=>wt.name!==G?.name);if(z.length===0)return;let Ee=!1;return(async()=>{for(const wt of z){if(Ee)return;try{if(!(await u.prStatus(t,e,wt.name))?.pr)continue;if(Ee)return;ie(Nt=>Nt?.name===wt.name?Nt:wt);return}catch{}}})(),()=>{Ee=!0}},[e,$e,t,u,i,G?.name,C,_e?.pr,r]),c.useEffect(()=>{O(R),M(R,{directory:t,branch:e,remoteName:G?.name??null,canShow:$e,github:u,githubAuthChecked:f,githubConnected:m?.connected??null})},[e,$e,t,O,u,f,m?.connected,R,G?.name,M]),c.useEffect(()=>(F(R),()=>{K(R)}),[R,F,K]),c.useEffect(()=>{const re=Pr.get(C)??null;E(re?.title??pc(e)),k(re?.body??""),I(re?.draft??!1),te(re?.targetBaseBranch?jn(re.targetBaseBranch):jn(n));const z=Pi(i,{selectedRemoteName:re?.selectedRemoteName,trackingBranch:r});ie(Ee=>Ee?.name===z?.name?Ee:z)},[n,e,i,C,r]),c.useEffect(()=>{Ft({markInitialResolved:!0})},[R,Ft]),c.useEffect(()=>{!$e||!G?.name||Ft({force:!0,silent:!0,markInitialResolved:!0})},[$e,Ft,G?.name]),c.useEffect(()=>{const re=_e?.resolvedRemoteName?.trim();if(!re||Ue.current)return;const z=i.find(Ee=>Ee.name===re);z&&ie(Ee=>Ee?.name===z.name?Ee:z)},[i,_e?.resolvedRemoteName]),c.useEffect(()=>{const re=()=>{const Ee=Ps.getState().entries[R]?.lastRefreshAt??0;Date.now()-Ee>6e4&&Ft({force:!0,silent:!0})},z=()=>{document.visibilityState==="visible"&&re()};return window.addEventListener("focus",re),document.addEventListener("visibilitychange",z),()=>{window.removeEventListener("focus",re),document.removeEventListener("visibilitychange",z)}},[R,Ft]),c.useEffect(()=>{f&&m?.connected===!1&&Ft({force:!0,silent:!0,markInitialResolved:!0})},[f,m,Ft]),c.useEffect(()=>{!t||!e||Pr.set(C,{title:A,body:W,draft:v,additionalContext:H,targetBaseBranch:se,selectedRemoteName:G?.name,activeSegment:ut})},[C,A,W,v,H,se,G?.name,t,e,ut]),c.useEffect(()=>{const re=X.current;return()=>{re.forEach(z=>{window.clearTimeout(z)}),X.current=[]}},[]);const Gs=c.useCallback(async()=>{if(!de&&t){Re(!0);try{const z={base:je&&Oe?.defaultBranchSha?Oe.defaultBranchSha:se,head:e};H&&(z.context=H);const Ee=await Zp(t,z);Ee.title?.trim()&&E(Ee.title.trim()),Ee.body?.trim()&&k(Ee.body.trim()),l?.()}catch(re){const z=re instanceof Error?re.message:String(re);Fe.error(a("gitView.pr.toast.generateDescriptionFailed"),{description:z})}finally{Re(!1)}}},[H,e,Oe?.defaultBranchSha,t,de,l,se,a,je]),bs=c.useCallback(async()=>{if(!u?.prCreate){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}const re=A.trim();if(!re){Fe.error(a("gitView.pr.toast.titleRequired"));return}const z=se.trim();if(!z){Fe.error(a("gitView.pr.toast.baseBranchRequired"));return}if(!je&&z===e){Fe.error(a("gitView.pr.toast.baseMustDifferFromHead"));return}fe(!0);try{const Ee=Ya(r),tt=je&&Oe,wt=await u.prCreate({directory:t,title:re,head:e,base:z,...W.trim()?{body:W}:{},draft:v,...tt?{targetRepo:{owner:Oe.owner,repo:Oe.repo},headRemote:"origin"}:{...G?{remote:G.name}:{},...Ee&&Ee!==G?.name?{headRemote:Ee}:{}}});Fe.success(a("gitView.pr.toast.prCreated")),U(R,Pt=>Pt&&{...Pt,pr:wt}),await Ft({force:!0}),fs()}catch(Ee){const tt=Ee instanceof Error?Ee.message:String(Ee);Fe.error(a("gitView.pr.toast.createPrFailed"),{description:tt})}finally{fe(!1)}},[W,e,Oe,t,v,u,R,Ft,fs,G,se,A,r,U,je,a]),wn=c.useCallback(async re=>{if(!u?.prMerge){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}ce(!0);try{const z=await u.prMerge({directory:t,number:re.number,method:ee});z.merged?Fe.success(a("gitView.pr.toast.prMerged")):Fe.message(a("gitView.pr.toast.prNotMerged"),{description:z.message||a("gitView.pr.notMergeable")}),await Ft({force:!0}),fs()}catch(z){const Ee=z instanceof Error?z.message:String(z);Fe.error(a("gitView.pr.toast.mergeFailed"),{description:Ee}),re.url&&lo(re.url)}finally{ce(!1)}},[t,u,ee,Ft,fs,a]),qs=c.useCallback(async re=>{if(!u?.prReady){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}Y(!0);try{await u.prReady({directory:t,number:re.number}),Fe.success(a("gitView.pr.toast.markedReady")),await Ft({force:!0}),fs()}catch(z){const Ee=z instanceof Error?z.message:String(z);Fe.error(a("gitView.pr.toast.markReadyFailed"),{description:Ee}),re.url&&lo(re.url)}finally{Y(!1)}},[t,u,Ft,fs,a]),Tn=c.useCallback(async re=>{if(!u?.prUpdate){Fe.error(a("gitView.pr.toast.githubApiUnavailable"));return}const z=ge.trim();if(!z){Fe.error(a("gitView.pr.toast.titleRequired"));return}L(!0);try{const Ee=await u.prUpdate({directory:t,number:re.number,title:z,body:$});U(R,tt=>tt&&{...tt,pr:{...tt.pr??re,...Ee}}),Te(!1),Fe.success(a("gitView.pr.toast.prUpdated")),await Ft({force:!0}),fs()}catch(Ee){const tt=Ee instanceof Error?Ee.message:String(Ee);Fe.error(a("gitView.pr.toast.updatePrFailed"),{description:tt})}finally{L(!1)}},[t,$,ge,u,R,Ft,fs,U,a]);if(!$e)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(cc,{})]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pullRequest.availableOnFeatureBranches")})]})});const $s=_e?.repo?.url||null,sn=je&&Oe?.url?Oe.url:$s,xs=!!_e?.canMerge,Zn=!!_e?.connected,er=f&&_e?.connected===!1,zs=v1(_e),Ts=zs?`var(--pr-${zs})`:"var(--status-info)",tr=zs==="draft"?"git-pr-draft":zs==="merged"?"git-merge":zs==="closed"?"git-close-pull-request":"git-pull-request",nn=ae?[`${ae.state}${ae.draft?" (draft)":""}`,ae.mergeable===!1?a("gitView.pr.notMergeable"):null,ae.state==="open"&&typeof ae.mergeableState=="string"&&ae.mergeableState&&ae.mergeableState!=="unknown"?ae.mergeableState:null].filter(Boolean).join(" · "):"",sr=Ge?Ge.total>0?`${Ge.success}/${Ge.total} ${a("gitView.pr.checks.label")}`:`${Ge.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:[ae?s.jsxs(ft,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{lo(ae.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:[s.jsx(B,{name:tr,className:"size-4 shrink-0",style:{color:Ts}}),a("gitView.pr.actions.openOnGitHub")]}):s.jsx(B,{name:tr,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")}),ae?s.jsxs("span",{className:"typography-meta text-muted-foreground truncate",children:["#",ae.number]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[ae&&N?s.jsxs(ft,{variant:"outline",size:"sm",className:Ie("pr-actions__walkthrough-button h-7 shrink-0 gap-1.5 px-2",p1),onClick:()=>{S(t,{kind:"pr",number:ae.number,sourceRepo:_e?.repo?{owner:_e.repo.owner,repo:_e.repo.repo}:void 0}),w(t,"walkthrough")},"aria-label":a("walkthrough.action.open"),children:[s.jsx(B,{name:"route",className:"size-4"}),s.jsx("span",{className:"pr-actions__walkthrough-label typography-ui-label",children:a("walkthrough.action.open")})]}):null,s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0",disabled:Le||Ot,onClick:()=>{yn()},"aria-label":a("gitView.pr.actions.refreshAria"),children:Le||Ot?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin text-muted-foreground"}):s.jsx(B,{name:"refresh",className:"size-4 text-muted-foreground"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.refresh")})})]}),s.jsx(cc,{className:"h-7 w-7"})]})]}),ae?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:Ts},children:nn}),Ge?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${hc(Ge.state)}`}),sr]}):null,r&&G&&r.split("/")[0]!==G.name?s.jsxs("span",{className:"min-w-0 truncate",children:[r.split("/")[0]," → ",G.name]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[xs&&ae.draft&&ae.state==="open"?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>qs(ae),disabled:he||oe||Pe||ve,"aria-label":a("gitView.pr.actions.markReadyAria"),children:he?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{name:"checkbox-circle",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.markReady")})})]}):null,xs?s.jsxs(s.Fragment,{children:[s.jsxs(cn,{value:ee,onValueChange:re=>ue(re),disabled:oe||ae.state!=="open",children:[s.jsx(dn,{size:"sm",className:"h-7 w-auto min-w-0",children:s.jsx(Zs,{})}),s.jsxs(un,{children:[s.jsx(us,{value:"squash",children:a("gitView.pr.mergeMethod.squash")}),s.jsx(us,{value:"merge",children:a("gitView.pr.mergeMethod.merge")}),s.jsx(us,{value:"rebase",children:a("gitView.pr.mergeMethod.rebase")})]})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{size:"sm",className:"h-7 w-7 px-0",onClick:()=>wn(ae),disabled:oe||he||ae.state!=="open"||ae.draft||Pe||ve,"aria-label":a("gitView.pr.actions.mergePrAria"),children:oe?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{name:"git-merge",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.mergePr")})})]})]}):null]})]}):null]}),s.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[er?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("gitView.pr.githubNotConnected")}),s.jsx(ft,{variant:"outline",size:"sm",onClick:P,className:"w-fit",children:a("gitView.pr.actions.openSettings")})]}):null,lt?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:lt}),sn?s.jsx(ft,{variant:"outline",size:"sm",asChild:!0,className:"w-fit",children:s.jsxs("a",{href:sn,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(B,{name:"external-link",className:"size-4"}),"Open Repo"]})}):null]}):null,!ae&&!ht&&!lt&&!er?s.jsxs("div",{className:"flex items-center gap-2 typography-micro text-muted-foreground",children:[s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}),a("gitView.pr.checkingStatus")]}):ae&&!De?s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"h-8 min-w-0",children:s.jsx(qd,{className:"h-full",items:[{id:"overview",label:a("gitView.pr.segment.overview")},{id:"checks",label:Ge&&Ge.total>0?`${a("gitView.pr.segment.checks")} ${Ge.success}/${Ge.total}`:a("gitView.pr.segment.checks"),icon:Ge?s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${hc(Ge.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:ut,onSelect:re=>Ct(re),layoutMode:"fit",variant:"active-pill",activePillButtonClassName:"h-7"})}),ut==="overview"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[xs&&ae.draft?s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.draftMustBeReady")}):null,xs?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:ve?s.jsx(Wn,{value:ge,onChange:re=>Q(re.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):s.jsx("div",{className:"typography-markdown text-xl font-semibold text-foreground break-words leading-snug",children:ae.title})}),ae.state==="open"?s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:ve?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"outline",size:"sm",className:"h-9 w-9 px-0",onClick:()=>{Te(!1),Q(ae.title||""),J(ae.body||"")},disabled:Pe,"aria-label":a("gitView.pr.actions.cancelEditingAria"),children:s.jsx(B,{name:"close",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.cancelEditing")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{size:"sm",className:"h-9 w-9 px-0",onClick:()=>Tn(ae),disabled:Pe||!ge.trim(),"aria-label":a("gitView.pr.actions.savePrAria"),children:Pe?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{name:"check",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.savePr")})})]})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{variant:"outline",size:"sm",className:"h-7 w-7 px-0",onClick:()=>Te(!0),"aria-label":a("gitView.pr.actions.editPrAria"),children:s.jsx(B,{name:"edit",className:"size-4"})})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.editPr")})})]})}):null]}),ve?s.jsx(Er,{value:$,onChange:re=>J(re.target.value),outerClassName:"min-h-[60vh]",placeholder:a("gitView.pr.placeholder.description"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h}):null,ve?null:ae.body?.trim()?s.jsx(Tl,{content:ae.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(Ne?"gitView.pr.loadingDescription":"gitView.pr.noDescription")})]}):null,ut==="checks"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[Ge&&Ge.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:[Ge.success>0?s.jsx("div",{className:"bg-[color:var(--status-success)]",style:{width:`${Ge.success/Ge.total*100}%`}}):null,Ge.failure>0?s.jsx("div",{className:"bg-[color:var(--status-error)]",style:{width:`${Ge.failure/Ge.total*100}%`}}):null,Ge.pending>0?s.jsx("div",{className:"bg-[color:var(--status-warning)]",style:{width:`${Ge.pending/Ge.total*100}%`}}):null]}),s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Ge.success,"/",Ge.total," ",a("gitView.pr.checks.label")]}),(Ge.inProgress??0)>0?s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-[var(--status-warning)]",children:[s.jsx(B,{name:"loader-4",className:"size-3.5 animate-spin"}),Ni(Ge.startedAt,void 0,Me)]}):null]}):null,Ge?.failure?s.jsxs(ft,{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:Wt,disabled:_t,"aria-label":a("gitView.pr.actions.resolveFailedChecksAria"),children:[_t?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{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((re,z)=>{const Ee=`${re.id??"run"}:${re.name}:${z}`,tt=re.status==="in_progress",wt=re.status==="queued",Pt=Ai(re.conclusion),Nt=Dt.has(Ee),$t=!!(re.output?.title||re.output?.summary||re.output?.text||(re.annotations?.length??0)>0||(re.job?.steps?.length??0)>0||re.detailsUrl),os=re.job?.workflowName,Xt=tt?Ni(re.startedAt,void 0,Me):Ni(re.startedAt,re.completedAt);return s.jsxs("div",{className:Ie("rounded-md border border-border/40",Pt&&"border-[var(--status-error-border)]"),children:[s.jsxs("button",{type:"button",disabled:!$t,onClick:()=>{be(Ys=>{const rn=new Set(Ys);return rn.has(Ee)?rn.delete(Ee):rn.add(Ee),rn})},className:"flex w-full items-center gap-2 px-2.5 py-2 text-left disabled:cursor-default",children:[tt?s.jsx(B,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-warning)]"}):wt?s.jsx(B,{name:"time",className:"size-4 shrink-0 text-muted-foreground"}):Pt?s.jsx(B,{name:"close-circle",className:"size-4 shrink-0 text-[var(--status-error)]"}):s.jsx(B,{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!==re.name?`${os} / ${re.name}`:re.name}),Xt?s.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:Xt}):null,$t?s.jsx(B,{name:"arrow-down-s",className:Ie("size-4 shrink-0 text-muted-foreground transition-transform",Nt&&"rotate-180")}):null]}),Nt&&$t?s.jsx("div",{className:"min-w-0 overflow-hidden border-t border-border/40 p-2.5",children:kt(re,{hideHeader:!0})}):null]},Ee)})}):et?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(B,{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,ut==="comments"?s.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[Je.length>0?s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(ft,{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:Jt,disabled:Mt,"aria-label":a("gitView.pr.actions.shareCommentsAria"),children:[Mt?s.jsx(B,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(B,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.comments.addAll")]})}):null,Je.length>0?s.jsx("div",{className:"relative pl-3",children:s.jsx("div",{children:Je.map((re,z)=>{const Ee=(re.authorName||"?").charAt(0).toUpperCase(),tt=z===Je.length-1;return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[tt?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:re.avatarUrl?s.jsx("img",{src:re.avatarUrl,alt:re.authorName,className:"h-full w-full object-cover"}):s.jsx("span",{children:Ee})}),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:[re.authorName,re.authorLogin&&re.authorLogin!==re.authorName?` · @${re.authorLogin}`:""]}),re.createdAt?s.jsx("span",{className:"whitespace-nowrap",children:We(re.createdAt)}):null,s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{variant:"ghost",size:"sm",className:"h-6 px-0 has-[>svg]:px-0 sm:px-2 sm:has-[>svg]:px-2.5 text-[var(--status-success)] hover:bg-[var(--status-success-background)] hover:text-[var(--status-success)] justify-start",onClick:()=>{Zt(re)},"aria-label":a("gitView.pr.actions.sendCommentToAgentAria"),children:[s.jsx(B,{name:"ai-generate-2",className:"size-3.5"}),a("gitView.pr.actions.sendToAgent")]})}),s.jsx(jt,{children:s.jsx("p",{children:a("gitView.pr.actions.sendCommentToAgent")})})]})]}),s.jsxs("div",{className:"typography-micro text-muted-foreground",children:[re.context,re.path?` · ${re.path}`:"",re.line?`:${re.line}`:""]}),s.jsx(Tl,{content:Se(re.body),className:["typography-markdown-body text-foreground break-words [&_a]:no-underline [&_a:hover]:no-underline",bt].filter(Boolean).join(" "),enableFileReferences:!1})]})]},re.id)})})}):et&&!Qe?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 typography-micro text-muted-foreground",children:[s.jsx(B,{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:[ae&&De?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(B,{name:ae.state==="merged"?"git-merge":"git-close-pull-request",className:"size-4 shrink-0",style:{color:Ts}}),s.jsx("div",{className:"min-w-0 flex-1 typography-micro text-muted-foreground",children:ae.state==="merged"?a("gitView.pr.history.merged",{number:ae.number,base:ae.base||se}):a("gitView.pr.history.closed",{number:ae.number})}),s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{lo(ae.url)},"aria-label":a("gitView.pr.actions.openOnGitHubAria"),children:s.jsx(B,{name:"external-link",className:"size-3.5"})})]}):null,s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:a("gitView.pr.createTitle")}),s.jsxs("div",{className:"typography-micro text-muted-foreground truncate",children:[e," ",s.jsx("span",{className:"opacity-60",children:"(local)"})," → ",se," ",s.jsxs("span",{className:"opacity-60",children:["(",je&&Oe?"upstream":"remote",")"]})]})]}),sn?s.jsx(ft,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:sn,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(B,{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(Wn,{value:A,onChange:re=>E(re.target.value),placeholder:a("gitView.pr.placeholder.title"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.field.baseBranch")}),ot.length>0?s.jsxs(cn,{value:se,onValueChange:te,children:[s.jsx(dn,{size:"lg","aria-label":a("gitView.pr.field.baseBranch"),children:s.jsx(Zs,{placeholder:a("gitView.pr.placeholder.selectBaseBranch")})}),s.jsx(un,{children:ot.map(re=>s.jsx(us,{value:re,children:re},re))})]}):s.jsx(Wn,{value:se,onChange:re=>te(re.target.value),placeholder:a("gitView.pr.placeholder.main"),"aria-label":a("gitView.pr.field.baseBranch")})]}),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(Er,{value:W,onChange:re=>k(re.target.value),className:"min-h-[110px]",placeholder:a("gitView.pr.placeholder.whatChanged"),autoCorrect:h?"on":"off",autoCapitalize:h?"sentences":"off",spellCheck:h})]}),s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":v,onClick:()=>I(re=>!re),onKeyDown:re=>{(re.key===" "||re.key==="Enter")&&(re.preventDefault(),I(z=>!z))},children:[s.jsx(Lr,{size:"sm",checked:v,onChange:re=>I(re),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(ft,{variant:"outline",size:"sm",onClick:()=>Z(!0),children:H.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),H.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(Dl,{open:me,onOpenChange:le,children:[s.jsxs(eg,{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:me?a("gitView.pr.actions.hide"):H.trim()?a("gitView.pr.actions.edit"):a("gitView.pr.actions.add")})]}),s.jsx(Il,{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(Er,{value:H,onChange:re=>_(re.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(Xo,{open:V,onClose:()=>Z(!1),title:a("gitView.pr.additionalContext.title"),footer:s.jsx(ft,{size:"sm",onClick:()=>Z(!1),className:"w-full",children:a("gitView.common.done")}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Er,{value:H,onChange:re=>_(re.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(ft,{variant:"outline",size:"sm",onClick:Gs,disabled:de||we,children:[de?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{name:"ai-generate-2",className:"size-4 text-primary"}),a("gitView.commit.generate")]}),s.jsx("div",{className:"flex-1"}),s.jsxs(ft,{size:"sm",className:"min-w-[7.5rem] justify-center gap-2",onClick:bs,disabled:we||!Zn||!se.trim()||!je&&se.trim()===e,children:[s.jsx("span",{className:"inline-flex size-4 items-center justify-center",children:we?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(B,{name:"git-pull-request",className:"size-4"})}),s.jsx("span",{children:a("gitView.pr.actions.createPr")})]})]})]})]})]})},Di=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/,""),co=new Map,uo=new Map,Sn=t=>`${Yt()}::${t}`,I1=()=>{const t=nt.c(115),{t:e}=At(),{git:n}=bn(),r=Yn(),{rootIsGitRepo:i,gitDirectory:o,nestedRepos:l}=tg(r??null),a=Ma(o??null),d=sg(o??null),u=ng(o??null),{ensureAll:m,ensureNestedRepos:f,selectNestedRepo:g}=Xn(Un(T1)),x=rt(E1),b=rt(R1),j=rt(M1),y=rt(O1);let h;t[0]!==r?(h=Di(r),t[0]=r,t[1]=h):h=t[1];const p=h;let w;if(t[2]!==y||t[3]!==p||t[4]!==j){e:{if(!p){w=void 0;break e}let G;if(t[6]!==y||t[7]!==p){let je;t[9]!==p?(je=ne=>Di(ne.path)===p,t[9]=p,t[10]=je):je=t[10],G=y.find(je),t[6]=y,t[7]=p,t[8]=G}else G=t[8];const ie=G;if(ie){w=ie;break e}for(const je of j.values())if(Di(je.path)===p){w=je;break e}w=void 0}t[2]=y,t[3]=p,t[4]=j,t[5]=w}else w=t[5];const S=w;let N;t[11]!==x||t[12]!==S||t[13]!==b?.open||t[14]!==j?(N=()=>{if(x)return j.get(x)??S;if(b?.open)return S},t[11]=x,t[12]=S,t[13]=b?.open,t[14]=j,t[15]=N):N=t[15],b?.open;let P;t[16]!==N?(P=N(),t[16]=N,t[17]=P):P=t[17];const C=P;let T;t[18]!==x?(T=G=>x?G.getAttachment(x):void 0,t[18]=x,t[19]=T):T=t[19];const O=mu(T),M=O&&!O.degraded&&!O.legacy?O.worktreeRoot??void 0:void 0,F=r1(r,C,a?.current??void 0);let K,D;t[20]!==m||t[21]!==n||t[22]!==o?(K=()=>{!o||!n||m(o,n)},D=[o,m,n],t[20]=m,t[21]=n,t[22]=o,t[23]=K,t[24]=D):(K=t[23],D=t[24]),c.useEffect(K,D);const[U,A]=c.useState(null);let E;t[25]!==M||t[26]!==F?.projectDirectory?(E=()=>{const G=M||F?.projectDirectory;if(!G){A(null);return}let ie=!1;return Su(G).then(je=>{if(ie)return;const ne=je.trim();A(ne&&ne!=="HEAD"?ne:null)}).catch(()=>{ie||A(null)}),()=>{ie=!0}},t[25]=M,t[26]=F?.projectDirectory,t[27]=E):E=t[27];const W=F?.projectDirectory;let k;t[28]!==M||t[29]!==W?(k=[M,W],t[28]=M,t[29]=W,t[30]=k):k=t[30],c.useEffect(E,k);let v;t[31]!==o?(v=()=>(o?co.get(Sn(o)):void 0)??[],t[31]=o,t[32]=v):v=t[32];const[I,H]=c.useState(v);let _;t[33]!==o?(_=()=>(o?uo.get(Sn(o)):void 0)??null,t[33]=o,t[34]=_):_=t[34];const[se,te]=c.useState(_);let ee,ue;t[35]!==n||t[36]!==o?(ee=()=>{if(!o||!n?.getRemotes){H([]);return}H(co.get(Sn(o))??[]);let G=!1;return n.getRemotes(o).then(ie=>{G||(co.set(Sn(o),ie??[]),H(ie??[]))}).catch(()=>{G||H(co.get(Sn(o))??[])}),()=>{G=!0}},ue=[o,n],t[35]=n,t[36]=o,t[37]=ee,t[38]=ue):(ee=t[37],ue=t[38]),c.useEffect(ee,ue);let de,Re;t[39]!==n||t[40]!==o?(de=()=>{if(!o||!n?.getRemoteUrl){te(null);return}te(uo.get(Sn(o))??null);let G=!1;return n.getRemoteUrl(o).then(ie=>{G||(uo.set(Sn(o),ie),te(ie))}).catch(()=>{G||te(uo.get(Sn(o))??null)}),()=>{G=!0}},Re=[o,n],t[39]=n,t[40]=o,t[41]=de,t[42]=Re):(de=t[41],Re=t[42]),c.useEffect(de,Re);let we;e:{if(!d?.all){let ie;t[43]===Symbol.for("react.memo_cache_sentinel")?(ie=[],t[43]=ie):ie=t[43],we=ie;break e}let G;t[44]!==d.all?(G=d.all.filter(B1).sort(),t[44]=d.all,t[45]=G):G=t[45],we=G}const fe=we;let Pe;e:{if(!d?.all){let ie;t[46]===Symbol.for("react.memo_cache_sentinel")?(ie=[],t[46]=ie):ie=t[46],Pe=ie;break e}let G;t[47]!==d.all?(G=d.all.filter(F1).map(L1).sort(),t[47]=d.all,t[48]=G):G=t[48],Pe=G}const L=Pe;let oe;t[49]!==L||t[50]!==se||t[51]!==I||t[52]!==a?.tracking?(oe=()=>{if(I.length>0)return I;const G=new Set,ie=a?.tracking?.trim();ie&&ie.includes("/")&&G.add(ie.split("/")[0]);for(const je of L){const ne=je.indexOf("/");ne>0&&G.add(je.slice(0,ne))}return G.size===0&&se&&G.add("origin"),Array.from(G).map(je=>({name:je,fetchUrl:se??"",pushUrl:se??""}))},t[49]=L,t[50]=se,t[51]=I,t[52]=a?.tracking,t[53]=oe):oe=t[53],a?.tracking;let ce;t[54]!==oe?(ce=oe(),t[54]=oe,t[55]=ce):ce=t[55];const he=ce,Y=a?.current??null;a?.tracking;let ve;t[56]!==a?.tracking?(ve=a?.tracking?.trim().split("/")[0],t[56]=a?.tracking,t[57]=ve):ve=t[57];const Te=ve,ke=(Te&&d?.defaultBranches?.[Te])??d?.defaultBranches?.origin;let xe;t[58]!==Y||t[59]!==ke||t[60]!==he||t[61]!==fe||t[62]!==U||t[63]!==F?.createdFromBranch?(xe=()=>Oh({remoteNames:new Set(he.map(_1)),localBranches:fe,worktreeCreatedFromBranch:F?.createdFromBranch,rootBranchHint:U,defaultBranch:ke,headBranch:Y}),t[58]=Y,t[59]=ke,t[60]=he,t[61]=fe,t[62]=U,t[63]=F?.createdFromBranch,t[64]=xe):xe=t[64],F?.createdFromBranch;let ge;t[65]!==xe?(ge=xe(),t[65]=xe,t[66]=ge):ge=t[66];const Q=ge;if(!r){let G;t[67]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx(B,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[67]=G):G=t[67];let ie;t[68]!==e?(ie=e("gitView.pullRequest.title"),t[68]=e,t[69]=ie):ie=t[69];let je;t[70]!==ie?(je=s.jsx("div",{className:"typography-ui-header text-foreground",children:ie}),t[70]=ie,t[71]=je):je=t[71];let ne;t[72]!==e?(ne=e("gitView.pullRequest.createHint"),t[72]=e,t[73]=ne):ne=t[73];let Oe;t[74]!==ne?(Oe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ne}),t[74]=ne,t[75]=Oe):Oe=t[75];let Ve;return t[76]!==je||t[77]!==Oe?(Ve=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[G,je,Oe]}),t[76]=je,t[77]=Oe,t[78]=Ve):Ve=t[78],Ve}if(i===!1&&u!==!0){let G;t[79]!==r||t[80]!==f?(G=()=>{f(r,{force:!0})},t[79]=r,t[80]=f,t[81]=G):G=t[81];let ie;return t[82]!==u||t[83]!==l||t[84]!==i||t[85]!==G?(ie=s.jsx(Bh,{rootIsGitRepo:i,resolvedIsGitRepo:u,nestedRepos:l,onRetryDiscovery:G}),t[82]=u,t[83]=l,t[84]=i,t[85]=G,t[86]=ie):ie=t[86],ie}if(!Y){let G;t[87]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx(B,{name:"git-pull-request",className:"h-12 w-12 text-muted-foreground/50"}),t[87]=G):G=t[87];let ie;t[88]!==e?(ie=e("gitView.pullRequest.title"),t[88]=e,t[89]=ie):ie=t[89];let je;t[90]!==ie?(je=s.jsx("div",{className:"typography-ui-header text-foreground",children:ie}),t[90]=ie,t[91]=je):je=t[91];let ne;t[92]!==e?(ne=e("gitView.pullRequest.createHint"),t[92]=e,t[93]=ne):ne=t[93];let Oe;t[94]!==ne?(Oe=s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:ne}),t[94]=ne,t[95]=Oe):Oe=t[95];let Ve;return t[96]!==je||t[97]!==Oe?(Ve=s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[G,je,Oe]}),t[96]=je,t[97]=Oe,t[98]=Ve):Ve=t[98],Ve}const $=i===!1&&Array.isArray(l)&&l.length>0;let J;t[99]!==r||t[100]!==o||t[101]!==l||t[102]!==g||t[103]!==$?(J=$?s.jsx("div",{className:"flex shrink-0 items-center border-b border-border/60 px-4 py-2",children:s.jsx(Fh,{repositories:l,selectedRepository:o??null,onSelectRepository:G=>{r&&g(r,G)},repositoryRoot:r??void 0})}):null,t[99]=r,t[100]=o,t[101]=l,t[102]=g,t[103]=$,t[104]=J):J=t[104];const me=o??r,le=a?.tracking??void 0;let V;t[105]!==Q||t[106]!==Y||t[107]!==L||t[108]!==I||t[109]!==me||t[110]!==le?(V=s.jsx(xn,{as:ju,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:s.jsx(D1,{directory:me,branch:Y,baseBranch:Q,trackingBranch:le,remotes:I,remoteBranches:L})}),t[105]=Q,t[106]=Y,t[107]=L,t[108]=I,t[109]=me,t[110]=le,t[111]=V):V=t[111];let Z;return t[112]!==J||t[113]!==V?(Z=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[J,V]}),t[112]=J,t[113]=V,t[114]=Z):Z=t[114],Z};function T1(t){return{ensureAll:t.ensureAll,ensureNestedRepos:t.ensureNestedRepos,selectNestedRepo:t.selectNestedRepo}}function E1(t){return t.currentSessionId}function R1(t){return t.newSessionDraft}function M1(t){return t.worktreeMetadata}function O1(t){return t.availableWorktrees}function B1(t){return!t.startsWith("remotes/")}function F1(t){return t.startsWith("remotes/")}function L1(t){return t.replace(/^remotes\//,"")}function _1(t){return t.name}const ia=2e4,$1=(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)=>lg(cg.getState().dictionary,t,e),z1=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"},W1=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()},yf=async(t,e,n)=>{if(rg(e)||og(e)||ig(e))return{ok:!0};try{const r=await W1(t,e,n);return ag(r)?{ok:!1,reason:"binary"}:$1(r,ia)>ia?{ok:!1,reason:"too-large"}:{ok:!0}}catch(r){return{ok:!1,reason:z1(r)}}},wf=t=>{if(t==="too-large"){const e=ia.toLocaleString(ku());return fo("contextFileOpen.failure.tooLarge",{count:e})}return fo(t==="missing"?"contextFileOpen.failure.missing":t==="binary"?"filesView.editor.cannotPreviewBinary":"contextFileOpen.failure.unreadable")},gc=8;let aa=null;const vf=t=>{aa={x:t.clientX,y:t.clientY}},Sf=t=>{const e=aa;return aa=null,!e||t.dataTransfer&&t.dataTransfer.dropEffect!=="none"?!1:Math.abs(t.clientX-e.x)<=gc&&Math.abs(t.clientY-e.y)<=gc},pr=t=>Array.from(t.types).includes("Files"),K1=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]:[]})},V1=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},Qa=(t,e)=>{const n=rs(e),r=rs(t).replace(/\/+$/,"");return n===r?".":!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},U1=(t,e)=>{const n=Qa(t,e);if(n!==".")return n;const r=rs(t);return r.split("/").filter(Boolean).pop()??r},H1=t=>{const e=rs(t),n=e.lastIndexOf("/");return n<0?"":n===0?"/":e.slice(0,n)},G1=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),q1=new Set(["node_modules"]),Y1=t=>q1.has(t),Q1=t=>{const e=rs(t);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},X1=8,Js=new Map,Xa=t=>JSON.stringify([Yt(),t]),J1=t=>{const e=Xa(t),n=Js.get(e);return n?(n.touchedAt=Date.now(),Js.delete(e),Js.set(e,n),n):null},Ii=t=>{const e=Xa(t),n=Js.get(e);if(n)return n.touchedAt=Date.now(),n;if(Js.size>=X1){const i=Js.keys().next().value;i!==void 0&&Js.delete(i)}const r={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Js.set(e,r),r},jf=(t,e)=>s.jsx(Oa,{filePath:t,extension:e}),Z1=t=>{const e=nt.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},ew=t=>{const e=nt.c(90),{node:n,root:r,isExpanded:i,isActive:o,isBrowserClient:l,status:a,badge:d,isDropTarget:u,canUpload:m,permissions:f,downloadFile:g,onSelect:x,onToggle:b,onRevealPath:j,onOpenDialog:y,onSetDropTarget:h,onDropFiles:p,onPickFiles:w}=t,{t:S}=At(),N=n.type==="directory";let P;e[0]!==N||e[1]!==n.path?(P=N?n.path:H1(n.path),e[0]=N,e[1]=n.path,e[2]=P):P=e[2];const C=P,{canRename:T,canCreateFile:O,canCreateFolder:M,canDelete:F,canReveal:K}=f,D=!N&&!!g,U=K&&!l,A=N&&m,E=T||O||M||A||F||D||U,[W,k]=c.useState(!1),[v,I]=c.useState(!1);let H;e[3]!==E?(H=ne=>{E&&(ne?.preventDefault(),I(!0))},e[3]=E,e[4]=H):H=e[4];const _=H;let se;e[5]!==N||e[6]!==n||e[7]!==x||e[8]!==b?(se=()=>{N?b(n.path):x(n)},e[5]=N,e[6]=n,e[7]=x,e[8]=b,e[9]=se):se=e[9];const te=se;let ee;e[10]===Symbol.for("react.memo_cache_sentinel")?(ee=ne=>{ne.stopPropagation(),I(!1),k(!0)},e[10]=ee):ee=e[10];const ue=ee;let de;e[11]!==O||e[12]!==M||e[13]!==F||e[14]!==T||e[15]!==U||e[16]!==A||e[17]!==g||e[18]!==l||e[19]!==N||e[20]!==n||e[21]!==y||e[22]!==w||e[23]!==j||e[24]!==S?(de=ne=>{const{Item:Oe,Separator:Ve}=ne;return s.jsxs(s.Fragment,{children:[T&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),y("rename",n)},children:[s.jsx(B,{name:"edit",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.rename")]}),s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),Gn(n.path).then(He=>{if(He.ok){Fe.success(S("sidebarFilesTree.toast.pathCopied"));return}Fe.error(S("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(B,{name:"file-copy",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.copyPath")]}),!N&&g&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),g(n.path).catch(He=>{console.error("Download failed:",He),Fe.error(S("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(B,{name:"download",className:"mr-2 h-4 w-4"})," ",S(l?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),j(n.path)},children:[s.jsx(B,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",S(dg())]}),N&&(O||M||A)&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{}),O&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),y("createFile",n)},children:[s.jsx(B,{name:"file-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFile")]}),M&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),y("createFolder",n)},children:[s.jsx(B,{name:"folder-add",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.newFolder")]}),A&&s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),w(n.path)},children:[s.jsx(B,{name:"upload-2",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.uploadFiles")]})]}),F&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{}),s.jsxs(Oe,{onClick:ze=>{ze.stopPropagation(),y("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ",S("sidebarFilesTree.menu.delete")]})]})]})},e[11]=O,e[12]=M,e[13]=F,e[14]=T,e[15]=U,e[16]=A,e[17]=g,e[18]=l,e[19]=N,e[20]=n,e[21]=y,e[22]=w,e[23]=j,e[24]=S,e[25]=de):de=e[25];const Re=de;let we;e[26]!==n.path||e[27]!==r?(we=ne=>{vf(ne);const Oe=Qa(r,n.path);!Oe||Oe==="."||(ne.dataTransfer.setData("application/x-openchamber-file-path",Oe),ne.dataTransfer.effectAllowed="copy")},e[26]=n.path,e[27]=r,e[28]=we):we=e[28];const fe=we;let Pe;e[29]!==te?(Pe=ne=>{Sf(ne)&&te()},e[29]=te,e[30]=Pe):Pe=e[30];const L=Pe;let oe;e[31]!==m||e[32]!==h||e[33]!==C?(oe=ne=>{!m||!C||!pr(ne.dataTransfer)||(ne.preventDefault(),ne.stopPropagation(),ne.dataTransfer.dropEffect="copy",h(C))},e[31]=m,e[32]=h,e[33]=C,e[34]=oe):oe=e[34];const ce=oe;let he;e[35]!==m||e[36]!==h||e[37]!==C?(he=ne=>{!m||!C||!pr(ne.dataTransfer)||ne.relatedTarget instanceof Node&&ne.currentTarget.contains(ne.relatedTarget)||(ne.stopPropagation(),h(null))},e[35]=m,e[36]=h,e[37]=C,e[38]=he):he=e[38];const Y=he;let ve;e[39]!==m||e[40]!==p||e[41]!==C?(ve=ne=>{!m||!C||!pr(ne.dataTransfer)||(ne.preventDefault(),ne.stopPropagation(),p(C,ne.dataTransfer))},e[39]=m,e[40]=p,e[41]=C,e[42]=ve):ve=e[42];const Te=ve;let ke;e[43]===Symbol.for("react.memo_cache_sentinel")?(ke={contentVisibility:"auto",blockSize:"calc(max(1lh, 1rem) + 0.5rem)"},e[43]=ke):ke=e[43];let xe;e[44]!==_||e[45]!==Y||e[46]!==ce||e[47]!==Te?(xe=s.jsx("div",{className:"group relative flex items-center typography-meta",style:ke,onContextMenu:_,onDragEnter:ce,onDragOver:ce,onDragLeave:Y,onDrop:Te}),e[44]=_,e[45]=Y,e[46]=ce,e[47]=Te,e[48]=xe):xe=e[48];const ge=u?"bg-interactive-selection ring-2 ring-inset ring-primary":o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Q;e[49]!==ge?(Q=Ie("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ge),e[49]=ge,e[50]=Q):Q=e[50];let $;e[51]!==N||e[52]!==i||e[53]!==n.extension||e[54]!==n.path?($=N?i?s.jsx(B,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):s.jsx(B,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):jf(n.path,n.extension),e[51]=N,e[52]=i,e[53]=n.extension,e[54]=n.path,e[55]=$):$=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 me;e[59]!==N||e[60]!==a?(me=!N&&a&&s.jsx(Z1,{status:a}),e[59]=N,e[60]=a,e[61]=me):me=e[61];let le;e[62]!==d||e[63]!==N?(le=N&&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]=N,e[64]=le):le=e[64];let V;e[65]!==_||e[66]!==L||e[67]!==fe||e[68]!==te||e[69]!==Q||e[70]!==$||e[71]!==J||e[72]!==me||e[73]!==le?(V=s.jsxs("button",{type:"button",onClick:te,onContextMenu:_,draggable:!0,onDragStart:fe,onDragEnd:L,className:Q,children:[$,J,me,le]}),e[65]=_,e[66]=L,e[67]=fe,e[68]=te,e[69]=Q,e[70]=$,e[71]=J,e[72]=me,e[73]=le,e[74]=V):V=e[74];let Z;e[75]!==W||e[76]!==E||e[77]!==Re||e[78]!==S?(Z=E&&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(ks,{open:W,onOpenChange:k,children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(Ss,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ue,title:S("sidebarFilesTree.actions.fileMenuTitle"),"aria-label":S("sidebarFilesTree.actions.fileMenuTitle"),children:s.jsx(B,{name:"more-2-fill",className:"h-4 w-4"})})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:S("sidebarFilesTree.actions.fileMenuTitle")})]}),s.jsx(js,{align:"end",side:"bottom",onCloseAutoFocus:()=>k(!1),children:Re({Item:zt,Separator:ps})})]})}),e[75]=W,e[76]=E,e[77]=Re,e[78]=S,e[79]=Z):Z=e[79];let G;e[80]!==xe||e[81]!==V||e[82]!==Z?(G=s.jsxs(Qd,{render:xe,children:[V,Z]}),e[80]=xe,e[81]=V,e[82]=Z,e[83]=G):G=e[83];let ie;e[84]!==Re?(ie=s.jsx(Yd,{className:"min-w-[180px]",children:Re({Item:Ln,Separator:Wi})}),e[84]=Re,e[85]=ie):ie=e[85];let je;return e[86]!==v||e[87]!==G||e[88]!==ie?(je=s.jsxs(Xd,{open:v,onOpenChange:I,children:[G,ie]}),e[86]=v,e[87]=G,e[88]=ie,e[89]=je):je=e[89],je},tw=(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,sw=c.memo(ew,tw),nw=t=>{const e=nt.c(6),{visible:n}=t,r=n===void 0?!0:n,i=Xn(ow),o=Yn();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(rw,{visible:r},l),e[3]=l,e[4]=r,e[5]=a):a=e[5],a},rw=({visible:t})=>{const e=c.useRef(t);e.current=t;const{t:n}=At(),{files:r,runtime:i}=bn(),o=eh(i.platform),l=Yn()??"",a=rs(l.trim()),d=Xa(a),u=th(),m=sh(),f=$d(be=>be.searchFiles),g=ye(be=>be.openContextFile),x=Ma(t?l:null),[b,j]=c.useState(""),y=Cu(b,200),h=c.useRef(null),[p,w]=c.useState([]),[S,N]=c.useState(!1),[P,C]=c.useState(null),[T,O]=c.useState({}),[M,F]=c.useState({}),K=c.useRef(new Set),D=c.useMemo(()=>new bx,[]);c.useEffect(()=>()=>D.clear(),[D]);const U=c.useRef(null);c.useEffect(()=>{if(C(null),!a){O({}),F({}),K.current=new Set;return}const be=J1(a);be?(O({...be.childrenByDir}),F({...be.loadErrorsByDir}),K.current=new Set(be.loadedDirs)):(O({}),F({}),K.current=new Set)},[a]),c.useEffect(()=>{if(!a)return;const be=Ii(a);be.childrenByDir=T},[a,T]),c.useEffect(()=>{if(!a)return;const be=Ii(a);be.loadErrorsByDir=M},[a,M]),c.useEffect(()=>{if(!a)return;const be=Ii(a);be.loadedDirs=new Set(K.current)},[a,T,M]),c.useEffect(()=>()=>{if(!a)return;const be=Js.get(d);be&&be.loadedDirs.size===0&&Object.keys(be.childrenByDir).length===0&&Js.delete(d)},[d,a]);const A=c.useMemo(()=>[],[]),E=c.useMemo(()=>[],[]),W=Xs(be=>a?be.byRoot[a]?.expandedPaths??A:A),k=c.useMemo(()=>new Set(W),[W]),v=Xs(be=>a?be.byRoot[a]?.selectedPath??null:null),I=Xs(be=>be.setSelectedPath),H=Xs(be=>be.addOpenPath),_=Xs(be=>be.removeOpenPathsByPrefix),se=Xs(be=>be.toggleExpandedPath),te=Xs(be=>be.collapseAllExpandedPaths),ee=ye(be=>a?be.contextPanelByDirectory[a]?.tabs??E:E),ue=c.useMemo(()=>new Set(ee.map(be=>be.mode==="file"?be.targetPath:null).filter(be=>typeof be=="string"&&be.length>0).map(be=>rs(be))),[ee]),[de,Re]=c.useState(null),[we,fe]=c.useState(null),[Pe,L]=c.useState(""),[oe,ce]=c.useState(!1),he=!!r.writeFile,Y=!!r.createDirectory,ve=!!r.rename,Te=!!r.delete,ke=!!r.revealPath,xe=c.useMemo(()=>({canRename:ve,canCreateFile:he,canCreateFolder:Y,canDelete:Te,canReveal:ke}),[ve,he,Y,Te,ke]),ge=c.useCallback(be=>{r.revealPath&&r.revealPath(be).catch(()=>{Fe.error(n("sidebarFilesTree.toast.revealFailed"))})},[r,n]),Q=c.useCallback((be,qe)=>{Re(be),fe(qe),L(be==="rename"&&qe.name||""),ce(!1)},[]),$=c.useCallback((be,qe)=>{const Ye=qe.filter(Ue=>Ue&&typeof Ue.name=="string"&&Ue.name.length>0).filter(Ue=>u||!Ue.name.startsWith(".")).filter(Ue=>m||!Y1(Ue.name)).map(Ue=>{const ct=Ue.name,X=rs(Ue.path||""),ae=X?G1(X)?X:rs(`${be}/${X}`):rs(`${be}/${ct}`),De=Ue.isDirectory?"directory":"file",Ke=De==="file"&&ct.includes(".")?ct.split(".").pop()?.toLowerCase():void 0;return{name:ct,path:ae,type:De,extension:Ke}});return V1(Ye)},[m,u]),J=c.useCallback(async(be,qe,Ye=!1)=>{if(!e.current||qe?.())return;const Ue=rs(be.trim());if(!Ue||!Ye&&K.current.has(Ue))return;const ct=Yt();return D.run(Ue,async X=>{const ae=()=>!X()||Yt()!==ct;try{const De=r.listDirectory?(await r.listDirectory(Ue)).entries:await mr.listLocalDirectory(Ue);if(ae())return;const Ke=$(Ue,De);K.current=new Set(K.current),K.current.add(Ue),F(q=>{if(!q[Ue])return q;const Be={...q};return delete Be[Ue],Be}),O(q=>q[Ue]&&xx(q[Ue],Ke)?q:{...q,[Ue]:Ke})}catch(De){if(ae())return;const Ke=De instanceof Error?De.message:String(De??"");console.error("Failed to load sidebar directory:",De),F(q=>({...q,[Ue]:Ke}))}},Ye)},[D,r,$]),me=c.useCallback(async()=>{if(!a)return;U.current?.abort();const be=new AbortController;U.current=be,D.clear();try{const Ye=(Xs.getState().byRoot[a]?.expandedPaths??[]).map(X=>rs(X)).filter(X=>!!X&&X!==a&&X.startsWith(`${a}/`)),Ue=[a,...Ye];K.current=new Set(K.current);for(const X of Ue)K.current.delete(X);F(X=>{if(Object.keys(X).length===0)return X;const ae={...X};let De=!1;for(const Ke of Ue)Ke in ae&&(delete ae[Ke],De=!0);return De?ae:X});const ct=()=>be.signal.aborted;await J(a,ct);for(let X=0;X<Ye.length&&!be.signal.aborted;X+=3){const ae=Ye.slice(X,X+3);await Promise.all(ae.map(De=>J(De,ct)))}}catch(qe){if(be.signal.aborted)return;console.error("Failed to refresh sidebar tree:",qe)}finally{U.current===be&&(U.current=null)}},[D,J,a]),le=c.useCallback(async be=>{if(!be){await me();return}const qe=rs(be);K.current=new Set(K.current),K.current.delete(qe),await J(qe,void 0,!0)},[J,me]);c.useEffect(()=>{a&&(U.current?.abort(),K.current=new Set,D.clear(),F({}),O(be=>Object.keys(be).length===0?be:{}),J(a))},[D,J,a,u,m]),c.useEffect(()=>{if(!t||!a||W.length===0)return;const be=W.map(Ue=>rs(Ue)).filter(Ue=>!!Ue&&Ue!==a&&Ue.startsWith(`${a}/`)&&!K.current.has(Ue)&&!D.has(Ue)).sort((Ue,ct)=>Ue.split("/").length-ct.split("/").length);if(be.length===0)return;let qe=!1;const Ye=()=>qe;return(async()=>{for(let Ue=0;Ue<be.length&&!qe;Ue+=3){const ct=be.slice(Ue,Ue+3);await Promise.all(ct.map(X=>J(X,Ye)))}})(),()=>{qe=!0}},[D,W,J,a,t]);const V=c.useRef(t);c.useEffect(()=>{const be=t&&!V.current;V.current=t,be&&me()},[me,t]),c.useEffect(()=>{if(!t)return;if(!l){w([]),N(!1);return}const be=y.trim();if(!be){w([]),N(!1);return}let qe=!1;return N(!0),f(l,be,150,{includeHidden:u,respectGitignore:!m,type:"file"}).then(Ye=>{if(qe)return;const ct=Ye.filter(X=>m||!Q1(X.path)).map(X=>({name:X.name,path:rs(X.path),type:"file",extension:X.extension,relativePath:X.relativePath}));w(ct)}).catch(()=>{qe||w([])}).finally(()=>{qe||N(!1)}),()=>{qe=!0}},[l,y,f,u,m,t]);const Z=c.useMemo(()=>{const be=new Map;if(!x?.files)return be;for(const qe of x.files)qe.index==="A"||qe.working_dir==="?"?be.set(qe.path,"git-added"):qe.index==="D"?be.set(qe.path,"git-deleted"):(qe.index==="M"||qe.working_dir==="M")&&be.set(qe.path,"git-modified");return be},[x]),G=c.useMemo(()=>{const be=new Map;if(!x?.files||!a)return be;for(const qe of x.files){const Ye=qe.index==="M"||qe.working_dir==="M",Ue=qe.index==="A"||qe.working_dir==="?";if(!Ye&&!Ue)continue;const ct=qe.path.split("/");if(ct.length<=1)continue;let X=a;for(let ae=0;ae<ct.length-1;ae++){X=`${X}/${ct[ae]}`;let De=be.get(X);De||(De={modified:0,added:0},be.set(X,De)),Ye&&De.modified++,Ue&&De.added++}}return be},[x,a]),ie=c.useCallback(be=>{if(ue.has(be))return"open";if(Z.size===0)return null;const qe=be.startsWith(a+"/")?be.slice(a.length+1):be;return Z.get(qe)??null},[ue,Z,a]),je=c.useCallback(be=>{if(G.size===0)return null;const qe=G.get(be);return qe&&qe.modified+qe.added>0?qe:null},[G]),ne=c.useCallback(async be=>{if(!a)return;const qe=await yf(r,be.path,{directory:a});if(!qe.ok){Fe.error(wf(qe.reason));return}I(a,be.path),H(a,be.path),g(a,be.path)},[H,r,g,a,I]),Oe=c.useCallback(async be=>{const qe=rs(be);a&&(se(a,qe),K.current.has(qe)||await J(qe))},[J,a,se]),{canUpload:Ve,uploadingDirectory:ze,uploadFiles:He,pickFiles:$e,uploadElements:R}=Lh({root:a,refreshDirectory:le}),pe=ze!==null,Le=ze??P,_e=c.useCallback((be,qe)=>{const Ye=K1(qe);Ye.length!==0&&(C(null),He(be,Ye))},[He]),lt=c.useCallback(be=>{!Ve||pe||!a||!pr(be.dataTransfer)||(be.preventDefault(),be.dataTransfer.dropEffect="copy",C(a))},[Ve,pe,a]),ht=c.useCallback(be=>{pr(be.dataTransfer)&&(be.relatedTarget instanceof Node&&be.currentTarget.contains(be.relatedTarget)||C(null))},[]),ot=c.useCallback(be=>{!Ve||pe||!a||!pr(be.dataTransfer)||(be.preventDefault(),_e(a,be.dataTransfer))},[Ve,_e,pe,a]),ut=c.useCallback(async be=>{if(be?.preventDefault(),!we||!de)return;ce(!0);const qe=()=>ce(!1),Ye=()=>Re(null);if(de==="createFile"){if(!Pe.trim()){Fe.error(n("sidebarFilesTree.toast.filenameRequired")),qe();return}if(!r.writeFile){Fe.error(n("sidebarFilesTree.toast.writeNotSupported")),qe();return}const Ue=we.path,ct=Ue?`${Ue}/`:"",X=rs(`${ct}${Pe.trim()}`);await r.writeFile(X,"").then(async ae=>{ae.success&&(Fe.success(n("sidebarFilesTree.toast.fileCreated")),await le(Ue)),Ye()}).catch(()=>Fe.error(n("sidebarFilesTree.toast.operationFailed"))).finally(qe);return}if(de==="createFolder"){if(!Pe.trim()){Fe.error(n("sidebarFilesTree.toast.folderNameRequired")),qe();return}const Ue=we.path,ct=Ue?`${Ue}/`:"",X=rs(`${ct}${Pe.trim()}`);await r.createDirectory(X).then(async ae=>{ae.success&&(Fe.success(n("sidebarFilesTree.toast.folderCreated")),await le(Ue)),Ye()}).catch(()=>Fe.error(n("sidebarFilesTree.toast.operationFailed"))).finally(qe);return}if(de==="rename"){if(!Pe.trim()){Fe.error(n("sidebarFilesTree.toast.nameRequired")),qe();return}if(!r.rename){Fe.error(n("sidebarFilesTree.toast.renameNotSupported")),qe();return}const Ue=we.path,ct=Ue.split("/").slice(0,-1).join("/"),X=ct?`${ct}/`:"",ae=rs(`${X}${Pe.trim()}`);await r.rename(Ue,ae).then(async De=>{De.success&&(Fe.success(n("sidebarFilesTree.toast.renamedSuccessfully")),await le(ct),a&&_(a,Ue),(v===Ue||v&&v.startsWith(`${Ue}/`))&&I(a,null)),Ye()}).catch(()=>Fe.error(n("sidebarFilesTree.toast.operationFailed"))).finally(qe);return}if(de==="delete"){if(!r.delete){Fe.error(n("sidebarFilesTree.toast.deleteNotSupported")),qe();return}const Ue=we.path,ct=Ue.split("/").slice(0,-1).join("/");await r.delete(Ue).then(async X=>{X.success&&(Fe.success(n("sidebarFilesTree.toast.deletedSuccessfully")),await le(ct),a&&_(a,Ue),(v===Ue||v&&v.startsWith(Ue+"/"))&&I(a,null)),Ye()}).catch(()=>Fe.error(n("sidebarFilesTree.toast.operationFailed"))).finally(qe);return}qe()},[de,we,Pe,r,le,_,a,v,I,n]);function yt(be,qe){const Ye=T[be]??[];return Ye.map((Ue,ct)=>{const X=Ue.type==="directory",ae=X&&k.has(Ue.path),De=v===Ue.path,Ke=ct===Ye.length-1;return s.jsxs("li",{className:"relative",children:[qe>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Ke&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),s.jsx(sw,{node:Ue,root:a,isExpanded:ae,isActive:De,isBrowserClient:o,status:X?void 0:ie(Ue.path),badge:X?je(Ue.path):void 0,isDropTarget:X&&Le===Ue.path,canUpload:Ve&&!pe,permissions:xe,downloadFile:r.downloadFile,onSelect:ne,onToggle:Oe,onRevealPath:ge,onOpenDialog:Q,onSetDropTarget:C,onDropFiles:_e,onPickFiles:$e}),X&&ae&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[M[Ue.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:M[Ue.path],children:M[Ue.path]}),s.jsxs(ft,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{le(Ue.path)},children:[s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):null,yt(Ue.path,qe+1)]})]},Ue.path)})}const mt=!!(a&&T[a]),xt=a?M[a]:null,Dt=Le?U1(a,Le):"";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:[he&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>Q("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(B,{name:"file-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFileTitle")})]}),Y&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>Q("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(B,{name:"folder-add",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.newFolderTitle")})]}),Ve&&s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>$e(a),disabled:!a||pe,className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":n("sidebarFilesTree.actions.uploadFilesTitle"),children:s.jsx(B,{name:"upload-2",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.uploadFilesTitle")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>{me()},className:"h-8 w-8 p-0 flex-shrink-0",title:n("sidebarFilesTree.actions.refreshTitle"),"aria-label":n("sidebarFilesTree.actions.refreshTitle"),children:s.jsx(B,{name:"refresh",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.refreshTitle")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(ft,{variant:"ghost",size:"sm",onClick:()=>{a&&te(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(B,{name:"collapse-vertical",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:6,children:n("sidebarFilesTree.actions.collapseAllTitle")})]})]}),s.jsxs("div",{className:"relative min-w-0",children:[s.jsx(B,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),s.jsx(Wn,{ref:h,value:b,onChange:be=>j(be.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:()=>{j(""),h.current?.focus()},children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null]})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx(xn,{outerClassName:"h-full min-h-0",className:Ie("p-2",Le===a&&"bg-interactive-selection/10"),onDragEnter:lt,onDragOver:lt,onDragLeave:ht,onDrop:ot,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(B,{name:"loader-4",className:"h-4 w-4 animate-spin"}),n("sidebarFilesTree.state.searching")]}):p.length>0?p.map(be=>{const qe=v===be.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>ne(be),draggable:!0,onDragStart:Ye=>{vf(Ye);const Ue=be.relativePath||Qa(a??"",be.path);!Ue||Ue==="."||(Ye.dataTransfer.setData("application/x-openchamber-file-path",Ue),Ye.dataTransfer.effectAllowed="copy")},onDragEnd:Ye=>{Sf(Ye)&&ne(be)},className:Ie("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",qe?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:be.path,children:[jf(be.path,be.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:be.relativePath??be.path})]})},be.path)}):xt?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{children:xt}),s.jsxs(ft,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{me()},children:[s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"}),n("sidebarFilesTree.actions.refreshTitle")]})]}):mt&&a?yt(a,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:n("sidebarFilesTree.state.loading")})})}),Le?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(B,{name:pe?"loader-4":"folder-received",className:Ie("size-4 flex-shrink-0",pe&&"animate-spin")}),s.jsx("span",{className:"min-w-0 truncate typography-meta",title:Dt,children:n(pe?"sidebarFilesTree.drop.uploading":"sidebarFilesTree.drop.target",{path:Dt})})]}):null]}),R,s.jsx(Cs,{open:!!de,onOpenChange:be=>!be&&Re(null),children:s.jsxs(Ns,{children:[s.jsxs(Hs,{children:[s.jsxs(Ls,{children:[de==="createFile"&&n("sidebarFilesTree.dialog.createFile.title"),de==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.title"),de==="rename"&&n("sidebarFilesTree.dialog.rename.title"),de==="delete"&&n("sidebarFilesTree.dialog.delete.title")]}),s.jsxs(_s,{children:[de==="createFile"&&n("sidebarFilesTree.dialog.createFile.description",{path:we?.path??n("sidebarFilesTree.dialog.rootFallback")}),de==="createFolder"&&n("sidebarFilesTree.dialog.createFolder.description",{path:we?.path??n("sidebarFilesTree.dialog.rootFallback")}),de==="rename"&&n("sidebarFilesTree.dialog.rename.description",{name:we?.name??""}),de==="delete"&&n("sidebarFilesTree.dialog.delete.description",{name:we?.name??""})]})]}),de!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Wn,{value:Pe,onChange:be=>L(be.target.value),placeholder:n(de==="rename"?"sidebarFilesTree.dialog.rename.placeholder":"sidebarFilesTree.dialog.namePlaceholder"),onKeyDown:be=>{be.key==="Enter"&&ut()},autoFocus:!0})}),s.jsxs(Qn,{children:[s.jsx(ft,{variant:"outline",onClick:()=>Re(null),disabled:oe,children:n("sidebarFilesTree.dialog.cancel")}),s.jsx(ft,{variant:de==="delete"?"destructive":"default",onClick:()=>{ut()},disabled:oe||de!=="delete"&&!Pe.trim(),children:oe?s.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):n(de==="delete"?"sidebarFilesTree.dialog.delete.confirm":"sidebarFilesTree.dialog.confirm")})]})]})})]})};function ow(t){return t.runtimeKey}const bc=60,iw=t=>{try{return new URL(t).origin}catch{return""}},Ti=new Set,kf=Jr()((t,e)=>({byOrigin:{},resolve:(n,r)=>{const i=iw(n);!i||!r||e().byOrigin[i]||Ti.has(i)||(Ti.add(i),hr("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<=bc)return{byOrigin:d};for(const m of u.slice(0,u.length-bc))delete d[m];return{byOrigin:d}})}).catch(()=>{}).finally(()=>{Ti.delete(i)}))}})),Ja=t=>t,la=t=>{const e=Ja(t).type;return typeof e=="string"?e:""},aw=t=>{const e=Ja(t).tool;return typeof e=="string"?e:""},lw=t=>{const e=Ja(t).text;return typeof e=="string"?e:""},cw=t=>{const e=la(t);return e==="tool"?aw(t).trim().toLowerCase()||"tool":e||"unknown"},dw=t=>{if(t.length===0)return"";const e=[];for(const n of t){const r=cw(n);e.includes(r)||e.push(r)}return e.join(" + ")},uw=t=>t.replace(/\s+/g," ").trim(),fw=t=>{for(const n of t)if(la(n)==="text"){const r=uw(lw(n));if(r.length===0)continue;return r}const e=t.filter(n=>la(n)!=="text").length;return e===0?"":`${e} attachment${e===1?"":"s"}`},mw=(t,e,n)=>`${n(t)} / ${n(e)}`,hw=t=>{if(t==="12h")return!0;if(t==="24h")return!1},pw=(t,e)=>{if(!t||!Number.isFinite(t))return"-";const n=hw(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}})},ca={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Io={user:0,assistant:0,tool:0,other:0},kn=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,xc=t=>{const e=t.info.tokens,n=e!==void 0?e:t.parts.find(m=>m.tokens!==void 0)?.tokens;if(typeof n=="number")return{...ca,total:kn(n)};if(!n||typeof n!="object")return ca;const r=n,i=kn(r.input),o=kn(r.output),l=kn(r.reasoning),a=kn(r.cache?.read),d=kn(r.cache?.write),u=kn(r.total);return{input:i,output:o,reasoning:l,cacheRead:a,cacheWrite:d,total:u>0?u:i+o+l+a+d}},gw=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim().length>0)return e;return""},As=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((e,n)=>e+As(n),0):t&&typeof t=="object"?Object.values(t).reduce((e,n)=>e+As(n),0):0,bw=(t,e)=>{const n=t,r=typeof n.type=="string"?n.type:"";if(r==="reasoning")return{...Io,assistant:As(n.text)+As(n.content)};const i=gw(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r==="tool"||e==="tool"?{user:0,assistant:0,tool:As(n.input)+As(n.output)+As(n.error)+As(n.call?.input)+As(n.call?.output)+As(n.call?.error)+As(n.raw)+Math.round(As(n.metadata)*.25)+Math.round(As(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}},yc=(t,e)=>({user:t.user+e.user,assistant:t.assistant+e.assistant,tool:t.tool+e.tool,other:t.other+e.other}),xw=t=>t.info.role==="user"?"user":t.info.role==="assistant"?"assistant":"other",yw=(t,e)=>{if(t.length===0)return{...Io};const n=t.reduce((r,i)=>{const o=xw(i);let l={...Io};for(const a of i.parts)l=yc(l,bw(a,o));return yc(r,l)},{...Io});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)}},On=t=>t.toLocaleString(ku()),ww=(t,e)=>!t||!Number.isFinite(t)?"-":vu(t,e,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),vw=(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}},Sw=()=>{const t=nt.c(209),{t:e}=At(),n=ye(jw);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=rt(kw),m=rt(Cw),f=Nu(m??void 0),g=ug(u??"",m??void 0),x=Vt(Nw);let b;t[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null),o(Aw),a(null)},t[1]=b):b=t[1];let j;t[2]!==m||t[3]!==u?(j=[m,u],t[2]=m,t[3]=u,t[4]=j):j=t[4],c.useEffect(b,j);let y,h;t[5]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},h=[],t[5]=y,t[6]=h):(y=t[5],h=t[6]),c.useEffect(y,h);let p;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=async(Xe,Ne)=>{(await Gn(Ne)).ok?(a(Xe),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{a(dt=>dt===Xe?null:dt),d.current=null},2e3)):a(null)},t[7]=p):p=t[7];const w=p;let S;t[8]!==u||t[9]!==f?(S=u?f.find(Xe=>Xe.id===u)??null:null,t[8]=u,t[9]=f,t[10]=S):S=t[10];const N=S;let P,C,T,O,M,F,K;if(t[11]!==g){P=g.filter(Pw),K=g.filter(Dw);const Xe=fg(g.map(Iw));T=Xe?g[Xe.index]??null:null,O=Xe?.state==="compacted";let Ne;t[19]!==T?(F=T?xc(T):ca,Ne=mg({input:F.input,cache:{read:F.cacheRead,write:F.cacheWrite}}),t[19]=T,t[20]=Ne,t[21]=F):(Ne=t[20],F=t[21]),C=Ne,M=P.reduce(Tw,0),t[11]=g,t[12]=P,t[13]=C,t[14]=T,t[15]=O,t[16]=M,t[17]=F,t[18]=K}else P=t[12],C=t[13],T=t[14],O=t[15],M=t[16],F=t[17],K=t[18];const D=M,U=T?.info??null,A=x,E=U?.providerID||"",W=U?.modelID||"";let k;t[22]!==W||t[23]!==A||t[24]!==E?(k=vw(A,E,W),t[22]=W,t[23]=A,t[24]=E,t[25]=k):k=t[25];const v=k,I=v.contextLimit,H=O?null:I&&I>0?Math.min(999,F.total/I*100):0;let _;if(t[26]!==g){const Xe=[...g].reverse().find(Ew),Ne=Xe?.info.role==="system"?Xe.info.text:"";_=yw(g,Ne),t[26]=g,t[27]=_}else _=t[27];const se=_,te=se.user,ee=se.assistant,ue=se.tool,de=Math.max(0,F.input-te-ee-ue),Re=te+ee+ue+de,we=g[0]?.info?.time?.created,fe=g.length>0?g[g.length-1]?.info?.time?.created:null;let Pe;t[28]!==N?.title||t[29]!==e?(Pe=N?.title||e("contextSidebar.session.untitled"),t[28]=N?.title,t[29]=e,t[30]=Pe):Pe=t[30];const L=N?.time?.created??we??null,oe=fe??N?.time?.created??null;let ce;t[31]!==ee||t[32]!==de||t[33]!==ue||t[34]!==te?(ce={user:te,assistant:ee,tool:ue,other:de},t[31]=ee,t[32]=de,t[33]=ue,t[34]=te,t[35]=ce):ce=t[35];let he;t[36]!==P.length||t[37]!==Re||t[38]!==C||t[39]!==I||t[40]!==v||t[41]!==g.length||t[42]!==Pe||t[43]!==L||t[44]!==oe||t[45]!==ce||t[46]!==F||t[47]!==D||t[48]!==H||t[49]!==K.length?(he={sessionTitle:Pe,messagesCount:g.length,userMessagesCount:K.length,assistantMessagesCount:P.length,createdAt:L,lastActivityAt:oe,providerModel:v,tokenBreakdown:F,usagePercent:H,cacheHitRate:C,totalAssistantCost:D,contextLimit:I,breakdown:ce,breakdownTotal:Re},t[36]=P.length,t[37]=Re,t[38]=C,t[39]=I,t[40]=v,t[41]=g.length,t[42]=Pe,t[43]=L,t[44]=oe,t[45]=ce,t[46]=F,t[47]=D,t[48]=H,t[49]=K.length,t[50]=he):he=t[50];const Y=he;if(!u){let Xe;t[51]!==e?(Xe=e("contextSidebar.empty.openSession"),t[51]=e,t[52]=Xe):Xe=t[52];let Ne;return t[53]!==Xe?(Ne=s.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:Xe}),t[53]=Xe,t[54]=Ne):Ne=t[54],Ne}let ve;t[55]!==e?(ve=e("contextSidebar.breakdown.user"),t[55]=e,t[56]=ve):ve=t[56];let Te;t[57]!==ve||t[58]!==Y.breakdown.user?(Te={key:"user",label:ve,value:Y.breakdown.user,color:"var(--status-success)"},t[57]=ve,t[58]=Y.breakdown.user,t[59]=Te):Te=t[59];let ke;t[60]!==e?(ke=e("contextSidebar.breakdown.assistant"),t[60]=e,t[61]=ke):ke=t[61];let xe;t[62]!==ke||t[63]!==Y.breakdown.assistant?(xe={key:"assistant",label:ke,value:Y.breakdown.assistant,color:"var(--primary-base)"},t[62]=ke,t[63]=Y.breakdown.assistant,t[64]=xe):xe=t[64];let ge;t[65]!==e?(ge=e("contextSidebar.breakdown.toolCalls"),t[65]=e,t[66]=ge):ge=t[66];let Q;t[67]!==ge||t[68]!==Y.breakdown.tool?(Q={key:"tool",label:ge,value:Y.breakdown.tool,color:"var(--status-warning)"},t[67]=ge,t[68]=Y.breakdown.tool,t[69]=Q):Q=t[69];let $;t[70]!==e?($=e("contextSidebar.breakdown.other"),t[70]=e,t[71]=$):$=t[71];let J;t[72]!==$||t[73]!==Y.breakdown.other?(J={key:"other",label:$,value:Y.breakdown.other,color:"var(--surface-muted-foreground)"},t[72]=$,t[73]=Y.breakdown.other,t[74]=J):J=t[74];let me;t[75]!==Te||t[76]!==xe||t[77]!==Q||t[78]!==J?(me=[Te,xe,Q,J],t[75]=Te,t[76]=xe,t[77]=Q,t[78]=J,t[79]=me):me=t[79];const le=me;let V;t[80]!==Y.sessionTitle?(V=s.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:Y.sessionTitle}),t[80]=Y.sessionTitle,t[81]=V):V=t[81];let Z;t[82]!==Y.providerModel.modelName||t[83]!==Y.providerModel.providerName?(Z=s.jsxs("span",{children:[Y.providerModel.providerName," / ",Y.providerModel.modelName]}),t[82]=Y.providerModel.modelName,t[83]=Y.providerModel.providerName,t[84]=Z):Z=t[84];let G;t[85]!==n||t[86]!==Y.createdAt?(G=Y.createdAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsx("span",{children:ww(Y.createdAt,n)})]}),t[85]=n,t[86]=Y.createdAt,t[87]=G):G=t[87];let ie;t[88]!==Z||t[89]!==G?(ie=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:[Z,G]}),t[88]=Z,t[89]=G,t[90]=ie):ie=t[90];let je;t[91]!==V||t[92]!==ie?(je=s.jsxs("div",{className:"mb-6",children:[V,ie]}),t[91]=V,t[92]=ie,t[93]=je):je=t[93];let ne;t[94]!==e?(ne=e("contextSidebar.section.context"),t[94]=e,t[95]=ne):ne=t[95];let Oe;t[96]!==ne?(Oe=s.jsx("span",{className:"typography-micro text-muted-foreground",children:ne}),t[96]=ne,t[97]=Oe):Oe=t[97];let Ve;t[98]!==Y.tokenBreakdown.total||t[99]!==Y.usagePercent?(Ve=Y.usagePercent===null?"—":On(Y.tokenBreakdown.total),t[98]=Y.tokenBreakdown.total,t[99]=Y.usagePercent,t[100]=Ve):Ve=t[100];let ze;t[101]!==Y.contextLimit?(ze=Y.contextLimit?` / ${On(Y.contextLimit)}`:"",t[101]=Y.contextLimit,t[102]=ze):ze=t[102];let He;t[103]!==Ve||t[104]!==ze?(He=s.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground/70",children:[Ve,ze]}),t[103]=Ve,t[104]=ze,t[105]=He):He=t[105];let $e;t[106]!==Oe||t[107]!==He?($e=s.jsxs("div",{className:"flex items-baseline justify-between",children:[Oe,He]}),t[106]=Oe,t[107]=He,t[108]=$e):$e=t[108];let R;t[109]!==Y.usagePercent?(R=Y.usagePercent!==null&&Y.usagePercent>0&&s.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,Y.usagePercent)}%`,backgroundColor:Y.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}}),t[109]=Y.usagePercent,t[110]=R):R=t[110];let pe;t[111]!==R?(pe=s.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:R}),t[111]=R,t[112]=pe):pe=t[112];let Le;t[113]!==e||t[114]!==Y.usagePercent?(Le=Y.usagePercent===null?e("contextUsage.compacted.description"):e("contextSidebar.context.percentUsed",{percent:Y.usagePercent.toFixed(1)}),t[113]=e,t[114]=Y.usagePercent,t[115]=Le):Le=t[115];let _e;t[116]!==Le?(_e=s.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:Le}),t[116]=Le,t[117]=_e):_e=t[117];let lt;t[118]!==$e||t[119]!==pe||t[120]!==_e?(lt=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[$e,pe,_e]}),t[118]=$e,t[119]=pe,t[120]=_e,t[121]=lt):lt=t[121];let ht;t[122]!==e?(ht=e("contextSidebar.stats.messages"),t[122]=e,t[123]=ht):ht=t[123];let ot;t[124]!==Y.messagesCount?(ot=On(Y.messagesCount),t[124]=Y.messagesCount,t[125]=ot):ot=t[125];let ut;t[126]!==ht||t[127]!==ot?(ut={label:ht,value:ot},t[126]=ht,t[127]=ot,t[128]=ut):ut=t[128];let yt;t[129]!==e?(yt=e("contextSidebar.stats.user"),t[129]=e,t[130]=yt):yt=t[130];let mt;t[131]!==Y.userMessagesCount?(mt=On(Y.userMessagesCount),t[131]=Y.userMessagesCount,t[132]=mt):mt=t[132];let xt;t[133]!==yt||t[134]!==mt?(xt={label:yt,value:mt},t[133]=yt,t[134]=mt,t[135]=xt):xt=t[135];let Dt;t[136]!==e?(Dt=e("contextSidebar.stats.assistant"),t[136]=e,t[137]=Dt):Dt=t[137];let be;t[138]!==Y.assistantMessagesCount?(be=On(Y.assistantMessagesCount),t[138]=Y.assistantMessagesCount,t[139]=be):be=t[139];let qe;t[140]!==Dt||t[141]!==be?(qe={label:Dt,value:be},t[140]=Dt,t[141]=be,t[142]=qe):qe=t[142];let Ye;t[143]!==e?(Ye=e("contextSidebar.stats.cost"),t[143]=e,t[144]=Ye):Ye=t[144];let Ue;t[145]!==Y.totalAssistantCost?(Ue=mx(Y.totalAssistantCost),t[145]=Y.totalAssistantCost,t[146]=Ue):Ue=t[146];let ct;t[147]!==Ye||t[148]!==Ue?(ct={label:Ye,value:Ue},t[147]=Ye,t[148]=Ue,t[149]=ct):ct=t[149];let X;t[150]!==ut||t[151]!==xt||t[152]!==qe||t[153]!==ct?(X=[ut,xt,qe,ct],t[150]=ut,t[151]=xt,t[152]=qe,t[153]=ct,t[154]=X):X=t[154];const ae=X;let De;t[155]!==ae?(De=s.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:ae.map(Rw)}),t[155]=ae,t[156]=De):De=t[156];let Ke;t[157]!==e?(Ke=e("contextSidebar.section.lastAssistantMessage"),t[157]=e,t[158]=Ke):Ke=t[158];let q;t[159]!==Ke?(q=s.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:Ke}),t[159]=Ke,t[160]=q):q=t[160];let Be;t[161]!==e||t[162]!==Y.cacheHitRate.hasInput||t[163]!==Y.cacheHitRate.percent||t[164]!==Y.tokenBreakdown.cacheRead||t[165]!==Y.tokenBreakdown.cacheWrite||t[166]!==Y.tokenBreakdown.input||t[167]!==Y.tokenBreakdown.output||t[168]!==Y.tokenBreakdown.reasoning?(Be=s.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:e("contextSidebar.tokens.input"),value:Y.tokenBreakdown.input,format:"count"},{label:e("contextSidebar.tokens.output"),value:Y.tokenBreakdown.output,format:"count"},{label:e("contextSidebar.tokens.reasoning"),value:Y.tokenBreakdown.reasoning,format:"count"},{label:e("contextSidebar.tokens.cacheRead"),value:Y.tokenBreakdown.cacheRead,format:"count"},{label:e("contextSidebar.tokens.cacheWrite"),value:Y.tokenBreakdown.cacheWrite,format:"count"},{label:e("contextSidebar.tokens.cacheHit"),value:Y.cacheHitRate.hasInput?Y.cacheHitRate.percent:null,format:"percent"}].map(Mw)}),t[161]=e,t[162]=Y.cacheHitRate.hasInput,t[163]=Y.cacheHitRate.percent,t[164]=Y.tokenBreakdown.cacheRead,t[165]=Y.tokenBreakdown.cacheWrite,t[166]=Y.tokenBreakdown.input,t[167]=Y.tokenBreakdown.output,t[168]=Y.tokenBreakdown.reasoning,t[169]=Be):Be=t[169];let Ze;t[170]!==q||t[171]!==Be?(Ze=s.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[q,Be]}),t[170]=q,t[171]=Be,t[172]=Ze):Ze=t[172];let Qe;t[173]!==le||t[174]!==Y.breakdownTotal?(Qe=s.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:le.map(Xe=>Xe.value<=0||Y.breakdownTotal<=0?null:s.jsx("div",{style:{width:`${Xe.value/Y.breakdownTotal*100}%`,backgroundColor:Xe.color}},Xe.key))}),t[173]=le,t[174]=Y.breakdownTotal,t[175]=Qe):Qe=t[175];let et;t[176]!==le||t[177]!==Y.breakdownTotal?(et=s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:le.map(Xe=>{const Ne=Y.breakdownTotal>0?Xe.value/Y.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:Xe.color}}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[Xe.label," ",s.jsxs("span",{className:"tabular-nums",children:[Ne.toFixed(0),"%"]})]})]},Xe.key)})}),t[176]=le,t[177]=Y.breakdownTotal,t[178]=et):et=t[178];let Ct;t[179]!==Qe||t[180]!==et?(Ct=s.jsxs("div",{className:"mb-6",children:[Qe,et]}),t[179]=Qe,t[180]=et,t[181]=Ct):Ct=t[181];let Ge;t[182]!==e?(Ge=e("contextSidebar.section.rawMessages"),t[182]=e,t[183]=Ge):Ge=t[183];let Tt;t[184]!==Ge?(Tt=s.jsx("div",{className:"typography-micro text-muted-foreground",children:Ge}),t[184]=Ge,t[185]=Tt):Tt=t[185];let Bt;if(t[186]!==l||t[187]!==i||t[188]!==g||t[189]!==e||t[190]!==n){let Xe;t[192]!==l||t[193]!==i||t[194]!==e||t[195]!==n?(Xe=Ne=>{const We=Ne.info.role,dt=We==="assistant",bt=We==="user",Se=i[Ne.info.id]===!0,Je=l===Ne.info.id,it=Ne.info.time?.created??null,pt=dw(Ne.parts),kt=dt?xc({info:Ne.info,parts:Ne.parts}):null,_t=bt?fw(Ne.parts):"",qt=pw(it,n),Mt=pt||"—",Lt=kt?mw(kt.input,kt.output,On):"",Wt=We||"unknown",Jt=pt?`${Wt}: ${pt}`:Wt,Zt=Se?JSON.stringify({info:Ne.info,parts:Ne.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":Se,onClick:()=>{o(Ft=>({...Ft,[Ne.info.id]:Ft[Ne.info.id]!==!0}))},children:s.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:dt?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[bt?s.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",_t]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:dt?Mt:Jt}),dt&&s.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Lt})]}),s.jsx("span",{className:"text-right text-muted-foreground",children:qt})]})}),Se&&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:Ft=>{Ft.stopPropagation(),w(Ne.info.id,Zt)},"aria-label":e(Je?"contextSidebar.actions.copied":"contextSidebar.actions.copyJson"),title:e(Je?"contextSidebar.actions.copied":"contextSidebar.actions.copy"),children:Je?s.jsx(B,{name:"check",className:"size-3.5"}):s.jsx(B,{name:"file-copy",className:"size-3.5"})})}),s.jsx(hg,{language:"json",code:Zt,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},Ne.info.id)},t[192]=l,t[193]=i,t[194]=e,t[195]=n,t[196]=Xe):Xe=t[196],Bt=[...g].reverse().map(Xe),t[186]=l,t[187]=i,t[188]=g,t[189]=e,t[190]=n,t[191]=Bt}else Bt=t[191];let Ce;t[197]!==Bt?(Ce=s.jsx("div",{className:"mt-2.5 space-y-1",children:Bt}),t[197]=Bt,t[198]=Ce):Ce=t[198];let Me;t[199]!==Tt||t[200]!==Ce?(Me=s.jsxs("div",{children:[Tt,Ce]}),t[199]=Tt,t[200]=Ce,t[201]=Me):Me=t[201];let st;return t[202]!==je||t[203]!==lt||t[204]!==De||t[205]!==Ze||t[206]!==Ct||t[207]!==Me?(st=s.jsx(xn,{outerClassName:"h-full",className:"bg-background",children:s.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[je,lt,De,Ze,Ct,Me]})}),t[202]=je,t[203]=lt,t[204]=De,t[205]=Ze,t[206]=Ct,t[207]=Me,t[208]=st):st=t[208],st};function jw(t){return t.timeFormatPreference}function kw(t){return t.currentSessionId}function Cw(t){return t.currentSessionDirectory}function Nw(t){return t.providers}function Aw(t){return Object.keys(t).length>0?{}:t}function Pw(t){return t.info.role==="assistant"}function Dw(t){return t.info.role==="user"}function Iw(t){return t.info}function Tw(t,e){const n=kn(e.info.cost);return t+n}function Ew(t){return t.info.role==="system"}function Rw(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 Mw(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)}%`:On(t.value):"—"})]},t.label)}const Cf=new Set(["localhost","127.0.0.1","0.0.0.0","::1","[::1]"]),Ow=t=>{const e=t.split("/")[0]?.split("?")[0]??"",n=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??"";return Cf.has(n.toLowerCase())},Fs="about:blank",gr=t=>{const e=t.trim();if(!e)return Fs;const n=e.includes("://")?e:`${Ow(e)?"http":"https"}://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?Fs:r.toString()}catch{return Fs}},Sr=t=>{try{return Cf.has(new URL(t).hostname.toLowerCase())}catch{return!1}},Za=t=>{if(!t||t===Fs)return"";try{return new URL(t).host||t}catch{return t}},Bw=new Set([-2,-7,-101,-102,-104,-109,-118,-324]),Fw=(t,e)=>Bw.has(t)&&Sr(e),Lw=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"},_w=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(Lw)}:{kind:"unavailable"}}catch{return{kind:"unavailable"}}},$w=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}},zw=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}},Ww=({announced:t,discovered:e})=>{const n=new Map;for(const r of t){const i=zw(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)},da="__openchamberBrowserAnnotationActive",Kw=`(() => {
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['${da}']; } catch (error) { /* non-configurable */ }
21
+ })();`,Vw=(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['${da}'] = 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['${da}']; } 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
+ });`},Uw={kind:"idle"},en=t=>typeof t=="object"&&t!==null,fn=t=>typeof t=="number"&&Number.isFinite(t),wc=t=>en(t)&&Object.values(t).every(e=>typeof e=="string"),el=t=>en(t)&&fn(t.x)&&fn(t.y)&&fn(t.width)&&fn(t.height),Nf=t=>en(t)&&fn(t.x)&&fn(t.y),Hw=t=>en(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"),Gw=t=>en(t)&&typeof t.tag=="string"&&typeof t.text=="string"&&typeof t.selector=="string"&&typeof t.path=="string"&&el(t.bounds)&&Nf(t.center)&&wc(t.attributes)&&wc(t.computedStyle)&&Array.isArray(t.ancestry)&&t.ancestry.every(Hw),qw=t=>en(t)&&typeof t.id=="string"&&Gw(t.element),Yw=t=>en(t)&&typeof t.id=="string"&&el(t.rect),Qw=t=>en(t)&&typeof t.id=="string"&&el(t.bounds)&&Array.isArray(t.points)&&t.points.every(Nf),Xw=t=>en(t)&&typeof t.id=="string"&&typeof t.pageUrl=="string"&&typeof t.pageTitle=="string"&&typeof t.comment=="string"&&en(t.viewport)&&fn(t.viewport.width)&&fn(t.viewport.height)&&fn(t.devicePixelRatio)&&Array.isArray(t.elements)&&t.elements.every(qw)&&Array.isArray(t.regions)&&t.regions.every(Yw)&&Array.isArray(t.strokes)&&t.strokes.every(Qw),Jw=1600,Zw=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}),ev=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 Zw(`data:${e};base64,${t}`),m=Math.max(1,u.naturalWidth||n),f=Math.max(1,u.naturalHeight||r),g=m/Math.max(1,i||m),x=f/Math.max(1,o||f),b=Math.min(1,Jw/m),j=document.createElement("canvas");j.width=Math.max(1,Math.floor(m*b)),j.height=Math.max(1,Math.floor(f*b));const y=j.getContext("2d");if(!y)return null;y.scale(b,b),y.drawImage(u,0,0,m,f);const h=N=>({x:N.x*g,y:N.y*x,width:N.width*g,height:N.height*x}),p=Math.max(2,2.5*g/Math.max(b,.2));y.strokeStyle=a,y.fillStyle=d;const w=N=>{const P=h(N);y.lineWidth=p,y.fillRect(P.x,P.y,P.width,P.height),y.strokeRect(P.x,P.y,P.width,P.height)};for(const N of l.elements)w(N.element.bounds);for(const N of l.regions)w(N.rect);for(const N of l.strokes)N.points.length<2||(y.beginPath(),N.points.forEach((P,C)=>{const T=P.x*g,O=P.y*x;C===0?y.moveTo(T,O):y.lineTo(T,O)}),y.lineCap="round",y.lineJoin="round",y.lineWidth=p*1.4,y.stroke());const S=await new Promise(N=>j.toBlob(N,"image/jpeg",.85));return S?new File([S],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},tv="({ width: window.innerWidth, height: window.innerHeight })",sv=async t=>{try{const e=await t.executeJavaScript(tv,!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}},To=async t=>{try{await t.executeJavaScript(Kw,!1)}catch{}},nv=async({host:t,theme:e,labels:n})=>{const r=Vw(e,n),i=await t.executeJavaScript(r,!0);if(i==null)return null;if(!Xw(i))return await To(t),null;const o=i;try{const l=await sv(t)??o.viewport,a=await t.capturePage();if(!a||!a.base64)return{payload:o,screenshot:null};const d=await ev({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}}},Os={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)"},rv=()=>{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()}},ov=t=>{const e=rv();if(!e)return{...Os,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)`)||Os.glassSurface,glassFilter:`blur(${o}) saturate(${l})`,primary:n("--primary",Os.primary),primarySoft:r("--primary",16,Os.primarySoft),primaryFaint:r("--primary",10,Os.primaryFaint),primaryContrast:n("--primary-foreground",Os.primaryContrast),surface:n("--surface-background",Os.surface),surfaceElevated:n("--surface-elevated",Os.surfaceElevated),border:n("--border",Os.border),text:n("--foreground",Os.text),mutedText:n("--muted-foreground",Os.mutedText)}}catch{return{...Os,colorScheme:t}}finally{e.dispose()}},iv=2e3,av=50,lv=400,Ds=new Map;let ua=null,Nn=null,zr=null;const fa=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}},ln=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)}},cv=async(t,e=iv)=>{const n=Date.now()+e;for(;!Ds.has(t)&&Date.now()<n;)await new Promise(r=>setTimeout(r,av));return Ds.get(t)??null},Af=()=>{const t=ua?Ds.get(ua):void 0;if(t)return t;let e=null;for(const n of Ds.values())e=n;return e},dv=()=>{const t=Af();return[...Ds.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}})},uv=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.`,fv=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=Ds.get(i);if(!l){if(Ds.size===0&&!Nn)return;if(await new Promise(a=>setTimeout(a,lv)),Ds.has(i)){await vc(t,Ds.get(i),r);return}if(!await fa(t.requestId))return;await ln(t.requestId,{ok:!1,error:uv(i)});return}await vc(t,l,r);return}const o=Af();if(!(!o&&!(e&&Nn))&&await fa(t.requestId))try{const l=typeof t.parameters.url=="string"?t.parameters.url:"";if(e&&!l){await ln(t.requestId,{ok:!1,error:"url is required"});return}const a=e&&Nn?Nn(l):null;if(e&&!a&&!o){await ln(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 ln(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a}});return}const u=await cv(a);if(!u){await ln(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!1,note:"The panel had no browser view yet, so the viewport was not applied. Call browser.resize now that one exists."}});return}const m=await u.run("browser.resize",{viewport:d}),f=m&&typeof m=="object"?m.viewport??null:null;await ln(t.requestId,{ok:!0,data:{url:l,opened:!0,tabId:a,viewportApplied:!0,viewport:f}});return}await ln(t.requestId,await Pf(o,t.action,r))}catch(l){await ln(t.requestId,{ok:!1,error:l instanceof Error?l.message:String(l)})}},vc=async(t,e,n)=>{await fa(t.requestId)&&await ln(t.requestId,await Pf(e,t.action,n))},Pf=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:dv()}}:{ok:!0,data:r}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},Df=()=>{zr||(zr=In(t=>{t.type==="browser-control-request"&&fv({requestId:t.requestId,action:t.action,parameters:t.parameters})}))},If=()=>{Ds.size>0||Nn||!zr||(zr(),zr=null)},mv=t=>(Ds.set(t.tabId,t),Df(),()=>{Ds.get(t.tabId)===t&&Ds.delete(t.tabId),If()}),hv=t=>{ua=t},pv=t=>(Nn=t,Df(),()=>{Nn===t&&(Nn=null),If()}),gv=50,bv=6,xv=2048,yv=200,Tf=t=>{const e=gr(String(t??"").trim());if(!e||e.length>xv)return"";try{const n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?"":n.toString()}catch{return""}},wv=(t,e)=>{const n=Tf(e.url);if(!n)return t;const r=t.find(l=>l.url===n),i=String(e.title??"").trim().slice(0,yv)||r?.title||"";return[{url:n,title:i,lastVisitedAt:e.at},...t.filter(l=>l.url!==n)].slice(0,gv)},vv=(t,e)=>{const n=Tf(e);return t.filter(r=>r.url!==n)},Sv=t=>`${t.url.replace(/^https?:\/\//,"")} ${t.title}`.toLowerCase(),Ef=(t,e,n=bv)=>{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=Sv(l);return l.url===r||a===o?!1:a.includes(o)}).slice(0,n)},Sc=20,Eo=t=>{const e=gt((t||"").trim());return e?JSON.stringify([Yt(),e]):""},jv=t=>{const e=Object.keys(t);if(e.length<=Sc)return t;const n=e.map(r=>[r,t[r]?.[0]?.lastVisitedAt??0]).sort((r,i)=>i[1]-r[1]).slice(0,Sc);return Object.fromEntries(n.map(([r])=>[r,t[r]??[]]))},br=Jr()(Rx(t=>({byProject:{},recordVisit:(e,n)=>{const r=Eo(e);r&&t(i=>{const o=i.byProject[r]??[],l=wv(o,{...n,at:Date.now()});return l===o?i:{byProject:jv({...i.byProject,[r]:l})}})},forget:(e,n)=>{const r=Eo(e);r&&t(i=>{const o=i.byProject[r];return o?{byProject:{...i.byProject,[r]:vv(o,n)}}:i})},clear:e=>{const n=Eo(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:nh(),partialize:t=>({byProject:t.byProject})})),kv=[],Rf=t=>e=>{const n=Eo(t);return(n?e.byProject[n]:void 0)??kv},ma=new Map,di=new Map,Kn=new Map,Vn=new Set,Cv=async(t,e)=>{if(!pl()){Vn.delete(t),dr(t,{type:"close"});return}if(await rh(pn()),!Vn.has(t)||!pl())return;const n=zd().websocket(`/api/dev-tunnel?port=${e}`),r=oh(n);Kn.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=()=>{Vn.delete(t),Kn.delete(t),dr(t,{type:"close"})}};pg(({connectionId:t,remotePort:e,message:n})=>{switch(n.type){case"data":{const r=Kn.get(t);r&&n.data&&r.send(n.data);return}case"close":Vn.delete(t),Kn.get(t)?.close(),Kn.delete(t);return;case"connect":Vn.add(t),Cv(t,e).catch(()=>{Vn.delete(t),dr(t,{type:"close"})})}});const Mf=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Of=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}},Bf=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}},jc=(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}},kc=(t,e)=>{try{di.set(e,new URL(t).origin)}catch{}};class Wr extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const Cc=async t=>{if(!t||!Mf()||!Sr(t))return t;const e=pn();if(!Of(e))return t;const n=Bf(t);if(!n)return t;const r=`${e}|${n}`,i=ma.get(r);if(i)return kc(t,i),jc(t,i);try{const o=await hr("desktop_dev_tunnel_open",{baseUrl:e,port:n,relay:ih(),targetKey:Yt(),clientToken:Vr(),requestHeaders:Wd()});if(!o||!Number.isInteger(o.localPort)||o.localPort<=0)throw new Wr(t);return ma.set(r,o.localPort),kc(t,o.localPort),jc(t,o.localPort)}catch(o){throw o instanceof Wr?o:new Wr(t)}},Nc=t=>{if(!t||!Mf()||!Sr(t)||!Of(pn()))return!1;const e=Bf(t);return e>0&&!di.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=di.get(Number.parseInt(e.port||"0",10));return n?`${n}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},Nv=()=>{ma.clear(),di.clear(),Vn.clear();for(const t of Kn.values())t.close();Kn.clear(),hr("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&vr(Nv);const Ac=6e3,Av=120,Pv=80,Dv=`
574
+ var MAX_ELEMENTS = ${Av};
575
+ var MAX_LABEL_CHARS = ${Pv};
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
+ `,Zr=t=>`(() => {
689
+ ${Dv}
690
+ ${t}
691
+ })()`,Iv=({selector:t}={})=>Zr(`
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, ${Ac}),
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 > ${Ac}) {
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
+ `),Tv=({selector:t,text:e})=>Zr(`
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
+ `),Ev=({selector:t,value:e,submit:n})=>Zr(`
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
+ `),Rv=({selector:t,direction:e})=>Zr(`
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
+ `),Mv=["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"],Ov=({selector:t})=>Zr(`
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(Mv)};
862
+ for (var i = 0; i < props.length; i += 1) {
863
+ var value = computed.getPropertyValue(props[i]);
864
+ if (value) styles[props[i]] = String(value).trim();
865
+ }
866
+
867
+ var rect = target.getBoundingClientRect();
868
+ return {
869
+ ok: true,
870
+ selector: cssPath(target),
871
+ tag: target.tagName.toLowerCase(),
872
+ label: label(target),
873
+ bounds: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },
874
+ inViewport: rect.bottom > 0 && rect.top < window.innerHeight,
875
+ styles: styles
876
+ };
877
+ `),Bv=t=>{const e=nt.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=At();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=(g,x)=>s.jsxs("div",{role:"option","aria-selected":x===r,className:Ie("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(g.url)},onPointerEnter:()=>l(x),children:[s.jsx(B,{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:g.title||Za(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:Ie("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(g.url)},children:s.jsx(B,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let m;return e[15]!==d||e[16]!==u?(m=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=m):m=e[17],m},Bs=t=>{const e=nt.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=Ie("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let m;e[2]!==n?(m=s.jsx(B,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=m):m=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==m?(f=s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:m})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=m,e[11]=f):f=e[11];let g;e[12]!==r?(g=s.jsx(jt,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let x;return e[14]!==f||e[15]!==g?(x=s.jsxs(vt,{children:[f,g]}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x},Ff=t=>{const e=nt.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:m,canGoBack:f,canGoForward:g,isLoading:x,onAnnotate:b,onOpenDevTools:j,isAnnotating:y,onHardReload:h,onZoomIn:p,onZoomOut:w,onZoomReset:S,zoomPercent:N,onClearCookies:P,onClearCache:C,onToggleDeviceBar:T,isDeviceBarOpen:O}=t;let M;e[0]!==r?(M=r===void 0?[]:r,e[0]=r,e[1]=M):M=e[1];const F=M,K=N===void 0?100:N,{t:D}=At(),[U,A]=c.useState(!1),[E,W]=c.useState(-1);let k;e[2]!==U||e[3]!==F?(k=U?F:[],e[2]=U,e[3]=F,e[4]=k):k=e[4];const v=k;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{W(-1)},e[5]=I):I=e[5];let H;e[6]!==n||e[7]!==U?(H=[n,U],e[6]=n,e[7]=U,e[8]=H):H=e[8],c.useEffect(I,H);let _;e[9]!==l?(_=ze=>{A(!1),W(-1),l(ze)},e[9]=l,e[10]=_):_=e[10];const se=_;let te;e[11]!==E||e[12]!==se||e[13]!==v?(te=ze=>{if(v.length!==0){if(ze.key==="ArrowDown"||ze.key==="ArrowUp"){ze.preventDefault();const He=ze.key==="ArrowDown"?1:-1,$e=v.length;W(R=>{const pe=R+He;return pe<-1?$e-1:pe>=$e?-1:pe});return}if(ze.key==="Escape"&&E>=0){ze.preventDefault(),W(-1);return}if(ze.key==="Enter"&&E>=0){ze.preventDefault();const He=v[E];He&&se(He.url)}}},e[11]=E,e[12]=se,e[13]=v,e[14]=te):te=e[14];const ee=te;let ue;e[15]!==D?(ue=D("contextPanel.browser.back"),e[15]=D,e[16]=ue):ue=e[16];const de=!f;let Re;e[17]!==a||e[18]!==de||e[19]!==ue?(Re=s.jsx(Bs,{icon:"arrow-left",label:ue,onClick:a,disabled:de}),e[17]=a,e[18]=de,e[19]=ue,e[20]=Re):Re=e[20];let we;e[21]!==D?(we=D("contextPanel.browser.forward"),e[21]=D,e[22]=we):we=e[22];const fe=!g;let Pe;e[23]!==d||e[24]!==we||e[25]!==fe?(Pe=s.jsx(Bs,{icon:"arrow-right",label:we,onClick:d,disabled:fe}),e[23]=d,e[24]=we,e[25]=fe,e[26]=Pe):Pe=e[26];let L;e[27]!==x||e[28]!==D?(L=D(x?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=x,e[28]=D,e[29]=L):L=e[29];let oe;e[30]!==u||e[31]!==L?(oe=s.jsx(Bs,{icon:"refresh",label:L,onClick:u}),e[30]=u,e[31]=L,e[32]=oe):oe=e[32];let ce;e[33]!==h||e[34]!==D?(ce=h?s.jsx(Bs,{icon:"restart",label:D("contextPanel.browser.hardReload"),onClick:h}):null,e[33]=h,e[34]=D,e[35]=ce):ce=e[35];let he;e[36]!==n||e[37]!==se?(he=ze=>{ze.preventDefault(),se(n)},e[36]=n,e[37]=se,e[38]=he):he=e[38];let Y;e[39]!==o?(Y=ze=>o(ze.target.value),e[39]=o,e[40]=Y):Y=e[40];let ve,Te;e[41]===Symbol.for("react.memo_cache_sentinel")?(ve=()=>A(!0),Te=()=>A(!1),e[41]=ve,e[42]=Te):(ve=e[41],Te=e[42]);const ke=v.length>0;let xe;e[43]===Symbol.for("react.memo_cache_sentinel")?(xe=Ie("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]=xe):xe=e[43];let ge;e[44]!==D?(ge=D("contextPanel.browser.addressAria"),e[44]=D,e[45]=ge):ge=e[45];let Q;e[46]!==n||e[47]!==ee||e[48]!==Y||e[49]!==ke||e[50]!==ge?(Q=s.jsx("input",{value:n,onChange:Y,onFocus:ve,onBlur:Te,onKeyDown:ee,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":ke,"aria-controls":"openchamber-browser-address-suggestions",className:xe,"aria-label":ge}),e[46]=n,e[47]=ee,e[48]=Y,e[49]=ke,e[50]=ge,e[51]=Q):Q=e[51];let $;e[52]!==i?($=ze=>i?.(ze),e[52]=i,e[53]=$):$=e[53];let J;e[54]!==E||e[55]!==se||e[56]!==$||e[57]!==v?(J=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Bv,{entries:v,activeIndex:E,onSelect:se,onForget:$,onHighlight:W})}),e[54]=E,e[55]=se,e[56]=$,e[57]=v,e[58]=J):J=e[58];let me;e[59]!==he||e[60]!==Q||e[61]!==J?(me=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:he,children:[Q,J]}),e[59]=he,e[60]=Q,e[61]=J,e[62]=me):me=e[62];let le;e[63]!==p||e[64]!==w||e[65]!==S||e[66]!==D||e[67]!==K?(le=w&&p?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(Bs,{icon:"subtract",label:D("contextPanel.browser.zoomOut"),onClick:w}),K!==100&&S?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(ft,{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":D("contextPanel.browser.zoomReset"),children:[K,"%"]})}),s.jsx(jt,{sideOffset:6,children:D("contextPanel.browser.zoomReset")})]}):null,s.jsx(Bs,{icon:"add",label:D("contextPanel.browser.zoomIn"),onClick:p})]}):null,e[63]=p,e[64]=w,e[65]=S,e[66]=D,e[67]=K,e[68]=le):le=e[68];let V;e[69]!==P||e[70]!==D?(V=P?s.jsx(Bs,{icon:"delete-bin",label:D("contextPanel.browser.clearCookies"),onClick:P}):null,e[69]=P,e[70]=D,e[71]=V):V=e[71];let Z;e[72]!==C||e[73]!==D?(Z=C?s.jsx(Bs,{icon:"database-2",label:D("contextPanel.browser.clearCache"),onClick:C}):null,e[72]=C,e[73]=D,e[74]=Z):Z=e[74];let G;e[75]!==O||e[76]!==T||e[77]!==D?(G=T?s.jsx(Bs,{icon:"smartphone",label:D("contextPanel.browser.deviceToolbar"),onClick:T,pressed:O}):null,e[75]=O,e[76]=T,e[77]=D,e[78]=G):G=e[78];let ie;e[79]!==y||e[80]!==b||e[81]!==D?(ie=b?s.jsx(Bs,{icon:"markup",label:D("contextPanel.browser.annotate.toggle"),onClick:b,pressed:y}):null,e[79]=y,e[80]=b,e[81]=D,e[82]=ie):ie=e[82];let je;e[83]!==j||e[84]!==D?(je=j?s.jsx(Bs,{icon:"terminal-box",label:D("contextPanel.browser.devTools"),onClick:j}):null,e[83]=j,e[84]=D,e[85]=je):je=e[85];let ne;e[86]!==D?(ne=D("contextPanel.browser.openExternal"),e[86]=D,e[87]=ne):ne=e[87];let Oe;e[88]!==m||e[89]!==ne?(Oe=s.jsx(Bs,{icon:"external-link",label:ne,onClick:m}),e[88]=m,e[89]=ne,e[90]=Oe):Oe=e[90];let Ve;return e[91]!==Re||e[92]!==Pe||e[93]!==oe||e[94]!==ce||e[95]!==me||e[96]!==le||e[97]!==V||e[98]!==Z||e[99]!==G||e[100]!==ie||e[101]!==je||e[102]!==Oe?(Ve=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Re,Pe,oe,ce,me,le,V,Z,G,ie,je,Oe]}),e[91]=Re,e[92]=Pe,e[93]=oe,e[94]=ce,e[95]=me,e[96]=le,e[97]=V,e[98]=Z,e[99]=G,e[100]=ie,e[101]=je,e[102]=Oe,e[103]=Ve):Ve=e[103],Ve},zo={kind:"fill"},Pc=240,Fv=3840,Lf=[{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}],Dc=t=>Number.isFinite(t)?Math.round(Math.min(Fv,Math.max(Pc,t))):Pc,Wo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},_f=t=>{const e=Lf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Lv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},_v=(t,e)=>{const n=Wo(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}},$v=["mobile","tablet","desktop","fill"],zv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Ic=t=>typeof t=="string"&&$v.includes(t),ha=t=>t==="fill"?zo:_f(zv[t])??zo,mo=t=>{const e=Wo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ha(n),i=Wo(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}},Wv=t=>{const e=nt.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=At();let d;e[0]!==n?(d=Wo(n),e[0]=n,e[1]=d):d=e[1];const u=d,m=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(de,Re)=>{const we=Number.parseInt(Re,10);if(!Number.isFinite(we))return;const fe=u??{width:1280,height:800};r({kind:"custom",width:Dc(de==="width"?we:fe.width),height:Dc(de==="height"?we:fe.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const g=f;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=Ie("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 j;e[6]!==r?(j=de=>{const Re=_f(de.target.value);r(Re??zo)},e[6]=r,e[7]=j):j=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=Ie("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=h):h=e[10];let p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let w;e[13]!==p?(w=s.jsx("option",{value:"",children:p}),e[13]=p,e[14]=w):w=e[14];let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=Lf.map(Kv),e[15]=S):S=e[15];let N;e[16]!==m||e[17]!==j||e[18]!==y||e[19]!==w?(N=s.jsxs("select",{value:m,onChange:j,"aria-label":y,className:h,children:[w,S]}),e[16]=m,e[17]=j,e[18]=y,e[19]=w,e[20]=N):N=e[20];const P=u?String(u.width):"";let C;e[21]!==g?(C=de=>g("width",de.target.value),e[21]=g,e[22]=C):C=e[22];let T;e[23]!==a?(T=a("contextPanel.browser.device.width"),e[23]=a,e[24]=T):T=e[24];let O;e[25]!==P||e[26]!==C||e[27]!==T?(O=s.jsx("input",{value:P,onChange:C,placeholder:"—",inputMode:"numeric","aria-label":T,className:b}),e[25]=P,e[26]=C,e[27]=T,e[28]=O):O=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=M):M=e[29];const F=u?String(u.height):"";let K;e[30]!==g?(K=de=>g("height",de.target.value),e[30]=g,e[31]=K):K=e[31];let D;e[32]!==a?(D=a("contextPanel.browser.device.height"),e[32]=a,e[33]=D):D=e[33];let U;e[34]!==F||e[35]!==K||e[36]!==D?(U=s.jsx("input",{value:F,onChange:K,placeholder:"—",inputMode:"numeric","aria-label":D,className:b}),e[34]=F,e[35]=K,e[36]=D,e[37]=U):U=e[37];let A;e[38]!==r||e[39]!==n?(A=()=>r(Lv(n)),e[38]=r,e[39]=n,e[40]=A):A=e[40];const E=!u;let W;e[41]!==a?(W=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=W):W=e[42];let k;e[43]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(B,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=k):k=e[43];let v;e[44]!==A||e[45]!==E||e[46]!==W?(v=s.jsx(St,{asChild:!0,children:s.jsx(ft,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:A,disabled:E,"aria-label":W,children:k})}),e[44]=A,e[45]=E,e[46]=W,e[47]=v):v=e[47];let I;e[48]!==a?(I=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=I):I=e[49];let H;e[50]!==I?(H=s.jsx(jt,{sideOffset:6,children:I}),e[50]=I,e[51]=H):H=e[51];let _;e[52]!==v||e[53]!==H?(_=s.jsxs(vt,{children:[v,H]}),e[52]=v,e[53]=H,e[54]=_):_=e[54];let se;e[55]!==l||e[56]!==u?(se=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=se):se=e[57];let te;e[58]===Symbol.for("react.memo_cache_sentinel")?(te=["system","light","dark"],e[58]=te):te=e[58];let ee;e[59]!==i||e[60]!==o||e[61]!==a?(ee=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:te.map(de=>s.jsx(ft,{type:"button",variant:i===de?"secondary":"ghost",size:"xs",className:Ie("shrink-0 rounded-full px-2.5 typography-micro",i===de?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(de),"aria-pressed":i===de,children:a(de==="system"?"contextPanel.browser.device.schemeSystem":de==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},de))}),e[59]=i,e[60]=o,e[61]=a,e[62]=ee):ee=e[62];let ue;return e[63]!==N||e[64]!==O||e[65]!==U||e[66]!==_||e[67]!==se||e[68]!==ee?(ue=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,O,M,U,_,se,ee]}),e[63]=N,e[64]=O,e[65]=U,e[66]=_,e[67]=se,e[68]=ee,e[69]=ue):ue=e[69],ue};function Kv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Vv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Uv=2e3,Hv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=pn();if(!t)return!1;try{return!Sr(new URL(t,window.location.href).toString())}catch{return!1}},$f=t=>{const e=nt.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=At();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=ry(i),[m]=c.useState(Hv);let f,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let O=!0,M=null;const F=new AbortController,K=()=>{_w(F.signal).then(D=>{O&&(d(D),M=setTimeout(K,Uv))})};return K(),()=>{O=!1,M&&clearTimeout(M),F.abort()}},g=[],e[1]=f,e[2]=g):(f=e[1],g=e[2]),c.useEffect(f,g);const x=a.kind==="ready"?a.servers:null;let b;e[3]!==u||e[4]!==x?(b=Ww({announced:u,discovered:x}),e[3]=u,e[4]=x,e[5]=b):b=e[5];const j=b;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Au,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let h;e[7]!==o?(h=o("contextPanel.browser.empty"),e[7]=o,e[8]=h):h=e[8];let p;e[9]!==h?(p=s.jsx("span",{className:"typography-ui-header text-foreground",children:h}),e[9]=h,e[10]=p):p=e[10];let w;e[11]!==o?(w=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=w):w=e[12];let S;e[13]!==w?(S=s.jsx("span",{className:"typography-micro text-muted-foreground",children:w}),e[13]=w,e[14]=S):S=e[14];let N;e[15]!==S||e[16]!==p?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[p,S]}),e[15]=S,e[16]=p,e[17]=N):N=e[17];let P;e[18]!==u||e[19]!==j||e[20]!==i||e[21]!==n||e[22]!==m||e[23]!==o?(P=j.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),m?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:j.map(O=>s.jsxs(ft,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{ty(i),n(O.url)},children:[s.jsx(B,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Za(O.url)||O.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Vv(O.url)})]},O.port))})]}):null,e[18]=u,e[19]=j,e[20]=i,e[21]=n,e[22]=m,e[23]=o,e[24]=P):P=e[24];let C;e[25]!==j.length||e[26]!==a.kind||e[27]!==o?(C=j.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=j.length,e[26]=a.kind,e[27]=o,e[28]=C):C=e[28];let T;return e[29]!==N||e[30]!==P||e[31]!==C?(T=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,N,P,C]}),e[29]=N,e[30]=P,e[31]=C,e[32]=T):T=e[32],T},vs=t=>Math.round(t),Gv=(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=${vs(l.x)}, y=${vs(l.y)}, width=${vs(l.width)}, height=${vs(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")},qv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${vs(n.x)}, y=${vs(n.y)}, width=${vs(n.width)}, height=${vs(n.height)}`},Yv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${vs(n.x)}, y=${vs(n.y)}, width=${vs(n.width)}, height=${vs(n.height)}`},Qv=({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: ${vs(t.viewport.width)}x${vs(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("",...Gv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(qv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(Yv(l,a)))),o.filter(l=>typeof l=="string").join(`
878
+ `)},Xv=t=>{const e=nt.c(7),{t:n}=At(),r=rt(Zv),i=rt(eS),o=Ui(tS),l=gg(sS);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){Fe.error(n("contextPanel.browser.annotate.noSession"));return}let m=!1;if(d.screenshot)try{await l(d.screenshot),m=!0}catch{m=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:Qv({payload:d.payload,screenshotAttached:m,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Fe.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},Jv=()=>{const t=nt.c(16),{t:e}=At();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 Zv(t){return t.currentSessionId}function eS(t){return t.newSessionDraft?.open}function tS(t){return t.addDraft}function sS(t){return t.addAttachedFile}const nS=3e4,rS=3,oS=250,iS={attempts:0,windowStartedAt:null},aS=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=nS,r=n?0:t.attempts;return r>=rS?null:{delayMs:oS*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},lS=-3,ho=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",fr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},cS=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:Uw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,m]=c.useState(!1),[f,g]=c.useState(!1),x=c.useRef(n);x.current=n;const b=c.useRef(iS);return c.useEffect(()=>{if(!t)return;const j=()=>{try{const M=t.getURL();return ho(M)?M:""}catch{return""}},y=()=>{try{m(t.canGoBack()),g(t.canGoForward())}catch{}},h=M=>{ho(M)&&(l(M),x.current(M))},p=()=>{const M=j();i({kind:"loading",url:M})},w=()=>{const M=j();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),h(M),y(),i(K=>K.kind==="failed"?K:{kind:"ready",url:M,title:F})},S=M=>{const F=fr(M);ho(F.url)&&(h(F.url),y())},N=M=>{const F=fr(M),K=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",D=j();K&&D&&kf.getState().resolve(D,K)},P=M=>{const F=fr(M);typeof F.title=="string"&&d(F.title)},C=M=>{const F=fr(M);if(F.isMainFrame===!1)return;const K=typeof F.errorCode=="number"?F.errorCode:0;K!==lS&&i({kind:"failed",url:ho(F.validatedURL)?F.validatedURL:j(),code:K,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let T=null;const O=()=>{const M=j(),F=aS(b.current,Date.now());if(!F){i({kind:"failed",url:M,code:0,description:"",crashed:!0});return}b.current=F.state,i({kind:"loading",url:M}),T=setTimeout(()=>{T=null;try{t.reload()}catch{i({kind:"failed",url:M,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",S),t.addEventListener("did-navigate-in-page",S),t.addEventListener("page-title-updated",P),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",C),t.addEventListener("render-process-gone",O),t.addEventListener("crashed",O);try{!t.isLoading()&&j()&&w()}catch{}return()=>{T!==null&&clearTimeout(T),t.removeEventListener("render-process-gone",O),t.removeEventListener("crashed",O),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",S),t.removeEventListener("did-navigate-in-page",S),t.removeEventListener("page-title-updated",P),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",C)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},dS=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,uS=4e4,po=.5,fS=-3,mS=4,hS="persist:openchamber-browser",Tc=20,pS=600,gS=2e4,bS=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=At(),{currentTheme:i}=qn(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(V=>{o.current=V,a(V)},[]),u=ye(V=>V.setContextPanelTabTargetPath),m=c.useRef(gr(t)),f=m.current!==Fs?m.current:"",[g,x]=c.useState(f?null:Fs),[b,j]=c.useState(f),[y,h]=c.useState(!1),[p,w]=c.useState(!1),[S,N]=c.useState(0),P=c.useRef(0),[C,T]=c.useState(!1),[O,M]=c.useState(zo),F=c.useRef(O);F.current=O;const K=c.useRef([]),[D,U]=c.useState("system"),[A,E]=c.useState({width:0,height:0}),W=c.useRef(null),k=c.useRef(null),v=c.useRef(!1),I=c.useRef(Date.now()),H=c.useCallback(V=>{!V||V===Fs||!e||!n||u(e,n,V)},[e,n,u]),_=cS(l,{initialUrl:f,onUrlChange:c.useCallback(V=>{const Z=ar(V);j(Z),H(Z)},[H])}),[se,te]=c.useState(null),ee=Xv(e),ue=Jv(),de=_.status.kind==="loading",Re=br(Rf(e)),we=br(V=>V.recordVisit),fe=br(V=>V.forget);c.useEffect(()=>{_.status.kind==="ready"&&we(e,{url:ar(_.status.url),title:_.status.title})},[e,_.status,we]);const Pe=c.useMemo(()=>Ef(Re,b),[Re,b]),L=c.useCallback(V=>{const Z=gr(V);Z!==Fs&&(j(Z),te(null),Cc(Z).then(G=>{const ie=o.current;if(!ie){x(G);return}try{ie.loadURL(G)}catch{x(G)}}).catch(G=>{G instanceof Wr&&te(Z)}))},[]);c.useEffect(()=>{if(!f)return;let V=!0;return Cc(f).then(Z=>{V&&x(Z)}).catch(Z=>{if(V){if(Z instanceof Wr){te(f),x(Fs);return}x(f)}}),()=>{V=!1}},[]);const oe=c.useMemo(()=>({executeJavaScript:async(V,Z)=>{const G=o.current;if(!G)throw new Error("Browser view is not available");return G.executeJavaScript(V,Z)},capturePage:async()=>{const V=o.current;if(!V)return null;const Z=V.getWebContentsId();return Number.isFinite(Z)?await hr("desktop_browser_capture_page",{webContentsId:Z}):null}}),[]),ce=c.useCallback(()=>{if(y){h(!1),To(oe);return}if(!_.url){Fe.error(r("contextPanel.browser.annotate.noPage"));return}const V=ov(i.metadata.variant==="light"?"light":"dark");h(!0),nv({host:oe,theme:V,labels:ue}).then(async Z=>{h(!1),Z&&await ee(Z)}).catch(()=>{h(!1),Fe.error(r("contextPanel.browser.annotate.failed"))})},[oe,ee,i,y,_.url,ue,r]);c.useEffect(()=>{if(!y)return;const V=Z=>{bg(Z)||Z.key!=="Escape"||(Z.preventDefault(),Z.stopImmediatePropagation(),h(!1),To(oe))};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[oe,y]);const he=c.useCallback(async(V=8e3)=>{const Z=Date.now();for(;;){const G=o.current;if(!G)return!1;let ie=!1;try{ie=G.isLoading()}catch{return!1}if(!ie)return!0;if(Date.now()-Z>V)return!1;await new Promise(je=>setTimeout(je,120))}},[]),Y=c.useCallback(async(V,Z)=>{const G=o.current;if(!G)throw new Error("The browser panel is not ready");const ie=()=>{Ic(Z.viewport)&&(M(ha(Z.viewport)),T(!0))};if(V==="browser.back"||V==="browser.forward"){const He=V==="browser.back";if(!(He?G.canGoBack():G.canGoForward()))throw new Error(He?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");He?G.goBack():G.goForward(),await new Promise(pe=>setTimeout(pe,150)),await he();let R="";try{R=G.getTitle()||""}catch{R=""}return{url:ar(G.getURL()),title:R}}if(V==="browser.capture"){const He=ye.getState(),$e=Fn(e),R=He.contextPanelByDirectory[$e],pe=!!(R?.isOpen&&R.activeTabId===n);pe||He.setActiveContextPanelTab(e,n);const Le=()=>{if(pe||!R)return;const _e=ye.getState(),lt=_e.contextPanelByDirectory[$e];!lt?.isOpen||lt.activeTabId!==n||(R.activeTabId&&R.activeTabId!==n&&_e.setActiveContextPanelTab(e,R.activeTabId),R.isOpen||_e.closeContextPanel(e))};try{const _e=Date.now()+1200;let lt=0,ht=0;for(;ht<2&&Date.now()<_e;){const yt=G.getBoundingClientRect().width;ht=yt>=2&&Math.abs(yt-lt)<.5?ht+1:0,lt=yt,await new Promise(mt=>setTimeout(mt,50))}await new Promise(yt=>{requestAnimationFrame(()=>requestAnimationFrame(()=>yt()))}),await he();const ot=await oe.capturePage();if(!ot)throw new Error("The page could not be captured");let ut="";try{ut=G.getTitle()||""}catch{ut=""}return{...ot,url:ar(G.getURL()),title:ut,viewport:mo(F.current)}}finally{Le()}}if(V==="browser.resize"){if(!Ic(Z.viewport))throw new Error("viewport is required");return ie(),await new Promise(He=>setTimeout(He,200)),await he(),{viewport:mo(ha(Z.viewport))}}if(V==="browser.open"){const He=typeof Z.url=="string"?Z.url:"";if(!He)throw new Error("url is required");ie(),L(He),await new Promise(pe=>setTimeout(pe,150));const $e=await he(25e3);let R="";try{R=G.getTitle()||""}catch{R=""}return{url:gr(He),title:R,opened:!0,settled:$e,viewport:mo(F.current)}}await he();const je=He=>typeof He=="string"&&He?He:void 0,Oe=(()=>{switch(V){case"browser.snapshot":return Iv({selector:je(Z.selector)});case"browser.click":return Tv({selector:je(Z.selector),text:je(Z.text)});case"browser.type":return Ev({selector:String(Z.selector??""),value:String(Z.value??""),submit:Z.submit===!0});case"browser.inspect":return Ov({selector:String(Z.selector??"")});case"browser.scroll":return Rv({selector:je(Z.selector),direction:je(Z.direction)});default:return null}})();if(!Oe)throw new Error(`Unsupported browser action: ${V}`);const Ve=await G.executeJavaScript(Oe,!0);if(!Ve||typeof Ve!="object")throw new Error("The page returned no result");const ze=Ve;if(ze.ok!==!0)throw new Error(typeof ze.error=="string"&&ze.error?ze.error:"Browser action failed");if(V==="browser.snapshot"){const He=K.current;return{...ze,viewport:mo(F.current),...He.length>0?{consoleProblems:[...He]}:{}}}return(V==="browser.click"||V==="browser.type"&&Z.submit===!0)&&(await new Promise(He=>setTimeout(He,150)),await he()),Ve},[oe,e,L,n,he]),ve=c.useCallback(()=>{const V=o.current;if(!V)return{title:"",url:""};let Z="",G="";try{Z=V.getTitle()||""}catch{Z=""}try{G=ar(V.getURL())}catch{G=""}return{title:Z,url:G}},[]);c.useEffect(()=>mv({tabId:n,describe:ve,run:Y}),[ve,Y,n]),c.useEffect(()=>{const V=oe;return()=>{To(V)}},[oe]),c.useEffect(()=>{if(!l)return;const V=G=>{const ie=G;if(typeof ie.level!="number"||ie.level<2)return;const je=ie.sourceId?`${ie.sourceId}${ie.line?`:${ie.line}`:""}`:"";K.current.push({level:ie.level>=3?"error":"warning",message:String(ie.message??"").slice(0,400),source:je}),K.current.length>Tc&&K.current.splice(0,K.current.length-Tc)},Z=()=>{K.current=[]};return l.addEventListener("console-message",V),l.addEventListener("did-start-loading",Z),()=>{l.removeEventListener("console-message",V),l.removeEventListener("did-start-loading",Z)}},[l]);const Te=c.useRef(new Set),ke=c.useCallback(V=>{Te.current.clear(),L(V)},[L]);c.useEffect(()=>{if(!l)return;const V=G=>{const ie=fr(G),je=typeof ie.url=="string"?ie.url:"";!je||!Nc(je)||(G.preventDefault(),L(je))},Z=G=>{const ie=fr(G);if(ie.isMainFrame===!1||ie.errorCode===-3)return;const je=typeof ie.validatedURL=="string"?ie.validatedURL:"";!je||!Nc(je)||Te.current.has(je)||(Te.current.add(je),L(je))};return l.addEventListener("will-navigate",V),l.addEventListener("did-fail-load",Z),()=>{l.removeEventListener("will-navigate",V),l.removeEventListener("did-fail-load",Z)}},[L,l]),c.useEffect(()=>{if(!l)return;const V=Z=>{const G=Z.detail;Z.preventDefault(),G?.url&&L(G.url)};return l.addEventListener("new-window",V),()=>l.removeEventListener("new-window",V)},[L,l]);const xe=c.useCallback(V=>{const Z=Math.min(mS,Math.max(fS,V));P.current=Z,N(Z);try{o.current?.setZoomLevel(Z)}catch{}},[]);c.useEffect(()=>{const V=Z=>{if(!(Z instanceof CustomEvent))return;const G=Z.detail,ie=o.current;!ie||document.activeElement!==ie||(G==="zoom-in"?xe(P.current+po):G==="zoom-out"?xe(P.current-po):G==="zoom-reset"&&xe(0))};return window.addEventListener("openchamber:zoom",V),()=>window.removeEventListener("openchamber:zoom",V)},[xe]);const ge=c.useCallback(V=>{hr("desktop_browser_clear_data",{partition:hS,cookies:V==="cookies",cache:V==="cache"}).then(()=>{Fe.success(r(V==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Fe.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const V=W.current;if(!V||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(G=>{const ie=G[0]?.contentRect;ie&&E({width:ie.width,height:ie.height})});return Z.observe(V),()=>Z.disconnect()},[]);const Q=c.useCallback(V=>{U(V);const Z=o.current;if(!Z)return;let G=-1;try{G=Z.getWebContentsId()}catch{return}hr("desktop_browser_set_color_scheme",{webContentsId:G,scheme:V}).catch(ie=>{U("system"),Fe.error(ie instanceof Error?ie.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),$=c.useCallback(()=>{try{de?o.current?.stop():o.current?.reload()}catch{}},[de]),J=_.status;c.useEffect(()=>{const V=()=>{w(!0);const ie=setTimeout(()=>{try{o.current?.reload()}catch{}},pS);return()=>clearTimeout(ie)};if(J.kind==="failed"){if(!Fw(J.code,J.url)){w(!1);return}const ie=Date.now(),je=k.current?.url===J.url?k.current:{url:J.url,startedAt:ie};if(k.current=je,ie-je.startedAt>uS){w(!1);return}return V()}if(J.kind==="loading")return;if(k.current=null,J.kind!=="ready"||!J.url||!Sr(J.url)){v.current=!0,w(!1);return}if(v.current||Date.now()-I.current>gS){v.current=!0,w(!1);return}let Z=!1,G=null;return $w(ar(J.url)).then(ie=>{if(!Z){if(ie===null||ie<500){v.current=!0,w(!1);return}G=V()}}),()=>{Z=!0,G?.()}},[J]);const me=_.status.kind==="failed"&&!p?_.status:null,le=_v(O,A);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Ff,{address:b,onAddressChange:j,onSubmit:ke,suggestions:Pe,onForgetSuggestion:V=>fe(e,V),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:$,onOpenExternal:()=>{Yr(_.url||b)},canGoBack:_.canGoBack,canGoForward:_.canGoForward,isLoading:de,onAnnotate:ce,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>xe(S+po),onZoomOut:()=>xe(S-po),onZoomReset:()=>xe(0),zoomPercent:Math.round(Math.pow(1.2,S)*100),onClearCookies:()=>ge("cookies"),onClearCache:()=>ge("cache"),onToggleDeviceBar:()=>T(V=>!V),isDeviceBarOpen:C}),C?s.jsx(Wv,{viewport:O,onViewportChange:M,colorScheme:D,onColorSchemeChange:Q,scale:le?.scale??1}):null,s.jsxs("div",{ref:W,className:Ie("relative min-h-0 flex-1 bg-background",le&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,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,g!==null&&!f&&!_.url&&!de?s.jsx($f,{onOpen:ke,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,se?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:se})})]}):null,me&&!se?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:me.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:me.crashed?r("contextPanel.browser.crashedHint"):me.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,de?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]})]})},xS=t=>{const e=nt.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=At(),l=ye(wS);let a;e[0]!==n?(a=gr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==Fs?d:"",[m,f]=c.useState(u),[g,x]=c.useState(u);let b;e[2]!==u?(b=u?[u]:[],e[2]=u,e[3]=b):b=e[3];const[j,y]=c.useState(b),[h,p]=c.useState(u?0:-1),[w,S]=c.useReducer(vS,0);let N;e[4]!==r||e[5]!==l||e[6]!==i?(N=ue=>{!ue||ue===Fs||!r||!i||l(r,i,ue)},e[4]=r,e[5]=l,e[6]=i,e[7]=N):N=e[7];const P=N;let C;e[8]!==r?(C=Rf(r),e[8]=r,e[9]=C):C=e[9];const T=br(C),O=br(SS),M=br(jS);let F;e[10]!==m||e[11]!==T?(F=Ef(T,m),e[10]=m,e[11]=T,e[12]=F):F=e[12];const K=F;let D;e[13]!==r||e[14]!==h||e[15]!==P||e[16]!==O?(D=ue=>{const de=gr(ue);de!==Fs&&(f(de),x(de),P(de),O(r,{url:de}),y(Re=>{const we=h>=0?Re.slice(0,h+1):[];return we[we.length-1]===de?(p(we.length-1),we):(p(we.length),[...we,de])}))},e[13]=r,e[14]=h,e[15]=P,e[16]=O,e[17]=D):D=e[17];const U=D;let A;e[18]!==j||e[19]!==P?(A=ue=>{const de=j[ue];de&&(p(ue),f(de),x(de),P(de))},e[18]=j,e[19]=P,e[20]=A):A=e[20];const E=A;let W;e[21]!==r||e[22]!==M?(W=ue=>M(r,ue),e[21]=r,e[22]=M,e[23]=W):W=e[23];let k,v;e[24]!==E||e[25]!==h?(v=()=>E(h-1),k=()=>E(h+1),e[24]=E,e[25]=h,e[26]=k,e[27]=v):(k=e[26],v=e[27]);let I;e[28]!==m||e[29]!==g?(I=()=>{Yr(g||m)},e[28]=m,e[29]=g,e[30]=I):I=e[30];const H=h>0,_=h>=0&&h<j.length-1;let se;e[31]!==m||e[32]!==U||e[33]!==K||e[34]!==k||e[35]!==I||e[36]!==H||e[37]!==_||e[38]!==W||e[39]!==v?(se=s.jsx(Ff,{address:m,onAddressChange:f,onSubmit:U,suggestions:K,onForgetSuggestion:W,onBack:v,onForward:k,onReload:S,onOpenExternal:I,canGoBack:H,canGoForward:_,isLoading:!1}),e[31]=m,e[32]=U,e[33]=K,e[34]=k,e[35]=I,e[36]=H,e[37]=_,e[38]=W,e[39]=v,e[40]=se):se=e[40];let te;e[41]!==g||e[42]!==U||e[43]!==w||e[44]!==o?(te=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx($f,{onOpen:U})}),e[41]=g,e[42]=U,e[43]=w,e[44]=o,e[45]=te):te=e[45];let ee;return e[46]!==se||e[47]!==te?(ee=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[se,te]}),e[46]=se,e[47]=te,e[48]=ee):ee=e[48],ee},yS=t=>{const e=nt.c(3),[n]=c.useState(dS);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(bS,{...t}):s.jsx(xS,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function wS(t){return t.setContextPanelTabTargetPath}function vS(t){return t+1}function SS(t){return t.recordVisit}function jS(t){return t.forget}const kS=Jn(()=>tn(()=>import("./WalkthroughView-DGnTzqIU.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=Jn(()=>tn(()=>import("./DiffView-BeN2_YYF.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}))),NS=Jn(()=>tn(()=>import("./FilesView-CN34wm_N.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}))),AS=Jn(()=>tn(()=>import("./GitView-DLDazOo1.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}))),PS=Jn(()=>tn(()=>import("./LinearIssuesView-BryoAHow.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}))),DS=Jn(()=>tn(()=>import("./PlanView-B7Xgihqk.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}))),zf=c.lazy(()=>tn(()=>import("./PluginPane-2C71F8uF.js").then(t=>t.q),__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}))),Wf={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}},IS=t=>{const e=nt.c(12),{mode:n,docking:r}=t,[i,o]=c.useState(null),l=Wf[r.dock],a=Math.max(kg,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=Ie("shrink-0 overflow-hidden duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d,l.page),e[0]=l.page,e[1]=d,e[2]=u):u=e[2];let m;e[3]!==l.vertical||e[4]!==a?(m=l.vertical?{height:a}:{width:a},e[3]=l.vertical,e[4]=a,e[5]=m):m=e[5];let f;e[6]!==n?(f=s.jsx(zf,{mode:n,onResize:o}),e[6]=n,e[7]=f):f=e[7];let g;return e[8]!==u||e[9]!==m||e[10]!==f?(g=s.jsx("div",{className:u,style:m,children:f}),e[8]=u,e[9]=m,e[10]=f,e[11]=g):g=e[11],g},Ec=c.lazy(()=>tn(()=>import("./GuestSurfacePane-BdaurnDr.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}))),Kf=320,tl=600,TS=400,ES=100,RS=24,Ko=new Map,MS=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},Rc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Kf,Math.round(t))):tl,Mc=t=>{const e=t??(typeof window<"u"?window.innerWidth:tl*2);return Math.max(Kf,e-TS)},OS=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},BS=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Vf=(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"):$n(t)?Ea.getState().guests.find(r=>r.id===Oo(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),FS=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},LS=(t,e,n)=>{if(t.mode==="chat"){const r=pa(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"?Za(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?FS(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Vf(t.mode,n)},_S=t=>{const e=nt.c(8),{mode:n}=t,r=Ba();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=m=>m.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Cg,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Qr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Oc=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Oa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(hf,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(B,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(B,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(B,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(B,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(B,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(B,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(B,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(B,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(B,{name:"chat-4",className:"h-3.5 w-3.5"});if($n(t.mode))return s.jsx(_S,{mode:t.mode});if(t.mode==="browser"){const n=$S(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(B,{name:"global",className:"h-3.5 w-3.5"})}},$S=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},zS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=At(),i=ye(p=>p.contextEditorTreeWidth),o=ye(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),m=c.useRef(null),f=c.useRef(null),g=c.useRef(null),x=c.useCallback(p=>{const w=g.current;w&&(w.style.width=`${p}px`,w.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),b=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,m.current=i,p.preventDefault()}},j=p=>{if(!l||f.current!==p.pointerId)return;const w=d.current-p.clientX,S=Li(u.current+w);m.current!==S&&(m.current=S,x(S))},y=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const w=Li(m.current??i);f.current=null,m.current=null,a(!1),o(w)},h=t?i:0;return s.jsxs("div",{ref:g,className:Ie("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?m.current??h:h}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?m.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Ie("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:j,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Ie("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(nw,{visible:t&&e})})]})},pa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,WS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},KS=(t,e)=>{if(e.length===0)return Ko;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?Ko:r},VS=(t,e)=>{const n=jg(t),r=c.useRef(Ko),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=KS(n.getState().session,i.current);return WS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Ko)},US=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,HS=()=>{const{t}=At(),e=Yn()??"",n=c.useMemo(()=>MS(e),[e]),r=ye(q=>n?q.contextPanelByDirectory[n]:void 0),i=ye(q=>q.closeContextPanel),o=ye(q=>q.closeContextPanelTab),l=ye(q=>q.openContextPanelTab),a=ye(q=>q.toggleContextPanelExpanded),d=ye(q=>q.setContextPanelWidth),u=ye(q=>q.setActiveContextPanelTab),m=ye(q=>q.openAgentBrowserTab);c.useEffect(()=>{if(e)return pv(q=>m(e,q))},[e,m]);const f=ye(q=>q.openContextFile);c.useEffect(()=>In(q=>{if(q.type!=="file-open-request")return;const Be=q.directory??e;Be&&f(Be,q.path)}),[e,f]);const g=ye(q=>q.reorderContextPanelTabs),x=Xs(q=>q.setSelectedPath),b=ye(q=>q.contextEditorTreeVisible),j=ye(q=>q.contextEditorTreeWidth),y=ye(q=>q.setContextEditorTreeWidth),h=ye(q=>q.toggleContextEditorTree),p=ye(q=>q.contextEditorVisible),w=ye(q=>q.toggleContextEditor),S=ye(q=>q.openNewContextBrowserTab),N=kf(q=>q.byOrigin),P=ye(q=>q.allowPromptingSubagentSessions),{themeMode:C,setThemeMode:T,lightThemeId:O,darkThemeId:M,currentTheme:F}=qn(),K=c.useMemo(()=>r?.tabs??[],[r?.tabs]),D=K.find(q=>q.id===r?.activeTabId)??K[K.length-1]??null,U=D?.mode==="browser"?D.id:null;c.useEffect(()=>{U&&hv(U)},[U]);const A=!!(r?.isOpen&&D),[E,W]=c.useState(null),k=c.useMemo(()=>K.some(q=>q.mode==="file"&&q.targetPath),[K]),v=k&&(p||!b),I=D?.mode??null,H=I==="file"&&!v,_=!!(A&&r?.expanded&&!H),se=I?r?.widthByMode?.[I]:void 0,te=I?r?.widthFractionByMode?.[I]:void 0,ee=I?xg(I):.5,ue=E??(typeof window<"u"?window.innerWidth:tl*2),de=te!=null&&E!=null?Math.round(te*E):se,Re=H?j:Rc(de??Math.round(ee*ue),Mc(E??ue));c.useEffect(()=>{!n||!I||H||te!=null||se==null||E==null||d(n,I,se,E)},[I,E,n,H,se,te,d]);const we=c.useMemo(()=>{const q=[];for(const Be of K){if(Be.mode!=="chat")continue;const Ze=pa(Be.dedupeKey);Ze&&!q.includes(Ze)&&q.push(Ze)}return q},[K]),fe=VS(n||void 0,we),[Pe,L]=c.useState(!1),oe=c.useRef(0),ce=c.useRef(Re),he=c.useRef(null),Y=c.useRef(null),ve=c.useRef(null),Te=c.useRef(new Map),ke=c.useRef(new Map),xe=c.useRef(!1);c.useLayoutEffect(()=>{const q=ve.current?.parentElement;if(!q||typeof ResizeObserver>"u")return;const Be=new ResizeObserver(()=>{W(q.clientWidth||null)});return Be.observe(q),W(q.clientWidth||null),()=>Be.disconnect()},[]),c.useEffect(()=>{if(!A||xe.current){xe.current=A;return}const q=window.requestAnimationFrame(()=>{ve.current?.focus({preventScroll:!0})});return xe.current=!0,()=>window.cancelAnimationFrame(q)},[A]);const ge=c.useRef(null),Q=c.useRef(null),$=c.useCallback(()=>{Q.current=null;const q=ve.current,Be=he.current;!q||Be===null||q.style.setProperty("--oc-context-panel-width",`${Be}px`)},[]);c.useEffect(()=>()=>{Q.current!==null&&clearTimeout(Q.current)},[]);const J=c.useCallback(q=>{const Be=ge.current,Ze=H?Li(q):Rc(q,Mc(Be));return Be===null?Ze:Math.min(Ze,Math.max(1,Be))},[H]),me=c.useCallback(q=>{!A||_||!n||(Y.current=q.pointerId,L(!0),oe.current=q.clientX,ce.current=Re,he.current=Re,ge.current=OS(ve.current),document.documentElement.style.cursor="col-resize",q.preventDefault())},[n,_,A,Re]),le=c.useCallback(()=>{const q=J(he.current??Re),Be=ge.current;he.current=null,ge.current=null,Q.current!==null&&(clearTimeout(Q.current),Q.current=null),document.documentElement.style.cursor="",H?y(q):n&&I&&d(n,I,q,Be??void 0),L(!1),Y.current=null},[I,J,n,H,y,d,Re]);c.useEffect(()=>{if(!Pe)return;const q=Qe=>{if(Y.current!==Qe.pointerId)return;const et=oe.current-Qe.clientX,Ct=J(ce.current+et);he.current!==Ct&&(he.current=Ct,Q.current===null&&(Q.current=setTimeout($,ES)))},Be=Qe=>{Y.current===Qe.pointerId&&le()},Ze=()=>{le()};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Ze),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Ze)}},[$,J,le,Pe]),c.useEffect(()=>{Pe||(he.current=null,document.documentElement.style.cursor="")},[Pe]);const V=c.useCallback(()=>{n&&i(n)},[i,n]),Z=c.useCallback(()=>{n&&a(n)},[n,a]),G=c.useCallback(q=>{q.key==="Escape"&&(q.target instanceof Node&&!q.currentTarget.contains(q.target)||yg(q.target)||wg(q.target)||(q.preventDefault(),q.stopPropagation(),V()))},[V]);c.useEffect(()=>{if(!(!n||!D)&&D.mode==="file"&&D.targetPath){x(n,D.targetPath,{allowOutsideRoot:!0});return}},[D,n,x]);const ie=c.useMemo(()=>K.filter(q=>q.mode==="chat"),[K]),je=A&&D?.mode==="chat"?D.id:null,ne=A&&D?.mode==="chat"?pa(D.dedupeKey):null,Oe=Mx(ie,je);c.useEffect(()=>{if(!A||!n||!ne||typeof window>"u")return;const q=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){vi(n,ne,!1);return}Pu(ne),vi(n,ne,!0)};q();const Be=window.setInterval(q,1e4);return window.addEventListener("focus",q),window.addEventListener("blur",q),document.addEventListener("visibilitychange",q),()=>{window.clearInterval(Be),window.removeEventListener("focus",q),window.removeEventListener("blur",q),document.removeEventListener("visibilitychange",q),vi(n,ne,!1)}},[ne,n,A]);const Ve=c.useCallback((q,Be,Ze)=>Ox(ke.current,q,Be,n||null,Ze,{mode:C,lightThemeId:O,darkThemeId:M,currentTheme:F},{allowPromptingSubagentSessions:P}),[P,F,M,n,O,C]),ze=Oe&&ne?Ve(Oe.id,ne,Oe.readOnly):null;c.useEffect(()=>{const q=new Set(K.map(Be=>Be.id));for(const Be of ke.current.keys())q.has(Be)||ke.current.delete(Be)},[K]);const He=c.useCallback(q=>{!n||D?.mode!=="diff"||l(n,{mode:"diff",targetPath:D.targetPath,stagedDiff:q==="staged",diffScope:q})},[D,n,l]),$e=c.useCallback(()=>{if(typeof window>"u")return;const q={themeMode:C,lightThemeId:O,darkThemeId:M,currentTheme:F};for(const Be of Te.current.values()){const Ze=Be.contentWindow;Ze&&Ze.postMessage({type:"openchamber:theme-sync",payload:q},window.location.origin)}},[F,M,O,C]),R=c.useCallback(()=>{if(typeof window>"u")return;const q={allowPromptingSubagentSessions:P};for(const Be of Te.current.values()){const Ze=Be.contentWindow;Ze&&Ze.postMessage({type:"openchamber:chat-settings-sync",payload:q},window.location.origin)}},[P]),pe=c.useCallback((q,Be,Ze)=>{const Qe=Be.contentWindow;Qe&&Qe.postMessage({type:rf,payload:{visible:je===q}},Ze)},[je]),Le=c.useCallback(()=>{if(!(typeof window>"u"))for(const[q,Be]of Te.current.entries())pe(q,Be,window.location.origin)},[pe]);c.useEffect(()=>{if(typeof window>"u")return;const q=Be=>{if(Be.origin!==window.location.origin)return;const Ze=Array.from(Te.current.entries()).find(([,Tt])=>Tt.contentWindow===Be.source);if(!Ze)return;const Qe=Be.data;if(Qe?.type===Bx){const[Tt,Bt]=Ze;pe(Tt,Bt,Be.origin);return}if(Qe?.type===Fx){if(typeof Qe.requestId!="string"||!Qe.requestId)return;const Tt=Yt(),Bt={apiBaseUrl:pn(),clientToken:Vr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Wd(),relayHostId:Tt.startsWith("host:")?Tt.slice(5):"",relay:ah()??void 0};Be.source?.postMessage({type:Lx,requestId:Qe.requestId,payload:Bt},Be.origin);return}if(Qe?.type==="openchamber:theme-sync-request"){$e();return}if(Qe?.type==="openchamber:chat-settings-request"){R();return}if(Qe?.type!=="openchamber:cycle-theme-request")return;const et=["light","dark","system"],Ge=(et.indexOf(C)+1)%et.length;T(et[Ge])};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)},[R,pe,$e,T,C]),c.useLayoutEffect(()=>{K.some(Be=>Be.mode==="chat")&&($e(),R(),Le())},[M,O,R,Le,$e,K,C]);const _e=D?.mode==="file"||D?.mode==="chat"||D?.mode==="browser",lt=c.useMemo(()=>D?K.filter(q=>q.mode===D.mode):[],[D,K]),ht=c.useMemo(()=>lt.map(q=>{const Be=LS(q,fe,t),Ze=US(Be,RS),Qe=BS(q.targetPath,e);return{id:q.id,label:Ze,icon:Oc(q,N),title:Qe?`${Be}: ${Qe}`:Be,closeLabel:t("contextPanel.tab.closeTabAria",{label:Ze})}}),[lt,e,N,fe,t]),ot=D?.mode==="context"?s.jsx(Sw,{}):D?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(AS,{isActive:A})}):D?.mode==="pr"?s.jsx(I1,{}):D?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(PS,{})}):D?.mode==="notes"?s.jsx(_h,{}):D?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(DS,{targetPath:D.targetPath,savedProjectPlan:D.projectPlanId&&D.projectPlanRef?{projectRef:D.projectPlanRef,planId:D.projectPlanId}:null})}):null,ut=c.useMemo(()=>K.filter(q=>q.mode==="browser"),[K]),yt=c.useMemo(()=>K.filter(q=>q.mode==="diff"),[K]),mt=c.useMemo(()=>K.find(q=>q.mode==="terminal")??null,[K]),xt=c.useMemo(()=>K.some(q=>q.mode==="walkthrough"),[K]),Dt=c.useMemo(()=>K.filter(q=>$n(q.mode)),[K]),be=Ea(q=>q.guests),qe=c.useMemo(()=>new Set(be.filter(vg).map(q=>q.id)),[be]),Ye=c.useMemo(()=>{const q=new Map;for(const Be of be){const Ze=Sg(Be);Ze&&q.set(Be.id,Ze)}return q},[be]),Ue=c.useMemo(()=>K.some(q=>q.mode==="file"),[K]),ct=D?.mode==="file",X=ye(q=>q.closeContextPanelTabs),ae=c.useCallback(q=>{if(!n)return null;const{id:Be,index:Ze,allIds:Qe,close:et}=q,Ct=()=>X(n,Qe.filter(Xe=>Xe!==Be)),Ge=()=>X(n,Qe.slice(0,Ze)),Tt=()=>X(n,Qe.slice(Ze+1)),Bt=()=>X(n,Qe),Ce=Qe.length>1,Me=Ze===0,st=Ze===Qe.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Ln,{onClick:et,children:[s.jsx(B,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Wi,{}),s.jsxs(Ln,{onClick:Ct,disabled:!Ce,children:[s.jsx(B,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Ln,{onClick:Ge,disabled:Me,children:[s.jsx(B,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Ln,{onClick:Tt,disabled:st,children:[s.jsx(B,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Wi,{}),s.jsxs(Ln,{onClick:Bt,disabled:!Ce,children:[s.jsx(B,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[X,n,t]),De=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[_e?s.jsx(qd,{items:ht,activeId:D?.id??null,onSelect:q=>{n&&u(n,q)},onClose:q=>{n&&o(n,q)},onReorder:(q,Be)=>{n&&g(n,q,Be)},layoutMode:"scrollable",variant:"default",tabContextMenu:ae}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[D?Oc(D,N):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:D?Vf(D.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[D?.mode==="browser"?s.jsx(ft,{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(B,{name:"add",className:"h-3.5 w-3.5"})}):null,ct&&k?s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":v,children:s.jsx(B,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,ct?s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(B,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,H?null:s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:Z,className:"h-7 w-7 p-0",title:t(_?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(_?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:_?s.jsx(B,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(B,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:V,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(B,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Ke=A?_?{"--oc-context-panel-width":E!==null?`${E}px`:"100%",width:E!==null?`${E}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${Re}px`}:{"--oc-context-panel-width":`${Re}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ve,"data-context-panel":"true",tabIndex:-1,inert:!A||void 0,className:Ie("flex min-h-0 flex-col overflow-hidden bg-background",_?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!A&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:G,style:Ke,children:[A&&!_&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),A&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!_&&s.jsx("div",{className:Ie("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Pe&&"bg-[var(--interactive-border)]"),onPointerDown:me,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Ie("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]",!A&&"pointer-events-none select-none opacity-0"),style:{width:_?E!==null?`${E}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!A,children:[De,s.jsxs("div",{className:Ie("relative min-h-0 flex-1 overflow-hidden",Pe&&"pointer-events-none"),children:[Ue?s.jsxs("div",{className:Ie("absolute inset-0 flex",ct?"flex":"hidden"),children:[k||!b?s.jsx("div",{className:Ie("h-full min-w-0 flex-1",k&&!v&&"hidden"),children:k?s.jsx(c.Suspense,{fallback:null,children:s.jsx(NS,{mode:"editor-only",visible:A&&ct&&v})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(B,{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(zS,{visible:b,active:A&&ct,fill:!v})]}):null,Oe&&ne&&ze?s.jsx("iframe",{ref:q=>{if(!q){Te.current.delete(Oe.id);return}Te.current.set(Oe.id,q)},src:ze,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ne}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{$e(),R(),Le()}},Oe.id):null,ut.map(q=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==q.id&&"invisible pointer-events-none"),"aria-hidden":D?.id!==q.id||void 0,children:s.jsx(yS,{initialUrl:q.targetPath??"",directory:n,tabID:q.id})},q.id)),yt.map(q=>s.jsx("div",{className:Ie("absolute inset-0",D?.id!==q.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(CS,{visible:A&&D?.id===q.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:q.diffScope??(q.stagedDiff?"staged":"working"),onDiffScopeChange:He,targetFilePath:q.targetPath,flushContent:!0})})},q.id)),mt?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="terminal"?"block":"hidden"),children:s.jsx($h,{visible:A&&D?.mode==="terminal",directory:mt.targetDirectory})}):null,xt?s.jsx("div",{className:Ie("absolute inset-0",D?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(kS,{directory:e,visible:A&&D?.mode==="walkthrough"})})}):null,Dt.map(q=>{if(!$n(q.mode))return null;const Be=Oo(q.mode),Ze=qe.has(Be),Qe=Ye.get(Be),et=D?.id===q.id,Ct=et&&A;return Ze&&!Qe&&!Ct?null:s.jsx("div",{className:Ie("absolute inset-0",et?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:Ze?Qe?s.jsxs("div",{className:Ie("flex h-full",Wf[Qe.dock].container),children:[s.jsx(IS,{mode:q.mode,docking:Qe}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:Ct?s.jsx(Ec,{mode:q.mode}):null})]}):s.jsx(Ec,{mode:q.mode}):s.jsx(zf,{mode:q.mode})})},q.id)}),D?.mode!=="chat"&&!ct&&D?.mode!=="browser"&&D?.mode!=="diff"&&D?.mode!=="terminal"&&D?.mode!=="walkthrough"&&!(D&&$n(D.mode))?ot:null]})]})]})},GS=t=>{const e=nt.c(43),{open:n,onOpenChange:r}=t,{t:i}=At(),o=ye(qS),l=ye(YS),a=ye(QS),d=ye(XS),u=Ba();let m;e[0]!==o||e[1]!==u?(m=Du(o,u),e[0]=o,e[1]=u,e[2]=m):m=e[2];const f=m,g=l.length===0;let x;if(e[3]!==l||e[4]!==f){let O;e[6]!==l?(O=M=>l.includes(M.id),e[6]=l,e[7]=O):O=e[7],x=f.every(O),e[3]=l,e[4]=f,e[5]=x}else x=e[5];const b=x;let j;e[8]!==i?(j=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=j):j=e[9];let y;e[10]!==j?(y=s.jsx(Ls,{children:j}),e[10]=j,e[11]=y):y=e[11];let h;e[12]!==i?(h=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=h):h=e[13];let p;e[14]!==h?(p=s.jsx(_s,{children:h}),e[14]=h,e[15]=p):p=e[15];let w;e[16]!==y||e[17]!==p?(w=s.jsxs(Hs,{children:[y,p]}),e[16]=y,e[17]=p,e[18]=w):w=e[18];let S;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let O;e[24]!==l||e[25]!==a||e[26]!==i?(O=M=>s.jsx(Ng,{settingsItem:`layout.context-rail.surface.${M.id}`,checked:!l.includes(M.id),onChange:F=>a(M.id,F),label:M.label??i(M.labelKey),ariaLabel:M.label??i(M.labelKey)},M.id),e[24]=l,e[25]=a,e[26]=i,e[27]=O):O=e[27],S=f.map(O),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=S}else S=e[23];let N;e[28]!==S?(N=s.jsx("div",{className:"flex flex-col",children:S}),e[28]=S,e[29]=N):N=e[29];let P;e[30]!==g||e[31]!==b||e[32]!==d||e[33]!==i?(P=g?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(ft,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=g,e[31]=b,e[32]=d,e[33]=i,e[34]=P):P=e[34];let C;e[35]!==P||e[36]!==w||e[37]!==N?(C=s.jsxs(Ns,{className:"max-w-md",children:[w,N,P]}),e[35]=P,e[36]=w,e[37]=N,e[38]=C):C=e[38];let T;return e[39]!==r||e[40]!==n||e[41]!==C?(T=s.jsx(Cs,{open:n,onOpenChange:r,children:C}),e[39]=r,e[40]=n,e[41]=C,e[42]=T):T=e[42],T};function qS(t){return t.contextRailOrder}function YS(t){return t.contextRailHiddenSurfaces}function QS(t){return t.setContextRailSurfaceVisible}function XS(t){return t.setContextRailHiddenSurfaces}const Uf=150,JS=500,ZS=[],ej=t=>t>99?"99+":String(t),tj=t=>{const e=nt.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:m,showOrderNumber:f,onSelect:g}=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:j,setNodeRef:y,transform:h,transition:p,isDragging:w}=oi(x);let S;e[2]!==a?(S=a!=null&&a>0?ej(a):null,e[2]=a,e[3]=S):S=e[3];const N=S;let P;e[4]!==h?(P=ii.Translate.toString(h),e[4]=h,e[5]=P):P=e[5];let C;e[6]!==P||e[7]!==p?(C={transform:P,transition:p},e[6]=P,e[7]=p,e[8]=C):C=e[8];const T=w&&"z-10 opacity-70";let O;e[9]!==T?(O=Ie("relative",T),e[9]=T,e[10]=O):O=e[10];let M;e[11]!==g||e[12]!==n?(M=()=>g(n),e[11]=g,e[12]=n,e[13]=M):M=e[13];const F=d??o,K=r?"text-primary":"text-muted-foreground hover:text-foreground";let D;e[14]!==K?(D=Ie("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",K),e[14]=K,e[15]=D):D=e[15];let U;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?(U=n.id==="diff"?s.jsx(hf,{className:"h-[18px] w-[18px]"}):s.jsx(Qr,{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]=U):U=e[19];let A;e[20]!==N||e[21]!==m||e[22]!==i||e[23]!==f?(A=f&&m!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:m===10?"0":m}):N?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:N}):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]=N,e[21]=m,e[22]=i,e[23]=f,e[24]=A):A=e[24];let E;e[25]!==b||e[26]!==r||e[27]!==j||e[28]!==D||e[29]!==U||e[30]!==A||e[31]!==M||e[32]!==F?(E=s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",...b,...j,onClick:M,"aria-label":F,"aria-pressed":r,className:D,children:[U,A]})}),e[25]=b,e[26]=r,e[27]=j,e[28]=D,e[29]=U,e[30]=A,e[31]=M,e[32]=F,e[33]=E):E=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let k;e[36]!==l?(k=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=k):k=e[37];let v;e[38]!==u?(v=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=v):v=e[39];let I;e[40]!==W||e[41]!==k||e[42]!==v?(I=s.jsx(jt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,k,v]})}),e[40]=W,e[41]=k,e[42]=v,e[43]=I):I=e[43];let H;e[44]!==E||e[45]!==I?(H=s.jsxs(vt,{delayDuration:Uf,children:[E,I]}),e[44]=E,e[45]=I,e[46]=H):H=e[46];let _;return e[47]!==y||e[48]!==H||e[49]!==C||e[50]!==O?(_=s.jsx("div",{ref:y,style:C,className:O,children:H}),e[47]=y,e[48]=H,e[49]=C,e[50]=O,e[51]=_):_=e[51],_},sj=()=>{const t=nt.c(92),{t:e}=At(),n=Yn();let r;t[0]!==n?(r=n?Fn(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=ye(o),a=ye(nj),d=ye(rj),u=ye(oj),m=ye(ij),f=ye(aj),g=ye(lj),x=ye(cj),b=Ra(dj),j=Hi(uj),y=Hi(fj),h=gn(mj),p=gn(hj),{screenWidth:w}=Dn(),S=Ma(i||null);let N;t[4]!==x?(N=Gi("switch_context_surface",x),t[4]=x,t[5]=N):N=t[5];const P=N,[C,T]=c.useState(!1);let O,M;t[6]!==P?(O=()=>{const le=new Set;let V=null,Z=!1;const G=pj,ie=()=>{Rl(P,le)?!Z&&V===null&&(V=setTimeout(()=>T(!0),JS)):(Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1))},je=Ve=>{if(le.add(Ve.key.toLowerCase()),G(Ve.key)&&Rl(P,le)){Z=!0,V!==null&&(clearTimeout(V),V=null),T(!1);return}ie()},ne=Ve=>{le.delete(Ve.key.toLowerCase()),ie()},Oe=()=>{le.clear(),Z=!1,V!==null&&(clearTimeout(V),V=null),T(!1)};return window.addEventListener("keydown",je,!0),window.addEventListener("keyup",ne,!0),window.addEventListener("blur",Oe),()=>{window.removeEventListener("keydown",je,!0),window.removeEventListener("keyup",ne,!0),window.removeEventListener("blur",Oe),V!==null&&clearTimeout(V)}},M=[P],t[6]=P,t[7]=O,t[8]=M):(O=t[7],M=t[8]),c.useEffect(O,M);let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F={activationConstraint:{distance:8}},t[9]=F):F=t[9];let K;t[10]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{delay:200,tolerance:6}},t[10]=K):K=t[10];const D=ei(mn(si,F),mn(ti,K)),U=Ba(),A=El(gj),E=El(bj),W=l?.tabs??ZS;let k;t[11]!==l?.activeTabId||t[12]!==W?(k=W.find(le=>le.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=k):k=t[13];const v=k,I=l?.isOpen?v?.mode??null:null,H=S?.files.length??0;let _;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==U||t[18]!==y||t[19]!==b||t[20]!==w||t[21]!==W?(_=Ag({railOrder:d,hiddenSurfaces:u,planModeEnabled:b,isVSCode:Pn(),screenWidth:w,tabs:W,linearConnected:y,githubConnected:p,extras:U}),t[14]=u,t[15]=d,t[16]=p,t[17]=U,t[18]=y,t[19]=b,t[20]=w,t[21]=W,t[22]=_):_=t[22];const se=_;let te,ee;t[23]!==I||t[24]!==g||t[25]!==i||t[26]!==j||t[27]!==y?(ee=()=>{!i||!j||y||I!=="linear"||g(i)},te=[I,g,i,j,y],t[23]=I,t[24]=g,t[25]=i,t[26]=j,t[27]=y,t[28]=te,t[29]=ee):(te=t[28],ee=t[29]),c.useEffect(ee,te);let ue,de;t[30]!==I||t[31]!==g||t[32]!==i||t[33]!==h||t[34]!==p?(ue=()=>{!i||!h||p||I!=="pr"||g(i)},de=[I,g,i,h,p],t[30]=I,t[31]=g,t[32]=i,t[33]=h,t[34]=p,t[35]=ue,t[36]=de):(ue=t[35],de=t[36]),c.useEffect(ue,de);const[Re,we]=c.useState(!1);let fe;t[37]!==U||t[38]!==m?(fe=le=>{const{active:V,over:Z}=le;if(!Z||V.id===Z.id)return;const G=Du(ye.getState().contextRailOrder,U).map(xj),ie=G.indexOf(V.id),je=G.indexOf(Z.id);ie===-1||je===-1||m(Ju(G,ie,je))},t[37]=U,t[38]=m,t[39]=fe):fe=t[39];const Pe=fe;if(!i)return null;let L;t[40]!==e?(L=e("contextRail.aria.rail"),t[40]=e,t[41]=L):L=t[41];let oe;t[42]!==se?(oe=se.map(yj),t[42]=se,t[43]=oe):oe=t[43];let ce;if(t[44]!==I||t[45]!==H||t[46]!==E||t[47]!==i||t[48]!==A||t[49]!==f||t[50]!==C||t[51]!==se||t[52]!==e||t[53]!==a){let le;t[55]!==I||t[56]!==H||t[57]!==E||t[58]!==i||t[59]!==A||t[60]!==f||t[61]!==C||t[62]!==e||t[63]!==a?(le=(V,Z)=>{const G=V.label??e(V.labelKey),ie=V.id==="git"&&!a?H:0,je=$n(V.mode)&&I!==V.mode?A[Oo(V.mode)]??0:0,ne=ie>0?ie:je>0?je:null,Oe=ne!==null&&ie===0;return s.jsx(tj,{surface:V,isActive:I===V.mode,showActivityDot:!1,label:G,description:e(V.descriptionKey),badgeCount:ne,badgeAriaLabel:ne!==null?e(Oe?ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:G,count:ne}):null,badgeDescription:ne!==null?e(Oe?ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:ne}):null,orderNumber:Z+1,showOrderNumber:C,onSelect:Ve=>{$n(Ve.mode)&&E(Oo(Ve.mode)),f(i,Ve.mode)}},V.id)},t[55]=I,t[56]=H,t[57]=E,t[58]=i,t[59]=A,t[60]=f,t[61]=C,t[62]=e,t[63]=a,t[64]=le):le=t[64],ce=se.map(le),t[44]=I,t[45]=H,t[46]=E,t[47]=i,t[48]=A,t[49]=f,t[50]=C,t[51]=se,t[52]=e,t[53]=a,t[54]=ce}else ce=t[54];let he;t[65]!==oe||t[66]!==ce?(he=s.jsx(Ha,{items:oe,strategy:Zu,children:ce}),t[65]=oe,t[66]=ce,t[67]=he):he=t[67];let Y;t[68]!==Pe||t[69]!==D||t[70]!==he?(Y=s.jsx(ni,{sensors:D,collisionDetection:ri,onDragEnd:Pe,children:he}),t[68]=Pe,t[69]=D,t[70]=he,t[71]=Y):Y=t[71];let ve;t[72]!==e?(ve=e("contextRail.configure.open"),t[72]=e,t[73]=ve):ve=t[73];let Te;t[74]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>we(!0),t[74]=Te):Te=t[74];let ke;t[75]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(B,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=ke):ke=t[75];let xe;t[76]!==ve?(xe=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":ve,onClick:Te,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:ke})}),t[76]=ve,t[77]=xe):xe=t[77];let ge;t[78]!==e?(ge=e("contextRail.configure.open"),t[78]=e,t[79]=ge):ge=t[79];let Q;t[80]!==ge?(Q=s.jsx(jt,{side:"left",sideOffset:8,children:ge}),t[80]=ge,t[81]=Q):Q=t[81];let $;t[82]!==xe||t[83]!==Q?($=s.jsxs(vt,{delayDuration:Uf,children:[xe,Q]}),t[82]=xe,t[83]=Q,t[84]=$):$=t[84];let J;t[85]!==Re?(J=s.jsx(GS,{open:Re,onOpenChange:we}),t[85]=Re,t[86]=J):J=t[86];let me;return t[87]!==L||t[88]!==Y||t[89]!==$||t[90]!==J?(me=s.jsxs("nav",{"aria-label":L,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[Y,$,J]}),t[87]=L,t[88]=Y,t[89]=$,t[90]=J,t[91]=me):me=t[91],me};function nj(t){return t.workStatusPanelVisible}function rj(t){return t.contextRailOrder}function oj(t){return t.contextRailHiddenSurfaces}function ij(t){return t.setContextRailOrder}function aj(t){return t.openContextSurface}function lj(t){return t.closeContextPanel}function cj(t){return t.shortcutOverrides}function dj(t){return t.planModeEnabled}function uj(t){return t.hasChecked}function fj(t){return t.status?.connected===!0}function mj(t){return t.hasChecked}function hj(t){return t.status?.connected===!0}function pj(t){return t.length===1&&t>="0"&&t<="9"}function gj(t){return t.countByGuest}function bj(t){return t.clearBadge}function xj(t){return t.id}function yj(t){return t.id}const wj=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),vj=(t,e,n,r)=>!n||r!==n||t.length===0?[]:Rr(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),Sj=new Set,jj=[],ga=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},kj=()=>{const t=nt.c(184),{t:e}=At(),n=ye(Cj),r=ye(Nj),i=ye(Aj),o=ye(Pj),l=ye(Dj),a=ye(Ij),d=ye(Tj),u=ye(Ej),m=ye(Rj),f=ye(Mj),g=ye(Oj),x=ye(Bj),b=rt(Fj),j=rt(Lj),y=rt(_j),h=Ur($j);let p;t[0]!==n?(p=Ne=>n?Ne.activeSessions:jj,t[0]=n,t[1]=p):p=t[1];const w=gs(p);let S;t[2]!==n?(S=Ne=>n?Ne.ids:Sj,t[2]=n,t[3]=S):S=t[3];const N=Ur(S);let P;t[4]!==n?(P=Ne=>n?Ne.rankById:La,t[4]=n,t[5]=P):P=t[5];const C=Fa(P),T=ts(zj),O=Kt(Wj),M=Kt(Kj),F=Yn(),K=$d(Vj),{files:D,git:U}=bn(),A=Xn(Uj),{isMobile:E}=Dn();let W;t[6]!==F?(W=F?ga(F):null,t[6]=F,t[7]=W):W=t[7];const k=W,[v,I]=c.useState(""),_=Cu(v,200).trim();let se;t[8]!==v?(se=v.trim(),t[8]=v,t[9]=se):se=t[9];const te=se;let ee,ue;t[10]!==n?(ee=()=>{n&&I("")},ue=[n],t[10]=n,t[11]=ee,t[12]=ue):(ee=t[11],ue=t[12]),c.useEffect(ee,ue);let de,Re;t[13]!==w||t[14]!==A||t[15]!==U||t[16]!==n?(de=()=>{if(!n||!U)return;const Ne=setTimeout(()=>{const We=new Set;for(const dt of w){const bt=Is(dt);!bt||We.has(bt)||(We.add(bt),A(bt,U))}},0);return()=>clearTimeout(Ne)},Re=[n,w,U,A],t[13]=w,t[14]=A,t[15]=U,t[16]=n,t[17]=de,t[18]=Re):(de=t[17],Re=t[18]),c.useEffect(de,Re);let we;t[19]!==r?(we=()=>r(!1),t[19]=r,t[20]=we):we=t[20];const fe=we;let Pe;t[21]!==fe?(Pe=Ne=>()=>{fe(),Ne()},t[21]=fe,t[22]=Pe):Pe=t[22];const L=Pe;let oe;t[23]!==O?.id||t[24]!==O?.path||t[25]!==T||t[26]!==y||t[27]!==E||t[28]!==d||t[29]!==u||t[30]!==b||t[31]!==L||t[32]!==g||t[33]!==x||t[34]!==l||t[35]!==i||t[36]!==e||t[37]!==h||t[38]!==a?(oe=()=>{const Ne=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(B,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:L(()=>{l(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(B,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:L(Hj)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(B,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:L(Gj)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(B,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:L(()=>{if(E){const{isSessionSwitcherOpen:We}=ye.getState();l(!We)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(B,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:L(()=>{T&&u(T,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(B,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:L(()=>{T&&d(T)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(B,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:L(qj)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(B,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:L(Yj)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(B,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:L(()=>i(!0))}];return Ne.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(B,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:L(()=>{y&&T&&h({directory:T,sessionId:y})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(B,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:L(()=>{y&&Gn(y).then(We=>{if(We.ok){Fe.success(e("sessions.sidebar.session.copyId.success"));return}Fe.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Fe.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(B,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:L(()=>{l(!1),Eg()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(B,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:L(()=>{l(!1),g(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(B,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:L(()=>{T&&(x("notes"),u(T,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(B,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:L(()=>{T&&(x("todos"),u(T,"notes"))})}),Pn()||Ne.push({id:"restart-opencode",secondary:!0,title:e("commandPalette.item.restartOpenCode"),icon:s.jsx(B,{name:"restart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.restartOpenCode"),onSelect:L(()=>{Vh(e)})}),Ne.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(B,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:L(Qj)}),Kr()&&Ne.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(B,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:L(()=>{An("desktop_open_draft_mini_chat_window",{directory:ga(T||O?.path||""),projectId:O?.id??null}).catch(Xj)})}),Ne},t[23]=O?.id,t[24]=O?.path,t[25]=T,t[26]=y,t[27]=E,t[28]=d,t[29]=u,t[30]=b,t[31]=L,t[32]=g,t[33]=x,t[34]=l,t[35]=i,t[36]=e,t[37]=h,t[38]=a,t[39]=oe):oe=t[39],O?.id,O?.path;let ce;t[40]!==oe?(ce=oe(),t[40]=oe,t[41]=ce):ce=t[41];const he=ce,Y=ye(Jj),ve=zh(),Te=Wh();let ke;t[42]===Symbol.for("react.memo_cache_sentinel")?(ke=hn(),t[42]=ke):ke=t[42];const xe=ke;let ge,Q;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=Pn(),Q=!xe&&Da(),t[43]=ge,t[44]=Q):(ge=t[43],Q=t[44]);let $;t[45]!==ve||t[46]!==E||t[47]!==Te||t[48]!==Y?($={isVSCode:ge,isWeb:Q,isDesktop:xe,isMobile:E,routingAvailable:Y,enterpriseMode:ve,jevBlockedByEnterprise:Te},t[45]=ve,t[46]=E,t[47]=Te,t[48]=Y,t[49]=$):$=t[49];const J=$;let me;if(t[50]!==L||t[51]!==i||t[52]!==o||t[53]!==J){let Ne;t[55]!==J?(Ne=dt=>dt.isAvailable?dt.isAvailable(J):!0,t[55]=J,t[56]=Ne):Ne=t[56];let We;t[57]!==L||t[58]!==i||t[59]!==o?(We=dt=>{const bt=Uh(dt.slug)??"settings-3",Se=(dt.keywords??[]).join(" ");return{id:`settings:${dt.slug}`,title:dt.title,icon:dt.slug==="mcp"?s.jsx(Rg,{className:"mr-2 h-4 w-4"}):s.jsx(B,{name:bt,className:"mr-2 h-4 w-4"}),searchText:`${dt.title} ${dt.group} ${Se}`,onSelect:L(()=>{o(dt.slug),i(!0)})}},t[57]=L,t[58]=i,t[59]=o,t[60]=We):We=t[60],me=Kh.filter(Zj).filter(Ne).map(We),t[50]=L,t[51]=i,t[52]=o,t[53]=J,t[54]=me}else me=t[54];const le=me;let V;if(t[61]!==w||t[62]!==N||t[63]!==C){const Ne=w.filter(e0);V=Pg(Ne,N,C),t[61]=w,t[62]=N,t[63]=C,t[64]=V}else V=t[64];const Z=V,G=Iu(),ie=rt(t0);let je;t[65]!==G||t[66]!==ie?(je=(Ne,We)=>{const dt=ie.get(Ne);return dt?.branch?dt.branch.trim()||null:We&&G.get(We)?.trim()||null},t[65]=G,t[66]=ie,t[67]=je):je=t[67];const ne=je;let Oe;t[68]===Symbol.for("react.memo_cache_sentinel")?(Oe=[],t[68]=Oe):Oe=t[68];const[Ve,ze]=c.useState(Oe),[He,$e]=c.useState(""),R=wj(k,_);let pe;t[69]!==k||t[70]!==R||t[71]!==n||t[72]!==K||t[73]!==ze||t[74]!==$e||t[75]!==_?(pe=()=>{if(!n){ze([]),$e("");return}if(!R){ze([]),$e("");return}if(!k){ze([]),$e("");return}let Ne=!1;return K(k,_,40,{type:"file"}).then(We=>{Ne||(ze(We.map(s0)),$e(R))}).catch(()=>{Ne||(ze([]),$e(R))}),()=>{Ne=!0}},t[69]=k,t[70]=R,t[71]=n,t[72]=K,t[73]=ze,t[74]=$e,t[75]=_,t[76]=pe):pe=t[76];let Le;t[77]!==k||t[78]!==R||t[79]!==n||t[80]!==K||t[81]!==_?(Le=[n,k,_,R,K],t[77]=k,t[78]=R,t[79]=n,t[80]=K,t[81]=_,t[82]=Le):Le=t[82],c.useEffect(pe,Le);const _e=te.length>0;let lt;e:{if(!_e){let We;t[83]!==he?(We=he.filter(n0).map(r0),t[83]=he,t[84]=We):We=t[84],lt=We;break e}let Ne;t[85]!==he||t[86]!==te?(Ne=Rr(he,te,o0,{limit:7,noFuzzy:!0}),t[85]=he,t[86]=te,t[87]=Ne):Ne=t[87],lt=Ne}const ht=lt;let ot;e:{if(!_e){let We;t[88]===Symbol.for("react.memo_cache_sentinel")?(We=[],t[88]=We):We=t[88],ot=We;break e}let Ne;t[89]!==te||t[90]!==le?(Ne=Rr(le,te,i0,{limit:7,noFuzzy:!0}),t[89]=te,t[90]=le,t[91]=Ne):Ne=t[91],ot=Ne}const ut=ot;let yt;e:{if(!_e){let We;t[92]!==Z?(We=Z.slice(0,5).map(a0),t[92]=Z,t[93]=We):We=t[93],yt=We;break e}let Ne;t[94]!==te||t[95]!==Z?(Ne=Rr(Z,te,l0,{limit:7,threshold:.2}),t[94]=te,t[95]=Z,t[96]=Ne):Ne=t[96],yt=Ne}const mt=yt;let xt;e:{if(!n){let We;t[97]===Symbol.for("react.memo_cache_sentinel")?(We=[],t[97]=We):We=t[97],xt=We;break e}let Ne;t[98]!==Ve||t[99]!==He||t[100]!==R||t[101]!==_?(Ne=vj(Ve,_,R,He),t[98]=Ve,t[99]=He,t[100]=R,t[101]=_,t[102]=Ne):Ne=t[102],xt=Ne}const Dt=xt,be=n&&R.length>0&&He!==R;let qe;e:{if(!_e){let We;t[103]===Symbol.for("react.memo_cache_sentinel")?(We=[],t[103]=We):We=t[103],qe=We;break e}let Ne;if(t[104]!==te||t[105]!==M){const We=M.map(c0);Ne=Rr(We,te,d0,{limit:7,threshold:.4}),t[104]=te,t[105]=M,t[106]=Ne}else Ne=t[106];qe=Ne}const Ye=qe;let Ue,ct,X,ae,De,Ke,q,Be,Ze,Qe,et,Ct,Ge,Tt;if(t[107]!==ne||t[108]!==fe||t[109]!==k||t[110]!==D||t[111]!==_e||t[112]!==n||t[113]!==m||t[114]!==b||t[115]!==v||t[116]!==ht||t[117]!==Dt||t[118]!==Ye||t[119]!==mt||t[120]!==ut||t[121]!==r||t[122]!==j||t[123]!==f||t[124]!==e){const Ne=ht.map(u0),We=ut.map(f0),dt=mt.map(m0),bt=_e?Dt.map(h0):[],Se=_e?Ye.map(p0):[];let Je;e:{if(!_e){Je=["commands","sessions"];break e}const Ot=g0,It=[{key:"commands",score:Ot(ht)},{key:"settings",score:Ot(ut)},{key:"sessions",score:Ot(mt)},{key:"files",score:Ot(Dt)},{key:"projects",score:Ot(Ye)}];It.sort(b0),Je=It.map(x0)}const it=Je,pt=Ot=>{fe(),j(Ot.id,Is(Ot))},kt=async Ot=>{if(!k)return;const It=await yf(D,Ot,{directory:k});if(!It.ok){Fe.error(wf(It.reason));return}m(k,Ot),fe()},_t=(Ot,It)=>{fe(),b({selectedProjectId:Ot,directoryOverride:It})},qt=Ot=>zn(Xr(Ot,f));ae=Cs,Ct=n,Ge=r;let Mt;t[139]!==e?(Mt=e("commandPalette.title"),t[139]=e,t[140]=Mt):Mt=t[140];let Lt;t[141]!==Mt?(Lt=s.jsx(Ls,{children:Mt}),t[141]=Mt,t[142]=Lt):Lt=t[142];let Wt;t[143]!==e?(Wt=e("commandPalette.description"),t[143]=e,t[144]=Wt):Wt=t[144];let Jt;t[145]!==Wt?(Jt=s.jsx(_s,{children:Wt}),t[145]=Wt,t[146]=Jt):Jt=t[146],t[147]!==Lt||t[148]!==Jt?(Tt=s.jsxs(Hs,{className:"sr-only",children:[Lt,Jt]}),t[147]=Lt,t[148]=Jt,t[149]=Tt):Tt=t[149],X=Ns,Qe="overflow-hidden p-0",et=!0,ct=Mg,q=!1,Be="[&_[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 Zt;t[150]!==e?(Zt=e("commandPalette.input.placeholder"),t[150]=e,t[151]=Zt):Zt=t[151],t[152]!==v||t[153]!==Zt?(Ze=s.jsx(Og,{value:v,onValueChange:I,placeholder:Zt}),t[152]=v,t[153]=Zt,t[154]=Ze):Ze=t[154],Ue=Bg;let Ft;t[155]!==e?(Ft=e("commandPalette.empty.noResults"),t[155]=e,t[156]=Ft):Ft=t[156],t[157]!==Ft?(De=s.jsx(Fg,{children:Ft}),t[157]=Ft,t[158]=De):De=t[158],Ke=it.map(Ot=>Ot==="commands"&&Ne.length>0?s.jsx(Cr,{children:Ne.map(It=>s.jsxs(Mr,{value:It.id,onSelect:It.onSelect,children:[It.icon,s.jsx("span",{children:It.title}),It.shortcutId?s.jsx(Dg,{children:qt(It.shortcutId)}):null]},It.id))},"commands"):Ot==="settings"&&We.length>0?s.jsx(Cr,{children:We.map(y0)},"settings"):Ot==="sessions"&&dt.length>0?s.jsx(Cr,{children:dt.map(It=>{const ss=It.title||e("commandPalette.session.untitled"),yn=Is(It),fs=ne(It.id,yn);return s.jsxs(Mr,{value:`session:${It.id}`,onSelect:()=>pt(It),children:[s.jsx(B,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ss}),fs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:fs})]}):null]},It.id)})},"sessions"):Ot==="files"&&bt.length>0?s.jsx(Cr,{children:bt.map(It=>{const ss=Ig(It.relativePath||It.name,{maxLength:80});return s.jsxs(Mr,{value:`file:${It.path}`,onSelect:()=>{kt(It.path)},children:[s.jsx(Oa,{filePath:It.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":It.relativePath,children:ss})]},`file:${It.path}`)})},"files"):Ot==="projects"&&Se.length>0?s.jsx(Cr,{children:Se.map(It=>{const ss=It.displayName;return s.jsxs(Mr,{value:`project:${It.id}`,onSelect:()=>_t(It.id,It.path),children:[s.jsx(B,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:ss}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:It.path})]},`project:${It.id}`)})},"projects"):null),t[107]=ne,t[108]=fe,t[109]=k,t[110]=D,t[111]=_e,t[112]=n,t[113]=m,t[114]=b,t[115]=v,t[116]=ht,t[117]=Dt,t[118]=Ye,t[119]=mt,t[120]=ut,t[121]=r,t[122]=j,t[123]=f,t[124]=e,t[125]=Ue,t[126]=ct,t[127]=X,t[128]=ae,t[129]=De,t[130]=Ke,t[131]=q,t[132]=Be,t[133]=Ze,t[134]=Qe,t[135]=et,t[136]=Ct,t[137]=Ge,t[138]=Tt}else Ue=t[125],ct=t[126],X=t[127],ae=t[128],De=t[129],Ke=t[130],q=t[131],Be=t[132],Ze=t[133],Qe=t[134],et=t[135],Ct=t[136],Ge=t[137],Tt=t[138];let Bt;t[159]!==be||t[160]!==e?(Bt=be?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[159]=be,t[160]=e,t[161]=Bt):Bt=t[161];let Ce;t[162]!==Ue||t[163]!==De||t[164]!==Ke||t[165]!==Bt?(Ce=s.jsxs(Ue,{children:[De,Ke,Bt]}),t[162]=Ue,t[163]=De,t[164]=Ke,t[165]=Bt,t[166]=Ce):Ce=t[166];let Me;t[167]!==ct||t[168]!==q||t[169]!==Be||t[170]!==Ze||t[171]!==Ce?(Me=s.jsxs(ct,{shouldFilter:q,className:Be,children:[Ze,Ce]}),t[167]=ct,t[168]=q,t[169]=Be,t[170]=Ze,t[171]=Ce,t[172]=Me):Me=t[172];let st;t[173]!==X||t[174]!==Qe||t[175]!==et||t[176]!==Me?(st=s.jsx(X,{className:Qe,showCloseButton:et,children:Me}),t[173]=X,t[174]=Qe,t[175]=et,t[176]=Me,t[177]=st):st=t[177];let Xe;return t[178]!==ae||t[179]!==Ct||t[180]!==Ge||t[181]!==Tt||t[182]!==st?(Xe=s.jsxs(ae,{open:Ct,onOpenChange:Ge,children:[Tt,st]}),t[178]=ae,t[179]=Ct,t[180]=Ge,t[181]=Tt,t[182]=st,t[183]=Xe):Xe=t[183],Xe};function Cj(t){return t.isCommandPaletteOpen}function Nj(t){return t.setCommandPaletteOpen}function Aj(t){return t.setSettingsDialogOpen}function Pj(t){return t.setSettingsPage}function Dj(t){return t.setSessionSwitcherOpen}function Ij(t){return t.toggleSidebar}function Tj(t){return t.openContextOverview}function Ej(t){return t.openContextSurface}function Rj(t){return t.openContextFile}function Mj(t){return t.shortcutOverrides}function Oj(t){return t.setArchivePageOpen}function Bj(t){return t.setProjectContextTab}function Fj(t){return t.openNewSessionDraft}function Lj(t){return t.setCurrentSession}function _j(t){return t.currentSessionId}function $j(t){return t.toggle}function zj(t){return t.currentDirectory}function Wj(t){return t.getActiveProject()}function Kj(t){return t.projects}function Vj(t){return t.searchFiles}function Uj(t){return t.ensureStatus}function Hj(){Tu()}function Gj(){Us.requestDirectoryDialog()}function qj(){Lg.invoke("cycle_theme")}function Yj(){Eu()}function Qj(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function Xj(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function Jj(t){return t.routingFeatureAvailable}function Zj(t){return t.slug!=="home"}function e0(t){return!Tg(t)}function t0(t){return t.worktreeMetadata}function s0(t){return{path:ga(t.path),name:t.name,relativePath:t.relativePath}}function n0(t){return!t.secondary}function r0(t){return{item:t,score:0}}function o0(t){return t.searchText}function i0(t){return t.searchText}function a0(t){return{item:t,score:0}}function l0(t){return t.title||""}function c0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function d0(t){return t.searchText}function u0(t){return t.item}function f0(t){return t.item}function m0(t){return t.item}function h0(t){return t.item}function p0(t){return t.item}function g0(t){return t.length?t[0].score:1/0}function b0(t,e){return t.score-e.score}function x0(t){return t.key}function y0(t){return s.jsxs(Mr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Bc=(t,e,n)=>zn(Xr(t,e),n),w0=()=>{const t=nt.c(47),{t:e}=At(),n=ye(v0),r=ye(S0),i=ye(j0);let o,l,a,d,u,m,f,g,x,b,j,y;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",column:"left",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[zn("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",column:"right",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",column:"right",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${zn(Gi("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${zn(Gi("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",column:"left",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}],P=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(D=>{const U=D.id?_g(D.id):void 0,A=D.descriptionKey??(U?.customizable?U.settingsLabelKey:void 0);if(!A||D.id&&!Xr(D.id,i))return null;const E=D.id?Bc(D.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(D.keys)?D.keys:D.keys.split(" / ");return s.jsxs("div",{className:"flex items-center gap-3 py-1 px-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[D.icon&&s.jsx(B,{name:D.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(A)})]}),s.jsx("div",{"aria-hidden":!0,className:"min-w-4 flex-1 border-b border-dotted border-border"}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:(Array.isArray(E)?E:[E]).map((W,k)=>s.jsxs(c.Fragment,{children:[k>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:W})]},`${W}-${k}`))})]},D.id||A)})})]},K.categoryKey);a=Cs,j=n,y=r,l=Ns,x="max-w-6xl w-[min(72rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let C;t[16]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(B,{name:"command",className:"h-5 w-5"}),t[16]=C):C=t[16];let T;t[17]!==e?(T=e("helpDialog.title"),t[17]=e,t[18]=T):T=t[18];let O;t[19]!==T?(O=s.jsxs(Ls,{className:"flex items-center gap-2",children:[C,T]}),t[19]=T,t[20]=O):O=t[20];let M;t[21]!==e?(M=e("helpDialog.description"),t[21]=e,t[22]=M):M=t[22];let F;t[23]!==M?(F=s.jsx(_s,{children:M}),t[23]=M,t[24]=F):F=t[24],t[25]!==O||t[26]!==F?(b=s.jsxs(Hs,{children:[O,F]}),t[25]=O,t[26]=F,t[27]=b):b=t[27],o=xn,m="flex-1 min-h-0 mt-3",f="pr-1",g=!0,d="grid grid-cols-1 gap-x-12 gap-y-4 lg:grid-cols-2",u=["left","right"].map(K=>s.jsxs("div",{className:"space-y-4",children:[N.filter(D=>D.column===K).map(P),K==="right"&&s.jsxs("ul",{className:"space-y-0.5 px-2 typography-meta text-muted-foreground",children:[s.jsxs("li",{children:["• ",e("helpDialog.proTips.commandPalette",{shortcut:Bc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))})]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.recentSessions")]}),s.jsxs("li",{children:["• ",e("helpDialog.proTips.leaderSequences")]})]})]},K)),t[0]=n,t[1]=r,t[2]=i,t[3]=e,t[4]=o,t[5]=l,t[6]=a,t[7]=d,t[8]=u,t[9]=m,t[10]=f,t[11]=g,t[12]=x,t[13]=b,t[14]=j,t[15]=y}else o=t[4],l=t[5],a=t[6],d=t[7],u=t[8],m=t[9],f=t[10],g=t[11],x=t[12],b=t[13],j=t[14],y=t[15];let h;t[28]!==d||t[29]!==u?(h=s.jsx("div",{className:d,children:u}),t[28]=d,t[29]=u,t[30]=h):h=t[30];let p;t[31]!==o||t[32]!==m||t[33]!==f||t[34]!==g||t[35]!==h?(p=s.jsx(o,{outerClassName:m,className:f,disableHorizontal:g,children:h}),t[31]=o,t[32]=m,t[33]=f,t[34]=g,t[35]=h,t[36]=p):p=t[36];let w;t[37]!==l||t[38]!==p||t[39]!==x||t[40]!==b?(w=s.jsxs(l,{className:x,children:[b,p]}),t[37]=l,t[38]=p,t[39]=x,t[40]=b,t[41]=w):w=t[41];let S;return t[42]!==a||t[43]!==w||t[44]!==j||t[45]!==y?(S=s.jsx(a,{open:j,onOpenChange:y,children:w}),t[42]=a,t[43]=w,t[44]=j,t[45]=y,t[46]=S):S=t[46],S};function v0(t){return t.isHelpDialogOpen}function S0(t){return t.setHelpDialogOpen}function j0(t){return t.shortcutOverrides}const k0=()=>{const t=nt.c(32),{t:e}=At(),n=ye(C0),r=ye(N0),i=ye(A0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await Gn(i)).ok){Fe.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Fe.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(Ls,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==u?(m=s.jsx(_s,{children:u}),t[9]=u,t[10]=m):m=t[10];let f;t[11]!==d||t[12]!==m?(f=s.jsxs(Hs,{children:[d,m]}),t[11]=d,t[12]=m,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let x;t[16]!==l||t[17]!==g?(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:g})}),t[16]=l,t[17]=g,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 j;t[22]!==b?(j=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]=j):j=t[23];let y;t[24]!==f||t[25]!==x||t[26]!==j?(y=s.jsxs(Ns,{className:"max-w-2xl",children:[f,x,j]}),t[24]=f,t[25]=x,t[26]=j,t[27]=y):y=t[27];let h;return t[28]!==n||t[29]!==r||t[30]!==y?(h=s.jsx(Cs,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=h):h=t[31],h};function C0(t){return t.isOpenCodeStatusDialogOpen}function N0(t){return t.setOpenCodeStatusDialogOpen}function A0(t){return t.openCodeStatusText}const P0=t=>{const e=nt.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 m,f;e[5]!==a||e[6]!==o||e[7]!==i?(m=()=>{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]=m,e[9]=f):(m=e[8],f=e[9]),c.useEffect(m,f);let g,x;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(g=()=>{if(!a||!r||typeof document>"u")return;const b=j=>{l.current&&(l.current.contains(j.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]=g,e[15]=x):(g=e[14],x=e[15]),c.useEffect(g,x)},D0=t=>{const e=nt.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(I0)),u=[];a.forEach(g=>{const x=d.get(g);x&&(u.push(x),d.delete(g))});const m=[],f=[];return l.forEach(g=>{d.has(g.id)&&(g.isArchivedBucket?f.push(g):m.push(g))}),[...m,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function I0(t){return[t.id,t]}const go="oc.sessions.projectCollapse",Fc="oc.sessions.groupOrder",Lc="oc.sessions.groupCollapse",_c=t=>{if(!t)return new Set;try{const e=Ga(Hn()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},T0=t=>{if(!t)return new Map;try{const e=of(Hn(),Ga(Hn())).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}},E0=t=>{const e=nt.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Bo(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>_c(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=()=>_c(o.getItem(Lc)),e[2]=u):u=e[2];const[m,f]=c.useState(u);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=()=>T0(o.getItem(Fc)),e[3]=g):g=e[3];const[x,b]=c.useState(g),j=c.useRef(0),y=c.useRef(!1),h=c.useRef(!1),p=c.useRef(null),w=c.useRef(null);let S;e[4]!==n?(S=()=>{if(n)return;const fe=w.current;if(w.current=null,p.current=null,!fe)return;const{projects:Pe}=Kt.getState(),L=Pe.map(oe=>({...oe,sidebarCollapsed:fe.has(oe.id)}));lr({projects:L}).catch(R0)},e[4]=n,e[5]=S):S=e[5];const N=S;let P;e[6]!==N||e[7]!==n?(P=fe=>{!globalThis.window||n||(w.current=fe,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{N()},700))},e[6]=N,e[7]=n,e[8]=P):P=e[8];const C=P;let T,O;e[9]===Symbol.for("react.memo_cache_sentinel")?(T=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,w.current=null},O=[],e[9]=T,e[10]=O):(T=e[9],O=e[10]),c.useEffect(T,O);let M,F;e[11]!==x?(F=()=>{if(h.current)try{o.setItem(Fc,JSON.stringify(Object.fromEntries(x.entries())))}catch{}},M=[x,o],e[11]=x,e[12]=M,e[13]=F):(M=e[12],F=e[13]),c.useEffect(F,M);let K,D;e[14]!==m?(K=()=>{if(y.current)try{o.setItem(Lc,JSON.stringify(Array.from(m)))}catch{}},D=[m,o],e[14]=m,e[15]=K,e[16]=D):(K=e[15],D=e[16]),c.useEffect(K,D);let U;e[17]!==r||e[18]!==C?(U=()=>{j.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const fe=new Set(r.map(M0));try{o.setItem(go,JSON.stringify(Array.from(fe)))}catch{}return C(fe),fe})},e[17]=r,e[18]=C,e[19]=U):U=e[19];const A=U;let E;e[20]!==C?(E=()=>{j.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const fe=new Set;try{o.setItem(go,JSON.stringify([]))}catch{}return C(fe),fe})},e[20]=C,e[21]=E):E=e[21];const W=E;let k;e[22]!==C?(k=fe=>{j.current=Date.now()+150,d(Pe=>{const L=new Set(Pe);L.has(fe)?L.delete(fe):L.add(fe);try{o.setItem(go,JSON.stringify(Array.from(L)))}catch{}return C(L),L})},e[22]=C,e[23]=k):k=e[23];const v=k;let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=fe=>{y.current=!0,f(Pe=>{const L=new Set(Pe);return L.has(fe)?L.delete(fe):L.add(fe),L})},e[24]=I):I=e[24];const H=I;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=fe=>{h.current=!0,b(fe)},e[25]=_):_=e[25];const se=_,{getOrderedGroups:te}=D0(x);let ee;e[26]!==m||e[27]!==a||e[28]!==x?(ee={collapsedProjects:a,collapsedGroups:m,groupOrderByProject:x},e[26]=m,e[27]=a,e[28]=x,e[29]=ee):ee=e[29];const ue=ee;let de;e[30]!==A||e[31]!==W||e[32]!==te||e[33]!==C||e[34]!==v?(de={setCollapsedProjects:d,toggleProject:v,collapseAllProjects:A,expandAllProjects:W,scheduleCollapsedProjectsPersist:C,setCollapsedGroups:f,toggleGroup:H,setGroupOrderByProject:se,getOrderedGroups:te},e[30]=A,e[31]=W,e[32]=te,e[33]=C,e[34]=v,e[35]=de):de=e[35];const Re=de;let we;return e[36]!==Re||e[37]!==ue?(we={state:ue,actions:Re},e[36]=Re,e[37]=ue,e[38]=we):we=e[38],we};function R0(){}function M0(t){return t.id}const O0=5*6e4,B0=t=>{const e=nt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=bn(),u=Xn(F0);let m,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(m=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(P=>{qi(()=>u(P.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=m,e[6]=f):(m=e[5],f=e[6]),c.useEffect(m,f);let g,x;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(g=()=>{if(!a)return;const P=new Map;n.forEach(C=>{P.set(C.id,i.get(C.normalizedPath)?.isGitRepo??null)}),o(P)},x=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=g,e[12]=x):(g=e[11],x=e[12]),c.useEffect(g,x);let b;if(e[13]!==i||e[14]!==n){let P;e[16]!==i?(P=C=>{const T=i.get(C.normalizedPath)?.branch??"";return`${C.id}:${T}`},e[16]=i,e[17]=P):P=e[17],b=n.map(P).join("|"),e[13]=i,e[14]=n,e[15]=b}else b=e[15];const j=b;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const h=c.useRef(y);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const w=c.useRef(p);let S;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(S=()=>{if(!a)return;let P=!1;const C=setTimeout(()=>{(async()=>{const O=new Set(n.map(L0));for(const A of h.current.keys())O.has(A)||(h.current.delete(A),w.current.delete(A));const M=Date.now(),F=n.filter(A=>{const E=i.get(A.normalizedPath);if(E?.isGitRepo===!1)return h.current.delete(A.id),w.current.delete(A.id),!1;if(E?.isGitRepo!==!0||E.branch===null)return!1;const W=E.branch.trim(),k=`${A.normalizedPath}\0${W}`,v=h.current.get(A.id);if(v===k){const I=w.current.get(A.id);return I&&(I.at=M),!1}return!(v!==void 0&&M-(w.current.get(A.id)?.at??0)<O0)});if(F.length===0)return;const K=await $g(F,2,async A=>{const E=i.get(A.normalizedPath)?.branch?.trim()??"",W=`${A.normalizedPath}\0${E}`,k=await qi(()=>Su(A.normalizedPath,E?{knownBranch:E}:void 0)).catch(_0);return{id:A.id,inputKey:W,branch:k}});if(P)return;const D=K.filter($0);if(D.length===0)return;const U=Date.now();l(A=>{const E=new Map(A);return D.forEach(W=>{const{id:k,branch:v}=W;v&&E.set(k,v)}),E}),D.forEach(A=>{const{id:E,inputKey:W,branch:k}=A;h.current.set(E,W),k&&w.current.set(E,{branch:k,at:U})})})()},150);return()=>{P=!0,clearTimeout(C)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=S):S=e[24];let N;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==j||e[29]!==l?(N=[a,n,j,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=j,e[29]=l,e[30]=N):N=e[30],c.useEffect(S,N)};function F0(t){return t.ensureStatus}function L0(t){return t.id}function _0(){return null}function $0(t){return t.branch}const z0=t=>{const e=nt.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(Hh,{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(Ns,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(xn,{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(Cs,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function W0(t){const e=nt.c(179),{t:n}=At(),r=Ru(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenArchive:u,headerActionIconClass:m,headerActionButtonClass:f,isSessionSearchOpen:g,setIsSessionSearchOpen:x,sessionSearchInputRef:b,sessionSearchQuery:j,setSessionSearchQuery:y,hasSessionSearchQuery:h,searchMatchCount:p,collapseAllProjects:w,expandAllProjects:S}=t,N=ns(s2),P=ns(t2),C=as(e2),T=as(Z0),O=as(J0),M=as(X0),F=as(Q0),K=as(Y0),D=as(q0),U=as(G0),A=as(H0),E=as(U0),W=o&&A==="single",k=o&&D==="timeline";if(i)return null;let v;e[0]!==f?(v=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=f,e[1]=v):v=e[1];let I;e[2]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=I):I=e[3];let H;e[4]!==m?(H=s.jsx(B,{name:"folder-add",className:m}),e[4]=m,e[5]=H):H=e[5];let _;e[6]!==a||e[7]!==v||e[8]!==I||e[9]!==H?(_=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:v,"aria-label":I,children:H})}),e[6]=a,e[7]=v,e[8]=I,e[9]=H,e[10]=_):_=e[10];let se;e[11]!==n?(se=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=se):se=e[12];let te;e[13]!==se?(te=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:se})}),e[13]=se,e[14]=te):te=e[14];let ee;e[15]!==_||e[16]!==te?(ee=s.jsxs(vt,{children:[_,te]}),e[15]=_,e[16]=te,e[17]=ee):ee=e[17];let ue;e[18]!==f?(ue=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=f,e[19]=ue):ue=e[19];let de;e[20]!==n?(de=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=de):de=e[21];let Re;e[22]!==m?(Re=s.jsx(B,{name:"calendar-schedule",className:m}),e[22]=m,e[23]=Re):Re=e[23];let we;e[24]!==d||e[25]!==ue||e[26]!==de||e[27]!==Re?(we=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":de,children:Re})}),e[24]=d,e[25]=ue,e[26]=de,e[27]=Re,e[28]=we):we=e[28];let fe;e[29]!==n?(fe=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=fe):fe=e[30];let Pe;e[31]!==fe?(Pe=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[31]=fe,e[32]=Pe):Pe=e[32];let L;e[33]!==we||e[34]!==Pe?(L=s.jsxs(vt,{children:[we,Pe]}),e[33]=we,e[34]=Pe,e[35]=L):L=e[35];let oe;e[36]!==f?(oe=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=f,e[37]=oe):oe=e[37];let ce;e[38]!==n?(ce=n("sessions.sidebar.nav.archive"),e[38]=n,e[39]=ce):ce=e[39];let he;e[40]!==m?(he=s.jsx(B,{name:"archive",className:m}),e[40]=m,e[41]=he):he=e[41];let Y;e[42]!==u||e[43]!==oe||e[44]!==ce||e[45]!==he?(Y=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:oe,"aria-label":ce,children:he})}),e[42]=u,e[43]=oe,e[44]=ce,e[45]=he,e[46]=Y):Y=e[46];let ve;e[47]!==n?(ve=n("sessions.sidebar.nav.archive"),e[47]=n,e[48]=ve):ve=e[48];let Te;e[49]!==ve?(Te=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ve})}),e[49]=ve,e[50]=Te):Te=e[50];let ke;e[51]!==Y||e[52]!==Te?(ke=s.jsxs(vt,{children:[Y,Te]}),e[51]=Y,e[52]=Te,e[53]=ke):ke=e[53];let xe;e[54]!==r||e[55]!==m||e[56]!==n?(xe=r.length>0&&s.jsxs(ks,{children:[s.jsx(Ss,{asChild:!0,children:s.jsx(ft,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(B,{name:"apps",className:m})})}),s.jsxs(js,{align:"start",children:[s.jsx(cr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(V0)]})]}),e[54]=r,e[55]=m,e[56]=n,e[57]=xe):xe=e[57];let ge;e[58]!==L||e[59]!==ke||e[60]!==xe||e[61]!==ee?(ge=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[ee,L,ke,xe]}),e[58]=L,e[59]=ke,e[60]=xe,e[61]=ee,e[62]=ge):ge=e[62];let Q;e[63]!==x?(Q=()=>x(K0),e[63]=x,e[64]=Q):Q=e[64];let $;e[65]!==f?($=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[65]=f,e[66]=$):$=e[66];let J;e[67]!==n?(J=n("sessions.sidebar.header.actions.searchSessions"),e[67]=n,e[68]=J):J=e[68];let me;e[69]!==m?(me=s.jsx(B,{name:"search",className:m}),e[69]=m,e[70]=me):me=e[70];let le;e[71]!==g||e[72]!==Q||e[73]!==$||e[74]!==J||e[75]!==me?(le=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Q,className:$,"aria-label":J,"aria-expanded":g,children:me})}),e[71]=g,e[72]=Q,e[73]=$,e[74]=J,e[75]=me,e[76]=le):le=e[76];let V;e[77]!==n?(V=n("sessions.sidebar.header.actions.searchSessions"),e[77]=n,e[78]=V):V=e[78];let Z;e[79]!==V?(Z=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V})}),e[79]=V,e[80]=Z):Z=e[80];let G;e[81]!==le||e[82]!==Z?(G=s.jsxs(vt,{children:[le,Z]}),e[81]=le,e[82]=Z,e[83]=G):G=e[83];const ie=N&&"bg-interactive-hover text-primary";let je;e[84]!==f||e[85]!==ie?(je=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent",ie),e[84]=f,e[85]=ie,e[86]=je):je=e[86];let ne;e[87]!==N||e[88]!==n?(ne=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[87]=N,e[88]=n,e[89]=ne):ne=e[89];let Oe;e[90]!==m?(Oe=s.jsx(B,{name:"checkbox-multiple",className:m}),e[90]=m,e[91]=Oe):Oe=e[91];let Ve;e[92]!==N||e[93]!==je||e[94]!==ne||e[95]!==Oe||e[96]!==P?(Ve=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:P,className:je,"aria-label":ne,"aria-pressed":N,children:Oe})}),e[92]=N,e[93]=je,e[94]=ne,e[95]=Oe,e[96]=P,e[97]=Ve):Ve=e[97];let ze;e[98]!==N||e[99]!==n?(ze=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[98]=N,e[99]=n,e[100]=ze):ze=e[100];let He;e[101]!==ze?(He=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ze})}),e[101]=ze,e[102]=He):He=e[102];let $e;e[103]!==Ve||e[104]!==He?($e=s.jsxs(vt,{children:[Ve,He]}),e[103]=Ve,e[104]=He,e[105]=$e):$e=e[105];let R;e[106]!==f?(R=Ie(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[106]=f,e[107]=R):R=e[107];let pe;e[108]!==n?(pe=n("sessions.sidebar.header.displayMode.label"),e[108]=n,e[109]=pe):pe=e[109];let Le;e[110]!==m?(Le=s.jsx(B,{name:"equalizer-2",className:m}),e[110]=m,e[111]=Le):Le=e[111];let _e;e[112]!==R||e[113]!==pe||e[114]!==Le?(_e=s.jsx(St,{asChild:!0,children:s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:R,"aria-label":pe,children:Le})})}),e[112]=R,e[113]=pe,e[114]=Le,e[115]=_e):_e=e[115];let lt;e[116]!==n?(lt=n("sessions.sidebar.header.displayMode.label"),e[116]=n,e[117]=lt):lt=e[117];let ht;e[118]!==lt?(ht=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:lt})}),e[118]=lt,e[119]=ht):ht=e[119];let ot;e[120]!==_e||e[121]!==ht?(ot=s.jsxs(vt,{children:[_e,ht]}),e[120]=_e,e[121]=ht,e[122]=ot):ot=e[122];let ut;e[123]!==U||e[124]!==o||e[125]!==D||e[126]!==n||e[127]!==k?(ut=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(X=>{const[ae,De]=X;return s.jsxs(zt,{onClick:()=>{U(ae),lr({sidebarViewMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(De)}),D===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),k?null:s.jsx(ps,{})]}):null,e[123]=U,e[124]=o,e[125]=D,e[126]=n,e[127]=k,e[128]=ut):ut=e[128];let yt;e[129]!==A||e[130]!==O||e[131]!==E||e[132]!==M||e[133]!==K||e[134]!==o||e[135]!==n||e[136]!==k||e[137]!==F?(yt=k?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(X=>{const[ae,De]=X;return s.jsxs(zt,{onClick:()=>{M(ae),lr({sidebarProjectSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(De)}),O===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(ps,{}),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(X=>{const[ae,De]=X;return s.jsxs(zt,{onClick:()=>{K(ae),lr({sidebarWorktreeSortOrder:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(De)}),F===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(ps,{})]}):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(X=>{const[ae,De]=X;return s.jsxs(zt,{onClick:()=>{E(ae),lr({sidebarProjectDisplayMode:ae})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(De)}),A===ae?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]},ae)}),s.jsx(ps,{})]}):null]}),e[129]=A,e[130]=O,e[131]=E,e[132]=M,e[133]=K,e[134]=o,e[135]=n,e[136]=k,e[137]=F,e[138]=yt):yt=e[138];let mt;e[139]!==W||e[140]!==l||e[141]!==C||e[142]!==n||e[143]!==k||e[144]!==T?(mt=!k&&l&&!W?s.jsxs(zt,{onClick:()=>{T(),lr({sidebarShowRecentSection:!C})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),C?s.jsx(B,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[139]=W,e[140]=l,e[141]=C,e[142]=n,e[143]=k,e[144]=T,e[145]=mt):mt=e[145];let xt;e[146]!==w||e[147]!==S||e[148]!==W||e[149]!==n||e[150]!==k?(xt=!k&&!W?s.jsxs(s.Fragment,{children:[s.jsx(ps,{}),s.jsxs(zt,{onClick:w,className:"flex items-center gap-2",children:[s.jsx(B,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(zt,{onClick:S,className:"flex items-center gap-2",children:[s.jsx(B,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}):null,e[146]=w,e[147]=S,e[148]=W,e[149]=n,e[150]=k,e[151]=xt):xt=e[151];let Dt;e[152]!==ut||e[153]!==yt||e[154]!==mt||e[155]!==xt?(Dt=s.jsxs(js,{align:"end",className:"min-w-[180px]",children:[ut,yt,mt,xt]}),e[152]=ut,e[153]=yt,e[154]=mt,e[155]=xt,e[156]=Dt):Dt=e[156];let be;e[157]!==ot||e[158]!==Dt?(be=s.jsxs(ks,{children:[ot,Dt]}),e[157]=ot,e[158]=Dt,e[159]=be):be=e[159];let qe;e[160]!==G||e[161]!==$e||e[162]!==be?(qe=s.jsxs("div",{className:"flex items-center gap-1.5",children:[G,$e,be]}),e[160]=G,e[161]=$e,e[162]=be,e[163]=qe):qe=e[163];let Ye;e[164]!==ge||e[165]!==qe?(Ye=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[ge,qe]}),e[164]=ge,e[165]=qe,e[166]=Ye):Ye=e[166];let Ue;e[167]!==h||e[168]!==g||e[169]!==p||e[170]!==b||e[171]!==j||e[172]!==x||e[173]!==y||e[174]!==n?(Ue=g?s.jsx("div",{className:"pb-1",children:s.jsx(Jd,{inputRef:b,value:j,onSearch:y,onClose:()=>x(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear"),leadingHint:h?p===1?n("sessions.sidebar.header.search.matchCountSingle",{count:p}):n("sessions.sidebar.header.search.matchCountPlural",{count:p}):void 0,trailingHint:n("sessions.sidebar.header.search.escapeHint")})}):null,e[167]=h,e[168]=g,e[169]=p,e[170]=b,e[171]=j,e[172]=x,e[173]=y,e[174]=n,e[175]=Ue):Ue=e[175];let ct;return e[176]!==Ye||e[177]!==Ue?(ct=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:[Ye,Ue]})}),e[176]=Ye,e[177]=Ue,e[178]=ct):ct=e[178],ct}function K0(t){return!t}function V0(t){return s.jsxs(zt,{onSelect:()=>ye.getState().setOpenGuestPage(t.id),children:[s.jsx(Qr,{icon:Wg(t.icon),iconSrc:zg(t.id,t.icon,zd().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function U0(t){return t.setProjectDisplayMode}function H0(t){return t.projectDisplayMode}function G0(t){return t.setSidebarViewMode}function q0(t){return t.sidebarViewMode}function Y0(t){return t.setWorktreeSortOrder}function Q0(t){return t.worktreeSortOrder}function X0(t){return t.setProjectSortOrder}function J0(t){return t.projectSortOrder}function Z0(t){return t.toggleRecentSection}function e2(t){return t.showRecentSection}function t2(t){return t.toggleMode}function s2(t){return t.enabled}const bo="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 n2(t){const e=nt.c(14),{onOpenSettings:n,onOpenUsage:r,onOpenShortcuts:i,onOpenAbout:o,onOpenUpdate:l,showRuntimeButtons:a,showUpdateButton:d}=t,u=a===void 0?!0:a,m=d===void 0?!0:d,{t:f}=At();if(!u&&!m)return null;let g;e[0]!==o||e[1]!==n||e[2]!==i||e[3]!==r||e[4]!==u||e[5]!==f?(g=u?s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:bo,"aria-label":f("sessions.sidebar.footer.actions.settings"),children:s.jsx(B,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:bo,"aria-label":f("usageStats.openAction"),children:s.jsx(B,{name:"bar-chart",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("usageStats.openAction")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:bo,"aria-label":f("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(B,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{side:"top",sideOffset:4,children:s.jsx("p",{children:f("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:bo,"aria-label":f("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(B,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(jt,{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]=g):g=e[6];let x;e[7]!==l||e[8]!==m||e[9]!==f?(x=m?s.jsx(ft,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:l,children:f("sessions.sidebar.footer.actions.update")}):null,e[7]=l,e[8]=m,e[9]=f,e[10]=x):x=e[10];let b;return e[11]!==g||e[12]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[g,x]}),e[11]=g,e[12]=x,e[13]=b):b=e[13],b}const r2=t=>{for(const e of t.sessions.values())if(e.tabs.some(Kd))return!0;return!1},o2=()=>{const t=nt.c(4),{terminal:e}=bn(),n=Rt(r2);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=i2,l=a2;if(n)return $i(e,"",l,o);let a=l2;return a=$i(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 i2(t){const e=Rt.getState(),n=Gh(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 a2(){return new Map(Rt.getState().actionMutationRevisions)}function l2(){}const c2=t=>{const e=nt.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:m,addSessionToFolder:f}=t,g=r===void 0?!0:r;let x,b;e[0]!==f||e[1]!==m||e[2]!==g||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(x=()=>{!g||o||!l||a||n.forEach(j=>{if(d.has(j.normalizedPath))return;const y=Mu(j.normalizedPath),h=i.archivedSessionsByProject.get(j.id)??[],p=u[y]??[],w=new Map(p.map(d2));h.forEach(S=>{const N=Kg(S,j.normalizedPath),P=N.toLowerCase();let C=w.get(P);C||(C=m(y,N),w.set(P,C)),C.sessionIds.includes(S.id)||f(y,C.id,S.id)})})},b=[n,g,i,o,l,a,d,u,m,f],e[0]=f,e[1]=m,e[2]=g,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 d2(t){return[t.name.toLowerCase(),t]}function u2({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([m,f])=>m!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const f2=t=>{const e=nt.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:m,openNewSessionDraft:f,setSessionSwitcherOpen:g}=t;let x,b;if(e[0]!==n){b=new Map,x=new Map;const P=(C,T,O,M)=>{b.has(C)||b.set(C,new Map);const F=b.get(C);M.forEach(K=>{const D=gt(K.worktree?.path??K.session.directory??O??T);F.set(K.session.id,{directory:D}),x.has(C)||x.set(C,{id:K.session.id,directory:D}),K.children.length>0&&P(C,T,D,K.children)})};n.forEach(C=>{C.groups.forEach(T=>{P(C.project.id,C.project.normalizedPath,T.directory,T.sessions)})}),e[0]=n,e[1]=x,e[2]=b}else x=e[1],b=e[2];let j;e[3]!==x||e[4]!==b?(j={metaByProject:b,firstSessionByProject:x},e[3]=x,e[4]=b,e[5]=j):j=e[5];const y=j,h=c.useRef(null);let p,w;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==m||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==g?(p=()=>{if(!r||u||ye.getState().isNewWorktreeDialogOpen||h.current===r)return;const P=n.find(M=>M.project.id===r);if(!P)return;const C=y.metaByProject.get(r);if(l&&C&&C.has(l)){h.current=r,o(M=>{if(M.get(r)===l)return M;const F=new Map(M);return F.set(r,l),F});return}const T=u2({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(T.kind==="preserve-current"){a===r&&(h.current=r);return}if(h.current=r,T.kind==="open-draft"){m&&g(!1),f({selectedProjectId:P.project.id,directoryOverride:P.project.normalizedPath});return}if(T.kind!=="select-session")return;const O=C?.get(T.sessionId)?.directory??null;d(T.sessionId,O)},w=[r,i,l,a,d,u,m,f,n,y,g,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=m,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=g,e[18]=p,e[19]=w):(p=e[18],w=e[19]),c.useLayoutEffect(p,w);let S,N;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(S=()=>{if(!r||!l)return;const P=y.metaByProject.get(r);!P||!P.has(l)||o(C=>{if(C.get(r)===l)return C;const T=new Map(C);return T.set(r,l),T})},N=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=S,e[25]=N):(S=e[24],N=e[25]),c.useEffect(S,N)},m2=t=>{const e=nt.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=rt(h2),a=rt(p2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let m;e[8]!==r?(m=()=>new Map(r),e[8]=r,e[9]=m):m=e[9];const[f,g]=c.useState(m);let x;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(x={...n,activeSessionByProject:f,setActiveSessionByProject:g,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],f2(x);let b,j;return e[16]!==f||e[17]!==i?(b=()=>{i(f)},j=[f,i],e[16]=f,e[17]=i,e[18]=b,e[19]=j):(b=e[18],j=e[19]),c.useEffect(b,j),null};function h2(t){return t.currentSessionId}function p2(t){return!!t.newSessionDraft?.open}const g2=t=>{const e=nt.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},Bn=(t,e)=>`${t}\0${e}`,Cn=(t,e)=>t??_a(e)??gt(e??null),Gr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??gt(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},sl=t=>t.startsWith("__archived__:"),b2=(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}))},$c=(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},x2=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!$a(r),y2=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,w2=(t,e,n)=>{const r=new Map,i=o=>{const l=Is(o.session)??gt(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}))},ba=(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})},Hf=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},Gf=(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 g=i.get(u.parentId)??[];g.push(u.id),i.set(u.parentId,g)}const m=new Set;let f=u.id;for(;f;){if(m.has(f)){o.add(u.id);break}m.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const m=r.get(u);if(!m)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&m.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(m.nodeCount>0||!n&&Fo([m.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},zc=new WeakMap;let Wc=1;const v2=t=>{const e=zc.get(t);if(e!==void 0)return e;const n=Wc;return Wc+=1,zc.set(t,n),n},Vo=t=>t.children.length===0?"":t.children.map(n=>{const r=v2(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Vo(n)}`}).join("|"),qf=(t,e,n,r,i,o)=>{const l=Yt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const m=d.session.directory??i,f=u.session.directory??o,g=Ml(l,m??"",d.session.id),x=Ml(l,f??"",u.session.id);return(g?n.has(g):!1)!==(x?r.has(x):!1)?!0:d.children.some((b,j)=>a(b,u.children[j]))};return a(t,e)},S2=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,j2=(t,e)=>t?t.branchLabel??null:e??null,k2=(t,e)=>{if(e)return null;const n=t?.branch?.trim(),r=gt(t?.path??null);return n&&r?Qo(r,n):null},Uo=(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},xo=t=>"run"in t,C2=(t,e)=>`${t}:active:run:${e}`,Ei=(t,e,n)=>{if(n||e.runKeyBySessionId.size===0)return[...t];const r=[],i=new Map;for(const o of t){const l=e.runKeyBySessionId.get(o.session.id),a=l?e.runs.get(l):void 0;if(!a){r.push(o);continue}const d=i.get(a.key);if(d){d.lanes.push(o);continue}const u={run:a,lanes:[o]};i.set(a.key,u),r.push(u)}for(const o of i.values()){const l=new Map(o.run.memberIds.map((a,d)=>[a,d]));o.lanes.sort((a,d)=>(l.get(a.session.id)??0)-(l.get(d.session.id)??0))}return r},Yf=(t,e)=>{const n=e.trim().toLowerCase(),r=n.startsWith("ses_"),i=o=>o.reduce((l,a)=>l+(!r||a.session.id.toLowerCase()===n?1:0)+i(a.children),0);return i(t)},N2=[],A2=new Set,Kc=32,Vc=64,P2=3,D2=7,yo=32,Rn=28,Uc=(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 za(t.session,e.session,n,La)},wo=t=>{const e=new Map,n=new Map,r=[],i=new WeakMap,o=t.map(l=>({node:l,visited:!1})).reverse();for(;o.length>0;){const l=o.pop();if(!l)continue;if(!l.visited){e.set(l.node.session.id,l.node),n.set(l.node.session.id,l.node.session);const d=r.length;r.push(l.node.session.id),i.set(l.node,[d,d+1]),o.push({node:l.node,visited:!0});for(let u=l.node.children.length-1;u>=0;u-=1){const m=l.node.children[u];m&&o.push({node:m,visited:!1})}continue}const a=i.get(l.node);a&&i.set(l.node,Object.freeze([a[0],r.length]))}return{byId:e,sessionsById:n,preorderIds:Object.freeze(r),subtreeRangeByNode:i}},I2=(t,e,n)=>`${t}:${e?"archived":"active"}:${n}`,T2=(t,e)=>{let n=null;for(const r of t){if(r.rowIndex>e)break;n=r}return n},E2=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),m=t.workSessionIds??A2;let f=0;const x=[...[...t.authoritativeSections.flatMap(A=>A.groups.flatMap(E=>E.sessions)),...t.chatGroup?.sessions??[]]];for(;x.length>0;){const A=x.pop();A&&(l.set(A.session.id,A.session),x.push(...A.children))}const b=A=>{const E=a.get(A)??0;return a.set(A,E+1),E===0?A:`${A}:${E}`},j=A=>{e.push(Object.freeze(A))},y=t.runIndex??Vg,h=(A,E)=>{const W=C2(E.renderContext,A.run.key),k=E.renderContext!=="timeline"&&(d||t.expandedParents.has(W)),v=A.lanes[0]?.session.id,I=v&&E.getSecondaryMeta?E.getSecondaryMeta(v):E.secondaryMeta;j({kind:"run",key:b(`${E.containerKey}:run:${A.run.key}`),estimateSize:E.renderContext==="timeline"?Vc:Kc,run:A.run,laneNodes:Object.freeze([...A.lanes]),projectId:E.projectId,projectLabel:I?.projectLabel??null,groupDirectory:E.groupDirectory,renderContext:E.renderContext,expansionKey:W,expanded:k,forceExpanded:d}),k&&w(A.lanes,1,E)},p=A=>{for(const E of Ei(A.nodes,y,A.archived))xo(E)?h(E,A):w([E],0,A)},w=(A,E,W)=>{const k=[...A].reverse().map(v=>({node:v,depth:E,directory:W.groupDirectory}));for(;k.length>0;){const v=k.pop();if(!v)continue;const I=b(`${W.containerKey}:session:${v.node.session.id}`),H=v.node.session.directory??v.directory;l.set(v.node.session.id,v.node.session),j({kind:"session",key:I,estimateSize:W.renderContext==="timeline"?Vc:Kc,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 _=W.indexedNodes?.subtreeRangeByNode.get(v.node),se=_&&_[1]>_[0]+1?Object.freeze([(W.selectionPoolOffset??0)+_[0]+1,(W.selectionPoolOffset??0)+_[1]]):void 0;if(n.push(Object.freeze({id:v.node.session.id,rowKey:I,scopeKey:W.selectionScopeKey,archived:W.archived,descendantRange:se})),!(!d&&!t.expandedParents.has(I2(W.renderContext,W.archived,v.node.session.id))))for(let te=v.node.children.length-1;te>=0;te-=1){const ee=v.node.children[te];ee&&k.push({node:ee,depth:v.depth+1,directory:H})}}},S=A=>{const E=t.groupSearchDataByGroup.get(A);if(E?.hasMatch!==!0)return 0;const W=m.size>0?E.filteredNodes.filter(v=>m.has(v.session.id)):[];return Math.max(0,E.matchedSessionCount-Yf(W,t.normalizedQuery))+E.folderNameMatchCount+(E.groupMatches?1:0)},N=(A,E,W,k,v)=>{const I=t.groupSearchDataByGroup.get(A);if(d){const ne=S(A);if(ne===0)return;f+=ne}const H=(d?I?.filteredNodes??[]:A.sessions).filter(ne=>!m.has(ne.session.id)).sort((ne,Oe)=>Uc(ne,Oe,u,t.sessionOrderIndex)),_=wo(H),se=r.length;r.push(..._.preorderIds);for(const[ne,Oe]of _.sessionsById)l.set(ne,Oe);const te=Cn(W,A.directory),ee=!d&&t.collapsedGroups.has(E);if(!k){const ne=_.preorderIds.flatMap(Oe=>_.sessionsById.get(Oe)??[]);j({kind:"group-header",key:`${E}:header`,estimateSize:yo,group:A,groupKey:E,projectId:W,collapsed:ee,forceExpanded:d,allSessions:Object.freeze(ne)})}if(ee)return;const ue=Gr(A).flatMap(({scopeKey:ne,directory:Oe})=>(t.foldersMap[ne]??N2).map(Ve=>({folder:Ve,scopeKey:ne,scopeDirectory:Oe,ownerKey:te,nodes:ba(Ve.sessionIds,_.byId).sort((ze,He)=>Uc(ze,He,u,t.sessionOrderIndex))}))),de=Gf(ue.map(ne=>({id:ne.folder.id,name:ne.folder.name,parentId:ne.folder.parentId,nodeCount:ne.nodes.length})),{archivedBucket:A.isArchivedBucket===!0,searchQuery:d?t.normalizedQuery:""}),Re=ue.filter(ne=>de.has(ne.folder.id)),we=new Map(Re.map(ne=>[Bn(ne.scopeKey,ne.folder.id),ne])),fe=new Map;for(const ne of Re){if(!ne.folder.parentId)continue;const Oe=Bn(ne.scopeKey,ne.folder.parentId),Ve=fe.get(Oe)??[];Ve.push(ne),fe.set(Oe,Ve)}const Pe=Hf(Re.map(ne=>({...ne.folder,scopeKey:ne.scopeKey}))).map(ne=>we.get(Bn(ne.scopeKey??"",ne.id))).filter(ne=>!!ne),L=new Set(Re.flatMap(ne=>ne.folder.sessionIds)),oe=H.filter(ne=>!L.has(ne.session.id)),ce=new Map,he=Pe.map(ne=>({folder:ne,visited:!1})),Y=new Set;for(;he.length>0;){const ne=he.pop();if(!ne)continue;const Oe=Bn(ne.folder.scopeKey,ne.folder.folder.id);if(!ne.visited){if(Y.has(Oe))continue;Y.add(Oe),he.push({folder:ne.folder,visited:!0});for(const ze of fe.get(Oe)??[])he.push({folder:ze,visited:!1});continue}const Ve=ne.folder.nodes.flatMap(ze=>{const He=_.subtreeRangeByNode.get(ze);return He?_.preorderIds.slice(He[0],He[1]).flatMap($e=>_.sessionsById.get($e)??[]):[ze.session]});for(const ze of fe.get(Oe)??[])Ve.push(...ce.get(Bn(ze.scopeKey,ze.folder.id))??[]);ce.set(Oe,Object.freeze(Ve))}const ve=new Set,Te=(ne,Oe)=>{const Ve=Bn(ne.scopeKey,ne.folder.id);if(ve.has(Ve))return;ve.add(Ve);const ze=Oe?`${Oe} / ${ne.folder.name}`:ne.folder.name,He=`${E}:folder:${Ve}`,$e=!d&&t.collapsedFolders.has(ne.folder.id),R=ce.get(Ve)??[],pe=$e&&!A.isArchivedBucket?ba([...new Set(R.map(lt=>lt.id))],_.byId):[],Le=te?t.folderAuthorityByOwner.get(te):void 0,_e=!!te&&!A.isArchivedBucket&&!sl(ne.scopeKey)&&Le?.complete===!0&&Le.scopeKeys.includes(ne.scopeKey);if(j({kind:"folder-header",key:He,estimateSize:yo,group:A,folder:ne.folder,displayName:ze,scopeKey:ne.scopeKey,scopeDirectory:ne.scopeDirectory,ownerKey:te,nodes:ne.nodes,activityNodes:pe,projectId:W,archived:A.isArchivedBucket===!0,collapsed:$e,forceExpanded:d,deleteSessions:R,subFolderCount:fe.get(Ve)?.length??0,dropEnabled:_e}),te&&o.push(Object.freeze({rowKey:He,scopeKey:ne.scopeKey,folderId:ne.folder.id,ownerKey:te,enabled:_e})),!$e){p({nodes:ne.nodes,containerKey:He,projectId:W,groupDirectory:ne.scopeDirectory??A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:"project",indexedNodes:_,selectionPoolOffset:se});for(const lt of fe.get(Ve)??[])Te(lt,ze)}};for(const ne of Pe)Te(ne,"");const ke=W?t.sessionBatchSize:void 0,xe=v?.initial??ke??(t.hideDirectoryControls?10:5),ge=v?.increment??ke??7,Q=Math.max(xe,t.visibleCountByContainer.get(E)??xe),$=ne=>!xo(ne)&&v?.pinnedAlwaysVisible===!0&&Ou(u,ne.session.directory??A.directory,ne.session.id),J=Ei(oe,y,A.isArchivedBucket===!0),me=J.filter(ne=>!$(ne));let le=Q;const V=A.isArchivedBucket||d?J:J.filter(ne=>$(ne)?!0:le<=0?!1:(le-=1,!0)),Z=V.flatMap(ne=>xo(ne)?ne.lanes:[ne]);p({nodes:Z,containerKey:E,projectId:W,groupDirectory:A.directory,ownerKey:te,selectionScopeKey:te,archived:A.isArchivedBucket===!0,renderContext:v?.renderContext??"project",indexedNodes:_,selectionPoolOffset:se});const G=J.length-V.length,ie=Q-le;!d&&!A.isArchivedBucket&&G>0?j({kind:"show-control",key:`${E}:more`,estimateSize:Rn,control:"more",containerKey:E,currentCount:ie,increment:ge}):!d&&!A.isArchivedBucket&&me.length>xe&&G===0&&j({kind:"show-control",key:`${E}:fewer`,estimateSize:Rn,control:"fewer",containerKey:E,currentCount:ie,increment:ge});const je=t.groupStatusByKey.get(E);H.length===0&&Re.length===0?je&&je.state!=="ready"?j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:je,group:A,groupKey:E}):j({kind:"empty",key:`${E}:empty`,estimateSize:Rn,emptyKind:A.isArchivedBucket?"archived":"group",group:A,projectId:W}):je&&je.state!=="ready"&&je.state!=="loading"&&j({kind:"status",key:`${E}:status`,estimateSize:Rn,status:je,group:A,groupKey:E})},P=A=>{const E=!d&&t.collapsedActivities.has(A),W=e.length;return j({kind:"activity-header",key:`activity:${A}:header`,estimateSize:yo,activityKey:A,collapsed:E,forceExpanded:d}),i.push(Object.freeze({rowIndex:W,kind:"activity",id:A})),E},C=t.viewMode==="timeline",T=A=>"run"in A,O=A=>{const E=Ei(A.map(k=>k.node),y,!1),W=new Map(A.map(k=>[k.node,k]));return E.flatMap(k=>{if(!xo(k)){const v=W.get(k);return v?[v]:[]}return[{run:k.run,items:k.lanes.flatMap(v=>W.get(v)??[])}]})},M=(A,E,W,k)=>{const v=A.items[0];if(!v)return;const I=A.items.map(ee=>ee.node),H=wo(I),_=r.length;r.push(...H.preorderIds);const se=Cn(v.projectId,v.groupDirectory),te=new Map(A.items.map(ee=>[ee.node.session.id,ee.getSecondaryMeta?ee.getSecondaryMeta(ee.node.session.id):ee.secondaryMeta]));h({run:A.run,lanes:I},{nodes:I,containerKey:E,projectId:v.projectId,groupDirectory:v.groupDirectory,ownerKey:se,selectionScopeKey:k?se:null,archived:!1,renderContext:W,getSecondaryMeta:ee=>te.get(ee)??null,indexedNodes:H,selectionPoolOffset:_})},F=(A,E,W,k,v=()=>1)=>{for(const I of O(A)){if(T(I)){M(I,E,W,k),d&&(f+=I.items.reduce((ee,ue)=>ee+v(ue),0));continue}const H=I,_=wo([H.node]),se=r.length;r.push(..._.preorderIds);const te=Cn(H.projectId,H.groupDirectory);p({nodes:[H.node],containerKey:E,projectId:H.projectId,groupDirectory:H.groupDirectory,ownerKey:te,selectionScopeKey:null,archived:!1,renderContext:W,secondaryMeta:H.secondaryMeta,getSecondaryMeta:H.getSecondaryMeta,indexedNodes:_,selectionPoolOffset:se}),d&&(f+=v(H))}};t.chatGroup&&(!d||S(t.chatGroup)>0)&&(P("chats")||N(t.chatGroup,"activity:chats",null,!0,C?{initial:P2,increment:D2,pinnedAlwaysVisible:!0,renderContext:"timeline-chat"}:void 0));const K=t.workItems??[];if(K.length>0&&(P("work")||F(K,"activity:work",C?"timeline":"recent",!1,E=>qh(E.node,t.normalizedQuery))),C){const A=(t.timelineItems??[]).filter(E=>!m.has(E.node.session.id));A.length>0&&(P("timeline")||F(A,"activity:timeline","timeline",!1))}if(!C&&t.showRecentSection)for(const A of t.recentSections){const E={...A,items:A.items.filter(te=>!m.has(te.node.session.id))};if(E.items.length===0||P("active-now"))continue;const k=`activity:${E.key}`,v=7,I=Math.max(v,t.visibleCountByContainer.get(k)??v),H=O(E.items),_=d?H:H.slice(0,I);for(const te of _){if(T(te)){M(te,k,"recent",!0),d&&(f+=te.items.length);continue}const ee=te,ue=wo([ee.node]),de=r.length;r.push(...ue.preorderIds),p({nodes:[ee.node],containerKey:k,projectId:ee.projectId,groupDirectory:ee.groupDirectory,ownerKey:Cn(ee.projectId,ee.groupDirectory),selectionScopeKey:Cn(ee.projectId,ee.groupDirectory),archived:!1,renderContext:"recent",secondaryMeta:ee.secondaryMeta,getSecondaryMeta:ee.getSecondaryMeta,indexedNodes:ue,selectionPoolOffset:de}),d&&(f+=1)}const se=H.length-_.length;!d&&se>0?j({kind:"show-control",key:`${k}:more`,estimateSize:Rn,control:"more",containerKey:k,currentCount:_.length,increment:7}):!d&&H.length>v&&j({kind:"show-control",key:`${k}:fewer`,estimateSize:Rn,control:"fewer",containerKey:k,currentCount:_.length,increment:7})}let D=C?[]:t.singleProjectMode?t.sections.filter(A=>A.project.id===t.singleProjectId):[...t.sections];if(t.showOnlyMainWorkspace){const A=D.find(E=>E.project.id===t.activeProjectId)??D[0];D=A?[A]:[]}for(const A of D){const E=b2(A,{mainWorkspaceOnly:t.showOnlyMainWorkspace});if(d&&!E.some(k=>S(k.group)>0))continue;const W=!d&&!t.singleProjectMode&&!t.showOnlyMainWorkspace&&t.collapsedProjects.has(A.project.id);if(!t.showOnlyMainWorkspace){const k=e.length;j({kind:"project-header",key:`project:${A.project.id}:header`,estimateSize:yo,section:A,collapsed:W,forceExpanded:d}),i.push(Object.freeze({rowIndex:k,kind:"project",id:A.project.id}))}if(!W)for(const k of E)N(k.group,k.groupKey,k.projectId,k.hideGroupLabel)}e.length===0&&j({kind:"empty",key:d?"sidebar:search-empty":"sidebar:empty",estimateSize:72,emptyKind:d?"search":"sidebar"});const U=new Map;return e.forEach((A,E)=>U.set(A.key,E)),Object.freeze({rows:Object.freeze(e),selectionEntries:Object.freeze(n),selectionDescendantIds:Object.freeze(r),rowIndexByKey:U,stickyHeaders:Object.freeze(i),folderDropTargets:Object.freeze(o),folderAuthorityByOwner:t.folderAuthorityByOwner,sessionById:l,searchMatchCount:d?f:0})},R2=(t,e)=>t.map(n=>{const r=gt(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
879
+ `),M2=[],O2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:g,buildGroupSearchText:x,foldersMap:b,standaloneGroups:j}=t,y=c.useRef(new Map),h=c.useMemo(()=>{const O=y.current,M=new Map;let F=0,K=0;const D=(A,E)=>A.length===E.length&&A.every((W,k)=>W===E[k]),U=e.map(A=>{const E=n(A.id),W=r(A.id),k=i.get(A.normalizedPath)??M2,v=o.has(A.id)?!!o.get(A.id):d,I=l.get(A.id)??null,H=R2(k,a),_=O.get(A.id);if(_&&_.project===A&&D(_.activeSessions,E)&&D(_.archivedSessions,W)&&_.availableWorktrees===k&&_.rootBranch===I&&_.worktreeBranchesKey===H&&_.isRepo===v&&_.buildGroupedSessions===u)return F+=1,M.set(A.id,_),_.section;if(K+=1,_){const ue=_.project!==A?"project":D(_.activeSessions,E)?D(_.archivedSessions,W)?_.availableWorktrees!==k?"worktrees":_.rootBranch!==I?"branch":_.worktreeBranchesKey!==H?"worktreeBranches":_.isRepo!==v?"repo":"builder":"archived":"sessions";ws(`ui.sidebar.project_section.rebuilt_reason.${ue}`)}const se=Bu([...E,...W]),te=u(se,A.normalizedPath,k,I,v),ee={project:A,groups:te};return M.set(A.id,{project:A,activeSessions:E,archivedSessions:W,availableWorktrees:k,rootBranch:I,worktreeBranchesKey:H,isRepo:v,buildGroupedSessions:u,section:ee}),ee});return y.current=M,F>0&&ws("ui.sidebar.project_section.reused",F),K>0&&ws("ui.sidebar.project_section.rebuilt",K),U},[e,n,r,i,o,d,u,l,a]),p=c.useMemo(()=>h,[h]),w=c.useMemo(()=>{const O=new WeakMap;if(!m)return O;const F=f.trim().toLowerCase().startsWith("ses_"),K=D=>{const U=g(D.sessions,f),A=Yf(U,f),E=!F&&Fo([x(D)],f),W=Gr(D).flatMap(({scopeKey:v})=>b[v]??[]),k=F?0:W.filter(v=>Fo([v.name],f)).length;O.set(D,{filteredNodes:U,matchedSessionCount:A,folderNameMatchCount:k,groupMatches:E,hasMatch:E||A>0||k>0})};return p.forEach(D=>{D.groups.forEach(K)}),j.forEach(K),O},[m,p,j,g,f,x,b]),S=c.useMemo(()=>m?p.map(O=>({...O,groups:O.groups.filter(M=>w.get(M)?.hasMatch===!0)})).filter(O=>O.groups.length>0):p,[m,p,w]),N=m?S:p,P=c.useRef(new WeakMap),C=c.useMemo(()=>{const O=P.current;return N.map(M=>{const F=O.get(M);if(F&&F.query===f)return F.section;const K=M.groups.filter(v=>!v.isArchivedBucket),D=M.groups.filter(v=>v.isArchivedBucket),U=K.flatMap(v=>m?w.get(v)?.filteredNodes??[]:v.sessions),A=K.map(v=>({scopeKey:v.folderScopeKey??gt(v.directory??null),directory:v.directory??null})).filter(v=>!!v.scopeKey),E=K.find(v=>v.isMain)??null,W={id:"flat",label:E?.label??"",branch:E?.branch??null,description:E?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:E?.directory??M.project.normalizedPath,folderScopeKey:E?.folderScopeKey??M.project.normalizedPath,folderScopes:A,sessions:U};if(m){const v=K.map(I=>w.get(I)).filter(I=>!!I);w.set(W,{filteredNodes:U,matchedSessionCount:v.reduce((I,H)=>I+H.matchedSessionCount,0),folderNameMatchCount:v.reduce((I,H)=>I+H.folderNameMatchCount,0),groupMatches:v.some(I=>I.groupMatches),hasMatch:v.some(I=>I.hasMatch)})}const k={project:M.project,groups:[W,...D]};return O.set(M,{query:f,section:k}),k})},[w,m,f,N]),T=c.useMemo(()=>{if(!m)return 0;const O=(F,K)=>{const D=w.get(K);if(!D)return F;const U=D.folderNameMatchCount+(D.groupMatches?1:0);return F+D.matchedSessionCount+U},M=N.reduce((F,K)=>K.groups.reduce(O,F),0);return j.reduce(O,M)},[m,N,j,w]);return{projectSections:h,visibleProjectSections:p,groupSearchDataByGroup:w,searchableProjectSections:S,sectionsForRender:N,flatSectionsForRender:C,searchMatchCount:T}},B2=180,Hc=150,F2=2,L2=8,Gc=[-1,1],Ri=t=>`${t.directory}
880
+ ${t.sessionId}`,_2=t=>t?.directory?.trim()||null,$2=({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(()=>Pn(),[]),m=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<F2&&l.current.length>0;){const x=l.current.shift();if(!x)break;if(x.generation!==d.current||rt.getState().currentSessionId===x.sessionId||Yi(x.sessionId,x.directory).renderable)continue;const j=Ri(x);a.current.add(j),i({directory:x.directory,sessionID:x.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(j),f()})}},[t,u,i]),g=c.useCallback(x=>{const b=x?.id,j=_2(x);if(!t||u||!b||!j||b===e)return;const y={sessionId:b,directory:j,generation:d.current},h=Ri(y);if(Yi(b,j).renderable||a.current.has(h)||l.current.some(S=>Ri(S)===h))return;const p=o.current.get(h);p!==void 0&&window.clearTimeout(p);const w=window.setTimeout(()=>{if(o.current.delete(h),y.generation!==d.current)return;const S=l.current;S.length>=L2&&S.shift(),S.push(y),f()},B2);o.current.set(h,w)},[e,t,u,f]);c.useEffect(()=>{m()},[m,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const x=window.setTimeout(()=>{const b=n.findIndex(j=>j.id===e);if(!(b<0))for(const j of Gc)g(n[b+j])},Hc);return()=>window.clearTimeout(x)},[e,t,u,g,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const x=window.setTimeout(()=>{const b=r.findIndex(j=>j.id===e);if(!(b<0))for(const j of Gc)g(r[b+j])},Hc);return()=>window.clearTimeout(x)},[e,t,u,r,g]),c.useEffect(()=>m,[m])},z2=t=>{const e=nt.c(3),n=rt(W2);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],$2(r),null};function W2(t){return t.currentSessionId}const K2=t=>{const e=nt.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:m,children:f,renderBody:g,mobileVariant:x,alwaysShowActions:b,isRenaming:j,renameDraft:y,onRenameDraftChange:h,onRenameSave:p,onRenameCancel:w,droppableRef:S,isDropTarget:N,onNewSession:P,depth:C,hideActions:T,archivedBucket:O}=t,M=a===void 0?null:a,F=g===void 0?!0:g,D=b===void 0?x===void 0?!1:x:b,U=j===void 0?!1:j,A=y===void 0?"":y,E=N===void 0?!1:N,W=T===void 0?!1:T,k=O===void 0?!1:O,{t:v}=At(),[I,H]=c.useState(!1),[_,se]=c.useState(""),te=c.useRef(null),ee=U||I,ue=U?A:_;let de;e[0]!==n.name?(de=()=>{se(n.name),H(!0)},e[0]=n.name,e[1]=de):de=e[1];const Re=de;let we;e[2]!==ue||e[3]!==n.name||e[4]!==U||e[5]!==u||e[6]!==p?(we=()=>{const He=ue.trim();He&&He!==n.name&&u(He),U&&p&&p(),H(!1),se("")},e[2]=ue,e[3]=n.name,e[4]=U,e[5]=u,e[6]=p,e[7]=we):we=e[7];const fe=we;let Pe;e[8]!==U||e[9]!==w?(Pe=()=>{U&&w&&w(),H(!1),se("")},e[8]=U,e[9]=w,e[10]=Pe):Pe=e[10];const L=Pe;let oe;e[11]!==U||e[12]!==h?(oe=He=>{U&&h?h(He):se(He)},e[11]=U,e[12]=h,e[13]=oe):oe=e[13];const ce=oe;let he,Y;e[14]!==U?(he=()=>{if(!U)return;const He=()=>{const pe=te.current;pe&&(pe.focus(),pe.select())},$e=requestAnimationFrame(He),R=window.setTimeout(He,0);return()=>{cancelAnimationFrame($e),window.clearTimeout(R)}},Y=[U],e[14]=U,e[15]=he,e[16]=Y):(he=e[15],Y=e[16]),c.useEffect(he,Y);const ve=l?"folder":"folder-open",Te=E&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let ke;e[17]!==Te?(ke=Ie("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Te),e[17]=Te,e[18]=ke):ke=e[18];let xe;e[19]!==d||e[20]!==ee?(xe=ee?void 0:He=>{He.currentTarget.blur(),d()},e[19]=d,e[20]=ee,e[21]=xe):xe=e[21];const ge=ee?void 0:"button",Q=ee?void 0:0;let $;e[22]!==d||e[23]!==ee?($=ee?void 0:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),d())},e[22]=d,e[23]=ee,e[24]=$):$=e[24];let J;e[25]!==n.name||e[26]!==l||e[27]!==v?(J=l?v("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):v("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=v,e[28]=J):J=e[28];const me=k?D?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":D?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let le;e[29]!==me?(le=Ie("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",me),e[29]=me,e[30]=le):le=e[30];const V=E?"text-primary":"text-muted-foreground";let Z;e[31]!==V?(Z=Ie("h-3.5 w-3.5 flex-shrink-0",V),e[31]=V,e[32]=Z):Z=e[32];let G;e[33]!==ve||e[34]!==Z?(G=s.jsx(B,{name:ve,className:Z}),e[33]=ve,e[34]=Z,e[35]=G):G=e[35];let ie;e[36]!==M||e[37]!==r||e[38]!==ue||e[39]!==n.name||e[40]!==L||e[41]!==ce||e[42]!==fe||e[43]!==l||e[44]!==E||e[45]!==ee||e[46]!==i||e[47]!==v?(ie=ee?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:V2,onMouseDown:U2,onSubmit:He=>{He.preventDefault(),fe()},children:[s.jsx("input",{ref:te,value:ue,onChange:He=>ce(He.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:v("sessions.sidebar.folderItem.namePlaceholder"),onClick:H2,onPointerDown:G2,onMouseDown:q2,onKeyDown:He=>{if(He.key==="Escape"){He.stopPropagation(),L();return}(He.key===" "||He.key==="Enter")&&He.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:Y2,onPointerDown:Q2,onMouseDown:X2,children:s.jsx(B,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:He=>{He.stopPropagation(),L()},onPointerDown:J2,onMouseDown:Z2,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(B,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("span",{className:Ie("typography-ui-label font-semibold truncate",E?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(jt,{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]}),M?s.jsx(Yh,{state:M}):null,l?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=M,e[37]=r,e[38]=ue,e[39]=n.name,e[40]=L,e[41]=ce,e[42]=fe,e[43]=l,e[44]=E,e[45]=ee,e[46]=i,e[47]=v,e[48]=ie):ie=e[48];let je;e[49]!==le||e[50]!==G||e[51]!==ie?(je=s.jsxs("div",{className:le,children:[G,ie]}),e[49]=le,e[50]=G,e[51]=ie,e[52]=je):je=e[52];let ne;e[53]!==D||e[54]!==k||e[55]!==n.name||e[56]!==Re||e[57]!==W||e[58]!==m||e[59]!==P||e[60]!==ee||e[61]!==v?(ne=!ee&&(!W||k)?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",D?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!k&&P?s.jsx("button",{type:"button",onClick:He=>{He.stopPropagation(),P()},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":v("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:v("sessions.sidebar.project.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-3.5 w-3.5"})}):null,k?null:s.jsx("button",{type:"button",onClick:He=>{He.stopPropagation(),Re()},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":v("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(B,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:He=>{He.stopPropagation(),m()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":k?v("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):v("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=D,e[54]=k,e[55]=n.name,e[56]=Re,e[57]=W,e[58]=m,e[59]=P,e[60]=ee,e[61]=v,e[62]=ne):ne=e[62];let Oe;e[63]!==S||e[64]!==ke||e[65]!==xe||e[66]!==ge||e[67]!==Q||e[68]!==$||e[69]!==J||e[70]!==je||e[71]!==ne?(Oe=s.jsxs("div",{ref:S,className:ke,onClick:xe,role:ge,tabIndex:Q,onKeyDown:$,"aria-label":J,children:[je,ne]}),e[63]=S,e[64]=ke,e[65]=xe,e[66]=ge,e[67]=Q,e[68]=$,e[69]=J,e[70]=je,e[71]=ne,e[72]=Oe):Oe=e[72];let Ve;e[73]!==f||e[74]!==l||e[75]!==F||e[76]!==i||e[77]!==o||e[78]!==v?(Ve=!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:v("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=F,e[76]=i,e[77]=o,e[78]=v,e[79]=Ve):Ve=e[79];let ze;return e[80]!==Oe||e[81]!==Ve?(ze=s.jsxs("div",{className:"oc-folder",children:[Oe,Ve]}),e[80]=Oe,e[81]=Ve,e[82]=ze):ze=e[82],ze},Qf=c.memo(K2);function V2(t){return t.stopPropagation()}function U2(t){return t.stopPropagation()}function H2(t){return t.stopPropagation()}function G2(t){return t.stopPropagation()}function q2(t){return t.stopPropagation()}function Y2(t){return t.stopPropagation()}function Q2(t){return t.stopPropagation()}function X2(t){return t.stopPropagation()}function J2(t){return t.stopPropagation()}function Z2(t){return t.stopPropagation()}function ek(t){const e=nt.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=Zd(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 qr=t=>{const e=nt.c(13),{directory:n,className:r}=t,{t:i}=At();let o;e[0]!==n?(o=lh(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=j=>j.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Rt(a)?.tabs.some(Kd))return null;let m;e[4]!==i?(m=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=m):m=e[5];const f=m;let g;e[6]!==r?(g=Ie("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(B,{name:"pulse",className:"size-3.5"}),e[8]=x):x=e[8];let b;return e[9]!==l||e[10]!==f||e[11]!==g?(b=s.jsx("span",{className:g,role:"img","aria-label":f,title:f,"data-action-directory":l,children:x}),e[9]=l,e[10]=f,e[11]=g,e[12]=b):b=e[12],b},tk=t=>{const e=nt.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,m=a===void 0?!1:a,f=`session-drag:${r??n}`;let g;e[0]!==m||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(g={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:m},e[0]=m,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=g):g=e[5];let x;e[6]!==m||e[7]!==f||e[8]!==g?(x={id:f,disabled:m,data:g},e[6]=m,e[7]=f,e[8]=g,e[9]=x):x=e[9];const{attributes:b,listeners:j,setNodeRef:y,isDragging:h}=kx(x);let p;e[10]!==j?(p=P=>{P.stopPropagation(),j?.onPointerDown&&j.onPointerDown(P)},e[10]=j,e[11]=p):p=e[11];const w=p,S=`touch-pan-y select-none${h?" opacity-30":""}`;let N;return e[12]!==b||e[13]!==d||e[14]!==w||e[15]!==j||e[16]!==y||e[17]!==S?(N=s.jsx("div",{ref:y,...b,...j,onPointerDown:w,className:S,children:d}),e[12]=b,e[13]=d,e[14]=w,e[15]=j,e[16]=y,e[17]=S,e[18]=N):N=e[18],N},Xf=t=>{const e=nt.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=Bn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let m;e[3]!==a||e[4]!==r?(m=a||sl(r),e[3]=a,e[4]=r,e[5]=m):m=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let g;e[10]!==u||e[11]!==m||e[12]!==f?(g={id:u,disabled:m,data:f},e[10]=u,e[11]=m,e[12]=f,e[13]=g):g=e[13];const{setNodeRef:x,isOver:b}=Cx(g);let j;e[14]!==l||e[15]!==b||e[16]!==x?(j=l(x,b),e[14]=l,e[15]=b,e[16]=x,e[17]=j):j=e[17];let y;return e[18]!==j?(y=s.jsx(s.Fragment,{children:j}),e[18]=j,e[19]=y):y=e[19],y},sk=t=>{const e=nt.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];const m=ei(mn(si,d),mn(ti,u)),[f,g]=c.useState(null),[x,b]=c.useState("Session"),[j,y]=c.useState(null),[h,p]=c.useState(null);if(!n){let M;return e[2]!==l?(M=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=M):M=e[3],M}let w;e[4]!==o||e[5]!==a?(w=M=>{g(null),y(null),p(null);const{active:F,over:K}=M;if(!K)return;const D=F.data.current,U=K.data.current;D?.type!=="session"||!D.sessionId||!D.ownerKey||D.archivedBucket===!0||a&&D.ownerKey!==a||U?.type!=="folder"||!U.folderId||!U.scopeKey||!U.ownerKey||sl(U.scopeKey)||U.ownerKey!==D.ownerKey||o(D.sessionId,{folderId:U.folderId,scopeKey:U.scopeKey,ownerKey:U.ownerKey},D.ownerKey)},e[4]=o,e[5]=a,e[6]=w):w=e[6];const S=w;let N,P;e[7]===Symbol.for("react.memo_cache_sentinel")?(N=M=>{const F=M.active.data.current;if(F?.type==="session"&&F.sessionId){g(F.sessionId),b(F.sessionTitle??"Session");const K=M.active.rect.current.initial?.width,D=M.active.rect.current.initial?.height;y(K??null),p(D??null)}},P=()=>{g(null),y(null),p(null)},e[7]=N,e[8]=P):(N=e[7],P=e[8]);let C;e[9]!==h||e[10]!==f||e[11]!==x||e[12]!==j||e[13]!==i?(C=f&&i?s.jsxs("div",{style:{width:j?`${j}px`:"auto",height:h?`${h}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(B,{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]=h,e[10]=f,e[11]=x,e[12]=j,e[13]=i,e[14]=C):C=e[14];let T;e[15]!==C?(T=s.jsx(Nx,{children:C}),e[15]=C,e[16]=T):T=e[16];let O;return e[17]!==l||e[18]!==S||e[19]!==m||e[20]!==T?(O=s.jsxs(ni,{sensors:m,collisionDetection:ri,onDragStart:N,onDragCancel:P,onDragEnd:S,children:[l,T]}),e[17]=l,e[18]=S,e[19]=m,e[20]=T,e[21]=O):O=e[21],O},Jf=c.createContext(null),nk=({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(Jf.Provider,{value:a.current,children:r})},Zf=()=>c.useContext(Jf),rk=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const m of u)l.has(m)||(l.add(m),o.push(m))}return o.length>0?{ids:o,scopeKey:i}:null},em=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},ok=t=>{const e=nt.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[m,f]=c.useState(!1),g=i===n&&!m,x=r?i===r&&!m:d;let b;e[0]!==l||e[1]!==i||e[2]!==o?(b=O=>{if(i===O){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=b):b=e[3];const j=b;let y;e[4]!==n||e[5]!==j||e[6]!==o?(y=O=>{if(O){u(!1),f(!1),o(n);return}j(n)},e[4]=n,e[5]=j,e[6]=o,e[7]=y):y=e[7];const h=y;let p;e[8]!==r||e[9]!==j||e[10]!==o?(p=O=>{if(!r){u(O);return}if(O){f(!1),o(r);return}j(r)},e[8]=r,e[9]=j,e[10]=o,e[11]=p):p=e[11];const w=p;let S;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(S=O=>{O||(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 N=S;let P;e[18]!==g||e[19]!==n||e[20]!==o?(P=()=>{f(!1),o(g?null:n)},e[18]=g,e[19]=n,e[20]=o,e[21]=P):P=e[21];const C=P;let T;return e[22]!==w||e[23]!==h||e[24]!==N||e[25]!==x||e[26]!==g||e[27]!==C?(T={isMenuOpen:g,isContextMenuOpen:x,handleMenuOpenChange:h,handleContextMenuOpenChange:w,handleMenuOpenChangeComplete:N,toggleMenu:C},e[22]=w,e[23]=h,e[24]=N,e[25]=x,e[26]=g,e[27]=C,e[28]=T):T=e[28],T},ik=t=>{const e=nt.c(10),{project:n,fallback:r}=t,{currentTheme:i}=qn(),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(Va,{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},ak=t=>{const e=nt.c(13),{project:n}=t,r=n?.icon?Wa[n.icon]:null,i=n?.color?Ka[n.color]??null:null;let o;e[0]!==i||e[1]!==r?(o=r?s.jsx(B,{name:r,className:Ie("h-3.5 w-3.5",!i&&"text-muted-foreground/75"),style:i?{color:i}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/75",style:i?{color:i}:void 0}),e[0]=i,e[1]=r,e[2]=o):o=e[2];const l=o;if(!n?.iconImage){let m;return e[3]!==l?(m=s.jsx("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:l}),e[3]=l,e[4]=m):m=e[4],m}let a;e[5]!==n.iconBackground?(a=n.iconBackground?{backgroundColor:n.iconBackground}:void 0,e[5]=n.iconBackground,e[6]=a):a=e[6];let d;e[7]!==l||e[8]!==n?(d=s.jsx(ik,{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},xa=t=>{const e=nt.c(48),{compact:n,project:r,projectLabel:i,title:o,titleClassName:l,branchLabel:a,thirdLineLead:d,statusDot:u,pinnedMarker:m,timeSlot:f,directoryIndicator:g,prBadge:x,zombieIndicator:b,goal:j,badges:y,doneHint:h,providerId:p,metaPaddingClass:w,hideMetaOnHoverClass:S}=t,N=n===void 0?!1:n,P=d===void 0?null:d,C=j===void 0?null:j,T=h===void 0?null:h,O=!N&&(!!a||!!P||!!x||!!b||!!C||!!y||!!p);let M;e[0]!==S||e[1]!==w?(M=Ie("ml-auto flex flex-shrink-0 items-center gap-1 transition-opacity",w,S),e[0]=S,e[1]=w,e[2]=M):M=e[2];const F=N?C:null,K=N?y:null;let D;e[3]!==f?(D=s.jsx("span",{className:"typography-micro leading-none text-muted-foreground/50 tabular-nums",children:f}),e[3]=f,e[4]=D):D=e[4];let U;e[5]!==g||e[6]!==T||e[7]!==m||e[8]!==u||e[9]!==M||e[10]!==F||e[11]!==K||e[12]!==D?(U=s.jsxs("span",{className:M,children:[F,K,g,m,T,u,D]}),e[5]=g,e[6]=T,e[7]=m,e[8]=u,e[9]=M,e[10]=F,e[11]=K,e[12]=D,e[13]=U):U=e[13];const A=U;if(N){let se;e[14]!==l?(se=Ie("min-w-0 flex-1 truncate typography-ui-label font-normal",l),e[14]=l,e[15]=se):se=e[15];let te;e[16]!==se||e[17]!==o?(te=s.jsx("div",{className:se,children:o}),e[16]=se,e[17]=o,e[18]=te):te=e[18];let ee;return e[19]!==A||e[20]!==te?(ee=s.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[te,A]}),e[19]=A,e[20]=te,e[21]=ee):ee=e[21],ee}let E;e[22]!==r?(E=s.jsx(ak,{project:r}),e[22]=r,e[23]=E):E=e[23];let W;e[24]!==i?(W=i?s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/85",children:i}):null,e[24]=i,e[25]=W):W=e[25];let k;e[26]!==A||e[27]!==E||e[28]!==W?(k=s.jsxs("div",{className:"relative flex h-5 w-full min-w-0 items-center gap-1",children:[E,W,A]}),e[26]=A,e[27]=E,e[28]=W,e[29]=k):k=e[29];let v;e[30]!==l?(v=Ie("w-full min-w-0 truncate typography-ui-label font-normal",l),e[30]=l,e[31]=v):v=e[31];let I;e[32]!==v||e[33]!==o?(I=s.jsx("div",{className:v,children:o}),e[32]=v,e[33]=o,e[34]=I):I=e[34];let H;e[35]!==y||e[36]!==a||e[37]!==C||e[38]!==O||e[39]!==x||e[40]!==p||e[41]!==P||e[42]!==b?(H=O?s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[P??(a?s.jsxs(s.Fragment,{children:[s.jsx(B,{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:[C,b??x,y,p?s.jsx(Fu,{providerId:p,className:"h-4 w-4 flex-shrink-0 opacity-45"}):null]})]}):null,e[35]=y,e[36]=a,e[37]=C,e[38]=O,e[39]=x,e[40]=p,e[41]=P,e[42]=b,e[43]=H):H=e[43];let _;return e[44]!==k||e[45]!==I||e[46]!==H?(_=s.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-px",children:[k,I,H]}),e[44]=k,e[45]=I,e[46]=H,e[47]=_):_=e[47],_};let ya=!1;const wa=new Set;let qc=!1;function lk(){for(const t of wa)t()}function tm(t){ya!==t&&(ya=t,lk())}function vo(t){tm(t.shiftKey)}function ck(){tm(!1)}function dk(){if(qc||typeof window>"u")return;qc=!0;const t={capture:!0,passive:!0};window.addEventListener("keydown",vo,t),window.addEventListener("keyup",vo,t),window.addEventListener("pointermove",vo,t),window.addEventListener("pointerdown",vo,t),window.addEventListener("blur",ck)}function uk(t){return dk(),wa.add(t),()=>{wa.delete(t)}}function fk(){return ya}function mk(){return!1}function hk(){return at.useSyncExternalStore(uk,fk,mk)}const sm=async(t,e,n)=>{const r=n.getRuntimeKey(),i=gt(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||gt(a.path??null)!==i)throw new Error("Project removed during worktree refresh");const d=nl({rawWorktreesByProjectRef:n.rawWorktreesByProjectRef,publishedWorktreesByProject:n.getPublishedWorktreesByProject(),runtimeKey:r}),u=o.map(b=>Ho(b));u.sort((b,j)=>nm({metadata:b},{metadata:j}));const m=Ug(d.worktreesByProject,i,u,e?.projectDirectory);pk(n.rawWorktreesByProjectRef,r),n.rawWorktreesByProjectRef.current={runtimeKey:r,revision:n.rawWorktreesByProjectRef.current.revision,worktreesByProject:m};const f=n.getPublishedWorktreesByProject(),g=Hg(n.partitionWorktreesByRegisteredProject(l,m),f),x=[...g.values()].flat();return n.recordWorktreesSeen(x.map(b=>b.path),n.now()),n.worktreeMapsEqual(g,f)||n.publishTopology({availableWorktrees:x,availableWorktreesByProject:g}),u},pk=(t,e)=>(t.current.runtimeKey!==e||(t.current={...t.current,revision:t.current.revision+1}),t.current.revision),gk=t=>new Map([...t.entries()].map(([e,n])=>[e,n.map(r=>Ho(r))])),nl=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:gk(t.publishedWorktreesByProject)}),t.rawWorktreesByProjectRef.current),nm=(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"})},Yc=t=>{const e=t.split("/").filter(Boolean);return e[e.length-1]??t},Ho=t=>({...t,path:gt(t.path)??t.path,projectDirectory:gt(t.projectDirectory)??t.projectDirectory,worktreeRoot:gt(t.worktreeRoot??t.path)??t.worktreeRoot}),Qc=t=>{const{currentWorktree:e,path:n,projectDirectory:r,projectRootBranch:i}=t,l=gt(e?.path??null)===n,a=l?e?.branch??"":i??"",d={path:n,projectDirectory:r,branch:a,label:l?e?.label||e?.branch||e?.name||Yc(n):i||Yc(n),name:l?e?.name:void 0,worktreeRoot:l?gt(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},Xc=t=>{const e=gt(t.projectPath??null),n=gt(t.sourceDirectory??null)??gt(t.currentWorktree?.path??null),r=gt(t.discoveredWorktrees.find(m=>gt(m.projectDirectory??null))?.projectDirectory??null),i=gt(t.currentWorktree?.projectDirectory??null),o=r??i??e,l=new Map,a=m=>{const f=gt(m.metadata.path??null);!f||l.has(f)||l.set(f,{...m,metadata:Ho({...m.metadata,path:f})})};for(const m of t.discoveredWorktrees){const f=gt(m.path??null);f&&a({metadata:Ho({...m,path:f,projectDirectory:gt(m.projectDirectory??null)??o??e??f}),isPrimary:o===f,isCurrent:n===f})}o&&!l.has(o)&&a({metadata:Qc({path:o,projectDirectory:o,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:!0,isCurrent:n===o}),n&&!l.has(n)&&a({metadata:Qc({path:n,projectDirectory:o??e??n,currentWorktree:t.currentWorktree,projectRootBranch:t.projectRootBranch}),isPrimary:o===n,isCurrent:!0});const d=[],u=[];for(const m of l.values()){if(m.isPrimary){d.push(m);continue}u.push(m)}return d.sort((m,f)=>m.metadata.path.localeCompare(f.metadata.path,void 0,{sensitivity:"base"})),u.sort(nm),[...d,...u]},rm=(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},bk=(t,e)=>{const n=e.getRuntimeKey(),r=e.getPublishedWorktreesByProject(),i=nl({rawWorktreesByProjectRef:e.rawWorktreesByProjectRef,publishedWorktreesByProject:r,runtimeKey:n}),o=rm(t,e),l=gt(o?.path??null);return{cachedTargets:Xc({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 sm(o,t.currentWorktree,e);return Xc({projectPath:l,discoveredWorktrees:d,sourceDirectory:t.sourceDirectory,currentWorktree:t.currentWorktree,projectRootBranch:e.projectRootBranch})})()}},xk=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},yk=t=>({refreshState:t.isRefreshing?"loading":t.loadFailed&&t.targets.length===0?"error":null,showNewWorktreeAction:!0}),wk=(t,e)=>gt(t.worktree?.path??null)===gt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch,Br=6,So=14,Jc=Br+14+6,Mi=new WeakMap,vk=t=>{const e=t.closest("[data-session-row]"),n=e?.closest(".overlay-scrollbar-container");if(!e||!n)return;Mi.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,Mi.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,ws("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}),Mi.set(n,a),l=window.requestAnimationFrame(d)},Sk=c.memo(function(e){const n=nt.c(22),{archiveLabel:r,deleteLabel:i,buttonSizeClass:o,iconSizeClass:l,onPointerDown:a,onMouseDown:d,onArchive:u,onDelete:m}=e,f=hk(),g=f?i:r;let x;n[0]!==u||n[1]!==m||n[2]!==f?(x=P=>{if(f||P.shiftKey){m(P);return}u(P)},n[0]=u,n[1]=m,n[2]=f,n[3]=x):x=n[3];const b=x,j=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let y;n[4]!==o||n[5]!==j?(y=Ie("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",j,o),n[4]=o,n[5]=j,n[6]=y):y=n[6];const h=f?"delete-bin":"archive";let p;n[7]!==l||n[8]!==h?(p=s.jsx(B,{name:h,className:l}),n[7]=l,n[8]=h,n[9]=p):p=n[9];let w;n[10]!==b||n[11]!==g||n[12]!==d||n[13]!==a||n[14]!==y||n[15]!==p?(w=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:y,"aria-label":g,onPointerDown:a,onMouseDown:d,onClick:b,onKeyDown:Tk,children:p})}),n[10]=b,n[11]=g,n[12]=d,n[13]=a,n[14]=y,n[15]=p,n[16]=w):w=n[16];let S;n[17]!==g?(S=s.jsx(jt,{side:"left",sideOffset:8,children:g}),n[17]=g,n[18]=S):S=n[18];let N;return n[19]!==w||n[20]!==S?(N=s.jsxs(vt,{children:[w,S]}),n[19]=w,n[20]=S,n[21]=N):N=n[21],N});function jk(t){ws("ui.sidebar_session_node.render");const{t:e}=At(),{node:n,depth:r=0,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d=!1,pinnedSessionIds:u,expandedParents:m,hasSessionSearchQuery:f,normalizedSessionSearchQuery:g,notifyOnSubtasks:x,editingId:b,editingRowKey:j,setEditingId:y,setEditingRowKey:h,editTitle:p,setEditTitle:w,handleSaveEdit:S,handleCancelEdit:N,toggleParent:P,handleSessionSelect:C,handleSessionDoubleClick:T,handleCopySessionId:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,createFolderAndStartRename:K,handleDeleteSession:D,handleRestoreSession:U,startSessionWorktreeMenuLoad:A,onEditProject:E,mobileVariant:W,alwaysShowActions:k,secondaryMeta:v,renderContext:I="project",rowKey:H,dragKey:_,children:se}=t,te=Ur(Ae=>Ae.toggle),ee=Gt(Ae=>Ae.getFoldersForScope),ue=Gt(Ae=>Ae.getSessionFolderId),de=Gt(Ae=>Ae.removeSessionFromFolder),Re=Gt(Ae=>Ae.addSessionToFolder),we=ye(Ae=>Ae.openContextPanelTab),fe=c.useMemo(()=>Pn(),[]),Pe=c.useMemo(()=>Kr(),[]),L=c.useContext(Gg),oe=fe?"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",ce=fe?"group-hover:opacity-0":"group-hover:opacity-0 group-has-[:focus-visible]:opacity-0",he=fe,Y=!d&&!W,ve=ye(Ae=>Ae.sessionWorkEnabled),Te=ye(Ae=>Ae.sessionRecapEnabled),ke=ve&&!d&&!n.session.parentID&&!$a(n.session.directory),xe=ke&&!k,ge=(xe?1:0)+(Y?1:0)+(he?1:0),Q=fe?["group-hover:pr-8","group-hover:pr-14","group-hover:pr-18","group-hover:pr-22"][ge]:["group-hover:pr-3 group-has-[:focus-visible]:pr-3","group-hover:pr-7 group-has-[:focus-visible]:pr-7","group-hover:pr-11 group-has-[:focus-visible]:pr-11"][ge],$=Y?"pr-13":"pr-7",J=fe?["pr-8","pr-14","pr-18","pr-22"][ge]:["pr-3","pr-7","pr-11"][ge],me=c.useRef(!1),[le,V]=c.useState(!1),Z=c.useRef(b);Z.current=b;const G=c.useRef(null),ie=c.useRef(!1),je=c.useRef(S);je.current=S;const ne=p,Oe=c.useRef(ne);Oe.current=ne;const Ve=c.useRef(null),ze=c.useRef(!1),He=c.useRef(null),$e=c.useRef(null),R=n.session,pe=R,Le=Kt(c.useCallback(Ae=>{if(v?.projectLabel||!o)return null;const Et=Ae.projects.find(Ut=>Ut.id===o);return Et?Et.label?.trim()||yr(gt(Et.path)??Et.path,null)||Et.path:null},[o,v?.projectLabel])),_e=I==="timeline"||I==="timeline-chat",lt=I==="timeline-chat",ht=Kt(c.useCallback(Ae=>!_e||!o?null:Ae.projects.find(Et=>Et.id===o)??null,[_e,o])),ot=v?.projectLabel??(Le?Lu(Le):null),ut=j2(v,n.worktree?.branch??null),yt=c.useMemo(()=>k2(n.worktree,fe),[fe,n.worktree]),mt=_u(yt),xt=mt?`var(--pr-${mt.visualState})`:void 0,Dt=!!ut&&I==="recent",be=c.useMemo(()=>{if(!mt)return null;switch(mt.visualState){case"merged":return e("sessions.sidebar.group.pr.status.merged");case"open":return mt.canMerge===!0||mt.mergeableState==="clean"||mt.checks?.state==="success"?e("sessions.sidebar.group.pr.status.readyToMerge"):e("sessions.sidebar.group.pr.status.open");case"blocked":return mt.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}},[mt,e]),qe=rt(Ae=>Ae.currentSessionId===R.id),Ye=gt(R.directory??null)??gt(i??null),Ue=a!==void 0?a:o??Ye??null,ct=hu(),X=$u(),ae=fe,De=ns(Ae=>Ae.enabled),Ke=ns(c.useCallback(Ae=>Ae.selectedIds.has(R.id),[R.id])),q=ns(Ae=>Ae.toggleSelected),Be=ns(Ae=>Ae.setRange),Ze=Zf(),Qe=H??R.id,et=b===R.id&&j===Qe,Ct=c.useCallback(Ae=>{const Et=[],Ut=es=>{es.children.forEach(cs=>{Et.push(cs.session.id),Ut(cs)})};return Ut(Ae),Et},[]),Ge=c.useCallback(Ae=>{const Et=[],Ut=es=>{es.children.forEach(cs=>{Et.push(cs.session),Ut(cs)})};return Ut(Ae),Et},[]),[Tt,Bt]=c.useState(!1),[Ce,Me]=c.useState(!0),st=`${I}:${d?"archived":"active"}:${R.id}`,Xe=H?`session-menu:${H}`:st,Ne=H?`session-context:${H}`:null,We=zu(c.useCallback(Ae=>!!Ae.sessionMemoryState.get(qg(R.id))?.isZombie,[R.id])),dt=ou(R.id),bt=Yg(R.id,dt),Se=ff(R.id),Je=Ia(R.id,Ye),it=Se||Je,pt=n.worktree??rt.getState().getWorktreeMetadata(R.id)??null,[kt,_t]=c.useState([]),[qt,Mt]=c.useState(!1),[Lt,Wt]=c.useState(!1),Jt=c.useRef(!1),Zt=c.useRef(0),Ft=Qg(R.id,Ye??void 0,{bootstrap:!1}),Ot=Xg(pe),It=ke&&Wu(pe),ss=It&&!dt&&Jg(pe),yn=e(It?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track"),fs=async()=>{try{await cb(R.id,Ye,It?"done":"open")}catch{Fe.error(e("sessions.sidebar.session.work.updateFailed"))}},Gs=Ot?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center",title:e(Ol[Ot.status]),"aria-label":e(Ol[Ot.status]),children:s.jsx(B,{name:"target",className:"h-3 w-3",style:{color:Zg[Ot.status]}})}):null,bs=pe.title||e("sessions.sidebar.session.untitled"),wn=!_e&&n.children.length>0,qs=Ou(u,Ye,R.id),Tn=st,$s=f?!0:m.has(Tn),sn=c.useMemo(()=>w2(n,$s,Ye),[$s,n,Ye]),xs=eb(sn),Zn=!!pe.parentID,zs=iu(R.id)>0&&(!Zn||x),Ts=pe.time?.updated||pe.time?.created||Date.now(),tr=Ku(Ts),nn=Vu(Ts),{isMenuOpen:sr,isContextMenuOpen:nr,handleMenuOpenChange:eo,handleContextMenuOpenChange:to,handleMenuOpenChangeComplete:re,toggleMenu:z}=ok({menuInstanceKey:Xe,contextMenuInstanceKey:Ne,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,hasDeferredCloseWork:()=>G.current!==null,onCloseComplete:()=>{if(!G.current)return;const{id:Ae,title:Et}=G.current;G.current=null,y(Ae),h(Qe),w(Et)}}),Ee=sr||nr,tt=c.useMemo(()=>tb(pe)?.key??null,[pe]),wt=c.useMemo(()=>Ct(n).length,[Ct,n]),Pt=c.useCallback(async Ae=>{const Et=[];let Ut=0;for(const es of Ae)try{if(!Ye)throw new Error("Session directory is required for export");const cs=await ct({directory:Ye,sessionID:es.session.id});if(!cs)throw new Error("Session runtime changed during export");const Ht=es.session.title||e("sessions.sidebar.session.export.untitledSubagent"),Es=es.session.agent,Qt=await Pt(es.children);Ut+=Qt.skipped,Et.push({title:Ht,agent:Es,records:cs,children:Qt.children})}catch{Ut+=Ct(es).length+1}return{children:Et,skipped:Ut}},[Ct,ct,Ye,e]),Nt=c.useCallback(Ae=>{Ae<=0||Fe.warning(Ae===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:Ae}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:Ae}))},[e]),$t=c.useCallback(async Ae=>{if(!Ye){Fe.error(e("sessions.sidebar.session.export.nothingToExport"));return}const Et=await ct({directory:Ye,sessionID:R.id}).catch(()=>null);if(!Et){Fe.error(e("sessions.sidebar.session.export.failedLoadHistory"));return}if(Et.length===0){Fe.error(e("sessions.sidebar.session.export.nothingToExport"));return}let Ut,es=0;if(Ae&&n.children.length>0){const Qt=await Pt(n.children);Ut=Qt.children,es=Qt.skipped}const cs=pu(Et,pe.title??null,Ut),Ht=gu(pe.title??null),Es=await bu(cs,Ht);if(Es){Fe.success(e("sessions.sidebar.session.export.success"),{action:{label:e(nb()),onClick:()=>{sb(Es).then(Qt=>{Qt||Fe.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Nt(es);return}xu(cs,Ht),Fe.success(e("sessions.sidebar.session.export.success")),Nt(es)},[Pt,ct,n.children,pe.title,R.id,Ye,Nt,e]),os=yu(),Xt=c.useMemo(()=>wu(os),[os]),Ys=c.useCallback(Ae=>{df({entry:Ae,t:e,session:{id:R.id,title:pe.title,directory:Ye},loadRecords:()=>Ye?ct({directory:Ye,sessionID:R.id}).catch(()=>null):Promise.resolve(null),onLoadFailed:()=>Fe.error(e("sessions.sidebar.session.export.failedLoadHistory"))})},[ct,pe.title,R.id,Ye,e]),rn=c.useCallback(async()=>{if(n.children.length>0){Me(!0),Bt(!0);return}await $t(!1)},[$t,n.children.length]),ui=c.useCallback(()=>{Ye&&An("desktop_open_session_mini_chat_window",{sessionId:R.id,directory:Ye,apiBaseUrl:pn(),clientToken:Vr()}).catch(Ae=>{console.warn("[session-sidebar] failed to open mini chat window",Ae)})},[R.id,Ye]);if(c.useEffect(()=>{if(!et)return;const Ae=Et=>{const es=(Et.target instanceof HTMLElement?Et.target:null)?.closest?.(`[data-session-rename-form="${CSS.escape(Qe)}"]`);$e.current&&!es&&je.current(Oe.current)};return document.addEventListener("mousedown",Ae),()=>document.removeEventListener("mousedown",Ae)},[et,Qe]),c.useLayoutEffect(()=>{if(!et){Ve.current===Qe&&(Ve.current=null);return}Ve.current!==Qe&&(Ve.current=Qe,ze.current=!0)},[p,et,Qe]),c.useLayoutEffect(()=>{if(!et||!ze.current)return;const Ae=He.current;!Ae||Ae.value!==p||(ze.current=!1,Ae.focus(),Ae.select())},[p,et,ne]),et){const Ae=s.jsxs("form",{ref:$e,"data-session-rename-form":Qe,className:"flex h-[1lh] w-full items-center gap-2 typography-ui-label",onSubmit:Et=>{Et.preventDefault(),S(ne)},children:[s.jsx("input",{ref:He,value:ne,onChange:Et=>w(Et.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:Et=>zi(Et,N)}),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(B,{name:"check",className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:N,"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(B,{name:"close",className:"size-3.5"})})]});return _e?s.jsx("div",{style:{paddingLeft:Br+4},className:Ie("group relative my-0.5 flex items-center rounded-md pr-2.5",lt?"py-1":"py-1.5",qe&&"bg-interactive-selection/70 text-interactive-selection-foreground"),children:s.jsx(xa,{compact:lt,project:ht,projectLabel:ot,title:Ae,titleClassName:"text-foreground",branchLabel:ut,statusDot:null,pinnedMarker:null,timeSlot:nn,directoryIndicator:null,prBadge:mt?s.jsxs("span",{className:"inline-flex flex-shrink-0 items-center gap-1 typography-micro",style:xt?{color:xt}:void 0,children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3",style:xt?{color:xt}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",mt.number]})]}):null,zombieIndicator:null,goal:Gs,badges:null,hideMetaOnHoverClass:""})},R.id):s.jsx("div",{style:{paddingLeft:Jc+r*So},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:Ae})},R.id)}const Qs=Ft.length,so=xs===1?e("sessions.sidebar.session.status.questionPendingSingle"):e("sessions.sidebar.session.status.questionPendingMany",{count:xs}),fi=S2({actionsAlwaysVisible:k&&!fe,menuOpen:Ee,hideOnHoverClass:ce}),rl=!it&&!dt&&zs&&!qe,rr=dt||rl,vm=e(dt?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),ol=s.jsx(cu,{state:dt?"running":"unread",label:vm}),no=(dt||rl)&&bt,Sm=!k&&wn&&(it||rr||qs),il=qs&&!it&&!rr,al=s.jsx(B,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),jm=it||rr||il?s.jsx("span",{style:{left:Br+r*So},className:Ie("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",Sm?"opacity-100 group-hover:opacity-0 group-has-[:focus-visible]:opacity-0":""),children:it?s.jsx(B,{name:"loader-4",className:"h-3 w-3 animate-spin text-primary","aria-label":e(Je?"sessions.aiRename.generating":"sessions.sidebar.session.status.movingToWorktree")}):rr?ol:il?al:null}):null,km=wn&&!k&&(it||rr||qs),Cm=wn?s.jsx("span",{role:"button",tabIndex:0,onClick:Ae=>{Ae.stopPropagation(),Ae.currentTarget.blur(),P(Tn)},onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ae.stopPropagation(),P(Tn))},style:{minWidth:14,minHeight:14,left:Br+r*So},className:Ie("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",km?"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($s?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:$s?s.jsx(B,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(B,{name:"arrow-right-s",className:"h-3 w-3"})}):null,mi=We?s.jsx(B,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Nm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),z()},Am=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Pm=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},hi=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},pi=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Dm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),F(null),D(R,{archivedBucket:d})},Im=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),F(null),D(R,{archivedBucket:d,hardDelete:!0,skipConfirm:!0})},Tm=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Em=Ae=>{Ae.preventDefault(),Ae.stopPropagation()},Rm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),L?.vscode?.executeCommand("openchamber.openSessionInEditor",R.id,bs)},ll=Ae=>{if(me.current){me.current=!1;return}if(De){if(Ae?.preventDefault(),Ae?.stopPropagation(),Ae?.shiftKey){const Et=Ze?.getEntries(),Ut=Et??Array.from(document.querySelectorAll("[data-session-row]")).map(Ht=>Ht.getAttribute("data-session-row")).filter(Ht=>!!Ht).map(Ht=>({id:Ht,rowKey:Ht,scopeKey:Ue,archived:d})),es=Et?ns.getState().anchorRowKey:ns.getState().anchorId,cs=new Map;cs.set(R.id,Ct(n)),Be(es,Qe,Ut,Ze?.getDescendantIds()??[],Ue,cs);return}q(R.id,Ue,Ct(n),Qe);return}Ae?.currentTarget&&vk(Ae.currentTarget),C(R.id,Ye)},Mm=Ae=>{Ae.defaultPrevented||(Ae.target instanceof HTMLElement?Ae.target:null)?.closest('button, a, input, [role="menuitem"], [role="menu"]')||ll(Ae)},Om=Ae=>{(Ae.button===2||Ae.button===0&&Ae.ctrlKey&&!De)&&(me.current=!0)},Bm=Ae=>{W&&Ae.pointerType==="touch"&&V(!0),Ae.button===0&&!qe&&!De&&!ae&&Ye&&!Yi(R.id,Ye).renderable&&X({directory:Ye,sessionID:R.id}).catch(()=>{})},cl=Ae=>{W&&Ae.pointerType==="touch"&&V(!1)},Fm=Ae=>{Jt.current=Ae,Zt.current+=1;const Et=Zt.current;if(!Ae){Mt(!1),Wt(!1);return}const Ut=A({projectId:o??null,sourceDirectory:Ye,currentWorktree:pt});_t(Ut.cachedTargets),Mt(!0),Wt(!1),Ut.refreshTargets.then(es=>{!Jt.current||Zt.current!==Et||(_t(es),Mt(!1),Wt(!1))}).catch(()=>{!Jt.current||Zt.current!==Et||(Mt(!1),Wt(!0))})},dl=({Item:Ae,Separator:Et,Sub:Ut,SubTrigger:es,SubContent:cs})=>s.jsxs(s.Fragment,{children:[s.jsxs(Ae,{onClick:()=>{G.current={id:R.id,title:bs}},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsx(na,{sessionID:R.id,directory:Ye,open:Ee,Item:Ae}),s.jsxs(Ae,{onClick:()=>O(R.id),className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyId")]}),s.jsxs(Ae,{onClick:()=>Ye&&te({directory:Ye,sessionId:R.id}),className:"[&>svg]:mr-1",children:[qs?s.jsx(B,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(B,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(qs?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),ke?s.jsxs(Ae,{onClick:()=>{fs()},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:It?"check":"eye",className:"mr-1 h-4 w-4"}),e(It?"sessions.sidebar.session.work.markDone":"sessions.sidebar.session.work.track")]}):null,s.jsxs(Ae,{onClick:()=>{rn()},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),Xt.map(Ht=>s.jsxs(Ae,{onClick:()=>Ys(Ht),className:"[&>svg]:mr-1",children:[s.jsx(Qr,{icon:Ht.icon,iconSrc:Ht.iconSrc,className:"mr-1 size-4"}),Ht.action.label]},`${Ht.guest.id}:${Ht.action.id}`)),_e&&o&&E?s.jsxs(Ae,{onClick:()=>E(o),className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"pencil-ai",className:"h-4 w-4"}),e("sessions.sidebar.project.actions.edit")]}):null,x2({isSubtaskSession:Zn,archivedBucket:!!d,isVSCode:fe,sessionDirectory:Ye})?(()=>{const Ht=y2({sessionDirectory:Ye,isStreaming:dt,isMovingToWorktree:Se}),Es=yk({targets:kt,isRefreshing:qt,loadFailed:Lt});return s.jsxs(Ut,{onOpenChange:Fm,children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs(es,{disabled:Ht,className:"w-full [&>svg]:mr-1","data-session-worktree-submenu-trigger":R.id,children:[s.jsx(B,{name:"folder-shared",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.moveToWorktreeTargets")]})}),s.jsx(jt,{side:"right",className:"max-w-72",children:e(Se?"sessions.sidebar.session.moveToWorktree.tooltipMoving":dt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltipTargets")})]}),s.jsxs(cs,{className:"min-w-[220px]","data-session-worktree-submenu":R.id,children:[kt.map(Qt=>{const Rs=gt(Qt.metadata.path??null)??Qt.metadata.path,kr=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(Ae,{disabled:is,title:Qt.metadata.path,"data-session-worktree-target":Rs,onClick:()=>{is||!Ye||oa({kind:"existing",root:pe,descendants:Ge(n),sourceDirectory:Ye,destination:Qt.metadata,messages:ra(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:kr}),Qt.isCurrent?s.jsx("span",{className:"sr-only",children:e("sessions.sidebar.session.moveToWorktree.current")}):null]}),Qt.isCurrent?s.jsx(B,{name:"check",className:"ml-2 h-3.5 w-3.5 flex-shrink-0 text-primary","aria-hidden":"true"}):null]},Rs)}),Es.refreshState==="loading"?s.jsx(Ae,{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,Es.refreshState==="error"?s.jsx(Ae,{disabled:!0,"data-session-worktree-refresh-state":"error",className:"py-0.5 text-muted-foreground typography-micro",children:e("sessions.sidebar.session.moveToWorktree.loadFailed")}):null,s.jsx(Et,{}),s.jsxs(Ae,{disabled:Ht,"data-session-worktree-new-action":"true",onClick:()=>{Ht||!Ye||oa({kind:"quick",root:pe,descendants:Ge(n),sourceDirectory:Ye,messages:ra(e,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.newWorktree")]})]})]})})():null,tt?s.jsxs(Ae,{onClick:()=>ye.getState().setRunOverviewKey(tt),className:"[&>svg]:mr-1",children:[s.jsx(Qi,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.openRunOverview")]}):null,Ye&&!d&&!_e?(()=>{const Ht=[],Es=is=>{const ms=gt(is??null);ms&&!Ht.includes(ms)&&Ht.push(ms)};if(o&&!fe){const is=Kt.getState().projects.find(or=>or.id===o),ms=gt(is?.path??null);Es(ms),ms&&(rt.getState().availableWorktreesByProject.get(ms)??[]).forEach(or=>Es(or.path))}Es(_a(Ye)),Es(Ye);const Qt=Ht.flatMap(is=>ee(is).map(ms=>({scope:is,folder:ms}))),Rs=Qt.find(({scope:is,folder:ms})=>ue(is,R.id)===ms.id)??null,kr=Ht[0]??Ye;return s.jsxs(s.Fragment,{children:[s.jsx(Et,{}),s.jsxs(Ut,{children:[s.jsxs(es,{className:"[&>svg]:mr-1",children:[s.jsx(B,{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(Ae,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Qt.map(({scope:is,folder:ms})=>{const or=Rs?.folder.id===ms.id;return s.jsxs(Ae,{onClick:()=>{if(or){de(is,R.id);return}Rs&&Rs.scope!==is&&de(Rs.scope,R.id),Re(is,ms.id,R.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:ms.name}),or?s.jsx(B,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},ms.id)}),s.jsx(Et,{}),s.jsxs(Ae,{onClick:()=>{const is=K(kr);is&&(ie.current=!0,Rs&&Rs.scope!==kr&&de(Rs.scope,R.id),Re(kr,is.id,R.id))},children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),Rs?s.jsxs(Ae,{onClick:()=>{de(Rs.scope,R.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,fe?null:s.jsxs(Ae,{disabled:!Ye,onClick:()=>{Ye&&we(Ye,{mode:"chat",dedupeKey:`session:${R.id}`,label:bs,sessionTitleFallback:bs})},className:"[&>svg]:mr-1",children:[s.jsx(B,{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")})]}),Pe?s.jsxs(Ae,{disabled:!Ye,onClick:ui,className:"[&>svg]:mr-1",children:[s.jsx(B,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(Et,{}),d?null:s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>D(R,{archivedBucket:d}),children:[s.jsx(B,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),d?s.jsxs(Ae,{className:"[&>svg]:mr-1",onClick:()=>U(R),children:[s.jsx(B,{name:"inbox-unarchive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.restore")]}):null,s.jsxs(Ae,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>D(R,{archivedBucket:d,hardDelete:!0}),children:[s.jsx(B,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Lm=Ae=>{Ae.preventDefault(),Ae.stopPropagation(),fs()},gi=k?"h-6 w-6":_e&&!lt?"h-5 w-5":"h-4 w-4",ro=k?"h-3.5 w-3.5":_e&&!lt?"h-3 w-3":"h-2.5 w-2.5",_m=k?"h-4 w-4":_e&&!lt?"h-3.5 w-3.5":"h-3 w-3",ul=Te&&!dt&&rb(pe)?.recap||null,fl=e("sessions.sidebar.session.work.doneSuggested"),bi=Ae=>ss?s.jsx("span",{className:Ie("inline-flex flex-shrink-0 items-center text-muted-foreground/75",Ae),title:fl,"aria-label":fl,children:s.jsx(B,{name:"check",className:"h-3.5 w-3.5"})}):null,ml=!_e&&ss,$m=Qs>0||xs>0||ml?s.jsxs(s.Fragment,{children:[ml?bi():null,Qs>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(B,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qs})]}):null,xs>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:so,"aria-label":so,children:[s.jsx(B,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:xs})]}):null]}):null,zm=_e&&mt?s.jsxs(vt,{children:[s.jsx(St,{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:xt?{color:xt}:void 0,disabled:!mt.url,"aria-label":be?`#${mt.number} · ${be}`:`#${mt.number}`,onPointerDown:hi,onMouseDown:pi,onClick:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),mt.url&&Yr(mt.url)},onKeyDown:Ae=>Ae.stopPropagation(),children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3",style:xt?{color:xt}:void 0}),s.jsxs("span",{className:"leading-none tabular-nums",children:["#",mt.number]})]})}),s.jsx(jt,{side:"top",sideOffset:6,children:s.jsx("p",{children:be?`#${mt.number} · ${be}`:`#${mt.number}`})})]}):null,Wm=_e?s.jsx(xa,{compact:lt,project:ht,projectLabel:ot,title:_r(bs,g),titleClassName:qe||Ke?"text-interactive-selection-foreground":zs?"text-foreground":"text-foreground/80",branchLabel:ut,statusDot:rr?ol:null,pinnedMarker:qs&&!it?al:null,timeSlot:no?s.jsx(yi,{sessionId:R.id,running:dt,className:"typography-micro"}):nn,directoryIndicator:!d&&Ye?s.jsx(qr,{directory:Ye}):null,prBadge:zm,zombieIndicator:mi,goal:Gs,badges:$m,doneHint:bi(),providerId:pe.model?.providerID??null,metaPaddingClass:k?Y?"pr-13":"pr-7":void 0,hideMetaOnHoverClass:k&&!fe?"":Ie(ce,Ee&&"opacity-0")}):null,Km=s.jsx(js,{align:"end",className:"min-w-[180px]",finalFocus:()=>ie.current?(ie.current=!1,!1):!Z.current,children:dl({Item:zt,Separator:ps,Sub:ib,SubTrigger:ab,SubContent:lb})}),Vm=s.jsx(Zi,{children:s.jsx(ea,{className:"app-region-no-drag z-50",children:s.jsx(ta,{"data-slot":"dropdown-menu-content",finalFocus:()=>ie.current?(ie.current=!1,!1):!Z.current,style:{color:"var(--surface-elevated-foreground)"},className:Ie(Ki,"min-w-[180px]"),children:dl({Item:({className:Ae,...Et})=>s.jsx(tf,{className:Ie(lu,Ae),...Et}),Separator:({className:Ae,...Et})=>s.jsx(ef,{className:Ie(au,Ae),...Et}),Sub:Ix,SubTrigger:({className:Ae,children:Et,...Ut})=>s.jsxs(Tx,{className:Ie(ob,Ae),...Ut,children:[Et,s.jsx(B,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:Ae,children:Et,...Ut})=>s.jsx(Zi,{children:s.jsx(ea,{className:"app-region-no-drag z-50",children:s.jsx(ta,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Ie(Ki,Ae),...Ut,children:Et})})})})})})});return s.jsxs(c.Fragment,{children:[s.jsx(tk,{sessionId:R.id,dragKey:_??Qe,ownerKey:l??Ue,sessionDirectory:Ye??null,sessionTitle:bs,archivedBucket:d,children:s.jsxs(nf,{open:nr,onOpenChange:to,onOpenChangeComplete:re,children:[s.jsxs(sf,{render:s.jsx("div",{"data-session-row":R.id,"data-session-scope":Ue??"","data-session-archived":d?"1":"0","aria-current":qe?"page":void 0,onClick:Mm,style:{paddingLeft:_e?Br+4:Jc+r*So},className:Ie("group relative my-0.5 flex cursor-pointer items-center rounded-md pr-2.5",_e&&!lt?"py-1.5":"py-1",_e&&!(qe||Ke)&&"hover:bg-interactive-hover/60",(qe||Ke)&&"bg-interactive-selection/70 text-interactive-selection-foreground",Ke&&"ring-1 ring-inset ring-border")}),children:[_e?null:jm,_e?null:Cm,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button","aria-pressed":De?Ke:void 0,onPointerDown:Bm,onPointerUp:cl,onPointerCancel:cl,onMouseDown:Om,onClick:Ae=>ll(Ae),onDoubleClick:Ae=>{Ae.stopPropagation(),T(R.id,bs)},className:Ie("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]",le&&"bg-interactive-hover/70",_e?void 0:k?fe?Q:$:Ee?J:Q),children:_e?Wm:s.jsxs("div",{className:"flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden",children:[s.jsx("div",{className:Ie("block min-w-0 flex-1 truncate typography-ui-label font-normal",qe||Ke?"text-interactive-selection-foreground":zs?"text-foreground":"text-foreground/80"),children:_r(bs,g)}),!d&&Ye&&I==="recent"?s.jsx(qr,{directory:Ye,className:k?void 0:Ee?"mr-1":fe?"group-hover:mr-1":"group-hover:mr-1 group-has-[:focus-visible]:mr-1"}):null,bi(Ie(fi,k?"ml-2":"ml-1")),k?s.jsx("span",{className:Ie("inline-flex flex-shrink-0 items-center gap-1 typography-micro text-muted-foreground/75",!ss&&"ml-2"),children:no?s.jsx(yi,{sessionId:R.id,running:dt}):s.jsxs(s.Fragment,{children:[Gs,Dt?s.jsx(B,{name:"git-branch",className:Ie("h-3 w-3",!xt&&"text-muted-foreground/60"),style:xt?{color:xt}:void 0}):null,nn]})}):no||Gs||Dt||I==="recent"?s.jsx("div",{className:Ie("relative flex h-4 flex-shrink-0 items-center justify-end",!ss&&"ml-1",Ee?"hidden":fe?"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:no?s.jsx(yi,{sessionId:R.id,running:dt,className:"typography-micro"}):s.jsxs(s.Fragment,{children:[Gs,Dt?s.jsx(B,{name:"git-branch",className:Ie("h-3 w-3",!xt&&"text-muted-foreground/60"),style:xt?{color:xt}:void 0}):null,I==="recent"?s.jsx("span",{className:"flex-shrink-0 typography-micro leading-none text-muted-foreground/75 tabular-nums",children:nn}):null]})})}):null,Qs>0?s.jsxs("span",{className:Ie("inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",fi),title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(B,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qs})]}):null,xs>0?s.jsxs("span",{className:Ie("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",fi),title:so,"aria-label":so,children:[s.jsx(B,{name:"question",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:xs})]}):null]})})}),!fe&&!_e?s.jsx(jt,{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:bs}),s.jsx("span",{className:"flex-shrink-0 text-muted-foreground",title:tr,children:nn})]}),ot&&!_e?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(B,{name:"folder",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:ot})]}):null,ut?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-muted-foreground",children:[s.jsx(B,{name:"git-branch",className:"h-3 w-3 flex-shrink-0",style:xt?{color:xt}:void 0}),s.jsx("span",{className:"min-w-0 truncate",children:ut})]}):null,mt&&be?s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(B,{name:"git-pull-request",className:"h-3 w-3 flex-shrink-0",style:xt?{color:xt}:void 0}),s.jsxs("span",{className:"min-w-0 truncate",style:xt?{color:xt}:void 0,children:["#",mt.number," · ",be]})]}):null,ul?s.jsx("p",{className:"min-w-0 line-clamp-4 text-muted-foreground",children:ul}):null]})}):null]})}),mi&&!W&&!_e?s.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 z-10",children:mi}):null,s.jsxs("div",{className:Ie("absolute right-1 z-10 flex items-center gap-0.5 transition-opacity",_e&&!lt?"top-1.5 h-5":"top-1/2 -translate-y-1/2",Ee||k&&!fe?"opacity-100":Ie("opacity-0",oe)),children:[xe?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",gi,It?"text-status-success":"text-muted-foreground hover:text-foreground"),"aria-label":yn,onPointerDown:hi,onMouseDown:pi,onClick:Lm,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(B,{name:It?"check":"eye",className:It?_m:ro})})}),s.jsx(jt,{side:"left",sideOffset:8,children:yn})]}):null,Y?s.jsx(Sk,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:gi,iconSizeClass:ro,onPointerDown:hi,onMouseDown:pi,onArchive:Dm,onDelete:Im}):null,he?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity",gi),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:Tm,onMouseDown:Em,onClick:Rm,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(B,{name:"external-link",className:ro})})}),s.jsx(jt,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(ks,{open:sr,onOpenChange:eo,onOpenChangeComplete:re,children:[s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("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",k?"h-6 w-6 opacity-100":Ee?"h-4 w-4 opacity-100":Ie("h-4 w-4 opacity-0",oe)),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:Am,onMouseDown:Pm,onClick:Nm,onKeyDown:Ae=>Ae.stopPropagation(),children:s.jsx(B,{name:"more-2",className:ro})})}),Km]})]})]}),Vm]})}),wn&&$s?se:null,s.jsx(Cs,{open:Tt,onOpenChange:Bt,children:s.jsxs(Ns,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ls,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(_s,{children:wt===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:wt}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:wt})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ce,onChange:Ae=>Me(Ae.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(Qn,{children:[s.jsx(ft,{type:"button",onClick:()=>Bt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{type:"button",onClick:()=>{Bt(!1),$t(Ce)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})})]},R.id)}const Zc=t=>gt(t.session.directory??null),kk=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),Ck=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},ed=t=>t.menuOpenSessionId??Ck(t),jo=(t,e,n)=>e?n.has(t.node.session.id)?!0:wr(t.node,e):!1,va=(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(va(t.children[l],e.children[l],n,r,i))return!0;return!1},Nk=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return va(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${t.renderContext??"project"}:${n}:${i.session.id}`)||va(t.node,e.node,t.expandedParents,e.expandedParents,i=>`${e.renderContext??"project"}:${r}:${i.session.id}`)},Ak=(t,e)=>t.id===e.id&&t.title===e.title&&t.directory===e.directory&&t.parentID===e.parentID&&t.time?.created===e.time?.created&&t.time?.updated===e.time?.updated&&t.time?.archived===e.time?.archived&&t.time?.idle===e.time?.idle&&t.metadata===e.metadata&&Uu(t,e),Pk=(t,e)=>{if(t.node.session.id!==e.node.session.id||!Ak(t.node.session,e.node.session)||!wk(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(Zc(t.node)!==Zc(e.node))return"nodeDirectory";if(!kk(t.secondaryMeta,e.secondaryMeta))return"secondaryMeta";if(t.pinnedSessionIds!==e.pinnedSessionIds&&qf(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,t.groupDirectory,e.groupDirectory))return"pinnedSessionIds";if(t.expandedParents!==e.expandedParents&&Nk(t,e))return"expandedParents";if(t.editingId!==e.editingId&&(jo(t,t.editingId,t.subtreeContainsEditing)||jo(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&&(jo(t,t.editingId,t.subtreeContainsEditing)||jo(e,e.editingId,e.subtreeContainsEditing)))return"editTitle";if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const r=ed(t),i=ed(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"},Dk=(t,e)=>{const n=Pk(t,e);return n===null?!0:(ws(`ui.sidebar_session_node.props_changed.${n}`),!1)},Ik=c.memo(jk,Dk);function Tk(t){return t.stopPropagation()}const Ek=t=>{const{t:e}=At(),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=ye(v=>v.setSessionSwitcherOpen),a=rt(v=>v.setCurrentSession),d=rt(v=>v.updateSessionTitle),u=rt(v=>v.deleteSession),m=rt(v=>v.deleteSessions),f=rt(v=>v.archiveSession),g=rt(v=>v.archiveSessions),x=rt(v=>v.unarchiveSession),{mobileVariant:b,allowReselect:j,onSessionSelected:y,resetSessionSearch:h,descendantIds:p,showDeletionDialog:w,setDeleteSessionConfirm:S,setEditingId:N,setEditingRowKey:P,editingSessionId:C,editingOccurrenceKey:T,setEditTitle:O}=t;c.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const M=c.useCallback((v,I)=>{if(_i("navigation.session_select"),ye.getState().closeMainSurfaces(),b&&l(!1),v===rt.getState().currentSessionId){j&&y?.(v),h();return}_i("navigation.session_state_set"),a(v,I??null),y?.(v),h()},[j,b,y,h,a,l]),F=c.useCallback((v,I)=>{N(v),P(T),O(I)},[T,O,N,P]),K=c.useCallback(async v=>{if(!r.current)return;const H=(v??i.current).trim();if(H)try{await d(C,H)}catch(_){console.error("[session-actions] rename failed",_),Fe.error(e("sessions.sidebar.session.rename.error",{detail:eu(_ instanceof Error?_:new Error(String(_)),e)}))}N(null),P(null),O("")},[C,O,N,P,e,d]),D=c.useCallback(()=>{N(null),P(null),O("")},[O,N,P]),U=c.useCallback(v=>{Gn(v).then(I=>{if(I.ok){Fe.success(e("sessions.sidebar.session.copyId.success"));return}Fe.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Fe.error(e("sessions.sidebar.session.copyId.error")))},[e]),A=c.useCallback(async(v,I,H)=>{const _=I?.archivedBucket===!0||I?.hardDelete===!0,se=H?.descendantIds??p;await Qh(_?"delete":"archive",v,se,{archiveSession:f,archiveSessions:g,deleteSession:u,deleteSessions:m},e)},[f,g,u,m,p,e]),E=c.useCallback((v,I)=>{const H=I?.archivedBucket===!0||I?.hardDelete===!0,_=Hd(v.id,p,H);if(!w||I?.skipConfirm===!0){A(v,I,{descendantIds:_});return}S({session:v,descendantCount:_.length,descendantIds:_,archivedBucket:H})},[p,A,S,w]),W=c.useCallback(async()=>{const v=o.current;if(!v)return;const{session:I,archivedBucket:H,descendantIds:_}=v;S(null),await A(I,{archivedBucket:H},{descendantIds:_})},[A,S]),k=c.useCallback(async v=>{await x(v.id)?Fe.success(e("sessions.sidebar.session.restore.success")):Fe.error(e("sessions.sidebar.session.restore.error"))},[e,x]);return c.useMemo(()=>({handleSessionSelect:M,handleSessionDoubleClick:F,handleSaveEdit:K,handleCancelEdit:D,handleCopySessionId:U,handleDeleteSession:E,handleRestoreSession:k,confirmDeleteSession:W}),[D,U,E,k,K,F,M,W])};function Rk(t){const e=nt.c(71),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t;let d,u,m,f,g,x,b,j,y,h;if(e[0]!==i||e[1]!==n||e[2]!==r){const v=n("sessions.sidebar.session.untitled");f=Cs,y=!!r,e[13]!==i?(h=H=>{H||i(null)},e[13]=i,e[14]=h):h=e[14],m=Ns,b=!1,j="max-w-sm gap-5",u=Hs;let I;e[15]!==n||e[16]!==r?.archivedBucket?(I=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=I):I=e[17],e[18]!==I?(x=s.jsx(Ls,{children:I}),e[18]=I,e[19]=x):x=e[19],d=_s,g=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||v,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||v,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||v,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||v,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||v}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||v}),e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=g,e[8]=x,e[9]=b,e[10]=j,e[11]=y,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],g=e[7],x=e[8],b=e[9],j=e[10],y=e[11],h=e[12];let p;e[20]!==d||e[21]!==g?(p=s.jsx(d,{children:g}),e[20]=d,e[21]=g,e[22]=p):p=e[22];let w;e[23]!==u||e[24]!==x||e[25]!==p?(w=s.jsxs(u,{children:[x,p]}),e[23]=u,e[24]=x,e[25]=p,e[26]=w):w=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 N=!o;let P;e[30]!==o?(P=o?s.jsx(B,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(B,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=o,e[31]=P):P=e[31];let C;e[32]!==n?(C=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=C):C=e[33];let T;e[34]!==P||e[35]!==C||e[36]!==S||e[37]!==N?(T=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":N,children:[P,C]}),e[34]=P,e[35]=C,e[36]=S,e[37]=N,e[38]=T):T=e[38];let O;e[39]!==i?(O=()=>i(null),e[39]=i,e[40]=O):O=e[40];let M;e[41]!==n?(M=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=M):M=e[42];let F;e[43]!==O||e[44]!==M?(F=s.jsx("button",{type:"button",onClick:O,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:M}),e[43]=O,e[44]=M,e[45]=F):F=e[45];let K;e[46]!==a?(K=()=>{a()},e[46]=a,e[47]=K):K=e[47];let D;e[48]!==n||e[49]!==r?.archivedBucket?(D=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=D):D=e[50];let U;e[51]!==K||e[52]!==D?(U=s.jsx("button",{type:"button",onClick:K,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:D}),e[51]=K,e[52]=D,e[53]=U):U=e[53];let A;e[54]!==F||e[55]!==U?(A=s.jsxs("div",{className:"flex items-center gap-2",children:[F,U]}),e[54]=F,e[55]=U,e[56]=A):A=e[56];let E;e[57]!==T||e[58]!==A?(E=s.jsxs(Qn,{className:"w-full sm:items-center sm:justify-between",children:[T,A]}),e[57]=T,e[58]=A,e[59]=E):E=e[59];let W;e[60]!==m||e[61]!==b||e[62]!==E||e[63]!==j||e[64]!==w?(W=s.jsxs(m,{showCloseButton:b,className:j,children:[w,E]}),e[60]=m,e[61]=b,e[62]=E,e[63]=j,e[64]=w,e[65]=W):W=e[65];let k;return e[66]!==f||e[67]!==W||e[68]!==y||e[69]!==h?(k=s.jsx(f,{open:y,onOpenChange:h,children:W}),e[66]=f,e[67]=W,e[68]=y,e[69]=h,e[70]=k):k=e[70],k}function Mk(t){const e=nt.c(57),{t:n}=At(),{value:r,setValue:i,showDeletionDialog:o,setShowDeletionDialog:l,onConfirm:a}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=m):m=e[3];const f=m;let g;e[4]!==d||e[5]!==u||e[6]!==n?(g=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]=g):g=e[7];const x=g,b=!!r;let j;e[8]!==i?(j=k=>{k||i(null)},e[8]=i,e[9]=j):j=e[9];let y;e[10]!==f?(y=s.jsx(Ls,{children:f}),e[10]=f,e[11]=y):y=e[11];let h;e[12]!==x?(h=s.jsx(_s,{children:x}),e[12]=x,e[13]=h):h=e[13];let p;e[14]!==y||e[15]!==h?(p=s.jsxs(Hs,{children:[y,h]}),e[14]=y,e[15]=h,e[16]=p):p=e[16];let w;e[17]!==l||e[18]!==o?(w=()=>l(!o),e[17]=l,e[18]=o,e[19]=w):w=e[19];const S=!o;let N;e[20]!==o?(N=o?s.jsx(B,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(B,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=o,e[21]=N):N=e[21];let P;e[22]!==n?(P=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=P):P=e[23];let C;e[24]!==P||e[25]!==w||e[26]!==S||e[27]!==N?(C=s.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","aria-pressed":S,children:[N,P]}),e[24]=P,e[25]=w,e[26]=S,e[27]=N,e[28]=C):C=e[28];let T;e[29]!==i?(T=()=>i(null),e[29]=i,e[30]=T):T=e[30];let O;e[31]!==n?(O=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=O):O=e[32];let M;e[33]!==T||e[34]!==O?(M=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:O}),e[33]=T,e[34]=O,e[35]=M):M=e[35];let F;e[36]!==a?(F=()=>{a()},e[36]=a,e[37]=F):F=e[37];let K;e[38]!==d||e[39]!==n?(K=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=K):K=e[40];let D;e[41]!==F||e[42]!==K?(D=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:K}),e[41]=F,e[42]=K,e[43]=D):D=e[43];let U;e[44]!==M||e[45]!==D?(U=s.jsxs("div",{className:"flex items-center gap-2",children:[M,D]}),e[44]=M,e[45]=D,e[46]=U):U=e[46];let A;e[47]!==C||e[48]!==U?(A=s.jsxs(Qn,{className:"w-full sm:items-center sm:justify-between",children:[C,U]}),e[47]=C,e[48]=U,e[49]=A):A=e[49];let E;e[50]!==A||e[51]!==p?(E=s.jsxs(Ns,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,A]}),e[50]=A,e[51]=p,e[52]=E):E=e[52];let W;return e[53]!==b||e[54]!==E||e[55]!==j?(W=s.jsx(Cs,{open:b,onOpenChange:j,children:E}),e[53]=b,e[54]=E,e[55]=j,e[56]=W):W=e[56],W}function om(t){const e=nt.c(36),{t:n}=At(),{value:r,setValue:i,onConfirm:o}=t,l=!!r;let a;e[0]!==i?(a=N=>{N||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(Ls,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(_s,{children:m}),e[9]=m,e[10]=f):f=e[10];let g;e[11]!==u||e[12]!==f?(g=s.jsxs(Hs,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=g):g=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 j;e[18]!==x||e[19]!==b?(j=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]=j):j=e[20];let y;e[21]!==n?(y=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=y):y=e[22];let h;e[23]!==o||e[24]!==y?(h=s.jsx("button",{type:"button",onClick:o,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:y}),e[23]=o,e[24]=y,e[25]=h):h=e[25];let p;e[26]!==h||e[27]!==j?(p=s.jsxs(Qn,{children:[j,h]}),e[26]=h,e[27]=j,e[28]=p):p=e[28];let w;e[29]!==p||e[30]!==g?(w=s.jsxs(Ns,{showCloseButton:!1,className:"max-w-sm gap-5",children:[g,p]}),e[29]=p,e[30]=g,e[31]=w):w=e[31];let S;return e[32]!==l||e[33]!==a||e[34]!==w?(S=s.jsx(Cs,{open:l,onOpenChange:a,children:w}),e[32]=l,e[33]=a,e[34]=w,e[35]=S):S=e[35],S}const Ok=new Set;function Bk(t){const e=nt.c(113),{node:n,depth:r,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:d,secondaryMeta:u,renderContext:m,rowKey:f,dragKey:g,renderExtras:x,pinnedSessionIds:b,expandedParents:j,hasSessionSearchQuery:y,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,toggleParent:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:A,setDeleteSessionConfirm:E,startFolderRename:W,startSessionWorktreeMenuLoad:k,onEditProject:v,mobileVariant:I,alwaysShowActions:H,renderChildren:_}=t,se=r===void 0?0:r,te=d===void 0?!1:d,ee=m===void 0?"project":m,ue=_===void 0?!0:_;ws("ui.sidebar_tree_item.render");const de=f??`${ee}:${te?"archived":"active"}:${n.session.id}`,Re=Gt($k),we=Gt(_k),fe=ye(Lk),Pe=ye(Fk);let L;if(e[0]!==n){L=[];const Oe=Ve=>Ve.children.forEach(ze=>{L.push(ze.session.id),Oe(ze)});Oe(n),e[0]=n,e[1]=L}else L=e[1];const oe=L.join(`
881
+ `);let ce;e[2]!==oe?(ce=oe?oe.split(`
882
+ `):[],e[2]=oe,e[3]=ce):ce=e[3];const he=ce;let Y;e[4]!==Re||e[5]!==W||e[6]!==we?(Y=(Oe,Ve)=>{if(!Oe)return null;Ve&&Gt.getState().collapsedFolderIds.has(Ve)&&we(Ve);const ze=Re(Oe,"New folder",Ve);return W(Oe,ze),ze},e[4]=Re,e[5]=W,e[6]=we,e[7]=Y):Y=e[7];const ve=Y;let Te;e[8]!==K||e[9]!==A||e[10]!==he||e[11]!==C||e[12]!==w||e[13]!==de||e[14]!==I||e[15]!==n.session.id||e[16]!==D||e[17]!==U||e[18]!==E||e[19]!==T||e[20]!==N||e[21]!==P||e[22]!==fe?(Te={mobileVariant:I,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,descendantIds:he,showDeletionDialog:fe,setDeleteSessionConfirm:E,deleteSessionConfirm:A,editingId:w,setEditingId:N,setEditingRowKey:P,editingSessionId:n.session.id,editingOccurrenceKey:de,editTitle:C,setEditTitle:T},e[8]=K,e[9]=A,e[10]=he,e[11]=C,e[12]=w,e[13]=de,e[14]=I,e[15]=n.session.id,e[16]=D,e[17]=U,e[18]=E,e[19]=T,e[20]=N,e[21]=P,e[22]=fe,e[23]=Te):Te=e[23];const ke=Ek(Te),xe=x?.childRenderExtrasFor,ge=n.session.directory??i;let Q;e[24]!==te||e[25]!==o||e[26]!==ee||e[27]!==ge?(Q={groupDirectory:ge,projectId:o,archivedBucket:te,renderContext:ee},e[24]=te,e[25]=o,e[26]=ee,e[27]=ge,e[28]=Q):Q=e[28];const $=Q,J=g??f??n.session.id,me=x?.subtreeContainsEditing??Ok,le=x?.menuOpenSessionId??null,V=x?.nodeStructureKey??"",Z=x?.relativeTimeTick;let G;e[29]!==K||e[30]!==H||e[31]!==$||e[32]!==xe||e[33]!==A||e[34]!==se||e[35]!==C||e[36]!==w||e[37]!==S||e[38]!==j||e[39]!==l||e[40]!==y||e[41]!==I||e[42]!==n.children||e[43]!==h||e[44]!==p||e[45]!==D||e[46]!==M||e[47]!==b||e[48]!==ue||e[49]!==U||e[50]!==a||e[51]!==E||e[52]!==T||e[53]!==N||e[54]!==P||e[55]!==F||e[56]!==W||e[57]!==k||e[58]!==O?(G=ue?n.children.map(Oe=>s.jsx(Go,{node:Oe,pinnedSessionIds:b,expandedParents:j,hasSessionSearchQuery:y,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,toggleParent:O,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,allowReselect:K,onSessionSelected:D,resetSessionSearch:U,deleteSessionConfirm:A,setDeleteSessionConfirm:E,startFolderRename:W,startSessionWorktreeMenuLoad:k,mobileVariant:I,alwaysShowActions:H,depth:se+1,folderOwnerKey:l,selectionScopeKey:a,...$,renderExtras:xe?.(Oe)},Oe.session.id)):null,e[29]=K,e[30]=H,e[31]=$,e[32]=xe,e[33]=A,e[34]=se,e[35]=C,e[36]=w,e[37]=S,e[38]=j,e[39]=l,e[40]=y,e[41]=I,e[42]=n.children,e[43]=h,e[44]=p,e[45]=D,e[46]=M,e[47]=b,e[48]=ue,e[49]=U,e[50]=a,e[51]=E,e[52]=T,e[53]=N,e[54]=P,e[55]=F,e[56]=W,e[57]=k,e[58]=O,e[59]=G):G=e[59];let ie;e[60]!==H||e[61]!==te||e[62]!==ve||e[63]!==se||e[64]!==C||e[65]!==w||e[66]!==S||e[67]!==de||e[68]!==j||e[69]!==l||e[70]!==i||e[71]!==y||e[72]!==I||e[73]!==n||e[74]!==h||e[75]!==p||e[76]!==v||e[77]!==M||e[78]!==b||e[79]!==o||e[80]!==ee||e[81]!==u||e[82]!==a||e[83]!==ke.handleCancelEdit||e[84]!==ke.handleCopySessionId||e[85]!==ke.handleDeleteSession||e[86]!==ke.handleRestoreSession||e[87]!==ke.handleSaveEdit||e[88]!==ke.handleSessionDoubleClick||e[89]!==ke.handleSessionSelect||e[90]!==T||e[91]!==N||e[92]!==P||e[93]!==F||e[94]!==k||e[95]!==J||e[96]!==me||e[97]!==le||e[98]!==V||e[99]!==Z||e[100]!==G||e[101]!==O?(ie=s.jsx(Ik,{expandedParents:j,hasSessionSearchQuery:y,normalizedSessionSearchQuery:h,notifyOnSubtasks:p,editingId:w,editingRowKey:S,setEditingId:N,setEditingRowKey:P,editTitle:C,setEditTitle:T,handleSaveEdit:ke.handleSaveEdit,handleCancelEdit:ke.handleCancelEdit,toggleParent:O,handleSessionSelect:ke.handleSessionSelect,handleSessionDoubleClick:ke.handleSessionDoubleClick,handleCopySessionId:ke.handleCopySessionId,openSidebarMenuKey:M,setOpenSidebarMenuKey:F,createFolderAndStartRename:ve,handleDeleteSession:ke.handleDeleteSession,handleRestoreSession:ke.handleRestoreSession,startSessionWorktreeMenuLoad:k,onEditProject:v,mobileVariant:I,alwaysShowActions:H,pinnedSessionIds:b,node:n,depth:se,groupDirectory:i,projectId:o,folderOwnerKey:l,selectionScopeKey:a,archivedBucket:te,secondaryMeta:u,renderContext:ee,rowKey:de,dragKey:J,subtreeContainsEditing:me,menuOpenSessionId:le,nodeStructureKey:V,relativeTimeTick:Z,children:G}),e[60]=H,e[61]=te,e[62]=ve,e[63]=se,e[64]=C,e[65]=w,e[66]=S,e[67]=de,e[68]=j,e[69]=l,e[70]=i,e[71]=y,e[72]=I,e[73]=n,e[74]=h,e[75]=p,e[76]=v,e[77]=M,e[78]=b,e[79]=o,e[80]=ee,e[81]=u,e[82]=a,e[83]=ke.handleCancelEdit,e[84]=ke.handleCopySessionId,e[85]=ke.handleDeleteSession,e[86]=ke.handleRestoreSession,e[87]=ke.handleSaveEdit,e[88]=ke.handleSessionDoubleClick,e[89]=ke.handleSessionSelect,e[90]=T,e[91]=N,e[92]=P,e[93]=F,e[94]=k,e[95]=J,e[96]=me,e[97]=le,e[98]=V,e[99]=Z,e[100]=G,e[101]=O,e[102]=ie):ie=e[102];let je;e[103]!==A||e[104]!==n.session.id||e[105]!==ke.confirmDeleteSession||e[106]!==E||e[107]!==Pe||e[108]!==fe?(je=A?.session.id===n.session.id?s.jsx(Rk,{value:A,setValue:E,showDeletionDialog:fe,setShowDeletionDialog:Pe,onConfirm:ke.confirmDeleteSession}):null,e[103]=A,e[104]=n.session.id,e[105]=ke.confirmDeleteSession,e[106]=E,e[107]=Pe,e[108]=fe,e[109]=je):je=e[109];let ne;return e[110]!==ie||e[111]!==je?(ne=s.jsxs(s.Fragment,{children:[ie,je]}),e[110]=ie,e[111]=je,e[112]=ne):ne=e[112],ne}function Fk(t){return t.setShowDeletionDialog}function Lk(t){return t.showDeletionDialog}function _k(t){return t.toggleFolderCollapse}function $k(t){return t.createFolder}const zk=(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&&Uu(t.session,e.session)&&gt(t.worktree?.path??null)===gt(e.worktree?.path??null)&&t.worktree?.branch===e.worktree?.branch&&t.children.length===e.children.length,Wk=(t,e)=>{if(t.node!==e.node&&!zk(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},Go=c.memo(Bk,Wk),Sa=6,Kk=Sa+14+6,Vk=4;function td(t){const e=nt.c(7),{providerIDs:n,ringClass:r}=t;let i;if(e[0]!==n||e[1]!==r){let l;e[3]!==r?(l=a=>s.jsx("span",{className:Ie("inline-flex h-4 w-4 items-center justify-center rounded-full bg-sidebar ring-1",r),children:s.jsx(Fu,{providerId:a,className:"h-3 w-3"})},a),e[3]=r,e[4]=l):l=e[4],i=n.slice(0,Vk).map(l),e[0]=n,e[1]=r,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=s.jsx("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:i}),e[5]=i,e[6]=o):o=e[6],o}function Uk(t){const e=nt.c(91),{run:n,laneNodes:r,renderContext:i,projectId:o,projectLabel:l,expansionKey:a,expanded:d,forceExpanded:u,notifyOnSubtasks:m,toggleParent:f}=t,{t:g}=At();let x;e[0]!==n.key?(x=oe=>oe.runOverviewKey===n.key,e[0]=n.key,e[1]=x):x=e[1];const b=ye(x),j=i==="timeline";let y;e[2]!==j||e[3]!==o?(y=oe=>j&&o?oe.projects.find(ce=>ce.id===o)??null:null,e[2]=j,e[3]=o,e[4]=y):y=e[4];const h=Kt(y),p=n.lanes.length;let w;e[5]!==p||e[6]!==g?(w=p===1?g("sessions.sidebar.run.laneCountSingle",{count:p}):g("sessions.sidebar.run.laneCountPlural",{count:p}),e[5]=p,e[6]=g,e[7]=w):w=e[7];const S=w;let N;e[8]!==r?(N=[...r],e[8]=r,e[9]=N):N=e[9];const P=N;let C;e[10]!==P||e[11]!==m?(C=s.jsx(tu,{nodes:P,includeUnreadSubtasks:m}),e[10]=P,e[11]=m,e[12]=C):C=e[12];const T=C,O=b?"text-interactive-selection-foreground":"text-foreground/80";let M;e[13]!==n.key?(M=()=>ye.getState().setRunOverviewKey(n.key),e[13]=n.key,e[14]=M):M=e[14];const F=M;if(j){const oe=n.key,ce=b?"page":void 0;let he;e[15]!==n.title||e[16]!==g?(he=g("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[15]=n.title,e[16]=g,e[17]=he):he=e[17];let Y;e[18]===Symbol.for("react.memo_cache_sentinel")?(Y={paddingLeft:Sa+4},e[18]=Y):Y=e[18];const ve=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let Te;e[19]!==ve?(Te=Ie("group relative my-0.5 flex w-full cursor-pointer items-center rounded-md py-1.5 pr-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",ve),e[19]=ve,e[20]=Te):Te=e[20];const ke=n.title;let xe;e[21]===Symbol.for("react.memo_cache_sentinel")?(xe=s.jsx(Qi,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground/40","aria-hidden":"true"}),e[21]=xe):xe=e[21];let ge;e[22]!==S?(ge=s.jsxs(s.Fragment,{children:[xe,s.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/50",children:S})]}),e[22]=S,e[23]=ge):ge=e[23];let Q;e[24]!==n.lastActivity?(Q=Vu(n.lastActivity),e[24]=n.lastActivity,e[25]=Q):Q=e[25];let $;e[26]!==n.providerIDs?($=s.jsx(td,{providerIDs:n.providerIDs,ringClass:"ring-sidebar opacity-60"}),e[26]=n.providerIDs,e[27]=$):$=e[27];let J;e[28]!==T||e[29]!==l||e[30]!==n.title||e[31]!==ge||e[32]!==Q||e[33]!==$||e[34]!==h||e[35]!==O?(J=s.jsx(xa,{project:h,projectLabel:l,title:ke,titleClassName:O,branchLabel:null,thirdLineLead:ge,statusDot:T,pinnedMarker:null,timeSlot:Q,directoryIndicator:null,prBadge:null,zombieIndicator:null,badges:$,hideMetaOnHoverClass:""}),e[28]=T,e[29]=l,e[30]=n.title,e[31]=ge,e[32]=Q,e[33]=$,e[34]=h,e[35]=O,e[36]=J):J=e[36];let me;return e[37]!==F||e[38]!==n.key||e[39]!==Te||e[40]!==J||e[41]!==ce||e[42]!==he?(me=s.jsx("button",{type:"button","data-run-row":oe,"aria-current":ce,"aria-label":he,onClick:F,style:Y,className:Te,children:J}),e[37]=F,e[38]=n.key,e[39]=Te,e[40]=J,e[41]=ce,e[42]=he,e[43]=me):me=e[43],me}let K;e[44]!==a||e[45]!==u||e[46]!==f?(K=oe=>{oe.stopPropagation(),u||f(a)},e[44]=a,e[45]=u,e[46]=f,e[47]=K):K=e[47];const D=K,U=n.key,A=b?"page":void 0;let E;e[48]===Symbol.for("react.memo_cache_sentinel")?(E={paddingLeft:Kk},e[48]=E):E=e[48];const W=b?"bg-interactive-selection/70 text-interactive-selection-foreground":"hover:bg-interactive-hover/60";let k;e[49]!==W?(k=Ie("group relative my-0.5 flex cursor-pointer items-center rounded-md py-1 pr-2.5",W),e[49]=W,e[50]=k):k=e[50];let v;e[51]!==D?(v=oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),D(oe))},e[51]=D,e[52]=v):v=e[52];let I;e[53]===Symbol.for("react.memo_cache_sentinel")?(I={left:Sa},e[53]=I):I=e[53];let H;e[54]!==d||e[55]!==g?(H=g(d?"sessions.sidebar.run.collapse":"sessions.sidebar.run.expand"),e[54]=d,e[55]=g,e[56]=H):H=e[56];const _=d?"arrow-down-s":"arrow-right-s";let se;e[57]!==_?(se=s.jsx(B,{name:_,className:"h-3 w-3"}),e[57]=_,e[58]=se):se=e[58];let te;e[59]!==d||e[60]!==v||e[61]!==H||e[62]!==se||e[63]!==D?(te=s.jsx("button",{type:"button",onClick:D,onKeyDown:v,style:I,className:"absolute top-1/2 inline-flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":d,"aria-label":H,children:se}),e[59]=d,e[60]=v,e[61]=H,e[62]=se,e[63]=D,e[64]=te):te=e[64];let ee;e[65]!==F?(ee=oe=>{oe.stopPropagation(),F()},e[65]=F,e[66]=ee):ee=e[66];let ue;e[67]!==n.title||e[68]!==g?(ue=g("sessions.sidebar.run.openOverviewAria",{title:n.title}),e[67]=n.title,e[68]=g,e[69]=ue):ue=e[69];let de;e[70]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(Qi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[70]=de):de=e[70];let Re;e[71]!==O?(Re=Ie("block min-w-0 flex-1 truncate typography-ui-label font-normal",O),e[71]=O,e[72]=Re):Re=e[72];let we;e[73]!==n.title||e[74]!==Re?(we=s.jsx("span",{className:Re,children:n.title}),e[73]=n.title,e[74]=Re,e[75]=we):we=e[75];let fe;e[76]!==n.providerIDs?(fe=s.jsx(td,{providerIDs:n.providerIDs,ringClass:"ring-sidebar"}),e[76]=n.providerIDs,e[77]=fe):fe=e[77];let Pe;e[78]!==T||e[79]!==ee||e[80]!==ue||e[81]!==we||e[82]!==fe?(Pe=s.jsxs("button",{type:"button",onClick:ee,className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":ue,children:[de,we,fe,T]}),e[78]=T,e[79]=ee,e[80]=ue,e[81]=we,e[82]=fe,e[83]=Pe):Pe=e[83];let L;return e[84]!==F||e[85]!==n.key||e[86]!==k||e[87]!==te||e[88]!==Pe||e[89]!==A?(L=s.jsxs("div",{"data-run-row":U,"aria-current":A,onClick:F,style:E,className:k,children:[te,Pe]}),e[84]=F,e[85]=n.key,e[86]=k,e[87]=te,e[88]=Pe,e[89]=A,e[90]=L):L=e[90],L}const Hk=c.memo(Uk),Gk=24,qk=t=>Array.from({length:Math.min(t,Gk)},(e,n)=>n),Yk=(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)},Qk=(t,e)=>t.find(n=>n.end>e)?.index??0;function sd(t,e){return e?.kind==="activity-header"||e?.kind==="project-header"||e?.kind==="group-header"&&t.kind!=="project-header"?"pb-2":void 0}function Xk({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=>Yk(Kx(y),n,o.length),[n,o.length]),m=Wx({count:o.length,enabled:e!==null,getScrollElement:l,estimateSize:a,getItemKey:d,overscan:8,rangeExtractor:u}),f=m.getVirtualItems(),g=e?m.getTotalSize():0,x=e?Math.max(g-e.clientHeight,0):0,b=e?Math.min(e.scrollTop,x):0,j=Qk(f,b);if(c.useLayoutEffect(()=>{i(j)},[j,i]),!e){const y=qk(o.length),h=y.reduce((w,S)=>w+(o[S]?.estimateSize??0),0),p=o.reduce((w,S)=>w+S.estimateSize,0);return s.jsxs("div",{"data-sidebar-virtual-pending":"true",children:[y.map(w=>{const S=o[w];return S?s.jsx("div",{className:sd(S,o[w+1]),children:r(S,w)},S.key):null}),p>h?s.jsx("div",{"aria-hidden":"true",style:{height:p-h}}):null]})}return s.jsx("div",{"data-sidebar-virtual-ready":"true",style:{height:g,position:"relative"},children:f.map(y=>{const h=o[y.index];return h?s.jsx("div",{className:`[&_[data-session-row]]:my-px ${sd(h,o[y.index+1])??""}`,"data-index":y.index,"data-sidebar-virtual-start":y.start,ref:m.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${y.start}px)`},children:r(h,y.index)},h.key):null})})}const Jk={work:"eye",chats:"chat-4","active-now":"history",timeline:"folder"},nd={work:"sessions.sidebar.work.title",chats:"sessions.sidebar.activity.chatsTitle","active-now":"sessions.sidebar.activity.recentTitle",timeline:"sessions.sidebar.activity.timelineTitle"},Zk=t=>{const e=nt.c(48),{activityKey:n,collapsed:r,forceExpanded:i,alwaysShowActions:o,onToggle:l,onNewChat:a,timelineView:d}=t,u=d===void 0?!1:d,{t:m}=At(),f=n==="chats";if(u){const K=i?void 0:l;let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=Ie("group flex w-full items-center gap-1 py-2 pl-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","pr-3.5"),e[0]=D):D=e[0];const U=!r,A=nd[n];let E;e[1]!==m||e[2]!==A?(E=m(A),e[1]=m,e[2]=A,e[3]=E):E=e[3];let W;e[4]!==E?(W=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:E}),e[4]=E,e[5]=W):W=e[5];let k;e[6]!==r||e[7]!==i?(k=i?null:s.jsx(B,{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]=k):k=e[8];let v;return e[9]!==i||e[10]!==K||e[11]!==U||e[12]!==W||e[13]!==k?(v=s.jsx("div",{className:"relative group/chats -mr-2",children:s.jsxs("button",{type:"button",onClick:K,disabled:i,className:D,"aria-expanded":U,children:[W,k]})}),e[9]=i,e[10]=K,e[11]=U,e[12]=W,e[13]=k,e[14]=v):v=e[14],v}const g=i?void 0:l,x=f?"pr-10":"pr-3.5";let b;e[15]!==x?(b=Ie("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 j=!r,y=Jk[n],h=!i&&"group-hover:hidden";let p;e[17]!==h?(p=Ie("h-3.5 w-3.5 text-muted-foreground/80",h),e[17]=h,e[18]=p):p=e[18];let w;e[19]!==y||e[20]!==p?(w=s.jsx(B,{name:y,className:p}),e[19]=y,e[20]=p,e[21]=w):w=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(B,{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 N;e[25]!==S||e[26]!==w?(N=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[w,S]}),e[25]=S,e[26]=w,e[27]=N):N=e[27];const P=nd[n];let C;e[28]!==m||e[29]!==P?(C=m(P),e[28]=m,e[29]=P,e[30]=C):C=e[30];let T;e[31]!==C?(T=s.jsx("span",{className:"typography-ui-label font-semibold lowercase text-foreground",children:C}),e[31]=C,e[32]=T):T=e[32];let O;e[33]!==i||e[34]!==N||e[35]!==T||e[36]!==g||e[37]!==b||e[38]!==j?(O=s.jsxs("button",{type:"button",onClick:g,disabled:i,className:b,"aria-expanded":j,children:[N,T]}),e[33]=i,e[34]=N,e[35]=T,e[36]=g,e[37]=b,e[38]=j,e[39]=O):O=e[39];let M;e[40]!==o||e[41]!==f||e[42]!==a||e[43]!==m?(M=f?s.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),a()},className:Ie("absolute right-0.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o?"opacity-100":"opacity-0 pointer-events-none group-hover/chats:opacity-100 group-hover/chats:pointer-events-auto group-focus-within/chats:opacity-100 group-focus-within/chats:pointer-events-auto"),"aria-label":m("sessions.sidebar.header.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-4 w-4"})}):null,e[40]=o,e[41]=f,e[42]=a,e[43]=m,e[44]=M):M=e[44];let F;return e[45]!==O||e[46]!==M?(F=s.jsxs("div",{className:"relative group/chats -ml-2.5 -mr-2",children:[O,M]}),e[45]=O,e[46]=M,e[47]=F):F=e[47],F},im=c.createContext(null);function rd(t){let e=0,n=t;for(;n;){e+=n.offsetTop;const o=n.offsetParent;n=o instanceof HTMLElement?o:null}const r=t.closest("[data-sidebar-virtual-start]"),i=Number(r?.dataset.sidebarVirtualStart??"0");return e+(Number.isFinite(i)?i:0)}function e3(t){const e=nt.c(14),{enabled:n,suspended:r,layoutKey:i,scrollRef:o,children:l}=t,a=r===void 0?!1:r,d=i===void 0?"":i;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[0]=u):u=e[0];const m=c.useRef(u),f=c.useRef(null);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=p=>(m.current.add(p),f.current?.(),()=>{m.current.delete(p),f.current?.()}),e[1]=g):g=e[1];const x=g;let b;e[2]!==n||e[3]!==o||e[4]!==a?(b=()=>{const p=o.current;if(!n||a||!p)return;const w=document.createElement("div");w.dataset.sidebarCrossfadeLayer="true",w.className="pointer-events-none sticky top-0 z-30 h-0",w.style.marginBlock="0px",p.prepend(w);let S=null,N=null,P=null,C=0;const T=new Set;let O=[];const M=window.matchMedia("(prefers-reduced-motion: reduce)"),F=s3,K=()=>{P?.cancel(),P=null,N?.remove(),N=null},D=()=>{let k=null,v=-1/0;for(const{entry:I,top:H}of O)H<=p.scrollTop&&H>=v&&(v=H,k=I);if(S!==k){if(K(),S&&k&&!M.matches){const I=S.host.cloneNode(!0);I instanceof HTMLElement&&(I.inert=!0,I.setAttribute("aria-hidden","true"),I.querySelectorAll("[id]").forEach(t3),I.className="pointer-events-none absolute inset-x-0 top-0 z-30",N=I)}S&&(F(S,S.slot),S.slot.style.removeProperty("height")),S=k,w.hidden=!k,k&&(k.slot.style.height=`${k.host.getBoundingClientRect().height}px`,F(k,w),N&&(w.append(N),P=N.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}),P.onfinish=K))}},U=()=>{S&&(S.slot.style.height=`${S.host.getBoundingClientRect().height}px`);const k=rd(p)+p.clientTop;O=Array.from(m.current,v=>({entry:v,top:rd(v.slot)-k})),D()},A=new ResizeObserver(U),E=new MutationObserver(()=>{cancelAnimationFrame(C),C=requestAnimationFrame(U)});A.observe(p);const W=()=>{E.disconnect();for(const k of T)m.current.has(k)||(A.unobserve(k.host),k.slot.parentElement&&A.unobserve(k.slot.parentElement),T.delete(k));for(const k of m.current){const v=k.slot.closest("[data-sidebar-virtual-start]");v&&E.observe(v,{attributes:!0,attributeFilter:["data-sidebar-virtual-start"]}),T.has(k)||(A.observe(k.host),k.slot.parentElement&&A.observe(k.slot.parentElement),T.add(k))}cancelAnimationFrame(C),C=requestAnimationFrame(U)};return f.current=W,p.addEventListener("scroll",D,{passive:!0}),W(),U(),()=>{f.current=null,cancelAnimationFrame(C),p.removeEventListener("scroll",D),A.disconnect(),E.disconnect(),K(),w.hidden=!0,S&&(F(S,S.slot),S.slot.style.removeProperty("height")),w.remove()}},e[2]=n,e[3]=o,e[4]=a,e[5]=b):b=e[5];let j;e[6]!==n||e[7]!==d||e[8]!==o||e[9]!==a?(j=[n,a,d,o],e[6]=n,e[7]=d,e[8]=o,e[9]=a,e[10]=j):j=e[10],c.useLayoutEffect(b,j);const y=n?x:null;let h;return e[11]!==l||e[12]!==y?(h=s.jsx(im.Provider,{value:y,children:l}),e[11]=l,e[12]=y,e[13]=h):h=e[13],h}function t3(t){return t.removeAttribute("id")}function s3(t,e){const n=document.activeElement,r=n instanceof HTMLElement&&t.host.contains(n);e.moveBefore&&e.isConnected&&t.host.isConnected?e.moveBefore(t.host,null):e.append(t.host),r&&n.focus({preventScroll:!0})}function n3(t){const e=nt.c(15);let n,r;e[0]!==t?({register:r,...n}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const i=c.useRef(null),[o]=c.useState(r3);let l,a;e[3]!==o||e[4]!==r?(l=()=>{const g=i.current;if(!g)return;g.append(o);const x=r({slot:g,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 m;e[10]!==o||e[11]!==u?(m=Um.createPortal(u,o),e[10]=o,e[11]=u,e[12]=m):m=e[12];let f;return e[13]!==m?(f=s.jsxs(s.Fragment,{children:[d,m]}),e[13]=m,e[14]=f):f=e[14],f}function r3(){const t=document.createElement("div");return t.className="pointer-events-auto flow-root",t}function am(t){const e=nt.c(3),n=c.useContext(im);let r;return e[0]!==t||e[1]!==n?(r=n?s.jsx(n3,{...t,register:n}):s.jsx("div",{...t}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const o3=t=>{const e=nt.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=()=>{mr.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},Oi=t=>{const e=nt.c(22),{id:n,projectLabel:r,projectIcon:i,projectColor:o,projectIconImage:l,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,m=u===void 0?!1:u,{currentTheme:f}=qn(),g=i?Wa[i]:null,x=o?Ka[o]??null:null,b=d!==void 0,j=b?m?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let y;e[0]!==m||e[1]!==b||e[2]!==d?(y=b?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center text-muted-foreground",m?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(B,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=m,e[1]=b,e[2]=d,e[3]=y):y=e[3];let h;e[4]!==m||e[5]!==f||e[6]!==b||e[7]!==x||e[8]!==j||e[9]!==n||e[10]!==a||e[11]!==l||e[12]!==g?(h=l?s.jsx("span",{className:Ie("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",b&&m?"hidden":"inline-flex",j),style:a?{backgroundColor:a}:void 0,children:s.jsx(Va,{project:{id:n,iconImage:l},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(B,{name:g,className:"h-3.5 w-3.5",style:x?{color:x}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:x?{color:x}:void 0})})}):g?s.jsx(B,{name:g,className:Ie("h-3.5 w-3.5",j),style:x?{color:x}:void 0}):s.jsx(B,{name:"folder",className:Ie("h-3.5 w-3.5 text-muted-foreground/80",j),style:x?{color:x}:void 0}),e[4]=m,e[5]=f,e[6]=b,e[7]=x,e[8]=j,e[9]=n,e[10]=a,e[11]=l,e[12]=g,e[13]=h):h=e[13];let p;e[14]!==y||e[15]!==h?(p=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[y,h]}),e[14]=y,e[15]=h,e[16]=p):p=e[16];let w;e[17]!==r?(w=s.jsx("span",{className:"truncate typography-ui-label font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=w):w=e[18];let S;return e[19]!==p||e[20]!==w?(S=s.jsxs(s.Fragment,{children:[p,w]}),e[19]=p,e[20]=w,e[21]=S):S=e[21],S},i3=t=>{const e=nt.c(61),{id:n,disabled:r,projectLabel:i,projectDescription:o,projectDirectory:l,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,isRepo:g,hideDirectoryControls:x,alwaysShowActions:b,onToggle:j,onNewSession:y,onNewWorktreeSession:h,onManageWorktrees:p,onRenameStart:w,onClose:S,children:N,showCreateButtons:P,hideHeader:C,statusIndicator:T,openSidebarMenuKey:O,setOpenSidebarMenuKey:M,projectPickerOptions:F,onProjectSelect:K}=t,D=r===void 0?!1:r,U=P===void 0?!0:P,A=C===void 0?!1:C,E=T===void 0?null:T,{t:W}=At(),k=o3(l);let v;e[0]!==D||e[1]!==n?(v={id:n,disabled:D},e[0]=D,e[1]=n,e[2]=v):v=e[2];const{attributes:I,listeners:H,setNodeRef:_,transform:se,transition:te,isDragging:ee}=oi(v),ue=c.useRef(!1),de=`project:${n}`,Re=O===de,[we,fe]=c.useState(!1),Pe=!!(F&&K);let L;e[3]!==de||e[4]!==M?(L=G=>{G&&fe(!1),M(G?de:null)},e[3]=de,e[4]=M,e[5]=L):L=e[5];const oe=L;let ce;e[6]!==x||e[7]!==g||e[8]!==S||e[9]!==p||e[10]!==y||e[11]!==w||e[12]!==U||e[13]!==W?(ce=G=>s.jsxs(s.Fragment,{children:[U&&!g&&!x&&y&&s.jsxs(G,{onClick:y,children:[s.jsx(B,{name:"add",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.newSession")]}),g&&!x&&p&&s.jsxs(G,{onClick:p,children:[s.jsx(B,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(G,{onClick:w,children:[s.jsx(B,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.edit")]}),s.jsxs(G,{onClick:S,className:"text-destructive focus:text-destructive",children:[s.jsx(B,{name:"close",className:"mr-1.5 h-4 w-4"}),W("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=x,e[7]=g,e[8]=S,e[9]=p,e[10]=y,e[11]=w,e[12]=U,e[13]=W,e[14]=ce):ce=e[14];const he=ce,Y=c3,ve=d3,Te=u3;let ke;e[15]===Symbol.for("react.memo_cache_sentinel")?(ke=G=>{(G.button===2||G.button===0&&G.ctrlKey)&&(ue.current=!0)},e[15]=ke):ke=e[15];const xe=ke;let ge;e[16]!==j?(ge=G=>{if(G.currentTarget.blur(),ue.current){ue.current=!1;return}j()},e[16]=j,e[17]=ge):ge=e[17];const Q=ge;let $;e[18]!==se?($=ii.Transform.toString(se),e[18]=se,e[19]=$):$=e[19];let J;e[20]!==$||e[21]!==te?(J={transform:$,transition:te},e[20]=$,e[21]=te,e[22]=J):J=e[22];const me=ee&&"opacity-30";let le;e[23]!==me?(le=Ie("relative",me),e[23]=me,e[24]=le):le=e[24];let V;e[25]!==b||e[26]!==I||e[27]!==k||e[28]!==oe||e[29]!==Q||e[30]!==x||e[31]!==A||e[32]!==n||e[33]!==f||e[34]!==we||e[35]!==Re||e[36]!==Pe||e[37]!==g||e[38]!==H||e[39]!==y||e[40]!==h||e[41]!==K||e[42]!==d||e[43]!==o||e[44]!==l||e[45]!==a||e[46]!==m||e[47]!==u||e[48]!==i||e[49]!==F||e[50]!==he||e[51]!==U||e[52]!==E||e[53]!==W?(V=A?null:s.jsx(s.Fragment,{children:s.jsxs(Xd,{open:we,onOpenChange:fe,children:[s.jsx(Qd,{render:s.jsx(am,{className:Ie("-ml-2.5 -mr-2 text-left group/project select-none","sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":"true",onContextMenu:G=>{x||(G.preventDefault(),fe(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...I,children:[Pe?s.jsxs(ks,{children:[s.jsx(Ss,{asChild:!0,children:s.jsxs("button",{type:"button",className:Ie("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]",g&&!x?b||Re?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Re?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),"aria-label":W("sessions.sidebar.project.selectAria",{project:i}),children:[s.jsx(Oi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m}),s.jsx(B,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),l?s.jsx(qr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(js,{align:"start",className:"max-h-[70vh] min-w-[220px] overflow-y-auto",children:F?.map(G=>s.jsxs(zt,{onClick:()=>K?.(G.id),className:"flex items-center justify-between gap-3",title:G.projectDescription,children:[s.jsx("span",{className:"flex min-w-0 items-center gap-1.5",children:s.jsx(Oi,{...G})}),G.id===n?s.jsx(B,{name:"check",className:"h-4 w-4 flex-shrink-0 text-primary"}):null]},G.id))})]}):s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:xe,onClick:Q,...H,className:Ie("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]",g&&!x?b||Re?"pr-20":"pr-0 group-hover/project:pr-20 group-focus-within/project:pr-20":b||Re?"pr-14":"pr-0 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(Oi,{id:n,projectLabel:i,projectIcon:a,projectColor:d,projectIconImage:u,projectIconBackground:m,isCollapsed:f,alwaysShowActions:b}),k?s.jsx("span",{className:"inline-flex flex-shrink-0 items-center text-status-warning",title:W("sessions.sidebar.project.folderMissing"),"aria-label":W("sessions.sidebar.project.folderMissing"),children:s.jsx(B,{name:"alert",className:"h-3 w-3"})}):null,E?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:E}):null,l?s.jsx(qr,{directory:l,className:"ml-auto"}):null]})}),s.jsx(jt,{side:"right",sideOffset:8,children:o})]}),s.jsxs("div",{className:Ie("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",U?"right-7":"right-0.5"),children:[U&&g&&!x&&h?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),h()},className:Ie("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":W("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(B,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,x?null:s.jsxs(ks,{open:Re,onOpenChange:oe,children:[s.jsx(Ss,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie("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",Re?"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":W("sessions.sidebar.project.actions.projectMenu"),onPointerDown:ve,onMouseDown:Te,onClick:Y,children:s.jsx(B,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(js,{align:"end",className:"min-w-[180px]",children:he(zt)})]})]}),U&&y?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),y()},className:Ie("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":W(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(B,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W(g?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(Yd,{className:"min-w-[180px]",children:he(Ln)})]})}),e[25]=b,e[26]=I,e[27]=k,e[28]=oe,e[29]=Q,e[30]=x,e[31]=A,e[32]=n,e[33]=f,e[34]=we,e[35]=Re,e[36]=Pe,e[37]=g,e[38]=H,e[39]=y,e[40]=h,e[41]=K,e[42]=d,e[43]=o,e[44]=l,e[45]=a,e[46]=m,e[47]=u,e[48]=i,e[49]=F,e[50]=he,e[51]=U,e[52]=E,e[53]=W,e[54]=V):V=e[54];let Z;return e[55]!==N||e[56]!==_||e[57]!==J||e[58]!==le||e[59]!==V?(Z=s.jsxs("div",{ref:_,style:J,className:le,children:[V,N]}),e[55]=N,e[56]=_,e[57]=J,e[58]=le,e[59]=V,e[60]=Z):Z=e[60],Z},a3=t=>{const e=nt.c(21),{id:n,disabled:r,children:i}=t,o=r===void 0?!1:r;let l;e[0]!==o||e[1]!==n?(l={id:n,disabled:o},e[0]=o,e[1]=n,e[2]=l):l=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:m,transition:f,isDragging:g}=oi(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 j;e[6]!==m?(j=ii.Transform.toString(m),e[6]=m,e[7]=j):j=e[7];let y;e[8]!==j||e[9]!==f?(y={transform:j,transition:f},e[8]=j,e[9]=f,e[10]=y):y=e[10];const h=g&&"opacity-50";let p;e[11]!==h?(p=Ie("space-y-0.5 rounded-md",h),e[11]=h,e[12]=p):p=e[12];let w;e[13]!==i||e[14]!==b?(w=i(b),e[13]=i,e[14]=b,e[15]=w):w=e[15];let S;return e[16]!==d||e[17]!==y||e[18]!==p||e[19]!==w?(S=s.jsx("div",{ref:d,style:y,className:p,children:w}),e[16]=d,e[17]=y,e[18]=p,e[19]=w,e[20]=S):S=e[20],S},l3=c.memo(a3);function c3(t){t.stopPropagation()}function d3(t){t.stopPropagation()}function u3(t){t.stopPropagation()}const od=[],f3=t=>{const e=nt.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=Zd(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},Bi=(t,e)=>e?t.sessions.some(n=>wr(n,e)):!1,m3=(t,e,n)=>t.sessions.some(r=>qf(r,r,e,n,t.directory,t.directory)),h3=(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)},p3=(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)},g3=(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&&m3(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.sessionOrderIndex!==e.sessionOrderIndex&&h3(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.expandedParents!==e.expandedParents&&p3(e.group,t.expandedParents,e.expandedParents)||t.editingId!==e.editingId&&(Bi(e.group,t.editingId)||Bi(e.group,e.editingId))||t.editingRowKey!==e.editingRowKey||t.editTitle!==e.editTitle&&Bi(e.group,e.editingId))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=e.group.isArchivedBucket===!0,r=Uo(e.group.sessions,t.openSidebarMenuKey,"project",n),i=Uo(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??gt(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 b3(t){const{t:e}=At(),{group:n,groupKey:r,projectId:i,hideGroupLabel:o,renderBody:l=!0,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,groupSearchDataByGroup:u,visibleSessionCount:m,sessionBatchSize:f,collapsedGroups:g,hideDirectoryControls:x,showMoreGroupSessions:b,resetGroupSessionLimit:j,mobileVariant:y,alwaysShowActions:h,activeProjectId:p,setActiveProjectIdOnly:w,setSessionSwitcherOpen:S,openNewSessionDraft:N,pinnedSessionIds:P,sessionOrderIndex:C,notifyOnSubtasks:T,onToggleCollapsedGroup:O,dragHandleProps:M,compactBodyPadding:F=!1,expandedParents:K,editingId:D,editingRowKey:U,openSidebarMenuKey:A,editTitle:E,folderRename:W,setFolderRenameDraft:k,clearFolderRename:v}=t,I=Gt(Se=>Se.toggleFolderCollapse),H=Gt(Se=>Se.renameFolder),_=Gt(Se=>Se.deleteFolder),se=Gt(Se=>Se.addSessionToFolder),te=ye(Se=>Se.showDeletionDialog),[ee,ue]=c.useState(null),de=c.useCallback((Se,Je)=>{const it=C.get(Se.session.id),pt=C.get(Je.session.id);if(it!==void 0||pt!==void 0){if(it===void 0)return 1;if(pt===void 0)return-1;if(it!==pt)return it-pt}return za(Se.session,Je.session,P,La)},[P,C]),Re=a?u.get(n):null,we=a?!1:g.has(r),fe=c.useMemo(()=>{if(n.isMain||n.isArchivedBucket||o)return null;const Se=gt(n.directory??null),Je=n.branch?.trim();return Se&&Je?Qo(Se,Je):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,o]),Pe=_u(fe),L=Pe?`var(--pr-${Pe.visualState})`:void 0,oe=Jo(),ce=c.useMemo(()=>{const Se=n.folderScopes?.map(Je=>gt(Je.directory))??[gt(n.directory??null)];return[...new Set(Se.filter(Je=>!!Je))]},[n.directory,n.folderScopes]);c.useSyncExternalStore(c.useCallback(Se=>ce.length>0?oe.subscribeBootstrap(Se):()=>{},[ce.length,oe]),c.useCallback(()=>ce.map(Se=>`${Se}\0${oe.getBootstrapState(Se)??""}\0${oe.getBootstrapFailure(Se)??""}\0${oe.getInitializationState(Se)??""}\0${oe.getInitializationFailure(Se)??""}`).join(""),[ce,oe]),c.useCallback(()=>"",[]));const he=ce.some(Se=>{const Je=oe.getBootstrapState(Se);return Je==="queued"||Je==="running"}),Y=ce.find(Se=>oe.getBootstrapState(Se)==="failed"||oe.getInitializationState(Se)==="failed")??null,ve=Y!==null&&oe.getBootstrapState(Y)==="failed",Te=Y?ve?oe.getBootstrapFailure(Y):oe.getInitializationFailure(Y):void 0,ke=Te==="os-permission"&&Vd(),[xe,ge]=c.useState(!1),Q=c.useCallback(()=>{Y&&oe.requestBootstrap({directory:Y,priority:we?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[oe,Y,n.isMain,we]),$=c.useCallback(async()=>{if(!(!Y||!ke||xe)){ge(!0);try{(await Ud(Y)).success&&Q()}finally{ge(!1)}}},[ke,Y,xe,Q]),J=f??(x?10:5),me=Math.max(J,m??J),le=a?Re?.groupMatches===!0:!1,V=a,Z=c.useMemo(()=>[...V?Re?.filteredNodes??[]:n.sessions].sort(de),[de,n.sessions,Re?.filteredNodes,V]),G=n.folderScopeKey??gt(n.directory??null),ie=Cn(i,n.directory),je=c.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:G?[{scopeKey:G,directory:n.directory??null}]:[],[G,n.directory,n.folderScopes]),ne=Gt(Un(c.useCallback(Se=>je.map(({scopeKey:Je})=>Se.foldersMap[Je]??od),[je]))),Oe=c.useMemo(()=>je.flatMap(({scopeKey:Se,directory:Je},it)=>(ne[it]??od).map(kt=>({folder:kt,scopeKey:Se,scopeDirectory:Je}))),[ne,je]),Ve=Gt(Un(c.useCallback(Se=>new Set(ne.flatMap(Je=>Je.filter(it=>Se.collapsedFolderIds.has(it.id)).map(it=>it.id))),[ne]))),ze=c.useMemo(()=>{const Se=new Map,Je=it=>{it.forEach(pt=>{Se.set(pt.session.id,pt),pt.children.length>0&&Je(pt.children)})};return Je(Z),Se},[Z]),He=c.useMemo(()=>Oe.map(({folder:Se,scopeKey:Je,scopeDirectory:it})=>{const pt=ba(Se.sessionIds,ze).sort(de);return{folder:Se,scopeKey:Je,scopeDirectory:it,nodes:pt}}),[Oe,ze,de]),$e=c.useMemo(()=>{const Se=Gf(He.map(({folder:Je,nodes:it})=>({id:Je.id,name:Je.name,parentId:Je.parentId,nodeCount:it.length})),{archivedBucket:n.isArchivedBucket===!0,searchQuery:a?d:""});return He.filter(({folder:Je})=>Se.has(Je.id))},[He,n.isArchivedBucket,a,d]),R=D,pe=A,Le=c.useMemo(()=>new Set($e.flatMap(Se=>Se.folder.sessionIds)),[$e]),_e=c.useMemo(()=>Z.filter(Se=>!Le.has(Se.session.id)),[Z,Le]),lt=c.useMemo(()=>{const Se=new Map($e.map(Je=>[Je.folder.id,Je]));return Hf($e.map(Je=>Je.folder)).map(Je=>Se.get(Je.id)).filter(Je=>!!Je)},[$e]),ht=c.useMemo(()=>{const Se=new Map;return $e.forEach(Je=>{if(!Je.folder.parentId)return;const it=Se.get(Je.folder.parentId)??[];it.push(Je),Se.set(Je.folder.parentId,it)}),Se},[$e]),ot=c.useMemo(()=>{const Se=new Map($e.map(pt=>[pt.folder.id,pt])),Je=new Map,it=(pt,kt)=>{const _t=Je.get(pt);if(_t!==void 0)return _t;if(kt.has(pt))return[];kt.add(pt);const qt=Se.get(pt),Mt=qt?[...qt.nodes]:[];for(const Lt of ht.get(pt)??[])Mt.push(...it(Lt.folder.id,kt));return Je.set(pt,Mt),Mt};return $e.forEach(({folder:pt})=>it(pt.id,new Set)),Je},[$e,ht]),ut="project",yt=c.useMemo(()=>{const Se=new Set;return $c(Z,R,Se),$e.forEach(({nodes:Je})=>{$c(Je,R,Se)}),Se},[Z,$e,R]),mt=c.useMemo(()=>{if(!pe)return null;const Se=Uo(Z,pe,ut,!!n.isArchivedBucket);if(Se)return Se;for(const{nodes:Je}of $e){const it=Uo(Je,pe,ut,!!n.isArchivedBucket);if(it)return it}return null},[pe,Z,$e,n.isArchivedBucket]),xt=c.useCallback(Se=>{const Je=new WeakMap,it=pt=>{Je.set(pt,Vo(pt));for(const kt of pt.children)it(kt)};return Se.forEach(it),Je},[]),Dt=c.useMemo(()=>xt(Z),[xt,Z]),be=c.useMemo(()=>{const Se=new WeakMap;return $e.forEach(({nodes:Je})=>{Je.forEach(it=>Se.set(it,Vo(it)))}),Se},[$e]),qe=c.useCallback(Se=>Dt.get(Se)??be.get(Se)??"",[Dt,be]),Ye=c.useCallback(Se=>({subtreeContainsEditing:yt,menuOpenSessionId:mt,nodeStructureKey:qe(Se)}),[yt,mt,qe]),Ue=_e.length,ct=n.isArchivedBucket||a?_e:_e.slice(0,me),X=Ue-ct.length,ae=!n.isArchivedBucket&&!a&&Ue>J&&X===0,De=c.useCallback(Se=>{const Je=[],it=pt=>{pt.forEach(kt=>{Je.push(kt.session),kt.children.length>0&&it(kt.children)})};return it(Se),Je},[]),Ke=c.useMemo(()=>De(Z),[De,Z]),q=c.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Se=new Map,Je=new Map;for(const{folder:pt}of $e){if(!pt.parentId)continue;const kt=Je.get(pt.parentId)??[];kt.push(pt.id),Je.set(pt.parentId,kt)}const it=(pt,kt)=>{if(kt.has(pt))return[];kt.add(pt);const _t=$e.find(({folder:Lt})=>Lt.id===pt),qt=_t?De(_t.nodes):[],Mt=Je.get(pt)??[];for(const Lt of Mt)qt.push(...it(Lt,kt));return qt};for(const{folder:pt}of $e)Se.set(pt.id,it(pt.id,new Set));return Se},[$e,De,n.isArchivedBucket]);if(a&&!le&&lt.length===0&&_e.length===0)return null;const Be=!n.isMain&&!!n.branch,Ze=n.branch&&db(n.branch,n.label)?{label:n.branch}:null,Qe=we?s.jsx(tu,{nodes:Z,includeUnreadSubtasks:T}):null,et=(Se,Je)=>{const{folder:it,scopeKey:pt,scopeDirectory:kt,nodes:_t}=Se,qt=q.get(it.id)??[],Mt=W?.folderId===it.id&&W?.scopeKey===pt,Lt=a?!1:Ve.has(it.id),Wt=Jt=>s.jsx(Xf,{folderId:it.id,scopeKey:pt,ownerKey:ie,children:(Zt,Ft)=>s.jsx(Qf,{folder:it,displayName:Je,sessions:_t,isCollapsed:Lt,collapsedActivityState:Jt,onToggle:()=>I(it.id),onRename:Ot=>{H(pt,it.id,Ot)},onDelete:()=>{if(n.isArchivedBucket){Us.requestDelete({sessions:qt,mode:"session"});return}if(!te){_(pt,it.id);return}const Ot=$e.filter(({folder:ss})=>ss.parentId===it.id).length,It=_t.length;ue({scopeKey:pt,folderId:it.id,folderName:it.name,subFolderCount:Ot,sessionCount:It})},groupDirectory:kt??n.directory,projectId:i,mobileVariant:y,alwaysShowActions:h,isRenaming:Mt,renameDraft:Mt?W?.draft:void 0,onRenameDraftChange:k,onRenameSave:()=>{const Ot=W?.draft.trim()??"";Ot&&H(pt,it.id,Ot),v()},onRenameCancel:v,droppableRef:Zt,isDropTarget:Ft,depth:0,onNewSession:()=>{i&&i!==p&&w(i),y&&S(!1),N({selectedProjectId:i,directoryOverride:kt??n.directory,targetFolderId:it.id,target:n.draftTarget})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0,children:_t.map(Ot=>s.jsx(Go,{node:Ot,pinnedSessionIds:P,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:T,editingId:D,editingRowKey:U,editTitle:E,openSidebarMenuKey:A,mobileVariant:y,alwaysShowActions:h,groupDirectory:kt??n.directory,projectId:i,folderOwnerKey:ie,selectionScopeKey:ie,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:yt,menuOpenSessionId:mt,nodeStructureKey:qe(Ot),childRenderExtrasFor:Ye},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))})},it.id);return Lt?s.jsx(f3,{nodes:ot.get(it.id)??_t,includeUnreadSubtasks:T,children:Wt},it.id):Wt(null)},Ct=()=>{const Se=new Map;for(const kt of $e){const _t=kt.folder.parentId;if(!_t)continue;const qt=Se.get(_t);qt?qt.push(kt):Se.set(_t,[kt])}const Je=[],it=new Set,pt=(kt,_t)=>{if(it.has(kt.folder.id))return;it.add(kt.folder.id);const qt=_t?`${_t} / ${kt.folder.name}`:kt.folder.name;Je.push(et(kt,qt)),!(!a&&Ve.has(kt.folder.id))&&(Se.get(kt.folder.id)??[]).forEach(Lt=>pt(Lt,qt))};return lt.forEach(kt=>pt(kt,"")),Je},Ge=!!(!n.isMain&&n.worktree),Tt=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(B,{name:"alert",className:"h-3 w-3"})}):null,Bt=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(B,{name:"alert",className:"h-3 w-3"})}):null,Ce=Ge||!!n.space,Me=!!n.space,st=h?Me?"pr-20":Ce?"pr-14":"pr-7":Me?"pr-2 group-hover/gh:pr-20 group-focus-within/gh:pr-20":Ce?"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",Xe=Y?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Te==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":ve?"sessions.sidebar.group.empty.loadFailed":"sessions.sidebar.group.empty.initializationFailed"),ke?s.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:xe,onClick:()=>{$()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:Q,children:e("sessions.sidebar.group.empty.retry")})]}):null,Ne=Se=>s.jsx(Go,{node:Se,pinnedSessionIds:P,expandedParents:K,hasSessionSearchQuery:a,normalizedSessionSearchQuery:d,notifyOnSubtasks:T,editingId:D,editingRowKey:U,editTitle:E,openSidebarMenuKey:A,mobileVariant:y,alwaysShowActions:h,groupDirectory:n.directory,projectId:i,folderOwnerKey:ie,selectionScopeKey:ie,archivedBucket:n.isArchivedBucket===!0,renderExtras:{subtreeContainsEditing:yt,menuOpenSessionId:mt,nodeStructureKey:qe(Se),childRenderExtrasFor:Ye},setEditingId:t.setEditingId,setEditingRowKey:t.setEditingRowKey,setEditTitle:t.setEditTitle,toggleParent:t.toggleParent,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,allowReselect:t.allowReselect,onSessionSelected:t.onSessionSelected,resetSessionSearch:t.resetSessionSearch,deleteSessionConfirm:t.deleteSessionConfirm,setDeleteSessionConfirm:t.setDeleteSessionConfirm,startFolderRename:t.startFolderRename,startSessionWorktreeMenuLoad:t.startSessionWorktreeMenuLoad},Se.session.id),We=s.jsxs(sk,{scopeKey:je[0]?.scopeKey??G,ownerKey:ie,hasFolders:$e.length>0,onSessionDroppedOnFolder:(Se,Je)=>{const it=$e.find(({folder:kt,scopeKey:_t})=>kt.id===Je.folderId&&_t===Je.scopeKey);if(!it)return;const pt=Gt.getState();for(const{scopeKey:kt}of je)kt!==it.scopeKey&&pt.getSessionFolderId(kt,Se)&&pt.removeSessionFromFolder(kt,Se);se(it.scopeKey,Je.folderId,Se)},children:[Ct(),ct.map(Ne),Ue===0&&$e.length===0?!n.isArchivedBucket&&!he&&!Xe&&n.directory&&!n.emptyMessage?s.jsx(ft,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{i&&i!==p&&w(i),y&&S(!1),N({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"):he?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):Xe||(n.emptyMessage??e("sessions.sidebar.group.empty.noSessionsInWorkspace"))}):null,Ue>0&&Xe?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:Xe}):null,X>0?s.jsx("button",{type:"button",onClick:()=>b(r,ct.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,ae?s.jsx("button",{type:"button",onClick:()=>j(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]}),dt="pb-2",bt=s.jsx(om,{value:ee,setValue:ue,onConfirm:()=>{const Se=ee;Se&&(_(Se.scopeKey,Se.folderId),ue(null))}});return o?l?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:Ie("oc-group-body",dt),children:We})}),bt]}):null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:Ie("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>O(r),role:"button",tabIndex:0,onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),O(r))},"aria-label":we?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!we,children:[s.jsxs("div",{ref:M?.setActivatorNodeRef,className:Ie("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",st),...M?.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(B,{name:"archive",className:Ie("h-3.5 w-3.5 shrink-0 text-muted-foreground",h?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:Ie("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:we?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(B,{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)}),Tt,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(B,{name:n.space?"box-3":"git-branch",className:Ie("h-3.5 w-3.5 shrink-0",!L&&"text-muted-foreground",h?"hidden":"group-hover/gh:hidden"),style:L?{color:L}:void 0,"aria-label":n.space?e("sessions.sidebar.group.space"):void 0}),s.jsx("span",{className:Ie("text-muted-foreground h-3.5 w-3.5 items-center justify-center",h?"inline-flex":"hidden group-hover/gh:inline-flex"),children:we?s.jsx(B,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(B,{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)}),Tt,Bt,Qe,Pe?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:L?{color:L}:void 0,children:["#",Pe.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]})}),Be&&Ze?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(B,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(B,{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:Ze.label})]}):null]}),!n.isArchivedBucket&&n.directory?s.jsx(qr,{directory:n.directory,className:"self-center"}):null]}),n.isArchivedBucket&&Ke.length>0?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),Us.requestDelete({sessions:Ke,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(B,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{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:Ie("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),Us.requestDelete({sessions:Ke,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(B,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.space?s.jsx("div",{className:Ie("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),n.space&&ch.getState().openAccessDialog(n.space.id)},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("spaces.group.access.giveAria",{label:n.label}),children:s.jsx(B,{name:"key",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("spaces.group.access.give")})})]})}):null,n.space?s.jsx("div",{className:Ie("absolute right-[3.25rem] top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 has-[[data-popup-open]]:opacity-100"),children:s.jsx(Xh,{spaceId:n.space.id,label:n.label})}):null,n.directory?s.jsx("div",{className:Ie("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",h?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Se=>{Se.stopPropagation(),i&&i!==p&&w(i),y&&S(!1),N({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(B,{name:"add",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),n.space?s.jsx(Jh,{spaceId:n.space.id,className:"pb-1 pl-5"}):null,!we&&l?s.jsx("div",{className:Ie("oc-group-body",dt),children:We}):null]}),bt]})}const x3=c.memo(b3,g3),ko=({projectId:t,mobileVariant:e,closeMobileSwitcher:n,setActiveProjectIdOnly:r,setSessionSwitcherOpen:i})=>{t&&r(t),e&&n&&i(!1)},id=(t,e)=>Lu(t.label?.trim()||yr(t.normalizedPath,e)||t.normalizedPath);function y3(t){const e=nt.c(104),{model:n,view:r,actions:i}=t;ws("ui.sidebar_projects_list.render");const{t:o}=At(),l=Jo(),a=Gt(I3),d=Gt(D3),u=Gt(P3),m=Gt(A3),f=ye(N3),[g,x]=c.useState(null),[b,j]=c.useState(null),[y,h]=c.useState(null),[p,w]=c.useState(null),[S,N]=c.useState(!1),P=c.useRef(null);let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C={activationConstraint:{distance:8}},e[0]=C):C=e[0];let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},e[1]=T):T=e[1];let O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O={coordinateGetter:Dx},e[2]=O):O=e[2];const M=ei(mn(si,C),mn(ti,T),mn(Ax,O));let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=$=>{P.current=$,w($)},e[3]=F):F=e[3];const K=F;let D;if(e[4]!==n.projectSections||e[5]!==r.homeDirectory){let $;e[7]!==r.homeDirectory?($=J=>({id:J.project.id,projectLabel:id(J.project,r.homeDirectory),projectDescription:Hr(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]=$):$=e[8],D=n.projectSections.map($),e[4]=n.projectSections,e[5]=r.homeDirectory,e[6]=D}else D=e[6];const U=D;let A;e:{if(!r.stickyZoneHeaders){A=-1;break e}let $;if(e[9]!==n.rowModel.stickyHeaders||e[10]!==b){let J;e[12]!==b?(J=me=>`${me.kind}:${me.id}`===b,e[12]=b,e[13]=J):J=e[13],$=n.rowModel.stickyHeaders.findIndex(J),e[9]=n.rowModel.stickyHeaders,e[10]=b,e[11]=$}else $=e[11];A=$}const E=A;let W;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]!==E){if(W=new Set,y){let $;e[22]!==y||e[23]!==n.rowModel.rowIndexByKey?($=n.rowModel.rowIndexByKey.get(y),e[22]=y,e[23]=n.rowModel.rowIndexByKey,e[24]=$):$=e[24];const J=$;J!==void 0&&W.add(J)}for(let $=0;$<n.rowModel.rows.length;$=$+1,$){const J=n.rowModel.rows[$];J?.kind==="session"&&(n.groupProps.editingRowKey===J.key||n.state.openSidebarMenuKey===`session-menu:${J.key}`||n.state.openSidebarMenuKey===`session-context:${J.key}`)&&W.add($)}if(E>=0){const $=Math.max(0,E-1),J=Math.min(n.rowModel.stickyHeaders.length-1,E+1);for(let me=$;me<=J;me=me+1,me){const le=n.rowModel.stickyHeaders[me];le&&W.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]=E,e[21]=W}else W=e[21];const k=W;let v;e[25]!==n.rowModel.stickyHeaders||e[26]!==r.stickyZoneHeaders?(v=$=>{const J=r.stickyZoneHeaders?T2(n.rowModel.stickyHeaders,$):null,me=J?`${J.kind}:${J.id}`:null;j(le=>le===me?le:me)},e[25]=n.rowModel.stickyHeaders,e[26]=r.stickyZoneHeaders,e[27]=v):v=e[27];const I=v;let H;e[28]!==l||e[29]!==o?(H=$=>{const J=()=>{if(!$.status.directory){Zo();return}l.requestBootstrap({directory:$.status.directory,priority:"expanded",reason:$.group.isMain?"project-expanded":"worktree-expanded",force:!0})},me=async()=>{if(!$.status.directory)return;(await Ud($.status.directory)).success&&J()};let le;e:switch($.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:[$.status.state==="loading"?s.jsx(B,{name:"loader-4",className:"size-3 animate-spin"}):null,le,$.status.canGrantAccess?s.jsx(ft,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:()=>{me()},children:o("sessions.sidebar.group.empty.grantAccess")}):null,$.status.state!=="loading"?s.jsx(ft,{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]=H):H=e[30];const _=H;let se;e[31]!==i||e[32]!==u||e[33]!==n.emptyState||e[34]!==n.groupProps||e[35]!==n.projectRepoStatus||e[36]!==n.searchEmptyState||e[37]!==n.singleProjectMode||e[38]!==n.state||e[39]!==U||e[40]!==d||e[41]!==_||e[42]!==f||e[43]!==o||e[44]!==a||e[45]!==r.alwaysShowActions||e[46]!==r.hideDirectoryControls||e[47]!==r.homeDirectory||e[48]!==r.mobileVariant||e[49]!==r.projectSortOrder||e[50]!==r.stickyZoneHeaders||e[51]!==r.timelineView||e[52]!==r.worktreeSortOrder?(se=$=>{if($.kind==="activity-header")return s.jsx(am,{className:r.stickyZoneHeaders?"sticky top-0 z-20 bg-sidebar":void 0,"data-sidebar-sticky-header":r.stickyZoneHeaders?"true":void 0,children:s.jsx(Zk,{activityKey:$.activityKey,collapsed:$.collapsed,forceExpanded:$.forceExpanded,alwaysShowActions:r.alwaysShowActions,timelineView:r.timelineView,onToggle:()=>{if(!$.collapsed){const J=`activity:${$.activityKey}`;i.group.resetGroupSessionLimit(J),n.state.setVisibleActivityCountByKey(me=>{if(!me.has(J))return me;const le=new Map(me);return le.delete(J),le})}n.state.setCollapsedActivityKeys(J=>{const me=new Set(J);return me.has($.activityKey)?me.delete($.activityKey):me.add($.activityKey),me})},onNewChat:()=>{ye.getState().closeMainSurfaces(),r.mobileVariant&&i.setSessionSwitcherOpen(!1),i.openNewSessionDraft({selectedProjectId:ub,directoryOverride:null})}})});if($.kind==="project-header"){const J=$.section.project,me=id(J,r.homeDirectory);return s.jsx(i3,{id:J.id,disabled:n.singleProjectMode||$.forceExpanded||n.state.editingId!==null||r.projectSortOrder!=="manual",projectLabel:me,projectDescription:Hr(J.normalizedPath,r.homeDirectory),projectDirectory:J.normalizedPath,projectIcon:J.icon,projectColor:J.color,projectIconImage:J.iconImage,projectIconBackground:J.iconBackground,isCollapsed:$.collapsed,isRepo:!!n.projectRepoStatus.get(J.id),hideDirectoryControls:r.hideDirectoryControls,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,statusIndicator:$.collapsed?i.renderProjectStatusIndicator?.(J.id,$.section.groups):null,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,projectPickerOptions:n.singleProjectMode?U:void 0,onProjectSelect:n.singleProjectMode?i.setSingleProjectId:void 0,onToggle:()=>{!$.forceExpanded&&!n.singleProjectMode&&i.toggleProject(J.id)},onNewSession:()=>{ko({projectId:J.id,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:J.id,directoryOverride:J.normalizedPath})},onNewWorktreeSession:()=>{ko({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($.kind==="group-header")return s.jsx(l3,{id:$.groupKey,disabled:$.forceExpanded||n.state.editingId!==null||r.worktreeSortOrder!=="manual",children:J=>s.jsx(x3,{...n.groupProps,...i.group,group:$.group,groupKey:$.groupKey,projectId:$.projectId,visibleSessionCount:n.state.visibleSessionCountByGroup.get($.groupKey),editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,dragHandleProps:J,renderBody:!1})});if($.kind==="folder-header"){const J=n.groupProps.folderRename?.folderId===$.folder.id&&n.groupProps.folderRename.scopeKey===$.scopeKey;return s.jsx(Xf,{folderId:$.folder.id,scopeKey:$.scopeKey,ownerKey:$.ownerKey,disabled:!$.dropEnabled,children:(me,le)=>s.jsx(ek,{notifyOnSubtasks:n.groupProps.notifyOnSubtasks,activityNodes:$.activityNodes,folder:$.folder,displayName:$.displayName,sessions:$.nodes,isCollapsed:$.collapsed,onToggle:$.forceExpanded?C3:()=>a($.folder.id),onRename:V=>d($.scopeKey,$.folder.id,V),onDelete:()=>{$.archived?Us.requestDelete({sessions:[...$.deleteSessions],mode:"session"}):f?x({scopeKey:$.scopeKey,folderId:$.folder.id,folderName:$.folder.name,subFolderCount:$.subFolderCount,sessionCount:$.nodes.length}):u($.scopeKey,$.folder.id)},renderBody:!1,groupDirectory:$.scopeDirectory??$.group.directory,projectId:$.projectId,mobileVariant:r.mobileVariant,alwaysShowActions:r.alwaysShowActions,isRenaming:J,renameDraft:J?n.groupProps.folderRename?.draft:void 0,onRenameDraftChange:n.groupProps.setFolderRenameDraft,onRenameSave:()=>{const V=n.groupProps.folderRename?.draft.trim();V&&d($.scopeKey,$.folder.id,V),n.groupProps.clearFolderRename()},onRenameCancel:n.groupProps.clearFolderRename,droppableRef:me,isDropTarget:le,onNewSession:()=>{ko({projectId:$.projectId,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:$.projectId,directoryOverride:$.scopeDirectory??$.group.directory,targetFolderId:$.folder.id,target:$.group.draftTarget})},archivedBucket:$.archived})})}if($.kind==="session"){const J=new Set;return wr($.node,n.state.editingId)&&J.add($.node.session.id),s.jsx("div",{onFocusCapture:()=>h($.key),onBlurCapture:()=>h(me=>me===$.key?null:me),children:s.jsx(Go,{...n.groupProps,node:$.node,depth:$.depth,groupDirectory:$.groupDirectory,projectId:$.projectId,folderOwnerKey:$.ownerKey,selectionScopeKey:$.selectionScopeKey,archivedBucket:$.archived,renderContext:$.renderContext,rowKey:$.key,dragKey:$.key,secondaryMeta:$.secondaryMeta,renderChildren:!1,editingId:n.state.editingId,openSidebarMenuKey:n.state.openSidebarMenuKey,setOpenSidebarMenuKey:n.state.setOpenSidebarMenuKey,renderExtras:{subtreeContainsEditing:J,menuOpenSessionId:n.state.openSidebarMenuKey===`session-menu:${$.key}`||n.state.openSidebarMenuKey===`session-context:${$.key}`?$.node.session.id:null,nodeStructureKey:Vo($.node)}})})}if($.kind==="run")return s.jsx(Hk,{run:$.run,laneNodes:$.laneNodes,renderContext:$.renderContext,projectId:$.projectId,projectLabel:$.projectLabel,expansionKey:$.expansionKey,expanded:$.expanded,forceExpanded:$.forceExpanded,notifyOnSubtasks:n.groupProps.notifyOnSubtasks,toggleParent:n.groupProps.toggleParent});if($.kind==="show-control")return s.jsx("button",{type:"button",className:Ie("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:()=>{$.containerKey.startsWith("activity:")?n.state.setVisibleActivityCountByKey(J=>{const me=new Map(J);return $.control==="more"?me.set($.containerKey,$.currentCount+$.increment):me.delete($.containerKey),me}):$.control==="more"?i.group.showMoreGroupSessions($.containerKey,$.currentCount,$.increment):i.group.resetGroupSessionLimit($.containerKey)},children:o($.control==="more"?"sessions.sidebar.group.showMore":"sessions.sidebar.group.showFewer")});if($.kind==="status")return _($);if($.emptyKind==="sidebar")return n.emptyState;if($.emptyKind==="search")return n.searchEmptyState;if($.emptyKind==="group"&&$.group?.directory&&!$.group.emptyMessage){const J=$.group;return s.jsx(ft,{variant:"link",size:"xs",className:"w-full justify-start pl-[26px] text-left font-normal normal-case text-muted-foreground/70 underline-offset-auto hover:text-foreground hover:underline",onClick:()=>{ko({projectId:$.projectId??null,mobileVariant:r.mobileVariant,closeMobileSwitcher:!0,setActiveProjectIdOnly:i.setActiveProjectIdOnly,setSessionSwitcherOpen:i.setSessionSwitcherOpen}),i.openNewSessionDraft({selectedProjectId:$.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:$.emptyKind==="archived"?o("sessions.sidebar.group.empty.noArchivedSessions"):$.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]=U,e[40]=d,e[41]=_,e[42]=f,e[43]=o,e[44]=a,e[45]=r.alwaysShowActions,e[46]=r.hideDirectoryControls,e[47]=r.homeDirectory,e[48]=r.mobileVariant,e[49]=r.projectSortOrder,e[50]=r.stickyZoneHeaders,e[51]=r.timelineView,e[52]=r.worktreeSortOrder,e[53]=se):se=e[53];const te=se;let ee;e[54]!==n.rowModel.rows?(ee=n.rowModel.rows.flatMap(k3),e[54]=n.rowModel.rows,e[55]=ee):ee=e[55];const ue=ee;let de;e[56]!==n.sectionsForRender?(de=new Set(n.sectionsForRender.map(j3)),e[56]=n.sectionsForRender,e[57]=de):de=e[57];const Re=de;let we;e[58]!==n.rowModel.stickyHeaders?(we=n.rowModel.stickyHeaders.map(S3).join(""),e[58]=n.rowModel.stickyHeaders,e[59]=we):we=e[59];const fe=we,Pe=!r.timelineView;let L;e[60]!==Re?(L=$=>{N(Re.has(String($.active.id)))},e[60]=Re,e[61]=L):L=e[61];let oe;e[62]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>N(!1),e[62]=oe):oe=e[62];let ce;e[63]!==i||e[64]!==m||e[65]!==n.rowModel.folderAuthorityByOwner||e[66]!==n.rowModel.folderDropTargets||e[67]!==n.rowModel.rows||e[68]!==n.sectionsForRender||e[69]!==n.state||e[70]!==r.hasSessionSearchQuery||e[71]!==r.projectSortOrder?(ce=$=>{if(N(!1),!$.over)return;const J=$.active.data.current,me=$.over.data.current;if(J?.type==="session"&&J.sessionId&&J.ownerKey&&J.archivedBucket!==!0&&me?.type==="folder"&&me.folderId&&me.scopeKey&&me.ownerKey===J.ownerKey){const $e=n.rowModel.folderDropTargets.find(Le=>Le.folderId===me.folderId&&Le.scopeKey===me.scopeKey&&Le.ownerKey===J.ownerKey),R=n.rowModel.folderAuthorityByOwner.get(J.ownerKey);if(!$e?.enabled||R?.complete!==!0)return;const pe=Gt.getState();for(const Le of R.scopeKeys)Le!==me.scopeKey&&pe.removeSessionFromFolder(Le,J.sessionId);m(me.scopeKey,me.folderId,J.sessionId);return}if(r.hasSessionSearchQuery||n.state.editingId!==null||$.active.id===$.over.id)return;const le=String($.active.id),V=String($.over.id),Z=n.sectionsForRender.map(v3),G=Z.indexOf(le),ie=Z.indexOf(V);if(G>=0&&ie>=0&&r.projectSortOrder==="manual"){i.reorderProjects(G,ie);return}const je=n.rowModel.rows.find($e=>$e.kind==="group-header"&&$e.groupKey===le),ne=n.rowModel.rows.find($e=>$e.kind==="group-header"&&$e.groupKey===V);if(!je||!ne||je.projectId!==ne.projectId||!je.projectId)return;const Oe=je.projectId,Ve=n.sectionsForRender.find($e=>$e.project.id===Oe);if(!Ve)return;const ze=Ve.groups.findIndex($e=>$e.id===je.group.id),He=Ve.groups.findIndex($e=>$e.id===ne.group.id);ze<0||He<0||i.setGroupOrderByProject($e=>new Map($e).set(Oe,Ju(Ve.groups,ze,He).map(w3)))},e[63]=i,e[64]=m,e[65]=n.rowModel.folderAuthorityByOwner,e[66]=n.rowModel.folderDropTargets,e[67]=n.rowModel.rows,e[68]=n.sectionsForRender,e[69]=n.state,e[70]=r.hasSessionSearchQuery,e[71]=r.projectSortOrder,e[72]=ce):ce=e[72];let he;e[73]!==I||e[74]!==n.rowModel||e[75]!==k||e[76]!==te||e[77]!==p?(he=s.jsx(Xk,{model:n.rowModel,scrollElement:p,pinnedRowIndexes:k,renderRow:te,onFirstVisibleIndexChange:I}),e[73]=I,e[74]=n.rowModel,e[75]=k,e[76]=te,e[77]=p,e[78]=he):he=e[78];let Y;e[79]!==ue||e[80]!==he?(Y=s.jsx(Ha,{items:ue,strategy:Zu,children:he}),e[79]=ue,e[80]=he,e[81]=Y):Y=e[81];let ve;e[82]!==M||e[83]!==L||e[84]!==ce||e[85]!==Y?(ve=s.jsx(ni,{sensors:M,collisionDetection:ri,onDragStart:L,onDragCancel:oe,onDragEnd:ce,children:Y}),e[82]=M,e[83]=L,e[84]=ce,e[85]=Y,e[86]=ve):ve=e[86];let Te;e[87]!==Pe||e[88]!==ve?(Te=s.jsx(xn,{ref:K,useScrollShadow:!0,hideTopScrollShadow:Pe,scrollShadowSize:40,outerClassName:"flex-1 min-h-0",className:"oc-sidebar-scroller pb-1 pl-2.5 pr-2 [overflow-anchor:none]",children:ve}),e[87]=Pe,e[88]=ve,e[89]=Te):Te=e[89];let ke;e[90]!==S||e[91]!==Te||e[92]!==r.stickyZoneHeaders||e[93]!==fe?(ke=s.jsx(e3,{enabled:r.stickyZoneHeaders,suspended:S,layoutKey:fe,scrollRef:P,children:Te}),e[90]=S,e[91]=Te,e[92]=r.stickyZoneHeaders,e[93]=fe,e[94]=ke):ke=e[94];let xe;e[95]!==u||e[96]!==g?(xe=()=>{g&&(u(g.scopeKey,g.folderId),x(null))},e[95]=u,e[96]=g,e[97]=xe):xe=e[97];let ge;e[98]!==g||e[99]!==xe?(ge=s.jsx(om,{value:g,setValue:x,onConfirm:xe}),e[98]=g,e[99]=xe,e[100]=ge):ge=e[100];let Q;return e[101]!==ke||e[102]!==ge?(Q=s.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[ke,ge]}),e[101]=ke,e[102]=ge,e[103]=Q):Q=e[103],Q}function w3(t){return t.id}function v3(t){return t.project.id}function S3(t){const{kind:e,id:n,rowIndex:r}=t;return`${e}:${n}:${r}`}function j3(t){return t.project.id}function k3(t){return t.kind==="project-header"?[t.section.project.id]:t.kind==="group-header"?[t.groupKey]:[]}function C3(){}function N3(t){return t.showDeletionDialog}function A3(t){return t.addSessionToFolder}function P3(t){return t.deleteFolder}function D3(t){return t.renameFolder}function I3(t){return t.toggleFolderCollapse}const T3=c.memo(y3),ja=new Map,ad=(t,e)=>{for(const n of t){const r=gt(n??null);r&&!ja.has(r)&&ja.set(r,e)}},ld=t=>{const e=gt(t??null);return e?ja.get(e)??0:0},Dr=t=>!!t.time?.archived,E3=t=>{const{t:e}=At(),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=gt(a.directory??null)??"";return`${(a.title||e("sessions.sidebar.session.untitled")).trim()} ${d}`.toLowerCase()},[e]),o=c.useCallback((a,d)=>{if(!d)return a;const u=d.trim().toLowerCase(),m=u.startsWith("ses_");return a.flatMap(f=>{if(m&&Dr(f.session))return[];if(m?f.session.id.toLowerCase()===u:Fo([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,m,f)=>{const g=gt(d??null),x=Bu(a),b=new Map(x.map(v=>[v.id,v])),j=new Map;x.forEach(v=>{const I=v.parentID;if(!I)return;const H=b.get(I);if(!H||Dr(H)!==Dr(v))return;const _=j.get(I)??[];_.push(v),j.set(I,_)});const y=fb(u,g),h=(g&&!t.isVSCode?t.spacesByProject?.get(g):void 0)??[],p=new Map;for(const v of h){const I=gt(v.directory);I&&p.set(I,v)}const w=v=>{const I=gt(v.directory??null),H=t.worktreeMetadata.get(v.id)??null;if(H)return H;if(I){const _=y.get(I)??null;if(_&&I!==g)return _}return null},S=new Set,N=v=>{S.add(v.id);const I=j.get(v.id)??[],H=[];for(const _ of I)S.has(_.id)||H.push(N(_));return{session:v,children:H,worktree:w(v)}},P=x.filter(v=>{const I=v.parentID;if(!I)return!0;const H=b.get(I);return H?Dr(H)!==Dr(v):!0}),C=[],T=v=>{S.has(v.id)||C.push(N(v))};P.forEach(T),x.forEach(T);const O=new Map,M="__archived__",F=v=>{if(v.time?.archived)return M;if(t.isVSCode||t.runKeyBySessionId?.has(v.id))return g??"__project_root__";const I=t.sessionOwners?.get(v.id)?.scopeDirectory;if(I){if(I===g)return g??"__project_root__";if(y.has(I)||p.has(I))return I}const _=gt(t.worktreeMetadata.get(v.id)?.path??null)??Is(v);return _&&_!==g&&y.has(_)?_:g??"__project_root__"};C.forEach(v=>{const I=F(v.session);O.has(I)||O.set(I,[]),O.get(I)?.push(v)});const K=g??"__project_root__",D=[{id:"root",label:f&&m&&m!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:m}):e("sessions.sidebar.grouping.projectRoot"),branch:m??null,description:g?Hr(g,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:g,folderScopeKey:g,sessions:O.get(K)??[]}],U=new Map;u.forEach(v=>{const I=gt(v.path)??v.path,H=O.get(I)??[],_=H.length>0,se=H.reduce((te,ee)=>{const ue=mb(ee.session,t.sessionOrderRanks);return Number.isFinite(ue)?Math.max(te,ue):te},0);U.set(I,{hasActiveSession:_,lastUpdatedAt:se})});const A=(v,I)=>{const H=(v.label||v.branch||v.name||v.path||"").toLowerCase(),_=(I.label||I.branch||I.name||I.path||"").toLowerCase();return H.localeCompare(_)},E=t.worktreeSortOrder!=="recent"?[...u].sort(A):[...u].sort((v,I)=>{const H=gt(v.path)??v.path,_=gt(I.path)??I.path,se=U.get(H)??{hasActiveSession:!1,lastUpdatedAt:0},te=U.get(_)??{hasActiveSession:!1,lastUpdatedAt:0};if(se.hasActiveSession!==te.hasActiveSession)return se.hasActiveSession?-1:1;if(se.hasActiveSession&&te.hasActiveSession)return te.lastUpdatedAt-se.lastUpdatedAt;const ee=ld(v.path),ue=ld(I.path);return ee!==ue?ue-ee:A(v,I)});(t.isVSCode?[]:E).forEach(v=>{const I=gt(v.path)??v.path,H=n.current.get(I)?.trim()||null,_=v.branch?.trim()||null,te=!!(H&&_&&v.label&&Bl(v.label)===Bl(_))?H:v.label||v.name||yr(I,t.homeDirectory)||I;D.push({id:`worktree:${I}`,label:te,branch:H||_,description:Hr(I,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:v,directory:I,folderScopeKey:I,sessions:O.get(I)??[]})});for(const[v,I]of p)D.push({id:`space:${I.id}`,label:I.name||e("sessions.sidebar.grouping.spaceUnnamed"),branch:null,description:null,isMain:!1,isArchivedBucket:!1,worktree:null,space:I,directory:v,folderScopeKey:v,sessions:O.get(v)??[]});const k=O.get(M)??[];return k.length>0&&D.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&&g?Mu(g):null,sessions:k}),D},[t.homeDirectory,t.worktreeMetadata,t.sessionOrderRanks,t.isVSCode,t.worktreeSortOrder,t.sessionOwners,t.spacesByProject,t.runKeyBySessionId,e]);return{buildGroupSearchText:r,buildSessionSearchText:i,filterSessionNodesForSearch:o,buildGroupedSessions:l}},R3=t=>{const e=nt.c(60),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:o,onMoveToFolder:l,onCreateFolderAndMove:a,onRemoveFromFolder:d,canRemoveFromFolder:u,onRestore:m,onArchive:f,onDelete:g,onDone:x}=t,{t:b}=At(),j=n>0,y=j&&!!r&&!o;let h;e[0]!==n||e[1]!==b?(h=b("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[0]=n,e[1]=b,e[2]=h):h=e[2];let p;e[3]!==h?(p=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:h}),e[3]=h,e[4]=p):p=e[4];let w;e[5]!==y||e[6]!==u||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==b?(w=y?s.jsxs(ks,{children:[s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(Ss,{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(B,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(js,{align:"end",className:"min-w-[180px]",children:[i.length===0?s.jsx(zt,{disabled:!0,className:"text-muted-foreground",children:b("sessions.sidebar.folders.none")}):i.map(_=>s.jsx(zt,{onClick:()=>l(_.id),children:s.jsx("span",{className:"flex-1 truncate",children:_.name})},_.id)),s.jsx(ps,{}),s.jsxs(zt,{onClick:a,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"}),b("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(zt,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(B,{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]=w):w=e[12];let S;e[13]!==o||e[14]!==j||e[15]!==m||e[16]!==b?(S=o?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,disabled:!j,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(B,{name:"inbox-unarchive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.restore")})})]}):null,e[13]=o,e[14]=j,e[15]=m,e[16]=b,e[17]=S):S=e[17];let N;e[18]!==o||e[19]!==j||e[20]!==f||e[21]!==b?(N=o?null:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,disabled:!j,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(B,{name:"archive",className:"h-4 w-4"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:b("sessions.sidebar.bulkActions.archive")})})]}),e[18]=o,e[19]=j,e[20]=f,e[21]=b,e[22]=N):N=e[22];const P=!j;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=Ie("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]=C):C=e[23];let T;e[24]!==b?(T=b("sessions.sidebar.bulkActions.delete"),e[24]=b,e[25]=T):T=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(B,{name:"delete-bin",className:"h-4 w-4"}),e[26]=O):O=e[26];let M;e[27]!==g||e[28]!==P||e[29]!==T?(M=s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:g,disabled:P,className:C,"aria-label":T,children:O})}),e[27]=g,e[28]=P,e[29]=T,e[30]=M):M=e[30];let F;e[31]!==b?(F=b("sessions.sidebar.bulkActions.delete"),e[31]=b,e[32]=F):F=e[32];let K;e[33]!==F?(K=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:F})}),e[33]=F,e[34]=K):K=e[34];let D;e[35]!==M||e[36]!==K?(D=s.jsxs(vt,{children:[M,K]}),e[35]=M,e[36]=K,e[37]=D):D=e[37];let U;e[38]!==b?(U=b("sessions.sidebar.header.actions.exitSelection"),e[38]=b,e[39]=U):U=e[39];let A;e[40]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(B,{name:"close",className:"h-4 w-4"}),e[40]=A):A=e[40];let E;e[41]!==x||e[42]!==U?(E=s.jsx(St,{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":U,children:A})}),e[41]=x,e[42]=U,e[43]=E):E=e[43];let W;e[44]!==b?(W=b("sessions.sidebar.header.actions.exitSelection"),e[44]=b,e[45]=W):W=e[45];let k;e[46]!==W?(k=s.jsx(jt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:W})}),e[46]=W,e[47]=k):k=e[47];let v;e[48]!==E||e[49]!==k?(v=s.jsxs(vt,{children:[E,k]}),e[48]=E,e[49]=k,e[50]=v):v=e[50];let I;e[51]!==D||e[52]!==v||e[53]!==w||e[54]!==S||e[55]!==N?(I=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[w,S,N,D,v]}),e[51]=D,e[52]=v,e[53]=w,e[54]=S,e[55]=N,e[56]=I):I=e[56];let H;return e[57]!==p||e[58]!==I?(H=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2.5 py-1.5",children:[p,I]}),e[57]=p,e[58]=I,e[59]=H):H=e[59],H},cd=new Map,M3=(t,e)=>{if(!t)return[];const n=e(t);return n.length>0?n.map(r=>r.scopeKey):[t]},O3=(t,e)=>{const n=t.sessionIds.filter(o=>e.has(o));if(n.length===0)return{ready:!1,value:null};const r=t.archivedBucket||em(new Set(n),e),i={sessionIds:n,sessionCount:n.length,archivedBucket:r};return{ready:n.length===t.sessionIds.length&&r===t.archivedBucket,value:i}},B3=t=>{const e=nt.c(89),{t:n}=At();let r;e[0]!==n?(r=le=>{const V=hb(le);return V?{description:eu(V,n)}:void 0},e[0]=n,e[1]=r):r=e[1];const i=r,{isInlineEditing:o,showDeletionDialog:l,foldersMap:a,getFolderScopesForProject:d,addSessionsToFolder:u,removeSessionsFromFolders:m,createFolderAndStartRename:f,archiveSessions:g,unarchiveSessions:x,deleteSessions:b,bulkDeleteConfirm:j,setBulkDeleteConfirm:y}=t,h=ns(F3),p=ns(L3),w=p>0,S=ns(_3),N=ns($3),P=Zf(),C=z3,T=W3;let O;e[2]!==w||e[3]!==P||e[4]!==S?(O=w&&em(S,P?.getSessionsById()??cd),e[2]=w,e[3]=P,e[4]=S,e[5]=O):O=e[5];const M=O;let F;e:{if(N){F=N;break e}F=null}const K=F;let D;e[6]!==K||e[7]!==d?(D=M3(K,d),e[6]=K,e[7]=d,e[8]=D):D=e[8];const U=D;let A;if(e[9]!==a||e[10]!==U){let le;e[12]!==a?(le=V=>a[V]??[],e[12]=a,e[13]=le):le=e[13],A=U.flatMap(le),e[9]=a,e[10]=U,e[11]=A}else A=e[11];const E=A;let W;e[14]!==a||e[15]!==U?(W=le=>{for(const V of U)if((a[V]??[]).some(Z=>Z.id===le))return V;return null},e[14]=a,e[15]=U,e[16]=W):W=e[16];const k=W;let v;e:{if(!w){v=!1;break e}for(const le of U)for(const V of a[le]??[])for(const Z of V.sessionIds)if(S.has(Z)){v=!0;break e}v=!1}const I=v;let H;e[17]!==u||e[18]!==m||e[19]!==S||e[20]!==U?(H=(le,V)=>{const Z=Array.from(S);for(const G of U)G!==le&&m(G,Z);u(le,V,Z)},e[17]=u,e[18]=m,e[19]=S,e[20]=U,e[21]=H):H=e[21];const _=H;let se;e[22]!==w||e[23]!==_||e[24]!==k?(se=le=>{if(!w)return;const V=k(le);V&&_(V,le)},e[22]=w,e[23]=_,e[24]=k,e[25]=se):se=e[25];const te=se;let ee;e[26]!==f||e[27]!==w||e[28]!==_||e[29]!==U?(ee=()=>{const le=U[0];if(!le||!w)return;const V=f(le);V&&_(le,V.id)},e[26]=f,e[27]=w,e[28]=_,e[29]=U,e[30]=ee):ee=e[30];const ue=ee;let de;e[31]!==w||e[32]!==m||e[33]!==S||e[34]!==U?(de=()=>{if(!w)return;const le=Array.from(S);for(const V of U)m(V,le)},e[31]=w,e[32]=m,e[33]=S,e[34]=U,e[35]=de):de=e[35];const Re=de;let we;e[36]!==g||e[37]!==b||e[38]!==i||e[39]!==n?(we=async(le,V)=>{if(le.length!==0)if(V){const{deletedIds:Z,failedIds:G}=await b(le);Z.length>0&&Fe.success(Z.length===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.deletedPlural",{count:Z.length})),G.length>0&&Fe.error(G.length===1?n("sessions.sidebar.bulkActions.failedDeleteSingle",{count:G.length}):n("sessions.sidebar.bulkActions.failedDeletePlural",{count:G.length}),i(G)),ns.getState().removeMany(Z)}else{const{archivedIds:Z,failedIds:G}=await g(le);Z.length>0&&Fe.success(Z.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:Z.length})),G.length>0&&Fe.error(G.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:G.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:G.length}),i(G)),ns.getState().removeMany(Z)}},e[36]=g,e[37]=b,e[38]=i,e[39]=n,e[40]=we):we=e[40];const fe=we;let Pe;e[41]!==fe||e[42]!==w||e[43]!==S||e[44]!==y||e[45]!==l?(Pe=le=>{if(!w)return;const V=Array.from(S);if(!l){fe(V,le);return}y({sessionIds:V,sessionCount:V.length,archivedBucket:le})},e[41]=fe,e[42]=w,e[43]=S,e[44]=y,e[45]=l,e[46]=Pe):Pe=e[46];const L=Pe;let oe;e[47]!==M||e[48]!==L?(oe=()=>L(M),e[47]=M,e[48]=L,e[49]=oe):oe=e[49];const ce=oe;let he;e[50]!==L?(he=()=>L(!1),e[50]=L,e[51]=he):he=e[51];const Y=he;let ve;e[52]!==L?(ve=()=>L(!0),e[52]=L,e[53]=ve):ve=e[53];const Te=ve;let ke;e[54]!==M||e[55]!==i||e[56]!==w||e[57]!==S||e[58]!==n||e[59]!==x?(ke=async()=>{if(!w||!M)return;const le=Array.from(S),{restoredIds:V,failedIds:Z}=await x(le);V.length>0&&Fe.success(V.length===1?n("sessions.sidebar.bulkActions.restoredSingle",{count:V.length}):n("sessions.sidebar.bulkActions.restoredPlural",{count:V.length})),Z.length>0&&Fe.error(Z.length===1?n("sessions.sidebar.bulkActions.failedRestoreSingle",{count:Z.length}):n("sessions.sidebar.bulkActions.failedRestorePlural",{count:Z.length}),i(Z)),ns.getState().removeMany(V)},e[54]=M,e[55]=i,e[56]=w,e[57]=S,e[58]=n,e[59]=x,e[60]=ke):ke=e[60];const xe=ke;let ge;e[61]!==j||e[62]!==fe||e[63]!==P||e[64]!==y?(ge=async()=>{if(!j)return;const le=P?.getSessionsById()??cd,V=O3(j,le);if(!V.ready){y(V.value);return}y(null),await fe(V.value.sessionIds,V.value.archivedBucket)},e[61]=j,e[62]=fe,e[63]=P,e[64]=y,e[65]=ge):ge=e[65];const Q=ge;let $,J;e[66]!==j||e[67]!==ce||e[68]!==o||e[69]!==P||e[70]!==h?($=()=>{if(!h)return;const le=/Macintosh|Mac OS X/.test(navigator.userAgent||""),V=Z=>{if(j||o)return;const G=Z.target instanceof HTMLElement?Z.target:null;if(G&&(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.isContentEditable))return;const ie=le?Z.metaKey:Z.ctrlKey;if(Z.key==="Escape"){Z.preventDefault(),ns.getState().disable();return}if(ie&&Z.key==="Backspace"){Z.preventDefault(),ce();return}if(ie&&(Z.key==="a"||Z.key==="A")){const je=rk(P?.getEntries()??[],P?.getDescendantIds()??[],ns.getState().scopeKey);if(!je)return;Z.preventDefault(),ns.getState().replaceAll(je.ids,je.scopeKey)}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},J=[j,ce,o,P,h],e[66]=j,e[67]=ce,e[68]=o,e[69]=P,e[70]=h,e[71]=$,e[72]=J):($=e[71],J=e[72]),c.useEffect($,J);let me;return e[73]!==I||e[74]!==E||e[75]!==M||e[76]!==Q||e[77]!==K||e[78]!==Y||e[79]!==ue||e[80]!==ce||e[81]!==Te||e[82]!==te||e[83]!==Re||e[84]!==xe||e[85]!==w||e[86]!==p||e[87]!==h?(me={selectionModeEnabled:h,hasSelection:w,selectedIdsSize:p,bulkScopeIsArchived:M,derivedSelectionScope:K,bulkScopeFolders:E,bulkCanRemoveFromFolder:I,handleToggleSelectionMode:C,handleExitSelectionMode:T,handleBulkMoveToFolder:te,handleBulkCreateFolderAndMove:ue,handleBulkRemoveFromFolder:Re,handleBulkDelete:ce,handleBulkArchive:Y,handleBulkHardDelete:Te,handleBulkRestore:xe,confirmBulkDelete:Q},e[73]=I,e[74]=E,e[75]=M,e[76]=Q,e[77]=K,e[78]=Y,e[79]=ue,e[80]=ce,e[81]=Te,e[82]=te,e[83]=Re,e[84]=xe,e[85]=w,e[86]=p,e[87]=h,e[88]=me):me=e[88],me};function F3(t){return t.enabled}function L3(t){return t.selectedIds.size}function _3(t){return t.selectedIds}function $3(t){return t.scopeKey}function z3(){ns.getState().toggleMode()}function W3(){ns.getState().disable()}function K3(t){const e=nt.c(37),{getFolderScopesForProject:n,isInlineEditing:r,startFolderRename:i}=t,[o,l]=c.useState(null),a=ye(J3),d=ye(X3),u=Gt(Q3),m=Gt(Y3),f=Gt(q3),g=Gt(G3),x=rt(H3),b=rt(U3),j=rt(V3);let y;e[0]!==m||e[1]!==i?(y=P=>{const C=m(P,"New folder");return i(P,C),C},e[0]=m,e[1]=i,e[2]=y):y=e[2];let h;e[3]!==f||e[4]!==x||e[5]!==o||e[6]!==j||e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==g||e[11]!==a||e[12]!==y||e[13]!==b?(h={isInlineEditing:r,showDeletionDialog:a,foldersMap:u,getFolderScopesForProject:n,addSessionsToFolder:f,removeSessionsFromFolders:g,createFolderAndStartRename:y,archiveSessions:x,unarchiveSessions:b,deleteSessions:j,bulkDeleteConfirm:o,setBulkDeleteConfirm:l},e[3]=f,e[4]=x,e[5]=o,e[6]=j,e[7]=u,e[8]=n,e[9]=r,e[10]=g,e[11]=a,e[12]=y,e[13]=b,e[14]=h):h=e[14];const p=B3(h);let w;e[15]!==p.bulkCanRemoveFromFolder||e[16]!==p.bulkScopeFolders||e[17]!==p.bulkScopeIsArchived||e[18]!==p.derivedSelectionScope||e[19]!==p.handleBulkArchive||e[20]!==p.handleBulkCreateFolderAndMove||e[21]!==p.handleBulkHardDelete||e[22]!==p.handleBulkMoveToFolder||e[23]!==p.handleBulkRemoveFromFolder||e[24]!==p.handleBulkRestore||e[25]!==p.handleExitSelectionMode||e[26]!==p.selectedIdsSize||e[27]!==p.selectionModeEnabled?(w=p.selectionModeEnabled?s.jsx(R3,{selectedCount:p.selectedIdsSize,scopeKey:p.derivedSelectionScope,scopeFolders:p.bulkScopeFolders,archivedBucket:p.bulkScopeIsArchived,onMoveToFolder:p.handleBulkMoveToFolder,onCreateFolderAndMove:p.handleBulkCreateFolderAndMove,onRemoveFromFolder:p.handleBulkRemoveFromFolder,canRemoveFromFolder:p.bulkCanRemoveFromFolder,onRestore:p.handleBulkRestore,onArchive:p.handleBulkArchive,onDelete:p.handleBulkHardDelete,onDone:p.handleExitSelectionMode}):null,e[15]=p.bulkCanRemoveFromFolder,e[16]=p.bulkScopeFolders,e[17]=p.bulkScopeIsArchived,e[18]=p.derivedSelectionScope,e[19]=p.handleBulkArchive,e[20]=p.handleBulkCreateFolderAndMove,e[21]=p.handleBulkHardDelete,e[22]=p.handleBulkMoveToFolder,e[23]=p.handleBulkRemoveFromFolder,e[24]=p.handleBulkRestore,e[25]=p.handleExitSelectionMode,e[26]=p.selectedIdsSize,e[27]=p.selectionModeEnabled,e[28]=w):w=e[28];let S;e[29]!==p.confirmBulkDelete||e[30]!==o||e[31]!==d||e[32]!==a?(S=s.jsx(Mk,{value:o,setValue:l,showDeletionDialog:a,setShowDeletionDialog:d,onConfirm:p.confirmBulkDelete}),e[29]=p.confirmBulkDelete,e[30]=o,e[31]=d,e[32]=a,e[33]=S):S=e[33];let N;return e[34]!==w||e[35]!==S?(N=s.jsxs(s.Fragment,{children:[w,S]}),e[34]=w,e[35]=S,e[36]=N):N=e[36],N}function V3(t){return t.deleteSessions}function U3(t){return t.unarchiveSessions}function H3(t){return t.archiveSessions}function G3(t){return t.removeSessionsFromFolders}function q3(t){return t.addSessionsToFolder}function Y3(t){return t.createFolder}function Q3(t){return t.foldersMap}function X3(t){return t.setShowDeletionDialog}function J3(t){return t.showDeletionDialog}const lm="oc.sessions.expandedParents.v3",Z3=Ga(Hn()),eC=()=>{try{const t=globalThis.localStorage.getItem(lm);if(t===null)return new Set;const e=Z3.safeParse(JSON.parse(t));return e.success?new Set(e.data):new Set}catch{return new Set}},tC=()=>{const[t,e]=c.useState(eC),n=c.useRef(t);n.current=t;const r=c.useCallback(i=>{const o=pb(n.current,i);n.current=o,e(o);try{globalThis.localStorage.setItem(lm,JSON.stringify([...o]))}catch{}},[]);return{expandedParents:t,toggleParent:r}},sC=t=>{const e=nt.c(22),{childStores:n,sections:r,chatGroup:i,canGrantAccess:o}=t,l=gs(nC),a=gs(rC);let d;e[0]!==i||e[1]!==r?(d=[...r.flatMap(oC),...i?[{key:"activity:chats",group:i}]:[]].map(lC),e[0]=i,e[1]=r,e[2]=d):d=e[2];const u=d;let m;e[3]!==u?(m=new Set(u.flatMap(cC)),e[3]=u,e[4]=m):m=e[4];let f;e[5]!==m?(f=[...m],e[5]=m,e[6]=f):f=e[6];const g=f;let x;e[7]!==n||e[8]!==g.length?(x=w=>g.length>0?n.subscribeBootstrap(w):dC,e[7]=n,e[8]=g.length,e[9]=x):x=e[9];let b;e[10]!==n||e[11]!==g?(b=()=>g.map(w=>`${w}\0${n.getBootstrapState(w)??""}\0${n.getBootstrapFailure(w)??""}\0${n.getInitializationState(w)??""}\0${n.getInitializationFailure(w)??""}`).join(""),e[10]=n,e[11]=g,e[12]=b):b=e[12];const j=c.useSyncExternalStore(x,b,uC);let y;if(e[13]!==o||e[14]!==n||e[15]!==l||e[16]!==u||e[17]!==a){y=new Map;for(const{key:w,archived:S,directories:N}of u){const P=N.find(C=>n.getBootstrapState(C)==="failed"||n.getInitializationState(C)==="failed");if(P){const C=n.getBootstrapState(P)==="failed",T=C?n.getBootstrapFailure(P):n.getInitializationFailure(P);y.set(w,{state:T==="os-permission"?"permission-denied":C?"load-failed":"initialization-failed",directory:P,canGrantAccess:T==="os-permission"&&o})}else{const C=a||!S&&N.length>0&&N.every(T=>n.getBootstrapState(T)==="complete");y.set(w,{state:C?"ready":l==="error"?"load-failed":"loading",directory:C?N[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 h=y;let p;return e[19]!==j||e[20]!==h?(p={groupStatusByKey:h,bootstrapSnapshot:j},e[19]=j,e[20]=h,e[21]=p):p=e[21],p};function nC(t){return t.status}function rC(t){return t.hasLoaded}function oC(t){return t.groups.map(e=>({key:`${t.project.id}:${e.id}`,group:e}))}function iC(t){return gt(t.directory)}function aC(t){return!!t}function lC(t){const{key:e,group:n}=t;return{key:e,archived:n.isArchivedBucket===!0,directories:Gr(n).map(iC).filter(aC)}}function cC(t){return t.directories}function dC(){}function uC(){return""}const fC=5*6e4,mC=[],dd=[],ud=[],hC=t=>!t.parentID,pC=({topology:t,view:e,actions:n})=>{const{alwaysShowActions:r,notifyOnSubtasks:i,projectViewActions:o,rowActions:l,...a}=n,d=Gt(Me=>Me.foldersMap),u=Gt(Me=>Me.collapsedFolderIds),m=Gt(Me=>Me.createFolder),f=Gt(Me=>Me.addSessionToFolder),g=e.projectView,{getOrderedGroups:x,setGroupOrderByProject:b,toggleGroup:j,toggleProject:y}=o,h=Zh({knownDirectories:t.knownDirectories,isVSCode:t.isVSCode,isVisible:!0}),p=gb(Me=>Me.projects),w=dh(),S=c.useMemo(()=>new Map(w.map(Me=>[Me.id,Me.name])),[w]),N=c.useMemo(()=>{const Me=new Map;for(const st of w){const Xe=gt(st.projectDirectory);if(!Xe)continue;const Ne=Me.get(Xe);Ne?Ne.push(st):Me.set(Xe,[st])}return Me},[w]),P=c.useMemo(()=>ep(h.sessions,t.projects,t.availableWorktreesByProject,t.isVSCode,h.archivedSessions,p,w),[p,h.archivedSessions,h.sessions,w,t.availableWorktreesByProject,t.isVSCode,t.projects]),[C,T]=c.useState(new Map),[O,M]=c.useState(new Set),[F,K]=c.useState(new Map),D=c.useCallback((Me,st,Xe=7)=>{T(Ne=>new Map(Ne).set(Me,st+Xe))},[]),U=c.useCallback(Me=>{T(st=>{if(!st.has(Me))return st;const Xe=new Map(st);return Xe.delete(Me),Xe})},[]),A=as(Me=>Me.showRecentSection),E=as(Me=>Me.projectDisplayMode),W=as(Me=>Me.singleProjectId),k=as(Me=>Me.setSingleProjectId),I=!t.isVSCode&&!uh()&&E==="single",H=e.sidebarViewMode==="timeline"&&!t.isVSCode,_=tp({enabled:A&&!I&&!H,isVSCode:t.isVSCode,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,sessions:h.rootSessions}),se=c.useMemo(()=>bb(h.rootSessions,Me=>gt(t.worktreeMetadata.get(Me.id)?.projectDirectory??Me.directory??null)),[h.rootSessions,t.worktreeMetadata]),te=c.useRef(null),ee=c.useMemo(()=>{const Me=Array.from(se.runKeyBySessionId,([st,Xe])=>`${st}\0${Xe}`).sort().join("");return te.current?.signature!==Me&&(te.current={signature:Me,map:se.runKeyBySessionId}),te.current.map},[se]),[ue,de]=c.useState(null),[Re,we]=c.useState(null),[fe,Pe]=c.useState(""),[L,oe]=c.useState(null),[ce,he]=c.useState(null),[Y,ve]=c.useState(null),Te=c.useCallback((Me,st)=>{ve({scopeKey:Me,folderId:st.id,draft:st.name})},[]),ke=c.useCallback(Me=>{ve(st=>st?{...st,draft:Me}:null)},[]),xe=c.useCallback(()=>ve(null),[]),{expandedParents:ge,toggleParent:Q}=tC(),$=rt(Me=>Me.setCurrentSession),J=c.useCallback((Me,st)=>{Me!==rt.getState().currentSessionId&&$(Me,st)},[$]),me=$u(),le=as(Me=>Me.worktreeSortOrder),{buildGroupedSessions:V,filterSessionNodesForSearch:Z,buildGroupSearchText:G}=E3({homeDirectory:e.homeDirectory,worktreeMetadata:t.worktreeMetadata,pinnedSessionIds:h.pinnedSessionIds,sessionOrderRanks:h.sessionOrderRanks,gitBranches:t.gitBranches,isVSCode:t.isVSCode,worktreeSortOrder:le,sessionOwners:P.bySessionId,spacesByProject:N,runKeyBySessionId:ee}),{getSessionsForProject:ie,getArchivedSessionsForProject:je}=g2({ownership:P}),ne=c.useMemo(()=>{if(t.isVSCode)return null;const Me=xb(e.homeDirectory)??h.chatSessions.map(Xe=>_a(Xe.directory)).find(Boolean)??null;if(!Me)return null;const st=Array.from(new Set([Me,...h.chatSessions.map(Xe=>gt(Xe.directory??null)).filter(Boolean)])).filter(Xe=>!!Xe).map(Xe=>({scopeKey:Xe,directory:Xe}));return{id:"managed-chats",label:"",branch:null,description:null,isMain:!0,worktree:null,directory:Me,folderScopeKey:Me,folderScopes:st,draftTarget:"chat",sessions:h.chatSessions.filter(Xe=>!Xe.time?.archived&&hC(Xe)).map(Xe=>ir(h.childrenMap,Xe))}},[h.chatSessions,h.childrenMap,t.isVSCode,e.homeDirectory]),Oe=c.useMemo(()=>ne?[ne]:mC,[ne]),{projectSections:Ve,groupSearchDataByGroup:ze,sectionsForRender:He,flatSectionsForRender:$e}=O2({normalizedProjects:t.projects,getSessionsForProject:ie,getArchivedSessionsForProject:je,availableWorktreesByProject:t.availableWorktreesByProject,projectRepoStatus:t.projectRepoStatus,projectRootBranches:t.projectRootBranches,gitBranches:t.gitBranches,lastRepoStatus:t.lastRepoStatus,buildGroupedSessions:V,hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,filterSessionNodesForSearch:Z,buildGroupSearchText:G,foldersMap:d,standaloneGroups:Oe}),R=e.onSearchMatchCountChange;c.useEffect(()=>()=>R(0),[R]);const pe=Jo(),Le=e.useGroupedSections?He:$e,_e=c.useMemo(()=>e.showInlineArchived?Le:Le.map(Me=>Me.groups.some(st=>st.isArchivedBucket)?{...Me,groups:Me.groups.filter(st=>!st.isArchivedBucket)}:Me),[Le,e.showInlineArchived]),lt=c.useCallback(Me=>$e.find(Xe=>Xe.project.id===Me)?.groups.find(Xe=>!Xe.isArchivedBucket)?.folderScopes??[],[$e]);c2({enabled:!0,normalizedProjects:t.projects,ownership:P,isSessionsLoading:e.isSessionsLoading,hasAuthoritativeGlobalSessions:h.hasAuthoritativeGlobalSessions,isWorktreeTopologyLoading:e.isWorktreeTopologyLoading,unresolvedWorktreeProjectPaths:e.unresolvedWorktreeProjectPaths,foldersMap:d,createFolder:m,addSessionToFolder:f});const{github:ht}=bn(),ot=gn(Me=>Me.status),ut=gn(Me=>Me.hasChecked),yt=Ps(Me=>Me.ensureEntry),mt=Ps(Me=>Me.setParams),xt=Ps(Me=>Me.refreshTargets),Dt=c.useRef(new Set);c.useEffect(()=>{if(!ht||!ut||!ot?.connected)return;const Me=new Map,st=Date.now();Ve.forEach(Xe=>{g.collapsedProjects.has(Xe.project.id)||Xe.groups.forEach(Ne=>{if(Ne.isArchivedBucket||Ne.isMain)return;const We=gt(Ne.directory??null),dt=Ne.branch?.trim()||t.gitBranches.get(We||"")?.trim();if(!We||!dt)return;const bt=Qo(We,dt),Se=Ps.getState().entries[bt],Je=Se?.status?.pr?.state==="closed"||Se?.status?.pr?.state==="merged",it=`${We}::${dt}`,pt=Math.max(Se?.lastRefreshAt??0,Se?.lastDiscoveryPollAt??0),kt=!!(Se?.isInitialStatusResolved&&(!Se.status?.pr||Je)&&(!Dt.current.has(it)||st-pt>=fC));(!Se||!Se.isInitialStatusResolved||kt)&&(kt&&Dt.current.add(it),Me.set(bt,{directory:We,branch:dt}))})}),Me.forEach((Xe,Ne)=>{yt(Ne),mt(Ne,{...Xe,remoteName:null,canShow:!0,github:ht,githubAuthChecked:ut,githubConnected:ot.connected})}),Me.size&&xt([...Me.values()],{silent:!0,markInitialResolved:!0})},[yt,ht,ut,ot?.connected,Ve,g.collapsedProjects,xt,mt,t.gitBranches]);const be=c.useMemo(()=>new Map(h.orderedSessions.map((Me,st)=>[Me.id,st])),[h.orderedSessions]),qe=c.useMemo(()=>le!=="manual"?_e:_e.map(Me=>{const st=x(Me.project.id,Me.groups);return st===Me.groups?Me:{...Me,groups:st}}),[x,_e,le]),Ye=c.useMemo(()=>{const Me=new Map(_.map(We=>[We.id,ir(h.childrenMap,We)])),st=[...Me.values()],Xe=[];for(;st.length>0;){const We=st.pop();if(!We)break;Xe.push(We.session),st.push(...We.children)}const Ne=wi({sessions:Xe,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,hideBranchMatchingProjectLabel:!0});return sp({sessions:_,getSessionLocation:We=>Ne.get(We)??null,getSessionNode:We=>Me.get(We.id)??ir(h.childrenMap,We),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[h.childrenMap,P.bySessionId,_,S,t.availableWorktreesByProject,t.gitBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),Ue=c.useMemo(()=>{if(!H)return dd;const Me=new Set(h.rootSessions.map(Ne=>Ne.id)),st=h.orderedSessions.filter(Ne=>Me.has(Ne.id)&&!Ne.time?.archived),Xe=wi({sessions:st,projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!1});return kl({sessions:st,getSessionLocation:Ne=>Xe.get(Ne)??null,getSessionNode:Ne=>({...ir(h.childrenMap,Ne),children:[],worktree:Xe.get(Ne.id)?.worktree??null}),query:e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:""})},[h.childrenMap,h.orderedSessions,h.rootSessions,P.bySessionId,S,H,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery]),ct=ye(Me=>Me.sessionWorkEnabled),X=c.useMemo(()=>{if(!ct)return ud;const Me=h.orderedSessions.filter(st=>!st.parentID&&!st.time?.archived&&!$a(st.directory)&&Wu(st));return Me.length>0?Me:ud},[h.orderedSessions,ct]),ae=c.useMemo(()=>new Set(X.map(Me=>Me.id)),[X]),De=c.useMemo(()=>{if(X.length===0)return dd;const Me=wi({sessions:[...X],projects:t.projects,ownerBySessionId:P.bySessionId,spaceLabelById:S,availableWorktreesByProject:t.availableWorktreesByProject,gitBranches:t.gitBranches,homeDirectory:e.homeDirectory,rootBranchByProjectId:t.projectRootBranches,hideBranchMatchingProjectLabel:!H}),st=new Map(X.map(We=>{const dt=ir(h.childrenMap,We),bt={...dt,children:H?[]:dt.children,worktree:Me.get(We.id)?.worktree??null};return[We.id,bt]})),Xe=e.hasSessionSearchQuery?e.normalizedSessionSearchQuery:"",Ne=Xe?X.filter(We=>{const dt=st.get(We.id);return dt?np(dt,Xe):!1}):[...X];return kl({sessions:Ne,getSessionLocation:We=>Me.get(We)??null,getSessionNode:We=>st.get(We.id)??ir(h.childrenMap,We),query:""})},[h.childrenMap,P.bySessionId,S,H,t.availableWorktreesByProject,t.gitBranches,t.projectRootBranches,t.projects,e.hasSessionSearchQuery,e.homeDirectory,e.normalizedSessionSearchQuery,X]),{groupStatusByKey:Ke,bootstrapSnapshot:q}=sC({childStores:pe,sections:qe,chatGroup:ne,canGrantAccess:Vd()});let Be=null;I&&(Ve.some(Me=>Me.project.id===W)?Be=W:Ve.some(Me=>Me.project.id===e.activeProjectId)?Be=e.activeProjectId:Be=Ve[0]?.project.id??null);const Ze=c.useMemo(()=>({hasSessionSearchQuery:e.hasSessionSearchQuery,normalizedSessionSearchQuery:e.normalizedSessionSearchQuery,groupSearchDataByGroup:ze,collapsedGroups:g.collapsedGroups,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:r,activeProjectId:e.activeProjectId,notifyOnSubtasks:i,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:be,expandedParents:ge,editingId:ue,editingRowKey:Re,editTitle:fe,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,setEditingId:de,setEditingRowKey:we,setEditTitle:Pe,toggleParent:Q,allowReselect:l.allowReselect,onSessionSelected:l.onSessionSelected,resetSessionSearch:l.resetSessionSearch,deleteSessionConfirm:ce,setDeleteSessionConfirm:he,startFolderRename:Te,startSessionWorktreeMenuLoad:n.startSessionWorktreeMenuLoad,onEditProject:H?a.openProjectEditDialog:void 0,folderRename:Y,setFolderRenameDraft:ke,clearFolderRename:xe}),[h.pinnedSessionIds,r,i,g.collapsedGroups,ze,be,fe,ue,Re,ge,Y,ke,xe,Te,ce,n.startSessionWorktreeMenuLoad,a.openProjectEditDialog,H,l,Q,e.hideDirectoryControls,e.hasSessionSearchQuery,e.activeProjectId,e.mobileVariant,e.normalizedSessionSearchQuery,e.useGroupedSections,I]),Qe=c.useMemo(()=>({showMoreGroupSessions:D,resetGroupSessionLimit:U,setActiveProjectIdOnly:a.setActiveProjectIdOnly,setSessionSwitcherOpen:a.setSessionSwitcherOpen,openNewSessionDraft:a.openNewSessionDraft,onToggleCollapsedGroup:j}),[U,D,j,a.openNewSessionDraft,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen]),et=c.useMemo(()=>{const Me=new Map;for(const st of qe)for(const Xe of st.groups){const Ne=Cn(st.project.id,Xe.directory);if(!Ne)continue;const We=Gr(Xe),dt=Me.get(Ne),bt=[...new Set([...dt?.scopeKeys??[],...We.map(Je=>Je.scopeKey)])],Se=h.hasAuthoritativeGlobalSessions&&We.every(Je=>{const it=gt(Je.directory);return!it||pe.getBootstrapState(it)==="complete"});Me.set(Ne,{scopeKeys:bt,complete:(dt?.complete??!0)&&Se})}if(ne){const st=Cn(null,ne.directory);st&&Me.set(st,{scopeKeys:Gr(ne).map(Xe=>Xe.scopeKey),complete:h.hasAuthoritativeGlobalSessions})}return Me},[q,ne,pe,h.hasAuthoritativeGlobalSessions,qe]),Ct=c.useMemo(()=>new Map([...C,...F]),[F,C]),Ge=c.useMemo(()=>E2({mode:e.hasSessionSearchQuery?"search":"normal",viewMode:H?"timeline":"projects",sections:qe,authoritativeSections:Ve,chatGroup:ne,recentSections:Ye,timelineItems:Ue,workItems:De,workSessionIds:ae,showRecentSection:A&&!I&&!H,foldersMap:d,groupSearchDataByGroup:ze,normalizedQuery:e.normalizedSessionSearchQuery,collapsedProjects:g.collapsedProjects,collapsedGroups:g.collapsedGroups,collapsedFolders:u,collapsedActivities:O,expandedParents:ge,visibleCountByContainer:Ct,pinnedSessionIds:h.pinnedSessionIds,sessionOrderIndex:be,groupStatusByKey:Ke,folderAuthorityByOwner:et,activeProjectId:e.activeProjectId,singleProjectMode:I&&!H,singleProjectId:Be,showOnlyMainWorkspace:e.showOnlyMainWorkspace,hideDirectoryControls:e.hideDirectoryControls,sessionBatchSize:I&&!e.useGroupedSections?20:void 0,runIndex:se}),[se,ne,O,Ue,H,De,ae,u,h.pinnedSessionIds,ge,et,d,ze,Ke,qe,Ve,g.collapsedGroups,g.collapsedProjects,Ye,Be,be,A,I,e.activeProjectId,e.hasSessionSearchQuery,e.hideDirectoryControls,e.normalizedSessionSearchQuery,e.showOnlyMainWorkspace,e.useGroupedSections,Ct]);c.useEffect(()=>{R(Ge.searchMatchCount)},[R,Ge.searchMatchCount]);const Tt=c.useMemo(()=>({rowModel:Ge,sectionsForRender:qe,projectSections:Ve,singleProjectMode:I,emptyState:e.emptyState,searchEmptyState:e.searchEmptyState,projectRepoStatus:t.projectRepoStatus,state:{editingId:ue,openSidebarMenuKey:L,setOpenSidebarMenuKey:oe,visibleSessionCountByGroup:C,collapsedActivityKeys:O,setCollapsedActivityKeys:M,visibleActivityCountByKey:F,setVisibleActivityCountByKey:K},groupProps:Ze}),[Ze,ue,L,Ve,qe,Ge,t.projectRepoStatus,e.emptyState,e.searchEmptyState,C,F,O,I]),Bt=c.useMemo(()=>({homeDirectory:e.homeDirectory,hasSessionSearchQuery:e.hasSessionSearchQuery,hideDirectoryControls:e.hideDirectoryControls,stickyZoneHeaders:e.stickyZoneHeaders,mobileVariant:e.mobileVariant,alwaysShowActions:r,projectSortOrder:e.projectSortOrder,worktreeSortOrder:le,timelineView:H}),[H,le,e.homeDirectory,e.hasSessionSearchQuery,e.hideDirectoryControls,e.mobileVariant,r,e.projectSortOrder,e.stickyZoneHeaders]),Ce=c.useMemo(()=>({group:Qe,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:k}),[Qe,a.openNewSessionDraft,a.openNewWorktreeDialog,a.openProjectEditDialog,a.openWorktreesPage,a.removeProject,a.reorderProjects,a.setActiveProjectIdOnly,a.setSessionSwitcherOpen,b,y,a.renderProjectStatusIndicator,k]);return s.jsxs(s.Fragment,{children:[s.jsx(o2,{}),s.jsx(m2,{projectSections:Ve,activeProjectId:e.activeProjectId,initialActiveSessionByProject:n.initialActiveSessionByProject,persistActiveSessionByProject:n.persistActiveSessionByProject,mobileVariant:e.mobileVariant,openNewSessionDraft:n.openNewSessionDraft,setSessionSwitcherOpen:n.setSessionSwitcherOpen,sessionOwnerBySessionId:P.bySessionId,handleSessionSelect:J}),s.jsx(z2,{sortedSessions:h.orderedSessions,recentSessions:_,prefetchSession:me}),s.jsxs(nk,{entries:Ge.selectionEntries,descendantIds:Ge.selectionDescendantIds,sessionsById:Ge.sessionById,children:[s.jsx(K3,{getFolderScopesForProject:lt,isInlineEditing:ue!==null,startFolderRename:Te}),s.jsx(T3,{model:Tt,view:Bt,actions:Ce})]})]})},gC=t=>{const e=nt.c(2);let n;return e[0]!==t?(n=t.view.isVisible?s.jsx(pC,{...t}):null,e[0]=t,e[1]=n):n=e[1],n},cm=(t,e,n)=>{const r=new Set;for(const i of t){const o=gt(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=gt(o.path);l&&r.add(l)}return r},fd="oc.sessions.activeSessionByProject",bC=[],xC=of(Hn(),Hn().min(1).catch("")),yC=({isVisible:t=!0,mobileVariant:e=!1,onSessionSelected:n,allowReselect:r=!1,hideDirectoryControls:i=!1,showOnlyMainWorkspace:o=!1})=>{_i("react.session_sidebar_render"),ws("ui.session_sidebar.render"),ws(`ui.session_sidebar.render.${e?"mobile":"desktop"}`),ws(`ui.session_sidebar.render.${t?"visible":"hidden"}`);const{t:l}=At(),[a,d]=c.useState(!1),[u,m]=c.useState(""),f=c.useCallback(()=>{m(""),d(!1)},[]),[g,x]=c.useState(0),b=c.useRef(null),j=c.useRef(null),[y,h]=c.useState(null),p=c.useMemo(()=>Bo(),[]),[w,S]=c.useState(new Map),N=ye(Ce=>Ce.isNewWorktreeDialogOpen),P=ye(Ce=>Ce.setNewWorktreeDialogOpen),[C,T]=c.useState(!1),O=c.useMemo(()=>{try{const Ce=p.getItem(fd);if(!Ce)return new Map;const Me=xC.safeParse(JSON.parse(Ce));if(!Me.success)return new Map;const st=new Map;return Object.entries(Me.data).forEach(([Xe,Ne])=>{Ne&&st.set(Xe,Ne)}),st}catch{return new Map}},[p]),M=c.useCallback(Ce=>{try{p.setItem(fd,JSON.stringify(Object.fromEntries(Ce.entries())))}catch{}},[p]),[F,K]=c.useState(new Map),D=ts(Ce=>Ce.homeDirectory),U=Kt(Ce=>Ce.projects),A=Kt(Ce=>Ce.activeProjectId),E=Kt(Ce=>Ce.removeProject),W=Kt(Ce=>Ce.setActiveProjectIdOnly),k=Kt(Ce=>Ce.updateProjectMeta),v=Kt(Ce=>Ce.reorderProjects),I=ye(Ce=>Ce.setSettingsDialogOpen),H=ye(Ce=>Ce.toggleHelpDialog),_=ye(Ce=>Ce.setAboutDialogOpen),se=ye(Ce=>Ce.setSessionSwitcherOpen),te=ye(Ce=>Ce.setScheduledTasksDialogOpen),ee=ye(Ce=>Ce.setArchivePageOpen),ue=ye(Ce=>Ce.setUsageStatsPageOpen),de=ye(Ce=>Ce.setWorktreesPageProjectId),Re=ye(Ce=>Ce.notifyOnSubtasks),we=c.useMemo(()=>u.trim().toLowerCase(),[u]),fe=we.length>0;P0({enabled:t,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:j,sessionSearchContainerRef:b});const Pe=Iu(t),L=c.useMemo(()=>Pn(),[]),oe=rt(Ce=>Ce.setCurrentSession),ce=rt(Ce=>Ce.worktreeMetadata),he=rt(Ce=>Ce.availableWorktreesByProject),Y=rt(Ce=>Ce.openNewSessionDraft),ve=c.useMemo(()=>cm(U,he,{includeWorktrees:!L}),[he,L,U]),Te=c.useCallback(Ce=>{ye.getState().closeMainSurfaces(),Y(Ce),L&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[L,Y]),ke=Fr(Un(Ce=>({checkForUpdates:Ce.checkForUpdates,available:Ce.available,runtimeType:Ce.runtimeType,info:Ce.info,downloading:Ce.downloading,downloaded:Ce.downloaded,progress:Ce.progress,error:Ce.error,downloadUpdate:Ce.downloadUpdate,restartToUpdate:Ce.restartToUpdate}))),xe=Yt(),ge=c.useMemo(()=>`${xe}|${U.map(Ce=>`${Ce.id}:${gt(Ce.path)??""}`).join("|")}`,[U,xe]),[Q,$]=c.useState(L?ge:null),[J,me]=c.useReducer(Ce=>Ce+1,0),le=!L&&Q!==ge,[V,Z]=c.useState(new Set),G=c.useRef(V);G.current=V;const ie=Vt(Ce=>Ce.isConnected),je=c.useRef({runtimeKey:null,revision:0,worktreesByProject:new Map});c.useEffect(()=>{let Ce=!1;return(async()=>{const st=xe,Xe=Vt.getState().isConnected,Ne=Kt.getState().projects;if(rt.setState({worktreeDiscoveryByProject:new Map(Ne.map(Mt=>[gt(Mt.path)??Mt.path,"loading"]))}),Ne.length===0||L){Ce||(je.current={runtimeKey:null,revision:0,worktreesByProject:new Map},Z(new Set),$(ge));return}const We=rt.getState().availableWorktreesByProject,dt=nl({rawWorktreesByProjectRef:je,publishedWorktreesByProject:We,runtimeKey:st}),bt=dt.revision,Se=new Map(dt.worktreesByProject),Je=new Set,it=3;let pt=0;const kt=Array.from({length:it},async()=>{for(;;){const Mt=pt;if(pt+=1,Mt>=Ne.length)return;const Lt=Ne[Mt],Wt=gt(Lt.path);if(Wt)try{const Jt=await qi(async()=>Xn.getState().directories.get(Wt)?.isGitRepo??await uu(Wt)?_l({id:Lt.id,path:Wt}):null);if(Jt===null){Se.delete(Wt);continue}if(Ce)return;Jt.length===0?Se.delete(Wt):Se.set(Wt,Jt)}catch{Je.add(Wt)}}});if(await Promise.all(kt),Ce||Yt()!==st)return;const _t=new Set(Ne.map(Mt=>gt(Mt.path)).filter(Boolean));for(const Mt of Se.keys())_t.has(Mt)||Se.delete(Mt);xk({rawWorktreesByProjectRef:je,runtimeKey:st,capturedRevision:bt,nextRawWorktreesByProject:Se,publishedWorktreesByProject:We,partitionWorktreesByRegisteredProject:Ll,projects:Ne,worktreeMapsEqual:Fl,recordWorktreesSeen:ad,publishTopology:Mt=>{rt.setState(Mt)},requestRediscovery:()=>{me()},now:()=>Date.now()})&&(Z(Je),rt.setState({worktreeDiscoveryByProject:new Map(Ne.map(Mt=>{const Lt=gt(Mt.path)??Mt.path;return[Lt,Je.has(Lt)?"error":"ready"]}))}),$(ge),Je.size>0&&!Xe&&Vt.getState().isConnected&&me())})(),()=>{Ce=!0}},[L,ge,xe,J]),c.useEffect(()=>{ie&&G.current.size>0&&me()},[ie]);const ne=c.useMemo(()=>hn(),[]),{isTablet:Oe}=Dn(),Ve=e||Oe,ze=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]),He=c.useMemo(()=>U.find(Ce=>Ce.id===y)??null,[U,y]),$e=c.useCallback(Ce=>{y&&k(y,{label:Ce.label,icon:Ce.icon,color:Ce.color,iconBackground:Ce.iconBackground,defaultAgent:Ce.defaultAgent??null,defaultModel:Ce.defaultModel??null,defaultVariant:Ce.defaultVariant??null})},[y,k]),R=c.useCallback(()=>{P(!0)},[P]),pe=c.useCallback(()=>{const Ce=Fr.getState();if(Ce.available&&Ce.info){T(!0);return}ke.checkForUpdates().then(()=>{const{available:Me,error:st}=Fr.getState();if(st){Fe.error(l("sessions.sidebar.updateCheck.errorTitle"),{description:st});return}if(!Me){Fe.success(l("sessions.sidebar.updateCheck.latestVersion"));return}T(!0)})},[l,ke]),Le=c.useCallback(()=>{e&&se(!1),I(!0)},[e,se,I]),_e=ke.available&&(ke.runtimeType==="desktop"||ke.runtimeType==="web"),lt=c.useCallback(()=>{Us.requestDirectoryDialog()},[]),ht=c.useMemo(()=>U.flatMap(Ce=>{const Me=gt(Ce.path);return Me?[{id:Ce.id,path:Ce.path,label:Ce.label,normalizedPath:Me,icon:Ce.icon??void 0,color:Ce.color??void 0,iconImage:Ce.iconImage??void 0,iconBackground:Ce.iconBackground??void 0,addedAt:Ce.addedAt,lastOpenedAt:Ce.lastOpenedAt,sidebarCollapsed:Ce.sidebarCollapsed}]:[]}),[U]),ot=c.useMemo(()=>ht.map(Ce=>Ce.normalizedPath),[ht]),ut=yb(t?ot:bC);B0({enabled:t,normalizedProjects:ht,gitRepoStatus:ut,setProjectRepoStatus:S,setProjectRootBranches:K});const yt=rt(Ce=>Ce.isLoading),mt=c.useRef(!1);A&&w.has(A)&&(mt.current=!!w.get(A));const xt=as(Ce=>Ce.showArchivedSessions),Dt=as(Ce=>Ce.projectSortOrder),be=as(Ce=>Ce.sidebarViewMode),qe=Kt(Ce=>Ce.manualProjectOrder),Ye={isVisible:t,mobileVariant:e,onSessionSelected:n,allowReselect:r,hideDirectoryControls:i,showOnlyMainWorkspace:o,t:l,isTablet:Oe,projects:U,activeProjectId:A,manualProjectOrder:qe,worktreeMetadata:ce,availableWorktreesByProject:he,gitBranches:Pe,gitRepoStatus:ut,updateStore:ke,showArchivedSessions:xt,projectSortOrder:Dt,projectRepoStatus:w,projectRootBranches:F,resolvedWorktreeTopologyKey:Q,unresolvedWorktreeProjectPaths:V,isSessionSearchOpen:a,sessionSearchQuery:u,editingProjectDialogId:y,updateDialogOpen:C},Ue=c.useRef(null),ct=Ue.current;if(ct){let Ce=!1;for(const Me of Object.keys(Ye))Object.is(ct[Me],Ye[Me])||(ws(`ui.session_sidebar.source.${Me}`),Ce=!0);Ce||ws("ui.session_sidebar.source.parent_or_context")}Ue.current=Ye;const X=c.useMemo(()=>rp(ht,Dt,qe),[ht,Dt,qe]),ae=E0({isVSCode:L,projects:X}),De=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]),Ke=L&&xt,q=!L,Be=L?"projects":be,Ze=Be==="projects",Ct=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",Ge="h-4.5 w-4.5",Tt=c.useMemo(()=>({projects:U,getCurrentProjects:()=>Kt.getState().projects,rawWorktreesByProjectRef:je,getPublishedWorktreesByProject:()=>rt.getState().availableWorktreesByProject,resolveProject:Ce=>Vi(Ce),listProjectWorktrees:_l,partitionWorktreesByRegisteredProject:Ll,worktreeMapsEqual:Fl,recordWorktreesSeen:ad,publishTopology:Ce=>{rt.setState(Ce)},getRuntimeKey:Yt,now:()=>Date.now()}),[U]),Bt=c.useCallback(Ce=>{const Me=rm(Ce,{projects:U,resolveProject:Vi});return bk(Ce,{...Tt,projectRootBranch:Me?F.get(Me.id)??null:null})},[F,U,Tt]);return c.useEffect(()=>{if(!L)return In(Ce=>{if(Ce.type==="session-created"){me();return}if(Ce.type==="worktree-changed")for(const Me of wb(Ce.directories)){const st=gt(Me.path),Xe=Yt(),Ne=We=>{!st||Yt()!==Xe||rt.setState(dt=>({worktreeDiscoveryByProject:new Map(dt.worktreeDiscoveryByProject).set(st,We)}))};Ne("loading"),sm(Me,null,Tt).then(()=>{!st||Yt()!==Xe||(Ne("ready"),Z(We=>{if(!We.has(st))return We;const dt=new Set(We);return dt.delete(st),dt}))}).catch(()=>{!st||Yt()!==Xe||(Ne("error"),Z(We=>new Set(We).add(st)))})}})},[L,Tt]),s.jsx(Xi,{delay:400,closeDelay:0,timeout:300,children:s.jsxs("div",{ref:b,className:Ie("relative flex h-full flex-col text-foreground overflow-x-hidden",e?"":"bg-transparent"),children:[s.jsx(W0,{hideDirectoryControls:i,showProjectDisplayControls:!L,showRecentControls:!L,handleOpenDirectoryDialog:lt,onOpenScheduled:()=>{e&&se(!1),te(!0)},onOpenArchive:()=>{e&&se(!1),ee(!0)},headerActionIconClass:Ge,headerActionButtonClass:Ct,isSessionSearchOpen:a,setIsSessionSearchOpen:d,sessionSearchInputRef:j,sessionSearchQuery:u,setSessionSearchQuery:m,hasSessionSearchQuery:fe,searchMatchCount:g,collapseAllProjects:ae.actions.collapseAllProjects,expandAllProjects:ae.actions.expandAllProjects}),s.jsx(gC,{topology:{projects:X,availableWorktreesByProject:he,knownDirectories:ve,isVSCode:L,worktreeMetadata:ce,gitBranches:Pe,projectRepoStatus:w,projectRootBranches:F,lastRepoStatus:mt.current},view:{isVisible:t,hasSessionSearchQuery:fe,normalizedSessionSearchQuery:we,activeProjectId:A,showInlineArchived:Ke,useGroupedSections:q,homeDirectory:D,mobileVariant:e,hideDirectoryControls:i,showOnlyMainWorkspace:o,isDesktopShellRuntime:ne,stickyZoneHeaders:Ze,projectSortOrder:Dt,sidebarViewMode:Be,emptyState:ze,searchEmptyState:De,isSessionsLoading:yt,isWorktreeTopologyLoading:le,unresolvedWorktreeProjectPaths:V,projectView:ae.state,onSearchMatchCountChange:x},actions:{rowActions:{allowReselect:r,onSessionSelected:n,resetSessionSearch:f},alwaysShowActions:Ve,notifyOnSubtasks:Re,setActiveProjectIdOnly:W,setSessionSwitcherOpen:se,openNewSessionDraft:Te,openNewWorktreeDialog:R,openWorktreesPage:Ce=>{e&&se(!1),de(Ce)},openProjectEditDialog:h,removeProject:E,reorderProjects:v,startSessionWorktreeMenuLoad:Bt,initialActiveSessionByProject:O,persistActiveSessionByProject:M,projectViewActions:ae.actions}}),s.jsx(n2,{onOpenSettings:Le,onOpenUsage:()=>ue(!0),onOpenShortcuts:H,onOpenAbout:()=>_(!0),onOpenUpdate:pe,showRuntimeButtons:!L,showUpdateButton:_e}),s.jsx(Gd,{open:C,onOpenChange:T,info:ke.info,downloading:ke.downloading,downloaded:ke.downloaded,progress:ke.progress,error:ke.error,onDownload:ke.downloadUpdate,onRestart:ke.restartToUpdate,runtimeType:ke.runtimeType}),s.jsx(z0,{open:!!He,onOpenChange:Ce=>{Ce||h(null)},project:He,onSave:$e}),s.jsx(op,{open:N,onOpenChange:P,onWorktreeCreated:(Ce,Me)=>{if(ye.getState().closeMainSurfaces(),e&&se(!1),Me?.sessionId){oe(Me.sessionId,Ce);return}Y({directoryOverride:Ce,preserveDirectoryOverride:!0})}})]})})},wC=c.memo(yC),an=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,Ks=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},vC=()=>{const{t}=At(),[e,n]=c.useState(!1),[r,i]=c.useState(!1),[o,l]=c.useState(null),[a,d]=c.useState([]),[u,m]=c.useState(!1),[f,g]=c.useState(!1),[x,b]=c.useState(!1),[j,y]=c.useState(!1),[h,p]=c.useState(new Set),w=rt(Q=>Q.getWorktreeMetadata),S=rt(Q=>Q.newSessionDraft),N=rt(Q=>Q.setNewSessionDraftTarget),P=rt(Q=>Q.setDraftBootstrapPendingDirectory),C=vb,T=rt(Q=>Q.deleteSessions),O=rt(Q=>Q.archiveSessions),M=ye(Q=>Q.showDeletionDialog),F=ye(Q=>Q.setShowDeletionDialog),K=ts(Q=>Q.currentDirectory),D=ts(Q=>Q.homeDirectory),U=ts(Q=>Q.isHomeReady),A=Kt(Q=>Q.projects),E=Kt(Q=>Q.activeProjectId),{isMobile:W,isTablet:k,hasTouchInput:v}=Dn(),I=W||k||v,H=c.useMemo(()=>{const $=(E?A.find(J=>J.id===E)??null:null)?.path??K;return Ks($)},[E,K,A]),_=c.useCallback(Q=>{const J=Ks(Q.projectDirectory)||H;return{id:(A.find(le=>Ks(le.path)===J)??null)?.id??`path:${J}`,path:J}},[H,A]),se=j&&h.size>0,te=c.useMemo(()=>{const Q=o?.worktree;return Q&&typeof Q.branch=="string"&&Q.branch.trim().length>0?!0:a.length>0&&a.every(({metadata:$})=>typeof $.branch=="string"&&$.branch.trim().length>0)},[o?.worktree,a]),ee=o?.mode==="worktree",ue=ee,de=x||!ee||!te,Re=x||!ee;c.useEffect(()=>{r||!U||A.length>0||(i(!0),n(!0))},[r,U,A.length]);const we=c.useCallback(Q=>{l({sessions:Q.sessions,dateLabel:Q.dateLabel,mode:Q.mode??"session",worktree:Q.worktree??null})},[]),fe=c.useCallback(()=>{l(null),d([]),m(!1),g(!1),b(!1),y(!1),p(new Set)},[]),Pe=c.useCallback(async Q=>{if(Q.sessions.length===0)return;if(Q.sessions.length===1){const le=Q.sessions[0];await C(le.id)?Fe.success(t("sessions.sidebar.session.delete.success")):Fe.error(t("sessions.sidebar.session.delete.error"));return}const $=Q.sessions.map(le=>le.id),{deletedIds:J,failedIds:me}=await T($);if(J.length>0){const le=me.length>0?me.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:me.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:me.length}):Q.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:Q.dateLabel}):void 0;Fe.success(J.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:J.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:J.length}),{description:an(le)})}me.length>0&&Fe.error(me.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:me.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:me.length}),{description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[C,T,t]);c.useEffect(()=>Us.onDeleteRequest(Q=>{if(!M&&(Q.mode??"session")==="session"){Pe(Q);return}we(Q)}),[we,M,Pe]),c.useEffect(()=>Us.onDirectoryRequest(()=>{n(!0)}),[]),c.useEffect(()=>{if(!o){d([]),m(!1),g(!1),y(!1),p(new Set);return}const Q=o.sessions.map(me=>{const le=w(me.id);return le?{session:me,metadata:le}:null}).filter(me=>!!me);d(Q),m(!1),y(!1),p(new Set);const $=new Map;if(o.worktree?.path&&$.set(Ks(o.worktree.path),o.worktree),Q.forEach(({metadata:me})=>{me.path&&$.set(Ks(me.path),me)}),$.size===0){y(!0);return}let J=!1;return(async()=>{const me=new Map,le=new Set;await Promise.all(Array.from($.entries()).map(async([V,Z])=>{try{const G=await Sb(Z.path);me.set(V,G),G?.isDirty&&le.add(V)}catch{Z.status&&(me.set(V,Z.status),Z.status.isDirty&&le.add(V))}})).catch(V=>{console.warn("Failed to inspect worktree status before deletion:",V)}),!J&&(p(le),y(!0),l(V=>{if(!V?.worktree?.path)return V;const Z=Ks(V.worktree.path),G=me.get(Z);if(!G)return V;const ie=V.worktree.status;return ie?.isDirty===G.isDirty&&ie?.ahead===G.ahead&&ie?.behind===G.behind&&ie?.upstream===G.upstream?V:{...V,worktree:{...V.worktree,status:G}}}),d(V=>V.map(Z=>{const G=Ks(Z.metadata.path),ie=me.get(G);return ie?{session:Z.session,metadata:{...Z.metadata,status:ie}}:Z})))})(),()=>{J=!0}},[o,w]),c.useEffect(()=>{te||m(!1)},[te]);const L=c.useCallback(async(Q,$,J)=>{const me=u&&te,le=_(Q),V=Ks(Q.path),Z=Ks(le.path);try{await fu(le,Q,{deleteRemoteBranch:me,deleteLocalBranch:$});const G=Ks(S?.directoryOverride);return S?.open&&V&&G===V&&Z&&(P(null),N({projectId:le.id,directoryOverride:Z},{force:!0})),Ks(K)===V&&Z&&ts.getState().setDirectory(Z,{showOverlay:!1}),!0}catch(G){return Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:Si(Q)}),{id:J,description:an(G instanceof Error?G.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[te,K,u,_,S?.directoryOverride,S?.open,P,N,t]),oe=c.useCallback((Q,$,J)=>{const me=u&&te,le=Fe.loading(t("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:Si(Q)}));(async()=>{try{if($.length>0){const{failedIds:G}=await O($);if(G.length>0){Fe.error(G.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:G.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:G.length}),{id:le,description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))});return}}if(!await L(Q,J,le))return;const Z=t(me?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");Fe.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:Si(Q)}),{id:le,description:an(Z)})}catch(V){Fe.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{id:le,description:an(V instanceof Error?V.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})}})()},[O,te,u,L,t]),ce=c.useCallback(async()=>{if(o){b(!0);try{const Q=ue,$=Q&&u,J=Q&&f;if(ee&&o.worktree){oe(o.worktree,o.sessions.map(me=>me.id),J),fe();return}if(o.sessions.length===1){const me=o.sessions[0];if(!await C(me.id)){Fe.error(t("sessions.sidebar.session.delete.error")),b(!1);return}const V=!ee&&Q?t($?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;Fe.success(t("sessions.sidebar.session.delete.success"),{description:an(V),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const me=o.sessions.map(G=>G.id);let le=[],V=[];const Z=await T(me);if(le=Z.deletedIds,V=Z.failedIds,le.length>0){const G=!ee&&Q?t($?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,je=[V.length>0?V.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:V.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:V.length}):o.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:o.dateLabel}):void 0,G].filter(Boolean).join(" ");Fe.success(le.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:le.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:le.length}),{description:an(je||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(V.length>0&&(Fe.error(V.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:V.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:V.length}),{description:an(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),le.length===0)){b(!1);return}}fe()}finally{b(!1)}}},[o,u,f,C,T,fe,ue,ee,oe,t]),he=o?.worktree??a[0]?.metadata??null,Y=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}):"",ve=o?s.jsxs("div",{className:Ie(ee?"space-y-3":"space-y-2"),children:[o.sessions.length>0&&s.jsxs("div",{className:Ie(ee?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[ee&&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:Ie(ee?"mt-2 space-y-1":"space-y-0.5"),children:[o.sessions.slice(0,5).map(Q=>s.jsxs("li",{className:Ie(ee?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Ie(!ee&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:Q.title||t("sessions.sidebar.session.untitled")})]},Q.id)),o.sessions.length>5&&s.jsx("li",{className:Ie(ee?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:o.sessions.length-5})})]})]}),ee?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(B,{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")}),he?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:he.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:he?Hr(he.path,D):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),se&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Te=ee?te?s.jsxs("button",{type:"button",onClick:()=>{de||m(Q=>!Q)},disabled:de,className:Ie("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",de?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[u?s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(B,{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,ke=ee?s.jsxs("button",{type:"button",onClick:()=>{Re||g(Q=>!Q)},disabled:Re,className:Ie("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Re?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[f?s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(B,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,xe=ee?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:[ke,Te]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:x,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ce,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(!M),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":!M,children:[M?s.jsx(B,{name:"checkbox-blank",className:"size-4"}):s.jsx(B,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{variant:"ghost",onClick:fe,disabled:x,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(ft,{variant:"destructive",onClick:ce,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")})]})]}),ge=ee?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:[I?s.jsx(Xo,{open:!!o,onClose:()=>{x||fe()},title:ge,footer:s.jsx("div",{className:"flex justify-end gap-2",children:xe}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Y&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Y}),ve]})}):s.jsx(Cs,{open:!!o,onOpenChange:Q=>{if(!Q){if(x)return;fe()}},children:s.jsxs(Ns,{className:Ie(ee?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Hs,{children:[s.jsxs(Ls,{className:Ie(ee&&"flex items-center gap-2"),children:[ee&&s.jsx(B,{name:"delete-bin",className:"h-5 w-5"}),ge]}),Y&&s.jsx(_s,{children:Y})]}),s.jsx("div",{className:Ie(ee&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:ve}),s.jsx(Qn,{className:"mt-2 gap-2 pt-1 pb-1",children:xe})]})}),s.jsx(ip,{open:e,onOpenChange:n})]})};function dm(t){if(!t||!t.trim())return{valid:!1,error:"required"};try{return af.CronExpressionParser.parse(t),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:"Invalid cron expression"}}}function SC(t,e,n=4){try{const r=e?{tz:e,currentDate:new Date}:{currentDate:new Date},i=af.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 jC=[{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"}],kC={"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"},_n=t=>kC[t]??t,um=[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",ka=typeof Intl<"u"&&typeof Intl.supportedValuesOf=="function"?[...new Set(Intl.supportedValuesOf("timeZone").map(_n))]:["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}`},Ro=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}`},CC=(t,e,n)=>{const r=Ro(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),NC=(t,e)=>{const n=t.getFullYear(),r=t.getMonth(),l=(new Date(n,r,1).getDay()-e+7)%7,a=new Date(n,r+1,0).getDate(),d=new Date(n,r,0).getDate(),u=[];for(let m=0;m<42;m+=1){const f=m-l+1;if(f<=0){const g=d+f;u.push({date:new Date(n,r-1,g),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},AC=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}},Mn=(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"},bd=t=>/^(0[1-9]|1[0-2])$/.test(t)?t:jr(t,{min:1,max:12}),Co=t=>/^[0-5][0-9]$/.test(t)?t:jr(t,{max:59}),PC=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:1,max:12,loop:!0}),xd=(t,e)=>jr(String(Number.parseInt(t,10)+e),{min:0,max:59,loop:!0}),DC=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}},IC=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}},TC=t=>{const e=new Intl.DateTimeFormat(t,{weekday:"short"}),n=new Date(2023,0,1);return um.map(r=>e.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+r)))},EC=(t,e)=>[...t.slice(e),...t.slice(0,e)],ys=t=>{const e=nt.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=nt.c(84),{value:n,onChange:r,use24Hour:i,hourAriaLabel:o,minuteAriaLabel:l,periodAriaLabel:a,amLabel:d,pmLabel:u}=t;let m;e[0]!==n?(m=AC(n),e[0]=n,e[1]=m):m=e[1];const f=m,g=at.useRef(null),x=at.useRef(null),[b,j]=at.useState(null),[y,h]=at.useState(null),p=at.useRef(null),w=at.useRef(null);let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=Q=>{p.current=Q,j(Q)},e[2]=S):S=e[2];const N=S;let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=Q=>{w.current=Q,h(Q)},e[3]=P):P=e[3];const C=P,T=_C,O=$C,M=zC;let F;e[4]!==r||e[5]!==f.meridiem||e[6]!==f.minute||e[7]!==i?(F=Q=>{const $=Q.replace(/\D/g,"").slice(0,2);N($),$.length===2&&(r(i?M(T($),f.minute):Mn(bd($),f.minute,f.meridiem)),N(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 K=F;let D;e[9]!==r||e[10]!==f.meridiem||e[11]!==f.minute||e[12]!==i?(D=()=>{const Q=p.current;if(Q!==null&&(N(null),Q.length!==0)){if(i){r(M(T(Q.padStart(2,"0")),f.minute));return}r(Mn(bd(Q.padStart(2,"0")),f.minute,f.meridiem))}},e[9]=r,e[10]=f.meridiem,e[11]=f.minute,e[12]=i,e[13]=D):D=e[13];const U=D;let A;e[14]!==r||e[15]!==f.hour12||e[16]!==f.hour24||e[17]!==f.meridiem||e[18]!==i?(A=Q=>{const $=Q.replace(/\D/g,"").slice(0,2);C($),$.length===2&&(r(i?M(f.hour24,Co($)):Mn(f.hour12,Co($),f.meridiem)),C(null))},e[14]=r,e[15]=f.hour12,e[16]=f.hour24,e[17]=f.meridiem,e[18]=i,e[19]=A):A=e[19];const E=A;let W;e[20]!==r||e[21]!==f.hour12||e[22]!==f.hour24||e[23]!==f.meridiem||e[24]!==i?(W=()=>{const Q=w.current;Q!==null&&(C(null),Q.length!==0&&r(i?M(f.hour24,Co(Q.padStart(2,"0"))):Mn(f.hour12,Co(Q.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]=W):W=e[25];const k=W;let v;e[26]!==r||e[27]!==f.hour12||e[28]!==f.hour24||e[29]!==f.meridiem||e[30]!==f.minute||e[31]!==i?(v=Q=>r(i?M(O(f.hour24,Q),f.minute):Mn(PC(f.hour12,Q),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]=v):v=e[32];const I=v;let H;e[33]!==r||e[34]!==f.hour12||e[35]!==f.hour24||e[36]!==f.meridiem||e[37]!==f.minute||e[38]!==i?(H=Q=>r(i?M(f.hour24,xd(f.minute,Q)):Mn(f.hour12,xd(f.minute,Q),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]=H):H=e[39];const _=H;let se;e[40]!==r||e[41]!==f.hour12||e[42]!==f.meridiem||e[43]!==f.minute?(se=Q=>{Q!==f.meridiem&&r(Mn(f.hour12,f.minute,Q))},e[40]=r,e[41]=f.hour12,e[42]=f.meridiem,e[43]=f.minute,e[44]=se):se=e[44];const te=se;let ee;e[45]!==U||e[46]!==I?(ee=Q=>{if(Q.key==="ArrowRight"){Q.preventDefault(),U(),x.current?.focus();return}(Q.key==="ArrowUp"||Q.key==="ArrowDown")&&(Q.preventDefault(),N(null),I(Q.key==="ArrowUp"?1:-1))},e[45]=U,e[46]=I,e[47]=ee):ee=e[47];const ue=ee;let de;e[48]!==k||e[49]!==_?(de=Q=>{if(Q.key==="ArrowLeft"&&(Q.currentTarget.selectionStart??0)===0){Q.preventDefault(),k(),g.current?.focus();return}(Q.key==="ArrowUp"||Q.key==="ArrowDown")&&(Q.preventDefault(),C(null),_(Q.key==="ArrowUp"?1:-1))},e[48]=k,e[49]=_,e[50]=de):de=e[50];const Re=de,we=i?"px-2":"pl-2 pr-1";let fe;e[51]!==we?(fe=Ie("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",we),e[51]=we,e[52]=fe):fe=e[52];const Pe=b??(i?f.hour24:f.hour12);let L;e[53]!==K?(L=Q=>K(Q.target.value),e[53]=K,e[54]=L):L=e[54];let oe;e[55]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>N(""),e[55]=oe):oe=e[55];let ce;e[56]!==U||e[57]!==o||e[58]!==ue||e[59]!==Pe||e[60]!==L?(ce=s.jsx("input",{ref:g,inputMode:"numeric",value:Pe,onChange:L,onKeyDown:ue,onFocus:oe,onBlur:U,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]=U,e[57]=o,e[58]=ue,e[59]=Pe,e[60]=L,e[61]=ce):ce=e[61];let he;e[62]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:":"}),e[62]=he):he=e[62];const Y=y??f.minute;let ve;e[63]!==E?(ve=Q=>E(Q.target.value),e[63]=E,e[64]=ve):ve=e[64];let Te;e[65]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>C(""),e[65]=Te):Te=e[65];let ke;e[66]!==k||e[67]!==l||e[68]!==Re||e[69]!==Y||e[70]!==ve?(ke=s.jsx("input",{ref:x,inputMode:"numeric",value:Y,onChange:ve,onKeyDown:Re,onFocus:Te,onBlur:k,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]=k,e[67]=l,e[68]=Re,e[69]=Y,e[70]=ve,e[71]=ke):ke=e[71];let xe;e[72]!==d||e[73]!==f.meridiem||e[74]!==a||e[75]!==u||e[76]!==te||e[77]!==i?(xe=i?null:s.jsxs(cn,{value:f.meridiem,onValueChange:Q=>te(Q),children:[s.jsx(dn,{"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(Zs,{})}),s.jsxs(un,{children:[s.jsx(us,{value:"AM",children:d}),s.jsx(us,{value:"PM",children:u})]})]}),e[72]=d,e[73]=f.meridiem,e[74]=a,e[75]=u,e[76]=te,e[77]=i,e[78]=xe):xe=e[78];let ge;return e[79]!==fe||e[80]!==ce||e[81]!==ke||e[82]!==xe?(ge=s.jsxs("div",{className:fe,children:[ce,he,ke,xe]}),e[79]=fe,e[80]=ce,e[81]=ke,e[82]=xe,e[83]=ge):ge=e[83],ge},wd=t=>new Date(t.getFullYear(),t.getMonth(),1),RC=()=>{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(),MC=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=_n(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:MC(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:_n(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}}},OC=(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(!dm(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")},BC=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))},FC=t=>{const e=nt.c(64),{draft:n,setDraft:r,locale:i,t:o}=t,l=n.schedule.cronExpression;let a;e[0]!==l?(a=l.trim()?dm(l):null,e[0]=l,e[1]=a):a=e[1];const d=a;let u;e:{if(!d?.valid||!l.trim()){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[2]=v):v=e[2],u=v;break e}let k;e[3]!==l||e[4]!==n.schedule.timezone?(k=SC(l,n.schedule.timezone),e[3]=l,e[4]=n.schedule.timezone,e[5]=k):k=e[5],u=k}const m=u;let f;e[6]!==n.schedule.timezone||e[7]!==i?(f=k=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(k),e[6]=n.schedule.timezone,e[7]=i,e[8]=f):f=e[8];const g=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(ys,{htmlFor:"sched-cron",required:!0,children:x}),e[11]=x,e[12]=b):b=e[12];let j;e[13]!==r?(j=k=>r(v=>({...v,schedule:{...v.schedule,cronExpression:k.target.value}})),e[13]=r,e[14]=j):j=e[14];let y;e[15]!==o?(y=o("sessions.scheduledTasks.editor.cronExpression.placeholder"),e[15]=o,e[16]=y):y=e[16];let h;e[17]!==l||e[18]!==j||e[19]!==y?(h=s.jsx(Wn,{id:"sched-cron",value:l,onChange:j,placeholder:y,className:"w-full max-w-xs font-mono"}),e[17]=l,e[18]=j,e[19]=y,e[20]=h):h=e[20];let p;e[21]!==l||e[22]!==d||e[23]!==o?(p=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]=p):p=e[24];let w;e[25]!==b||e[26]!==h||e[27]!==p?(w=s.jsxs("div",{className:"flex flex-col gap-1",children:[b,h,p]}),e[25]=b,e[26]=h,e[27]=p,e[28]=w):w=e[28];let S;e[29]!==g||e[30]!==m||e[31]!==o?(S=m.length>0?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("sessions.scheduledTasks.editor.cronExpression.nextRuns")}),s.jsx("span",{className:"typography-micro text-foreground",children:m.map(g).join(", ")})]}):null,e[29]=g,e[30]=m,e[31]=o,e[32]=S):S=e[32];let N;e[33]!==o?(N=o("sessions.scheduledTasks.editor.cronExpression.examples"),e[33]=o,e[34]=N):N=e[34];let P;e[35]!==N?(P=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[35]=N,e[36]=P):P=e[36];let C;e[37]!==r||e[38]!==o?(C=jC.map(k=>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(v=>({...v,schedule:{...v.schedule,cronExpression:k.expression}})),children:[s.jsx("span",{className:"font-mono",children:k.expression}),s.jsx("span",{className:"text-muted-foreground",children:o(k.labelKey)})]},k.expression)),e[37]=r,e[38]=o,e[39]=C):C=e[39];let T;e[40]!==C?(T=s.jsx("div",{className:"flex flex-wrap gap-1.5",children:C}),e[40]=C,e[41]=T):T=e[41];let O;e[42]!==P||e[43]!==T?(O=s.jsxs("div",{className:"flex flex-col gap-1",children:[P,T]}),e[42]=P,e[43]=T,e[44]=O):O=e[44];let M;e[45]!==o?(M=o("sessions.scheduledTasks.editor.timezone.label"),e[45]=o,e[46]=M):M=e[46];let F;e[47]!==M?(F=s.jsx(ys,{children:M}),e[47]=M,e[48]=F):F=e[48];let K;e[49]!==r?(K=k=>{r(v=>({...v,schedule:{...v.schedule,timezone:k}}))},e[49]=r,e[50]=K):K=e[50];let D;e[51]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(dn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Zs,{})}),e[51]=D):D=e[51];let U;e[52]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(un,{children:ka.map(WC)}),e[52]=U):U=e[52];let A;e[53]!==n.schedule.timezone||e[54]!==K?(A=s.jsxs(cn,{value:n.schedule.timezone,onValueChange:K,children:[D,U]}),e[53]=n.schedule.timezone,e[54]=K,e[55]=A):A=e[55];let E;e[56]!==F||e[57]!==A?(E=s.jsxs("div",{className:"flex flex-col gap-1",children:[F,A]}),e[56]=F,e[57]=A,e[58]=E):E=e[58];let W;return e[59]!==w||e[60]!==S||e[61]!==O||e[62]!==E?(W=s.jsxs("div",{className:"flex flex-col gap-3",children:[w,S,O,E]}),e[59]=w,e[60]=S,e[61]=O,e[62]=E,e[63]=W):W=e[63],W};function LC(t){const{open:e,task:n,onOpenChange:r,onSave:i}=t,{t:o,locale:l}=At(),a=Vt(R=>R.loadProviders),d=Vt(R=>R.loadAgents),u=Vt(R=>R.providers),m=Vt(R=>R.currentProviderId),f=Vt(R=>R.currentModelId),g=Vt(R=>R.currentVariant||""),x=Vt(R=>R.currentAgentName||""),b=ye(R=>R.timeFormatPreference),j=ye(R=>R.weekStartPreference),y=ye(R=>R.isMobile),[h,p]=at.useState(()=>Sd(n,{providerID:m,modelID:f,variant:g,agent:x})),[w,S]=at.useState(!1),[N,P]=at.useState(!1),[C,T]=at.useState(!1),[O,M]=at.useState(""),[F,K]=at.useState(!1),[D,U]=at.useState(""),[A,E]=at.useState(!1),[W,k]=at.useState(""),[v,I]=at.useState(()=>{const R=Ro(n?.schedule?.date||"")||new Date;return new Date(R.getFullYear(),R.getMonth(),1)}),H=at.useRef(null),_=at.useRef(null),se=at.useRef(null),te=at.useRef(null),ee=at.useRef(null),ue=at.useMemo(()=>IC(l),[l]),de=at.useMemo(()=>DC(l),[l]),Re=at.useMemo(()=>b==="24h"?!0:b==="12h"?!1:ue,[b,ue]),we=at.useMemo(()=>j==="sunday"?0:j==="monday"?1:de,[j,de]),fe=at.useMemo(()=>{const R=TC(l);return EC(um.map(pe=>({value:pe,label:R[pe]||""})),we)},[l,we]);at.useEffect(()=>{e&&(a({source:"scheduledTaskEditor"}),d({source:"scheduledTaskEditor"}))},[e,a,d]),at.useEffect(()=>{if(!e)return;p(Sd(n,{providerID:m,modelID:f,variant:g,agent:x}));const R=Ro(n?.schedule?.date||"")||new Date;I(new Date(R.getFullYear(),R.getMonth(),1)),P(!1),K(!1),T(!1),U(""),M("")},[e,n,m,f,g,x]),at.useEffect(()=>{if(!N)return;const R=pe=>{H.current&&!H.current.contains(pe.target)&&P(!1)};return document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[N]);const Pe=at.useMemo(()=>{const pe=u.find(Le=>Le.id===h.execution.providerID)?.models?.find(Le=>Le.id===h.execution.modelID);return jb(pe?.variants)},[u,h.execution.providerID,h.execution.modelID]),L=Pe.length>0,oe=at.useMemo(()=>!L||!h.execution.variant?"__default":Pe.includes(h.execution.variant)?h.execution.variant:"__default",[h.execution.variant,L,Pe]);at.useEffect(()=>{L||!h.execution.variant||p(R=>({...R,execution:{...R.execution,variant:""}}))},[L,h.execution.variant]);const ce=at.useCallback((R,pe)=>{p(Le=>{const _e=new Set(Le.schedule.weekdays);return pe?_e.add(R):_e.delete(R),{...Le,schedule:{...Le.schedule,weekdays:Array.from(_e).sort((lt,ht)=>lt-ht)}}})},[]),he=at.useCallback((R,pe)=>{p(Le=>{const _e=Le.schedule.times.slice();return _e[R]=pe,{...Le,schedule:{...Le.schedule,times:_e}}})},[]),Y=at.useCallback(R=>{p(pe=>{const Le=pe.schedule.times.filter((_e,lt)=>lt!==R);return{...pe,schedule:{...pe.schedule,times:Le.length>0?Le:["09:00"]}}})},[]),ve=at.useCallback(()=>{p(R=>({...R,schedule:{...R.schedule,times:[...R.schedule.times,"12:00"]}}))},[]),Te=at.useMemo(()=>RC(),[]),ke=at.useMemo(()=>wd(Te),[Te]),xe=at.useMemo(()=>{const R=Ro(h.schedule.onceDate);return R?vd(R,Te)?o("sessions.scheduledTasks.editor.date.today"):new Intl.DateTimeFormat(l,{weekday:"short"}).format(R):null},[h.schedule.onceDate,l,o,Te]),ge=at.useMemo(()=>wd(v).getTime()<=ke.getTime(),[v,ke]),Q=at.useMemo(()=>fe.map(R=>R.label),[fe]),$=at.useCallback(R=>{p(pe=>({...pe,schedule:{...pe.schedule,onceDate:R}}))},[]),J=at.useCallback((R,pe)=>{if(R.startsWith("/")){const ht=R.indexOf(" "),ot=R.indexOf(`
883
+ `),ut=Math.min(ht===-1?R.length:ht,ot===-1?R.length:ot);if(pe<=ut&&ht===-1){U(R.substring(1,ut)),K(!0),T(!1),E(!1);return}}K(!1);const Le=R.substring(0,pe),_e=Le.lastIndexOf("#");if(_e!==-1){const ht=_e>0?Le[_e-1]:null,ot=Le.substring(_e+1);if((!ht||/\s/.test(ht))&&!ot.includes(" ")&&!ot.includes(`
884
+ `)){k(ot),E(!0),T(!1);return}}E(!1);const lt=Le.lastIndexOf("@");if(lt!==-1){const ht=lt>0?Le[lt-1]:null,ot=Le.substring(lt+1);(!ht||/\s/.test(ht))&&!ot.includes(" ")&&!ot.includes(`
885
+ `)?(M(ot),T(!0)):T(!1);return}T(!1)},[]),me=at.useCallback(R=>{p(pe=>({...pe,execution:{...pe.execution,prompt:R}}))},[]),le=at.useCallback(R=>{const pe=h.execution.prompt,_e=_.current?.selectionStart??pe.length,ht=pe.substring(0,_e).lastIndexOf("@"),ot=R.relativePath&&R.relativePath.trim().length>0?R.relativePath.trim():R.path||R.name,ut=ht!==-1?ht:_e,yt=`${pe.substring(0,ut)}@${ot} ${pe.substring(_e)}`,mt=ut+ot.length+2;me(yt),T(!1),M(""),requestAnimationFrame(()=>{const xt=_.current;xt&&(xt.selectionStart=mt,xt.selectionEnd=mt,xt.focus()),J(yt,mt)})},[h.execution.prompt,me,J]),V=at.useCallback(R=>{const pe=h.execution.prompt,_e=_.current?.selectionStart??pe.length,ht=pe.substring(0,_e).lastIndexOf("@"),ot=ht!==-1?ht:_e,ut=`${pe.substring(0,ot)}@${R} ${pe.substring(_e)}`,yt=ot+R.length+2;me(ut),T(!1),M(""),requestAnimationFrame(()=>{const mt=_.current;mt&&(mt.selectionStart=yt,mt.selectionEnd=yt,mt.focus()),J(ut,yt)})},[h.execution.prompt,me,J]),Z=at.useCallback(R=>{const pe=`/${R.name} `;me(pe),K(!1),U(""),E(!1),requestAnimationFrame(()=>{const Le=_.current;Le&&(Le.focus(),Le.selectionStart=Le.value.length,Le.selectionEnd=Le.value.length),J(pe,pe.length)})},[me,J]),G=at.useCallback((R,pe)=>{const Le=h.execution.prompt,lt=_.current?.selectionStart??Le.length,ot=Le.substring(0,lt).lastIndexOf("#"),ut=ot!==-1?ot:lt,yt=`${Le.substring(0,ut)}#${pe} ${Le.substring(lt)}`,mt=ut+pe.length+2;me(yt),E(!1),k(""),requestAnimationFrame(()=>{const xt=_.current;xt&&(xt.selectionStart=mt,xt.selectionEnd=mt,xt.focus()),J(yt,mt)})},[h.execution.prompt,me,J]),ie=at.useCallback(R=>{if(F&&te.current&&(R.key==="Enter"||R.key==="ArrowUp"||R.key==="ArrowDown"||R.key==="Escape"||R.key==="Tab")){R.preventDefault(),te.current.handleKeyDown(R.key);return}C&&se.current&&(R.key==="Enter"||R.key==="ArrowUp"||R.key==="ArrowDown"||R.key==="Escape"||R.key==="Tab")&&(R.preventDefault(),se.current.handleKeyDown(R.key)),A&&ee.current&&(R.key==="Enter"||R.key==="ArrowUp"||R.key==="ArrowDown"||R.key==="Escape"||R.key==="Tab")&&(R.preventDefault(),ee.current.handleKeyDown(R.key))},[F,C,A]),je=at.useCallback(async()=>{const R=OC(h,o);if(R){Fe.error(R);return}const pe={...h.id?{id:h.id}:{},name:h.name.trim(),enabled:h.enabled,schedule:{kind:h.schedule.kind,timezone:h.schedule.timezone.trim(),...h.schedule.kind==="cron"?{cron:h.schedule.cronExpression.trim()}:h.schedule.kind==="once"?{date:h.schedule.onceDate,time:h.schedule.onceTime}:{times:BC(h.schedule.times),...h.schedule.kind==="weekly"?{weekdays:h.schedule.weekdays}:{}}},execution:{prompt:h.execution.prompt,providerID:h.execution.providerID,modelID:h.execution.modelID,...h.execution.variant.trim()?{variant:h.execution.variant.trim()}:{},...h.execution.agent.trim()?{agent:h.execution.agent.trim()}:{},...h.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...h.execution.goalEnabled?{goalEnabled:!0}:{},...h.execution.goalEnabled&&h.execution.goalTokenBudget?{goalTokenBudget:h.execution.goalTokenBudget}:{}},...h.state?{state:h.state}:{}};S(!0);try{await i(pe),r(!1)}catch(Le){Fe.error(Le instanceof Error?Le.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{S(!1)}},[h,r,i,o]),ne=at.useId(),Oe=at.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),Ve=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),ze=o("sessions.scheduledTasks.editor.description"),He=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(ys,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Wn,{id:"sched-name",value:h.name,onChange:R=>p(pe=>({...pe,name:R.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(ys,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(cn,{value:h.schedule.kind,onValueChange:R=>{p(pe=>({...pe,schedule:{...pe.schedule,kind:R,...R==="cron"&&!pe.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(dn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Zs,{children:R=>o(R==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":R==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":R==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(un,{children:[s.jsx(us,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(us,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(us,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(us,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),h.schedule.kind==="cron"?s.jsx(FC,{draft:h,setDraft:p,locale:l,t:o}):h.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:H,children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Ie(kb({size:"default"}),"w-fit max-w-full"),onClick:()=>P(R=>!R),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(B,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:CC(h.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(B,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?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:()=>I(R=>gd(R,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:ge,children:s.jsx(B,{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(v)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>I(R=>gd(R,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(B,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:Q.map((R,pe)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:R},`${R}-${pe}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:NC(v,we).map(({date:R,inCurrentMonth:pe})=>{const Le=pd(R),_e=Le===h.schedule.onceDate,lt=vd(R,Te),ht=R.getTime()<Te.getTime(),ot=_e?"bg-interactive-selection text-interactive-selection-foreground":ht?"text-muted-foreground/40":pe?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{ht||($(Le),P(!1))},disabled:ht,className:["h-8 rounded-md typography-ui-label",ot,lt&&!_e?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",ht?"cursor-not-allowed opacity-45":""].join(" "),children:R.getDate()},Le)})}),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:xe||""}),s.jsx(ft,{type:"button",size:"xs",variant:"ghost",onClick:()=>{$(pd(Te)),I(new Date(Te.getFullYear(),Te.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(yd,{value:h.schedule.onceTime,use24Hour:Re,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:R=>p(pe=>({...pe,schedule:{...pe.schedule,onceTime:R}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(cn,{value:h.schedule.timezone,onValueChange:R=>{p(pe=>({...pe,schedule:{...pe.schedule,timezone:R}}))},children:[s.jsx(dn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Zs,{})}),s.jsx(un,{children:ka.map(R=>s.jsx(us,{value:R,children:R},R))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[h.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:fe.map(R=>{const pe=h.schedule.weekdays.includes(R.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",pe?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(Lr,{checked:pe,onChange:Le=>ce(R.value,Le),ariaLabel:R.label}),s.jsx("button",{type:"button",onClick:()=>ce(R.value,!pe),className:"group-hover:text-foreground",children:R.label})]},R.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:h.schedule.times.map((R,pe)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yd,{value:R,use24Hour:Re,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:Le=>he(pe,Le)}),h.schedule.times.length>1?s.jsx(ft,{type:"button",size:"icon",variant:"ghost",onClick:()=>Y(pe),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null]},pe))}),s.jsx("div",{children:s.jsxs(ft,{type:"button",size:"sm",variant:"outline",onClick:ve,children:[s.jsx(B,{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(ys,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(cn,{value:h.schedule.timezone,onValueChange:R=>{p(pe=>({...pe,schedule:{...pe.schedule,timezone:R}}))},children:[s.jsx(dn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Zs,{})}),s.jsx(un,{children:ka.map(R=>s.jsx(us,{value:R,children:R},R))})]})]})]}),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(ys,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Cb,{providerId:h.execution.providerID,modelId:h.execution.modelID,onChange:(R,pe)=>{p(Le=>({...Le,execution:{...Le.execution,providerID:R,modelID:pe,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(cn,{value:oe,disabled:!L,onValueChange:R=>{p(pe=>({...pe,execution:{...pe.execution,variant:R==="__default"?"":R}}))},children:[s.jsx(dn,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Zs,{children:R=>R==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):R})}),s.jsxs(un,{children:[s.jsx(us,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Pe.map(R=>s.jsx(us,{value:R,children:R},R))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(ys,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Nb,{agentName:h.execution.agent,filter:R=>Ab(R.mode),onChange:R=>p(pe=>({...pe,execution:{...pe.execution,agent:R}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(ys,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(Er,{id:"sched-prompt",ref:_,value:h.execution.prompt,onChange:R=>{const pe=R.target.value;me(pe);const Le=R.target.selectionStart??pe.length;J(pe,Le)},onKeyDown:ie,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(Pb,{ref:te,searchQuery:D,onCommandSelect:Z,onClose:()=>K(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,C?s.jsx(Db,{ref:se,searchQuery:O,onFileSelect:le,onAgentSelect:V,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,A?s.jsx(Ib,{ref:ee,searchQuery:W,onSnippetSelect:G,onClose:()=>E(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),h.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(Lr,{checked:h.execution.goalTokenBudget!==null,onChange:R=>p(pe=>({...pe,execution:{...pe.execution,goalTokenBudget:R?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),h.execution.goalTokenBudget!==null?s.jsx(Tb,{value:h.execution.goalTokenBudget,onValueChange:R=>{typeof R=="number"&&Number.isFinite(R)&&R>0&&p(pe=>({...pe,execution:{...pe.execution,goalTokenBudget:Math.floor(R)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),$e=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(Lr,{checked:h.enabled,onChange:R=>p(pe=>({...pe,enabled:R})),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(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(md),onClick:()=>p(R=>({...R,execution:{...R.execution,permissionAutoAccept:!R.execution.permissionAutoAccept}})),"aria-pressed":h.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:h.execution.permissionAutoAccept?s.jsx(B,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(B,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",className:Ie(md,h.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(R=>({...R,execution:{...R.execution,goalEnabled:!R.execution.goalEnabled}})),"aria-pressed":h.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:h.execution.goalEnabled?s.jsx(B,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(B,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(jt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(ft,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:w,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(ft,{type:"button",size:"sm",onClick:je,disabled:w,children:o(w?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return y?s.jsx(Xo,{open:e,title:Ve,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:R=>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:Ve}),R]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:ze})]}),footer:$e,children:He}):s.jsx(Cs,{open:e,onOpenChange:R=>{!R&&Oe()||r(R)},children:s.jsxs(Ns,{"aria-describedby":ne,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(_s,{id:ne,className:"sr-only",children:ze}),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(Ls,{className:"typography-ui-label font-medium text-foreground",children:Ve}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:ze})]})}),s.jsx(ju,{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:He})}),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:$e})})]})})}function _C(t){return jr(t,{min:0,max:23})}function $C(t,e){return jr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function zC(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 WC(t){return s.jsx(us,{value:t,children:t},t)}const KC=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))},VC=(t,e)=>{const n=KC(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:_n(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:_n(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:_n(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:_n(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},UC=(t,e)=>!t||!Number.isFinite(t)?"":Eb(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),g=Math.round(r%o/i),x=g>0?`${f}h ${g}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),m=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:m}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:m})},HC={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"}},GC=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function qC(){const{t}=At(),e=ye(k=>k.isScheduledTasksDialogOpen),n=ye(k=>k.setScheduledTasksDialogOpen),r=ye(k=>k.isMobile),i=ye(k=>k.timeFormatPreference),o=Kt(k=>k.projects),l=Kt(k=>k.getActiveProject()),a=ts(k=>k.homeDirectory),{currentTheme:d}=qn(),[u,m]=at.useState(""),[f,g]=at.useState([]),[x,b]=at.useState(!0),[j,y]=at.useState(!1),[h,p]=at.useState(null),[w,S]=at.useState(null),N=at.useMemo(()=>o.find(k=>k.id===u)||null,[o,u]),P=at.useCallback(k=>{const v=k.label?.trim()||yr(k.path,a||void 0),I=k.icon?Wa[k.icon]:null,H=k.color?Ka[k.color]:void 0,_=I?s.jsx(B,{name:I,className:"h-3.5 w-3.5 shrink-0",style:H?{color:H}:void 0}):s.jsx(B,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:H?{color:H}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[k.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(Va,{project:{id:k.id,iconImage:k.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:_})}):_,s.jsx("span",{className:"truncate",children:v})]})},[a,d.metadata.variant,d.colors.surface.foreground]),C=at.useCallback(async(k,v)=>{if(!k){g([]);return}v?.silent||b(!0);try{const I=await yx(k);I.sort((H,_)=>{if(H.enabled!==_.enabled)return H.enabled?-1:1;const se=H.name.localeCompare(_.name);return se!==0?se:(H.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(_.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g(I)}catch(I){Fe.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),v?.silent||g([])}finally{v?.silent||b(!1)}},[t]);at.useEffect(()=>{if(!e)return;const k=l?.id||o[0]?.id||"";m(k),k?C(k):(g([]),b(!1))},[e,l,o,C]),at.useEffect(()=>{if(!e)return;let k=null;const v=In(I=>{I.type==="scheduled-task-ran"&&I.projectId===u&&(k&&clearTimeout(k),k=setTimeout(()=>{C(u,{silent:!0})},400))});return()=>{k&&clearTimeout(k),v()}},[e,u,C]);const T=at.useCallback(async k=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await ql(u,k),await C(u),Fe.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,C,t]),O=at.useCallback(async(k,v)=>{if(u){S(k.id),g(I=>I.map(H=>H.id===k.id?{...H,enabled:v}:H));try{k.loopFile?await wx(u,k.id,v):await ql(u,{...k,enabled:v}),await C(u,{silent:!0})}catch(I){Fe.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await C(u,{silent:!0})}finally{S(null)}}},[u,C,t]),M=at.useCallback(async k=>{if(!(!u||!window.confirm(k.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:k.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:k.name})))){S(k.id);try{k.loopFile?await vx(u,k.id):await Sx(u,k.id),await C(u,{silent:!0}),Fe.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(I){Fe.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{S(null)}}},[u,C,t]),F=at.useCallback(k=>{if(!k.loopFile){p(k),y(!0);return}N?.path&&(n(!1),Xs.getState().setSelectedPath(N.path,k.loopFile,{allowOutsideRoot:!0}),ye.getState().openContextFile(N.path,k.loopFile))},[N?.path,n]),K=at.useCallback(async k=>{if(u){S(k.id);try{const{sessionId:v,persistError:I}=await jx(u,k.id);if(await Promise.all([C(u,{silent:!0}),Zo()]),I?Fe.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Fe.success(t("sessions.scheduledTasks.dialog.toast.started")),v){const H=o.find(_=>_.id===u);rt.getState().setCurrentSession(v,H?.path??null)}}catch(v){Fe.error(v instanceof Error?v.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{S(null)}}},[u,o,C,t]),D=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(cn,{value:u||"__none",onValueChange:k=>{const v=k==="__none"?"":k;m(v),v?C(v):g([])},children:[s.jsx(dn,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Zs,{children:P(N)}):s.jsx(Zs,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(un,{children:[o.length===0?s.jsx(us,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(k=>s.jsx(us,{value:k.id,children:P(k)},k.id))]})]})]}),U=()=>{p(null),y(!0)},A=k=>{m(k),k?C(k):g([])},E=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(B,{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(k=>{const v=w===k.id,I=k.state?.lastStatus||"idle",H=HC[I],_=t(I==="success"?"sessions.scheduledTasks.dialog.status.success":I==="error"?"sessions.scheduledTasks.dialog.status.error":I==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),se=k.state?.nextRunAt,te=k.state?.lastRunAt;return s.jsxs("div",{className:Ie("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Ie("min-w-0",!k.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:k.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:VC(k,t)}),k.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:k.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:k.loopFile})}):null]}),s.jsxs("div",{className:Ie("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!k.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),se?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:jd(se,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:UC(se,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(B,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),I==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(B,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):te?s.jsxs(s.Fragment,{children:[H.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${H.tone})`},children:[s.jsx(B,{name:H.Icon,className:"h-3.5 w-3.5"}),_]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:jd(te,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),k.state?.lastError?s.jsxs("div",{className:Ie("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!k.enabled&&"opacity-60"),style:GC("error"),children:[s.jsx(B,{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:k.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Ie("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",k.enabled?"text-foreground":"text-muted-foreground",v&&"cursor-not-allowed opacity-50"),children:[s.jsx(Lr,{checked:k.enabled,onChange:ee=>{O(k,ee)},ariaLabel:k.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:k.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:k.name}),disabled:v}),k.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(ft,{variant:"outline",size:"sm",onClick:()=>{K(k)},disabled:v,children:[s.jsx(B,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(ft,{variant:"outline",size:"sm",onClick:()=>F(k),disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:k.name}),children:[s.jsx(B,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(ft,{variant:"destructive",size:"sm",onClick:()=>{M(k)},disabled:v,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:k.name}),children:s.jsx(B,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},k.id)})})}),W=s.jsxs("div",{className:"space-y-4",children:[D,E]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Xo,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:k=>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")}),k]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(ft,{className:"w-full",onClick:U,disabled:!u,children:[s.jsx(B,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:W}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",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(k=>s.jsx("button",{type:"button",onClick:()=>A(k.id),className:Ie("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===k.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:P(k)},k.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(ft,{size:"sm",onClick:U,disabled:!u,children:[s.jsx(B,{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:E})})]})]})}):null,s.jsx(LC,{open:j,task:h,onOpenChange:y,onSave:T})]})}const Mo=100;function YC(){const t=nt.c(108),{t:e}=At(),n=ye(r4),r=ye(n4),i=rt(s4),o=rt(t4),l=ts(e4);let a;t[0]!==n?(a=se=>n?se.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=gs(Un(a)),[u,m]=c.useState(""),[f,g]=c.useState(null),[x,b]=c.useState(Mo);let j;t[2]!==u?(j=u.trim().toLowerCase(),t[2]=u,t[3]=j):j=t[3];const y=j;let h;e:{if(!n){let te;t[4]===Symbol.for("react.memo_cache_sentinel")?(te=[],t[4]=te):te=t[4],h=te;break e}let se;t[5]!==d?(se=[...d].sort(ZC),t[5]=d,t[6]=se):se=t[6],h=se}const p=h;let w;if(t[7]!==l||t[8]!==p||t[9]!==e){const se=new Map;for(const te of p){const ee=gt(Is(te))??"",ue=se.get(ee);if(ue){ue.sessions.push(te);continue}se.set(ee,{directory:ee,label:ee?yr(ee,l)||ee:e("sessions.archivePage.otherProjects"),sessions:[te]})}w=[...se.values()].sort(JC),t[7]=l,t[8]=p,t[9]=e,t[10]=w}else w=t[10];const S=w;let N;e:{if(y){if(y.startsWith("ses_")){let ee;if(t[11]!==y||t[12]!==p){let ue;t[14]!==y?(ue=de=>de.id.toLowerCase()===y,t[14]=y,t[15]=ue):ue=t[15],ee=p.filter(ue),t[11]=y,t[12]=p,t[13]=ee}else ee=t[13];N=ee;break e}let te;t[16]!==y||t[17]!==p?(te=Rb(p,y,XC),t[16]=y,t[17]=p,t[18]=te):te=t[18],N=te;break e}if(f===null){N=p;break e}let se;t[19]!==S||t[20]!==f?(se=S.find(te=>te.directory===f)?.sessions??[],t[19]=S,t[20]=f,t[21]=se):se=t[21],N=se}const P=N;let C,T,O,M,F,K,D,U,A,E;if(t[22]!==d.length||t[23]!==S||t[24]!==P||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 se=P.slice(0,x);C=P.length-se.length;const te=d.length;let ee;t[45]===Symbol.for("react.memo_cache_sentinel")?(ee=ge=>{g(ge),b(Mo)},t[45]=ee):ee=t[45];const ue=ee;let de;t[46]!==i||t[47]!==r?(de=ge=>{const Q=gt(Is(ge));i(ge.id,Q??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=de):de=t[48];const Re=de;let we;t[49]!==e||t[50]!==o?(we=ge=>{o(ge.id).then(Q=>{Q?Fe.success(e("sessions.sidebar.session.restore.success")):Fe.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=we):we=t[51];const fe=we;if(!n){F=null;break e}let Pe;t[52]!==e?(Pe=(ge,Q,$,J,me,le,V)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:me,title:le,className:Ie("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",V?"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:Q}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:$})]}),V?s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>Us.requestDelete({sessions:V,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:Q}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(jt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ge),t[52]=e,t[53]=Pe):Pe=t[53];const L=Pe;M="absolute inset-0 z-10 flex flex-col bg-background",T="flex min-h-0 flex-1";let oe;if(t[54]!==L||t[55]!==f||t[56]!==e||t[57]!==te){let ge;t[59]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>ue(null),t[59]=ge):ge=t[59],oe=L("__all__",e("sessions.archivePage.allDirectories"),te,f===null,ge),t[54]=L,t[55]=f,t[56]=e,t[57]=te,t[58]=oe}else oe=t[58];let ce;if(t[60]!==S||t[61]!==L||t[62]!==f){let ge;t[64]!==L||t[65]!==f?(ge=Q=>L(Q.directory||"__none__",Q.label,Q.sessions.length,f===Q.directory,()=>ue(Q.directory),Q.directory||void 0,Q.sessions),t[64]=L,t[65]=f,t[66]=ge):ge=t[66],ce=S.map(ge),t[60]=S,t[61]=L,t[62]=f,t[63]=ce}else ce=t[63];t[67]!==oe||t[68]!==ce?(O=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:[oe,ce]})}),t[67]=oe,t[68]=ce,t[69]=O):O=t[69],A="flex min-w-0 flex-1 flex-col";let he;t[70]===Symbol.for("react.memo_cache_sentinel")?(he=ge=>{m(ge),b(Mo)},t[70]=he):he=t[70];let Y;t[71]!==e?(Y=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=Y):Y=t[72];let ve;t[73]!==e?(ve=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=ve):ve=t[74];let Te;t[75]!==u||t[76]!==Y||t[77]!==ve?(Te=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Jd,{value:u,onSearch:he,placeholder:Y,clearLabel:ve})}),t[75]=u,t[76]=Y,t[77]=ve,t[78]=Te):Te=t[78];let ke;t[79]!==P.length||t[80]!==e?(ke=P.length===1?e("sessions.archivePage.countSingle",{count:P.length}):e("sessions.archivePage.countPlural",{count:P.length}),t[79]=P.length,t[80]=e,t[81]=ke):ke=t[81];let xe;t[82]!==ke?(xe=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:ke}),t[82]=ke,t[83]=xe):xe=t[83],t[84]!==Te||t[85]!==xe?(E=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Te,xe]}),t[84]=Te,t[85]=xe,t[86]=E):E=t[86],U="min-h-0 flex-1 overflow-y-auto px-6 py-3",K="mx-auto w-full max-w-3xl space-y-0.5",D=se.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(y?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):se.map(ge=>{const Q=gt(Is(ge))??"",$=Q?yr(Q,l)||Q: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:()=>Re(ge),role:"button",tabIndex:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),Re(ge))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ge.title||e("sessions.sidebar.session.untitled")}),y&&$?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:Q,children:$}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ku(ge.time?.archived??ge.time?.updated??ge.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),fe(ge)},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:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),Us.requestDelete({sessions:[ge],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:ge.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ge.id)})}t[22]=d.length,t[23]=S,t[24]=P,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]=C,t[36]=T,t[37]=O,t[38]=M,t[39]=F,t[40]=K,t[41]=D,t[42]=U,t[43]=A,t[44]=E}else C=t[35],T=t[36],O=t[37],M=t[38],F=t[39],K=t[40],D=t[41],U=t[42],A=t[43],E=t[44];if(F!==Symbol.for("react.early_return_sentinel"))return F;let W;t[87]!==C||t[88]!==e?(W=C>0?s.jsx("button",{type:"button",onClick:()=>b(QC),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]=C,t[88]=e,t[89]=W):W=t[89];let k;t[90]!==W||t[91]!==K||t[92]!==D?(k=s.jsxs("div",{className:K,children:[D,W]}),t[90]=W,t[91]=K,t[92]=D,t[93]=k):k=t[93];let v;t[94]!==k||t[95]!==U?(v=s.jsx("div",{className:U,children:k}),t[94]=k,t[95]=U,t[96]=v):v=t[96];let I;t[97]!==v||t[98]!==A||t[99]!==E?(I=s.jsxs("div",{className:A,children:[E,v]}),t[97]=v,t[98]=A,t[99]=E,t[100]=I):I=t[100];let H;t[101]!==T||t[102]!==O||t[103]!==I?(H=s.jsxs("div",{className:T,children:[O,I]}),t[101]=T,t[102]=O,t[103]=I,t[104]=H):H=t[104];let _;return t[105]!==M||t[106]!==H?(_=s.jsx("div",{className:M,children:H}),t[105]=M,t[106]=H,t[107]=_):_=t[107],_}function QC(t){return t+Mo}function XC(t){return[t.title]}function JC(t,e){return e.sessions.length-t.sessions.length}function ZC(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function e4(t){return t.homeDirectory}function t4(t){return t.unarchiveSession}function s4(t){return t.setCurrentSession}function n4(t){return t.setArchivePageOpen}function r4(t){return t.isArchivePageOpen}function o4(){const t=nt.c(18),{t:e}=At(),n=ye(l4),r=ye(a4),i=Kt(i4);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=Kt(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(B,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let m;t[9]!==a||t[10]!==u?(m=s.jsx("div",{className:"flex items-center",children:s.jsxs(ft,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=m):m=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx(ap,{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 g;return t[15]!==m||t[16]!==f?(g=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[m,f]})})}),t[15]=m,t[16]=f,t[17]=g):g=t[17],g}function i4(t){return t.setActiveProjectIdOnly}function a4(t){return t.setNewWorktreeDialogOpen}function l4(t){return t.worktreesPageProjectId}function c4(t,e,n){const[r,i]=c.useState(null),o=c.useRef(n);return o.current=n,c.useEffect(()=>{if(!t||r)return;let l=!1;return Mb(e).then(a=>{l||i(()=>a)},a=>{console.error("[on-demand] failed to load component",a),l||o.current()}),()=>{l=!0}},[r,e,t]),r}function d4(t){const e=[],n=(r,i)=>{const o=gt(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 u4=new Map,f4=t=>{const e=nt.c(23),{isVSCode:n}=t,r=Jo(),i=Kt(m4),o=ts(h4),l=rt(p4);let a;e[0]!==n?(a=O=>n?u4:O.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=rt(a),u=!n;let m;e[2]!==d||e[3]!==i||e[4]!==u?(m=cm(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=m):m=e[5];const f=m,g=gs(g4),x=gs(b4),b=gs(x4),j=`session-list-sync:${c.useId()}`;let y,h;e[6]!==j||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(j,d4({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(j)),h=[j,r,o,l],e[6]=j,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=h):(y=e[10],h=e[11]),c.useEffect(y,h);const p=c.useRef(null);let w,S;e[12]!==n||e[13]!==f?(w=()=>{const O=new Set(f),M=p.current;p.current=O;const F=M?[...O].filter(K=>!M.has(K)):n?[...O]:[];F.length&&Ta(F,Lo())},S=[n,f],e[12]=n,e[13]=f,e[14]=w,e[15]=S):(w=e[14],S=e[15]),c.useEffect(w,S);let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[16]=N):N=e[16],c.useEffect(y4,N);let P;e[17]!==x||e[18]!==g?(P=[...g,...x],e[17]=x,e[18]=g,e[19]=P):P=e[19];const C=P;let T;e[20]!==C||e[21]!==b?(T={enabled:!0,hasAuthoritativeGlobalSessions:b,sessions:C},e[20]=C,e[21]=b,e[22]=T):T=e[22],lp(T)};function m4(t){return t.projects}function h4(t){return t.currentDirectory}function p4(t){return t.currentSessionDirectory}function g4(t){return t.activeSessions}function b4(t){return t.archivedSessions}function x4(t){return t.status==="ready"}function y4(){let t=null,e=!1;const n=new Set,r=In(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(),Zo(Lo());return}const o=[...n];n.clear(),o.length&&Ta(o,Lo())},500)});return()=>{t&&clearTimeout(t),r()}}const w4=()=>tn(()=>import("./SettingsWindow-CofS020b.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=>t.SettingsWindow),v4=()=>{const t=nt.c(71);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],f4(e),cp();const n=ye(S4),r=ye(j4),i=ye(k4),o=ye(C4),l=ye(N4);let a;t[1]!==l?(a=()=>l(!1),t[1]=l,t[2]=a):a=t[2];const d=c4(o,w4,a),u=ye(A4),m=ye(P4),f=ye(D4),g=ye(I4),x=ye(T4),b=ye(E4),j=Ru();let y;if(t[3]!==j||t[4]!==b){let ge;t[6]!==b?(ge=Q=>Q.id===b,t[6]=b,t[7]=ge):ge=t[7],y=j.find(ge),t[3]=j,t[4]=b,t[5]=y}else y=t[5];const h=y;let p,w;t[8]!==h||t[9]!==b?(p=()=>{b&&!h&&ye.getState().setOpenGuestPage(null)},w=[b,h],t[8]=h,t[9]=b,t[10]=p,t[11]=w):(p=t[10],w=t[11]),c.useEffect(p,w);let S;t[12]===Symbol.for("react.memo_cache_sentinel")?(S=[],t[12]=S):S=t[12],c.useEffect(M4,S);const N=m||f||g||!!x||u||!!h;let P;t[13]===Symbol.for("react.memo_cache_sentinel")?(P=[],t[13]=P):P=t[13],c.useEffect(B4,P);const{isMobile:C}=Dn();dp();let T,O;t[14]!==C||t[15]!==i?(T=()=>{ye.getState().isMobile!==C&&i(C)},O=[C,i],t[14]=C,t[15]=i,t[16]=T,t[17]=O):(T=t[16],O=t[17]),c.useEffect(T,O);let M,F,K,D,U;t[18]===Symbol.for("react.memo_cache_sentinel")?(U=s.jsx(kj,{}),M=s.jsx(w0,{}),F=s.jsx(k0,{}),K=s.jsx(up,{}),D=s.jsx(vC,{}),t[18]=M,t[19]=F,t[20]=K,t[21]=D,t[22]=U):(M=t[18],F=t[19],K=t[20],D=t[21],U=t[22]);let A;t[23]!==r?(A=r?s.jsxs(s.Fragment,{children:[s.jsx(fp,{}),s.jsx(mp,{}),s.jsx(hp,{}),s.jsx(pp,{})]}):null,t[23]=r,t[24]=A):A=t[24];let E;t[25]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(Xy,{}),t[25]=E):E=t[25];let W;t[26]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(Qy,{}),t[26]=W):W=t[26];let k;t[27]!==n?(k=s.jsx(wC,{isVisible:n}),t[27]=n,t[28]=k):k=t[28];let v;t[29]!==C||t[30]!==n||t[31]!==k?(v=s.jsx(Yy,{isOpen:n,isMobile:C,className:"border-border",topBar:W,children:k}),t[29]=C,t[30]=n,t[31]=k,t[32]=v):v=t[32];let I;t[33]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(Gy,{}),t[33]=I):I=t[33];const H=N&&"invisible";let _;t[34]!==H?(_=Ie("absolute inset-0",H),t[34]=H,t[35]=_):_=t[35];const se=!o&&!N;let te;t[36]!==se?(te=s.jsx(hs,{children:s.jsx(su,{active:se})}),t[36]=se,t[37]=te):te=t[37];let ee;t[38]!==_||t[39]!==te?(ee=s.jsx("div",{className:_,children:te}),t[38]=_,t[39]=te,t[40]=ee):ee=t[40];let ue;t[41]===Symbol.for("react.memo_cache_sentinel")?(ue=s.jsx(hs,{children:s.jsx(gp,{})}),t[41]=ue):ue=t[41];let de;t[42]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsx(hs,{children:s.jsx(qC,{})}),t[42]=de):de=t[42];let Re;t[43]===Symbol.for("react.memo_cache_sentinel")?(Re=s.jsx(hs,{children:s.jsx(YC,{})}),t[43]=Re):Re=t[43];let we;t[44]!==g?(we=g&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(hs,{children:s.jsx(bp,{})})}),t[44]=g,t[45]=we):we=t[45];let fe;t[46]===Symbol.for("react.memo_cache_sentinel")?(fe=s.jsx(hs,{children:s.jsx(o4,{})}),t[46]=fe):fe=t[46];let Pe;t[47]!==h?(Pe=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(hs,{children:s.jsx(zx,{mode:`plugin:${h.id}`,surface:"page",item:null,onDismiss:F4})})}),t[47]=h,t[48]=Pe):Pe=t[48];let L;t[49]!==ee||t[50]!==we||t[51]!==Pe?(L=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ee,ue,de,Re,we,fe,Pe]}),t[49]=ee,t[50]=we,t[51]=Pe,t[52]=L):L=t[52];let oe;t[53]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(HS,{}),t[53]=oe):oe=t[53];let ce;t[54]!==L?(ce=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:[L,oe]})})}),t[54]=L,t[55]=ce):ce=t[55];let he;t[56]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(hs,{children:s.jsx(sj,{})})}),t[56]=he):he=t[56];let Y;t[57]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(hs,{children:s.jsx(hx,{})}),t[57]=Y):Y=t[57];let ve;t[58]!==ce?(ve=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[I,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[ce,he,Y]})]}),t[58]=ce,t[59]=ve):ve=t[59];let Te;t[60]!==v||t[61]!==ve?(Te=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[v,ve]}),t[60]=v,t[61]=ve,t[62]=Te):Te=t[62];let ke;t[63]!==d||t[64]!==o||t[65]!==l?(ke=d?s.jsx(d,{open:o,onOpenChange:l}):null,t[63]=d,t[64]=o,t[65]=l,t[66]=ke):ke=t[66];let xe;return t[67]!==A||t[68]!==Te||t[69]!==ke?(xe=s.jsx(xp,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[U,M,F,K,D,A,E,Te,ke]})}),t[67]=A,t[68]=Te,t[69]=ke,t[70]=xe):xe=t[70],xe};function S4(t){return t.isSidebarOpen}function j4(t){return t.isolatedSpacesEnabled}function k4(t){return t.setIsMobile}function C4(t){return t.isSettingsDialogOpen}function N4(t){return t.setSettingsDialogOpen}function A4(t){return t.runOverviewKey!==null}function P4(t){return t.isScheduledTasksDialogOpen}function D4(t){return t.isArchivePageOpen}function I4(t){return t.isUsageStatsPageOpen}function T4(t){return t.worktreesPageProjectId}function E4(t){return t.openGuestPageId}function R4(){return ye.getState().setOpenGuestPage(null)}function M4(){return vr(R4)}function O4(){return ye.getState().closeMainSurfaces()}function B4(){const t=O4,e=rt.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 F4(){return ye.getState().setOpenGuestPage(null)}const fm=12,L4=[{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"}],_4=t=>{const e=nt.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,m=l===void 0?L4:l,f=at.useRef(!1);let g,x;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},x=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=x):(g=e[2],x=e[3]),at.useEffect(g,x);let b;e[4]===Symbol.for("react.memo_cache_sentinel")?(b=Array.from({length:fm},$4),e[4]=b):b=e[4];const j=b;if(!n)return null;let y;e[5]!==i?(y=Ie("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=S=>{const N={"--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:N,children:j.map((P,C)=>{const T=P.x*S.radius,O=P.y*S.radius,M={"--translate-x":`${T}px`,"--translate-y":`${O}px`,"--particle-delay":`${P.delay}ms`,color:`var(${S.colorVar})`};return s.jsx("span",{className:"firework-particle",style:M},`${S.id}-${C}-${d}`)})},`${S.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],h=m.map(w),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let p;return e[14]!==d||e[15]!==y||e[16]!==h?(p=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=y,e[16]=h,e[17]=p):p=e[17],p};function $4(t,e){const n=Math.PI*2*e/fm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const z4=t=>{const e=nt.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]=at.useState(o),d=at.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),a(W4)},e[4]=f):f=e[4];const g=f;let x;e[5]!==i?(x=()=>{m(),a(K4),d.current=window.setTimeout(()=>{a(V4),d.current=null},i)},e[5]=i,e[6]=x):x=e[6];const b=x;let j,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(j=()=>()=>m(),y=[m],e[7]=j,e[8]=y):(j=e[7],y=e[8]),at.useEffect(j,y);let h;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==b?(h={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:b,dismissFireworks:g},e[9]=l.cycle,e[10]=l.isActive,e[11]=b,e[12]=h):h=e[12],h};function W4(t){return t.isActive?{...t,isActive:!1}:t}function K4(t){return{isActive:!0,cycle:t.cycle+1}}function V4(t){return t.isActive?{...t,isActive:!1}:t}const mm=c.createContext(void 0),U4=t=>{const e=nt.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=z4();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(_4,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(mm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},K5=()=>{const t=c.useContext(mm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ca="openchamber_requests_in_flight",hm=1e3,H4=300*1e3,qo=Math.ceil(H4/hm),G4=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ca)==="1"}catch{return!1}},pm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let q4=1;const Y4=(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))},Q4=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},gm=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},xr=(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)},X4=()=>{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=q4++;Y4(o,Date.now());try{return await e(r,i)}finally{Q4(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)},Ir=t=>{t.length>qo&&t.splice(0,t.length-qo)},J4=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=gm(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(xr(e,50)),t.p90Samples.push(xr(e,90)),t.p99Samples.push(xr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Ir(t.samples),Ir(t.p50Samples),Ir(t.p90Samples),Ir(t.p99Samples),Ir(t.maxSamples),t.lastSampleAt=Date.now()},Z4=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(J4,hm))},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(Ca,"1"),window.__openchamberRequestsInFlight__=pm(),X4(),Z4();return}window.localStorage.removeItem(Ca),Cd(),kd(),delete window.__openchamberRequestsInFlight__}catch{}},eN=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=pm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},Na=()=>{if(typeof window>"u")return Ad();const t=window.__openchamberRequestsInFlight__;if(!G4()||!t)return Ad();const e=gm(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:xr(e,50),ageP90:xr(e,90),ageP99:xr(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:qo}},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:qo});function tN(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const bm=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`},Aa=t=>`${(t/1e3).toFixed(2)} s`,ds=t=>{const e=nt.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=nt.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=At();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(rN,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?bm(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let x;e[18]!==m||e[19]!==g?(x=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,g]}),e[18]=m,e[19]=g,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 j;e[23]!==r.entries.length||e[24]!==b?(j=s.jsx(ds,{label:b,value:r.entries.length}),e[23]=r.entries.length,e[24]=b,e[25]=j):j=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let h;e[28]!==y||e[29]!==u?(h=s.jsx(ds,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=h):h=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==o?(w=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=w):w=e[35];let S;e[36]!==p||e[37]!==w?(S=s.jsx(ds,{label:p,value:w}),e[36]=p,e[37]=w,e[38]=S):S=e[38];let N;e[39]!==h||e[40]!==S||e[41]!==j?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[j,h,S]}),e[39]=h,e[40]=S,e[41]=j,e[42]=N):N=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,N,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(xn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(P=>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:P.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:P.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:P.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:P.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:P.total})})]})]},P.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=nt.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(oN,0),u=r>0?52/r:0;let m;e[0]!==d||e[1]!==a?(m=S=>a-d+S,e[0]=d,e[1]=a,e[2]=m):m=e[2];const f=m;let g;e[3]!==u?(g=S=>56-S*u,e[3]=u,e[4]=g):g=e[4];const x=g;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 j=`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 h;if(e[9]!==n||e[10]!==f||e[11]!==x){let S;e[13]!==f||e[14]!==x?(S=(N,P)=>{const C=N.samples.length;if(C===0)return null;const T=N.samples.map((M,F)=>`${f(F)},${x(M).toFixed(2)}`),O=`M ${T.join(" L ")}`;return s.jsxs(c.Fragment,{children:[N.filled?s.jsx("path",{d:`M ${f(0)},56 L ${T.join(" L ")} L ${f(C-1)},56 Z`,fill:`color-mix(in srgb, ${N.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:O,fill:"none",stroke:N.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},P)},e[13]=f,e[14]=x,e[15]=S):S=e[15],h=n.map(S),e[9]=n,e[10]=f,e[11]=x,e[12]=h}else h=e[12];let p;e[16]!==o||e[17]!==j||e[18]!==y||e[19]!==h?(p=s.jsxs("svg",{viewBox:j,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,h]}),e[16]=o,e[17]=j,e[18]=y,e[19]=h,e[20]=p):p=e[20];let w;return e[21]!==b||e[22]!==p?(w=s.jsxs("div",{className:"relative w-full",children:[b,p]}),e[21]=b,e[22]=p,e[23]=w):w=e[23],w},sN=t=>{const e=nt.c(100),{onClose:n}=t,{t:r}=At(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=rt(iN),u=zu(aN),m=Nu(),f=Ob(lN),g=Ps(cN),[x,b]=c.useState(dN),[j,y]=c.useState(uN),[h,p]=c.useState(fN),w=[{label:"p50",current:h.ageP50,samples:h.p50Samples,color:"var(--status-success)"},{label:"p90",current:h.ageP90,samples:h.p90Samples,color:"var(--status-info)"},{label:"p99",current:h.ageP99,samples:h.p99Samples,color:"var(--status-warning)"},{label:"max",current:h.ageMax,samples:h.maxSamples,color:"var(--status-error)"}];let S;e[0]!==h.samples?(S=h.samples.reduce(mN,0),e[0]=h.samples,e[1]=S):S=e[1];const N=S,P=w.reduce(pN,0);let C;e[2]!==x.entries?(C=new Map,x.entries.forEach(Le=>{C.set(Le.metric,Le.count)}),e[2]=x.entries,e[3]=C):C=e[3];let T;e[4]!==C?(T=C.get("ui.message_list.render")??0,e[4]=C,e[5]=T):T=e[5];let O;e[6]!==C?(O=C.get("ui.message_list.render.streaming")??0,e[6]=C,e[7]=O):O=e[7];let M;e[8]!==C?(M=C.get("ui.chat_message.render")??0,e[8]=C,e[9]=M):M=e[9];let F;e[10]!==C?(F=C.get("ui.chat_message.render.streaming")??0,e[10]=C,e[11]=F):F=e[11];let K;e[12]!==C?(K=C.get("ui.chat_message.render.static_during_stream")??0,e[12]=C,e[13]=K):K=e[13];let D;e[14]!==C?(D=C.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=C,e[15]=D):D=e[15];let U;e[16]!==T||e[17]!==O||e[18]!==M||e[19]!==F||e[20]!==K||e[21]!==D?(U={messageListRender:T,messageListRenderStreaming:O,chatMessageRender:M,chatMessageRenderStreaming:F,chatMessageRenderStaticDuringStream:K,chatMessageRenderStaticOutsideActiveTurnDuringStream:D},e[16]=T,e[17]=O,e[18]=M,e[19]=F,e[20]=K,e[21]=D,e[22]=U):U=e[22];const A=U;let E,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const Le=()=>{b(Ao()),y(Po()),p(Na())};Le();const _e=window.setInterval(Le,500);return()=>window.clearInterval(_e)},E=[],e[23]=E,e[24]=W):(E=e[23],W=e[24]),c.useEffect(W,E);let k,v;e[25]!==l?(k=()=>{if(l==="idle")return;const Le=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Le)},v=[l],e[25]=l,e[26]=k,e[27]=v):(k=e[26],v=e[27]),c.useEffect(k,v);let I=0,H=0,_=0;for(const Le of Object.keys(f)){const _e=f[Le]??[];H=H+_e.length;for(const lt of _e)lt.role==="user"?_=_+1:lt.role==="assistant"&&(I=I+1)}let se;e[28]!==I||e[29]!==H||e[30]!==_?(se={assistant:I,total:H,user:_},e[28]=I,e[29]=H,e[30]=_,e[31]=se):se=e[31];const te=se;let ee;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==m||e[36]!==r){let Le;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Le=_e=>{const lt=f[_e.id]??[];let ht=0,ot=0;for(const yt of lt)yt.role==="user"?ot=ot+1:yt.role==="assistant"&&(ht=ht+1);const ut=u.get(_e.id);return{id:_e.id,title:_e.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ht,messageCount:lt.length,userMessageCount:ot,isStreaming:ut?.isStreaming||!1,isZombie:ut?.isZombie||!1,backgroundCount:ut?.backgroundMessageCount||0,lastAccessed:ut?.lastAccessedAt||0,isCurrent:_e.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Le):Le=e[42],ee=m.map(Le).sort(gN),e[32]=d,e[33]=f,e[34]=u,e[35]=m,e[36]=r,e[37]=ee}else ee=e[37];const ue=ee;let de;e[43]!==f?(de=Object.keys(f),e[43]=f,e[44]=de):de=e[44];const Re=de.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const Le={generatedAt:new Date().toISOString(),ui:Ao(),vscode:Po()};await navigator.clipboard.writeText(JSON.stringify(Le,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const fe=we,Pe=Fb,L="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let oe;e[46]===Symbol.for("react.memo_cache_sentinel")?(oe={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=oe):oe=e[46];let ce;e[47]!==i?(ce=tN(i),e[47]=i,e[48]=ce):ce=e[48];let he;e[49]!==ce?(he=s.jsx(B,{name:ce,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=ce,e[50]=he):he=e[50];let Y;e[51]!==r?(Y=r("memoryDebugPanel.title"),e[51]=r,e[52]=Y):Y=e[52];let ve;e[53]!==Y?(ve=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Y}),e[53]=Y,e[54]=ve):ve=e[54];let Te;e[55]!==he||e[56]!==ve?(Te=s.jsxs("div",{className:"flex items-center gap-2",children:[he,ve]}),e[55]=he,e[56]=ve,e[57]=Te):Te=e[57];let ke;e[58]!==i?(ke=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(ft,{size:"xs",variant:"ghost",onClick:fe,children:s.jsx(B,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(ft,{size:"xs",variant:"ghost",onClick:()=>{fh(),b(Ao()),y(Po())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=ke):ke=e[59];let xe;e[60]!==i?(xe=i==="requests"?s.jsx(ft,{size:"xs",variant:"ghost",onClick:()=>{eN(),p(Na())},children:s.jsx(B,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=xe):xe=e[61];let ge;e[62]!==n?(ge=n?s.jsx(ft,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(B,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=ge):ge=e[63];let Q;e[64]!==ke||e[65]!==xe||e[66]!==ge?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[ke,xe,ge]}),e[64]=ke,e[65]=xe,e[66]=ge,e[67]=Q):Q=e[67];let $;e[68]!==Te||e[69]!==Q?($=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Te,Q]}),e[68]=Te,e[69]=Q,e[70]=$):$=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 me=i==="memory"?"secondary":"ghost";let le;e[72]===Symbol.for("react.memo_cache_sentinel")?(le=()=>o("memory"),e[72]=le):le=e[72];let V;e[73]!==r?(V=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=V):V=e[74];let Z;e[75]!==me||e[76]!==V?(Z=s.jsx(ft,{size:"sm",variant:me,className:"flex-1",onClick:le,children:V}),e[75]=me,e[76]=V,e[77]=Z):Z=e[77];const G=i==="streaming"?"secondary":"ghost";let ie;e[78]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>o("streaming"),e[78]=ie):ie=e[78];let je;e[79]!==r?(je=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=je):je=e[80];let ne;e[81]!==G||e[82]!==je?(ne=s.jsx(ft,{size:"sm",variant:G,className:"flex-1",onClick:ie,children:je}),e[81]=G,e[82]=je,e[83]=ne):ne=e[83];const Oe=i==="requests"?"secondary":"ghost";let Ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>o("requests"),e[84]=Ve):Ve=e[84];let ze;e[85]!==r?(ze=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=ze):ze=e[86];let He;e[87]!==Oe||e[88]!==ze?(He=s.jsx(ft,{size:"sm",variant:Oe,className:"flex-1",onClick:Ve,children:ze}),e[87]=Oe,e[88]=ze,e[89]=He):He=e[89];let $e;e[90]!==Z||e[91]!==ne||e[92]!==He?($e=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:J,children:[Z,ne,He]}),e[90]=Z,e[91]=ne,e[92]=He,e[93]=$e):$e=e[93];const R=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:te.total}),s.jsx(ds,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Re} / ${$l.MAX_SESSIONS}`}),s.jsx(ds,{label:r("memoryDebugPanel.metric.userMessages"),value:te.user}),s.jsx(ds,{label:r("memoryDebugPanel.metric.assistantMessages"),value:te.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:Bb()})})]}),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:$l.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:g})]})]}),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(xn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:ue.map(Le=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Le.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:Le.title}),Le.isStreaming?s.jsx(B,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Le.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:Le.assistantMessageCount,user:Le.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Le.messageCount})}),Le.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Le.backgroundCount]}):null]})]},Le.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(vt,{children:[s.jsx(St,{asChild:!0,children:s.jsx(ft,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(bN),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:te,sessionMessageRoleCounts:ue.map(xN),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(jt,{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(ft,{size:"xs",variant:"outline",onClick:fe,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:j.entries.length}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListRenders"),value:A.messageListRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:A.messageListRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:A.chatMessageRender}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:A.chatMessageRenderStreaming}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:A.chatMessageRenderStaticDuringStream}),s.jsx(ds,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:A.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Pd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:x,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),j.entries.length>0?s.jsx(Pd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:j,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:`${h.totalSettled} / ${h.totalStarted}`}),s.jsx(ds,{label:r("memoryDebugPanel.requests.tracking"),value:h.startedAt?bm(h.durationMs):r("memoryDebugPanel.common.idle")})]}),h.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:h.peak})]})]}),s.jsx(Dd,{series:[{samples:h.samples,color:"var(--status-info)",filled:!0}],peak:N,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:h.peak}),maxLabel:`${N}`}),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:Aa(h.peakAgeMs)})]}),s.jsx(Dd,{series:w.map(yN),peak:P,windowSeconds:h.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:Aa(P)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:w.map(wN)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:h.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let pe;return e[94]!==Pe||e[95]!==oe||e[96]!==$||e[97]!==$e||e[98]!==R?(pe=s.jsxs(Pe,{className:L,style:oe,children:[$,$e,R]}),e[94]=Pe,e[95]=oe,e[96]=$,e[97]=$e,e[98]=R,e[99]=pe):pe=e[99],pe},nN=sN;function rN(t,e){return t+e.count}function oN(t,e){return Math.max(t,e.samples.length)}function iN(t){return t.currentSessionId}function aN(t){return t.sessionMemoryState}function lN(t){return t.message}function cN(t){return t.totalRequestCount}function dN(){return Ao()}function uN(){return Po()}function fN(){return Na()}function mN(t,e){return Math.max(t,e)}function hN(t,e){return Math.max(t,e)}function pN(t,e){return e.samples.reduce(hN,t)}function gN(t,e){return e.lastAccessed-t.lastAccessed}function bN(t){return{id:t.id,title:t.title}}function xN(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function yN(t){return{samples:t.samples,color:t.color}}function wN(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:Aa(t.current)})]},t.label)}const vN=()=>{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()??"":""},SN=async()=>{const t=vN()||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",Fi="openchamber:check-for-updates",jN=t=>{const e=rt(h=>h.openNewSessionDraft),n=ye(h=>h.toggleCommandPalette),r=ye(h=>h.setCommandPaletteOpen),i=ye(h=>h.toggleHelpDialog),o=ye(h=>h.toggleSidebar),l=ye(h=>h.setSessionSwitcherOpen),a=ye(h=>h.setSettingsDialogOpen),d=ye(h=>h.setAboutDialogOpen),u=Fr(h=>h.checkForUpdates),{setThemeMode:m}=qn(),f=c.useRef(!1),g=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:h,error:p}=Fr.getState();if(p){Fe.error("Failed to check for updates",{description:p});return}h||Fe.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),x=c.useCallback(()=>{Us.requestDirectoryDialog()},[]),b=c.useCallback(h=>{const p=Lb();if(p.length===0)return;const w=rt.getState().currentSessionId,S=p.findIndex(C=>C.id===w);let N=h>0?0:p.length-1;S>=0&&(N=(S+h+p.length)%p.length);const P=p[N];P&&(l(!1),rt.getState().setCurrentSession(P.id))},[l]),j=c.useCallback(h=>{const{activeProjectId:p,projects:w,setActiveProject:S}=Kt.getState();if(w.length===0)return;const N=w.findIndex(T=>T.id===p);let P=h>0?0:w.length-1;N>=0&&(P=(N+h+w.length)%w.length);const C=w[P];C&&S(C.id)},[]),y=c.useCallback(h=>{switch(h){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=rt.getState(),w=ts.getState().currentDirectory;e(p.currentSessionId&&w?{directoryOverride:w}:void 0)}break;case"new-worktree-session":l(!1),Tu();break;case"change-workspace":x();break;case"toggle-right-sidebar":{const p=ts.getState().currentDirectory;if(!p)break;const w=ye.getState(),S=Fn(p),N=w.contextPanelByDirectory[S];N?.isOpen?w.closeContextPanel(S):N?.activeTabId?w.setActiveContextPanelTab(S,N.activeTabId):w.openContextSurface(S,"git");break}case"open-right-sidebar-git":{const p=ts.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"git");break}case"open-right-sidebar-files":{const p=ts.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"file");break}case"toggle-terminal":{const p=ts.getState().currentDirectory;if(!p)break;ye.getState().openContextSurface(Fn(p),"terminal");break}case"toggle-terminal-expanded":{const p=ts.getState().currentDirectory;if(!p)break;const w=Fn(p),S=ye.getState(),N=S.contextPanelByDirectory[w];(N?.isOpen?N.tabs.find(C=>C.id===N.activeTabId)?.mode:null)!=="terminal"&&S.openContextSurface(w,"terminal"),S.toggleContextPanelExpanded(w);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||SN();break}case"theme-light":m("light");break;case"theme-dark":m("dark");break;case"theme-system":m("system");break;case"add-selection-to-chat":_b();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ts.getState().goBack();break;case"go-forward":ts.getState().goForward();break;case"previous-session":b(-1);break;case"next-session":b(1);break;case"previous-project":j(-1);break;case"next-project":j(1);break;case"help-dialog":i();break;case"download-logs":{Eu().catch(()=>{Fe.error("Failed to collect OpenCode status")});break}}},[x,j,b,t,e,d,l,r,a,m,n,i,o]);c.useEffect(()=>{const h=w=>{const S=w.detail;S&&y(S)},p=()=>{g()};return window.addEventListener(Id,h),window.addEventListener(Fi,p),()=>{window.removeEventListener(Id,h),window.removeEventListener(Fi,p)}},[y,g]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let w=null,S=null;return p("openchamber:menu-action",N=>{const P=N?.payload;typeof P=="string"&&y(P)}).then(N=>{w=N}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Fi))}).then(N=>{S=N}).catch(()=>{}),()=>{(async()=>{try{const P=w?.();P instanceof Promise&&await P}catch{}try{const P=S?.();P instanceof Promise&&await P}catch{}})()}},[y])},kN="openchamber:tray-action",CN=5e3,NN=500,AN=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,xm=t=>{const e=t.action.trim()||"Permission",n=t.resources.find(r=>r.trim());return n?`${e}: ${n}`:e},ym=t=>t.title.trim()||"Question",PN=(t,e)=>za(t,e,Ur.getState().ids,Fa.getState().rankById),DN=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},IN=(t,e,n,r,i)=>{if(!t)return"";const o=ru(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||DN(t),d=Do(t);let u=d&&i.get(d)||"";if(!u){for(const[m,f]of Xn.getState().directories)if(Do(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(g=>Do(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},TN=()=>{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 zb){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:Kb(m),value:Wb(f.valueLabel,g)})}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}},EN=async()=>{try{if(Yo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=pn();if(e&&gl(e,t))return"Local OpenChamber";const r=(await Ld()).hosts.find(i=>e?gl(e,mh(i)):!1);return r?.label?.trim()?_d(r.label.trim()):"Instance"}catch{return""}},RN=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Ji()}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(Do(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",g=t.get(d);(!g||g==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:xm(m),directory:o})}for(const[d,u]of Object.entries(a.form??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"form",id:m.id,sessionId:f,sessionTitle:"",label:ym(m),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},MN=(t,e)=>{const n=Hu.getState().index.session,r=gs.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const w=i.get(p.parentID)??[];w.push(p.id),i.set(p.parentID,w)}const o=p=>{const w=[],S=[...i.get(p)??[]],N=new Set;for(;S.length;){const P=S.pop();N.has(P)||(N.add(P),w.push(P),S.push(...i.get(P)??[]))}return w},l=ye.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let w=n.unseenCount[p.id]??0;w===0&&l.notifyOnSubtasks&&(w=o(p.id).reduce((S,N)=>S+(n.unseenCount[N]??0),0)),w>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=RN(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const m=Ua.getState().statusById,f=p=>{const w=d.statusById.get(p);return w&&w!=="idle"?w:m.get(p)?.status.type??w??"idle"},g=p=>{const w=p.map(S=>f(S));return w.includes("busy")?"busy":w.includes("retry")?"retry":"idle"},x=Kt.getState().projects,b=rt.getState().availableWorktreesByProject,j=r.filter(p=>p?.id&&!p.parentID).slice().sort(PN).slice(0,AN).map(p=>{const w=[p.id,...o(p.id)],S=Is(p)??"";return{id:p.id,title:p.title||"Untitled session",status:g(w),branch:S?d.branchByDirectory.get(S)??"":"",unseen:w.reduce((N,P)=>N+(n.unseenCount[P]??0),0),hasError:w.some(N=>n.unseenHasError[N]??!1),directory:S,subtitle:IN(S,p,x,b,d.branchByDirectory)}}),y=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),h=new Set(y.map(p=>p.id));for(const[p,w]of Gu.getState().bySession){const S=u.get(p)||"";for(const N of w.permissions)h.has(N.id)||(h.add(N.id),y.push({kind:"permission",id:N.id,sessionId:p,sessionTitle:S,label:xm(N),directory:w.directory}));for(const N of w.forms)h.has(N.id)||(h.add(N.id),y.push({kind:"form",id:N.id,sessionId:p,sessionTitle:S,label:ym(N),directory:w.directory}))}return{sessions:j,approvals:y,instanceName:t,usage:TN(),dockBadgeCount:a}},ON=()=>{c.useEffect(()=>{if(!Td()||!Kr())return;const t=Ed();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const C=MN(i,t),T=JSON.stringify(C);T!==n&&(n=T,An("desktop_tray_update",C))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},NN))},a=Hu.subscribe(()=>l()),d=gs.subscribe(()=>l()),u=ye.subscribe((C,T)=>{(C.dockBadgeEnabled!==T.dockBadgeEnabled||C.notifyOnSubtasks!==T.notifyOnSubtasks)&&l()}),m=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),m;EN().then(C=>{e||(i=C,o())});const f=new Map,g=()=>{if(e)return;let C;try{C=Ji()}catch{return}const T=new Set;for(const[O,M]of C.children.entries())T.add(O),f.has(O)||f.set(O,M.subscribe(()=>l()));for(const[O,M]of f)T.has(O)||(M(),f.delete(O))};let x=null;try{x=Ji().subscribeRegistry(()=>{g(),l()})}catch{}g();const b=Kt.subscribe(()=>l()),j=rt.subscribe(()=>l()),y=Xn.subscribe(()=>l()),h=Ua.subscribe(()=>l()),p=Gu.subscribe(()=>l()),w=Fa.subscribe(()=>l()),S=Ur.subscribe(()=>l()),N=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:C,results:T}=ur.getState();C.length>0&&C.some(M=>!T.some(F=>F.providerId===M))&&ur.getState().fetchQuotas(C)});const P=window.setInterval(()=>{g(),o()},CN);return o(),()=>{m(),window.clearInterval(P),b(),j(),y(),h(),p(),w(),S(),N(),x?.();for(const C of f.values())C();f.clear()}},[]),c.useEffect(()=>{if(!Td()||!Ed()||!Kr())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&$b(i.sessionId,i.id,i.response).catch(()=>{Fe.error("Failed to respond to permission request")})};let r=null;return e(kN,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{}}},[])},BN=30*6e4,FN=(t,e,n=BN)=>{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 Tr=null;const LN=()=>{if(Tr)return Tr;const t=Yt();return Tr=(async()=>{const e=await mr.getHostSessionStatusSnapshot();if(!e||Yt()!==t)return;const n=Ua.getState(),r=gs.getState().entityById,i=FN(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Is(a):null}});for(const[l,a]of i)Vb(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Is(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,forms:a.forms})}Ub(o)})().finally(()=>{Tr=null}),Tr},_N=45e3,$N=[1e3,2e3,4e3],zN=(t,e,n=window.setTimeout.bind(window),r=window.clearTimeout.bind(window))=>{let i=!1,o,l=0,a=!1;const d=async u=>{const m=await u().catch(()=>!1);if(i)return;a||=m;const f=a?void 0:$N[l];f!==void 0&&(l+=1),o=n(()=>{o=void 0,d(e)},f??_N)};return d(t),()=>{i=!0,o!==void 0&&r(o)}},WN=t=>{const e=nt.c(3);let n,r;e[0]!==t?(n=()=>{if(!t)return;const i=KN;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 KN(){const t=Yt();let e=!0;const n=async i=>(i?await Hb(Lo()):await Zo(),!e||Yt()!==t?!1:(LN(),gs.getState().status==="ready")),r=zN(()=>n(!0),()=>n(!1));return()=>{e=!1,r()}}const VN=()=>globalThis.document?document.visibilityState==="visible"&&document.hasFocus():!0,UN=t=>{const e=nt.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!(!n||hn()||!Da()||!globalThis.window))return In(HN)},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function HN(t){if(t.type!=="notification")return;const e=ye.getState();if(!e.nativeNotificationsEnabled||e.notificationMode!=="always"&&t.payload.requireHidden!==!1&&VN())return;Fd()?.notifications?.notifyAgentCompletion(t.payload)}const GN=6e4,qN=t=>{const e=nt.c(10),n=ye(YN),r=Gb(QN),o=yp(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:GN})},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 In(m=>{m.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function YN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function QN(t){return t.load}const XN=()=>{const t=nt.c(4),{t:e}=At(),n=ye(JN);let r,i;t[0]!==n||t[1]!==e?(r=()=>In(o=>{o.type==="browser-provider-reset"&&(n("builtin"),Fe.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 JN(t){return t.setBrowserProvider}const Rd="pwa-install-toast-shown",Md="pwa-install-toast-dismissed",ZN=()=>{const t=nt.c(6),{browserTab:e}=wp(),{t:n}=At(),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"||!Da()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(Fe.dismiss(u),u=null)},f=async()=>{if(!d)return;const b=d;d=null,m(),await b.prompt();const{outcome:j}=await b.userChoice;j==="accepted"&&Fe.success(r.current("pwa.installPrompt.started"))},g=b=>{const j=b;if(typeof j.prompt!="function")return;j.preventDefault(),d=j;const y=Bo(),h=hh();vp({dismissed:y.getItem(Md),sessionShown:h.getItem(Rd),hasActiveToast:u!==null})&&(h.setItem(Rd,"true"),u=Fe.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:()=>{Bo().setItem(Md,"true"),m()}}}))},x=()=>{d=null,m(),Fe.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",x),()=>{m(),window.removeEventListener("beforeinstallprompt",g),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)},e5=({open:t,onOpenChange:e})=>{const{t:n}=At(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[m,f]=c.useState(!1),[g,x]=c.useState(null),[b,j]=c.useState(!1);c.useCallback(async()=>{},[g,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await ls("/api/system/info");if(p.ok){const w=await p.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){o(w.openchamberVersion);return}}}catch{}o(await qb())})()},[t]),c.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const S=await w.json().catch(()=>null),N=typeof S?.currentVersion=="string"?S.currentVersion.trim():"";!h&&N&&a(N)}catch{}})(),()=>{h=!0}},[t]),c.useEffect(()=>{{x(null),j(!1);return}},[t,r]);const y=i;return s.jsx(Cs,{open:t,onOpenChange:e,children:s.jsx(Ns,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Au,{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(B,{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(B,{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(B,{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")})]})})})},Pa="project-config-invalid",t5=()=>{const t=nt.c(9),{t:e}=At(),n=Vt(s5);let r;t[0]!==n?(r=g=>g.projectConfigErrors[n],t[0]=n,t[1]=r):r=t[1];const i=Vt(r),[o,l]=at.useState(!1);let a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const g=Vt.getState(),x=g.activeDirectoryKey;l(!0),Promise.all([g.loadProviders({directory:x,source:"projectConfigError:retry"}),g.loadAgents({directory:x,source:"projectConfigError:retry"})]).finally(()=>l(!1))},t[2]=a):a=t[2];const d=a;let u,m;t[3]!==i||t[4]!==o||t[5]!==e?(u=()=>{if(!i){Fe.dismiss(Pa);return}Fe.error(e("projectConfigError.toast.title"),{id:Pa,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:g=>{g.preventDefault(),o||d()}}})},m=[i,o,d,e],t[3]=i,t[4]=o,t[5]=e,t[6]=u,t[7]=m):(u=t[6],m=t[7]),at.useEffect(u,m);let f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],t[8]=f):f=t[8],at.useEffect(r5,f),null};function s5(t){return t.activeDirectoryKey}function n5(){Fe.dismiss(Pa)}function r5(){return n5}const o5="\x1B",i5=new RegExp(`${o5}\\[[0-9;?]*[ -/]*[@-~]`,"g"),No=Hn().transform(t=>t.replace(i5,"").trim()).nullish(),a5=Yl({isOpenCodeReady:Ql().optional(),openCodeRunning:Ql().optional(),lastOpenCodeError:No,opencodeBinaryResolved:No,lastOpenCodeLaunchDiagnostics:Yl({sourceBinary:No,binary:No}).nullish()}),l5=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=a5.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}},c5=(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=Jn(()=>tn(()=>import("./OnboardingScreen-C22bGmnP.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}))),d5=()=>{const t=nt.c(3),e=ye(g5),n=ye(b5);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(e5,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},u5=t=>{const e=nt.c(33),{onRetry:n,isRetrying:r}=t,{t:i}=At(),[o,l]=c.useState(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{const N=new AbortController,P=Yt(),C=setTimeout(()=>N.abort(),5e3);return l5(N.signal).then(T=>{!N.signal.aborted&&Yt()===P&&l(T)}).catch(x5).finally(()=>clearTimeout(C)),()=>{N.abort(),clearTimeout(C)}},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),c.useEffect(a,d);const u=Vt(y5),m=o?null:u?.message??null;let f;e[2]!==i?(f=i("startup.initRecovery.title"),e[2]=i,e[3]=f):f=e[3];let g;e[4]!==f?(g=s.jsx("h1",{className:"typography-title text-foreground",children:f}),e[4]=f,e[5]=g):g=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==i?(x=i(c5(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 j;e[12]!==g||e[13]!==b?(j=s.jsxs("div",{className:"flex flex-col gap-2",children:[g,b]}),e[12]=g,e[13]=b,e[14]=j):j=e[14];let y;e[15]!==m||e[16]!==i?(y=m&&s.jsxs("dl",{className:"w-full min-w-0 text-left","aria-live":"polite",children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.lastError")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-[var(--surface-muted)] px-3 py-2 font-mono typography-meta text-muted-foreground",children:m})]}),e[15]=m,e[16]=i,e[17]=y):y=e[17];let h;e[18]!==o||e[19]!==i?(h=o&&s.jsxs("dl",{className:"w-full min-w-0 space-y-3 text-left","aria-live":"polite",children:[o.binary&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.binary")}),s.jsx("dd",{className:"break-all font-mono typography-meta",children:o.binary})]}),o.error&&s.jsxs("div",{children:[s.jsx("dt",{className:"typography-meta text-muted-foreground",children:i("startup.initRecovery.error")}),s.jsx("dd",{className:"max-h-56 overflow-y-auto whitespace-pre-wrap break-words font-mono typography-meta text-[var(--status-error)]",children:o.error})]})]}),e[18]=o,e[19]=i,e[20]=h):h=e[20];let p;e[21]!==r||e[22]!==i?(p=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[21]=r,e[22]=i,e[23]=p):p=e[23];let w;e[24]!==r||e[25]!==n||e[26]!==p?(w=s.jsx(ft,{type:"button",onClick:n,disabled:r,children:p}),e[24]=r,e[25]=n,e[26]=p,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==j||e[30]!==y||e[31]!==h?(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:[j,y,h,w]})}),e[28]=w,e[29]=j,e[30]=y,e[31]=h,e[32]=S):S=e[32],S},Bd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",f5=()=>{if(typeof window>"u"||!$x())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}},m5=t=>{const e=nt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ts(w5),l=rt(v5),a=rt(S5),d=ex(),u=c.useRef(null);let m;e[0]!==n.directory?(m=Bd(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let g;e[2]!==o?(g=Bd(o),e[2]=o,e[3]=g):g=e[3];const x=g;let b,j;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 N=`${f}
886
+ ${n.sessionId}`;u.current===N&&l||(u.current=N,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},j=[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]=j):(b=e[12],j=e[13]),c.useEffect(b,j),f&&x!==f)return null;let y;e[14]!==i?(y=s.jsx(qu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(nu,{}),e[16]=h):h=e[16];let p;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(p=s.jsx(su,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=p):p=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Yu,{}),e[21]=w):w=e[21];let S;return e[22]!==y||e[23]!==p?(S=s.jsxs(s.Fragment,{children:[y,h,p,w]}),e[22]=y,e[23]=p,e[24]=S):S=e[24],S};function h5({apis:t}){c.useEffect(()=>{ph("App:mounted"),gh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Vt(L=>L.initializeApp),n=Vt(L=>L.isInitialized),r=Vt(L=>L.isConnected),i=Vt(L=>L.providers.length),o=Vt(L=>L.agents.length),l=Vt(L=>L.loadProviders),a=Vt(L=>L.loadAgents),d=rt(L=>L.error),u=rt(L=>L.clearError),m=ts(L=>L.currentDirectory),f=ts(L=>L.setDirectory),g=ts(L=>L.isSwitchingDirectory),[x,b]=c.useState(!1),j=gn(L=>L.refreshStatus),y=Hi(L=>L.refreshStatus),[h,p]=c.useState(()=>t.runtime.isVSCode),[w,S]=c.useState(!1),[N,P]=c.useState(!1),[C,T]=c.useState(0),[O,M]=c.useState(0),[F,K]=c.useState(!1),D=ye(L=>L.wideChatLayoutEnabled),U=ye(L=>L.mobileKeyboardMode),A=c.useMemo(()=>hn(),[]),E=Ra(L=>L.setPlanModeEnabled),[W,k]=c.useState(()=>bl()),[v,I]=c.useState(()=>{const L=xl();return L!==null?yl({isDesktopShell:!0,bootOutcome:L}):null}),H=c.useRef(!1),_=c.useMemo(()=>f5(),[]),se=!_||w;c.useEffect(()=>(wl(x),Nd(x),()=>{wl(!1),Nd(!1)}),[x]),c.useEffect(()=>{bh(U)},[U]),c.useEffect(()=>{p(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>vr(L=>{jp(L),M(oe=>oe+1),P(!1),T(oe=>oe+1)}),[]);const te=zl(L=>{const oe=Yt();return Object.values(L.runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===oe).map(ce=>`${ce.originalSessionID}:${ce.phase}:${ce.lastForwardedMessageID??""}:${ce.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(_)return;const L=Yt(),oe=Object.values(zl.getState().runsByOriginalSessionID).filter(ce=>ce.status==="running"&&ce.runtimeKey===L);for(const ce of oe)Yb(ce.originalSessionID)},[te,_,O]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",D),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[D]),c.useEffect(()=>(vl(t),()=>vl(null)),[t]),c.useEffect(()=>{_||(j(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,_,r,j,y,O]),Qb();const ee=W==="valid",ue=v?.screen==="main";c.useEffect(()=>{if(!xh({isDesktopShell:A,isInitialized:n,bootOutcomeKnown:ee,bootViewIsMain:ue}))return;const L=setTimeout(()=>{const oe=document.getElementById("initial-loading");oe&&(oe.classList.add("fade-out"),setTimeout(()=>{oe.remove()},300))},150);return()=>clearTimeout(L)},[A,n,ee,ue]),c.useEffect(()=>{if(!A||W!=="malformed")return;const L=document.getElementById("initial-loading");L&&(L.textContent="Desktop startup failed — please restart the app.")},[A,W]),c.useEffect(()=>{if(A)return;const L=setTimeout(()=>{const oe=document.getElementById("initial-loading");oe&&!n&&(oe.classList.add("fade-out"),setTimeout(()=>{oe.remove()},300))},5e3);return()=>clearTimeout(L)},[A,n]),c.useEffect(()=>{let L=!1;return(async()=>{const ce=await ls("/health",{method:"GET"}).catch(()=>null);if(!ce||!ce.ok||L)return;const he=await ce.json().catch(()=>null);if(!he||L)return;const Y=he.planModeExperimentalEnabled;E(Y===!0||Y===1||Y==="1"||Y==="true")})(),()=>{L=!0}},[E]),c.useEffect(()=>{h||e()},[e,h]),c.useEffect(()=>{if(h||n)return;let L=!0,oe,ce=0;const he=10,Y=1e3,ve=async()=>{if(!L)return;if(ce>=he){P(!0);return}const Te=Vt.getState();if(Te.isInitialized){P(!1);return}ce+=1,await Te.initializeApp();const ke=Vt.getState();if(!L)return;if(ke.isInitialized){P(!1);return}if(ce>=he){P(!0);return}const xe=Math.min(Y*Math.pow(2,ce-1),16e3);oe=setTimeout(ve,xe)};return oe=setTimeout(ve,Y),()=>{L=!1,oe&&clearTimeout(oe)}},[C,n,h]),c.useEffect(()=>{n&&P(!1)},[n]),c.useEffect(()=>{if(!N)return;const L=document.getElementById("initial-loading");L&&(L.classList.add("fade-out"),setTimeout(()=>{L.remove()},300))},[N]),c.useEffect(()=>{if(h||!r||i>0&&o>0)return;let L=!0,oe=0;const ce=15,he=async()=>{const ve=Vt.getState();if(!(ve.providers.length>0&&ve.agents.length>0))try{ve.providers.length===0&&await l({source:"startupRecovery"}),Vt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};he();const Y=setInterval(()=>{if(L){if(++oe>=ce){clearInterval(Y);return}he()}},2e3);return()=>{L=!1,clearInterval(Y)}},[r,h,a,l,i,o]),c.useEffect(()=>{g||h||r&&mr.setDirectory(m)},[m,g,r,h]),c.useEffect(()=>{if(!_||typeof window>"u")return;const L=he=>{S(he?.visible===!0)},oe=he=>{if(he.origin!==window.location.origin||he.source!==window.parent)return;const Y=he.data;Y?.type===rf&&L(Y.payload)},ce=window;return ce.__openchamberSetEmbeddedVisibility=L,window.addEventListener("message",oe),_x(),()=>{window.removeEventListener("message",oe),ce.__openchamberSetEmbeddedVisibility===L&&delete ce.__openchamberSetEmbeddedVisibility}},[_]),c.useEffect(()=>{!_?.directory||h||m!==_.directory&&f(_.directory,{showOverlay:!1})},[m,_,h,f]),c.useEffect(()=>{if(!_||typeof window>"u")return;const L=oe=>{oe.storageArea===window.localStorage&&oe.key==="ui-store"&&ye.persist.rehydrate()};return window.addEventListener("storage",L),()=>{window.removeEventListener("storage",L)}},[_]),c.useEffect(()=>{if(typeof window>"u")return;const L=oe=>{const ce=oe.detail,he=typeof ce?.sessionId=="string"?ce.sessionId.trim():"";if(!he)return;const Y=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null;rt.getState().setCurrentSession(he,Y)};return window.addEventListener("openchamber:open-session",L),()=>window.removeEventListener("openchamber:open-session",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{An("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",L),()=>window.removeEventListener("openchamber:open-mini-chat",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=()=>{const oe=rt.getState().currentSessionId;oe&&Pu(oe)};return window.addEventListener("focus",L),()=>window.removeEventListener("focus",L)},[]),c.useEffect(()=>{if(typeof window>"u")return;const L=oe=>{const ce=oe.detail,he=typeof ce?.directory=="string"&&ce.directory.trim().length>0?ce.directory.trim():null,Y=typeof ce?.projectId=="string"&&ce.projectId.trim().length>0?ce.projectId.trim():null,ve=!!(he||Y);ye.getState().setSessionSwitcherOpen(!1),rt.getState().openNewSessionDraft({target:ve?"project":"chat",selectedProjectId:ve?Y:null,directoryOverride:ve?he:null,preserveDirectoryOverride:!!he})};return window.addEventListener("openchamber:open-draft-session",L),()=>window.removeEventListener("openchamber:open-draft-session",L)},[]),c.useEffect(()=>{typeof window>"u"||!n||g||H.current||(H.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),Xb({enabled:se}),UN({enabled:se}),qN(m||null),XN(),Jb(),kp(),ZN(),Zb(),px(),Cp();const de=c.useCallback(()=>{b(L=>!L)},[]);jN(de),ON(),WN(!_),c.useEffect(()=>{if(_)return;const L=()=>b(oe=>!oe);return window.addEventListener("openchamber:memory-debug-toggle",L),()=>window.removeEventListener("openchamber:memory-debug-toggle",L)},[_]),c.useEffect(()=>{_||d&&setTimeout(()=>u(),5e3)},[u,_,d]),c.useEffect(()=>{if(!A||W!=="not-injected")return;let L=!1,oe=0;const ce=200,he=2e3,Y=50,ve=()=>{if(L)return;oe++;const Te=bl();if(Te!=="not-injected"){if(L=!0,k(Te),Te==="valid"){const xe=xl();xe&&I(yl({isDesktopShell:!0,bootOutcome:xe}))}return}const ke=Math.min(ce*Math.pow(1.1,oe),he);if(oe>=Y){const xe=document.getElementById("initial-loading");xe&&!xe.textContent?.includes("taking longer")&&(xe.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ve,ke)};return window.setTimeout(ve,ce),()=>{L=!0}},[A,W]);const Re=c.useCallback(async()=>{if(yh({isDesktopShell:hn(),isDesktopLocalOriginActive:Yo()})){await wh();return}window.location.reload()},[]),we=c.useCallback(async()=>{if(!F){P(!1),K(!0);try{await Vt.getState().initializeApp()}finally{K(!1)}Vt.getState().isInitialized||T(L=>L+1)}},[F]),fe=L=>{if(L.screen==="recovery")return L.variant};if(A&&v&&v.screen!=="main"){if(v.screen==="chooser")return s.jsx(hs,{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:v.localAvailable!==!1,onCliAvailable:Re,onChooseRemote:()=>{}})})})});const L=fe(v),oe=v.screen==="recovery"&&"url"in v?v.url:void 0;return s.jsx(hs,{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:L,recoveryHostUrl:oe,recoveryHostLabel:void 0,localAvailable:v.localAvailable!==!1,onCliAvailable:Re})})})})}if(_)return s.jsx(hs,{children:s.jsx(Wl,{sdk:mr.getSdkClient(),directory:m||"",children:s.jsx(Kl,{apis:t,children:s.jsx(Xi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(m5,{embeddedSessionChat:_,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:se}),s.jsx(Vl,{}),s.jsx(Ul,{})]})})})},O)});if(N&&!n&&!h&&!_)return s.jsx(hs,{children:s.jsx(u5,{onRetry:()=>{we()},isRetrying:F},O)});const Pe=!n&&!A;return s.jsx(hs,{children:s.jsx(Wl,{sdk:mr.getSdkClient(),directory:m||"",children:s.jsx(Kl,{apis:t,children:s.jsx(U4,{children:s.jsx(Xi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:A?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(qu,{embeddedBackgroundWorkEnabled:se}),s.jsx(nu,{}),s.jsx(t5,{}),s.jsx(v4,{}),s.jsx(Np,{ready:n&&(!A||ee&&ue)}),s.jsx(Yu,{}),s.jsx(Vl,{}),s.jsx(Ul,{}),!Pe&&s.jsxs(s.Fragment,{children:[s.jsx(Ap,{}),s.jsx(d5,{}),x&&s.jsx(nN,{onClose:()=>b(!1)})]})]})})})})},O)})}function p5(t){const e=nt.c(2);let n;return e[0]!==t?(n=s.jsx(Sp,{children:s.jsx(h5,{...t})}),e[0]=t,e[1]=n):n=e[1],n}function g5(t){return t.isAboutDialogOpen}function b5(t){return t.setAboutDialogOpen}function x5(){}function y5(t){return t.lastInitFailure}function w5(t){return t.currentDirectory}function v5(t){return t.currentSessionId}function S5(t){return t.setCurrentSession}const j5=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();tx();vh().then(()=>{Promise.all([Sh(),sx()]).catch(t=>{console.error("[main] settings init failed:",t)}),nx(),rx(),ox()}).catch(t=>{console.error("[main] appearance init failed:",t)});const wm=document.getElementById("root");if(!wm)throw new Error("Root element not found");ix();Hm.createRoot(wm).render(s.jsx(at.StrictMode,{children:s.jsx(ax,{children:s.jsx(lx,{children:s.jsx(cx,{children:s.jsx(dx,{children:s.jsx(p5,{apis:j5})})})})})}));const V5=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{p1 as W,r1 as a,K5 as b,wf as g,V5 as m,h1 as u,yf as v};