@openchamber/web 1.18.4 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
  3. package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-C-F3AX6D.js} +1 -1
  4. package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-BPECg1jS.js} +1 -1
  5. package/dist/assets/DiagramView-D0YNMix8.js +1 -0
  6. package/dist/assets/DiffView-BHWaMYCC.js +4 -0
  7. package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
  8. package/dist/assets/{GitView-DBFrDDBv.js → GitView-Rp8P1KEI.js} +4 -4
  9. package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-KnXFN2A-.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-BMn3mtor.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
  12. package/dist/assets/OnboardingScreen-CenIeD4v.js +1 -0
  13. package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-BzVOVog8.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
  15. package/dist/assets/PlanView-Czu1KMJa.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
  17. package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
  18. package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
  19. package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
  20. package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
  21. package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
  22. package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-CaSYE0lw.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +1 -0
  25. package/dist/assets/de-DFdX3ABv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-iC-FKvV9.js +15 -0
  28. package/dist/assets/fr-BBbi_1AL.js +13 -0
  29. package/dist/assets/index-BiEgzzkg.js +1 -0
  30. package/dist/assets/index-Cwmuwk3V.js +7 -0
  31. package/dist/assets/index-GNm1wgUH.css +1 -0
  32. package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-BG53Ixxy.js} +1 -1
  33. package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-BbV-39jl.js} +1 -1
  34. package/dist/assets/ja-DQLQJL2J.js +15 -0
  35. package/dist/assets/ko-BeElEB4Y.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-Dpzo18z7.js +2 -0
  38. package/dist/assets/main-WMjtYzJs.js +921 -0
  39. package/dist/assets/markdownCore--tDmyI_v.js +2 -0
  40. package/dist/assets/miniChat-ldEghBLB.js +2 -0
  41. package/dist/assets/mobile-Dk-VGreF.js +2 -0
  42. package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BcFaMtMu.js} +1 -1
  43. package/dist/assets/pl-CLHt2_vV.js +15 -0
  44. package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
  46. package/dist/assets/renderMobileApp-CDfHS5rr.js +25 -0
  47. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
  48. package/dist/assets/scheduledTasksApi-BFSlqgnG.js +1 -0
  49. package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DCT2Sq_z.js} +1 -1
  50. package/dist/assets/uk-PhsC-c4-.js +15 -0
  51. package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-B53Rb6m7.js} +168 -164
  52. package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-DsHmyMwp.js} +1 -1
  54. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
  55. package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
  56. package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
  60. package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
  61. package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
  62. package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
  63. package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
  67. package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
  68. package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
  77. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
  78. package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
  79. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
  80. package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
  81. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
  82. package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
  83. package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
  84. package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
  85. package/dist/assets/{web-components-GMc3oR3i.js → web-components-pcwCTWjC.js} +4 -4
  86. package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
  87. package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
  88. package/dist/index.html +5 -4
  89. package/dist/mini-chat.html +4 -3
  90. package/dist/mobile.html +4 -3
  91. package/package.json +3 -5
  92. package/server/index.js +152 -3
  93. package/server/lib/agent-memory/actions.js +243 -0
  94. package/server/lib/agent-memory/actions.test.js +343 -0
  95. package/server/lib/agent-memory/feature-flag.js +19 -0
  96. package/server/lib/agent-memory/feature-flag.test.js +38 -0
  97. package/server/lib/agent-memory/project-resolution.js +65 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +94 -0
  99. package/server/lib/agent-memory/routes.http.test.js +270 -0
  100. package/server/lib/agent-memory/routes.js +169 -0
  101. package/server/lib/agent-memory/runtime.js +432 -0
  102. package/server/lib/agent-memory/runtime.test.js +344 -0
  103. package/server/lib/agent-memory/threat-patterns.js +61 -0
  104. package/server/lib/agent-memory/threat-patterns.test.js +61 -0
  105. package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
  106. package/server/lib/agent-tool/runtime.js +63 -13
  107. package/server/lib/agent-tool/runtime.test.js +85 -2
  108. package/server/lib/context-obligatory/runtime.js +34 -3
  109. package/server/lib/context-obligatory/runtime.test.js +114 -0
  110. package/server/lib/dictation/DOCUMENTATION.md +32 -8
  111. package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
  112. package/server/lib/dictation/local/worker-process.js +2 -2
  113. package/server/lib/dictation/openai-compatible-session.js +3 -2
  114. package/server/lib/dictation/stream-manager.js +77 -34
  115. package/server/lib/dictation/stream-manager.test.js +60 -2
  116. package/server/lib/fs/DOCUMENTATION.md +3 -0
  117. package/server/lib/fs/routes.js +149 -32
  118. package/server/lib/fs/routes.test.js +301 -0
  119. package/server/lib/git/DOCUMENTATION.md +8 -0
  120. package/server/lib/git/routes.js +43 -0
  121. package/server/lib/git/service.js +206 -72
  122. package/server/lib/git/service.test.js +222 -0
  123. package/server/lib/github/DOCUMENTATION.md +14 -3
  124. package/server/lib/github/pr-status.js +188 -83
  125. package/server/lib/github/pr-status.test.js +182 -0
  126. package/server/lib/github/routes.js +36 -30
  127. package/server/lib/notifications/template-runtime.js +2 -3
  128. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  129. package/server/lib/openchamber-control/actions.js +78 -0
  130. package/server/lib/openchamber-control/service.js +7 -0
  131. package/server/lib/openchamber-sessions/routes.js +14 -0
  132. package/server/lib/opencode/DOCUMENTATION.md +12 -6
  133. package/server/lib/opencode/claude-cli-auth.js +60 -0
  134. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  135. package/server/lib/opencode/feature-routes-runtime.js +16 -9
  136. package/server/lib/opencode/lifecycle.js +202 -26
  137. package/server/lib/opencode/lifecycle.test.js +179 -1
  138. package/server/lib/opencode/plugins.js +12 -3
  139. package/server/lib/opencode/plugins.test.js +18 -0
  140. package/server/lib/opencode/providers.js +9 -4
  141. package/server/lib/opencode/providers.test.js +27 -0
  142. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  143. package/server/lib/opencode/proxy.js +116 -6
  144. package/server/lib/opencode/proxy.test.js +158 -1
  145. package/server/lib/opencode/restart-session-recovery.test.js +59 -0
  146. package/server/lib/opencode/routes.js +4 -1
  147. package/server/lib/opencode/session-runtime.js +39 -2
  148. package/server/lib/opencode/session-runtime.test.js +74 -0
  149. package/server/lib/opencode/settings-helpers.js +26 -0
  150. package/server/lib/opencode/settings-helpers.test.js +57 -0
  151. package/server/lib/opencode/settings-normalization-runtime.js +3 -0
  152. package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
  153. package/server/lib/opencode/settings-runtime.js +83 -10
  154. package/server/lib/opencode/settings-runtime.test.js +85 -0
  155. package/server/lib/opencode/shared.js +120 -16
  156. package/server/lib/opencode/shared.test.js +185 -1
  157. package/server/lib/opencode/skill-routes.js +29 -73
  158. package/server/lib/opencode/skill-routes.test.js +2 -5
  159. package/server/lib/project-context/DOCUMENTATION.md +160 -0
  160. package/server/lib/project-context/routes.http.test.js +264 -0
  161. package/server/lib/project-context/routes.js +237 -0
  162. package/server/lib/project-context/runtime.js +672 -0
  163. package/server/lib/project-context/runtime.test.js +498 -0
  164. package/server/lib/projects/project-config.js +7 -2
  165. package/server/lib/quota/DOCUMENTATION.md +17 -2
  166. package/server/lib/quota/providers/claude/auth.js +113 -0
  167. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  168. package/server/lib/quota/providers/claude/index.js +151 -0
  169. package/server/lib/quota/providers/claude/index.test.js +147 -0
  170. package/server/lib/quota/providers/claude/transforms.js +127 -0
  171. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  172. package/server/lib/quota/providers/command-code.js +90 -0
  173. package/server/lib/quota/providers/command-code.test.js +85 -0
  174. package/server/lib/quota/providers/index.js +30 -2
  175. package/server/lib/quota/providers/index.test.js +10 -1
  176. package/server/lib/quota/providers/zai.js +26 -6
  177. package/server/lib/quota/providers/zai.test.js +33 -0
  178. package/server/lib/quota/utils/formatters.js +2 -1
  179. package/server/lib/scheduled-tasks/runtime.js +21 -2
  180. package/server/lib/session-knowledge/DOCUMENTATION.md +89 -0
  181. package/server/lib/session-knowledge/routes.js +107 -0
  182. package/server/lib/session-knowledge/runtime.js +331 -0
  183. package/server/lib/session-knowledge/runtime.test.js +275 -0
  184. package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
  185. package/server/lib/skills-catalog/cache.js +120 -1
  186. package/server/lib/skills-catalog/cache.test.js +77 -0
  187. package/server/lib/skills-catalog/curated-sources.js +21 -5
  188. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  189. package/server/lib/skills-catalog/disk-cache.js +52 -0
  190. package/server/lib/skills-catalog/github-meta.js +139 -0
  191. package/server/lib/skills-catalog/github-meta.test.js +71 -0
  192. package/server/lib/skills-catalog/source.js +0 -5
  193. package/server/lib/small-model/DOCUMENTATION.md +74 -6
  194. package/server/lib/small-model/call.js +46 -12
  195. package/server/lib/small-model/call.test.js +79 -0
  196. package/server/lib/small-model/index.js +57 -6
  197. package/server/lib/small-model/index.test.js +102 -2
  198. package/server/lib/small-model/routes.js +4 -2
  199. package/server/lib/small-model/runtime-providers.js +156 -0
  200. package/server/lib/small-model/runtime-providers.test.js +112 -0
  201. package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
  202. package/dist/assets/DiffView-DZIoOnV7.js +0 -4
  203. package/dist/assets/FilesView-BKL6YlKG.js +0 -14
  204. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
  205. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
  206. package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
  207. package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
  208. package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
  209. package/dist/assets/SettingsView-5RmswFZe.js +0 -28
  210. package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
  211. package/dist/assets/ToolOutputDialog-Za6V4VMJ.js +0 -15
  212. package/dist/assets/ToolPartDiffPreview-BL-9ixyC.js +0 -8
  213. package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
  214. package/dist/assets/de-u7gSnqWs.js +0 -9
  215. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  216. package/dist/assets/es-T9O7aAOr.js +0 -15
  217. package/dist/assets/fr-Oor7ewbE.js +0 -13
  218. package/dist/assets/index-BzIpNlNE.css +0 -1
  219. package/dist/assets/index-C0yNhuZw.js +0 -1
  220. package/dist/assets/index-DRpChWux.js +0 -7
  221. package/dist/assets/ja-DHpqbVmr.js +0 -15
  222. package/dist/assets/ko-CwLkS3nx.js +0 -15
  223. package/dist/assets/main-D7UcL3VQ.js +0 -2
  224. package/dist/assets/main-DPMd2iKS.js +0 -915
  225. package/dist/assets/markdownCore-DDrHVneM.js +0 -2
  226. package/dist/assets/miniChat-O_GVoEbc.js +0 -2
  227. package/dist/assets/mobile-Br4TtAqc.js +0 -2
  228. package/dist/assets/pl-CcZILN8q.js +0 -15
  229. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  230. package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
  231. package/dist/assets/renderMobileApp-toj9cXoh.js +0 -25
  232. package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
  233. package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
  234. package/dist/assets/uk-BA2kZR38.js +0 -15
  235. package/dist/assets/useInlineCommentController-CYPvYJDt.js +0 -2
  236. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  237. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  238. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  239. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  240. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  241. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  242. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  243. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  244. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  245. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  246. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  247. package/server/lib/quota/providers/claude.js +0 -107
  248. package/server/lib/skills-catalog/clawdhub/api.js +0 -126
  249. package/server/lib/skills-catalog/clawdhub/install.js +0 -238
  250. package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
  251. package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
@@ -0,0 +1,15 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BiEgzzkg.js","assets/useAppFontEffects-B53Rb6m7.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-Cwmuwk3V.js","assets/vendor-zod-C9ioTTSo.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-GNm1wgUH.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-DsHmyMwp.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-BEARQjgn.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.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-vch3tJ4c.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-DkRR5b75.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/isFilePlainText-BbV-39jl.js","assets/isDiffPlainText-BG53Ixxy.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-Czu1KMJa.js","assets/shikiHighlight-DCT2Sq_z.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-DSfrIBKT.js","assets/CodeMirrorCommentWidgets-C36E738Y.js","assets/vendor-ghostty-web-CrxinGGH.js","assets/vendor-capacitor-keyboard-CYccoJjr.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Gt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as Ge,r as le,j as t,R as m}from"./vendor-react-BUCujlKS.js";import{e4 as bo,aH as yo,f as Qe,o as wo,bu as Is,bv as Ts,bx as Ds,I as R,bW as vo,bS as Bn,h as se,B as Ne,b0 as vr,g as jo,t as ke,e5 as ko,e6 as So,e7 as No,O as Co,dN as Io,e8 as To,e9 as Do,ea as Po,y as rt,eb as Eo,d6 as Ro,d9 as Ao,da as Bo,l as kt,ec as Mo,dq as jr,ed as Lo,dr as Fo,bT as Ps,cQ as Oo,bw as Gs,aW as Hs,ee as Uo,ef as $o,eg as Wo,eh as _o,ei as zo,ej as Vo,ek as Go,el as Ho,b as Ct,c2 as Ko,_ as Mn,dm as qo,dJ as kr,dy as Sr,dA as Yo,em as Jo,u as gn,ct as Qo,en as xn,S as yt,cA as Xo,eo as Ln,ep as Zo,eq as ea,er as Fn,es as ta,et as sa,eu as na,ev as ra,aX as oa,ew as aa,aV as $t,aS as Wt,aU as _t,bR as Ks,bM as Nr,bN as Cr,ex as Ir,bO as Tr,bP as Dr,bQ as Ws,L as Pr,N as ia,ey as la,ez as On,eA as ca,T as da,U as ua,R as fa,eB as Er,w as ma,x as ha,eC as pa,eD as ga,eE as xa,eF as ba,aY as Ht,aZ as Kt,a_ as qt,co as bn,cp as yn,cq as wn,cr as vn,cj as Ft,ck as Et,eG as ps,aR as At,M as Ss,by as ya,bz as Tn,eH as Un,V as Dn,aj as _s,c0 as wa,eI as Rr,bU as va,dF as ja,a4 as Pn,eJ as Zs,m as Ar,cU as gs,eK as $n,eL as Wn,cS as _n,bV as ka,eM as Sa,eN as Na,dz as Ca,eO as Ia,eP as Ta,af as Bs,ag as zn,eQ as Da,eR as Pa,dX as Pt,eS as Ea,eT as Ra,eU as Rt,eV as jn,eW as Aa,eX as Ms,c7 as Ba,eY as Ma,eZ as La,e_ as Fa,e$ as Oa,f0 as Ua,f1 as $a,d8 as Wa,dl as _a,cD as za,d7 as Va,f2 as Ga,ah as Ha,a0 as Ka,bK as qa,f3 as Br,e1 as Ya,df as Ja,f4 as Qa,f5 as Xa,f6 as Za,bH as ei,cI as ti}from"./useAppFontEffects-B53Rb6m7.js";import{aj as Vn,ak as si,al as Gn,am as ni,i as ri,an as oi,E as Mr,_ as ai,r as Bt,u as Pe,z as ii,b as li,t as ci,a as en,d as Hn,L as Lr,W as di,ao as Lt,o as ui,m as Es,y as Fr,a0 as fi,a1 as mi,ap as hi,aq as pi,v as xs,U as gi,ar as xi,a8 as bi,as as ws,at as tn,au as Or,T as yi,n as wi,x as vi}from"./index-Cwmuwk3V.js";import{C as ji,c as ki,b as Si,d as Ni,S as Ci,M as Ii,a as Ti,g as Di,h as Pi,i as Ei}from"./vendor-base-ui-DsHmyMwp.js";import{c as qs,d as Ur,p as $r,a as Ri}from"./vendor-zustand-BAGL70zf.js";import{i as Wr}from"./contextPanelEmbeddedChat-BEARQjgn.js";import{toast as Kn}from"./vendor-sonner-DFyL3AvE.js";import{f as _r,h as zr,P as Vr,k as Ai,D as Gr,j as Hr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Kr,S as qr,h as Bi,v as Mi,a as Li}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const Fi=["typescript","javascript","tsx","jsx","json","markdown"],Jr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let qn=null;const Qr=()=>(qn??=Promise.all([Gt(()=>import("./index-BiEgzzkg.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])),Gt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Gt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([112,113,99,100,6,84,85,86,87,88,89,90,91,92,93,94,95,96,97]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),qn),Ns={},Yn=new Set,kn=new Set;let Us={light:"pierre-light",dark:"pierre-dark"};const Oi=()=>{for(const s of kn)s()},Xr=(s,e)=>{e.setRenderOptions({theme:Us,lineDiffType:Jr[s].lineDiffType})},Sn=s=>{typeof window>"u"||Yn.has(s)||(Yn.add(s),Qr().then(e=>{if(Ns[s])return;const n=Jr[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Fi,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),Ns[s]=r,Xr(s,r),Oi()}))},Ui=s=>(kn.add(s),()=>kn.delete(s)),$i=s=>{if(!(Us.light===s.light&&Us.dark===s.dark)){Us=s;for(const e of Object.keys(Ns)){const n=Ns[e];n&&Xr(e,n)}}},zu=s=>{const e=Ge.c(15),{children:n}=s,r=bo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Vn(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=Vn(!0),e[1]=i):i=e[1];const f=i,c=r?.lightThemeId??a.metadata.id,d=r?.darkThemeId??f.metadata.id;let l;e[2]!==c||e[3]!==r?.availableThemes?(l=r?.availableThemes.find(S=>S.metadata.id===c)??a,e[2]=c,e[3]=r?.availableThemes,e[4]=l):l=e[4];const g=l;let h;e[5]!==d||e[6]!==r?.availableThemes?(h=r?.availableThemes.find(S=>S.metadata.id===d)??f,e[5]=d,e[6]=r?.availableThemes,e[7]=h):h=e[7];const p=h;let u,y;e[8]!==p||e[9]!==g?(u=()=>{let S=!1;return Qr().then(P=>{S||(P.ensurePierreThemeRegistered(g),P.ensurePierreThemeRegistered(p),$i({light:g.metadata.id,dark:p.metadata.id}))}),()=>{S=!0}},y=[p,g],e[8]=p,e[9]=g,e[10]=u,e[11]=y):(u=e[10],y=e[11]),le.useEffect(u,y);let k;e[12]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[12]=k):k=e[12],le.useEffect(_i,k);let N;return e[13]!==n?(N=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=N):N=e[14],N},Vu=s=>{const e=Ge.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>Ns[n],e[0]=n,e[1]=r):r=e[1];const o=le.useSyncExternalStore(Ui,r,zi);let a,i;return e[2]!==n?(a=()=>{Sn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),le.useEffect(a,i),o};function Wi(){Sn("unified"),Sn("split")}function _i(){if(typeof window>"u")return;const s=Wi;if(typeof window.requestIdleCallback=="function"){const n=window.requestIdleCallback(s,{timeout:5e3});return()=>window.cancelIdleCallback(n)}const e=window.setTimeout(s,2e3);return()=>window.clearTimeout(e)}function zi(){}const Jn="openchamber.update-install-id";function Vi(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(Jn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(Jn,e),e}catch{return}}function Gi(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=yo();return s}catch{return"unknown"}}function Hi(){const s=typeof window<"u"?window.__OPENCHAMBER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(s==="arm64"||s==="aarch64")return"arm64";if(s==="x64"||s==="amd64"||s==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const r=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(r==="arm"||r==="arm64"||r==="aarch64")return"arm64";if(r==="x86"||r==="x64"||r==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function Ki(){const s=li();if(s==="android"||s==="ios")return s;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function qi(s){const e=Pe.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",Gi()),n.set("arch",Hi()),n.set("platform",Ki()),e&&(s==="desktop"||s==="mobile")){const r=Vi();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",ii()?"local":"remote"),n):s==="vscode"?(n.set("appType","vscode"),n.set("instanceMode","local"),n):s==="mobile"?(n.set("appType","mobile-capacitor"),n.set("instanceMode","remote"),n):(n.set("appType","web"),n.set("instanceMode","unknown"),n)}async function Ls(s,e){try{const n=qi(s),r=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?n.set("currentVersion",e):s==="vscode"&&r&&n.set("currentVersion",r);const o=await Bt(`/api/openchamber/update-check?${n.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);const a=await o.json();return{available:a.available??!1,version:a.version,currentVersion:a.currentVersion??"unknown",body:a.body,releaseUrl:a.releaseUrl,downloadUrl:a.downloadUrl,nextSuggestedCheckInSec:typeof a.nextSuggestedCheckInSec=="number"&&Number.isFinite(a.nextSuggestedCheckInSec)?a.nextSuggestedCheckInSec:void 0,packageManager:a.packageManager,updateCommand:a.updateCommand}}catch(n){return console.warn("Failed to check for updates:",n),null}}function Yi(){return ri()?"mobile":oi()?"desktop":Mr()?"vscode":ai()?"web":null}const Qn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Ji=qs()((s,e)=>({...Qn,checkForUpdates:async()=>{const n=Yi();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.20.0",[i,f]=await Promise.allSettled([Gn(),Ls("desktop",a)]),c=i.status==="fulfilled"?i.value:null;return o=f.status==="fulfilled"?f.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:c?.available??!1,info:c,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Ls("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Ls("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Ls("mobile","1.20.0"),o=r?.nextSuggestedCheckInSec??null);return s({checking:!1,available:n==="vscode"?!1:r?.available??!1,info:n==="vscode"?null:r,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(r){return s({checking:!1,error:r instanceof Error?r.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:n,runtimeType:r}=e();if(!(r!=="desktop"||!n)){s({downloading:!0,error:null,progress:null});try{const o=await Gn();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(s(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await ni(i=>{s({progress:i})}))throw new Error("Desktop update only works on Local instance");s({downloading:!1,downloaded:!0})}catch(o){s({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:n,runtimeType:r}=e();if(!(r!=="desktop"||!n))try{if(!await si())throw new Error("Desktop restart only works on Local instance")}catch(o){s({error:o instanceof Error?o.message:"Failed to restart"})}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Qn)}})),Xn="https://github.com/openchamber/openchamber/releases";function Qi(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(vr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function Xi(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Zn(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Zi(s,e){const n=s.split(".").map(o=>Number.parseInt(o,10)),r=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(n[o])?n[o]:0,i=Number.isFinite(r[o])?r[o]:0;if(a!==i)return i-a}return 0}function el(s){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[];let r;for(;(r=e.exec(s))!==null;)n.push({version:r[1]??"",date:r[2]??"",start:r.index});return n.length===0?[]:n.map((o,a)=>{const i=n[a+1]?.start??s.length,f=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:f}})}const er=2e3,tl=600*1e3;async function sl(){try{const s=await Bt("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}});return s.ok?{success:!0,autoRestart:(await s.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await s.json().catch(()=>({}))).error||`Server error: ${s.status}`}}catch(s){return{success:!1,error:s instanceof Error?s.message:void 0}}}async function nl(){try{return(await Bt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function rl(s,e=Math.ceil(tl/er),n=er){for(let r=0;r<e;r++){try{const o=await Bt("/api/openchamber/update-check?reportUsage=false",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);if(a&&a.available===!1||a&&typeof a.currentVersion=="string"&&typeof s=="string"&&a.currentVersion!==s)return!0}else if((o.status===401||o.status===403)&&await nl())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Gu=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:f,onRestart:c,runtimeType:d="desktop"})=>{const{t:l}=Qe(),[g,h]=le.useState(!1),[p,u]=le.useState("idle"),[y,k]=le.useState(null),N=n?.version?n.releaseUrl||`${Xn}/tag/v${n.version}`:Xn,S=n?.downloadUrl||N,P=a?.total?Math.round(a.downloaded/a.total*100):0,O=d==="web",w=d==="mobile",v=n?.updateCommand||"openchamber update";le.useEffect(()=>{s||(u("idle"),k(null))},[s]);const b=async()=>{(await jo(v)).ok&&(h(!0),setTimeout(()=>h(!1),2e3))},D=le.useCallback(async U=>{await wo(U)},[]),C=le.useCallback(async()=>{u("updating"),k(null);const U=await sl();if(!U.success){u("error"),k(U.error||l("updateDialog.error.updateFailed"));return}U.autoRestart&&(u("restarting"),await new Promise(F=>setTimeout(F,2e3))),u("reconnecting"),await rl(n?.currentVersion)?window.location.reload():(u("error"),k(l("updateDialog.error.takingLonger")))},[n?.currentVersion,l]),_=le.useCallback(()=>{D(S)},[D,S]),L=p!=="idle"&&p!=="error",H=le.useMemo(()=>{if(!n?.body)return null;const U=n.body.trim();if(!U)return null;const Y=el(U);if(Y.length===0)return{kind:"raw",title:l("updateDialog.changelog.title"),content:Zn(U)};const F=[...Y].sort((te,$)=>Zi(te.version,$.version));return{kind:"sections",title:l("updateDialog.changelog.title"),sections:F.map(te=>({version:te.version,dateLabel:Qi(te.date),content:Zn(Xi(te.raw)||U)}))}},[n?.body,l]);return t.jsx(Is,{open:s,onOpenChange:L?void 0:e,children:t.jsxs(Ts,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Ds,{className:"flex items-center gap-2.5",children:[t.jsx(R,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:l(p==="restarting"||p==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(n?.currentVersion||n?.version)&&t.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ml-3",children:[n?.currentVersion&&t.jsx("span",{className:"text-muted-foreground",children:n.currentVersion}),n?.currentVersion&&n?.version&&t.jsx("span",{className:"text-muted-foreground/50",children:"→"}),n?.version&&t.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:n.version})]})]}),t.jsxs("div",{className:"space-y-2",children:[O&&L&&t.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(R,{name:"loader",className:"h-5 w-5 animate-spin text-[var(--primary-base)]"}),t.jsxs("div",{className:"typography-ui-label text-foreground",children:[p==="updating"&&l("updateDialog.status.installingUpdate"),p==="restarting"&&l("updateDialog.status.serverRestarting"),p==="reconnecting"&&l("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:l("updateDialog.status.autoReloadHint")})]}),H&&!L&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(vo,{className:"max-h-[400px] p-0",fillContainer:!1,children:H.kind==="raw"?t.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:U=>{const F=U.target.closest("a");F&&F.href&&(U.preventDefault(),U.stopPropagation(),D(F.href))},children:t.jsx(Bn,{content:H.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:H.sections.map(U=>t.jsxs("div",{className:"p-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",U.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:U.dateLabel})]}),t.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline",onClickCapture:Y=>{const te=Y.target.closest("a");te&&te.href&&(Y.preventDefault(),Y.stopPropagation(),D(te.href))},children:t.jsx(Bn,{content:U.content,disableLinkSafety:!0,enableFileReferences:!1})})]},U.version))})})}),O&&p==="error"&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(R,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:l("updateDialog.fallback.updateViaTerminal")})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]",children:[t.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:v}),t.jsx("button",{onClick:b,className:se("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",g&&"text-[var(--status-success)]"),title:l(g?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:g?t.jsx(R,{name:"check",className:"h-4 w-4"}):t.jsx(R,{name:"clipboard",className:"h-4 w-4"})})]})]}),!O&&!w&&r&&t.jsxs("div",{className:"space-y-2 mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:l("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[P,"%"]})]}),t.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${P}%`}})})]}),(i||y)&&t.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:t.jsx("p",{className:"text-sm text-[var(--status-error)]",children:i||y})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:N,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!O&&!w&&!o&&!r&&t.jsxs("button",{onClick:f,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),l("updateDialog.actions.downloadUpdate")]}),!O&&!w&&r&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),l("updateDialog.status.downloading")]}),!O&&!w&&o&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"restart",className:"h-4 w-4"}),l("updateDialog.actions.restartToUpdate")]}),w&&t.jsxs(Ne,{onClick:_,size:"default",children:[t.jsx(R,{name:"external-link",className:"h-4 w-4"}),l("updateDialog.actions.openMobileUpdate")]}),O&&!L&&t.jsxs("button",{onClick:C,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(R,{name:"download",className:"h-4 w-4"}),l("updateDialog.actions.updateNow")]}),O&&L&&t.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[t.jsx(R,{name:"loader",className:"h-4 w-4 animate-spin"}),l("updateDialog.status.updating")]})]})]})]})})},Hu=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),ol=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),al=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},il=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),ms="opencode-update-available",Fs="opencode-upgrade-progress",ll=5e3,cl=[1e4,6e4],tr="opencode-update-toast-dismissed-version",Ku=()=>{const{t:s}=Qe(),e=Pe(i=>i.showOpenCodeUpdateNotifications),n=le.useRef(new Set),r=le.useRef(!1);le.useEffect(()=>{e||ke.dismiss(ms)},[e]);const o=le.useCallback(()=>{ke.dismiss(Fs),ko({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=le.useCallback(async()=>{if(!r.current){r.current=!0,ke.dismiss(ms),ke.message(s("opencodeUpdate.toast.upgrading.title"),{id:Fs,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(R,{name:"refresh",className:"h-4 w-4 animate-spin text-muted-foreground"})});try{const i=await Bt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),f=await i.json().catch(()=>null);if(!i.ok||f?.success===!1)throw new Error(f?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));ke.success(s("opencodeUpdate.toast.updated.title"),{id:Fs,description:f?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:f.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(R,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){ke.error(s("opencodeUpdate.toast.failed.title"),{id:Fs,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return le.useEffect(()=>{const i=h=>{if(!Pe.getState().showOpenCodeUpdateNotifications){ke.dismiss(ms);return}ol({version:h,dismissedVersion:Hn().getItem(tr),seenVersions:n.current})&&(n.current.add(h),ke.info(s("opencodeUpdate.toast.available.title"),{id:ms,description:s("opencodeUpdate.toast.available.description",{version:h}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Hn().setItem(tr,h),Lr({openCodeUpdateToastDismissedVersion:h}),ke.dismiss(ms)}}}))};let f=!1;const c=[],d=async(h,p=en())=>{try{const u=await Bt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!u.ok)throw new Error(u.statusText||"OpenCode upgrade status check failed");const y=await u.json().catch(()=>null),k=il(y);!f&&p===en()&&k&&i(k)}catch{const u=cl[h];!f&&p===en()&&u!==void 0&&c.push(setTimeout(()=>{d(h+1,p)},u))}},l=h=>{al(h.detail)&&d(0)};e&&c.push(setTimeout(()=>{d(0)},ll));const g=ci(({runtimeKey:h})=>{n.current.clear(),ke.dismiss(ms),Pe.getState().showOpenCodeUpdateNotifications&&d(0,h)});return window.addEventListener("openchamber:opencode-update-available",l),()=>{f=!0;for(const h of c)clearTimeout(h);g(),window.removeEventListener("openchamber:opencode-update-available",l)}},[a,e,s]),null},qu=()=>{const s=Ge.c(3),[e,n]=m.useState(dl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>No(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),m.useEffect(o,a),!r)return null;let i;return s[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:t.jsx(Co,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function dl(){return So()}class ul extends m.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){this.setState({error:e,errorInfo:n})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?t.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:t.jsxs(Io,{className:"w-full max-w-md",children:[t.jsx(To,{className:"text-center",children:t.jsxs(Do,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(R,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(Po,{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&t.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&t.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[t.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),t.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(Ne,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(R,{name:"restart",className:"h-4 w-4 mr-2"}),this.props.texts.resetAction]})}),t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function fl(s){const e=Ge.c(22),{t:n}=Qe();let r;e[0]!==n?(r=n("chat.errorBoundary.title"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==n?(o=n("chat.errorBoundary.description"),e[2]=n,e[3]=o):o=e[3];let a;e[4]!==n?(a=n("chat.errorBoundary.sessionLabel"),e[4]=n,e[5]=a):a=e[5];let i;e[6]!==n?(i=n("chat.errorBoundary.detailsSummary"),e[6]=n,e[7]=i):i=e[7];let f;e[8]!==n?(f=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=f):f=e[9];let c;e[10]!==n?(c=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=c):c=e[11];let d;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==f||e[17]!==c?(d={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:f,persistentHint:c},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=f,e[17]=c,e[18]=d):d=e[18];let l;return e[19]!==s||e[20]!==d?(l=t.jsx(ul,{...s,texts:d}),e[19]=s,e[20]=d,e[21]=l):l=e[21],l}const Yu=s=>{const e=Ge.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,f=o===void 0?!1:o,d=rt(ml)||void 0;let l;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==f?(l=t.jsx(Eo,{active:i,messagesEnabled:r,readOnly:f,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=f,e[4]=l):l=e[4];let g;return e[5]!==d||e[6]!==l?(g=t.jsx(fl,{sessionId:d,children:l}),e[5]=d,e[6]=l,e[7]=g):g=e[7],g};function ml(s){return s.currentSessionId}function Ju(s){const e=Ge.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(ji,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Qu(s){const e=Ge.c(4);let n;e[0]!==s?({...n}=s,e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=t.jsx(ki,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Xu(s){const e=Ge.c(20);let n,r,o,a,i;e[0]!==s?({className:r,positionerClassName:o,children:n,style:i,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a,e[5]=i):(n=e[1],r=e[2],o=e[3],a=e[4],i=e[5]);let f;e[6]!==o?(f=se("app-region-no-drag z-50",o),e[6]=o,e[7]=f):f=e[7];let c;e[8]!==i?(c={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=c):c=e[9];let d;e[10]!==r?(d=se(Ro,r),e[10]=r,e[11]=d):d=e[11];let l;e[12]!==n||e[13]!==a||e[14]!==c||e[15]!==d?(l=t.jsx(Si,{"data-slot":"dropdown-menu-content",style:c,className:d,...a,children:n}),e[12]=n,e[13]=a,e[14]=c,e[15]=d,e[16]=l):l=e[16];let g;return e[17]!==f||e[18]!==l?(g=t.jsx(Ii,{children:t.jsx(Ti,{className:f,children:l})}),e[17]=f,e[18]=l,e[19]=g):g=e[19],g}function Zu(s){const e=Ge.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=se(Ao,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Ni,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function ef(s){const e=Ge.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=se(Bo,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Ci,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const hl=Pi,pl=s=>{const e=Ge.c(14);let n,r,o,a;e[0]!==s?({className:o,asChild:n,children:r,...a}=s,e[0]=s,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);let i;e[5]!==n||e[6]!==r?(i=n&&le.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const f=i;let c;e[8]!==o?(c=se("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==f||e[12]!==c?(d=t.jsx(Di,{className:c,...a,...f}),e[10]=a,e[11]=f,e[12]=c,e[13]=d):d=e[13],d},gl=s=>{const e=Ge.c(8);let n,r;e[0]!==s?({className:n,...r}=s,e[0]=s,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let o;e[3]!==n?(o=se("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Ei,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},sr=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function xl(s){const e=Ge.c(131),{t:n}=Qe(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:f,allowRunAsGoal:c,onConfirm:d}=s,l=f===void 0?!1:f,g=c===void 0?!1:c;let h;e[0]!==g?(h=g&&!Mr(),e[0]=g,e[1]=h):h=e[1];const p=h,u=kt(Tl),y=kt(Il),k=Mo(Cl),N=kt(Nl),S=kt(Sl),P=kt(kl),O=kt(jl),w=kt(vl);let v;e[2]!==w||e[3]!==P||e[4]!==S||e[5]!==O?(v=()=>sr({providerID:S,modelID:P,variant:O,agent:w}),e[2]=w,e[3]=P,e[4]=S,e[5]=O,e[6]=v):v=e[6];const[b,D]=m.useState(v);let C,_;e[7]!==k||e[8]!==y||e[9]!==u||e[10]!==r||e[11]!==i?(C=()=>{r&&(u({directory:i,source:"todoSendDialog"}),y({directory:i}),k())},_=[r,u,y,k,i],e[7]=k,e[8]=y,e[9]=u,e[10]=r,e[11]=i,e[12]=C,e[13]=_):(C=e[12],_=e[13]),m.useEffect(C,_);let L,H;e[14]!==w||e[15]!==P||e[16]!==S||e[17]!==O||e[18]!==r?(L=()=>{r&&D(sr({providerID:S,modelID:P,variant:O,agent:w}))},H=[r,S,P,O,w],e[14]=w,e[15]=P,e[16]=S,e[17]=O,e[18]=r,e[19]=L,e[20]=H):(L=e[19],H=e[20]),m.useEffect(L,H);let U,Y;e[21]!==b.modelID||e[22]!==b.providerID||e[23]!==r||e[24]!==N?(U=()=>{if(!r||N.length===0)return;const x=N.find(ve=>ve.id===b.providerID)??N[0],A=Array.isArray(x?.models)?x.models:[],ge=A.some(ve=>ve.id===b.modelID),fe=A[0]?.id??"";x?.id===b.providerID&&ge||D(ve=>({...ve,providerID:x?.id??"",modelID:ge?ve.modelID:fe,variant:""}))},Y=[r,N,b.providerID,b.modelID],e[21]=b.modelID,e[22]=b.providerID,e[23]=r,e[24]=N,e[25]=U,e[26]=Y):(U=e[25],Y=e[26]),m.useEffect(U,Y);const F=wl;let te;if(e[27]!==b.modelID||e[28]!==b.providerID||e[29]!==N){let x;e[31]!==b.providerID?(x=ge=>ge.id===b.providerID,e[31]=b.providerID,e[32]=x):x=e[32],te=N.find(x)?.models?.find(ge=>ge.id===b.modelID),e[27]=b.modelID,e[28]=b.providerID,e[29]=N,e[30]=te}else te=e[30];const $=te;let G;e[33]!==$?(G=$?.variants?Object.keys($.variants):[],e[33]=$,e[34]=G):G=e[34];const E=G,B=E.length>0;let W,K;e[35]!==b.variant||e[36]!==B?(W=()=>{B||!b.variant||D(yl)},K=[B,b.variant],e[35]=b.variant,e[36]=B,e[37]=W,e[38]=K):(W=e[37],K=e[38]),m.useEffect(W,K);let T;e[39]!==b.modelID||e[40]!==b.providerID?(T=b.providerID.trim().length>0&&b.modelID.trim().length>0,e[39]=b.modelID,e[40]=b.providerID,e[41]=T):T=e[41];const z=T;let J;e[42]!==z||e[43]!==b||e[44]!==d||e[45]!==l?(J=()=>{!z||l||d(b)},e[42]=z,e[43]=b,e[44]=d,e[45]=l,e[46]=J):J=e[46];const ae=J;let ee,X;e[47]!==ae||e[48]!==r?(ee=()=>{if(!r)return;const x=A=>{(A.metaKey||A.ctrlKey)&&A.key==="Enter"&&(A.preventDefault(),ae())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},X=[r,ae],e[47]=ae,e[48]=r,e[49]=ee,e[50]=X):(ee=e[49],X=e[50]),m.useEffect(ee,X);let Q;e[51]!==n||e[52]!==a?(Q=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=Q):Q=e[53];const re=Q;let ce;e[54]!==o||e[55]!==l?(ce=x=>{l||o(x)},e[54]=o,e[55]=l,e[56]=ce):ce=e[56];let me;e[57]!==re?(me=t.jsx(Gs,{children:t.jsx(Ds,{children:re})}),e[57]=re,e[58]=me):me=e[58];let oe;e[59]!==n?(oe=n("chat.modelControls.model"),e[59]=n,e[60]=oe):oe=e[60];let q;e[61]!==oe?(q=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:oe}),e[61]=oe,e[62]=q):q=e[62];let ie;e[63]===Symbol.for("react.memo_cache_sentinel")?(ie=(x,A)=>{D(ge=>({...ge,providerID:x,modelID:A,variant:""}))},e[63]=ie):ie=e[63];let he;e[64]!==b.modelID||e[65]!==b.providerID?(he=t.jsx(jr,{providerId:b.providerID,modelId:b.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ie}),e[64]=b.modelID,e[65]=b.providerID,e[66]=he):he=e[66];let j;e[67]!==q||e[68]!==he?(j=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[q,he]}),e[67]=q,e[68]=he,e[69]=j):j=e[69];let V;e[70]!==n?(V=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=V):V=e[71];let Z;e[72]!==V?(Z=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:V}),e[72]=V,e[73]=Z):Z=e[73];const pe=!B;let ne;e[74]===Symbol.for("react.memo_cache_sentinel")?(ne=x=>D(A=>({...A,variant:x})),e[74]=ne):ne=e[74];let we;e[75]!==b.variant||e[76]!==pe||e[77]!==E?(we=t.jsx(Lo,{value:b.variant,options:E,disabled:pe,onChange:ne}),e[75]=b.variant,e[76]=pe,e[77]=E,e[78]=we):we=e[78];let Te;e[79]!==Z||e[80]!==we?(Te=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Z,we]}),e[79]=Z,e[80]=we,e[81]=Te):Te=e[81];let Be;e[82]!==n?(Be=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Be):Be=e[83];let Me;e[84]!==Be?(Me=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Be}),e[84]=Be,e[85]=Me):Me=e[85];let tt;e[86]===Symbol.for("react.memo_cache_sentinel")?(tt=x=>D(A=>({...A,agent:x})),e[86]=tt):tt=e[86];let Le;e[87]!==b.agent?(Le=t.jsx(Fo,{agentName:b.agent,filter:F,dropdownPortalToBody:!0,onChange:tt}),e[87]=b.agent,e[88]=Le):Le=e[88];let Xe;e[89]!==Me||e[90]!==Le?(Xe=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Me,Le]}),e[89]=Me,e[90]=Le,e[91]=Xe):Xe=e[91];let Ae;e[92]!==j||e[93]!==Te||e[94]!==Xe?(Ae=t.jsxs("div",{className:"flex flex-col gap-4",children:[j,Te,Xe]}),e[92]=j,e[93]=Te,e[94]=Xe,e[95]=Ae):Ae=e[95];const Ze=`flex items-center gap-3 ${p?"justify-between":"justify-end"}`;let Fe;e[96]!==b.runAsGoal||e[97]!==p||e[98]!==l||e[99]!==n?(Fe=p?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ps,{checked:b.runAsGoal===!0,onChange:x=>D(A=>({...A,runAsGoal:x})),disabled:l,ariaLabel:n("sessions.scheduledTasks.editor.goal.aria")}),t.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:l,onClick:()=>D(bl),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=b.runAsGoal,e[97]=p,e[98]=l,e[99]=n,e[100]=Fe):Fe=e[100];let Ye;e[101]!==o?(Ye=()=>o(!1),e[101]=o,e[102]=Ye):Ye=e[102];let ot;e[103]!==n?(ot=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=ot):ot=e[104];let We;e[105]!==l||e[106]!==Ye||e[107]!==ot?(We=t.jsx(Ne,{variant:"ghost",size:"sm",onClick:Ye,disabled:l,children:ot}),e[105]=l,e[106]=Ye,e[107]=ot,e[108]=We):We=e[108];const Je=!z||l;let Ke;e[109]!==l||e[110]!==n?(Ke=n(l?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=l,e[110]=n,e[111]=Ke):Ke=e[111];let Ie;e[112]!==ae||e[113]!==Je||e[114]!==Ke?(Ie=t.jsx(Ne,{size:"sm",onClick:ae,disabled:Je,children:Ke}),e[112]=ae,e[113]=Je,e[114]=Ke,e[115]=Ie):Ie=e[115];let De;e[116]!==We||e[117]!==Ie?(De=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[We,Ie]}),e[116]=We,e[117]=Ie,e[118]=De):De=e[118];let _e;e[119]!==Ze||e[120]!==Fe||e[121]!==De?(_e=t.jsxs("div",{className:Ze,children:[Fe,De]}),e[119]=Ze,e[120]=Fe,e[121]=De,e[122]=_e):_e=e[122];let qe;e[123]!==me||e[124]!==Ae||e[125]!==_e?(qe=t.jsxs(Ts,{className:"max-w-md overflow-visible",children:[me,Ae,_e]}),e[123]=me,e[124]=Ae,e[125]=_e,e[126]=qe):qe=e[126];let it;return e[127]!==r||e[128]!==ce||e[129]!==qe?(it=t.jsx(Is,{open:r,onOpenChange:ce,children:qe}),e[127]=r,e[128]=ce,e[129]=qe,e[130]=it):it=e[130],it}function bl(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function yl(s){return{...s,variant:""}}function wl(s){return Oo(s.mode)}function vl(s){return s.currentAgentName||""}function jl(s){return s.currentVariant||""}function kl(s){return s.currentModelId}function Sl(s){return s.currentProviderId}function Nl(s){return s.providers}function Cl(s){return s.loadAgents}function Il(s){return s.loadAgents}function Tl(s){return s.loadProviders}const Dl=280,nr=4,Pl=({transform:s})=>({...s,y:0}),El=s=>{const e=Ge.c(18),{id:n,children:r,className:o}=s;let a;e[0]!==n?(a={id:n},e[0]=n,e[1]=a):a=e[1];const{attributes:i,listeners:f,setNodeRef:c,transform:d,transition:l,isDragging:g}=Kr(a);let h;e[2]!==d?(h=Yr.Transform.toString(d),e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h||e[5]!==l?(p={transform:h,transition:l},e[4]=h,e[5]=l,e[6]=p):p=e[6];const u=g&&"opacity-50";let y;e[7]!==o||e[8]!==u?(y=se("h-full rounded-md",o,u),e[7]=o,e[8]=u,e[9]=y):y=e[9];let k;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==f||e[14]!==c||e[15]!==p||e[16]!==y?(k=t.jsx("div",{ref:c,"data-sortable-tab-id":n,style:p,className:y,...i,...f,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=f,e[14]=c,e[15]=p,e[16]=y,e[17]=k):k=e[17],k},Rl=s=>{const e=Ge.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=se("h-full",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==r||e[3]!==n||e[4]!==a?(i=t.jsx("div",{className:a,"data-sortable-tab-id":n,children:r}),e[2]=r,e[3]=n,e[4]=a,e[5]=i):i=e[5],i},Cs=s=>{const e=Ge.c(133),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:f,variant:c,activePillInsetClassName:d,activePillButtonClassName:l,inactiveTabsIconOnly:g,animateActivePill:h,activePillLowercase:p,nonCompositedIndicator:u,className:y}=s,k=f===void 0?"scrollable":f,N=c===void 0?"default":c,S=g===void 0?!1:g,P=p===void 0?!0:p,O=u===void 0?!1:u,{t:w}=Qe(),v=Pe(Al),{isTablet:b}=Hs(),D=v||b,C=m.useRef(null);let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={left:!1,right:!1},e[0]=_):_=e[0];const[L,H]=m.useState(_);let U;e[1]!==n?(U=n.map(Bl),e[1]=n,e[2]=U):U=e[2];const Y=U,F=k==="scrollable",te=N==="default",$=N==="active-pill",E=$||N==="animated",B=te,W=E||B,K=$&&F,T=E,z=h??E,J=typeof i=="function",ae=J?El:Rl;let ee;e[3]===Symbol.for("react.memo_cache_sentinel")?(ee=new Map,e[3]=ee):ee=e[3];const X=m.useRef(ee),[Q,re]=m.useState(null),[ce,me]=m.useState(!1),[oe,q]=m.useState(null),ie=m.useRef(!1),he=m.useRef(0),j=m.useRef(r),V=m.useRef(null);let Z;e:{if(!W||!oe||!r||oe===r){Z=0;break e}const xe=n.findIndex(Oe=>Oe.id===oe),ue=n.findIndex(Oe=>Oe.id===r);if(xe<0||ue<0){Z=0;break e}Z=xe>ue?nr:-nr}const pe=Z;let ne;e[4]===Symbol.for("react.memo_cache_sentinel")?(ne={activationConstraint:{distance:8}},e[4]=ne):ne=e[4];const we=_r(zr(Vr,ne)),Te=Ml;let Be;e[5]===Symbol.for("react.memo_cache_sentinel")?(Be=(xe,ue)=>{if(ue){X.current.set(xe,ue);return}X.current.delete(xe)},e[5]=Be):Be=e[5];const Me=Be;let tt;e[6]!==r||e[7]!==W?(tt=()=>{if(!W||!r){re(Ll);return}const xe=C.current,ue=X.current.get(r);if(!xe||!ue){re(Fl);return}let Oe=0,ct=0,dt=ue;for(;dt&&dt!==xe;)Oe=Oe+dt.offsetLeft,ct=ct+dt.offsetTop,dt=dt.offsetParent;const vt={left:Oe,top:ct,width:ue.offsetWidth,height:ue.offsetHeight};re(Nt=>Te(Nt,vt)?Nt:vt)},e[6]=r,e[7]=W,e[8]=tt):tt=e[8];const Le=tt;let Xe;e[9]!==F?(Xe=()=>{if(!F){H({left:!1,right:!1});return}const xe=C.current;if(!xe){H({left:!1,right:!1});return}H({left:xe.scrollLeft>2,right:xe.scrollLeft+xe.clientWidth<xe.scrollWidth-2})},e[9]=F,e[10]=Xe):Xe=e[10];const Ae=Xe;let Ze;e[11]!==F||e[12]!==Ae?(Ze=()=>{if(!F){H({left:!1,right:!1});return}const xe=C.current;if(!xe)return;Ae(),xe.addEventListener("scroll",Ae,{passive:!0});const ue=new ResizeObserver(Ae);return ue.observe(xe),()=>{xe.removeEventListener("scroll",Ae),ue.disconnect()}},e[11]=F,e[12]=Ae,e[13]=Ze):Ze=e[13];let Fe;e[14]!==F||e[15]!==n.length||e[16]!==Ae?(Fe=[F,n.length,Ae],e[14]=F,e[15]=n.length,e[16]=Ae,e[17]=Fe):Fe=e[17],m.useEffect(Ze,Fe);let Ye;e[18]!==r||e[19]!==Le||e[20]!==W?(Ye=()=>{if(!W){re(null);return}Le();const xe=C.current;if(!xe)return;const ue=new ResizeObserver(()=>{performance.now()-he.current>Dl&&me(!1),Le()});if(ue.observe(xe),r){const Oe=X.current.get(r);Oe&&ue.observe(Oe)}return()=>{ue.disconnect()}},e[18]=r,e[19]=Le,e[20]=W,e[21]=Ye):Ye=e[21];let ot;e[22]!==r||e[23]!==n.length||e[24]!==Le||e[25]!==W?(ot=[r,n.length,Le,W],e[22]=r,e[23]=n.length,e[24]=Le,e[25]=W,e[26]=ot):ot=e[26],m.useEffect(Ye,ot);let We;e[27]!==Le?(We=()=>{Le()},e[27]=Le,e[28]=We):We=e[28],m.useLayoutEffect(We);let Je;e[29]!==Y?(Je=Y.join("\0"),e[29]=Y,e[30]=Je):Je=e[30];const Ke=Je;let Ie,De;e[31]!==r||e[32]!==Ke||e[33]!==W?(Ie=()=>{if(!W){ie.current=!1,me(!1);return}const xe=V.current!==Ke;if(V.current=Ke,!ie.current){ie.current=!0,j.current=r;return}const ue=j.current!==r;if(j.current=r,!ue||xe){me(!1);return}he.current=performance.now(),me(!0)},De=[r,Ke,W],e[31]=r,e[32]=Ke,e[33]=W,e[34]=Ie,e[35]=De):(Ie=e[34],De=e[35]),m.useLayoutEffect(Ie,De);let _e;e[36]!==r||e[37]!==F||e[38]!==Ae?(_e=()=>{if(!F||!r)return;const xe=C.current;if(!xe)return;const ue=window.requestAnimationFrame(()=>{const Oe=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),ct=xe.querySelector(`[data-sortable-tab-id="${Oe}"]`);ct&&(ct.scrollIntoView({block:"nearest",inline:"nearest"}),Ae())});return()=>{window.cancelAnimationFrame(ue)}},e[36]=r,e[37]=F,e[38]=Ae,e[39]=_e):_e=e[39];let qe;e[40]!==r||e[41]!==F||e[42]!==n.length||e[43]!==Ae?(qe=[r,F,n.length,Ae],e[40]=r,e[41]=F,e[42]=n.length,e[43]=Ae,e[44]=qe):qe=e[44],m.useEffect(_e,qe);let it;e[45]!==i?(it=xe=>{if(!i)return;const{active:ue,over:Oe}=xe;!Oe||ue.id===Oe.id||i(String(ue.id),String(Oe.id))},e[45]=i,e[46]=it):it=e[46];const x=it;let A;e[47]!==y?(A=se("relative flex h-full min-w-0 flex-1",y),e[47]=y,e[48]=A):A=e[48];let ge;e[49]!==F||e[50]!==L||e[51]!==E?(ge=F&&L.left?t.jsx("div",{className:se("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",E?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=F,e[50]=L,e[51]=E,e[52]=ge):ge=e[52];let fe;e[53]!==F||e[54]!==L||e[55]!==E?(fe=F&&L.right?t.jsx("div",{className:se("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",E?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=F,e[54]=L,e[55]=E,e[56]=fe):fe=e[56];const ve=E?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Ue=E&&"@container/pill-tabs",Ve=E&&"pill-tabs__track",$e=E&&(d??"gap-0.5 py-0.5"),Ee=B&&"items-center overflow-y-hidden",I=T&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",ye=F?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Ce;e[57]!==ve||e[58]!==Ue||e[59]!==Ve||e[60]!==$e||e[61]!==Ee||e[62]!==I||e[63]!==ye?(Ce=se("relative flex h-full min-w-0 flex-1",ve,Ue,Ve,$e,Ee,I,ye),e[57]=ve,e[58]=Ue,e[59]=Ve,e[60]=$e,e[61]=Ee,e[62]=I,e[63]=ye,e[64]=Ce):Ce=e[64];let Re;e[65]!==F?(Re=F?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=F,e[66]=Re):Re=e[66];let at;e[67]!==w?(at=w("sortableTabsStrip.aria.tabs"),e[67]=w,e[68]=at):at=e[68];let lt;e[69]!==O||e[70]!==pe||e[71]!==Q||e[72]!==ce||e[73]!==z||e[74]!==E?(lt=E&&Q?t.jsx("div",{className:se("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",z&&ce&&(O?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:O?{left:`${Q.left+pe}px`,top:`${Q.top}px`,width:`${Q.width}px`,height:`${Q.height}px`}:{transform:`translate3d(${Q.left+pe}px, ${Q.top}px, 0)`,width:`${Q.width}px`,height:`${Q.height}px`}}):null,e[69]=O,e[70]=pe,e[71]=Q,e[72]=ce,e[73]=z,e[74]=E,e[75]=lt):lt=e[75];let st;e[76]!==pe||e[77]!==Q||e[78]!==ce||e[79]!==B?(st=B&&Q?t.jsx("div",{className:se("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",ce&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${Q.left+pe}px, 0, 0)`,width:`${Q.width}px`},"aria-hidden":!0}):null,e[76]=pe,e[77]=Q,e[78]=ce,e[79]=B,e[80]=st):st=e[80];let mt;if(e[81]!==ae||e[82]!==r||e[83]!==l||e[84]!==P||e[85]!==D||e[86]!==S||e[87]!==$||e[88]!==v||e[89]!==F||e[90]!==n||e[91]!==a||e[92]!==o||e[93]!==K||e[94]!==E||e[95]!==W){let xe;e[97]!==ae||e[98]!==r||e[99]!==l||e[100]!==P||e[101]!==D||e[102]!==S||e[103]!==$||e[104]!==v||e[105]!==F||e[106]!==a||e[107]!==o||e[108]!==K||e[109]!==E||e[110]!==W?(xe=ue=>{const Oe=ue.id===r,ct=S&&E&&!Oe&&!!ue.icon,dt=!ct,vt=!!ue.icon,Nt=S&&E&&Oe&&!F&&!K,pt=ue.closable!==!1&&!!a,gt=pt&&!!ue.icon,jt=F||K?void 0:E?Nt?"flex-none basis-auto":v?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",St=pt?ht=>{ht.button===1&&(ht.preventDefault(),ht.stopPropagation(),a?.(ue.id))}:void 0,Tt=pt?Ol:void 0;return t.jsx(ae,{id:ue.id,className:jt,children:t.jsxs("div",{ref:ht=>Me(ue.id,ht),onAuxClick:St,onMouseDown:Tt,className:se("group flex h-full min-w-0 flex-nowrap items-center",F||K?"shrink-0":E?"w-full":"w-full min-w-0",E?"relative z-10 bg-transparent":Oe?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[t.jsx("button",{type:"button",role:"tab","aria-selected":Oe,"aria-label":ct?ue.title??ue.label:void 0,onClick:()=>o(ue.id),onPointerDown:W?()=>{me(!0),q(ue.id)}:void 0,onPointerUp:W?()=>q(null):void 0,onPointerLeave:W?()=>q(null):void 0,onPointerCancel:W?()=>q(null):void 0,className:se(E?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",E&&P?"lowercase":null,E&&(ct?"gap-0":"gap-1.5"),E?K?"shrink-0 whitespace-nowrap px-3 text-center":F?"max-w-56 shrink-0 px-3 text-center":ct?"px-2 !min-w-0 text-center":Nt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":F?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",E?l??($?v?"h-[38px]":"h-[31px]":"h-7"):null,E?Oe?"text-foreground":"text-muted-foreground hover:text-foreground":null,E?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:ue.title??ue.label,children:E?t.jsxs(t.Fragment,{children:[vt?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:se("flex items-center justify-center transition-opacity",gt&&(D?"opacity-0":"group-hover:opacity-0")),children:ue.icon}),gt?t.jsx("span",{role:"button",tabIndex:-1,className:se("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",D?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Ul,onClick:ht=>{ht.stopPropagation(),a?.(ue.id)},"aria-label":ue.closeLabel??`Close ${ue.label} tab`,title:ue.closeLabel??`Close ${ue.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,dt?t.jsx("span",{className:"animated-tabs__label truncate",children:ue.label}):null]}):t.jsxs("span",{className:se("flex min-w-0 flex-nowrap items-center gap-1.5",!F&&"justify-center"),children:[vt?t.jsxs("span",{className:se("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",Oe?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:se("flex items-center justify-center transition-opacity",gt&&(D?"opacity-0":"group-hover:opacity-0")),children:ue.icon}),gt?t.jsx("span",{role:"button",tabIndex:-1,className:se("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",D?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:$l,onClick:ht=>{ht.stopPropagation(),a?.(ue.id)},"aria-label":ue.closeLabel??`Close ${ue.label} tab`,title:ue.closeLabel??`Close ${ue.label} tab`,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:ue.label})]})}),pt&&!gt?t.jsx("button",{type:"button",onPointerDown:Wl,onClick:ht=>{ht.stopPropagation(),a?.(ue.id)},className:se("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",E?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",E?Oe?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":Oe?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":ue.closeLabel??`Close ${ue.label} tab`,title:ue.closeLabel??`Close ${ue.label} tab`,children:t.jsx(R,{name:"close",className:"h-3 w-3"})}):null]})},ue.id)},e[97]=ae,e[98]=r,e[99]=l,e[100]=P,e[101]=D,e[102]=S,e[103]=$,e[104]=v,e[105]=F,e[106]=a,e[107]=o,e[108]=K,e[109]=E,e[110]=W,e[111]=xe):xe=e[111],mt=n.map(xe),e[81]=ae,e[82]=r,e[83]=l,e[84]=P,e[85]=D,e[86]=S,e[87]=$,e[88]=v,e[89]=F,e[90]=n,e[91]=a,e[92]=o,e[93]=K,e[94]=E,e[95]=W,e[96]=mt}else mt=e[96];let ze;e[112]!==Ce||e[113]!==Re||e[114]!==at||e[115]!==lt||e[116]!==st||e[117]!==mt?(ze=t.jsxs("div",{ref:C,className:Ce,style:Re,role:"tablist","aria-label":at,children:[lt,st,mt]}),e[112]=Ce,e[113]=Re,e[114]=at,e[115]=lt,e[116]=st,e[117]=mt,e[118]=ze):ze=e[118];let ut;e[119]!==A||e[120]!==ge||e[121]!==fe||e[122]!==ze?(ut=t.jsxs("div",{className:A,children:[ge,fe,ze]}),e[119]=A,e[120]=ge,e[121]=fe,e[122]=ze,e[123]=ut):ut=e[123];const M=ut;if(!J)return M;let de;e[124]===Symbol.for("react.memo_cache_sentinel")?(de=[Pl],e[124]=de):de=e[124];let be;e[125]!==Y||e[126]!==M?(be=t.jsx(qr,{items:Y,strategy:Bi,children:M}),e[125]=Y,e[126]=M,e[127]=be):be=e[127];let He;e[128]===Symbol.for("react.memo_cache_sentinel")?(He=t.jsx(Ai,{dropAnimation:null}),e[128]=He):He=e[128];let je;return e[129]!==x||e[130]!==we||e[131]!==be?(je=t.jsxs(Gr,{sensors:we,collisionDetection:Hr,onDragEnd:x,modifiers:de,children:[be,He]}),e[129]=x,e[130]=we,e[131]=be,e[132]=je):je=e[132],je};function Al(s){return s.isMobile}function Bl(s){return s.id}function Ml(s,e){return!s||!e?s===e:Math.abs(s.left-e.left)<.5&&Math.abs(s.top-e.top)<.5&&Math.abs(s.width-e.width)<.5&&Math.abs(s.height-e.height)<.5}function Ll(s){return s===null?s:null}function Fl(s){return s===null?s:null}function Ol(s){s.button===1&&s.preventDefault()}function Ul(s){s.stopPropagation()}function $l(s){s.stopPropagation()}function Wl(s){s.stopPropagation()}const Vt=qs()(Ur($r((s,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:n=>{s({selectedProfileId:n})},loadProfiles:async()=>{s({isLoading:!0});const n=e().profiles;try{const r=await Vo();return s({profiles:r,isLoading:!1}),!0}catch(r){return console.error("Failed to load git identity profiles:",r),s({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{const n=await zo();if(n&&n.userName&&n.userEmail){const r={id:"global",name:"Global Identity",userName:n.userName,userEmail:n.userEmail,authType:n.sshCommand?"ssh":void 0,sshKey:n.sshCommand?n.sshCommand.replace("ssh -i ",""):null,color:"info",icon:"fingerprint"};s({globalIdentity:r})}else s({globalIdentity:null});return!0}catch(n){return console.error("Failed to load global git identity:",n),s({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{const n=await _o();return s({discoveredCredentials:n}),!0}catch(n){return console.error("Failed to discover git credentials:",n),s({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{const n=r=>{if(typeof r!="string")return null;const o=r.trim();return o.length>0?o:null};try{let r=null;if(r===null){const o=ui()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Bt("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(o.ok){const a=await o.json().catch(()=>null);r=n(a?.defaultGitIdentityId)}}catch{}return s({defaultGitIdentityId:r}),!0}catch(r){return console.error("Failed to load default git identity setting:",r),!1}},setDefaultGitIdentityId:async n=>{try{const r=typeof n=="string"?n.trim():"",o=r.length>0?r:"";return await Lr({defaultGitIdentityId:o}),s({defaultGitIdentityId:o.length>0?o:null}),!0}catch(r){return console.error("Failed to save default git identity setting:",r),!1}},createProfile:async n=>{try{const r={...n,id:n.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:n.color||"keyword",icon:n.icon||"branch"};return Lt("saving"),await Wo(r),Lt("saved"),await e().loadProfiles(),!0}catch(r){return Lt("error"),console.error("Failed to create git identity profile:",r),!1}},updateProfile:async(n,r)=>{try{const o=e().profiles.find(i=>i.id===n);if(!o)throw new Error("Profile not found");const a={...o,...r};return Lt("saving"),await $o(n,a),Lt("saved"),await e().loadProfiles(),!0}catch(o){return Lt("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return Lt("saving"),await Uo(n),Lt("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return Lt("error"),console.error("Failed to delete git identity profile:",r),!1}},getProfileById:n=>{const{profiles:r,globalIdentity:o}=e();return n==="global"?o||void 0:r.find(a=>a.id===n)},getUnimportedCredentials:()=>{const{profiles:n,discoveredCredentials:r}=e();return r.filter(o=>!n.some(a=>a.authType==="token"&&a.host===o.host))}}),{name:"git-identities-store",storage:di(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=Vt);const zs=Go,Ot=s=>{const e=Ge.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:f,children:c,className:d,contentClassName:l,divider:g}=s,h=g===void 0?!0:g;let p;return e[0]!==c||e[1]!==d||e[2]!==l||e[3]!==r||e[4]!==h||e[5]!==f||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(p=t.jsx(Ho,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:f,divider:h,className:d,contentClassName:l,children:c}),e[0]=c,e[1]=d,e[2]=l,e[3]=r,e[4]=h,e[5]=f,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=p):p=e[10],p},_l=450,zl=({projectRef:s=null,sections:e="all"})=>{const{t:n}=Qe(),{isMobile:r,isTablet:o}=Hs(),a=r||o,i=Ct(T=>T.getActiveProject()),f=s?.path??i?.path??null,c=rt(T=>T.getWorktreeMetadata),d=Ko(),l=Es(T=>T.homeDirectory),[g,h]=m.useState([]),[p,u]=m.useState(!1),[y,k]=m.useState(!1),[N,S]=m.useState(null),[P,O]=m.useState(null),[w,v]=m.useState([]),[b,D]=m.useState(!1),C=m.useRef(!1),_=m.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!f?null:{id:i.id,path:f},[i?.id,f,s?.id,s?.path]),L=m.useCallback(async()=>{if(!(!_||P===!1))try{const T=await Mn(_);v(T)}catch{}},[_,P]);m.useEffect(()=>{if(!f)return;let T=!1;return O(null),(async()=>{try{const z=await qo(f);if(T)return;O(z)}catch{}})(),()=>{T=!0}},[f]),m.useEffect(()=>{if(!_){v([]),D(!1);return}if(P===!1){v([]),D(!1);return}let T=!1;return D(!0),v([]),(async()=>{try{const z=await Mn(_);if(T)return;v(z)}catch{}finally{T||D(!1)}})(),()=>{T=!0}},[_,P]),m.useEffect(()=>{if(!_)return;let T=!1;return k(!0),(async()=>{try{const[z,J]=await Promise.all([kr(_),Sr(_)]);if(!T){const ae=z.length>0?z:[""];h(ae),S(JSON.stringify(ae)),u(J)}}catch{T||(h([""]),S(JSON.stringify([""])),u(!1))}finally{T||k(!1)}})(),()=>{T=!0}},[_]);const H=m.useCallback(async T=>{if(!_)return!1;const z=T.filter(J=>J.trim().length>0);try{return await Yo(_,z)?(S(JSON.stringify(T)),!0):(ke.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return ke.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[_,n]),U=m.useMemo(()=>N===null?!1:N!==JSON.stringify(g),[N,g]);m.useEffect(()=>{if(!U||y||C.current)return;const T=window.setTimeout(()=>{C.current||(C.current=!0,(async()=>{try{await H(g)}finally{C.current=!1}})())},_l);return()=>{window.clearTimeout(T)}},[U,y,H,g]);const Y=m.useCallback((T,z)=>{h(J=>{const ae=[...J];return ae[T]=z,ae})},[]),F=m.useCallback(()=>{h(T=>[...T,""])},[]),te=m.useCallback(T=>{h(z=>{const J=z.filter((ae,ee)=>ee!==T);return J.length>0?J:[""]})},[]),$=m.useCallback(()=>{!U||C.current||(C.current=!0,(async()=>{try{await H(g)}finally{C.current=!1}})())},[U,H,g]),G=m.useCallback(T=>{u(T),_&&Jo(_,T)},[_]),E=m.useCallback(T=>{const z=oe=>oe.replace(/\\/g,"/").replace(/\/+$/,""),J=z(T.path),ae=d.filter(oe=>{const q=c(oe.id);if(q?.path&&z(q.path)===J)return!0;const ie=oe.directory;return!!(ie&&z(ie)===J)}),ee=new Set(ae.map(oe=>oe.id)),X=[...gn.getState().activeSessions,...gn.getState().archivedSessions],Q=oe=>{const q=X.filter(he=>{const j=he.parentID;return j&&oe.has(j)});if(q.length===0)return[];const ie=new Set(q.map(he=>he.id));return[...q,...Q(ie)]},re=Q(ee),ce=new Set,me=[...ae,...re].filter(oe=>ce.has(oe.id)?!1:(ce.add(oe.id),!0));Qo.requestDelete({sessions:me,mode:"worktree",worktree:T})},[d,c]),B=m.useMemo(()=>d.map(T=>T.id).join(","),[d]);m.useEffect(()=>{P&&f&&L()},[B,P,f,L]);const W=t.jsxs(xn,{children:[n("settings.openchamber.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.openchamber.worktrees.setup.tooltipSuffix")]}),K=t.jsx(xn,{children:n("settings.openchamber.worktrees.list.tooltip")});return f?P===!1?t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:W,children:y?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.setup.loading")}):t.jsxs("div",{className:se("space-y-2",zs),children:[g.map((T,z)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(yt,{value:T,onChange:J=>Y(z,J.target.value),onBlur:$,placeholder:n("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Ne,{type:"button",variant:"ghost",size:"icon",onClick:()=>te(z),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.openchamber.worktrees.setup.removeCommandAria"),children:t.jsx(R,{name:"close",className:"h-4 w-4"})})]},z)),t.jsxs(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:F,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),n("settings.openchamber.worktrees.setup.addCommand")]}),t.jsxs("label",{"data-settings-item":"projects.worktree.setup.wait",className:"flex cursor-pointer items-center gap-2 py-1",children:[t.jsx(Ps,{checked:p,onChange:G,ariaLabel:n("settings.openchamber.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:se("typography-ui-label font-normal",p?"text-foreground":"text-foreground/60"),children:n("settings.openchamber.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Ot,{title:n("settings.openchamber.worktrees.list.title"),titleAccessory:K,children:b?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.list.loading")}):w.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.openchamber.worktrees.list.empty")}):t.jsx("div",{className:se("space-y-1",e==="all"&&zs),children:w.map(T=>t.jsxs("div",{className:"group flex w-full items-center gap-2 py-1.5",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"flex min-w-0 items-center gap-2",children:t.jsx("p",{className:"typography-meta min-w-0 truncate text-foreground",children:T.label||T.branch||n("settings.openchamber.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:Xo(T.path,l)})]}),t.jsx("button",{type:"button",onClick:()=>E(T),className:se("flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",a?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":n("settings.openchamber.worktrees.list.deleteWorktreeAria",{name:T.branch||T.label||T.path}),children:t.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]},T.path))})})]}):t.jsx(Ot,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.worktrees.state.selectProject")})})},rr=(s,e)=>e.updatedAtMs-s.updatedAtMs,or=qs((s,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){s({isLoading:!0,error:null});try{const[n,r]=await Promise.all([sa(),Fn()]),o={};for(const a of r.sort(rr))o[a.id]=a;e().listenerReady||await na(a=>{s(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),s({instances:n.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(n){s({isLoading:!1,error:n instanceof Error?n.message:String(n)})}}},loadImports:async()=>{if(!e().isImportsLoading){s({isImportsLoading:!0,error:null});try{const n=await ta();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Fn(),r={};for(const o of n.sort(rr))r[o.id]=o;s({statusesById:r})}catch(n){s({error:n instanceof Error?n.message:String(n)})}},setInstances:async n=>{s({isSaving:!0,error:null});try{await ea({instances:n}),s({instances:n,isSaving:!1}),await e().refreshStatuses()}catch(r){throw s({isSaving:!1,error:r instanceof Error?r.message:String(r)}),r}},upsertInstance:async n=>{const r=e().instances,o=r.some(a=>a.id===n.id)?r.map(a=>a.id===n.id?n:a):[n,...r];await e().setInstances(o)},createFromCommand:async(n,r,o)=>{const a=ra(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Ln(n).catch(()=>{});const r=e().instances.filter(o=>o.id!==n);await e().setInstances(r),s(o=>{const a={...o.statusesById};return delete a[n],{statusesById:a}})},connect:async n=>{s({error:null});try{await Zo(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},disconnect:async n=>{s({error:null});try{await Ln(n),await e().refreshStatuses()}catch(r){throw s({error:r instanceof Error?r.message:String(r)}),r}},retry:async n=>{await e().connect(n)},getStatus:n=>e().statusesById[n]||null,clearError:()=>s({error:null})})),Zr=[{key:"play",label:"Play",Icon:"play"},{key:"build",label:"Build",Icon:"hammer"},{key:"lint",label:"Lint",Icon:"checkbox-circle"},{key:"terminal",label:"Terminal",Icon:"terminal-box"},{key:"tools",label:"Tools",Icon:"tools"},{key:"bug",label:"Bug",Icon:"bug"},{key:"flask",label:"Flask",Icon:"flask"},{key:"rocket",label:"Rocket",Icon:"rocket"},{key:"code",label:"Code",Icon:"code"},{key:"server",label:"Server",Icon:"server"},{key:"branch",label:"Branch",Icon:"git-branch"},{key:"search",label:"Search",Icon:"search"},{key:"settings",label:"Settings",Icon:"settings-3"},{key:"brain",label:"Brain",Icon:"brain-ai-3"},{key:"stack",label:"Stack",Icon:"stack"},{key:"robot",label:"Robot",Icon:"robot-2"},{key:"command",label:"Command",Icon:"command"},{key:"file",label:"File",Icon:"file-text"}],eo=Object.fromEntries(Zr.map(s=>[s.key,s.Icon])),Vl="openchamber:project-actions-updated",Gl=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},tf=(s,e)=>`${Gl(s)}::${e}`,Hl=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},ar=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},Kl=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=ar(e.localPort),r=ar(e.remotePort);if(!n||!r)return null;const o=Hl(e.localHost||s.localForward.bindHost||"127.0.0.1"),a=(e.remoteHost||"127.0.0.1").trim(),i=(s.nickname||s.id||"instance").trim();return{id:`${s.id}::${e.id}`,label:`${i} - ${o}:${n} -> ${a}:${r}`,url:`http://${o}:${n}`}},to=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=Kl(n,r);o&&e.push(o)}return e},sf=(s,e)=>{const n=(s||"").trim();return n&&to(e).find(a=>a.id===n)?.url||null},ql=450,Yl=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Jl=()=>({id:Yl(),name:"",command:"",icon:"play"}),Ql=({projectRef:s})=>{const{t:e}=Qe(),n=m.useMemo(()=>Fr(),[]),r=or(v=>v.instances),o=or(v=>v.load),[a,i]=m.useState([]),[f,c]=m.useState(!1),[d,l]=m.useState(null),[g,h]=m.useState({}),p=m.useRef(!1),u=m.useRef(null);m.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),m.useEffect(()=>{let v=!1;return c(!0),(async()=>{try{const b=await oa(s);if(v)return;i(b.actions),l(JSON.stringify({actions:b.actions}))}catch{if(v)return;i([]),l(JSON.stringify({actions:[]}))}finally{v||c(!1)}})(),()=>{v=!0}},[s]);const y=m.useMemo(()=>n?to(r):[],[r,n]),k=m.useMemo(()=>a.some(b=>b.name.trim().length===0||b.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),N=m.useMemo(()=>d===null?!1:d!==JSON.stringify({actions:a}),[a,d]),S=m.useCallback(async v=>await aa(s,{actions:v,primaryActionId:null})?(l(JSON.stringify({actions:v})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Vl,{detail:{projectId:s.id}})),!0):(ke.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);m.useEffect(()=>{if(!N||f||k||p.current)return;const v=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await S(a)}finally{p.current=!1}})())},ql);return()=>{window.clearTimeout(v)}},[a,N,f,S,k]),m.useEffect(()=>{if(!N||!k||f){k||(u.current=null);return}const v=window.setTimeout(()=>{u.current!==k&&(u.current=k,ke.error(k))},1e3);return()=>{window.clearTimeout(v)}},[N,f,k]);const P=m.useCallback(()=>{const v=Jl();i(b=>[...b,v]),h(b=>({...b,[v.id]:!0}))},[]),O=m.useCallback(v=>{i(b=>b.filter(D=>D.id!==v)),h(b=>{const D={...b};return delete D[v],D})},[]),w=m.useCallback((v,b)=>{i(D=>D.map(C=>C.id===v?b(C):C))},[]);return t.jsxs(Ot,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Ne,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:P,children:[t.jsx(R,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[f?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.loading")}):a.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.empty")}):t.jsx("div",{className:se("space-y-0",zs),children:a.map(v=>{const b=v.icon||"play",D=eo[b]||"play",C=g[v.id]??!1,_=v.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(hl,{open:C,onOpenChange:L=>{h(H=>({...H,[v.id]:L}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(pl,{className:"group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[C?t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(R,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(R,{name:D,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:_})})]}),t.jsx(Ne,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>O(v.id),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(gl,{className:"pt-1.5",children:t.jsxs("div",{className:"space-y-2 pb-4 pl-3 pr-1",children:[t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsxs($t,{children:[t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]","aria-label":e("settings.projects.actions.field.selectIconAria"),children:t.jsx(R,{name:D,className:"h-4 w-4"})})}),t.jsx(_t,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:Zr.map(L=>{const H=L.Icon,U=(v.icon||"play")===L.key;return t.jsx("button",{type:"button",onClick:()=>w(v.id,Y=>({...Y,icon:L.key})),className:se("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",U&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:L.label}),children:t.jsx(R,{name:H,className:"h-4 w-4"})},L.key)})})})]}),t.jsx(yt,{value:v.name,onChange:L=>w(v.id,H=>({...H,name:L.target.value})),placeholder:e("settings.projects.actions.field.actionNamePlaceholder"),className:"h-7 flex-1 min-w-0"})]}),t.jsxs("div",{className:"py-1",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.command")}),t.jsx(Ks,{value:v.command,onChange:L=>w(v.id,H=>({...H,command:L.target.value})),placeholder:e("settings.projects.actions.field.commandPlaceholder"),className:"min-h-[88px] w-full font-mono text-xs"})]}),t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.projects.actions.field.autoOpenUrl")}),t.jsxs("div",{className:"group flex cursor-pointer items-center gap-2",role:"button",tabIndex:0,"aria-pressed":v.autoOpenUrl===!0,onClick:()=>w(v.id,L=>({...L,...L.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:L=>{(L.key===" "||L.key==="Enter")&&(L.preventDefault(),w(v.id,H=>({...H,...H.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Ps,{checked:v.autoOpenUrl===!0,onChange:L=>w(v.id,H=>({...H,...L?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:_})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),v.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(yt,{value:v.openUrl||"",onChange:L=>w(v.id,H=>({...H,openUrl:L.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(xn,{contentClassName:"max-w-xs",children:e("settings.projects.actions.field.overrideUrlTooltip")})]}),n?t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"typography-meta mb-0.5 text-muted-foreground",children:e("settings.projects.actions.field.desktopSshForward")}),y.length>0?t.jsxs(Nr,{value:v.desktopOpenSshForward&&y.some(L=>L.id===v.desktopOpenSshForward)?v.desktopOpenSshForward:"__none__",onValueChange:L=>{w(v.id,H=>({...H,...L==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:L}}))},children:[t.jsx(Cr,{size:Ir,className:"w-full",children:t.jsx(Tr,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Dr,{children:[t.jsx(Ws,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),y.map(L=>t.jsx(Ws,{value:L.id,children:L.label},L.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},v.id)})}),k&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:k}):null]})},Xl=s=>{if(!s)return[];const e=s.variants;return e?Object.keys(e):[]},sn="__default__",so=s=>s.charAt(0).toUpperCase()+s.slice(1),Zl=s=>{const e=Ge.c(138),{form:n}=s,{t:r}=Qe(),{currentTheme:o}=Pr(),a=kt(ec),{name:i,setName:f,icon:c,setIcon:d,color:l,setColor:g,iconBackground:h,setIconBackground:p,parsedDefaultModel:u,defaultVariant:y,handleDefaultModelChange:k,handleDefaultVariantChange:N,isUploadingIcon:S,isRemovingCustomIcon:P,isDiscoveringIcon:O,pendingRemoveImageIcon:w,setPendingRemoveImageIcon:v,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:D,hasPendingUploadImageIcon:C,hasCustomIcon:_,effectiveHasImageIcon:L,hasRemovableImageIcon:H,showImagePreview:U,fileInputRef:Y,handleUploadIcon:F,handleRemoveImageIcon:te,handleDiscoverIcon:$,currentIconImage:G,project:E}=n;let B;e:{const{providerId:fe,modelId:ve}=u;if(!fe||!ve){let Ve;e[0]===Symbol.for("react.memo_cache_sentinel")?(Ve=[],e[0]=Ve):Ve=e[0],B=Ve;break e}let Ue;if(e[1]!==ve||e[2]!==fe||e[3]!==a){const Ve=a.find($e=>$e.id===fe)?.models.find($e=>$e.id===ve);Ue=Xl(Ve),e[1]=ve,e[2]=fe,e[3]=a,e[4]=Ue}else Ue=e[4];B=Ue}const W=B;if(!E)return null;const K=l?ia[l]??null:null;let T;e[5]!==r?(T=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=T):T=e[6];let z;e[7]!==f?(z=fe=>f(fe.target.value),e[7]=f,e[8]=z):z=e[8];let J;e[9]!==r?(J=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=J):J=e[10];let ae;e[11]===Symbol.for("react.memo_cache_sentinel")?(ae=se("h-8 rounded-md px-3",zs),e[11]=ae):ae=e[11];let ee;e[12]!==i||e[13]!==z||e[14]!==J?(ee=t.jsx(yt,{value:i,onChange:z,placeholder:J,className:ae}),e[12]=i,e[13]=z,e[14]=J,e[15]=ee):ee=e[15];let X;e[16]!==T||e[17]!==ee?(X=t.jsx(Ot,{title:T,settingsItem:"projects.name",divider:!1,children:ee}),e[16]=T,e[17]=ee,e[18]=X):X=e[18];let Q;e[19]!==r?(Q=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=Q):Q=e[20];let re;e[21]!==r?(re=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=re):re=e[22];let ce;e[23]!==r?(ce=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=ce):ce=e[24];let me;e[25]!==k||e[26]!==u.modelId||e[27]!==u.providerId?(me=t.jsx(jr,{providerId:u.providerId,modelId:u.modelId,onChange:k,className:la}),e[25]=k,e[26]=u.modelId,e[27]=u.providerId,e[28]=me):me=e[28];let oe;e[29]!==ce||e[30]!==me?(oe=t.jsx(On,{settingsItem:"projects.default-model",label:ce,children:me}),e[29]=ce,e[30]=me,e[31]=oe):oe=e[31];let q;e[32]!==W||e[33]!==y||e[34]!==N||e[35]!==r?(q=W.length>0?t.jsx(On,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(Nr,{value:y??sn,onValueChange:fe=>N(fe===sn?void 0:fe),children:[t.jsx(Cr,{size:Ir,className:ca,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(Tr,{children:y?so(y):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(Dr,{children:[t.jsx(Ws,{value:sn,children:r("settings.projects.page.option.thinkingDefault")}),W.map(tc)]})]})}):null,e[32]=W,e[33]=y,e[34]=N,e[35]=r,e[36]=q):q=e[36];let ie;e[37]!==oe||e[38]!==q||e[39]!==Q||e[40]!==re?(ie=t.jsxs(Ot,{title:Q,info:re,contentClassName:"space-y-0",children:[oe,q]}),e[37]=oe,e[38]=q,e[39]=Q,e[40]=re,e[41]=ie):ie=e[41];let he;e[42]!==r?(he=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=he):he=e[43];let j;e[44]!==g?(j=()=>g(null),e[44]=g,e[45]=j):j=e[45];const V=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Z;e[46]!==V?(Z=se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",V),e[46]=V,e[47]=Z):Z=e[47];let pe;e[48]!==r?(pe=r("settings.projects.page.field.none"),e[48]=r,e[49]=pe):pe=e[49];let ne;e[50]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=ne):ne=e[50];let we;e[51]!==j||e[52]!==Z||e[53]!==pe?(we=t.jsx("button",{type:"button",onClick:j,className:Z,title:pe,children:ne}),e[51]=j,e[52]=Z,e[53]=pe,e[54]=we):we=e[54];let Te;e[55]!==l||e[56]!==g?(Te=da.map(fe=>t.jsx("button",{type:"button",onClick:()=>g(fe.key),className:se("h-7 w-7 rounded-md border transition-colors",l===fe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:fe.cssVar},title:fe.label},fe.key)),e[55]=l,e[56]=g,e[57]=Te):Te=e[57];let Be;e[58]!==we||e[59]!==Te?(Be=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[we,Te]}),e[58]=we,e[59]=Te,e[60]=Be):Be=e[60];let Me;e[61]!==he||e[62]!==Be?(Me=t.jsx(Ot,{title:he,settingsItem:"projects.accent-color",children:Be}),e[61]=he,e[62]=Be,e[63]=Me):Me=e[63];let tt;e[64]!==r?(tt=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=tt):tt=e[65];let Le;e[66]!==F?(Le=fe=>{const ve=fe.target.files?.[0]??null;F(ve),fe.currentTarget.value=""},e[66]=F,e[67]=Le):Le=e[67];let Xe;e[68]!==Y||e[69]!==Le?(Xe=t.jsx("input",{ref:Y,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:Le}),e[68]=Y,e[69]=Le,e[70]=Xe):Xe=e[70];let Ae;e[71]!==d?(Ae=()=>d(null),e[71]=d,e[72]=Ae):Ae=e[72];const Ze=c===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let Fe;e[73]!==Ze?(Fe=se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ze),e[73]=Ze,e[74]=Fe):Fe=e[74];let Ye;e[75]!==r?(Ye=r("settings.projects.page.field.none"),e[75]=r,e[76]=Ye):Ye=e[76];let ot;e[77]===Symbol.for("react.memo_cache_sentinel")?(ot=t.jsx(R,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=ot):ot=e[77];let We;e[78]!==Ae||e[79]!==Fe||e[80]!==Ye?(We=t.jsx("button",{type:"button",onClick:Ae,className:Fe,title:Ye,children:ot}),e[78]=Ae,e[79]=Fe,e[80]=Ye,e[81]=We):We=e[81];let Je;e[82]!==K||e[83]!==c||e[84]!==d?(Je=ua.map(fe=>{const ve=fe.Icon;return t.jsx("button",{type:"button",onClick:()=>d(fe.key),className:se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",c===fe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:fe.label,children:t.jsx(R,{name:ve,className:"w-4 h-4",style:K&&c===fe.key?{color:K}:void 0})},fe.key)}),e[82]=K,e[83]=c,e[84]=d,e[85]=Je):Je=e[85];let Ke;e[86]!==We||e[87]!==Je?(Ke=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[We,Je]}),e[86]=We,e[87]=Je,e[88]=Ke):Ke=e[88];let Ie;e[89]!==G||e[90]!==o||e[91]!==L||e[92]!==C||e[93]!==h||e[94]!==b||e[95]!==E||e[96]!==D||e[97]!==U||e[98]!==r?(Ie=L&&U&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.projects.page.field.preview")}),t.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1",children:t.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:h?{backgroundColor:h}:void 0,children:C&&b?t.jsx("img",{src:b,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>D(!0)}):t.jsx(fa,{project:{...E,iconImage:G??E.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>D(!0)})})})]}),e[89]=G,e[90]=o,e[91]=L,e[92]=C,e[93]=h,e[94]=b,e[95]=E,e[96]=D,e[97]=U,e[98]=r,e[99]=Ie):Ie=e[99];let De;e[100]!==L||e[101]!==h||e[102]!==p||e[103]!==r?(De=L&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:h??"#000000",onChange:fe=>p(fe.target.value),className:"h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1","aria-label":r("settings.projects.page.field.projectIconBackgroundAria")}),t.jsx(yt,{value:h??"",onChange:fe=>p(fe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Ne,{type:"button",size:"xs",variant:"outline",onClick:()=>p(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!h,children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=L,e[101]=h,e[102]=p,e[103]=r,e[104]=De):De=e[104];let _e;e[105]!==Y||e[106]!==$||e[107]!==_||e[108]!==O||e[109]!==S||e[110]!==r?(_e=!_&&t.jsxs(t.Fragment,{children:[t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",onClick:()=>Y.current?.click(),disabled:S,children:r(S?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Ne,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{$()},disabled:O,children:r(O?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=Y,e[106]=$,e[107]=_,e[108]=O,e[109]=S,e[110]=r,e[111]=_e):_e=e[111];let qe;e[112]!==te||e[113]!==H||e[114]!==P||e[115]!==r?(qe=H&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{te()},disabled:P,children:r(P?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=te,e[113]=H,e[114]=P,e[115]=r,e[116]=qe):qe=e[116];let it;e[117]!==P||e[118]!==w||e[119]!==v||e[120]!==r?(it=w&&t.jsx(Ne,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>v(!1),disabled:P,children:r("settings.projects.page.actions.undoRemove")}),e[117]=P,e[118]=w,e[119]=v,e[120]=r,e[121]=it):it=e[121];let x;e[122]!==_e||e[123]!==qe||e[124]!==it?(x=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[_e,qe,it]}),e[122]=_e,e[123]=qe,e[124]=it,e[125]=x):x=e[125];let A;e[126]!==tt||e[127]!==Xe||e[128]!==Ke||e[129]!==Ie||e[130]!==De||e[131]!==x?(A=t.jsxs(Ot,{title:tt,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Xe,Ke,Ie,De,x]}),e[126]=tt,e[127]=Xe,e[128]=Ke,e[129]=Ie,e[130]=De,e[131]=x,e[132]=A):A=e[132];let ge;return e[133]!==ie||e[134]!==Me||e[135]!==A||e[136]!==X?(ge=t.jsxs(t.Fragment,{children:[X,ie,Me,A]}),e[133]=ie,e[134]=Me,e[135]=A,e[136]=X,e[137]=ge):ge=e[137],ge};function ec(s){return s.providers}function tc(s){return t.jsx(Ws,{value:s,children:so(s)},s)}const sc=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,nc=s=>{if(!s)return null;const e=s.trim();return e&&sc.test(e)?e.toLowerCase():null},rc=s=>{const{t:e}=Qe(),n=Ct(q=>q.uploadProjectIcon),r=Ct(q=>q.removeProjectIcon),o=Ct(q=>q.discoverProjectIcon),a=Ct(q=>s?q.projects.find(ie=>ie.id===s.id)?.iconImage??null:null),[i,f]=m.useState(""),[c,d]=m.useState(null),[l,g]=m.useState(null),[h,p]=m.useState(null),[u,y]=m.useState(void 0),[k,N]=m.useState(void 0),[S,P]=m.useState(!1),[O,w]=m.useState(!1),[v,b]=m.useState(!1),[D,C]=m.useState(!1),[_,L]=m.useState(null),[H,U]=m.useState(null),[Y,F]=m.useState(!1),te=m.useRef(null),$=m.useCallback(()=>{L(null),U(q=>(q&&URL.revokeObjectURL(q),null))},[]),G=s?.id??null;m.useEffect(()=>{if(!s){f(""),d(null),g(null),p(null),y(void 0),N(void 0);return}f(s.label??""),d(s.icon??null),g(s.color??null),p(s.iconBackground??null),y(s.defaultModel),N(s.defaultVariant),C(!1),$(),F(!1)},[s,$]),m.useEffect(()=>()=>{$()},[$]);const E=m.useMemo(()=>Er(u)??{providerId:"",modelId:""},[u]),B=!!s?.iconImage,W=!!(_&&H),K=s?.iconImage?.source==="custom",T=B&&!D||W,z=T,J=!!(s&&B&&!D),ae=!Y&&(W||J),ee=!!s&&(i.trim()!==(s?.label??"").trim()||c!==(s?.icon??null)||l!==(s?.color??null)||h!==(s?.iconBackground??null)||(u??void 0)!==(s?.defaultModel??void 0)||(k??void 0)!==(s?.defaultVariant??void 0)||D||!!_),X=m.useCallback((q,ie)=>{y(q&&ie?`${q}/${ie}`:void 0),N(void 0)},[]),Q=m.useCallback(q=>{N(q)},[]),re=m.useCallback(q=>{!s||!q||S||(C(!1),F(!1),L(q),U(ie=>(ie&&URL.revokeObjectURL(ie),URL.createObjectURL(q))))},[S,s]),ce=m.useCallback(()=>{!s||!z||O||(W&&$(),C(!!B),F(!1))},[$,W,z,B,O,s]),me=m.useCallback(async()=>{if(!(!s||v)){$(),C(!1),F(!1),b(!0);try{const q=await o(s.id);if(!q.ok){ke.error(q.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(q.skipped){ke.success(e("settings.projects.page.toast.customIconAlreadySet"));return}ke.success(e("settings.projects.page.toast.iconDiscovered"))}finally{b(!1)}}},[$,o,v,s,e]),oe=m.useCallback(async q=>{const ie=q?.silent===!0;if(!s)return null;const he=i.trim();if(!he)return null;if(_){P(!0);const V=await n(s.id,_);if(P(!1),!V.ok)return ke.error(V.error||e("settings.projects.page.toast.uploadIconFailed")),null;ie||ke.success(e("settings.projects.page.toast.iconUpdated")),$(),C(!1)}const j=D&&!!s.iconImage;if(j){w(!0);const V=await r(s.id);if(w(!1),!V.ok)return ke.error(V.error||e("settings.projects.page.toast.removeIconFailed")),null;ie||ke.success(e("settings.projects.page.toast.iconRemoved")),C(!1),p(null)}return{label:he,icon:c,color:l,iconBackground:nc(j?null:h),defaultModel:u??null,defaultVariant:u?k??null:null}},[$,l,u,k,c,h,i,D,_,s,r,e,n]);return m.useEffect(()=>{F(!1)},[G,a?.updatedAt]),{name:i,setName:f,icon:c,setIcon:d,color:l,setColor:g,iconBackground:h,setIconBackground:p,defaultModel:u,defaultVariant:k,parsedDefaultModel:E,handleDefaultModelChange:X,handleDefaultVariantChange:Q,isUploadingIcon:S,isRemovingCustomIcon:O,isDiscoveringIcon:v,pendingRemoveImageIcon:D,setPendingRemoveImageIcon:C,pendingUploadIconFile:_,pendingUploadIconPreviewUrl:H,previewImageFailed:Y,setPreviewImageFailed:F,hasStoredImageIcon:B,hasPendingUploadImageIcon:W,hasCustomIcon:K,effectiveHasImageIcon:T,hasRemovableImageIcon:z,showStoredImagePreview:J,showImagePreview:ae,fileInputRef:te,clearPendingUploadIcon:$,handleUploadIcon:re,handleRemoveImageIcon:ce,handleDiscoverIcon:me,hasChanges:ee,prepareSaveData:oe,currentIconImage:a,project:s}},oc=450,ac=(s,e)=>{const{t:n}=Qe(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:f,defaultModel:c,pendingRemoveImageIcon:d,pendingUploadIconFile:l,isUploadingIcon:g,isRemovingCustomIcon:h,prepareSaveData:p}=s,u=m.useRef(!1);m.useEffect(()=>{if(!r||!o.trim()||g||h||u.current)return;const y=window.setTimeout(()=>{u.current||(u.current=!0,(async()=>{try{const k=await p({silent:!0});if(k)try{await e(k)}catch{ke.error(n("settings.projects.page.toast.saveFailed"))}}finally{u.current=!1}})())},oc);return()=>{window.clearTimeout(y)}},[i,c,r,a,f,h,g,o,e,d,l,p,n])},nf=s=>{const e=Ge.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=rc(n);let f;e:{if(!n){f=null;break e}let y;e[0]!==n.id||e[1]!==n.path?(y={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=y):y=e[2],f=y}const c=f;let d;if(e[3]!==r?(d=async y=>{await r(y)},e[3]=r,e[4]=d):d=e[4],ac(i,d),!n||!c)return null;let g;e[5]!==i?(g=t.jsx(Zl,{form:i}),e[5]=i,e[6]=g):g=e[6];let h;e[7]!==c?(h=t.jsx(Ql,{projectRef:c}),e[7]=c,e[8]=h):h=e[8];let p;e[9]!==c||e[10]!==a?(p=a?t.jsx(zl,{projectRef:c}):null,e[9]=c,e[10]=a,e[11]=p):p=e[11];let u;return e[12]!==g||e[13]!==h||e[14]!==p?(u=t.jsxs("div",{className:"space-y-0",children:[g,h,p]}),e[12]=g,e[13]=h,e[14]=p,e[15]=u):u=e[15],u},rf=s=>{const e=Ge.c(17),{percent:n,tonePercent:r,className:o}=s;let a;e[0]!==n?(a=ma(n)??0,e[0]=n,e[1]=a):a=e[1];const i=a,f=r??n;let c;e[2]!==f?(c=ha(f),e[2]=f,e[3]=c):c=e[3];const d=c;let l;e[4]!==d?(l=d==="critical"?{backgroundColor:"var(--status-error)"}:d==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=d,e[5]=l):l=e[5];const g=l;let h;e[6]!==o?(h=se("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",o),e[6]=o,e[7]=h):h=e[7];const p=`${i}%`;let u;e[8]!==g||e[9]!==p?(u={...g,width:p},e[8]=g,e[9]=p,e[10]=u):u=e[10];let y;e[11]!==i||e[12]!==u?(y=t.jsx("div",{className:"h-full transition-all duration-300",style:u,role:"progressbar","aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),e[11]=i,e[12]=u,e[13]=y):y=e[13];let k;return e[14]!==h||e[15]!==y?(k=t.jsx("div",{className:h,children:y}),e[14]=h,e[15]=y,e[16]=k):k=e[16],k},no=()=>{const s=pa();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},of=()=>{const s=Ge.c(2),[e,n]=m.useState(ic);let r,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{n(no())};i();for(const f of a)typeof f.addEventListener=="function"?f.addEventListener("change",i):typeof f.addListener=="function"&&f.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const f of a)typeof f.removeEventListener=="function"?f.removeEventListener("change",i):typeof f.removeListener=="function"&&f.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),m.useEffect(r,o),e};function ic(){return no()}const lc=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:s=>!s.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"split",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"split",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"split",keywords:["plugin","plugins","extensions","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","github","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],isAvailable:s=>!s.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:s=>!s.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:s=>!s.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:s=>!s.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:s=>!s.isVSCode},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:s=>s.isMobile&&!s.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","plugin","provider","oauth","claude","cursor","command code","connect","discord","telegram","messenger"]}],cc={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function dc(s){const e=s.trim().toLowerCase();return lc.find(n=>n.slug===e)??null}function uc(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=cc[e];if(n)return n;const r=dc(e);return r?r.slug:"home"}function af(s){switch(s){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"providers":return"cloud";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"about":return"information";case"home":return null;default:return"robot-2"}}const fc=["chat","git","diff","terminal","files","diagram"],mc=["settings","agents","commands","skills","providers","usage","git-identities"],It={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function ir(s){const e=hc();return{sessionId:pc(e),tab:gc(e),settingsPath:xc(e),diffFile:bc(e)}}function hc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function pc(s){const e=s.get(It.SESSION);return!e||e.trim().length===0?null:e.trim()}function gc(s){const e=s.get(It.TAB);if(!e)return null;const n=e.toLowerCase().trim();return fc.includes(n)?n:null}function xc(s){const e=s.get(It.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="openchamber"||n==="general"||n==="preferences"?"home":(mc.includes(n),n)}function bc(s){const e=s.get(It.FILE);if(!e||e.trim().length===0)return null;try{return decodeURIComponent(e.trim())}catch{return e.trim()}}function lr(){if(typeof window>"u")return!1;try{const s=new URLSearchParams(window.location.search);return s.has(It.SESSION)||s.has(It.TAB)||s.has(It.SETTINGS)||s.has(It.FILE)}catch{return!1}}const yc="chat";function ro(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(It.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(It.SETTINGS,n),e}return s.tab!==yc&&e.set(It.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(It.FILE,s.diffFile),e}function wc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function vc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=ro(s),r=[...e.entries()].sort((a,i)=>a[0].localeCompare(i[0])),o=[...n.entries()].sort((a,i)=>a[0].localeCompare(i[0]));if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(r[a][0]!==o[a][0]||r[a][1]!==o[a][1])return!1;return!0}catch{return!0}}function cr(s,e={}){if(!(typeof window>"u")&&!(jc()||Wr())&&!(!e.force&&vc(s)))try{const n=ro(s),r=wc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function jc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function kc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function lf(){const s=m.useMemo(()=>kc(),[]),e=m.useMemo(()=>Wr(),[]),n=m.useRef(!1),r=m.useRef(!1),o=rt(h=>h.setCurrentSession),a=Pe(h=>h.setActiveSurface),i=Pe(h=>h.setSettingsDialogOpen),f=Pe(h=>h.setSettingsPage),c=Pe(h=>h.navigateToDiff),d=m.useCallback(async h=>{if(!r.current){r.current=!0;try{if(h.sessionId){const p=rt.getState().currentSessionId;if(h.sessionId!==p){const u=rt.getState().getDirectoryForSession(h.sessionId);o(h.sessionId,u)}}if(h.settingsPath){f(uc(h.settingsPath)),i(!0);return}Pe.getState().isSettingsDialogOpen&&i(!1),h.tab&&a(h.tab),h.diffFile&&(h.tab==="diff"||!h.tab)&&c(h.diffFile)}finally{r.current=!1}}},[o,a,i,f,c]),l=m.useCallback(()=>{const h=rt.getState(),p=Pe.getState();return{sessionId:h.currentSessionId,tab:p.activeSurface,isSettingsOpen:p.isSettingsDialogOpen,settingsPath:p.settingsPage,diffFile:p.pendingDiffFile}},[]),g=m.useCallback((h={})=>{if(s||e||r.current)return;const p=l();cr(p,h)},[s,e,l]);m.useEffect(()=>{if(n.current||(n.current=!0,!lr()))return;const h=ir();(async()=>(await d(h),!s&&!e&&cr({...l(),sessionId:h.sessionId??rt.getState().currentSessionId,tab:h.tab??Pe.getState().activeSurface,settingsPath:h.settingsPath??Pe.getState().settingsPage,diffFile:h.diffFile??Pe.getState().pendingDiffFile},{replace:!0,force:!0})))()},[d,l,s,e]),m.useEffect(()=>{if(s||e)return;let h=rt.getState().currentSessionId;return rt.subscribe(u=>{const y=u.currentSessionId;y===h||r.current||(h=y,g())})},[s,e,g]),m.useEffect(()=>{if(s||e)return;let h=Pe.getState().activeSurface,p=Pe.getState().isSettingsDialogOpen,u=Pe.getState().settingsPage,y=Pe.getState().pendingDiffFile;return Pe.subscribe(N=>{if(r.current)return;const S=N.activeSurface!==h,P=N.isSettingsDialogOpen!==p,O=N.settingsPage!==u,w=N.pendingDiffFile!==y&&N.activeSurface==="diff";h=N.activeSurface,p=N.isSettingsDialogOpen,u=N.settingsPage,y=N.pendingDiffFile,(S||P||O||w)&&g()})},[s,e,g]),m.useEffect(()=>{if(typeof window>"u"||s||e)return;const h=()=>{const p=ir();if(lr())d(p);else{const u=Pe.getState();u.isSettingsDialogOpen&&i(!1),u.activeSurface!=="chat"&&a("chat")}};return window.addEventListener("popstate",h),()=>{window.removeEventListener("popstate",h)}},[d,s,e,a,i])}function cf(){const s=Ge.c(5),e=Ji(Nc),n=m.useRef(e);let r,o;s[0]!==e?(r=()=>{n.current=e},o=[e],s[0]=e,s[1]=r,s[2]=o):(r=s[1],o=s[2]),m.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let f=!1,c=null;const d=Sc,l=g=>{f||(c=window.setTimeout(async()=>{const h=await n.current(),p=typeof h=="number"&&Number.isFinite(h)?d(h):36e5;l(p)},g))};return l(3e3),()=>{f=!0,c!==null&&window.clearTimeout(c)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),m.useEffect(a,i)}function Sc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function Nc(s){return s.checkForUpdates}const Nn=1e3,js=60*Nn,nn=60*js,Cc=(s,e)=>{const n=Math.max(0,s);return n<js?e("common.duration.secondsCompact",{seconds:Math.floor(n/Nn)}):n<nn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/js),seconds:Math.floor(n%js/Nn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/nn),minutes:Math.floor(n%nn/js)})},Ic=1e3,df=s=>{const e=Ge.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=Qe(),i=ga(n),f=xa(n),c=ba(r,Ic),d=r?Math.max(0,c-(i??c)):f;if(d===void 0)return null;let l,g;e[0]!==d||e[1]!==r||e[2]!==a?(l=Cc(d,a),g=r?a("sessions.sidebar.session.status.activeFor",{duration:l}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:l}),e[0]=d,e[1]=r,e[2]=a,e[3]=l,e[4]=g):(l=e[3],g=e[4]);const h=g,p=r?"text-primary":"text-[var(--status-info)]";let u;e[5]!==o||e[6]!==p?(u=se("shrink-0 tabular-nums",p,o),e[5]=o,e[6]=p,e[7]=u):u=e[7];let y;return e[8]!==h||e[9]!==l||e[10]!==u?(y=t.jsx("span",{className:u,"aria-label":h,title:h,children:l}),e[8]=h,e[9]=l,e[10]=u,e[11]=y):y=e[11],y},Tc=()=>{const s=Ge.c(14),[e,n]=le.useState(!1),[r,o]=le.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Fr()),o(fi())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),le.useEffect(a,i);let f;s[2]!==e?(f=async u=>e?await mi(u):{success:!0,path:u},s[2]=e,s[3]=f):f=s[3];const c=f;let d;s[4]!==e?(d=async u=>e?await hi():{success:!0},s[4]=e,s[5]=d):d=s[5];const l=d;let g;s[6]!==e?(g=async u=>e?await pi():{success:!0},s[6]=e,s[7]=g):g=s[7];const h=g;let p;return s[8]!==r||s[9]!==e||s[10]!==c||s[11]!==l||s[12]!==h?(p={isDesktop:e,canRequestAccess:r,requestAccess:c,startAccessing:l,stopAccessing:h},s[8]=r,s[9]=e,s[10]=c,s[11]=l,s[12]=h,s[13]=p):p=s[13],p},Dc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Pc=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:o,onCreate:a,remotes:i=[],disabled:f=!1})=>{const{t:c}=Qe(),[d,l]=m.useState(!1),[g,h]=m.useState(""),[p,u]=m.useState(!1),[y,k]=m.useState(!1),[N,S]=m.useState(""),[P,O]=m.useState(!1),w=m.useRef(null),v=m.useCallback($=>{$.stopPropagation()},[]),b=i.length>1,D=m.useMemo(()=>Dc(N),[N]),C=m.useMemo(()=>{const $=g.toLowerCase();return $?e.filter(G=>G.toLowerCase().includes($)):e},[g,e]),_=m.useMemo(()=>{const $=g.toLowerCase();return $?n.filter(G=>G.toLowerCase().includes($)):n},[g,n]),L=$=>{if($===s){l(!1);return}o($),l(!1),h("")},H=()=>{u(!0),setTimeout(()=>w.current?.focus(),50)},U=async()=>{if(!(!D||P)){if(b){k(!0);return}O(!0);try{await a(D,i[0]),S(""),u(!1),l(!1)}finally{O(!1)}}},Y=async $=>{if(!(!D||P)){O(!0);try{await a(D,$),S(""),u(!1),k(!1),l(!1)}finally{O(!1)}}},F=()=>{k(!1)},te=()=>{S(""),u(!1),k(!1)};return m.useEffect(()=>{d||(h(""),u(!1),k(!1),S(""))},[d]),t.jsxs($t,{open:d,onOpenChange:l,children:[t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:f,children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||c("gitView.branch.detachedHead")}),t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(qt,{sideOffset:8,children:c("gitView.branch.currentBranchTooltip")})]}),t.jsx(_t,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(bn,{className:"h-full min-h-0",children:[t.jsx(yn,{placeholder:c("gitView.branch.searchPlaceholder"),value:g,onValueChange:h,onKeyDown:v}),t.jsxs(wn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(vn,{children:c("gitView.branch.empty")}),t.jsx(Ft,{children:y?t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("button",{type:"button",onClick:F,disabled:P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[c("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:D})," ",c("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:i.map($=>t.jsxs("button",{type:"button",onClick:()=>Y($),disabled:P,className:"flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50",children:[t.jsxs("span",{className:"typography-ui-label text-foreground",children:[P?t.jsx(R,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,$.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:$.pushUrl})]},$.name))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:w,placeholder:c("gitView.branch.newBranchPlaceholder"),value:N,onChange:$=>S($.target.value),onClick:$=>$.stopPropagation(),onKeyDown:$=>{v($),$.key==="Enter"?($.preventDefault(),U()):$.key==="Escape"&&($.preventDefault(),te())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:U,disabled:!D||P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:P?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:te,disabled:P,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]}):t.jsxs(Et,{onSelect:H,children:[t.jsx(R,{name:"add",className:"size-4"}),t.jsx("span",{children:c("gitView.branch.create")})]})}),t.jsx(ps,{}),t.jsxs(Ft,{heading:c("gitView.branch.localBranches"),children:[C.map($=>t.jsxs(Et,{onSelect:()=>L($),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:$}),(r?.[$]?.ahead||r?.[$]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[$].ahead||0," ahead ·"," ",r[$].behind||0," behind"]})]}),s===$&&t.jsx("span",{className:"typography-micro text-primary",children:c("gitView.branch.currentBadge")})]},`local-${$}`)),C.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noLocalBranches")})})]}),t.jsx(ps,{}),t.jsxs(Ft,{heading:c("gitView.branch.remoteBranches"),children:[_.map($=>t.jsx(Et,{onSelect:()=>L($),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:$})},`remote-${$}`)),_.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:c("gitView.branch.noRemoteBranches")})})]})]})]})})]})},Ec=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),Rc=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=Qe(),[o,a]=m.useState(!1),[i,f]=m.useState(s||""),[c,d]=m.useState(!1),l=m.useRef(null),g=()=>{!s||!e||(f(s),a(!0),setTimeout(()=>l.current?.focus(),0))},h=async()=>{if(!s||!e||!i.trim())return;const y=Ec(i);if(y===s){a(!1);return}d(!0);try{await e(s,y),a(!1),f("")}finally{d(!1)}},p=()=>{a(!1),f("")},u=y=>{y.key==="Enter"?(y.preventDefault(),h()):y.key==="Escape"&&(y.preventDefault(),p())};return o?t.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-8",children:t.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:y=>{y.preventDefault(),h()},children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:l,value:i,onChange:y=>f(y.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:r("gitView.branch.namePlaceholder"),onKeyDown:u,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:c,"aria-label":r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:p,disabled:c,"aria-label":r("gitView.branch.renameCancel"),title:r("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(R,{name:"close",className:"size-4"})})]})}):t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-8",children:[t.jsx(R,{name:"git-branch",className:"size-4 text-primary shrink-0"}),t.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[t.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:s||r("gitView.branch.detachedHead")}),n&&e&&s&&t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:g,title:r("gitView.branch.renameTitle"),children:t.jsx(R,{name:"edit",className:"size-4"})})]})]})},Ac=s=>{const e=Ge.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:f,removingRemoteName:c,aheadCount:d,behindCount:l,trackingRemoteName:g,hasUncommittedChanges:h}=s,p=r===void 0?[]:r,u=c===void 0?null:c,y=d===void 0?0:d,k=l===void 0?0:l,N=h===void 0?!1:h,{t:S}=Qe(),P=m.useRef(!1),O=!!u,w=p.find(pe=>pe.name===g)??p[0],v=k>0&&N,b=f||n!==null||O||!w||v,D=f||n!==null||O||p.length===0,C=y>0||k>0;let _;e[0]!==S?(_=S("gitView.sync.sync"),e[0]=S,e[1]=_):_=e[1];const L=k>0?`↓${k}`:null,H=y>0?`↑${y}`:null;let U;e[2]!==_||e[3]!==L||e[4]!==H?(U=[_,L,H].filter(Boolean),e[2]=_,e[3]=L,e[4]=H,e[5]=U):U=e[5];const Y=U.join(" "),F=v?S("gitView.sync.commitOrStashTooltip"):w?C?S("gitView.sync.syncChangesTooltip",{ahead:y,behind:k}):S("gitView.sync.syncChanges"):S("gitView.sync.noRemoteTooltip"),te=()=>{w&&a(w)},$="inline-flex items-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",G=v?0:void 0;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=se("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[6]=E):E=e[6];let B;e[7]!==S?(B=S("gitView.sync.syncChanges"),e[7]=S,e[8]=B):B=e[8];let W;e[9]!==n?(W=n==="sync"?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=W):W=e[10];let K;e[11]!==Y?(K=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:Y}),e[11]=Y,e[12]=K):K=e[12];let T;e[13]!==te||e[14]!==b||e[15]!==B||e[16]!==W||e[17]!==K?(T=t.jsxs("button",{type:"button",onClick:te,disabled:b,className:E,"aria-label":B,children:[W,K]}),e[13]=te,e[14]=b,e[15]=B,e[16]=W,e[17]=K,e[18]=T):T=e[18];let z;e[19]!==G||e[20]!==T?(z=t.jsx(Kt,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:G,children:T})}),e[19]=G,e[20]=T,e[21]=z):z=e[21];let J;e[22]!==F?(J=t.jsx(qt,{sideOffset:8,children:F}),e[22]=F,e[23]=J):J=e[23];let ae;e[24]!==z||e[25]!==J?(ae=t.jsxs(Ht,{children:[z,J]}),e[24]=z,e[25]=J,e[26]=ae):ae=e[26];const ee=$t;let X;e[27]===Symbol.for("react.memo_cache_sentinel")?(X=se("inline-flex h-7 w-6 items-center justify-center border-l border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"),e[27]=X):X=e[27];let Q;e[28]!==S?(Q=S("gitView.sync.moreActionsAria"),e[28]=S,e[29]=Q):Q=e[29];let re;e[30]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsx(R,{name:"arrow-down-s",className:"size-4"}),e[30]=re):re=e[30];let ce;e[31]!==D||e[32]!==Q?(ce=t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",className:X,disabled:D,"aria-label":Q,children:re})}),e[31]=D,e[32]=Q,e[33]=ce):ce=e[33];const me=_t,oe="start",q=-40,ie="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",he=p.map(pe=>t.jsx(At,{onSelect:ne=>{if(P.current){ne.preventDefault(),P.current=!1;return}o(pe)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(R,{name:"refresh",className:"size-4 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:S("gitView.sync.fetchFromRemote",{name:pe.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:pe.fetchUrl})]})}),i&&pe.name!==g?t.jsx(Ne,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||O,onPointerDown:ne=>{P.current=!0,ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{P.current=!0,ne.preventDefault(),ne.stopPropagation(),i(pe)},"aria-label":S("gitView.header.removeRemoteAria",{name:pe.name}),title:S("gitView.header.removeRemoteTitle",{name:pe.name}),children:u===pe.name?t.jsx(R,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(R,{name:"close",className:"size-3.5"})}):null]})},pe.name));let j;e[34]!==me||e[35]!==he?(j=t.jsx(me,{align:oe,alignOffset:q,className:ie,children:he}),e[34]=me,e[35]=he,e[36]=j):j=e[36];let V;e[37]!==ee||e[38]!==ce||e[39]!==j?(V=t.jsxs(ee,{children:[ce,j]}),e[37]=ee,e[38]=ce,e[39]=j,e[40]=V):V=e[40];let Z;return e[41]!==ae||e[42]!==V?(Z=t.jsxs("div",{className:$,children:[ae,V]}),e[41]=ae,e[42]=V,e[43]=Z):Z=e[43],Z},Bc={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},Mc={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function oo(s){return s&&Mc[s]||"var(--primary)"}const dr=s=>{const e=Ge.c(8),{icon:n,className:r,colorToken:o}=s,a=Bc[n??"branch"]??"user-3";let i;e[0]!==o?(i=oo(o),e[0]=o,e[1]=i):i=e[1];let f;e[2]!==i?(f={color:i},e[2]=i,e[3]=f):f=e[3];let c;return e[4]!==r||e[5]!==a||e[6]!==f?(c=t.jsx(R,{name:a,className:r,style:f}),e[4]=r,e[5]=a,e[6]=f,e[7]=c):c=e[7],c},ao=s=>{const e=Ge.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,f=i===void 0?!1:i,{t:c}=Qe(),d=a||r.length===0,l=n?.color;let g;e[0]!==l?(g=oo(l),e[0]=l,e[1]=g):g=e[1];let h;e[2]!==g?(h={color:g},e[2]=g,e[3]=h):h=e[3];let p;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(p=a?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(dr,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=p):p=e[7];let u;e[8]!==n?.name||e[9]!==f||e[10]!==c?(u=!f&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||c("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=f,e[10]=c,e[11]=u):u=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(R,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=y):y=e[12];let k;e[13]!==d||e[14]!==h||e[15]!==p||e[16]!==u?(k=t.jsx(Kt,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",style:h,disabled:d,children:[p,u,y]})})}),e[13]=d,e[14]=h,e[15]=p,e[16]=u,e[17]=k):k=e[17];let N;e[18]!==c?(N=c("gitView.header.identityTooltip"),e[18]=c,e[19]=N):N=e[19];let S;e[20]!==N?(S=t.jsx(qt,{sideOffset:8,children:N}),e[20]=N,e[21]=S):S=e[21];let P;e[22]!==S||e[23]!==k?(P=t.jsxs(Ht,{children:[k,S]}),e[22]=S,e[23]=k,e[24]=P):P=e[24];let O;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==c?(O=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:c("gitView.header.noProfiles")})}):r.map(b=>{const D=n?.id===b.id;return t.jsx(At,{onSelect:()=>o(b),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(dr,{icon:b.icon,colorToken:b.color,className:"size-4"}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:b.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:b.userEmail})]}),D?t.jsx(R,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},b.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=c,e[29]=O):O=e[29];let w;e[30]!==O?(w=t.jsx(_t,{align:"end",className:"w-64",children:O}),e[30]=O,e[31]=w):w=e[31];let v;return e[32]!==P||e[33]!==w?(v=t.jsxs($t,{children:[P,w]}),e[32]=P,e[33]=w,e[34]=v):v=e[34],v},Lc=s=>{const e=Ge.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=Qe(),f=`${n.remote}/${n.branch}`,c=n.ahead===0&&n.behind===0;let d;e[0]!==i||e[1]!==f||e[2]!==r?(d=r?i("gitView.header.upstreamTooltipTracking",{target:f,tracking:r}):i("gitView.header.upstreamTooltip",{target:f}),e[0]=i,e[1]=f,e[2]=r,e[3]=d):d=e[3];const l=d;let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(R,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=g):g=e[4];let h;e[5]!==f?(h=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:f}),e[5]=f,e[6]=h):h=e[6];let p;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==c||e[10]!==i?(p=c?t.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[n.ahead>0?t.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",n.ahead]}):null,n.behind>0?t.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",n.behind]}):null]}),e[7]=n.ahead,e[8]=n.behind,e[9]=c,e[10]=i,e[11]=p):p=e[11];let u;e[12]!==h||e[13]!==p?(u=t.jsx(Kt,{asChild:!0,children:t.jsxs("div",{className:"inline-flex h-8 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[g,h,p]})}),e[12]=h,e[13]=p,e[14]=u):u=e[14];let y;e[15]!==l?(y=t.jsx(qt,{sideOffset:8,children:l}),e[15]=l,e[16]=y):y=e[16];let k;return e[17]!==u||e[18]!==y||e[19]!==a?(k=t.jsxs(Ht,{delayDuration:a,children:[u,y]}),e[17]=u,e[18]=y,e[19]=a,e[20]=k):k=e[20],k},uf=s=>{const e=Ge.c(67),{status:n,localBranches:r,remoteBranches:o,branchInfo:a,syncAction:i,remotes:f,onFetch:c,onSync:d,onRemoveRemote:l,removingRemoteName:g,onCheckoutBranch:h,onCreateBranch:p,onRenameBranch:u,activeIdentityProfile:y,availableIdentities:k,onSelectIdentity:N,isApplyingIdentity:S,isWorktreeMode:P,onOpenHistory:O,onOpenGraph:w,onOpenStashes:v,onOpenUpdateBranch:b,onOpenReintegrateCommits:D,pullRequest:C,prChecks:_,onOpenPullRequest:L}=s,{t:H}=Qe();if(!n)return null;let U;e[0]!==w||e[1]!==O||e[2]!==D||e[3]!==v||e[4]!==b||e[5]!==H?(U=O||w||v||b?t.jsxs($t,{children:[t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":H("gitView.header.repositoryViews"),children:t.jsx(R,{name:"more-fill",className:"size-4"})})})}),t.jsx(qt,{sideOffset:8,children:H("gitView.header.repositoryViews")})]}),t.jsxs(_t,{align:"end",children:[O?t.jsxs(At,{onSelect:O,children:[t.jsx(R,{name:"history",className:"size-4"}),H("gitView.history.title")]}):null,w?t.jsxs(At,{onSelect:w,children:[t.jsx(R,{name:"git-branch",className:"size-4"}),H("gitView.graph.title")]}):null,v?t.jsxs(At,{onSelect:v,children:[t.jsx(R,{name:"archive-stack",className:"size-4"}),H("gitView.stashes.title")]}):null,b?t.jsxs(At,{onSelect:b,children:[t.jsx(R,{name:"git-merge",className:"size-4"}),H("gitView.header.updateBranch")]}):null,D?t.jsxs(At,{onSelect:D,children:[t.jsx(R,{name:"split-cells-horizontal",className:"size-4"}),H("gitView.integrate.title")]}):null]})]}):null,e[0]=w,e[1]=O,e[2]=D,e[3]=v,e[4]=b,e[5]=H,e[6]=U):U=e[6];let Y;e[7]!==U?(Y=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:U}),e[7]=U,e[8]=Y):Y=e[8];const F=Y,te=_?_.state==="success"?"var(--status-success)":_.state==="failure"?"var(--status-error)":"var(--status-warning)":null,$=C?C.state==="merged"?"merged":C.state==="closed"?"closed":C.draft?"draft":_?.state==="failure"||C.mergeable===!1||C.mergeableState==="blocked"||C.mergeableState==="dirty"?"blocked":"open":null;let G;e[9]!==L||e[10]!==te||e[11]!==$||e[12]!==C||e[13]!==H?(G=C&&L?t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(Ne,{variant:"ghost",size:"sm",onClick:L,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(R,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${$})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:H("gitView.pr.numberLabel",{number:C.number})}),te?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:te}}):null]})}),t.jsx(qt,{sideOffset:8,children:H("gitView.header.openPullRequest")})]}):null,e[9]=L,e[10]=te,e[11]=$,e[12]=C,e[13]=H,e[14]=G):G=e[14];const E=G,B=!n;let W;e[15]!==n.tracking?(W=n.tracking?.split("/")[0],e[15]=n.tracking,e[16]=W):W=e[16];const K=(n.files?.length??0)>0;let T;e[17]!==c||e[18]!==l||e[19]!==d||e[20]!==f||e[21]!==g||e[22]!==n.ahead||e[23]!==n.behind||e[24]!==i||e[25]!==B||e[26]!==W||e[27]!==K?(T=t.jsx(Ac,{syncAction:i,remotes:f,onFetch:c,onSync:d,onRemoveRemote:l,removingRemoteName:g,disabled:B,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:W,hasUncommittedChanges:K}),e[17]=c,e[18]=l,e[19]=d,e[20]=f,e[21]=g,e[22]=n.ahead,e[23]=n.behind,e[24]=i,e[25]=B,e[26]=W,e[27]=K,e[28]=T):T=e[28];const z=T;let J;e[29]!==n.tracking||e[30]!==n.upstreamComparison?(J=n.upstreamComparison?t.jsx(Lc,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[29]=n.tracking,e[30]=n.upstreamComparison,e[31]=J):J=e[31];const ae=J;let ee;e[32]!==y||e[33]!==k||e[34]!==S||e[35]!==N?(ee=t.jsx(ao,{activeProfile:y,identities:k,onSelect:N,isApplying:S,iconOnly:!0}),e[32]=y,e[33]=k,e[34]=S,e[35]=N,e[36]=ee):ee=e[36];const X=ee;let Q;e[37]!==a||e[38]!==P||e[39]!==r||e[40]!==h||e[41]!==p||e[42]!==u||e[43]!==o||e[44]!==f||e[45]!==n.current?(Q=t.jsx("div",{className:"min-w-0 flex-1",children:P?t.jsx(Rc,{currentBranch:n.current,onRename:u}):t.jsx(Pc,{currentBranch:n.current,localBranches:r,remoteBranches:o,branchInfo:a,onCheckout:h,onCreate:p,remotes:f})}),e[37]=a,e[38]=P,e[39]=r,e[40]=h,e[41]=p,e[42]=u,e[43]=o,e[44]=f,e[45]=n.current,e[46]=Q):Q=e[46];let re;e[47]!==X?(re=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:X}),e[47]=X,e[48]=re):re=e[48];let ce;e[49]!==Q||e[50]!==re?(ce=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[Q,re]}),e[49]=Q,e[50]=re,e[51]=ce):ce=e[51];let me;e[52]!==E?(me=E?t.jsx("div",{className:"shrink-0",children:E}):null,e[52]=E,e[53]=me):me=e[53];let oe;e[54]===Symbol.for("react.memo_cache_sentinel")?(oe=t.jsx("div",{className:"min-w-0 flex-1"}),e[54]=oe):oe=e[54];let q;e[55]!==ae?(q=ae?t.jsx("div",{className:"min-w-0 shrink",children:ae}):null,e[55]=ae,e[56]=q):q=e[56];let ie;e[57]!==z?(ie=t.jsx("div",{className:"shrink-0",children:z}),e[57]=z,e[58]=ie):ie=e[58];let he;e[59]!==F||e[60]!==me||e[61]!==q||e[62]!==ie?(he=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[me,oe,q,F,ie]}),e[59]=F,e[60]=me,e[61]=q,e[62]=ie,e[63]=he):he=e[63];let j;return e[64]!==ce||e[65]!==he?(j=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[ce,he]}),e[64]=ce,e[65]=he,e[66]=j):j=e[66],j},Fc=s=>s==="/",Vs=s=>s.replace(/\\/g,"/"),En=s=>{if(!s||Fc(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},bs=s=>s.endsWith("/"),Oc=s=>{const e=s.trim();return!e||bs(e)?e:`${e}/`},Rn=s=>s.lastIndexOf("/"),io=s=>{if(bs(s))return s;const e=Rn(s);return e<0?s:s.slice(0,e+1)},Uc=s=>{const e=Rn(s);return s.slice(e+1)},lo=s=>{const e=En(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Rn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},$c=s=>bs(s)&&lo(s)!==null,Wc=(s,e)=>`${io(s)}${e}/`,zt=s=>{if(!s)return null;const e=En(Vs(s.trim()));return e?e.toLowerCase():null},ur=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},_c=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,rn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},zc=async()=>{try{const s=await Bt("/api/fs/home",{method:"GET",headers:{Accept:"application/json"}});if(s.ok){const e=await s.json();if(typeof e.home=="string"&&e.home.trim().length>0)return Vs(e.home.trim())}}catch{}return xs.getFilesystemHome().catch(()=>null)},ff=({open:s,onOpenChange:e})=>{const{t:n}=Qe(),r=Es(I=>I.homeDirectory),o=Ct(I=>I.projects),a=Ct(I=>I.addProject),i=Pe(I=>I.setActiveMainTab),f=Pe(I=>I.setSessionSwitcherOpen),c=rt(I=>I.openNewSessionDraft),d=Vt(I=>I.profiles),l=Vt(I=>I.globalIdentity),g=Vt(I=>I.defaultGitIdentityId),h=Vt(I=>I.loadProfiles),p=Vt(I=>I.loadGlobalIdentity),u=Vt(I=>I.loadDefaultGitIdentityId),{canRequestAccess:y,requestAccess:k,startAccessing:N}=Tc(),{isMobile:S}=Hs(),P=m.useRef(null),O=m.useRef(null),w=m.useRef(new Map),[v,b]=m.useState(""),[D,C]=m.useState("~/"),[_,L]=m.useState([]),[H,U]=m.useState(!1),[Y,F]=m.useState(!1),[te,$]=m.useState(null),[G,E]=m.useState(0),[B,W]=m.useState(0),[K,T]=m.useState(!1),[z,J]=m.useState(!1),[ae,ee]=m.useState(0),[X,Q]=m.useState(!1),[re,ce]=m.useState(""),[me,oe]=m.useState(null),[q,ie]=m.useState(!1),he=v||r,j=m.useMemo(()=>new Set(o.map(I=>zt(I.path)).filter(I=>!!I)),[o]);m.useEffect(()=>{if(!s)return;C("~/"),L([]),W(0),T(!1),J(!1),Q(!1),ce(""),oe(null),ie(!1),requestAnimationFrame(()=>rn(P.current));let I=!1;return(async()=>{const Ce=await zc();I||(b(Ce||r||""),requestAnimationFrame(()=>rn(P.current)))})(),()=>{I=!0}},[r,s]),m.useEffect(()=>{s&&(h(),p(),u())},[u,h,p,s]);const V=m.useMemo(()=>{const I=new Map;l&&I.set(l.id,l);for(const ye of d)I.set(ye.id,ye);return Array.from(I.values())},[d,l]);m.useEffect(()=>{if(!s||!X||me!==null)return;const I=typeof g=="string"?g.trim():"";if(I&&V.some(Ce=>Ce.id===I)){oe(I);return}const ye=V.find(Ce=>Ce.authType==="ssh"||Ce.sshKey);ye&&oe(ye.id)},[V,g,X,s,me]);const Z=m.useMemo(()=>V.find(I=>I.id===me)??null,[V,me]),pe=m.useMemo(()=>io(D),[D]),ne=m.useMemo(()=>bs(D)?"":Uc(D),[D]),we=m.useMemo(()=>he?ur(pe,he):"",[pe,he]);m.useEffect(()=>{if(!s||!we){L([]),$(null);return}let I=!1;return U(!0),F(!1),$(null),xs.listLocalDirectory(we).then(ye=>{if(I)return;F(!1),$(null);const Ce=ye.filter(Re=>Re.isDirectory).map(Re=>({name:Re.name,path:Vs(Re.path)})).sort((Re,at)=>Re.name.localeCompare(at.name));L(Ce)}).catch(ye=>{if(!I){L([]);const Ce=gi(ye)?ye.reason:"unknown";$(Ce),F(Ce==="not-found")}}).finally(()=>{I||U(!1)}),()=>{I=!0}},[we,G,s]);const Te=m.useMemo(()=>{const I=ne.toLowerCase(),ye=q||ne.startsWith(".");return _.filter(Ce=>Ce.name.toLowerCase().startsWith(I)&&(ye||!Ce.name.startsWith(".")))},[ne,_,q]),Be=m.useMemo(()=>{const I=[];$c(D)&&I.push({type:"up",value:"browse:up",name:"..",path:lo(D)});for(const ye of Te){const Ce=zt(ye.path);I.push({type:"directory",value:`browse:${ye.path}`,name:ye.name,path:ye.path,disabled:!!(Ce&&j.has(Ce))})}return I},[j,Te,D]);m.useEffect(()=>{W(0)},[D,Be.length]);const Me=m.useMemo(()=>he?En(ur(D,he)):"",[he,D]),tt=zt(Me),Le=!!(tt&&j.has(tt)),Xe=m.useMemo(()=>ne?Te.find(I=>I.name===ne)??null:null,[ne,Te]),Ae=!!(Me&&!Le&&(te===null||te==="not-found")&&(bs(D)&&Y||!bs(D)&&ne.trim().length>0&&Xe===null)),Ze=!K&&!z&&!Le&&te!=="os-permission"&&te!=="invalid-response"&&te!=="unknown"&&!!Me,Fe=Ze&&re.trim().length>0,Ye=Be[B]??null,ot=!!(Ye&&(Ye.type==="up"||Ye.type==="directory"&&!Ye.disabled)),We=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Je=n(Le?"directoryExplorerDialog.actions.alreadyAdded":X?K?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":K?"directoryExplorerDialog.actions.adding":Ae?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");m.useLayoutEffect(()=>{const I=O.current;if(!I)return;const ye=()=>ee(Math.ceil(I.getBoundingClientRect().width));if(ye(),typeof ResizeObserver>"u")return;const Ce=new ResizeObserver(ye);return Ce.observe(I),()=>Ce.disconnect()},[Je]),m.useLayoutEffect(()=>{const I=P.current;I&&(I.scrollLeft=I.scrollWidth)},[ae,D]),m.useLayoutEffect(()=>{s&&rn(P.current)},[s]),m.useLayoutEffect(()=>{const I=Be[B];I&&w.current.get(I.value)?.scrollIntoView({block:"nearest"})},[B,Be]);const Ke=m.useCallback(()=>{e(!1)},[e]),Ie=m.useCallback((I,ye)=>{i("chat"),S&&f(!1),c({selectedProjectId:I,directoryOverride:ye}),Ke()},[Ke,S,c,i,f]),De=m.useCallback((I,ye)=>{I.stopPropagation();const Ce=zt(ye);if(Ce&&j.has(Ce))return;const Re=a(ye);if(!Re){ke.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Ie(Re.id,Re.path)},[a,j,Ie,n]),_e=m.useCallback(async I=>{if(!I||K)return;const ye=zt(I);if(ye&&j.has(ye))return;let Ce=I;T(!0);try{const Re=!X&&Ae&&zt(I)===zt(Me);if(X){const lt=re.trim();if(!lt){ke.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Ce=(await xs.cloneRepository({remoteUrl:lt,destinationPath:I,gitIdentityId:Z?.id??null})).path}else Re&&await xs.createDirectory(I,{asProject:!0});const at=a(Ce);if(!at){ke.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Ie(at.id,at.path)}catch(Re){ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Re instanceof Error?Re.message:n("directoryExplorerDialog.toast.unknownError")})}finally{T(!1)}},[a,j,re,X,K,Ie,Z?.id,Ae,Me,n]),qe=m.useCallback(I=>{C(Oc(I))},[]),it=m.useCallback(I=>{C(Wc(D,I.name))},[D]),x=m.useCallback(I=>{if(I){if(I.type==="up"){I.path&&qe(I.path);return}I.disabled||it(I)}},[qe,it]),A=m.useCallback(async()=>{if(!(!y||z)){J(!0);try{const I=await k(Me);if(!I.success||!I.path){I.error&&I.error!=="Directory selection cancelled"&&ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I.error});return}const ye=await N(I.path);if(!ye.success){ke.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:ye.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await _e(I.path)}catch(I){ke.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:I instanceof Error?I.message:n("directoryExplorerDialog.toast.unknownError")})}finally{J(!1)}}},[y,_e,z,k,N,n,Me]),ge=m.useCallback(I=>{if(I.key==="ArrowDown"){I.preventDefault(),W(ye=>Math.min(Be.length-1,ye+1));return}if(I.key==="ArrowUp"){I.preventDefault(),W(ye=>Math.max(0,ye-1));return}if(I.key==="Enter"){if(I.preventDefault(),_c(I)){_e(Me);return}ot&&x(Ye);return}I.key==="Backspace"&&D===""&&(I.preventDefault(),Ke())},[x,_e,Ke,ot,Ye,D,Be.length,Me]),fe=t.jsxs("button",{type:"button",onClick:()=>ie(I=>!I),className:"flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40",children:[q?t.jsx(R,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(R,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),ve=t.jsxs("div",{className:"px-2.5 py-1.5",children:[X?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(yt,{value:re,onChange:I=>ce(I.target.value),placeholder:n("directoryExplorerDialog.clone.remoteUrlPlaceholder"),className:"min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),t.jsx(ao,{activeProfile:Z,identities:V,onSelect:I=>oe(I.id),isApplying:K,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(R,{name:"folder-add",className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80"}),t.jsx(yt,{ref:P,value:D,onChange:I=>C(Vs(I.target.value)),onKeyDown:ge,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!S&&ae>0?{paddingRight:`${ae+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),S?null:t.jsx(Ne,{ref:O,variant:"outline",size:"xs",tabIndex:-1,className:"absolute right-1.5 top-1/2 h-7 -translate-y-1/2 gap-1 px-2 typography-meta",disabled:X?!Fe:!Ze,onMouseDown:I=>I.preventDefault(),onClick:()=>{_e(Me)},title:Je,children:Je})]})]}),Ue=t.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm",children:t.jsxs("div",{className:"max-h-[min(28rem,58vh)] overflow-y-auto p-2",children:[t.jsx("div",{className:"px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80",children:n("directoryExplorerDialog.browse.directories")}),H?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):te&&te!=="not-found"?t.jsxs("div",{className:"flex flex-col items-center gap-3 px-4 py-10 text-center",children:[t.jsx("div",{className:"typography-ui-label text-status-error",children:n(te==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[te==="os-permission"&&y?t.jsx(Ne,{size:"xs",onClick:()=>{A()},disabled:z,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Ne,{variant:"outline",size:"xs",onClick:()=>E(I=>I+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):Be.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:Be.map((I,ye)=>{const Ce=ye===B;return t.jsxs("button",{ref:Re=>{Re?w.current.set(I.value,Re):w.current.delete(I.value)},type:"button",disabled:I.type==="directory"&&I.disabled,onMouseEnter:()=>W(ye),onMouseDown:Re=>Re.preventDefault(),onClick:()=>x(I),className:se("flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Ce&&"bg-interactive-selection text-interactive-selection-foreground",!Ce&&"hover:bg-interactive-hover/50",I.type==="directory"&&I.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[I.type==="up"?t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(R,{name:"folder-6",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}),t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:t.jsx("span",{className:"truncate typography-ui-label text-foreground",children:I.name})}),I.type==="directory"&&I.disabled?t.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground",children:n("directoryExplorerDialog.browse.addedBadge")}):I.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Re=>Re.stopPropagation(),onClick:Re=>De(Re,I.path),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",title:n("directoryExplorerDialog.browse.quickAdd"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null]},I.value)})})]})}),Ve=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[ve,Ue]}),$e=t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(R,{name:"arrow-down-s",className:"-ml-1 h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.navigate")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.select")]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:We}),t.jsx(R,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Ee=()=>t.jsxs(t.Fragment,{children:[S?null:$e,t.jsxs("div",{className:se("flex w-full flex-row justify-end gap-2 sm:w-auto",S&&"justify-stretch"),children:[y?t.jsx(Ne,{variant:"ghost",size:"xs",onClick:A,disabled:K||z||X,children:n(z?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Ne,{variant:"ghost",size:"xs",onClick:()=>Q(I=>!I),disabled:K||z,className:se(S&&"flex-1"),children:n(X?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),S?t.jsx(Ne,{size:"xs",onClick:()=>{_e(Me)},disabled:X?!Fe:!Ze,className:"flex-1",children:Je}):null]})]});return S?t.jsx(Ss,{open:s,onClose:Ke,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:Ee()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:fe}),Ve]})}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Gs,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Ds,{children:n("directoryExplorerDialog.title")}),t.jsx(ya,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),fe]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Ve}),t.jsx(Tn,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:Ee()})]})})};function fr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=Un(e,o,l=>l),i=Un(n,o,l=>l),f=[],c=a.other,d=i.other;for(const l of a.matching)f.push({label:l,value:l,source:"local"});for(const l of i.matching)f.push({label:l,value:`remotes/${l}`,source:"remote"});return f.sort((l,g)=>{const h=l.label.localeCompare(g.label,void 0,{sensitivity:"accent"});return h!==0?h:l.source!==g.source?l.source.localeCompare(g.source):l.value.localeCompare(g.value)}),{matching:f,otherLocal:c,otherRemote:d}}const on="oc:lastWorktreeSourceBranch",Vc=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Gc=({branches:s,savedSourceBranch:e,rootBranch:n})=>!!(e&&s.includes(e))&&e?{sourceBranch:e,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&s.includes(n)?n:s.includes("main")?"main":s.includes("master")?"master":s[0]??"",shouldClearSavedSourceBranch:!!e};function Hc({open:s,onOpenChange:e,onSelect:n}){const{t:r}=Qe(),o=Pe(j=>j.isMobile),{github:a}=Dn(),i=_s(j=>j.status),f=_s(j=>j.hasChecked),c=Pe(j=>j.setSettingsDialogOpen),d=Pe(j=>j.setSettingsPage),l=Ct(j=>j.getActiveProject()),g=l?.path??null,h=le.useMemo(()=>g&&l?{id:l.id,path:g}:null,[l,g]),[p,u]=le.useState("issues"),[y,k]=le.useState(""),[N,S]=le.useState([]),[P,O]=le.useState([]),[w,v]=le.useState(!1),[b,D]=le.useState(!1),[C,_]=le.useState(null),[L,H]=le.useState(null),[U,Y]=le.useState(null),[F,te]=le.useState(!1),[$,G]=le.useState(new Map),[E,B]=le.useState(1),[W,K]=le.useState(!1),T=wa(y,350),z=le.useCallback(async j=>{if(!(!g||!a)&&!(f&&i?.connected===!1)){v(!0),_(null),B(1),K(!1);try{if(p==="issues"&&a.issuesList){const V=await a.issuesList(g,{page:1,query:j});V.connected===!1?(_(r("session.githubIntegration.error.notConnected")),S([])):(S(V.issues??[]),B(V.page??1),K(!!V.hasMore))}else if(p==="prs"&&a.prsList){const V=await a.prsList(g,{page:1,query:j});V.connected===!1?(_(r("session.githubIntegration.error.notConnected")),O([])):(O(V.prs??[]),B(V.page??1),K(!!V.hasMore))}}catch(V){_(V instanceof Error?V.message:r("session.githubIntegration.error.loadDataFailed"))}finally{v(!1)}}},[g,a,f,i,p,r]);le.useEffect(()=>{if(!s||!g||f&&i?.connected===!1||!a)return;if(!T.trim()){z();return}const j=new AbortController;v(!0),_(null),B(1),K(!1);const V=p==="issues"&&a.issuesList?a.issuesList(g,{page:1,query:T.trim()}):p==="prs"&&a.prsList?a.prsList(g,{page:1,query:T.trim()}):null;if(!V){v(!1);return}return V.then(Z=>{j.signal.aborted||("issues"in Z?Z.connected===!1?(_(r("session.githubIntegration.error.notConnected")),S([])):(S(Z.issues??[]),B(Z.page??1),K(!!Z.hasMore)):"prs"in Z&&(Z.connected===!1?(_(r("session.githubIntegration.error.notConnected")),O([])):(O(Z.prs??[]),B(Z.page??1),K(!!Z.hasMore))))}).catch(Z=>{j.signal.aborted||_(Z instanceof Error?Z.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{j.signal.aborted||v(!1)}),()=>j.abort()},[s,g,a,f,i,p,T,z,r]);const J=le.useCallback(async()=>{if(!(!g||!a)&&!(w||b)&&W){D(!0);try{const j=E+1;if(p==="issues"&&a.issuesList){const V=T.trim()?await a.issuesList(g,{page:j,query:T.trim()}):await a.issuesList(g,{page:j});V.connected!==!1&&(S(Z=>[...Z,...V.issues??[]]),B(V.page??j),K(!!V.hasMore))}else if(p==="prs"&&a.prsList){const V=T.trim()?await a.prsList(g,{page:j,query:T.trim()}):await a.prsList(g,{page:j});V.connected!==!1&&(O(Z=>[...Z,...V.prs??[]]),B(V.page??j),K(!!V.hasMore))}}catch{}finally{D(!1)}}},[g,a,p,E,W,w,b,T]);le.useEffect(()=>{if(!s){u("issues"),k(""),S([]),O([]),H(null),Y(null),te(!1),_(null),G(new Map),B(1),K(!1);return}z()},[s,z]);const ae=le.useCallback(async j=>{if(!(!h||!j)&&!$.has(j))try{const Z=(await Rr(h,{mode:"new",branchName:j,worktreeName:j})).errors.find(pe=>pe.code==="branch_in_use");G(pe=>new Map(pe).set(j,{isValid:!Z,error:Z?r(Z.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{G(V=>new Map(V).set(j,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[h,$,r]);le.useEffect(()=>{!s||p!=="prs"||P.forEach(j=>{j.head&&ae(j.head)})},[s,p,P,ae]);const ee=f&&i?.connected===!0,X=()=>{d("github"),c(!0)},Q=j=>{H(j),Y(null)},re=j=>{Y(j),H(null)},ce=()=>{L?n({type:"issue",item:L}):U&&n({type:"pr",item:U,includeDiff:F}),e(!1)},me=()=>{H(null),Y(null),te(!1)},oe=L||U&&$.get(U.head??"")?.isValid!==!1,q=j=>j.head?$.get(j.head)?.isValid===!1:!0,ie=t.jsx(t.Fragment,{children:ee?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(R,{name:"search",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(yt,{value:y,onChange:j=>k(j.target.value),placeholder:r(p==="issues"?"session.githubIntegration.search.issuesPlaceholder":"session.githubIntegration.search.prsPlaceholder"),className:"h-8 pl-9"})]}),t.jsx("div",{className:"mt-2 h-[300px] overflow-hidden",children:t.jsxs("div",{className:"h-full overflow-y-auto",children:[w&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),C&&t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive",children:[t.jsx(R,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:C})]})}),!w&&!C&&p==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[N.length>0?N.map(j=>t.jsx("button",{onClick:()=>Q(j),className:se("w-full text-left px-2 py-1.5 rounded transition-colors",L?.number===j.number?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",j.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:j.title}),j.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block",children:[j.sourceRepo.owner,"/",j.sourceRepo.repo]}):null]})]})},`${j.sourceRepo?.owner??""}-${j.sourceRepo?.repo??""}-${j.number}`)):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noIssuesFound")}),W&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{J()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),b&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!w&&!C&&p==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[P.length>0?P.map(j=>{const V=q(j),Z=j.head?$.get(j.head):void 0;return t.jsx("button",{onClick:()=>!V&&re(j),disabled:V,className:se("w-full text-left px-2 py-1.5 rounded transition-colors",U?.number===j.number?"bg-interactive-selection text-interactive-selection-foreground":V?"opacity-50 cursor-not-allowed":"hover:bg-interactive-hover"),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("span",{className:"text-muted-foreground shrink-0 typography-micro",children:["#",j.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:j.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[j.head," → ",j.base]}),j.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[j.sourceRepo.owner,"/",j.sourceRepo.repo]}):null,V&&Z?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:Z.error})]})]})]})},`${j.sourceRepo?.owner??""}-${j.sourceRepo?.repo??""}-${j.number}`)}):t.jsx("div",{className:"flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground",children:r("session.githubIntegration.empty.noPullRequestsFound")}),W&&!b&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{J()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),b&&t.jsx("div",{className:"flex items-center justify-center py-2",children:t.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]})]})})]}):t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 gap-4",children:[t.jsx(R,{name:"github",className:"h-12 w-12 text-muted-foreground"}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"typography-ui-label text-foreground",children:r("session.githubIntegration.connect.title")}),t.jsx("p",{className:"typography-small text-muted-foreground mt-1",children:r("session.githubIntegration.connect.description")})]}),t.jsx(Ne,{onClick:X,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),he=t.jsxs("div",{className:se("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:se("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(L||U)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 h-8 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate max-w-[150px]",children:L?r("session.githubIntegration.selected.issueNumber",{number:L.number}):r("session.githubIntegration.selected.prNumber",{number:U?.number??""})}),t.jsx("button",{onClick:me,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),p==="prs"&&U&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Ps,{checked:F,onChange:j=>te(j),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:se("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),className:se(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Ne,{size:"sm",onClick:ce,disabled:!oe,className:se(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(Ss,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:ee?he:void 0,renderHeader:j=>t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border/40",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:r("session.githubIntegration.title")}),j]}),t.jsx("div",{className:"w-full",children:t.jsx(Cs,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:V=>{u(V),k("")},variant:"active-pill",layoutMode:"fit"})}),(L||U)&&t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:L?r("session.githubIntegration.selected.issueNumber",{number:L.number}):r("session.githubIntegration.selected.prNumber",{number:U?.number??""})}),t.jsx("button",{onClick:me,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ie}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ds,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"github",className:"h-5 w-5"}),r("session.githubIntegration.title")]}),t.jsx("div",{className:"w-[220px]",children:t.jsx(Cs,{items:[{id:"issues",label:r("session.githubIntegration.tabs.issues"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(R,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:j=>{u(j),k("")},variant:"active-pill",layoutMode:"fit"})})]})}),ie,t.jsx(Tn,{className:"mt-1",children:he})]})})})}const ks=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),Kc=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",mr=(s,e,n)=>{const r=ks(s.head||"");if(!r)throw new Error("PR head branch is missing");if(e.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};const o=n.find(d=>{const l=d.indexOf("/");return l<=0||l>=d.length-1?!1:d.slice(l+1)===r});if(o){const d=o.indexOf("/"),l=o.slice(0,d);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:l,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${l}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",f=`pr-${Kc(i)}`,c=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!c)throw new Error("PR head repository URL is unavailable. The fork may have been deleted; push the branch to a reachable repository and try again.");return{existingBranch:`remotes/${f}/${r}`,setUpstream:!0,upstreamRemote:f,upstreamBranch:r,ensureRemoteName:f,ensureRemoteUrl:c,sourceLabel:`${f}/${r}`}},xt=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,"").split("/").join("-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,80),qc=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
3
+ ${JSON.stringify(e,null,2)}`},Yc=s=>`GitHub pull request context (JSON)
4
+ ${JSON.stringify(s,null,2)}`;function mf({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=Qe(),{github:o,git:a}=Dn(),i=Pe(x=>x.isMobile),f=_s(x=>x.status),c=_s(x=>x.hasChecked),d=Ct(x=>x.getActiveProject()),l=d?.path??null,g=le.useMemo(()=>l&&d?{id:d.id,path:l}:null,[d,l]),[h,p]=le.useState("new-branch"),[u,y]=le.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[k,N]=le.useState({selectedBranch:"",worktreeName:""}),S=va(l),P=ja(l),O=Pn(x=>x.fetchBranches),w=le.useMemo(()=>S?.all?S.all.filter(x=>!x.startsWith("remotes/")).sort():[],[S]),v=le.useMemo(()=>S?.all?S.all.filter(x=>x.startsWith("remotes/")).map(x=>x.replace(/^remotes\//,"")).sort():[],[S]),b=rt(x=>x.availableWorktreesByProject),D=le.useMemo(()=>{if(!l)return new Set;const x=b.get(l)??[];return new Set(x.map(A=>A.name))},[b,l]),C=le.useCallback((x=10)=>{for(let A=0;A<x;A++){const ge=Zs();if(!D.has(ge))return ge}return`${Zs()}-${Date.now().toString(36).slice(-4)}`},[D]),[_,L]=le.useState(!1),[H,U]=le.useState(!1),[Y,F]=le.useState(!1),[te,$]=le.useState(!1),[G,E]=le.useState(!1),[B,W]=le.useState(""),[K,T]=le.useState(""),z=le.useRef(null),J=le.useRef(null),ae=le.useRef(null),ee=le.useRef(null),X=le.useCallback(x=>{x.stopPropagation()},[]),Q=le.useCallback(x=>{let A=x;for(;A&&A!==document.body;){const{overflowY:ge}=window.getComputedStyle(A);if((ge==="auto"||ge==="scroll")&&A.scrollHeight>A.clientHeight)return A;A=A.parentElement}return null},[]),re=le.useCallback(x=>{x&&(x.scrollTop=0)},[]),ce=le.useCallback(x=>{const A=x.current?.querySelector('[data-slot="command-list"]')??null;re(A)},[re]),me=le.useCallback(x=>{const A=Q(x.current);re(A)},[Q,re]),oe=le.useMemo(()=>fr({localBranches:w,remoteBranches:v,query:B}),[w,v,B]),q=le.useMemo(()=>fr({localBranches:w,remoteBranches:v,query:K}),[w,v,K]),ie=B.trim().length>0,he=K.trim().length>0,j=oe.matching.length>0,V=q.matching.length>0,Z=!!(l&&a),pe=le.useCallback(()=>{!l||!a||O(l,a)},[l,a,O]);le.useEffect(()=>{!s||!l||!a||S?.all||O(l,a)},[s,l,a,S?.all,O]),le.useEffect(()=>{!H&&!te&&W("")},[H,te]),le.useEffect(()=>{!Y&&!G&&T("")},[Y,G]),le.useEffect(()=>{H&&ce(z),te&&me(ae)},[H,te,B,ce,me]),le.useEffect(()=>{Y&&ce(J),G&&me(ee)},[Y,G,K,ce,me]);const[ne,we]=le.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Te,Be]=le.useState(!1),[Me,tt]=le.useState(null),Le=le.useCallback(()=>{const x=kt.getState(),A=x.getVisibleAgents();if(x.settingsDefaultAgent){const ge=A.find(fe=>fe.name===x.settingsDefaultAgent);if(ge)return ge.name}return A.find(ge=>ge.name==="build")?.name||A[0]?.name},[]),Xe=le.useCallback(()=>{const x=kt.getState(),A=x.settingsDefaultModel;if(!A)return null;const ge=Er(A);if(!ge)return null;const{providerId:fe,modelId:ve}=ge;return x.getModelMetadata(fe,ve)?{providerID:fe,modelID:ve}:null},[]),Ae=le.useCallback((x,A)=>{const ge=kt.getState(),fe=ge.settingsDefaultVariant,ve=ge.currentProviderId===x&&ge.currentModelId===A?ge.currentVariant:void 0,$e=ge.providers.find(Ee=>Ee.id===x)?.models.find(Ee=>Ee.id===A)?.variants;if(!$e)return fe||ve||void 0;if(fe&&Object.prototype.hasOwnProperty.call($e,fe))return fe;if(ve&&Object.prototype.hasOwnProperty.call($e,ve))return ve},[]),Ze=le.useCallback(async x=>{if(!l||!o)return;const A=kt.getState(),ge=Ar.getState().lastUsedProvider,fe=Xe(),ve=fe?.providerID||A.currentProviderId||ge?.providerID,Ue=fe?.modelID||A.currentModelId||ge?.modelID,Ve=Le()||A.currentAgentName||void 0;if(!ve||!Ue){ke.error(r("session.newWorktree.error.noModelSelected"));return}const $e=Ae(ve,Ue);if(x.issue){if(!o.issueGet||!o.issueComments)return;const Ee=await o.issueGet(l,x.issue.number,{sourceRepo:x.issue.sourceRepo??null});if(Ee.connected===!1||!Ee.repo||!Ee.issue)throw new Error("Failed to load issue context");const I=await o.issueComments(l,x.issue.number,{sourceRepo:x.issue.sourceRepo??null});if(I.connected===!1)throw new Error("Failed to load issue comments");const ye=await gs("github.issue.review.visible",{issue_number:String(x.issue.number)}),Ce=await gs("github.issue.review.instructions"),Re=qc({repo:Ee.repo,issue:Ee.issue,comments:I.comments??[]});await rt.getState().sendMessage(ye,ve,Ue,Ve,void 0,void 0,[{text:Ce,synthetic:!0},{text:Re,synthetic:!0}],$e,void 0,{sessionId:x.sessionId}),$n(x.sessionId,x.directory,Wn({url:Ee.issue.url,number:Ee.issue.number,title:Ee.issue.title,kind:"issue",author:Ee.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ke.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(x.pr){if(!o.prContext)return;const Ee=await o.prContext(l,x.pr.number,{sourceRepo:x.pr.sourceRepo??null,includeDiff:x.includeDiff,includeCheckDetails:!1});if(Ee.connected===!1||!Ee.repo||!Ee.pr)throw new Error("Failed to load PR context");const I=await gs("github.pr.review.visible",{pr_number:String(x.pr.number)}),ye=await gs("github.pr.review.instructions"),Ce=Yc(Ee);await rt.getState().sendMessage(I,ve,Ue,Ve,void 0,void 0,[{text:ye,synthetic:!0},{text:Ce,synthetic:!0}],$e,void 0,{sessionId:x.sessionId}),$n(x.sessionId,x.directory,Wn({url:Ee.pr.url,number:Ee.pr.number,title:Ee.pr.title,kind:"pull",author:Ee.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),ke.success(r("session.newWorktree.toast.sessionFromPr"))}},[o,l,Le,Xe,Ae,r]),Fe=h==="new-branch"?u:k;le.useEffect(()=>{if(!s||!S?.all||!l||u.sourceBranch)return;const x=u.sourceBranch;let A=!1;return(async()=>{try{const fe=await ka(l).catch(()=>null);if(A)return;const ve=localStorage.getItem(on),{sourceBranch:Ue,shouldClearSavedSourceBranch:Ve}=Gc({branches:S.all,savedSourceBranch:ve,rootBranch:fe});if(Ve&&localStorage.removeItem(on),A||x)return;Ue&&y($e=>({...$e,sourceBranch:Ue}))}catch{}})(),()=>{A=!0}},[s,S?.all,l,u.sourceBranch]),le.useLayoutEffect(()=>{if(!s)return;p("new-branch"),N({selectedBranch:"",worktreeName:""}),U(!1),F(!1),$(!1),E(!1),W(""),T(""),we({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const x=C();y({branchName:x,worktreeName:x,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,C]),le.useEffect(()=>{if(h!=="new-branch"||!u.isSyncingWorktreeName)return;const x=ks(u.branchName),A=xt(x);y(ge=>({...ge,worktreeName:A}))},[h,u.branchName,u.isSyncingWorktreeName]);const Ye=le.useCallback(async()=>{if(!g||!ne.touched||Te)return;Me&&Me.abort();const x=new AbortController;tt(x),we(A=>({...A,isValidating:!0}));try{const A=h==="new-branch"?u.branchName:k.selectedBranch,ge=Fe.worktreeName,fe=ks(A),ve=xt(ge);let Ue=null,Ve=null;if(fe||(Ue=r("session.newWorktree.error.branchNameRequired")),ve||(Ve=r("session.newWorktree.error.worktreeDirectoryRequired")),fe&&ve){const $e=h==="new-branch"?u.linkedPr:null,Ee=$e?mr($e,w,v):null,I=await Rr(g,{mode:h==="existing-branch"||Ee?"existing":"new",branchName:fe,worktreeName:ve,existingBranch:Ee?.existingBranch??(h==="existing-branch"?fe:void 0),...Ee?.ensureRemoteName?{ensureRemoteName:Ee.ensureRemoteName}:{},...Ee?.ensureRemoteUrl?{ensureRemoteUrl:Ee.ensureRemoteUrl}:{}});if(x.signal.aborted)return;I.ok||I.errors.forEach(ye=>{if(ye.code==="worktree_exists"){Ve=Ve??ye.message;return}ye.code.startsWith("branch_")&&(Ue=Ue??ye.message)})}x.signal.aborted||we($e=>({...$e,isValidating:!1,branchError:Ue,worktreeError:Ve}))}catch{x.signal.aborted||we(A=>({...A,isValidating:!1}))}},[g,h,u.branchName,u.linkedPr,k.selectedBranch,Fe.worktreeName,w,v,ne.touched,Me,Te,r]),ot=h==="new-branch"?u.branchName:k.selectedBranch;le.useEffect(()=>{if(!s||!g||!ne.touched||Te)return;const x=setTimeout(()=>{Ye()},300);return()=>clearTimeout(x)},[Fe.worktreeName,ot,s,g,Ye,ne.touched,Te]);const We=async()=>{if(!g||!l){ke.error(r("session.newWorktree.error.noActiveProject"));return}we(ve=>({...ve,touched:!0}));const x=h==="new-branch"?u.branchName:k.selectedBranch,A=Fe.worktreeName,ge=ks(x),fe=xt(A);if(!ge){ke.error(r("session.newWorktree.error.branchNameRequired"));return}if(!fe){ke.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Me&&(Me.abort(),tt(null)),we(ve=>({...ve,isValidating:!1,branchError:null,worktreeError:null})),Be(!0);try{const ve=h==="new-branch"?u.linkedPr:null,Ue=h==="new-branch"?u.linkedIssue:null,Ve=h==="new-branch"?u.linkedPr:null,$e=h==="new-branch"?u.includePrDiff:!1,Ee=!!(Ue||Ve),I=await kr(g),ye=u.sourceBranch;let Ce="";const Re=(()=>{if(ve){const ze=mr(ve,w,v);return Ce=ze.sourceLabel,{preferredName:ge||fe,mode:"existing",branchName:ge,worktreeName:fe,existingBranch:ze.existingBranch,setupCommands:I,setUpstream:ze.setUpstream,upstreamRemote:ze.upstreamRemote,upstreamBranch:ze.upstreamBranch,returnAfterDirectoryCreated:!0,...ze.ensureRemoteName?{ensureRemoteName:ze.ensureRemoteName}:{},...ze.ensureRemoteUrl?{ensureRemoteUrl:ze.ensureRemoteUrl}:{}}}return Ce=h==="new-branch"?ye:"",{preferredName:ge||fe,mode:h==="existing-branch"?"existing":"new",branchName:h==="existing-branch"?void 0:ge,worktreeName:fe,existingBranch:h==="existing-branch"?ge:void 0,setupCommands:I,returnAfterDirectoryCreated:!0,...ye&&h==="new-branch"?{startRef:ye}:{}}})(),at=await Sa(l,Re),lt=await Na(g,at);let st=null;if(Ee){await Sr(g)&&await Ca(lt.path);const ze=Ue?`#${Ue.number} ${Ue.title}`.trim():Ve?`#${Ve.number} ${Ve.title}`.trim():r("session.newWorktree.newSessionTitle"),ut=await Ia(ze,lt.path,null);if(!ut?.id)throw new Error("Failed to create session");st=ut.id,n?.(lt.path,{sessionId:st}),e(!1),Be(!1),Ta(ut.id,ze).catch(()=>{});try{rt.getState().initializeNewOpenChamberSession(ut.id,kt.getState().agents)}catch{}}else e(!1),Be(!1);const mt=Vc({mode:h,sourceBranch:u.sourceBranch,linkedPr:!!u.linkedPr,selectedBranch:k.selectedBranch});mt&&localStorage.setItem(on,mt),ke.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${lt.branch||lt.name}${Ce?` ${r("session.newWorktree.fromSource",{source:Ce})}`:""}`})}),st?Ze({sessionId:st,directory:lt.path,issue:Ue,pr:Ve,includeDiff:$e}).catch(ze=>{const ut=ze instanceof Error?ze.message:r("session.newWorktree.error.sendGitHubContextFailed");ke.error(r("session.newWorktree.error.sendGitHubContextFailed"),{description:ut})}):n?.(lt.path)}catch(ve){const Ue=ve instanceof Error?ve.message:r("session.newWorktree.error.createWorktreeFailed");ke.error(r("session.newWorktree.error.createWorktreeFailed"),{description:Ue})}finally{Be(!1)}},Je=x=>{p(x),we(A=>({...A,touched:!1,branchError:null,worktreeError:null}))},Ke=x=>{if(!x){y(A=>({...A,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(x.type==="issue"){const A=x.item,ge=`issue-${A.number}-${Zs()}`;y(fe=>({...fe,linkedIssue:A,linkedPr:null,includePrDiff:!1,branchName:ge,worktreeName:xt(ge),isSyncingWorktreeName:!0}))}else if(x.type==="pr"){const A=x.item;y(ge=>({...ge,linkedPr:A,linkedIssue:null,includePrDiff:x.includeDiff??!1,branchName:A.head,worktreeName:xt(A.head),isSyncingWorktreeName:!0}))}},Ie=c&&f?.connected===!0,_e=(h==="existing-branch"?!!k.selectedBranch&&!!k.worktreeName&&!ne.branchError&&!ne.worktreeError:!!ks(u.branchName)&&!!u.worktreeName&&!ne.branchError&&!ne.worktreeError)&&!Te,qe=()=>{y(x=>({...x,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},it=t.jsxs("div",{className:se("flex gap-2",i?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:se("flex items-center gap-1.5 text-destructive",i?"w-full justify-center order-first":"mr-auto"),children:ne.touched&&(ne.branchError||ne.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ne.branchError||ne.worktreeError})]})}),t.jsxs("div",{className:se("flex gap-2",i&&"w-full"),children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Te,className:se(i&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:We,disabled:!_e||Te,className:se("gap-1.5",i&&"flex-1"),children:[Te&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Te?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[i?t.jsxs(Ss,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:it,children:[t.jsx("div",{className:"w-full mb-4",children:t.jsx(Cs,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:h,onSelect:x=>Je(x),variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[h==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>$(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:k.selectedBranch?"text-foreground":"text-muted-foreground",children:k.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:pe,disabled:!Z||P,title:r("session.newWorktree.fetchBranches"),children:P?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]}),t.jsx(Ss,{open:te,title:r("session.newWorktree.selectBranch"),onClose:()=>$(!1),children:t.jsxs("div",{className:"space-y-4",ref:ae,children:[t.jsx(yt,{value:B,onChange:x=>W(x.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),P?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&v.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[ie&&j&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:oe.matching.map(x=>t.jsx("button",{onClick:()=>{N(A=>({...A,selectedBranch:x.value,worktreeName:xt(x.label)})),we(A=>({...A,touched:!0})),$(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",k.selectedBranch===x.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))})]}),ie&&!j&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),oe.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ie?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:oe.otherLocal.map(x=>t.jsx("button",{onClick:()=>{N(A=>({...A,selectedBranch:x,worktreeName:xt(x)})),we(A=>({...A,touched:!0})),$(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",k.selectedBranch===x?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},x))})]}),oe.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(ie?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:oe.otherRemote.map(x=>t.jsx("button",{onClick:()=>{N(A=>({...A,selectedBranch:`remotes/${x}`,worktreeName:xt(x)})),we(A=>({...A,touched:!0})),$(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",k.selectedBranch===`remotes/${x}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},`remotes/${x}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-col items-start gap-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),h==="new-branch"&&Ie&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>L(!0),className:"gap-1.5 h-7",children:[t.jsx(R,{name:"github",className:"size-4 text-status-success"}),u.linkedIssue||u.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:u.branchName,onChange:x=>{y(A=>({...A,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>we(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!u.linkedPr,className:se("h-8",ne.touched&&ne.branchError&&"border-destructive",u.linkedPr&&"bg-muted text-muted-foreground")}),u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:u.linkedPr.head})})]}),u.linkedIssue&&!u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:u.linkedIssue.number,title:u.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),h!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const x=xt(h==="new-branch"?u.branchName:"");y(A=>({...A,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!u.branchName||u.worktreeName===xt(u.branchName),className:se("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",u.worktreeName===xt(u.branchName)||!u.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:Fe.worktreeName,onChange:x=>{h==="new-branch"?y(A=>({...A,worktreeName:x.target.value,isSyncingWorktreeName:!1})):N(A=>({...A,worktreeName:x.target.value}))},onBlur:()=>we(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:se("h-8",ne.touched&&ne.worktreeError&&"border-destructive")})]}),h==="new-branch"&&!u.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>E(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:u.sourceBranch?"text-foreground":"text-muted-foreground",children:u.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),u.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:u.sourceBranch})}),t.jsx(Ss,{open:G,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>E(!1),children:t.jsxs("div",{className:"space-y-4",ref:ee,children:[t.jsx(yt,{value:K,onChange:x=>T(x.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),P?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&v.length===0?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noBranchesFound")}):t.jsxs("div",{className:"space-y-4",children:[he&&V&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r("session.newWorktree.matchingBranches")}),t.jsx("div",{className:"space-y-1",children:q.matching.map(x=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:x.value})),E(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",u.sourceBranch===x.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))})]}),he&&!V&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),q.otherLocal.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(he?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:q.otherLocal.map(x=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:x})),E(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",u.sourceBranch===x?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},x))})]}),q.otherRemote.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"typography-small font-semibold text-foreground px-2",children:r(he?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:q.otherRemote.map(x=>t.jsx("button",{onClick:()=>{y(A=>({...A,sourceBranch:`remotes/${x}`})),E(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",u.sourceBranch===`remotes/${x}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:x})},`remotes/${x}`))})]})]})]})})]}),(u.linkedIssue||u.linkedPr)&&h==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),u.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:u.linkedIssue.number})}),u.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:u.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:u.linkedIssue?.title||u.linkedPr?.title}),t.jsx("a",{href:u.linkedIssue?.url||u.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:qe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[u.linkedPr.head," → ",u.linkedPr.base]}),u.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ds,{className:"flex items-center gap-2 shrink-0",children:[t.jsx(R,{name:"git-branch",className:"h-5 w-5"}),r("session.newWorktree.title")]}),t.jsx("div",{className:"w-[280px] shrink-0",children:t.jsx(Cs,{items:[{id:"new-branch",label:r("session.newWorktree.mode.newBranch"),icon:t.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(R,{name:"git-repository",className:"h-3.5 w-3.5"})}],activeId:h,onSelect:x=>Je(x),variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[h==="existing-branch"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.selectBranch")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs($t,{open:H,onOpenChange:U,children:[t.jsx(Wt,{asChild:!0,children:t.jsxs("button",{type:"button",className:se(_n({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:se("truncate",k.selectedBranch?"text-foreground":"text-muted-foreground"),children:k.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(_t,{align:"start",sideOffset:6,portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:z,children:t.jsxs(bn,{shouldFilter:!1,children:[t.jsx(yn,{placeholder:r("session.newWorktree.searchBranches"),value:B,onValueChange:W,onKeyDown:X}),t.jsx(wn,{disableHorizontal:!0,children:P?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&v.length===0?t.jsx(vn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ie&&j&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:oe.matching.map(x=>t.jsx(Et,{value:x.value,onSelect:()=>{N(A=>({...A,selectedBranch:x.value,worktreeName:xt(x.label)})),we(A=>({...A,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))}),ie&&!j&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),oe.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[ie&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(ie?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:oe.otherLocal.map(x=>t.jsx(Et,{value:x,onSelect:()=>{N(A=>({...A,selectedBranch:x,worktreeName:xt(x)})),we(A=>({...A,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`local-${x}`))})]}),oe.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(oe.otherLocal.length>0||ie)&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(ie?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:oe.otherRemote.map(x=>t.jsx(Et,{value:`remotes/${x}`,onSelect:()=>{N(A=>({...A,selectedBranch:`remotes/${x}`,worktreeName:xt(x)})),we(A=>({...A,touched:!0})),U(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),t.jsx(Ne,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:pe,disabled:!Z||P,title:r("session.newWorktree.fetchBranches"),children:P?t.jsx(R,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(R,{name:"refresh",className:"size-4"})})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.branchName")}),h==="new-branch"&&Ie&&t.jsxs(Ne,{variant:"outline",size:"sm",onClick:()=>L(!0),className:"gap-1.5 h-7",children:[t.jsx(R,{name:"github",className:"size-4 text-status-success"}),u.linkedIssue||u.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:u.branchName,onChange:x=>{y(A=>({...A,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>we(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!u.linkedPr,className:se("h-8",ne.touched&&ne.branchError&&"border-destructive",u.linkedPr&&"bg-muted text-muted-foreground")}),u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:u.linkedPr.head})})]}),u.linkedIssue&&!u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(R,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:u.linkedIssue.number,title:u.linkedIssue.title})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold",children:r("session.newWorktree.worktreeDirectory")}),h!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const x=xt(h==="new-branch"?u.branchName:"");y(A=>({...A,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!u.branchName||u.worktreeName===xt(u.branchName),className:se("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",u.worktreeName===xt(u.branchName)||!u.branchName?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:r("session.newWorktree.resetToMatchBranchName"),children:[t.jsx(R,{name:"refresh",className:"h-3 w-3"}),t.jsx("span",{children:r("session.newWorktree.actions.reset")})]})]}),t.jsx(yt,{value:Fe.worktreeName,onChange:x=>{h==="new-branch"?y(A=>({...A,worktreeName:x.target.value,isSyncingWorktreeName:!1})):N(A=>({...A,worktreeName:x.target.value}))},onBlur:()=>we(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:se("h-8",ne.touched&&ne.worktreeError&&"border-destructive")})]}),h==="new-branch"&&!u.linkedPr&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"typography-ui-label text-foreground block font-semibold",children:r("session.newWorktree.sourceBranch")}),t.jsxs($t,{open:Y,onOpenChange:F,children:[t.jsx(Wt,{asChild:!0,children:t.jsxs("button",{type:"button",className:se(_n({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:se("truncate",u.sourceBranch?"text-foreground":"text-muted-foreground"),children:u.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(_t,{align:"start",portalToBody:!0,className:"w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden",ref:J,children:t.jsxs(bn,{shouldFilter:!1,children:[t.jsx(yn,{placeholder:r("session.newWorktree.searchBranches"),value:K,onValueChange:T,onKeyDown:X}),t.jsx(wn,{disableHorizontal:!0,children:P?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&v.length===0?t.jsx(vn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[he&&V&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:q.matching.map(x=>t.jsx(Et,{value:x.value,onSelect:()=>{y(A=>({...A,sourceBranch:x.value})),F(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))}),he&&!V&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),q.otherLocal.length>0&&t.jsxs(t.Fragment,{children:[he&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(he?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:q.otherLocal.map(x=>t.jsx(Et,{value:x,onSelect:()=>{y(A=>({...A,sourceBranch:x})),F(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`local-${x}`))})]}),q.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(q.otherLocal.length>0||he)&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(he?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:q.otherRemote.map(x=>t.jsx(Et,{value:`remotes/${x}`,onSelect:()=>{y(A=>({...A,sourceBranch:`remotes/${x}`})),F(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),u.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:u.sourceBranch})})]}),(u.linkedIssue||u.linkedPr)&&h==="new-branch"&&t.jsxs("div",{className:"mt-2 px-2 py-1.5 rounded bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),u.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:u.linkedIssue.number})}),u.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:u.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:u.linkedIssue?.title||u.linkedPr?.title}),t.jsx("a",{href:u.linkedIssue?.url||u.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(R,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:qe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]}),u.linkedPr&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 pl-5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[u.linkedPr.head," → ",u.linkedPr.base]}),u.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]}),t.jsxs(Tn,{className:"mt-1 flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center gap-1.5 text-destructive",children:ne.touched&&(ne.branchError||ne.worktreeError)&&t.jsxs(t.Fragment,{children:[t.jsx(R,{name:"error-warning",className:"h-3.5 w-3.5"}),t.jsx("span",{className:"typography-micro",children:ne.branchError||ne.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Te,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Ne,{size:"sm",onClick:We,disabled:!_e||Te,className:"gap-1.5",children:[Te&&t.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Te?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Hc,{open:_,onOpenChange:L,onSelect:Ke})]})}const Jc=(s,e)=>{if(!s)return e("mcpDropdown.status.unknown");switch(s.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:s.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:s.error||""});default:return s.status}},Qc=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},hf=({active:s,className:e,headerAction:n,listClassName:r,hideHeader:o=!1,mobileListDensity:a=!1})=>{const{t:i}=Qe(),c=Es(w=>w.currentDirectory)??null,d=Bs(w=>w.getStatusForDirectory(c)),l=Bs(w=>w.refresh),g=Bs(w=>w.connect),h=Bs(w=>w.disconnect),p=zn(w=>w.mcpServers),u=zn(w=>w.loadMcpConfigs),[y,k]=m.useState(!1),[N,S]=m.useState(null);m.useEffect(()=>{l({directory:c,silent:!0})},[l,c]),m.useEffect(()=>{u({force:!0})},[u]),m.useEffect(()=>{s&&Promise.all([l({directory:c,silent:!0}),u({force:!0})])},[s,l,c,u]);const P=m.useMemo(()=>{const w=new Set(Object.keys(d));for(const v of p)v?.name&&w.add(v.name);return Array.from(w).sort((v,b)=>v.localeCompare(b))},[p,d]),O=m.useCallback(w=>{if(w?.preventDefault(),y)return;k(!0);const v=new Promise(b=>setTimeout(b,500));Promise.all([l({directory:c}),v]).finally(()=>{k(!1)})},[y,l,c]);return t.jsxs("div",{className:se("w-full",e),children:[o?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:i("mcpDropdown.title")}),c&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:c.split("/").pop()||c})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:y,onClick:O,"aria-label":i("mcpDropdown.actions.refreshAria"),children:t.jsx(R,{name:"refresh",className:se("h-4 w-4",y&&"animate-spin")})})]})]})}),t.jsx("div",{className:se("max-h-64 overflow-y-auto",a?"space-y-1 py-3":"px-3 py-2.5",r),children:t.jsxs("div",{className:se(!a&&P.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[P.map(w=>{const v=d[w],b=Qc(v),D=v?.status==="connected",C=N===w,_=Jc(v,i);return t.jsxs("div",{className:se("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",a?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Ht,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx("span",{className:se("rounded-full flex-shrink-0",a?"h-2.5 w-2.5":"h-2 w-2",b==="success"&&"bg-status-success",b==="error"&&"bg-status-error",b==="warning"&&"bg-status-warning",b==="default"&&"bg-muted-foreground/40"),"aria-label":_})}),t.jsx(qt,{side:"left",children:t.jsx("p",{children:_})})]}),t.jsx("span",{className:se("truncate",a?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:w})]})}),t.jsx(Da,{checked:D,disabled:C,className:"data-[checked]:bg-status-info",onCheckedChange:async L=>{S(w);try{if(!L){await h(w,c);return}const H=d?.[w]?.status;if(H==="needs_auth"||H==="needs_client_registration"){const{opened:U}=await Pa({name:w,directory:c});U||Kn.error(i("mcpDropdown.toast.authorizeOpenFailed"));return}await g(w,c)}catch(H){Kn.error(H instanceof Error?H.message:i("mcpDropdown.toast.authorizeFailed"))}finally{S(null)}}})]},w)}),P.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:i("mcpDropdown.empty.configureInConfig")})]})})]})},An=(s,e)=>s==="global"?"global":`project:${e??""}`,co=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,hr=(s,e)=>s.reduce((n,r)=>co(r,e)?n+1:n,0),uo=s=>{const e=Ge.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:f,expandLabel:c}=s,{t:d}=Qe(),l=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let g;e[0]!==l?(g=se("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",l),e[0]=l,e[1]=g):g=e[1];const h=n?void 0:r;let p;e[2]!==n||e[3]!==r?(p=n?void 0:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=p):p=e[4];const u=n?void 0:"button",y=n?void 0:0,k=n?void 0:c;let N;e[5]!==a||e[6]!==o?(N=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=N):N=e[7];let S;e[8]!==n||e[9]!==r||e[10]!==d?(S=n?t.jsx("button",{type:"button",onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":d("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:d("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(R,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=d,e[11]=S):S=e[11];let P;e[12]!==i||e[13]!==S?(P=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:Xc,onKeyDown:Zc,children:[S,i]}),e[12]=i,e[13]=S,e[14]=P):P=e[14];let O;e[15]!==P||e[16]!==N?(O=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[N,P]}),e[15]=P,e[16]=N,e[17]=O):O=e[17];let w;e[18]!==f?(w=f?t.jsx("div",{className:"min-w-0",children:f}):null,e[18]=f,e[19]=w):w=e[19];let v;return e[20]!==O||e[21]!==w||e[22]!==g||e[23]!==h||e[24]!==p||e[25]!==u||e[26]!==y||e[27]!==k?(v=t.jsxs("li",{className:g,onClick:h,onKeyDown:p,role:u,tabIndex:y,"aria-label":k,children:[O,w]}),e[20]=O,e[21]=w,e[22]=g,e[23]=h,e[24]=p,e[25]=u,e[26]=y,e[27]=k,e[28]=v):v=e[28],v};function Xc(s){return s.stopPropagation()}function Zc(s){return s.stopPropagation()}const ed=s=>{const e=Ge.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:f}=s,{t:c}=Qe(),[d,l]=m.useState(n.title),[g,h]=m.useState(n.body);let p,u;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(p=()=>{o||(l(n.title),h(n.body))},u=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=p,e[4]=u):(p=e[3],u=e[4]),m.useEffect(p,u);let y;e[5]!==g||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==d?(y=()=>{const F=d.trim(),te=g.trim();if(!F||!te){l(n.title),h(n.body);return}F===n.title&&te===n.body||i({title:F,body:te})},e[5]=g,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=d,e[10]=y):y=e[10];const k=y,N=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let S;e[11]!==c||e[12]!==N?(S=c(N),e[11]=c,e[12]=N,e[13]=S):S=e[13];const P=S;let O;e[14]!==k||e[15]!==o||e[16]!==a?(O=()=>{o&&k(),a()},e[14]=k,e[15]=o,e[16]=a,e[17]=O):O=e[17];const w=n.title;let v;e[18]!==n.flagged||e[19]!==c?(v=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(R,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),c("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=c,e[20]=v):v=e[20];let b;e[21]!==v||e[22]!==P?(b=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[P,v]}),e[21]=v,e[22]=P,e[23]=b):b=e[23];let D;e[24]!==r||e[25]!==c?(D=r?t.jsx("span",{className:se("mb-0.5 mr-1.5 inline-block rounded-full px-1.5 py-px typography-micro font-medium",r==="new"?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--status-warning)]/15 text-[var(--status-warning)]"),children:c(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=c,e[26]=D):D=e[26];let C;e[27]!==c?(C=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=c,e[28]=C):C=e[28];let _;e[29]!==c?(_=c("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=c,e[30]=_):_=e[30];let L;e[31]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=L):L=e[31];let H;e[32]!==f||e[33]!==C||e[34]!==_?(H=t.jsx("button",{type:"button",onClick:f,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":C,title:_,children:L}),e[32]=f,e[33]=C,e[34]=_,e[35]=H):H=e[35];let U;e[36]!==g||e[37]!==k||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==c||e[42]!==d?(U=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(yt,{value:d,onChange:F=>l(F.target.value.slice(0,Ea)),onBlur:k,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(Ks,{simple:!0,rows:Math.min(20,Math.max(3,g.split(`
5
+ `).length+1)),value:g,onChange:F=>h(F.target.value.slice(0,Ra)),onBlur:k,"aria-label":c("rightSidebar.contextNotesTodo.memory.actions.editBody"),className:"min-h-0 w-full resize-none bg-transparent p-0 typography-meta leading-normal text-muted-foreground focus-visible:outline-none focus-visible:ring-0"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:n.title}),t.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap break-words typography-meta text-muted-foreground",children:n.body})]}),e[36]=g,e[37]=k,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=c,e[42]=d,e[43]=U):U=e[43];let Y;return e[44]!==n.title||e[45]!==o||e[46]!==D||e[47]!==H||e[48]!==U||e[49]!==O||e[50]!==b?(Y=t.jsx(uo,{expanded:o,onToggleExpanded:O,expandLabel:w,footer:b,header:D,actions:H,children:U}),e[44]=n.title,e[45]=o,e[46]=D,e[47]=H,e[48]=U,e[49]=O,e[50]=b,e[51]=Y):Y=e[51],Y},td=s=>{const e=Ge.c(55),{projectPath:n,query:r}=s,{t:o}=Qe(),[a,i]=m.useState("project"),[f,c]=m.useState(null),d=Pt(sd),l=Pt(nd),g=Pt(rd),h=Pt(od),p=Pt(ad),u=Pt(id),y=Pe(ld),k=a==="global"?d:l,N=a==="global"?g:h;let S;e[0]!==n||e[1]!==a?(S=An(a,n),e[0]=n,e[1]=a,e[2]=S):S=e[2];const P=S;let O;e[3]!==P?(O=X=>X.agentMemoryViewedAt[P]??0,e[3]=P,e[4]=O):O=e[4];const w=Pe(O),v=m.useRef(w),[b,D]=m.useState(w);let C,_;e[5]!==y||e[6]!==P?(C=()=>(v.current=Pe.getState().agentMemoryViewedAt[P]??0,D(v.current),()=>{y(P,Date.now())}),_=[y,P],e[5]=y,e[6]=P,e[7]=C,e[8]=_):(C=e[7],_=e[8]),m.useEffect(C,_);let L;if(e[9]!==k||e[10]!==r){e:{const X=r.trim().toLowerCase();if(!X){L=k;break e}L=k.filter(Q=>Q.title.toLowerCase().includes(X)||Q.body.toLowerCase().includes(X))}e[9]=k,e[10]=r,e[11]=L}else L=e[11];const H=L;let U;e[12]!==p||e[13]!==a||e[14]!==o?(U=async X=>{if(!await p(a,X)){const Q=Pt.getState().error;ke.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),Q?{description:Q}:void 0)}},e[12]=p,e[13]=a,e[14]=o,e[15]=U):U=e[15];const Y=U;let F;e[16]!==u||e[17]!==a||e[18]!==o?(F=async(X,Q)=>{if(!await u(a,X,Q)){const re=Pt.getState().error;ke.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),re?{description:re}:void 0)}},e[16]=u,e[17]=a,e[18]=o,e[19]=F):F=e[19];const te=F;let $;e[20]!==o?($=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[20]=o,e[21]=$):$=e[21];let G;e[22]!==l.length||e[23]!==$?(G={id:"project",label:$,count:l.length},e[22]=l.length,e[23]=$,e[24]=G):G=e[24];let E;e[25]!==o?(E=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[25]=o,e[26]=E):E=e[26];let B;e[27]!==d.length||e[28]!==E?(B={id:"global",label:E,count:d.length},e[27]=d.length,e[28]=E,e[29]=B):B=e[29];let W;e[30]!==B||e[31]!==G?(W=[G,B],e[30]=B,e[31]=G,e[32]=W):W=e[32];const K=W;let T;e[33]!==o?(T=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[33]=o,e[34]=T):T=e[34];let z;e[35]!==a||e[36]!==K?(z=K.map(X=>t.jsx(Ne,{type:"button",variant:"chip",size:"xs","aria-pressed":a===X.id,className:"!font-normal",onClick:()=>i(X.id),children:`${X.label} ${X.count}`},X.id)),e[35]=a,e[36]=K,e[37]=z):z=e[37];let J;e[38]!==T||e[39]!==z?(J=t.jsx("div",{role:"group","aria-label":T,className:"flex items-center gap-1",children:z}),e[38]=T,e[39]=z,e[40]=J):J=e[40];let ae;e[41]!==b||e[42]!==f||e[43]!==Y||e[44]!==te||e[45]!==n||e[46]!==r||e[47]!==a||e[48]!==N||e[49]!==o||e[50]!==H?(ae=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):N?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):H.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r.trim()?o("rightSidebar.contextNotesTodo.memory.empty.noMatches"):o("rightSidebar.contextNotesTodo.memory.empty.nothing")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:H.map(X=>t.jsx(ed,{entry:X,badge:co(X,b),expanded:f===X.id,onToggleExpanded:()=>c(f===X.id?null:X.id),onSave:Q=>{te(X.id,Q)},onDelete:()=>{Y(X.id)}},X.id))}),e[41]=b,e[42]=f,e[43]=Y,e[44]=te,e[45]=n,e[46]=r,e[47]=a,e[48]=N,e[49]=o,e[50]=H,e[51]=ae):ae=e[51];let ee;return e[52]!==J||e[53]!==ae?(ee=t.jsxs("div",{className:"flex flex-col gap-2",children:[J,ae]}),e[52]=J,e[53]=ae,e[54]=ee):ee=e[54],ee};function sd(s){return s.global}function nd(s){return s.project}function rd(s){return s.globalFailed}function od(s){return s.projectFailed}function ad(s){return s.deleteEntry}function id(s){return s.saveEntry}function ld(s){return s.markAgentMemoryViewed}const cd=400,dd=s=>{const e=Ge.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:f,onDelete:c}=s,{t:d}=Qe(),[l,g]=m.useState(n.body),h=m.useRef(n.body),p=m.useRef(null);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},e[0]=u):u=e[0];const y=u;let k,N;e[1]!==l||e[2]!==n.body?(k=()=>{n.body!==h.current&&l===h.current&&(h.current=n.body,g(n.body))},N=[l,n.body],e[1]=l,e[2]=n.body,e[3]=k,e[4]=N):(k=e[3],N=e[4]),m.useEffect(k,N);let S,P;e[5]!==l||e[6]!==i?(S=()=>{if(l!==h.current)return p.current=window.setTimeout(()=>{p.current=null,l.trim()&&(h.current=l,i(l))},cd),y},P=[y,l,i],e[5]=l,e[6]=i,e[7]=S,e[8]=P):(S=e[7],P=e[8]),m.useEffect(S,P);let O,w;e[9]===Symbol.for("react.memo_cache_sentinel")?(O=()=>y,w=[y],e[9]=O,e[10]=w):(O=e[9],w=e[10]),m.useEffect(O,w);let v;e[11]!==l||e[12]!==i?(v=()=>{if(y(),l!==h.current){if(!l.trim()){g(h.current);return}h.current=l,i(l)}},e[11]=l,e[12]=i,e[13]=v):v=e[13];const b=v;let D;e[14]!==n.source||e[15]!==d?(D=n.source==="selection"?d("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?d("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=d,e[16]=D):D=e[16];const C=D;let _;e[17]!==d?(_=d("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=d,e[18]=_):_=e[18];let L;e[19]!==C?(L=C?t.jsx("span",{className:"typography-micro text-muted-foreground",children:C}):null,e[19]=C,e[20]=L):L=e[20];const H=r?"text-primary":"text-muted-foreground hover:text-foreground";let U;e[21]!==H?(U=se("inline-flex h-6 w-6 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",H),e[21]=H,e[22]=U):U=e[22];let Y;e[23]!==r||e[24]!==d?(Y=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=d,e[25]=Y):Y=e[25];let F;e[26]!==r||e[27]!==d?(F=d(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=d,e[28]=F):F=e[28];const te=r?"pushpin-2-fill":"pushpin";let $;e[29]!==te?($=t.jsx(R,{name:te,className:"h-3.5 w-3.5"}),e[29]=te,e[30]=$):$=e[30];let G;e[31]!==f||e[32]!==r||e[33]!==U||e[34]!==Y||e[35]!==F||e[36]!==$?(G=t.jsx("button",{type:"button",onClick:f,className:U,"aria-pressed":r,"aria-label":Y,title:F,children:$}),e[31]=f,e[32]=r,e[33]=U,e[34]=Y,e[35]=F,e[36]=$,e[37]=G):G=e[37];let E;e[38]!==d?(E=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=d,e[39]=E):E=e[39];let B;e[40]!==d?(B=d("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=d,e[41]=B):B=e[41];let W;e[42]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=W):W=e[42];let K;e[43]!==c||e[44]!==E||e[45]!==B?(K=t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":E,title:B,children:W}),e[43]=c,e[44]=E,e[45]=B,e[46]=K):K=e[46];let T;e[47]!==G||e[48]!==K?(T=t.jsxs(t.Fragment,{children:[G,K]}),e[47]=G,e[48]=K,e[49]=T):T=e[49];let z;e[50]!==l||e[51]!==o||e[52]!==b?(z=o?t.jsx(Ks,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,l.split(`
6
+ `).length+1)),value:l,onChange:ae=>g(ae.target.value.slice(0,jn)),onBlur:b,className:"min-h-0 w-full resize-none bg-transparent p-0 typography-ui-label leading-normal text-foreground focus-visible:outline-none focus-visible:ring-0"}):t.jsx("p",{className:"line-clamp-3 whitespace-pre-wrap break-words typography-ui-label leading-normal text-foreground",title:l,children:l}),e[50]=l,e[51]=o,e[52]=b,e[53]=z):z=e[53];let J;return e[54]!==o||e[55]!==a||e[56]!==_||e[57]!==L||e[58]!==T||e[59]!==z?(J=t.jsx(uo,{expanded:o,onToggleExpanded:a,expandLabel:_,footer:L,actions:T,children:z}),e[54]=o,e[55]=a,e[56]=_,e[57]=L,e[58]=T,e[59]=z,e[60]=J):J=e[60],J},ud=s=>{const e=Ge.c(67),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:f}=s,{t:c}=Qe(),[d,l]=m.useState(""),[g,h]=m.useState(null),p=Pe(fd),u=Pe(md),y=Rt(hd),k=Rt(pd),N=Rt(gd);let S;if(e[0]!==r||e[1]!==a){e:{const ee=a.trim().toLowerCase();if(!ee){S=r;break e}S=r.filter(X=>X.body.toLowerCase().includes(ee))}e[0]=r,e[1]=a,e[2]=S}else S=e[2];const P=S;let O;e[3]!==n?(O=ee=>{const X=Rt.getState().getEntry(n).error;ke.error(ee,X?{description:X}:void 0)},e[3]=n,e[4]=O):O=e[4];const w=O;let v;e[5]!==d||e[6]!==y||e[7]!==n||e[8]!==w||e[9]!==c?(v=async()=>{const ee=d.trim();if(!ee)return;if(!await y(n,{body:ee})){w(c("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}l("")},e[5]=d,e[6]=y,e[7]=n,e[8]=w,e[9]=c,e[10]=v):v=e[10];const b=v;let D;e[11]!==N||e[12]!==n||e[13]!==w||e[14]!==c?(D=async ee=>{await N(n,ee)||w(c("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[11]=N,e[12]=n,e[13]=w,e[14]=c,e[15]=D):D=e[15];const C=D;let _;e[16]!==f||e[17]!==w||e[18]!==c?(_=async(ee,X)=>{await f(ee,X)||w(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[16]=f,e[17]=w,e[18]=c,e[19]=_):_=e[19];const L=_;let H;e[20]!==n||e[21]!==w||e[22]!==k||e[23]!==c?(H=(ee,X)=>{k(n,ee,X).then(Q=>{Q||w(c("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[20]=n,e[21]=w,e[22]=k,e[23]=c,e[24]=H):H=e[24];const U=H;let Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=ee=>l(ee.target.value.slice(0,jn)),e[25]=Y):Y=e[25];let F;e[26]!==c?(F=c("rightSidebar.contextNotesTodo.notes.placeholder"),e[26]=c,e[27]=F):F=e[27];let te;e[28]!==d.length?(te=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d.length,"/",jn]}),e[28]=d.length,e[29]=te):te=e[29];let $;e[30]!==b?($=()=>{b()},e[30]=b,e[31]=$):$=e[31];let G;e[32]!==d||e[33]!==o?(G=o||d.trim().length===0,e[32]=d,e[33]=o,e[34]=G):G=e[34];let E;e[35]!==c?(E=c("rightSidebar.contextNotesTodo.notes.addAria"),e[35]=c,e[36]=E):E=e[36];let B;e[37]!==c?(B=c("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=c,e[38]=B):B=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[39]=W):W=e[39];let K;e[40]!==$||e[41]!==G||e[42]!==E||e[43]!==B?(K=t.jsx("button",{type:"button",onClick:$,disabled:G,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-primary/50 disabled:cursor-not-allowed disabled:opacity-40","aria-label":E,title:B,children:W}),e[40]=$,e[41]=G,e[42]=E,e[43]=B,e[44]=K):K=e[44];let T;e[45]!==K||e[46]!==te?(T=t.jsxs(t.Fragment,{children:[te,K]}),e[45]=K,e[46]=te,e[47]=T):T=e[47];let z;e[48]!==d||e[49]!==o||e[50]!==p||e[51]!==u||e[52]!==T||e[53]!==F?(z=t.jsx(Ks,{value:d,onChange:Y,placeholder:F,resizedHeight:p,onResizeHeightChange:u,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:T}),e[48]=d,e[49]=o,e[50]=p,e[51]=u,e[52]=T,e[53]=F,e[54]=z):z=e[54];let J;e[55]!==g||e[56]!==C||e[57]!==U||e[58]!==L||e[59]!==i||e[60]!==a||e[61]!==c||e[62]!==P?(J=t.jsx("div",{children:P.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?c("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):c("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:P.map(ee=>t.jsx(dd,{note:ee,pinned:i.has(ee.id),expanded:g===ee.id,onToggleExpanded:()=>h(X=>X===ee.id?null:ee.id),onSaveBody:X=>U(ee.id,X),onTogglePinned:()=>{L(ee.id,!i.has(ee.id))},onDelete:()=>{C(ee.id)}},ee.id))})}),e[55]=g,e[56]=C,e[57]=U,e[58]=L,e[59]=i,e[60]=a,e[61]=c,e[62]=P,e[63]=J):J=e[63];let ae;return e[64]!==z||e[65]!==J?(ae=t.jsxs("div",{className:"space-y-2",children:[z,J]}),e[64]=z,e[65]=J,e[66]=ae):ae=e[66],ae};function fd(s){return s.notesPanelHeight}function md(s){return s.setNotesPanelHeight}function hd(s){return s.createNote}function pd(s){return s.saveNoteBody}function gd(s){return s.deleteNote}const xd=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=Qe(),f=m.useRef(null),[c,d]=m.useState(!1),[l,g]=m.useState(null),h=Rt(b=>b.createPlan),p=Rt(b=>b.deletePlan),u=Es(b=>b.currentDirectory),y=Pe(b=>b.openContextPanelTab),k=m.useCallback(async b=>{if(!l){g(b);try{await p(s,b)||ke.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{g(null)}}},[l,s,p,i]),N=m.useCallback(async(b,D)=>{if(!b.trim()){ke.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const C=Aa(b,D||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await h(s,{title:C.title,body:C.body})){ke.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}ke.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[h,s,i]),S=m.useCallback(async()=>{if(c)return;const b=await xi({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(b.success&&b.path){d(!0);try{const D=new URLSearchParams({path:b.path,allowOutsideWorkspace:"true"});b.outsideFileGrant&&D.set("outsideFileGrant",b.outsideFileGrant);const C=await Bt(`/api/fs/read?${D.toString()}`,{cache:"no-store"});if(!C.ok){ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const _=await C.text(),L=b.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await N(_,L)}catch(D){const C=D instanceof Error?D.message:void 0;ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),C?{description:C}:void 0)}finally{d(!1)}return}b.error==="Native file picker not available"&&f.current?.click()},[N,c,s.path,i]),P=m.useCallback(async b=>{if(b){d(!0);try{const D=await b.text(),C=b.name.replace(/\.(md|markdown|txt)$/i,"").trim();await N(D,C)}catch(D){const C=D instanceof Error?D.message:void 0;ke.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),C?{description:C}:void 0)}finally{d(!1)}}},[N,i]),O=m.useCallback(async(b,D)=>{if(!await a(b,D)){const _=Rt.getState().getEntry(s).error;ke.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),_?{description:_}:void 0)}},[a,s,i]),w=m.useMemo(()=>{const b=n.trim().toLowerCase();return b?e.filter(D=>D.title.toLowerCase().includes(b)):e},[e,n]),v=m.useCallback(b=>{if(r){r({id:b.id,title:b.title});return}const D=u?.trim()||s.path.trim();D&&y(D,{mode:"plan",projectPlanId:b.id,dedupeKey:`plan:${b.id}`,label:b.title})},[u,r,y,s.path]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx("input",{ref:f,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:b=>{const D=b.target.files?.[0]??null;P(D),b.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:S,disabled:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":i("rightSidebar.contextNotesTodo.plans.importFromFile"),title:i("rightSidebar.contextNotesTodo.plans.importFromFile"),children:t.jsx(R,{name:"add",className:"h-3.5 w-3.5"})})]}),t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:w.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?i("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):i("rightSidebar.contextNotesTodo.plans.empty")}):t.jsx("ul",{className:"divide-y divide-border/50",children:w.map(b=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>v(b),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:b.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(b.createdAt).toLocaleDateString(vr())})]}),t.jsx("button",{type:"button",onClick:()=>{O(b.id,!o.has(b.id))},className:se("inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",o.has(b.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(b.id),"aria-label":o.has(b.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(b.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),children:t.jsx(R,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{k(b.id)},disabled:l===b.id,className:"inline-flex h-6 w-6 flex-shrink-0 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-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:i("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":i("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:b.title}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},b.id))})})]})},bd=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,yd=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],pr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},wd=s=>{const e=Ge.c(20),{id:n,children:r}=s;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:f,setActivatorNodeRef:c,transform:d,transition:l,isDragging:g}=Kr(o);let h;e[2]!==d?(h=Yr.Transform.toString(d),e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h||e[5]!==l?(p={transform:h,transition:l},e[4]=h,e[5]=l,e[6]=p):p=e[6];const u=g&&"opacity-60";let y;e[7]!==u?(y=se(u),e[7]=u,e[8]=y):y=e[8];let k;e[9]!==a||e[10]!==r||e[11]!==g||e[12]!==i||e[13]!==c?(k=r({attributes:a,listeners:i,setActivatorNodeRef:c,isDragging:g}),e[9]=a,e[10]=r,e[11]=g,e[12]=i,e[13]=c,e[14]=k):k=e[14];let N;return e[15]!==f||e[16]!==p||e[17]!==y||e[18]!==k?(N=t.jsx("li",{ref:f,style:p,className:y,children:k}),e[15]=f,e[16]=p,e[17]=y,e[18]=k,e[19]=N):N=e[19],N},vd=s=>{const e=Ge.c(80),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:f,onSendToCurrentSession:c,onSendToNewSession:d,onSendToNewWorktreeSession:l}=s,{t:g}=Qe(),[h,p]=m.useState(""),[u,y]=m.useState(jd);let k;e[0]!==h||e[1]!==f||e[2]!==n?(k=()=>{const j=h.trim();j&&(f(pr(n,{id:bd(),text:j.slice(0,Ms),completed:!1,createdAt:Date.now()})),p(""))},e[0]=h,e[1]=f,e[2]=n,e[3]=k):k=e[3];const N=k;let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=j=>{y(V=>{const Z=new Set(V);return Z.has(j)?Z.delete(j):Z.add(j),Z})},e[4]=S):S=e[4];const P=S;let O;e[5]!==f||e[6]!==n?(O=(j,V)=>{const Z=n.find(we=>we.id===j);if(!Z||Z.completed===V)return;const pe=n.filter(we=>we.id!==j),ne={...Z,completed:V};f(V?[...pe,ne]:pr(pe,ne))},e[5]=f,e[6]=n,e[7]=O):O=e[7];const w=O;let v;e[8]!==f||e[9]!==n?(v=j=>{f(n.filter(V=>V.id!==j))},e[8]=f,e[9]=n,e[10]=v):v=e[10];const b=v;let D;e[11]!==f||e[12]!==n?(D=()=>{const j=n.filter(kd);j.length!==n.length&&f(j)},e[11]=f,e[12]=n,e[13]=D):D=e[13];const C=D;let _;e[14]!==f||e[15]!==n?(_=j=>{const{active:V,over:Z}=j;if(!Z||V.id===Z.id)return;const pe=n.findIndex(we=>we.id===V.id),ne=n.findIndex(we=>we.id===Z.id);pe===-1||ne===-1||f(yd(Li(n,pe,ne)))},e[14]=f,e[15]=n,e[16]=_):_=e[16];const L=_;let H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H={activationConstraint:{distance:8}},e[17]=H):H=e[17];const U=_r(zr(Vr,H));let Y;e[18]!==h?(Y=h.slice(0,Ms),e[18]=h,e[19]=Y):Y=e[19];const F=Y;let te;e[20]!==n?(te=n.reduce(Sd,0),e[20]=n,e[21]=te):te=e[21];const $=te;let G;if(e[22]!==r||e[23]!==n){e:{const j=r.trim().toLowerCase();if(!j){G=n;break e}G=n.filter(V=>V.text.toLowerCase().includes(j))}e[22]=r,e[23]=n,e[24]=G}else G=e[24];const E=G,B=o||$===0;let W;e[25]!==g?(W=g("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[25]=g,e[26]=W):W=e[26];let K;e[27]!==C||e[28]!==B||e[29]!==W?(K=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:C,disabled:B,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:W})}),e[27]=C,e[28]=B,e[29]=W,e[30]=K):K=e[30];let T;e[31]!==F.length?(T=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[F.length,"/",Ms]}),e[31]=F.length,e[32]=T):T=e[32];let z;e[33]!==K||e[34]!==T?(z=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[K,T]}),e[33]=K,e[34]=T,e[35]=z):z=e[35];let J;e[36]===Symbol.for("react.memo_cache_sentinel")?(J=j=>p(j.target.value.slice(0,Ms)),e[36]=J):J=e[36];let ae;e[37]!==N?(ae=j=>{j.key==="Enter"&&(j.preventDefault(),N())},e[37]=N,e[38]=ae):ae=e[38];let ee;e[39]!==g?(ee=g("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[39]=g,e[40]=ee):ee=e[40];let X;e[41]!==o||e[42]!==ae||e[43]!==ee||e[44]!==F?(X=t.jsx(yt,{value:F,onChange:J,onKeyDown:ae,placeholder:ee,disabled:o,className:"h-8"}),e[41]=o,e[42]=ae,e[43]=ee,e[44]=F,e[45]=X):X=e[45];let Q;e[46]!==o||e[47]!==F?(Q=o||F.trim().length===0,e[46]=o,e[47]=F,e[48]=Q):Q=e[48];let re;e[49]!==g?(re=g("rightSidebar.contextNotesTodo.todo.addAria"),e[49]=g,e[50]=re):re=e[50];let ce;e[51]!==g?(ce=g("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=g,e[52]=ce):ce=e[52];let me;e[53]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx(R,{name:"add",className:"h-4 w-4"}),e[53]=me):me=e[53];let oe;e[54]!==N||e[55]!==Q||e[56]!==re||e[57]!==ce?(oe=t.jsx("button",{type:"button",onClick:N,disabled:Q,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":re,title:ce,children:me}),e[54]=N,e[55]=Q,e[56]=re,e[57]=ce,e[58]=oe):oe=e[58];let q;e[59]!==X||e[60]!==oe?(q=t.jsxs("div",{className:"flex items-center gap-1.5",children:[X,oe]}),e[59]=X,e[60]=oe,e[61]=q):q=e[61];let ie;e[62]!==a||e[63]!==u||e[64]!==b||e[65]!==L||e[66]!==w||e[67]!==c||e[68]!==d||e[69]!==l||e[70]!==r||e[71]!==i||e[72]!==g||e[73]!==U||e[74]!==E?(ie=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:E.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?g("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):g("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(Gr,{sensors:U,collisionDetection:Hr,onDragEnd:L,children:t.jsx(qr,{items:E.map(Nd),strategy:Mi,children:t.jsx("ul",{className:"divide-y divide-border/50",children:E.map(j=>{const V=u.has(j.id);return t.jsx(wd,{id:j.id,children:Z=>t.jsxs("div",{className:se("flex gap-1.5 px-2.5 py-1.5",V?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:Z.setActivatorNodeRef,...Z.attributes,...Z.listeners,onClick:Cd,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":g("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:j.text}),title:g("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:j.text}),children:t.jsx(R,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Ps,{checked:j.completed,onChange:pe=>w(j.id,pe),ariaLabel:g("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:j.text})})}),t.jsx("button",{type:"button",onClick:()=>P(j.id),className:se("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",V?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",j.completed&&"text-muted-foreground line-through"),title:V?void 0:j.text,"aria-label":V?g("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:j.text}):g("rightSidebar.contextNotesTodo.todo.actions.expand",{text:j.text}),children:j.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>b(j.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-primary/50","aria-label":g("rightSidebar.contextNotesTodo.todo.actions.delete",{text:j.text}),title:g("rightSidebar.contextNotesTodo.todo.actions.delete",{text:j.text}),children:t.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs($t,{children:[t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===j.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-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":g("rightSidebar.contextNotesTodo.todo.actions.send",{text:j.text}),title:g("rightSidebar.contextNotesTodo.todo.actions.send",{text:j.text}),children:t.jsx(R,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(_t,{align:"end",className:"w-56",children:[t.jsx(At,{onClick:()=>c(j.text),children:g("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(At,{onClick:()=>d(j.id,j.text),children:g("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(At,{onClick:()=>l(j.id,j.text),disabled:!a,children:g("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},j.id)})})})})}),e[62]=a,e[63]=u,e[64]=b,e[65]=L,e[66]=w,e[67]=c,e[68]=d,e[69]=l,e[70]=r,e[71]=i,e[72]=g,e[73]=U,e[74]=E,e[75]=ie):ie=e[75];let he;return e[76]!==z||e[77]!==q||e[78]!==ie?(he=t.jsxs("div",{className:"space-y-2",children:[z,q,ie]}),e[76]=z,e[77]=q,e[78]=ie,e[79]=he):he=e[79],he};function jd(){return new Set}function kd(s){return!s.completed}function Sd(s,e){return s+(e.completed?1:0)}function Nd(s){return s.id}function Cd(s){s.preventDefault(),s.stopPropagation()}const Id=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=Qe(),[a,i]=m.useState(null),[f,c]=m.useState(!1),[d,l]=m.useState(null),g=rt(C=>C.currentSessionId),h=rt(C=>C.createSession),p=rt(C=>C.initializeNewOpenChamberSession),u=rt(C=>C.sendMessage),y=rt(C=>C.setCurrentSession),k=Ba(C=>C.setPendingInputText),N=Pe(C=>C.setActiveMainTab),S=Pe(C=>C.setSessionSwitcherOpen),P=m.useCallback(()=>{N("chat"),S(!1)},[N,S]),O=m.useCallback(C=>{if(!g){ke.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}P();const _=`\`\`\`md
7
+ ${C}
8
+ \`\`\``;k(_,"append"),ke.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[g,r,P,k,o]),w=m.useCallback((C,_)=>{!e||d||i({kind:"session",todoId:C,todoText:_})},[e,d]),v=m.useCallback((C,_)=>{if(!(!e||d)){if(!n){ke.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:C,todoText:_})}},[n,e,d,o]),b=m.useCallback(async C=>{if(!e||!a)return;const _=await gs("plan.todo.visible",{todo_text:a.todoText}),H=[{synthetic:!0,text:await gs("plan.todo.instructions",{todo_text:a.todoText})}];c(!0),l(a.todoId);try{P();let U=null,Y=e.path;if(a.kind==="worktree"){if(!n){ke.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const te=await Ma(e.path,La());if(!te?.id)return;U=te.id,Y=te.path}else{const te=await h(void 0,e.path,null);if(!te?.id){ke.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}U=te.id,Y=te.directory??e.path,p(te.id,kt.getState().agents??[])}if(!U)return;const F=Ar.getState();F.saveSessionModelSelection(U,C.providerID,C.modelID),C.agent.trim()&&(F.saveSessionAgentSelection(U,C.agent),F.saveAgentModelForSession(U,C.agent,C.providerID,C.modelID),F.saveAgentModelVariantForSession(U,C.agent,C.providerID,C.modelID,C.variant||void 0)),y(U,Y),await u(_,C.providerID,C.modelID,C.agent.trim()||void 0,void 0,void 0,H,C.variant||void 0),ke.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(U){const Y=U instanceof Error?U.message:void 0;ke.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),Y?{description:Y}:void 0)}finally{c(!1),l(null)}},[n,h,p,r,a,e,P,u,y,o]),D=m.useCallback(()=>{f||i(null)},[f]);return{pendingSendTarget:a,isSubmitting:f,sendingTodoId:d,sendToCurrentSession:O,sendToNewSession:w,sendToNewWorktreeSession:v,confirmSend:b,closeDialog:D}},Td=m.lazy(()=>Gt(()=>import("./PlanView-Czu1KMJa.js"),__vite__mapDeps([114,2,3,4,5,6,7,8,9,115,57,58,59,60,61,62,79,55,56,63,116,117,118,1,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,119,120,112,113,99,100,84,85,86,87,88,89,90,91,92,93,94,95,96,97])).then(s=>({default:s.PlanView}))),gr=["notes","todos","plans","memory"],Dd=120,Pd=320,an=s=>Math.min(Pd,Math.max(Dd,Math.round(s))),Ed=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],vs=(s,e)=>s.toLowerCase().includes(e),Rd=s=>{const e=Ge.c(244),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:f}=s,c=o===void 0?!1:o,{t:d}=Qe();let l;e[0]!==n?(l=Fa(n),e[0]=n,e[1]=l):l=e[1];const g=l;let h;e[2]!==g?(h=Se=>(g?Se.entries[g]:void 0)??Oa,e[2]=g,e[3]=h):h=e[3];const p=Rt(h),u=Rt(Ad),y=Rt(Bd),k=rt(Md),N=rt(Ld),S=rt(Fd),P=rt(Od);let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O={notes:[],plans:[]},e[4]=O):O=e[4];const[w,v]=m.useState(O);let b,D;e[5]!==N||e[6]!==k||e[7]!==S.open||e[8]!==S.projectContextPins?(b=()=>{if(S.open){v(S.projectContextPins??{notes:[],plans:[]});return}let Se=!1;return Ua(N,k).then(et=>{Se||v({notes:et.notes.map(Ud),plans:et.plans.map($d)})}),()=>{Se=!0}},D=[N,k,S.open,S.projectContextPins],e[5]=N,e[6]=k,e[7]=S.open,e[8]=S.projectContextPins,e[9]=b,e[10]=D):(b=e[9],D=e[10]),m.useEffect(b,D);let C;e[11]!==N||e[12]!==k||e[13]!==S.open||e[14]!==P?(C=async(Se,et,wt)=>{if(S.open)return P(Se,et,wt),!0;if(!k||!N)return!1;const Mt=await $a(N,k,Se,et,wt);return Mt?(v(Mt),!0):!1},e[11]=N,e[12]=k,e[13]=S.open,e[14]=P,e[15]=C):C=e[15];const _=C;let L;e[16]!==w.notes?(L=new Set(w.notes),e[16]=w.notes,e[17]=L):L=e[17];const H=L;let U;e[18]!==w.plans?(U=new Set(w.plans),e[18]=w.plans,e[19]=U):U=e[19];const Y=U,F=Pe(Wd),te=Pt(_d),$=F&&!te,G=Pt(zd),E=Pt(Vd),B=Pe(Gd),W=Pe(Hd);let K;e[20]!==B?(K=gr.includes(B)?B:"notes",e[20]=B,e[21]=K):K=e[21];const T=K,z=T==="memory"&&!$?"notes":T,[J,ae]=m.useState(""),[ee,X]=m.useState(null);let Q;e[22]!==J?(Q=J.trim().toLowerCase(),e[22]=J,e[23]=Q):Q=e[23];const re=Q;let ce;e[24]!==p.todos?(ce=Ed(p.todos),e[24]=p.todos,e[25]=ce):ce=e[25];const me=ce,oe=p.loading&&!p.loaded;let q;e[26]!==G||e[27]!==E?(q=[...G,...E],e[26]=G,e[27]=E,e[28]=q):q=e[28];const ie=q;let he;e:{if(!re){let ft;e[29]!==p.notes.length||e[30]!==p.plans.length||e[31]!==ie.length||e[32]!==me.length?(ft={notes:p.notes.length,todos:me.length,plans:p.plans.length,memory:ie.length},e[29]=p.notes.length,e[30]=p.plans.length,e[31]=ie.length,e[32]=me.length,e[33]=ft):ft=e[33],he=ft;break e}let Se;if(e[34]!==p.notes||e[35]!==re){let ft;e[37]!==re?(ft=ys=>vs(ys.body,re),e[37]=re,e[38]=ft):ft=e[38],Se=p.notes.filter(ft),e[34]=p.notes,e[35]=re,e[36]=Se}else Se=e[36];const et=Se.length;let wt;if(e[39]!==me||e[40]!==re){let ft;e[42]!==re?(ft=ys=>vs(ys.text,re),e[42]=re,e[43]=ft):ft=e[43],wt=me.filter(ft),e[39]=me,e[40]=re,e[41]=wt}else wt=e[41];const Mt=wt.length;let us;if(e[44]!==p.plans||e[45]!==re){let ft;e[47]!==re?(ft=ys=>vs(ys.title,re),e[47]=re,e[48]=ft):ft=e[48],us=p.plans.filter(ft),e[44]=p.plans,e[45]=re,e[46]=us}else us=e[46];const xo=us.length;let fs;e[49]!==ie||e[50]!==re?(fs=ie.filter(ft=>vs(ft.title,re)||vs(ft.body,re)),e[49]=ie,e[50]=re,e[51]=fs):fs=e[51];let As;e[52]!==Se.length||e[53]!==wt.length||e[54]!==us.length||e[55]!==fs.length?(As={notes:et,todos:Mt,plans:xo,memory:fs.length},e[52]=Se.length,e[53]=wt.length,e[54]=us.length,e[55]=fs.length,e[56]=As):As=e[56],he=As}const j=he,V=Pe(Kd);let Z;e[57]!==n?.path?(Z=Se=>Se.agentMemoryViewedAt[An("project",n?.path??null)]??0,e[57]=n?.path,e[58]=Z):Z=e[58];const pe=Pe(Z),ne=hr(G,V)+hr(E,pe),we=Pe(qd),Te=Pe(Yd),[Be,Me]=m.useState(!1),[tt,Le]=m.useState(null),Xe=tt??we;let Ae;e[59]!==Xe?(Ae=an(Xe),e[59]=Xe,e[60]=Ae):Ae=e[60];const Ze=Ae;let Fe;e[61]!==Ze?(Fe=Se=>{Se.currentTarget.setPointerCapture(Se.pointerId),Me(!0),Le(Ze)},e[61]=Ze,e[62]=Fe):Fe=e[62];const Ye=Fe;let ot;e[63]===Symbol.for("react.memo_cache_sentinel")?(ot=Se=>{if(!Se.currentTarget.hasPointerCapture(Se.pointerId))return;const et=Se.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Le(an(et-Se.clientX))},e[63]=ot):ot=e[63];const We=ot;let Je;e[64]!==Te?(Je=Se=>{Se.currentTarget.hasPointerCapture(Se.pointerId)&&Se.currentTarget.releasePointerCapture(Se.pointerId),Me(!1),Le(et=>(et!==null&&Te(an(et)),null))},e[64]=Te,e[65]=Je):Je=e[65];const Ke=Je;let Ie;e[66]!==c||e[67]!==a||e[68]!==n?(Ie={projectRef:n,canCreateWorktree:c,onActionComplete:a},e[66]=c,e[67]=a,e[68]=n,e[69]=Ie):Ie=e[69];const De=Id(Ie);let _e,qe;e[70]!==u||e[71]!==n?(_e=()=>{n&&u(n)},qe=[u,n],e[70]=u,e[71]=n,e[72]=_e,e[73]=qe):(_e=e[72],qe=e[73]),m.useEffect(_e,qe);const it=m.useRef(null);let x,A;e[74]!==p.error||e[75]!==p.loaded||e[76]!==d?(x=()=>{if(!p.error){it.current=null;return}it.current!==p.error&&(it.current=p.error,p.loaded||ke.error(d("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},A=[p.error,p.loaded,d],e[74]=p.error,e[75]=p.loaded,e[76]=d,e[77]=x,e[78]=A):(x=e[77],A=e[78]),m.useEffect(x,A);let ge;e[79]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>{X(null)},e[79]=ge):ge=e[79];let fe;e[80]!==g?(fe=[g],e[80]=g,e[81]=fe):fe=e[81],m.useEffect(ge,fe);let ve,Ue;e[82]!==z?(ve=()=>{z!=="plans"&&X(null)},Ue=[z],e[82]=z,e[83]=ve,e[84]=Ue):(ve=e[83],Ue=e[84]),m.useEffect(ve,Ue);let Ve;e[85]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>{ae("")},e[85]=Ve):Ve=e[85];let $e;e[86]!==g?($e=[g],e[86]=g,e[87]=$e):$e=e[87],m.useEffect(Ve,$e);let Ee,I;e[88]!==z||e[89]!==j||e[90]!==W||e[91]!==re?(Ee=()=>{if(!re||j[z]>0)return;const Se=gr.find(et=>j[et]>0);Se&&W(Se)},I=[z,j,W,re],e[88]=z,e[89]=j,e[90]=W,e[91]=re,e[92]=Ee,e[93]=I):(Ee=e[92],I=e[93]),m.useEffect(Ee,I);let ye;e[94]!==n||e[95]!==y||e[96]!==d?(ye=Se=>{n&&y(n,Se).then(et=>{et||ke.error(d("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[94]=n,e[95]=y,e[96]=d,e[97]=ye):ye=e[97];const Ce=ye;let Re;e[98]!==d?(Re=d("rightSidebar.contextNotesTodo.tabs.notes"),e[98]=d,e[99]=Re):Re=e[99];const at=String(j.notes);let lt;e[100]!==Re||e[101]!==at?(lt={id:"notes",icon:"sticky-note",label:Re,count:at},e[100]=Re,e[101]=at,e[102]=lt):lt=e[102];let st;e[103]!==d?(st=d("rightSidebar.contextNotesTodo.tabs.todos"),e[103]=d,e[104]=st):st=e[104];const mt=String(j.todos);let ze;e[105]!==st||e[106]!==mt?(ze={id:"todos",icon:"checkbox-circle",label:st,count:mt},e[105]=st,e[106]=mt,e[107]=ze):ze=e[107];let ut;e[108]!==d?(ut=d("rightSidebar.contextNotesTodo.tabs.plans"),e[108]=d,e[109]=ut):ut=e[109];const M=String(j.plans);let de;e[110]!==ut||e[111]!==M?(de={id:"plans",icon:"file-text",label:ut,count:M},e[110]=ut,e[111]=M,e[112]=de):de=e[112];let be;e[113]!==j.memory||e[114]!==ne||e[115]!==$||e[116]!==d?(be=$?[{id:"memory",icon:"brain-4",label:d("rightSidebar.contextNotesTodo.tabs.memory"),count:ne>0?`${ne}/${j.memory}`:String(j.memory)}]:[],e[113]=j.memory,e[114]=ne,e[115]=$,e[116]=d,e[117]=be):be=e[117];let He;e[118]!==lt||e[119]!==ze||e[120]!==de||e[121]!==be?(He=[lt,ze,de,...be],e[118]=lt,e[119]=ze,e[120]=de,e[121]=be,e[122]=He):He=e[122];const je=He;if(!n){let Se;e[123]!==f?(Se=se("w-full min-w-0 p-3",f),e[123]=f,e[124]=Se):Se=e[124];let et;e[125]!==d?(et=d("rightSidebar.contextNotesTodo.empty.selectProject"),e[125]=d,e[126]=et):et=e[126];let wt;e[127]!==et?(wt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:et}),e[127]=et,e[128]=wt):wt=e[128];let Mt;return e[129]!==Se||e[130]!==wt?(Mt=t.jsx("div",{className:Se,children:wt}),e[129]=Se,e[130]=wt,e[131]=Mt):Mt=e[131],Mt}let xe;e[132]!==r||e[133]!==n.path?(xe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[132]=r,e[133]=n.path,e[134]=xe):xe=e[134];const ue=xe;let Oe;e[135]!==f?(Oe=se("flex h-full min-h-0 w-full min-w-0 flex-col",f),e[135]=f,e[136]=Oe):Oe=e[136];let ct;e[137]!==ee||e[138]!==d?(ct=ee?t.jsx("button",{type:"button",onClick:()=>X(null),className:"inline-flex h-6 w-6 flex-shrink-0 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-primary/50","aria-label":d("rightSidebar.contextNotesTodo.plans.actions.back"),title:d("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[137]=ee,e[138]=d,e[139]=ct):ct=e[139];let dt;e[140]!==n.path||e[141]!==ue?(dt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:ue}),e[140]=n.path,e[141]=ue,e[142]=dt):dt=e[142];let vt;e[143]===Symbol.for("react.memo_cache_sentinel")?(vt=t.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e[143]=vt):vt=e[143];let Nt;e[144]===Symbol.for("react.memo_cache_sentinel")?(Nt=Se=>ae(Se.target.value),e[144]=Nt):Nt=e[144];let pt;e[145]!==d?(pt=d("rightSidebar.contextNotesTodo.search.placeholder"),e[145]=d,e[146]=pt):pt=e[146];let gt;e[147]!==J||e[148]!==pt?(gt=t.jsx(yt,{value:J,onChange:Nt,placeholder:pt,className:"h-8 pl-7 pr-7"}),e[147]=J,e[148]=pt,e[149]=gt):gt=e[149];let jt;e[150]!==J||e[151]!==d?(jt=J?t.jsx("button",{type:"button",onClick:()=>ae(""),className:"absolute right-1.5 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 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-primary/50","aria-label":d("rightSidebar.contextNotesTodo.search.clear"),title:d("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null,e[150]=J,e[151]=d,e[152]=jt):jt=e[152];let St;e[153]!==gt||e[154]!==jt?(St=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[vt,gt,jt]}),e[153]=gt,e[154]=jt,e[155]=St):St=e[155];let Tt;e[156]!==ct||e[157]!==dt||e[158]!==St?(Tt=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[ct,dt,St]}),e[156]=ct,e[157]=dt,e[158]=St,e[159]=Tt):Tt=e[159];const ht=ee?"overflow-hidden":"overflow-y-auto";let Ut;e[160]!==ht?(Ut=se("min-h-0 min-w-0 flex-1 p-3",ht),e[160]=ht,e[161]=Ut):Ut=e[161];let Yt;e[162]!==z||e[163]!==p.notes||e[164]!==oe||e[165]!==H||e[166]!==n||e[167]!==J||e[168]!==_?(Yt=z==="notes"?t.jsx(ud,{projectRef:n,notes:p.notes,disabled:oe,query:J,pinnedNoteIds:H,onTogglePinned:(Se,et)=>_("note",Se,et)}):null,e[162]=z,e[163]=p.notes,e[164]=oe,e[165]=H,e[166]=n,e[167]=J,e[168]=_,e[169]=Yt):Yt=e[169];let Jt;e[170]!==z||e[171]!==c||e[172]!==Ce||e[173]!==oe||e[174]!==J||e[175]!==De.sendToCurrentSession||e[176]!==De.sendToNewSession||e[177]!==De.sendToNewWorktreeSession||e[178]!==De.sendingTodoId||e[179]!==me?(Jt=z==="todos"?t.jsx(vd,{todos:me,query:J,disabled:oe,canCreateWorktree:c,sendingTodoId:De.sendingTodoId,onPersistTodos:Ce,onSendToCurrentSession:De.sendToCurrentSession,onSendToNewSession:De.sendToNewSession,onSendToNewWorktreeSession:De.sendToNewWorktreeSession}):null,e[170]=z,e[171]=c,e[172]=Ce,e[173]=oe,e[174]=J,e[175]=De.sendToCurrentSession,e[176]=De.sendToNewSession,e[177]=De.sendToNewWorktreeSession,e[178]=De.sendingTodoId,e[179]=me,e[180]=Jt):Jt=e[180];let Qt;e[181]!==z||e[182]!==$||e[183]!==n.path||e[184]!==J?(Qt=z==="memory"&&$?t.jsx(td,{projectPath:n.path,query:J}):null,e[181]=z,e[182]=$,e[183]=n.path,e[184]=J,e[185]=Qt):Qt=e[185];let Xt;e[186]!==z||e[187]!==p.plans||e[188]!==i||e[189]!==ee||e[190]!==Y||e[191]!==n||e[192]!==J||e[193]!==_?(Xt=z==="plans"&&!ee?t.jsx(xd,{projectRef:n,plans:p.plans,query:J,pinnedPlanIds:Y,onTogglePinned:(Se,et)=>_("plan",Se,et),onOpenPlan:i??X}):null,e[186]=z,e[187]=p.plans,e[188]=i,e[189]=ee,e[190]=Y,e[191]=n,e[192]=J,e[193]=_,e[194]=Xt):Xt=e[194];let Zt;e[195]!==z||e[196]!==ee?(Zt=z==="plans"&&ee?t.jsx(m.Suspense,{fallback:null,children:t.jsx(Td,{projectPlanId:ee.id,onNavigatedToChat:()=>X(null)})}):null,e[195]=z,e[196]=ee,e[197]=Zt):Zt=e[197];let es;e[198]!==Ut||e[199]!==Yt||e[200]!==Jt||e[201]!==Qt||e[202]!==Xt||e[203]!==Zt?(es=t.jsxs("div",{className:Ut,children:[Yt,Jt,Qt,Xt,Zt]}),e[198]=Ut,e[199]=Yt,e[200]=Jt,e[201]=Qt,e[202]=Xt,e[203]=Zt,e[204]=es):es=e[204];const Ys=`${Ze}px`;let ts;e[205]!==Ys?(ts={width:Ys},e[205]=Ys,e[206]=ts):ts=e[206];let ss;e[207]!==d?(ss=d("rightSidebar.contextNotesTodo.sections.label"),e[207]=d,e[208]=ss):ss=e[208];const Js=Be&&"bg-[var(--interactive-border)]";let ns;e[209]!==Js?(ns=se("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Js),e[209]=Js,e[210]=ns):ns=e[210];let rs;e[211]!==d?(rs=d("rightSidebar.contextNotesTodo.sections.resize"),e[211]=d,e[212]=rs):rs=e[212];let os;e[213]!==Ke||e[214]!==Ye||e[215]!==ns||e[216]!==rs?(os=t.jsx("div",{className:ns,onPointerDown:Ye,onPointerMove:We,onPointerUp:Ke,onPointerCancel:Ke,role:"separator","aria-orientation":"vertical","aria-label":rs}),e[213]=Ke,e[214]=Ye,e[215]=ns,e[216]=rs,e[217]=os):os=e[217];let as;e[218]!==z||e[219]!==je||e[220]!==W?(as=je.map(Se=>{const et=z===Se.id;return t.jsxs("button",{type:"button",onClick:()=>W(Se.id),"aria-current":et?"page":void 0,className:se("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",et?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(R,{name:Se.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:Se.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:Se.count})]},Se.id)}),e[218]=z,e[219]=je,e[220]=W,e[221]=as):as=e[221];let is;e[222]!==ts||e[223]!==ss||e[224]!==os||e[225]!==as?(is=t.jsxs("nav",{className:"relative flex flex-shrink-0 flex-col gap-0.5 overflow-y-auto border-l border-[var(--interactive-border)] p-2",style:ts,"aria-label":ss,children:[os,as]}),e[222]=ts,e[223]=ss,e[224]=os,e[225]=as,e[226]=is):is=e[226];let ls;e[227]!==es||e[228]!==is?(ls=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[es,is]}),e[227]=es,e[228]=is,e[229]=ls):ls=e[229];const Qs=De.pendingSendTarget!==null;let cs;e[230]!==De?(cs=Se=>{Se||De.closeDialog()},e[230]=De,e[231]=cs):cs=e[231];const Xs=De.pendingSendTarget?.kind??"session";let ds;e[232]!==n.path||e[233]!==De.confirmSend||e[234]!==De.isSubmitting||e[235]!==Qs||e[236]!==cs||e[237]!==Xs?(ds=t.jsx(xl,{open:Qs,onOpenChange:cs,target:Xs,projectDirectory:n.path,submitting:De.isSubmitting,onConfirm:De.confirmSend}),e[232]=n.path,e[233]=De.confirmSend,e[234]=De.isSubmitting,e[235]=Qs,e[236]=cs,e[237]=Xs,e[238]=ds):ds=e[238];let Rs;return e[239]!==Oe||e[240]!==Tt||e[241]!==ls||e[242]!==ds?(Rs=t.jsxs("div",{className:Oe,children:[Tt,ls,ds]}),e[239]=Oe,e[240]=Tt,e[241]=ls,e[242]=ds,e[243]=Rs):Rs=e[243],Rs};function Ad(s){return s.load}function Bd(s){return s.saveTodos}function Md(s){return s.currentSessionId}function Ld(s){return s.currentSessionDirectory}function Fd(s){return s.newSessionDraft}function Od(s){return s.setDraftProjectContextPin}function Ud(s){return s.id}function $d(s){return s.id}function Wd(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function _d(s){return s.disabled}function zd(s){return s.global}function Vd(s){return s.project}function Gd(s){return s.projectContextTab}function Hd(s){return s.setProjectContextTab}function Kd(s){return s.agentMemoryViewedAt[An("global",null)]??0}function qd(s){return s.projectContextSidebarWidth}function Yd(s){return s.setProjectContextSidebarWidth}const pf=s=>{const e=Ge.c(26),{onActionComplete:n,onOpenPlan:r}=s,o=Ct(Jd),a=Ct(Qd),i=Es(Xd),{t:f}=Qe(),c=Pn(Zd),d=rt(eu),l=rt(tu);let g;e[0]!==l||e[1]!==i?(g=Wa(l)??_a(i),e[0]=l,e[1]=i,e[2]=g):g=e[2];const h=g;let p;e:{if(d){p=null;break e}if(o){let v;e[3]!==o||e[4]!==a?(v=a.find(b=>b.id===o)??a[0]??null,e[3]=o,e[4]=a,e[5]=v):v=e[5],p=v;break e}p=a[0]??null}const u=p;let y;e:{if(d&&h){let b;e[6]!==h?(b={id:Ga,path:h},e[6]=h,e[7]=b):b=e[7],y=b;break e}if(!u){y=null;break e}let v;e[8]!==u.id||e[9]!==u.path?(v={id:u.id,path:u.path},e[8]=u.id,e[9]=u.path,e[10]=v):v=e[10],y=v}const k=y;let N;e:{if(d){let b;e[11]!==f?(b=f("sessions.sidebar.activity.chatsTitle"),e[11]=f,e[12]=b):b=e[12],N=b;break e}if(!u){N=null;break e}let v;e[13]!==u.label||e[14]!==u.path||e[15]!==i?(v=u.label?.trim()||za(u.path,i)||u.path,e[13]=u.label,e[14]=u.path,e[15]=i,e[16]=v):v=e[16],N=v}const S=N;let P;e:{if(!u){P=!1;break e}let v;e[17]!==u.path||e[18]!==c?(v=c.get(u.path)?.isGitRepo,e[17]=u.path,e[18]=c,e[19]=v):v=e[19],P=v===!0}const O=P;let w;return e[20]!==O||e[21]!==n||e[22]!==r||e[23]!==S||e[24]!==k?(w=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(Rd,{projectRef:k,projectLabel:S,canCreateWorktree:O,onActionComplete:n,onOpenPlan:r})}),e[20]=O,e[21]=n,e[22]=r,e[23]=S,e[24]=k,e[25]=w):w=e[25],w};function Jd(s){return s.activeProjectId}function Qd(s){return s.projects}function Xd(s){return s.homeDirectory}function Zd(s){return s.directories}function eu(s){return s.newSessionDraft.open?s.newSessionDraft.target==="chat":Va(s.currentSessionDirectory)}function tu(s){return s.currentSessionDirectory}const $s=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),Cn=512*1024,su=new TextEncoder,nu=new TextDecoder,ln=s=>{const e=su.encode(s);if(e.byteLength<=Cn)return{text:s,byteLength:e.byteLength};let n=e.byteLength-Cn;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:nu.decode(r),byteLength:r.byteLength}},hs=(s,e)=>`${s}\0${e}`,cn=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},ru="terminal-store";let xr=!1,br=0;const Os=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(br+=1,`tab-${Date.now().toString(36)}-${br.toString(36)}`),dn=s=>typeof s=="object"&&s!==null,ou=s=>{const e=/^tab-(\d+)$/.exec(s);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function bt(s){let e=s.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const au=/^Terminal(?: (\d+))?$/,iu=s=>{let e=0;for(const n of s){const r=au.exec(n.label);if(!r)continue;const o=r[1]?Number.parseInt(r[1],10):1;Number.isSafeInteger(o)&&(e=Math.max(e,o))}return e===0?"Terminal":`Terminal ${e+1}`},un=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),fn=s=>({tabs:[s],activeTabId:s.id}),Dt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let mn=null,hn=null;const lu=s=>{if(hn&&mn?.sessions===s.sessions&&mn.nextTabId===s.nextTabId)return hn;const e={sessions:Array.from(s.sessions.entries()).map(([n,r])=>[n,{activeTabId:r.activeTabId,tabs:r.tabs.map(o=>({id:o.id,label:o.label,iconKey:o.iconKey,createdAt:o.createdAt}))}]),nextTabId:s.nextTabId};return mn={sessions:s.sessions,nextTabId:s.nextTabId},hn=e,e},cu=()=>{const s=Ri(()=>bi());if(!s)return;let e=null;return{getItem:n=>s.getItem(n),setItem:(n,r)=>{if(r.state!==e)return e=r.state,s.setItem(n,r)},removeItem:n=>(e=null,s.removeItem(n))}},nt=qs()(Ur($r((s,e)=>({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=bt(n);r&&s(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),i=Os(),f=un(i,"Terminal");return a.set(r,fn(f)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=bt(n);return e().sessions.get(r)},getActiveTab:n=>{const r=bt(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(i=>i.id===a)??o.tabs[0]:o.tabs[0]},getBuffer:(n,r)=>e().buffers.get(hs(bt(n),r))??$s,createTab:n=>{const r=bt(n);if(!r)return"tab-invalid";const o=Os();return s(a=>{const i=new Map(a.sessions),f=i.get(r),c=a.nextTabId+1,d=iu(f?.tabs??[]),l=un(o,d);return f?i.set(r,{...f,tabs:[...f.tabs,l]}):i.set(r,fn(l)),{sessions:i,nextTabId:c}}),o},setActiveTab:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),f=i.get(o);return!f||f.activeTabId===r||Dt(f,r)<0?a:(i.set(o,{...f,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=bt(n),i=o.trim();i&&s(f=>{const c=new Map(f.sessions),d=c.get(a);if(!d)return f;const l=Dt(d,r);if(l<0||d.tabs[l]?.label===i)return f;const g=[...d.tabs];return g[l]={...g[l],label:i},c.set(a,{...d,tabs:g}),{sessions:c}})},setTabIconKey:(n,r,o)=>{const a=bt(n);s(i=>{const f=new Map(i.sessions),c=f.get(a);if(!c)return i;const d=Dt(c,r);if(d<0)return i;const l=o?.trim()||null;if(c.tabs[d]?.iconKey===l)return i;const g=[...c.tabs];return g[d]={...g[d],iconKey:l},f.set(a,{...c,tabs:g}),{sessions:f}})},closeTab:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),f=i.get(o);if(!f)return a;const c=Dt(f,r);if(c<0)return a;const d=f.tabs.filter(y=>y.id!==r),l=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,y])=>!(y.directory===o&&y.tabId===r))),g=Object.keys(l).length!==Object.keys(a.projectActionRuns).length,h=hs(o,r),p=a.buffers.has(h)?cn(a.buffers,y=>y===h):null;if(d.length===0){const y=Os(),k=un(y,"Terminal");return i.set(o,fn(k)),{sessions:i,nextTabId:a.nextTabId+1,...p?{buffers:p}:{},...g?{projectActionRuns:l}:{}}}let u=f.activeTabId;return f.activeTabId===r&&(u=d[Math.min(c,d.length-1)]?.id??d[0]?.id??null),i.set(o,{...f,tabs:d,activeTabId:u}),{sessions:i,...p?{buffers:p}:{},...g?{projectActionRuns:l}:{}}})},setTabSessionId:(n,r,o)=>{const a=bt(n);s(i=>{const f=new Map(i.sessions),c=f.get(a);if(!c)return i;const d=Dt(c,r);if(d<0)return i;const l=c.tabs[d],g=o!==null&&l.terminalSessionId!==o,h=o?"running":l.terminalSessionId?"exited":l.lifecycle,p={...l,terminalSessionId:o,lifecycle:h,isConnecting:!1},u=hs(a,r),y=g&&i.buffers.has(u)?cn(i.buffers,N=>N===u):null,k=[...c.tabs];return k[d]=p,f.set(a,{...c,tabs:k}),{sessions:f,...y?{buffers:y}:{}}})},setTabLifecycle:(n,r,o)=>{const a=bt(n);s(i=>{const f=new Map(i.sessions),c=f.get(a);if(!c)return i;const d=Dt(c,r);if(d<0)return i;const l=[...c.tabs];return l[d]={...l[d],lifecycle:o,isConnecting:!1},f.set(a,{...c,tabs:l}),{sessions:f}})},setConnecting:(n,r,o)=>{const a=bt(n);s(i=>{const f=new Map(i.sessions),c=f.get(a);if(!c)return i;const d=Dt(c,r);if(d<0)return i;const l=[...c.tabs];return l[d]={...l[d],isConnecting:o},f.set(a,{...c,tabs:l}),{sessions:f}})},replaceBuffer:(n,r,o,a)=>{const i=bt(n);s(f=>{const c=f.sessions.get(i);if(!c||Dt(c,r)<0)return f;const d=hs(i,r),l=f.buffers.get(d)??$s;if(l.lastSequence>a)return f;const g=ln(o);if(l.lastSequence===a&&l.byteLength===g.byteLength&&l.chunks.map(u=>u.data).join("")===g.text)return f;const h=f.nextChunkId,p=new Map(f.buffers);return p.set(d,{chunks:g.text?[{id:h,data:g.text,byteLength:g.byteLength}]:[],byteLength:g.byteLength,lastSequence:a}),{buffers:p,nextChunkId:g.text?h+1:h}})},appendToBuffer:(n,r,o,a,i)=>{if(!o)return;const f=bt(n);s(c=>{const d=c.sessions.get(f);if(!d||Dt(d,r)<0)return c;const l=hs(f,r),g=c.buffers.get(l)??$s;if(a!==void 0&&a<=g.lastSequence)return c;const h=c.nextChunkId,p=ln(o),u=i!==void 0&&i!==o?ln(i).text:void 0,y={id:h,data:p.text,...u!==void 0?{replayData:u}:{},byteLength:p.byteLength},k=[...g.chunks,y];let N=g.byteLength+y.byteLength;for(;N>Cn&&k.length>1;){const P=k.shift();if(!P)break;N-=P.byteLength}const S=new Map(c.buffers);return S.set(l,{chunks:k,byteLength:N,lastSequence:a??g.lastSequence}),{buffers:S,nextChunkId:h+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=bt(n);s(f=>{const c=new Map(f.sessions),d=c.get(i);if(!d)return f;const l=Dt(d,r);if(l<0)return f;const g=d.tabs[l],h=a.autoOpened??g.previewAutoOpened,p=a.locked??g.previewUrlLocked;if(g.previewUrl===o&&g.previewAutoOpened===h&&g.previewUrlLocked===p)return f;const u=[...d.tabs];return u[l]={...g,previewUrl:o,previewAutoOpened:h,previewUrlLocked:p},c.set(i,{...d,tabs:u}),{sessions:c}})},markPreviewAutoOpened:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),f=i.get(o);if(!f)return a;const c=Dt(f,r);if(c<0)return a;const d=f.tabs[c];if(!d.previewUrl||d.previewAutoOpened)return a;const l=[...f.tabs];return l[c]={...d,previewAutoOpened:!0},i.set(o,{...f,tabs:l}),{sessions:i}})},setProjectActionRun:n=>{s(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{s(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{s(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},removeDirectory:n=>{const r=bt(n);s(o=>{const a=new Map(o.sessions);a.delete(r);const i=hs(r,""),f=cn(o.buffers,d=>d.startsWith(i)),c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,d])=>d.directory!==r));return{sessions:a,...f?{buffers:f}:{},projectActionRuns:c}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:ru,storage:cu(),partialize:lu,merge:(s,e)=>{if(!dn(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const f of n){if(!Array.isArray(f)||f.length!==2)continue;const[c,d]=f;if(typeof c!="string"||!dn(d))continue;const l=Array.isArray(d.tabs)?d.tabs:[],g=[],h=new Map;for(const k of l){if(!dn(k))continue;const N=typeof k.id=="string"?k.id:null;if(!N)continue;const S=ou(N);S!==null&&(o=Math.max(o,S));const P=S===null?N:Os();h.set(N,P),g.push({id:P,label:typeof k.label=="string"?k.label:"Terminal",iconKey:typeof k.iconKey=="string"?k.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof k.createdAt=="number"?k.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(g.length===0)continue;const p=typeof d.activeTabId=="string"?d.activeTabId:null,u=p?h.get(p)??p:null,y=u?g.some(k=>k.id===u):!1;r.set(c,{tabs:g,activeTabId:y?u:g[0].id})}const a=typeof s.nextTabId=="number"&&Number.isFinite(s.nextTabId)?s.nextTabId:1,i=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,buffers:new Map,nextChunkId:1,nextTabId:i,hasHydrated:!0}}})));if(typeof window<"u"&&!xr){xr=!0;const s=nt.persist,e=()=>{nt.getState().hasHydrated||nt.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function du(s){const{colors:e}=s,n=e.syntax.base;return{background:e.surface.background,foreground:n.foreground,cursor:e.interactive.cursor,cursorAccent:e.surface.background,selectionBackground:e.interactive.selection,selectionForeground:e.interactive.selectionForeground,selectionInactiveBackground:e.interactive.selection+"50",black:e.surface.muted,red:e.status.error,green:e.status.success,yellow:e.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:e.status.error,brightGreen:e.status.success,brightYellow:e.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:e.surface.elevatedForeground}}function uu(s,e,n,r,o=!1){const i=`${s}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:e,fontFamily:i,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:o}}const pn=["\x1B[0m","\x1B[m"],fu=s=>{const e=s.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(n){const a=n.length<=4?n.slice(0,3).split("").map(i=>i+i).join(""):n.slice(0,6);return[Number.parseInt(a.slice(0,2),16),Number.parseInt(a.slice(2,4),16),Number.parseInt(a.slice(4,6),16)]}const r=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!r)return null;const o=r.slice(1,4).map(Number);return o.some(a=>a<0||a>255)?null:o},yr=s=>{const e=fu(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},mu=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...pn.map(c=>c.length))-1;for(let c=1;c<=Math.min(a,r.length);c+=1){const d=r.slice(-c);pn.some(l=>l.length>d.length&&l.startsWith(d))&&(o=c)}const i=o>0?r.slice(-o):"";let f=o>0?r.slice(0,-o):r;for(const c of pn)f=f.replaceAll(c,n);return{data:f,carry:i}},hu=(s,e,n,r,o)=>{if(n.width<=0||n.height<=0||r<=0||o<=0)return null;const a=Math.floor((s-n.left)/n.width*r),i=Math.floor((e-n.top)/n.height*o);return{column:Math.max(0,Math.min(r-1,a)),row:Math.max(0,Math.min(o-1,i))}},pu=(s,e)=>{const n=Math.max(0,Math.min(s.length-1,e)),r=i=>!!(i&&!/^\s+$/u.test(i));if(!r(s[n]))return{startColumn:n,endColumn:n};let o=n,a=n;for(;o>0&&r(s[o-1]);)o-=1;for(;a<s.length-1&&r(s[a+1]);)a+=1;return{startColumn:o,endColumn:a}};let gu=null;const xu=()=>gu??=Gt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([121,6])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),bu=2e3,yu=()=>{if(typeof window>"u")return Promise.resolve();const s=window.__openchamberEnsureNerdFonts;return typeof s!="function"?Promise.resolve():Promise.race([Promise.resolve(s()).catch(()=>{}),new Promise(e=>setTimeout(e,bu))]).then(()=>{})},wu=(s,e,n)=>{if(typeof window>"u"||typeof document>"u")return null;const r=document.createElement("canvas").getContext("2d");if(!r||s.clientWidth<24||s.clientHeight<24)return null;r.font=`${n}px ${e}`;const o=r.measureText("M"),a=Math.ceil(o.width),i=Math.ceil((o.actualBoundingBoxAscent||n*.8)+(o.actualBoundingBoxDescent||n*.2))+2;if(a<1||i<1)return null;const f=window.getComputedStyle(s),c=(Number.parseInt(f.paddingLeft,10)||0)+(Number.parseInt(f.paddingRight,10)||0),d=(Number.parseInt(f.paddingTop,10)||0)+(Number.parseInt(f.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-c-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-d)/i))}},fo=m.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,fontFamily:a,fontSize:i,className:f,enableTouchScroll:c=!1,autoFocus:d=!0,isVisible:l=!0},g)=>{const h=m.useRef(null),p=m.useRef(null),u=m.useRef(null),y=m.useRef(n),k=m.useRef(r),N=m.useRef(null),S=m.useRef(null),P=m.useRef(null),O=m.useRef(""),w=m.useRef(""),v=m.useRef(yr(o.background)),b=m.useRef(!1),D=m.useRef(0),C=m.useRef(l),_=m.useRef(!1),[L,H]=m.useState(0),[U,Y]=m.useState(0);y.current=n,k.current=r,C.current=l,v.current=yr(o.background),m.useLayoutEffect(()=>{const G=h.current;if(!G)return;const E=wu(G,a,i);S.current=E,E&&k.current(E.cols,E.rows)},[a,i]);const F=m.useCallback(()=>{const G=h.current,E=p.current;if(!G||!E||!u.current||!C.current)return;const B=G.getBoundingClientRect();if(!(B.width<24||B.height<24))try{u.current.fit();const W={cols:E.cols,rows:E.rows};(!N.current||N.current.cols!==W.cols||N.current.rows!==W.rows)&&(N.current=W,k.current(W.cols,W.rows)),_.current||(_.current=!0,H(K=>K+1))}catch{}},[]),te=m.useCallback(()=>{if(b.current||!O.current||!p.current)return;const G=p.current,E=O.current;O.current="";const B=mu(E,w.current,v.current);if(w.current=B.carry,!B.data){O.current&&te();return}b.current=!0;const W=D.current;G.write(B.data,()=>{p.current!==G||D.current!==W||(b.current=!1,O.current&&te())})},[]),$=m.useCallback(()=>{P.current=null,O.current="",w.current="",b.current=!1,D.current+=1;const G=p.current;if(!G){Y(E=>E+1);return}try{G.reset();const E=v.current;E&&G.write(`${E}\x1B[2J\x1B[H`)}catch{Y(E=>E+1)}},[]);return m.useEffect(()=>{const G=h.current;if(!G)return;let E=!1,B=null,W=null,K=null,T=null,z=[];const J=()=>{B&&C.current&&(B.options.cursorBlink=!0)},ae=Q=>{Q.relatedTarget instanceof Node&&G.contains(Q.relatedTarget)||B&&(B.options.cursorBlink=!1)},ee=()=>{B&&C.current&&G.contains(document.activeElement)&&(B.options.cursorBlink=!0)},X=()=>{B&&(B.options.cursorBlink=!1)};return G.addEventListener("focusin",J),G.addEventListener("focusout",ae),window.addEventListener("focus",ee),window.addEventListener("blur",X),Promise.all([xu(),yu()]).then(([{module:Q,ghostty:re}])=>{if(E)return;B=new Q.Terminal({...uu(a,i,o,re,!1),...S.current??{}});const ce=new Q.FitAddon;B.loadAddon(ce),B.open(G),p.current=B,u.current=ce,z=[B.onData(oe=>y.current(oe))],W=new ResizeObserver(()=>{K&&clearTimeout(K),K=setTimeout(F,80)}),W.observe(G),F();const me=v.current;me&&B.write(`${me}\x1B[2J\x1B[H`),T=requestAnimationFrame(F)}),()=>{E=!0;const Q=document.activeElement;Q instanceof HTMLElement&&G.contains(Q)&&(Q.blur(),window.Capacitor?.getPlatform?.()==="android"&&Gt(async()=>{const{Keyboard:ce}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:ce}},__vite__mapDeps([122,123])).then(({Keyboard:ce})=>ce.hide()).catch(()=>{})),W?.disconnect(),K&&clearTimeout(K),T!==null&&cancelAnimationFrame(T),G.removeEventListener("focusin",J),G.removeEventListener("focusout",ae),window.removeEventListener("focus",ee),window.removeEventListener("blur",X),z.forEach(re=>re.dispose()),B?.dispose(),p.current=null,u.current=null,N.current=null,P.current=null,O.current="",w.current="",b.current=!1,D.current+=1,_.current=!1}},[F,a,i,U,o]),m.useEffect(()=>{const G=p.current,E=h.current;!G||!E||(G.options.cursorBlink=l&&document.hasFocus()&&E.contains(document.activeElement))},[l,L]),m.useEffect(()=>{if(!p.current)return;if(e.length===0){P.current!==null&&$();return}const E=P.current;let B=-1;if(E!==null){for(let T=e.length-1;T>=0;T-=1){const z=e[T].id;if(z===E){B=T;break}if(z<E)break}if(B<0){$();return}}const W=B<0,K=B>=0?e.slice(B+1):e;O.current+=K.map(T=>W?T.replayData??T.data:T.data).join(""),P.current=e.at(-1)?.id??null,te()},[e,te,L,$]),m.useEffect(()=>{if(!d||!l)return;const G=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(G)},[d,l,L,s]),m.useEffect(()=>{const G=h.current;if(!c||!G)return;const E=B=>{const W=B;if(!W.isComposing)switch(W.inputType){case"insertText":W.data&&y.current(W.data);break;case"insertLineBreak":case"insertParagraph":y.current("\r");break;case"deleteContentBackward":y.current("");break}};return G.addEventListener("beforeinput",E),()=>G.removeEventListener("beforeinput",E)},[c,L]),m.useEffect(()=>{const G=h.current,E=p.current;if(!c||!G||!E)return;let B=null,W=null,K="idle",T=0,z=0,J=0,ae=0,ee=null;const X=Math.max(12,i+2),Q=()=>{window.Capacitor?.getPlatform?.()==="android"&&Gt(async()=>{const{Keyboard:Z}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:Z}},__vite__mapDeps([122,123])).then(({Keyboard:Z})=>Z.show()).catch(()=>{})},re=()=>{W&&(clearTimeout(W),W=null)},ce=(V,Z)=>{const pe=G.querySelector("canvas");return pe?hu(V,Z,pe.getBoundingClientRect(),E.cols,E.rows):null},me=(V,Z)=>{const pe=G.querySelector("canvas");if(!pe)return;const ne=pe.getBoundingClientRect(),we=ne.left+(Z.column+.5)/E.cols*ne.width,Te=ne.top+(Z.row+.5)/E.rows*ne.height;pe.dispatchEvent(new MouseEvent(V,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:we,clientY:Te}))},oe=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},q=V=>{V.pointerType!=="touch"||B!==null||(B=V.pointerId,K="pending",T=V.clientX,z=V.clientY,J=V.clientY,ae=0,ee=null,G.setPointerCapture(V.pointerId),W=setTimeout(()=>{if(W=null,B!==V.pointerId||K!=="pending")return;const Z=ce(T,z);if(!Z)return;const pe=E.buffer.active,ne=Math.max(0,pe.length-E.rows-pe.viewportY+Z.row),we=pe.getLine(ne),Te=Array.from({length:E.cols},(tt,Le)=>we?.getCell(Le)?.getChars()??""),Be=pu(Te,Z.column),Me={column:Be.startColumn,row:Z.row};ee={column:Be.endColumn,row:Z.row},K="selecting",me("mousedown",Me),me("mousemove",ee)},350))},ie=V=>{if(B!==V.pointerId)return;if(K==="selecting"){const ne=ce(V.clientX,V.clientY);ne&&(!ee||ne.column!==ee.column||ne.row!==ee.row)&&(ee=ne,me("mousemove",ne)),V.cancelable&&V.preventDefault();return}if(K==="pending"){if(Math.hypot(V.clientX-T,V.clientY-z)<8)return;re(),K="scrolling"}if(K!=="scrolling")return;const Z=J-V.clientY;J=V.clientY,ae+=Z;const pe=Math.trunc(ae/X);pe&&(E.scrollLines(pe),ae-=pe*X),V.cancelable&&V.preventDefault()},he=V=>{if(B!==V.pointerId)return;const Z=K==="pending",pe=K==="selecting";re(),G.hasPointerCapture(V.pointerId)&&G.releasePointerCapture(V.pointerId),B=null,K="idle",pe&&oe(),Z&&(E.focus(),Q())},j=V=>{if(B!==V.pointerId)return;const Z=K==="selecting";re(),G.hasPointerCapture(V.pointerId)&&G.releasePointerCapture(V.pointerId),B=null,K="idle",Z&&oe()};return G.addEventListener("pointerdown",q),G.addEventListener("pointermove",ie,{passive:!1}),G.addEventListener("pointerup",he),G.addEventListener("pointercancel",j),()=>{re(),G.removeEventListener("pointerdown",q),G.removeEventListener("pointermove",ie),G.removeEventListener("pointerup",he),G.removeEventListener("pointercancel",j)}},[c,i,L]),m.useImperativeHandle(g,()=>({focus:()=>p.current?.focus(),fit:F,getSelection:()=>{const G=p.current,E=G?.getSelectionPosition(),B=G?.getSelection()??"";return!E||!B.trim()?null:{text:B,startLine:E.start.y+1,endLine:E.end.y+1}}}),[F]),t.jsx("div",{ref:h,"data-terminal-owner":"main",className:se("terminal-viewport-container h-full w-full overflow-hidden touch-none",f)})});fo.displayName="TerminalViewport";const vu="\x1B",mo=new RegExp(`${vu}\\[[0-9;?]*[ -/]*[@-~]`,"g"),ju=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,ku=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,Su=/Serving HTTP on .*? port (\d{2,5})/i,Nu=new Set([".",",",";",":","!","?"]),ho=s=>{let e=s;for(;e.length>0;){const n=e[e.length-1];if(n===")"||n==="]"||n==="}"||n===">"){const r=n===")"?"(":n==="]"?"[":n==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${r}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${n}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(Nu.has(n)){e=e.slice(0,-1);continue}break}return e},In=s=>{let e=ho(s);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},Cu=s=>{if(!s)return[];const e=s.replace(mo,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(Su);if(a?.[1]){const i=Number.parseInt(a[1],10);Number.isFinite(i)&&i>0&&i<=65535&&o(`http://127.0.0.1:${i}/`)}for(const i of e.split(`
9
+ `)){if(!ku.test(i))continue;const f=Array.from(i.matchAll(ju));if(f.length===0)continue;const c=f.find(d=>{try{return!!new URL(In(d[1])).port}catch{return!1}});o(In((c??f[0])[1]))}return n},po=s=>Cu(s)[0]??null,Iu=async(s,e=1500)=>{if(!s||typeof window>"u")return!1;let n;try{n=new URL(s)}catch{return!1}if(n.protocol!=="http:"&&n.protocol!=="https:")return!1;const r=n.hostname.toLowerCase();if(r!=="localhost"&&r!=="127.0.0.1"&&r!=="0.0.0.0"&&r!=="::1"&&r!=="::")return!1;const o=new AbortController,a=window.setTimeout(()=>o.abort(),e);try{const i=await Bt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n.toString()}),cache:"no-store",signal:o.signal});return i.ok?(await i.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(a)}},Tu=/https?:\/\/[^\s<>'"`]+/gi,gf=(s,{requireAnnounced:e=!1}={})=>{const n=po(s);if(n)return n;if(e)return null;const r=String(s||"").replace(mo,""),o=[];for(const f of r.match(Tu)??[])try{const c=new URL(ho(f));c.port&&o.push(c)}catch{}if(o.length===0)return null;const a=f=>{const c=f.hostname.toLowerCase();return(c==="localhost"||c==="127.0.0.1"||c==="0.0.0.0"||c==="::1"?50:0)-(f.search||f.hash?10:0)};let i=o[0];for(const f of o.slice(1))a(f)>a(i)&&(i=f);return In(i.toString())},Du={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},Pu=(s,e)=>{if(e&&s.startsWith("arrow-")){const n=e==="ctrl"?"5":"3",r={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[s];return`\x1B[1;${n}${r}`}return Du[s]},go=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},Eu=(s,e)=>s&&(e==="ctrl"?go(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),wr={cols:80,rows:24},xf=({visible:s})=>{const{t:e}=Qe(),{terminal:n,runtime:r}=Dn(),{currentTheme:o}=Pr(),a=m.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});a.current={themeMode:o.metadata.variant==="light"?"light":"dark",terminalBackground:o.colors.surface.background,terminalForeground:o.colors.syntax.base.foreground};const{monoFont:i}=Ha(),f=Pe(M=>M.terminalFontSize),c=Pe(M=>M.terminalShell),d=Pe(M=>M.terminalLoginShells.includes(M.terminalShell)),{isMobile:l,isTablet:g,hasTouchOnlyPointer:h}=Hs(),p=l||g,u=(p||h)&&r.platform==="web",y=r.platform!=="vscode",k=Pe(M=>M.showTerminalQuickKeysOnDesktop),N=p||k,S=rt(M=>M.currentSessionId),P=rt(M=>M.newSessionDraft),O=S!==null||P?.open===!0,w=Ka()??null,v=nt(M=>w?M.sessions.get(w):void 0),b=nt(M=>M.hasHydrated),D=nt(M=>M.ensureDirectory),C=nt(M=>M.createTab),_=nt(M=>M.setActiveTab),L=nt(M=>M.closeTab),H=nt(M=>M.setTabSessionId),U=nt(M=>M.setTabLifecycle),Y=nt(M=>M.setConnecting),F=nt(M=>M.appendToBuffer),te=nt(M=>M.replaceBuffer),$=nt(M=>M.setTabPreviewUrl),G=qa(M=>M.addDraft),E=Pe(M=>M.openContextPreview),B=m.useMemo(()=>v?y?v.activeTabId??v.tabs[0]?.id??null:v.tabs[0]?.id??null:null,[v,y]),W=m.useMemo(()=>{if(v)return B?v.tabs.find(M=>M.id===B)??v.tabs[0]:v.tabs[0]},[v,B]),K=m.useMemo(()=>(v?.tabs??[]).map(M=>({icon:(()=>{const de=M.iconKey?eo[M.iconKey]??"terminal":"terminal";return t.jsx(R,{name:de,className:"h-4 w-4"})})(),id:M.id,label:M.label,title:M.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[v?.tabs,e]),T=W?.terminalSessionId??null,z=W?.lifecycle??"idle",J=nt(M=>w&&B?M.getBuffer(w,B).chunks:$s.chunks),ae=W?.isConnecting??!1,ee=W?.previewUrl??null,[X,Q]=m.useState(null),[re,ce]=m.useState(!1),[me,oe]=m.useState(!1),[q,ie]=m.useState(null),[he,j]=m.useState(!1),V=m.useRef(null),Z=m.useRef(null),pe=m.useRef(B),ne=m.useRef(T),we=m.useRef(w),Te=m.useRef(null),Be=m.useRef(null),Me=m.useRef(new Set),tt=m.useRef(""),Le=m.useRef(new Set),Xe=m.useRef(0),Ae=m.useCallback(()=>{tt.current="",Le.current.clear(),Xe.current+=1},[]),Ze=m.useCallback(()=>{u||typeof document<"u"&&!document.hasFocus()||Te.current?.focus()},[u]),Fe=m.useCallback(()=>{u||Te.current?.focus()},[u]),ot=Pe(M=>M.activeSurface)==="terminal",We=s??ot,[Je,Ke]=m.useState(We);m.useEffect(()=>{We&&Ke(!0)},[We]),m.useEffect(()=>{ne.current=T},[T]),m.useEffect(()=>{!T||!n.updateAppearance||n.updateAppearance(T,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,T]),m.useEffect(()=>{pe.current=B,Ae()},[B,Ae]),m.useEffect(()=>{we.current=w},[w]),m.useEffect(()=>{!N&&q!==null&&ie(null)},[N,q,ie]),m.useEffect(()=>{!T&&q!==null&&ie(null)},[T,q,ie]);const Ie=m.useCallback(()=>{V.current?.(),V.current=null,Z.current=null,oe(!1)},[]);m.useEffect(()=>()=>{Ie(),ne.current=null},[Ie]);const De=m.useCallback((M,de,be)=>{if(!be)return;const He=`${tt.current}${be}`.replace(/\r\n|\r/g,`
10
+ `),je=He.split(`
11
+ `),xe=He.endsWith(`
12
+ `)?je.join(`
13
+ `):je.slice(0,-1).join(`
14
+ `);if(tt.current=He.endsWith(`
15
+ `)?"":(je[je.length-1]??"").slice(-1024),!xe)return;const ue=po(xe);if(!ue||Le.current.has(ue))return;const Oe=Xe.current;Le.current.add(ue),Iu(ue).then(ct=>{if(Le.current.delete(ue),!ct||Xe.current!==Oe)return;const dt=nt.getState().getDirectoryState(M)?.tabs.find(vt=>vt.id===de);!dt||dt.previewUrlLocked||dt.previewUrl===ue||$(M,de,ue,{locked:!1,autoOpened:!1})})},[$]),_e=m.useCallback((M,de,be)=>{if(Z.current===be)return;Ie(),Z.current=be;const He=n.connect(be,{onEvent:je=>{if(Z.current===be)switch(je.type){case"snapshot":{Y(M,de,!1),Q(null),ce(!1),oe(!1),Ze(),te(M,de,je.data??"",je.sequence??0),De(M,de,je.data??""),je.status==="exited"&&U(M,de,"exited");break}case"reconnecting":{Q(null),ce(!1),oe(!0);break}case"data":{je.data&&(F(M,de,je.data,je.sequence,je.replayData),De(M,de,je.data));break}case"exit":{const xe=typeof je.exitCode=="number"?je.exitCode:null,ue=typeof je.signal=="number"?je.signal:null,ct=!!nt.getState().getDirectoryState(M)?.tabs.find(dt=>dt.id===de)?.label?.startsWith("Action:");F(M,de,e("terminalView.stream.processExitedMessage",{exitCodeSegment:xe!==null?e("terminalView.stream.processExitedWithCode",{exitCode:xe}):"",signalSegment:ue!==null?e("terminalView.stream.processExitedWithSignal",{signal:ue}):""})),U(M,de,"exited"),Y(M,de,!1),Q(ct?null:e("terminalView.error.sessionEnded")),ce(!1),oe(!1),Ie();break}}},onError:(je,xe)=>{if(Z.current===be){if(!xe){Q(null),ce(!1);return}if(oe(!1),je.code==="SESSION_NOT_FOUND"&&!nt.getState().getDirectoryState(M)?.tabs.find(Oe=>Oe.id===de)?.label?.startsWith("Action:")){Q(null),ce(!1),Y(M,de,!1),H(M,de,null),U(M,de,"idle"),Ie();return}Q(e("terminalView.error.connectionFailed",{message:je.message})),ce(!0),Y(M,de,!1),U(M,de,"exited"),H(M,de,null),Ie()}}});V.current=()=>{He.close(),Z.current=null}},[F,te,Ie,Ze,De,Y,U,H,e,n]);m.useEffect(()=>{let M=!1;if(!b||!Je)return;if(!w){Q(e(O?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),Ie();return}return(async()=>{const be=w;if(!we.current||we.current!==be)return;if(!nt.getState().getDirectoryState(be)){D(be);return}const je=nt.getState().getDirectoryState(be);if(!je||je.tabs.length===0)return;const xe=y?je.activeTabId??je.tabs[0]?.id??null:je.tabs[0]?.id??null;if(!xe)return;const ue=je.tabs.find(pt=>pt.id===xe)??je.tabs[0],Oe=ue?.terminalSessionId??null,ct=ue?.lifecycle??"idle",dt=!!ue?.label?.startsWith("Action:"),vt=nt.getState().getBuffer(be,xe),Nt=vt.byteLength>0||vt.chunks.length>0;if(!Oe){if(ct==="exited"){Y(be,xe,!1);return}if(dt&&Nt){Y(be,xe,!1);return}const pt=`${be}\0${xe}`;if(Me.current.has(pt))return;const gt=Be.current??wr;Me.current.add(pt),Q(null),ce(!1),oe(!1),Y(be,xe,!0);try{const jt=await n.createSession({cwd:be,sessionId:xe,cols:gt.cols,rows:gt.rows,shell:c,loginShell:d,...a.current}),St=!M&&we.current===be&&pe.current===xe;if(!nt.getState().getDirectoryState(be)?.tabs.find(Ut=>Ut.id===xe)){try{await n.close(jt.sessionId)}catch{}return}if(H(be,xe,jt.sessionId),!St)return;const ht=Be.current;ht&&(ht.cols!==gt.cols||ht.rows!==gt.rows)&&n.resize({sessionId:jt.sessionId,...ht}).catch(()=>{});return}catch(jt){const St=nt.getState().getDirectoryState(be)?.tabs.find(Tt=>Tt.id===xe);if(!St||St.terminalSessionId||(Y(be,xe,!1),we.current!==be||pe.current!==xe))return;Q(jt instanceof Error?jt.message:e("terminalView.error.startSessionFailed")),ce(!0),oe(!1);return}finally{Me.current.delete(pt)}}!Oe||M||(ne.current=Oe,_e(be,xe,Oe))})(),()=>{M=!0,ne.current=null,Ie()}},[O,w,T,z,B,Je,y,b,D,Y,U,H,_e,Ie,e,n,d,c]),m.useEffect(()=>{if(!We||u)return;if(typeof window>"u"){Ze();return}const M=window.requestAnimationFrame(()=>{Ze()});return()=>{window.cancelAnimationFrame(M)}},[B,Ze,We,u]);const qe=m.useCallback(async()=>{if(!w||he)return;const M=nt.getState().getDirectoryState(w),de=y?B??M?.activeTabId??M?.tabs[0]?.id??null:M?.tabs[0]?.id??null;if(!de)return;const be=M?.tabs.find(He=>He.id===de)?.terminalSessionId??null;if(!(!be||!n.restartSession)){j(!0),Q(null),ce(!1),oe(!1),Ie(),Ae();try{const He=Be.current??wr,je=await n.restartSession(be,{cwd:w,shell:c,loginShell:d,...He,...a.current});if(nt.getState().getDirectoryState(w)?.tabs.find(ue=>ue.id===de)?.terminalSessionId!==be||(H(w,de,je.sessionId),U(w,de,"running"),we.current!==w||pe.current!==de))return;ne.current=je.sessionId,_e(w,de,je.sessionId)}catch(He){if(nt.getState().getDirectoryState(w)?.tabs.find(xe=>xe.id===de)?.terminalSessionId!==be||we.current!==w||pe.current!==de)return;Q(He instanceof Error?He.message:e("terminalView.error.restartFailed")),ce(!1),oe(!1),ne.current=be,_e(w,de,be)}finally{j(!1)}}},[B,Ie,w,y,he,Ae,U,H,_e,e,n,d,c]),it=m.useCallback(async()=>{await qe()},[qe]),x=m.useCallback(()=>{if(!w)return;const M=C(w);_(w,M),Q(null),ce(!1),oe(!1),Ie()},[C,Ie,w,_]),A=m.useCallback(()=>{const M=Te.current?.getSelection(),de=S??(P?.open?"draft":null);!M||!de||!W||!w||G({directory:w,sessionKey:de},{source:"terminal",fileLabel:W.label,startLine:M.startLine,endLine:M.endLine,code:M.text,language:W.terminalSessionId??W.id,text:""})},[W,G,S,w,P?.open]),ge=m.useCallback(M=>{w&&(_(w,M),Q(null),ce(!1),oe(!1),Ie())},[Ie,w,_]),fe=m.useCallback(M=>{if(!w)return;M===B&&Ie(),Q(null),ce(!1),oe(!1);const de=nt.getState().getDirectoryState(w)?.tabs.find(be=>be.id===M)?.terminalSessionId;(async()=>{de&&await n.close(de),L(w,M)})().catch(be=>Q(be instanceof Error?be.message:e("terminalView.error.sessionEnded")))},[B,L,Ie,w,e,n]),ve=m.useCallback(M=>{if(!M||me)return;let de=M,be=!1;q&&M.length>0&&(de=Eu(M,q),be=!0);const He=ne.current;He&&(n.sendInput(He,de).catch(je=>{me||Q(je instanceof Error?je.message:e("terminalView.error.sendInputFailed"))}),be&&(ie(null),Fe()))},[q,Fe,me,ie,e,n]),Ue=m.useCallback((M,de)=>{const be=Be.current;if((!be||be.cols!==M||be.rows!==de)&&(Be.current={cols:M,rows:de}),!We)return;const He=ne.current;He&&n.resize({sessionId:He,cols:M,rows:de}).catch(()=>{})},[We,n]),Ve=m.useCallback(M=>{ie(de=>de===M?null:M),Fe()},[Fe,ie]),$e=m.useCallback(M=>{const de=Pu(M,q);de&&(ve(de),ie(null),Fe())},[q,Fe,ve,ie]),Ee=m.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),I=m.useCallback(M=>{if(M.repeat)return;const de=M.key;if(!de||de==="Control"||de==="Meta"||de==="Alt"||de==="Shift")return;const be=de.length===1?de.toLowerCase():de;if(be in Ee){M.preventDefault(),M.stopPropagation(),$e(Ee[be]);return}if(q!=="ctrl")return;const He=M.code??"",je=de.length===1&&/[a-zA-Z]/.test(de)?de.toUpperCase():He.startsWith("Key")&&He.length===4?He.slice(3).toUpperCase():null;if(je&&je.length===1&&je>="A"&&je<="Z"){const xe=go(je);if(!xe)return;M.preventDefault(),M.stopPropagation(),ve(xe),ie(null),Fe()}},[q,Fe,$e,ve,Ee,ie]);m.useEffect(()=>{if(!(!N||!q||!T))return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[q,I,N,T]);const ye=m.useMemo(()=>{const M=ws[tn].stack;if(typeof window>"u")return(ws[i]??ws[tn]).stack;const be=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return be&&be.trim().length>0?be.trim():(ws[i]??ws[tn]).stack??M},[i]),Ce=m.useMemo(()=>du(o),[o]),Re=`${w??"no-dir"}::${B??"no-tab"}`;if(m.useEffect(()=>{if(!We||u)return;const M=Te.current;if(!M)return;const de=()=>{M.fit()};if(typeof window<"u"){const be=window.requestAnimationFrame(()=>{de(),Ze()}),He=[220,400].map(je=>window.setTimeout(de,je));return()=>{window.cancelAnimationFrame(be),He.forEach(je=>window.clearTimeout(je))}}de()},[Ze,We,u,Re,T]),m.useEffect(()=>{if(!We||!u)return;let M=null;const de=()=>{M!==null&&window.cancelAnimationFrame(M),M=window.requestAnimationFrame(()=>{M=null,Te.current?.fit()})};return window.addEventListener("oc:keyboard-settled",de),()=>{window.removeEventListener("oc:keyboard-settled",de),M!==null&&window.cancelAnimationFrame(M)}},[We,Re,u]),!O)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:e("terminalView.empty.selectSession")});if(!w)return t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[t.jsx("p",{children:e("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:qe,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("terminalView.actions.retry")})]});const at=!T||ae||he||me,lt=Je,st=p?"lg":"xs",mt=p?"w-10 p-0":"w-9 p-0",ze=M=>{p&&M.preventDefault()},ut=t.jsxs(t.Fragment,{children:[t.jsx(Ne,{type:"button",size:st,variant:"outline",onPointerDown:ze,onClick:()=>$e("esc"),disabled:at,children:e("terminalView.quickKeys.escape")}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("tab"),disabled:at,children:[t.jsx(R,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"chip","aria-pressed":q==="ctrl",className:p?"px-3":"px-2",onPointerDown:ze,onClick:()=>Ve("ctrl"),disabled:at,children:[t.jsx("span",{className:"text-xs font-medium",children:e("terminalView.quickKeys.controlLabel")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"chip","aria-pressed":q==="alt",className:p?"px-3":"px-2",onPointerDown:ze,onClick:()=>Ve("alt"),disabled:at,children:[t.jsx("span",{className:"text-xs font-medium",children:e("terminalView.quickKeys.altLabel")}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("arrow-up"),disabled:at,children:[t.jsx(R,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("arrow-left"),disabled:at,children:[t.jsx(R,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("arrow-down"),disabled:at,children:[t.jsx(R,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("arrow-right"),disabled:at,children:[t.jsx(R,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Ne,{type:"button",size:st,variant:"outline",className:mt,onPointerDown:ze,onClick:()=>$e("enter"),disabled:at,children:[t.jsx(R,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:se("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",p?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[y&&v?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:se("min-w-0 flex-1",p?"h-8":"h-7"),children:t.jsx(Cs,{items:K,activeId:B,onSelect:ge,onClose:fe,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:se("shrink-0",p?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:x,title:e("terminalView.tabs.newTabTitle"),children:t.jsx(R,{name:"add",className:`${p?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{qe()},disabled:he,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(R,{name:"restart",className:"h-4 w-4"})}),t.jsx(Ne,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:A,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(R,{name:"attachment-2",className:"h-4 w-4"})}),ee?t.jsxs(Ne,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{w&&E(w,ee)},title:e("terminalView.preview.openTitle"),children:[t.jsx(R,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:e("terminalView.preview.open")})]}):null]})]}):null,!p&&N&&y&&v?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ut}):null,!p&&N&&(!y||!v)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:ut}):null]}),t.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:Ce.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:lt?t.jsx(fo,{ref:M=>{Te.current=M},sessionKey:Re,chunks:J,onInput:ve,onResize:Ue,theme:Ce,fontFamily:ye,fontSize:f,enableTouchScroll:u,autoFocus:We,isVisible:We},Re):null}),!me&&X&&t.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[t.jsx("span",{children:X}),re&&p&&t.jsx(Ne,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:it,disabled:he,title:e("terminalView.actions.hardRestartTitle"),type:"button",children:e("terminalView.actions.hardRestart")})]})]}),p&&N?t.jsx("div",{className:"shrink-0 overflow-x-auto border-t border-border/40 bg-[var(--surface-background)] px-2 pt-1.5 pb-[max(0.375rem,calc(var(--oc-app-bottom-safe,0px)-var(--oc-keyboard-inset,0px)))] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:t.jsx("div",{className:"flex min-w-max items-center gap-1.5",children:ut})}):null]})},bf=()=>{Or(),xs.reconnectToRuntimeBaseUrl(),Br()},yf=s=>{rt.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),Pe.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&Ya.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),Or(),nt.getState().clearAll(),xs.reconnectToRuntimeBaseUrl(),kt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),Ct.getState().resetForRuntimeSwitch(),Rt.getState().reset(),gn.getState().resetForRuntimeSwitch(),Ja.setState({statusById:new Map}),Qa(),Xa(),Za.getState().reset(),yi.getState().resetForRuntimeSwitch(),Pn.getState().resetForRuntimeSwitch(s.runtimeKey),ei.getState().resetForRuntimeSwitch(),ti.getState().resetForRuntimeSwitch(s.runtimeKey),wi.getState().resetForRuntimeSwitch(s.runtimeKey),rt.getState().restoreForRuntimeSwitch(s.runtimeKey),Pe.getState().restoreForRuntimeSwitch(s.runtimeKey),Br(),queueMicrotask(()=>{vi()})};export{Ju as A,lc as B,qu as C,ff as D,af as E,nf as F,Gc as G,of as H,Hu as I,Vt as J,dc as K,on as L,hf as M,mf as N,Ku as O,pf as P,uc as Q,xl as R,df as S,xf as T,Gu as U,Vu as V,zl as W,uf as X,Ac as a,Cs as b,yf as c,cf as d,lf as e,Yu as f,zu as g,or as h,nt as i,Vl as j,sf as k,eo as l,Cu as m,Gl as n,gf as o,rf as p,hl as q,bf as r,pl as s,tf as t,Ji as u,gl as v,Xu as w,ef as x,Zu as y,Qu as z};