@openchamber/web 1.18.3 → 1.19.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 (215) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-DbUi6I9s.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
  3. package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-D9cV-qR9.js} +1 -1
  4. package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-B9NCadU7.js} +1 -1
  5. package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
  6. package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-BWNq-0ov.js} +2 -2
  7. package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
  8. package/dist/assets/{GitView-C-n17voy.js → GitView-DsWXqWx3.js} +3 -3
  9. package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-h4dHASlq.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
  12. package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
  13. package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-jPKTJje5.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
  15. package/dist/assets/PlanView-UvuxIl9-.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
  17. package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
  18. package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
  19. package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
  22. package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-Bxun3k66.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
  25. package/dist/assets/de-DbV6CLxv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-CVDlyzZ4.js +15 -0
  28. package/dist/assets/fr-Czc-p0g-.js +13 -0
  29. package/dist/assets/index-1OhiMDBz.css +1 -0
  30. package/dist/assets/index-BSvmTvZl.js +1 -0
  31. package/dist/assets/index-DzriVon2.js +7 -0
  32. package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-DwHKxDYc.js} +1 -1
  33. package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-Dwq6ILxo.js} +1 -1
  34. package/dist/assets/ja-dwc9NM_S.js +15 -0
  35. package/dist/assets/ko-Ds1DZ8FX.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-BF51IOVF.js +921 -0
  38. package/dist/assets/{main-C0DyIwTb.js → main-D7UPARut.js} +2 -2
  39. package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
  40. package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-BISXSGOo.js} +2 -2
  41. package/dist/assets/mobile-BnYxVuvw.js +2 -0
  42. package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-BEDPDypx.js} +2 -2
  43. package/dist/assets/pl-CLiTO7i-.js +15 -0
  44. package/dist/assets/pt-BR-GIimJgpK.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
  46. package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-BiMbzPq9.js} +7 -7
  47. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
  48. package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
  49. package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-DXYW46vW.js} +1 -1
  50. package/dist/assets/uk-DLfgD1ki.js +15 -0
  51. package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-CbzHzFop.js} +139 -142
  52. package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CegKdDXi.js} +2 -2
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.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-Dihw9MtL.js → vendor-codemirror-language-data-CiAYDJXN.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-adaMkgkm.js +39 -0
  85. package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-DCLjCO9n.js} +1 -1
  86. package/dist/assets/zh-CN-DkeP5awK.js +15 -0
  87. package/dist/assets/zh-TW-BocaFm3d.js +15 -0
  88. package/dist/index.html +4 -4
  89. package/dist/mini-chat.html +3 -3
  90. package/dist/mobile.html +3 -3
  91. package/package.json +1 -1
  92. package/server/index.js +116 -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 +56 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +85 -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 +427 -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/dev-tunnel/client.js +20 -1
  111. package/server/lib/dev-tunnel/tunnel.test.js +9 -0
  112. package/server/lib/fs/DOCUMENTATION.md +3 -0
  113. package/server/lib/fs/routes.js +149 -32
  114. package/server/lib/fs/routes.test.js +225 -0
  115. package/server/lib/git/DOCUMENTATION.md +8 -0
  116. package/server/lib/git/service.js +121 -67
  117. package/server/lib/git/service.test.js +129 -0
  118. package/server/lib/github/DOCUMENTATION.md +14 -3
  119. package/server/lib/github/pr-status.js +188 -83
  120. package/server/lib/github/pr-status.test.js +182 -0
  121. package/server/lib/github/routes.js +36 -30
  122. package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
  123. package/server/lib/markdown-image-grants/routes.js +340 -0
  124. package/server/lib/markdown-image-grants/routes.test.js +221 -0
  125. package/server/lib/notifications/template-runtime.js +2 -3
  126. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  127. package/server/lib/openchamber-control/actions.js +78 -0
  128. package/server/lib/openchamber-control/service.js +7 -0
  129. package/server/lib/openchamber-sessions/routes.js +14 -0
  130. package/server/lib/opencode/DOCUMENTATION.md +6 -4
  131. package/server/lib/opencode/claude-cli-auth.js +60 -0
  132. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  133. package/server/lib/opencode/feature-routes-runtime.js +22 -0
  134. package/server/lib/opencode/plugins.js +12 -3
  135. package/server/lib/opencode/plugins.test.js +18 -0
  136. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  137. package/server/lib/opencode/proxy.js +116 -6
  138. package/server/lib/opencode/proxy.test.js +158 -1
  139. package/server/lib/opencode/routes.js +4 -1
  140. package/server/lib/opencode/server-startup-runtime.js +22 -1
  141. package/server/lib/opencode/server-startup-runtime.test.js +44 -0
  142. package/server/lib/opencode/settings-helpers.js +11 -0
  143. package/server/lib/opencode/settings-helpers.test.js +35 -0
  144. package/server/lib/opencode/settings-runtime.js +51 -0
  145. package/server/lib/opencode/shared.js +120 -16
  146. package/server/lib/opencode/shared.test.js +185 -1
  147. package/server/lib/project-context/DOCUMENTATION.md +158 -0
  148. package/server/lib/project-context/routes.http.test.js +264 -0
  149. package/server/lib/project-context/routes.js +237 -0
  150. package/server/lib/project-context/runtime.js +667 -0
  151. package/server/lib/project-context/runtime.test.js +498 -0
  152. package/server/lib/quota/DOCUMENTATION.md +16 -1
  153. package/server/lib/quota/providers/claude/auth.js +113 -0
  154. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  155. package/server/lib/quota/providers/claude/index.js +151 -0
  156. package/server/lib/quota/providers/claude/index.test.js +147 -0
  157. package/server/lib/quota/providers/claude/transforms.js +127 -0
  158. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  159. package/server/lib/quota/providers/command-code.js +90 -0
  160. package/server/lib/quota/providers/command-code.test.js +72 -0
  161. package/server/lib/quota/providers/index.js +22 -2
  162. package/server/lib/quota/providers/index.test.js +10 -1
  163. package/server/lib/quota/utils/formatters.js +2 -1
  164. package/server/lib/scheduled-tasks/runtime.js +21 -2
  165. package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
  166. package/server/lib/session-knowledge/routes.js +107 -0
  167. package/server/lib/session-knowledge/runtime.js +331 -0
  168. package/server/lib/session-knowledge/runtime.test.js +275 -0
  169. package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
  170. package/server/lib/skills-catalog/curated-sources.js +1 -1
  171. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  172. package/server/lib/small-model/index.js +8 -0
  173. package/server/lib/small-model/index.test.js +31 -1
  174. package/server/lib/small-model/routes.js +3 -1
  175. package/dist/assets/DiagramView-CndEcZNu.js +0 -1
  176. package/dist/assets/FilesView-CzUgIvUm.js +0 -14
  177. package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
  178. package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
  179. package/dist/assets/OnboardingScreen-BmN0lhk4.js +0 -1
  180. package/dist/assets/PlanView-CWM0iyFk.js +0 -4
  181. package/dist/assets/SessionSwitcherDropdown-Cez-9xRh.js +0 -1
  182. package/dist/assets/SettingsView-Bl1drwPw.js +0 -28
  183. package/dist/assets/SettingsWindow-DL5axjDZ.js +0 -1
  184. package/dist/assets/contextPanelEmbeddedChat-tQekJUAF.js +0 -1
  185. package/dist/assets/de-u7gSnqWs.js +0 -9
  186. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  187. package/dist/assets/es-T9O7aAOr.js +0 -15
  188. package/dist/assets/fr-Oor7ewbE.js +0 -13
  189. package/dist/assets/index-CVNuER6G.css +0 -1
  190. package/dist/assets/index-Crz1YOFl.js +0 -1
  191. package/dist/assets/index-iFY_N5aO.js +0 -7
  192. package/dist/assets/ja-DHpqbVmr.js +0 -15
  193. package/dist/assets/ko-CwLkS3nx.js +0 -15
  194. package/dist/assets/main-CAxX6DAN.js +0 -915
  195. package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
  196. package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
  197. package/dist/assets/mobile-DEmhwNcV.js +0 -2
  198. package/dist/assets/pl-CcZILN8q.js +0 -15
  199. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  200. package/dist/assets/renderElectronMiniChatApp-Dpbswpom.js +0 -2
  201. package/dist/assets/runtimeEndpointReset-cbahJ3hD.js +0 -13
  202. package/dist/assets/scheduledTasksApi-BxgGWTL8.js +0 -1
  203. package/dist/assets/uk-BA2kZR38.js +0 -15
  204. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  205. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  206. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  207. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  208. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  209. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  210. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  211. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  212. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  213. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  214. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  215. package/server/lib/quota/providers/claude.js +0 -107
@@ -0,0 +1,15 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BSvmTvZl.js","assets/useAppFontEffects-CbzHzFop.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DzriVon2.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-1OhiMDBz.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BYlZTzrw.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-BO1wRpaN.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-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-CiAYDJXN.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/vendor-zod-adaMkgkm.js","assets/computeVirtualFileMetrics-DYFv_yZS.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-Dwq6ILxo.js","assets/isDiffPlainText-DwHKxDYc.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-UvuxIl9-.js","assets/shikiHighlight-DXYW46vW.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-CegKdDXi.js","assets/CodeMirrorCommentWidgets-DAvopJvy.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 _e,r as ie,j as t,R as f}from"./vendor-react-BUCujlKS.js";import{d_ as co,aG as uo,f as Xe,o as fo,bs as Ts,bt as Ps,bv as Ds,I as E,bU as mo,bQ as Rn,h as se,B as ke,a$ as yr,g as ho,t as ve,d$ as po,e0 as go,e1 as xo,O as bo,dH as yo,e2 as wo,e3 as vo,e4 as jo,y as at,e5 as ko,d3 as No,d4 as So,d5 as Co,l as kt,e6 as Io,dj as wr,e7 as To,dk as Po,bR as Es,cN as Do,bu as Vs,aV as Gs,e8 as Eo,e9 as Ro,ea as Ao,eb as Bo,ec as Mo,ed as Lo,ee as Fo,ef as Oo,b as Ct,c0 as Uo,_ as An,dg as $o,dD as vr,ds as jr,du as Wo,eg as _o,u as hn,cq as zo,eh as pn,S as yt,cx as Vo,ei as Bn,ej as Go,ek as Ko,el as Mn,em as Ho,en as qo,eo as Yo,ep as Jo,aW as Qo,eq as Xo,aU as $t,aR as Wt,aT as _t,bP as Ks,bK as Zo,bL as ea,er as ta,bM as sa,bN as na,bO as Ln,L as kr,N as ra,T as oa,U as aa,R as ia,es as Nr,w as la,x as ca,et as da,eu as ua,ev as fa,ew as ma,aX as Kt,aY as Ht,aZ as qt,cl as gn,cm as xn,cn as bn,co as yn,ch as Ft,ci as Et,ex as ps,aQ as At,M as Ns,bw as ha,bx as Cn,ey as Fn,V as In,aj as _s,b_ as pa,ez as Sr,bS as ga,dz as xa,a4 as Tn,eA as Xs,m as Cr,cR as gs,eB as On,eC as Un,cP as $n,bT as ba,eD as ya,eE as wa,dt as va,eF as ja,eG as ka,af as Ms,ag as Wn,eH as Na,eI as Sa,dR as Dt,eJ as Ca,eK as Ia,eL as Rt,eM as wn,eN as Ta,eO as Ls,c5 as Pa,eP as Da,eQ as Ea,eR as Ra,eS as Aa,eT as Ba,eU as Ma,cA as La,ah as Fa,a0 as Oa,bI as Ua,eV as Ir,dX as $a,da as Wa,eW as _a,eX as za,eY as Va,bF as Ga,cF as Ka}from"./useAppFontEffects-CbzHzFop.js";import{ai as _n,aj as Ha,ak as zn,al as qa,i as Ya,am as Ja,E as Tr,_ as Qa,r as Bt,u as De,z as Xa,b as Za,t as ei,a as Zs,d as Vn,L as Pr,W as ti,an as Lt,o as si,m as Rs,y as Dr,a0 as ni,a1 as ri,ao as oi,ap as ai,v as xs,U as ii,aq as li,a7 as ci,ar as ws,as as en,at as Er,T as di,n as ui,x as fi}from"./index-DzriVon2.js";import{C as mi,c as hi,b as pi,d as gi,S as xi,M as bi,a as yi,g as wi,h as vi,i as ji}from"./vendor-base-ui-BYlZTzrw.js";import{c as Hs,d as Rr,p as Ar,a as ki}from"./vendor-zustand-BAGL70zf.js";import{i as Br}from"./contextPanelEmbeddedChat-BO1wRpaN.js";import{toast as Gn}from"./vendor-sonner-DFyL3AvE.js";import{f as Mr,h as Lr,P as Fr,k as Ni,D as Or,j as Ur}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as $r,S as Wr,h as Si,v as Ci,a as Ii}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as _r}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const Ti=["typescript","javascript","tsx","jsx","json","markdown"],zr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Kn=null;const Vr=()=>(Kn??=Promise.all([Gt(()=>import("./index-BSvmTvZl.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,5,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})),Kn),Ss={},Hn=new Set,vn=new Set;let $s={light:"pierre-light",dark:"pierre-dark"};const Pi=()=>{for(const s of vn)s()},Gr=(s,e)=>{e.setRenderOptions({theme:$s,lineDiffType:zr[s].lineDiffType})},jn=s=>{typeof window>"u"||Hn.has(s)||(Hn.add(s),Vr().then(e=>{if(Ss[s])return;const n=zr[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Ti,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),Ss[s]=r,Gr(s,r),Pi()}))},Di=s=>(vn.add(s),()=>vn.delete(s)),Ei=s=>{if(!($s.light===s.light&&$s.dark===s.dark)){$s=s;for(const e of Object.keys(Ss)){const n=Ss[e];n&&Gr(e,n)}}},Pu=s=>{const e=_e.c(15),{children:n}=s,r=co();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=_n(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=_n(!0),e[1]=i):i=e[1];const u=i,d=r?.lightThemeId??a.metadata.id,l=r?.darkThemeId??u.metadata.id;let c;e[2]!==d||e[3]!==r?.availableThemes?(c=r?.availableThemes.find(S=>S.metadata.id===d)??a,e[2]=d,e[3]=r?.availableThemes,e[4]=c):c=e[4];const g=c;let h;e[5]!==l||e[6]!==r?.availableThemes?(h=r?.availableThemes.find(S=>S.metadata.id===l)??u,e[5]=l,e[6]=r?.availableThemes,e[7]=h):h=e[7];const p=h;let m,y;e[8]!==p||e[9]!==g?(m=()=>{let S=!1;return Vr().then(R=>{S||(R.ensurePierreThemeRegistered(g),R.ensurePierreThemeRegistered(p),Ei({light:g.metadata.id,dark:p.metadata.id}))}),()=>{S=!0}},y=[p,g],e[8]=p,e[9]=g,e[10]=m,e[11]=y):(m=e[10],y=e[11]),ie.useEffect(m,y);let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[12]=v):v=e[12],ie.useEffect(Ai,v);let N;return e[13]!==n?(N=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=N):N=e[14],N},Du=s=>{const e=_e.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>Ss[n],e[0]=n,e[1]=r):r=e[1];const o=ie.useSyncExternalStore(Di,r,Bi);let a,i;return e[2]!==n?(a=()=>{jn(n)},i=[n],e[2]=n,e[3]=a,e[4]=i):(a=e[3],i=e[4]),ie.useEffect(a,i),o};function Ri(){jn("unified"),jn("split")}function Ai(){if(typeof window>"u")return;const s=Ri;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 Bi(){}const qn="openchamber.update-install-id";function Mi(){if(!(typeof window>"u"||typeof crypto.randomUUID!="function"))try{const s=window.localStorage.getItem(qn)?.trim();if(s)return s;const e=crypto.randomUUID();return window.localStorage.setItem(qn,e),e}catch{return}}function Li(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=uo();return s}catch{return"unknown"}}function Fi(){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 Oi(){const s=Za();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 Ui(s){const e=De.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",Li()),n.set("arch",Fi()),n.set("platform",Oi()),e&&(s==="desktop"||s==="mobile")){const r=Mi();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",Xa()?"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 Fs(s,e){try{const n=Ui(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 $i(){return Ya()?"mobile":Ja()?"desktop":Tr()?"vscode":Qa()?"web":null}const Yn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},Wi=Hs()((s,e)=>({...Yn,checkForUpdates:async()=>{const n=$i();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.19.0",[i,u]=await Promise.allSettled([zn(),Fs("desktop",a)]),d=i.status==="fulfilled"?i.value:null;return o=u.status==="fulfilled"?u.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:d?.available??!1,info:d,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Fs("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Fs("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Fs("mobile","1.19.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 zn();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 qa(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 Ha())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(Yn)}})),Jn="https://github.com/openchamber/openchamber/releases";function _i(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(yr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function zi(s){return s.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Qn(s){return s.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function Vi(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 Gi(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,u=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:u}})}const Xn=2e3,Ki=600*1e3;async function Hi(){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 qi(){try{return(await Bt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function Yi(s,e=Math.ceil(Ki/Xn),n=Xn){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 qi())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Eu=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:u,onRestart:d,runtimeType:l="desktop"})=>{const{t:c}=Xe(),[g,h]=ie.useState(!1),[p,m]=ie.useState("idle"),[y,v]=ie.useState(null),N=n?.version?n.releaseUrl||`${Jn}/tag/v${n.version}`:Jn,S=n?.downloadUrl||N,R=a?.total?Math.round(a.downloaded/a.total*100):0,$=l==="web",w=l==="mobile",k=n?.updateCommand||"openchamber update";ie.useEffect(()=>{s||(m("idle"),v(null))},[s]);const b=async()=>{(await ho(k)).ok&&(h(!0),setTimeout(()=>h(!1),2e3))},I=ie.useCallback(async F=>{await fo(F)},[]),P=ie.useCallback(async()=>{m("updating"),v(null);const F=await Hi();if(!F.success){m("error"),v(F.error||c("updateDialog.error.updateFailed"));return}F.autoRestart&&(m("restarting"),await new Promise(M=>setTimeout(M,2e3))),m("reconnecting"),await Yi(n?.currentVersion)?window.location.reload():(m("error"),v(c("updateDialog.error.takingLonger")))},[n?.currentVersion,c]),z=ie.useCallback(()=>{I(S)},[I,S]),O=p!=="idle"&&p!=="error",K=ie.useMemo(()=>{if(!n?.body)return null;const F=n.body.trim();if(!F)return null;const X=Gi(F);if(X.length===0)return{kind:"raw",title:c("updateDialog.changelog.title"),content:Qn(F)};const M=[...X].sort((ee,G)=>Vi(ee.version,G.version));return{kind:"sections",title:c("updateDialog.changelog.title"),sections:M.map(ee=>({version:ee.version,dateLabel:_i(ee.date),content:Qn(zi(ee.raw)||F)}))}},[n?.body,c]);return t.jsx(Ts,{open:s,onOpenChange:O?void 0:e,children:t.jsxs(Ps,{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(E,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),t.jsx("span",{className:"text-lg font-semibold text-foreground",children:c(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&&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(E,{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"&&c("updateDialog.status.installingUpdate"),p==="restarting"&&c("updateDialog.status.serverRestarting"),p==="reconnecting"&&c("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:c("updateDialog.status.autoReloadHint")})]}),K&&!O&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(mo,{className:"max-h-[400px] p-0",fillContainer:!1,children:K.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:F=>{const M=F.target.closest("a");M&&M.href&&(F.preventDefault(),F.stopPropagation(),I(M.href))},children:t.jsx(Rn,{content:K.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:K.sections.map(F=>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",F.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:F.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:X=>{const ee=X.target.closest("a");ee&&ee.href&&(X.preventDefault(),X.stopPropagation(),I(ee.href))},children:t.jsx(Rn,{content:F.content,disableLinkSafety:!0,enableFileReferences:!1})})]},F.version))})})}),$&&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(E,{name:"terminal",className:"h-4 w-4"}),t.jsx("span",{children:c("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:k}),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:c(g?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:g?t.jsx(E,{name:"check",className:"h-4 w-4"}):t.jsx(E,{name:"clipboard",className:"h-4 w-4"})})]})]}),!$&&!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:c("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[R,"%"]})]}),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:`${R}%`}})})]}),(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(E,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),t.jsxs("div",{className:"flex-1 flex justify-end",children:[!$&&!w&&!o&&!r&&t.jsxs("button",{onClick:u,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(E,{name:"download",className:"h-4 w-4"}),c("updateDialog.actions.downloadUpdate")]}),!$&&!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(E,{name:"loader",className:"h-4 w-4 animate-spin"}),c("updateDialog.status.downloading")]}),!$&&!w&&o&&t.jsxs("button",{onClick:d,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(E,{name:"restart",className:"h-4 w-4"}),c("updateDialog.actions.restartToUpdate")]}),w&&t.jsxs(ke,{onClick:z,size:"default",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),c("updateDialog.actions.openMobileUpdate")]}),$&&!O&&t.jsxs("button",{onClick:P,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(E,{name:"download",className:"h-4 w-4"}),c("updateDialog.actions.updateNow")]}),$&&O&&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(E,{name:"loader",className:"h-4 w-4 animate-spin"}),c("updateDialog.status.updating")]})]})]})]})})},Ru=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Ji=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),Qi=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Xi=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),ms="opencode-update-available",Os="opencode-upgrade-progress",Zi=5e3,el=[1e4,6e4],Zn="opencode-update-toast-dismissed-version",Au=()=>{const{t:s}=Xe(),e=De(i=>i.showOpenCodeUpdateNotifications),n=ie.useRef(new Set),r=ie.useRef(!1);ie.useEffect(()=>{e||ve.dismiss(ms)},[e]);const o=ie.useCallback(()=>{ve.dismiss(Os),po({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=ie.useCallback(async()=>{if(!r.current){r.current=!0,ve.dismiss(ms),ve.message(s("opencodeUpdate.toast.upgrading.title"),{id:Os,description:s("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:t.jsx(E,{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({})}),u=await i.json().catch(()=>null);if(!i.ok||u?.success===!1)throw new Error(u?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));ve.success(s("opencodeUpdate.toast.updated.title"),{id:Os,description:u?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:u.version}):s("opencodeUpdate.toast.updated.description"),duration:1/0,icon:t.jsx(E,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:s("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){ve.error(s("opencodeUpdate.toast.failed.title"),{id:Os,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return ie.useEffect(()=>{const i=h=>{if(!De.getState().showOpenCodeUpdateNotifications){ve.dismiss(ms);return}Ji({version:h,dismissedVersion:Vn().getItem(Zn),seenVersions:n.current})&&(n.current.add(h),ve.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:()=>{Vn().setItem(Zn,h),Pr({openCodeUpdateToastDismissedVersion:h}),ve.dismiss(ms)}}}))};let u=!1;const d=[],l=async(h,p=Zs())=>{try{const m=await Bt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!m.ok)throw new Error(m.statusText||"OpenCode upgrade status check failed");const y=await m.json().catch(()=>null),v=Xi(y);!u&&p===Zs()&&v&&i(v)}catch{const m=el[h];!u&&p===Zs()&&m!==void 0&&d.push(setTimeout(()=>{l(h+1,p)},m))}},c=h=>{Qi(h.detail)&&l(0)};e&&d.push(setTimeout(()=>{l(0)},Zi));const g=ei(({runtimeKey:h})=>{n.current.clear(),ve.dismiss(ms),De.getState().showOpenCodeUpdateNotifications&&l(0,h)});return window.addEventListener("openchamber:opencode-update-available",c),()=>{u=!0;for(const h of d)clearTimeout(h);g(),window.removeEventListener("openchamber:opencode-update-available",c)}},[a,e,s]),null},Bu=()=>{const s=_e.c(3),[e,n]=f.useState(tl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>xo(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),f.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(bo,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function tl(){return go()}class sl extends f.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(yo,{className:"w-full max-w-md",children:[t.jsx(wo,{className:"text-center",children:t.jsxs(vo,{className:"flex items-center justify-center gap-2 text-destructive",children:[t.jsx(E,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),t.jsxs(jo,{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(ke,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[t.jsx(E,{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 nl(s){const e=_e.c(22),{t:n}=Xe();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 u;e[8]!==n?(u=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=u):u=e[9];let d;e[10]!==n?(d=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=d):d=e[11];let l;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==u||e[17]!==d?(l={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:u,persistentHint:d},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=u,e[17]=d,e[18]=l):l=e[18];let c;return e[19]!==s||e[20]!==l?(c=t.jsx(sl,{...s,texts:l}),e[19]=s,e[20]=l,e[21]=c):c=e[21],c}const Mu=s=>{const e=_e.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,u=o===void 0?!1:o,l=at(rl)||void 0;let c;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==u?(c=t.jsx(ko,{active:i,messagesEnabled:r,readOnly:u,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=u,e[4]=c):c=e[4];let g;return e[5]!==l||e[6]!==c?(g=t.jsx(nl,{sessionId:l,children:c}),e[5]=l,e[6]=c,e[7]=g):g=e[7],g};function rl(s){return s.currentSessionId}function Lu(s){const e=_e.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(mi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Fu(s){const e=_e.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(hi,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Ou(s){const e=_e.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 u;e[6]!==o?(u=se("app-region-no-drag z-50",o),e[6]=o,e[7]=u):u=e[7];let d;e[8]!==i?(d={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=d):d=e[9];let l;e[10]!==r?(l=se(No,r),e[10]=r,e[11]=l):l=e[11];let c;e[12]!==n||e[13]!==a||e[14]!==d||e[15]!==l?(c=t.jsx(pi,{"data-slot":"dropdown-menu-content",style:d,className:l,...a,children:n}),e[12]=n,e[13]=a,e[14]=d,e[15]=l,e[16]=c):c=e[16];let g;return e[17]!==u||e[18]!==c?(g=t.jsx(bi,{children:t.jsx(yi,{className:u,children:c})}),e[17]=u,e[18]=c,e[19]=g):g=e[19],g}function Uu(s){const e=_e.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(So,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(gi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function $u(s){const e=_e.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(Co,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(xi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const ol=vi,al=s=>{const e=_e.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&&ie.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const u=i;let d;e[8]!==o?(d=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]=d):d=e[9];let l;return e[10]!==a||e[11]!==u||e[12]!==d?(l=t.jsx(wi,{className:d,...a,...u}),e[10]=a,e[11]=u,e[12]=d,e[13]=l):l=e[13],l},il=s=>{const e=_e.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(ji,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},er=s=>({providerID:s.providerID,modelID:s.modelID,variant:s.variant,agent:s.agent});function ll(s){const e=_e.c(131),{t:n}=Xe(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:u,allowRunAsGoal:d,onConfirm:l}=s,c=u===void 0?!1:u,g=d===void 0?!1:d;let h;e[0]!==g?(h=g&&!Tr(),e[0]=g,e[1]=h):h=e[1];const p=h,m=kt(yl),y=kt(bl),v=Io(xl),N=kt(gl),S=kt(pl),R=kt(hl),$=kt(ml),w=kt(fl);let k;e[2]!==w||e[3]!==R||e[4]!==S||e[5]!==$?(k=()=>er({providerID:S,modelID:R,variant:$,agent:w}),e[2]=w,e[3]=R,e[4]=S,e[5]=$,e[6]=k):k=e[6];const[b,I]=f.useState(k);let P,z;e[7]!==v||e[8]!==y||e[9]!==m||e[10]!==r||e[11]!==i?(P=()=>{r&&(m({directory:i,source:"todoSendDialog"}),y({directory:i}),v())},z=[r,m,y,v,i],e[7]=v,e[8]=y,e[9]=m,e[10]=r,e[11]=i,e[12]=P,e[13]=z):(P=e[12],z=e[13]),f.useEffect(P,z);let O,K;e[14]!==w||e[15]!==R||e[16]!==S||e[17]!==$||e[18]!==r?(O=()=>{r&&I(er({providerID:S,modelID:R,variant:$,agent:w}))},K=[r,S,R,$,w],e[14]=w,e[15]=R,e[16]=S,e[17]=$,e[18]=r,e[19]=O,e[20]=K):(O=e[19],K=e[20]),f.useEffect(O,K);let F,X;e[21]!==b.modelID||e[22]!==b.providerID||e[23]!==r||e[24]!==N?(F=()=>{if(!r||N.length===0)return;const x=N.find(Ne=>Ne.id===b.providerID)??N[0],L=Array.isArray(x?.models)?x.models:[],xe=L.some(Ne=>Ne.id===b.modelID),Be=L[0]?.id??"";x?.id===b.providerID&&xe||I(Ne=>({...Ne,providerID:x?.id??"",modelID:xe?Ne.modelID:Be,variant:""}))},X=[r,N,b.providerID,b.modelID],e[21]=b.modelID,e[22]=b.providerID,e[23]=r,e[24]=N,e[25]=F,e[26]=X):(F=e[25],X=e[26]),f.useEffect(F,X);const M=ul;let ee;if(e[27]!==b.modelID||e[28]!==b.providerID||e[29]!==N){let x;e[31]!==b.providerID?(x=xe=>xe.id===b.providerID,e[31]=b.providerID,e[32]=x):x=e[32],ee=N.find(x)?.models?.find(xe=>xe.id===b.modelID),e[27]=b.modelID,e[28]=b.providerID,e[29]=N,e[30]=ee}else ee=e[30];const G=ee;let U;e[33]!==G?(U=G?.variants?Object.keys(G.variants):[],e[33]=G,e[34]=U):U=e[34];const D=U,A=D.length>0;let W,H;e[35]!==b.variant||e[36]!==A?(W=()=>{A||!b.variant||I(dl)},H=[A,b.variant],e[35]=b.variant,e[36]=A,e[37]=W,e[38]=H):(W=e[37],H=e[38]),f.useEffect(W,H);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 _=T;let Y;e[42]!==_||e[43]!==b||e[44]!==l||e[45]!==c?(Y=()=>{!_||c||l(b)},e[42]=_,e[43]=b,e[44]=l,e[45]=c,e[46]=Y):Y=e[46];const le=Y;let te,Q;e[47]!==le||e[48]!==r?(te=()=>{if(!r)return;const x=L=>{(L.metaKey||L.ctrlKey)&&L.key==="Enter"&&(L.preventDefault(),le())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},Q=[r,le],e[47]=le,e[48]=r,e[49]=te,e[50]=Q):(te=e[49],Q=e[50]),f.useEffect(te,Q);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 J;e[54]!==o||e[55]!==c?(J=x=>{c||o(x)},e[54]=o,e[55]=c,e[56]=J):J=e[56];let ce;e[57]!==re?(ce=t.jsx(Vs,{children:t.jsx(Ds,{children:re})}),e[57]=re,e[58]=ce):ce=e[58];let oe;e[59]!==n?(oe=n("chat.modelControls.model"),e[59]=n,e[60]=oe):oe=e[60];let ae;e[61]!==oe?(ae=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:oe}),e[61]=oe,e[62]=ae):ae=e[62];let ue;e[63]===Symbol.for("react.memo_cache_sentinel")?(ue=(x,L)=>{I(xe=>({...xe,providerID:x,modelID:L,variant:""}))},e[63]=ue):ue=e[63];let he;e[64]!==b.modelID||e[65]!==b.providerID?(he=t.jsx(wr,{providerId:b.providerID,modelId:b.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ue}),e[64]=b.modelID,e[65]=b.providerID,e[66]=he):he=e[66];let j;e[67]!==ae||e[68]!==he?(j=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[ae,he]}),e[67]=ae,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 me=!A;let ne;e[74]===Symbol.for("react.memo_cache_sentinel")?(ne=x=>I(L=>({...L,variant:x})),e[74]=ne):ne=e[74];let ye;e[75]!==b.variant||e[76]!==me||e[77]!==D?(ye=t.jsx(To,{value:b.variant,options:D,disabled:me,onChange:ne}),e[75]=b.variant,e[76]=me,e[77]=D,e[78]=ye):ye=e[78];let Ie;e[79]!==Z||e[80]!==ye?(Ie=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Z,ye]}),e[79]=Z,e[80]=ye,e[81]=Ie):Ie=e[81];let Me;e[82]!==n?(Me=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=Me):Me=e[83];let Ue;e[84]!==Me?(Ue=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:Me}),e[84]=Me,e[85]=Ue):Ue=e[85];let tt;e[86]===Symbol.for("react.memo_cache_sentinel")?(tt=x=>I(L=>({...L,agent:x})),e[86]=tt):tt=e[86];let Le;e[87]!==b.agent?(Le=t.jsx(Po,{agentName:b.agent,filter:M,dropdownPortalToBody:!0,onChange:tt}),e[87]=b.agent,e[88]=Le):Le=e[88];let st;e[89]!==Ue||e[90]!==Le?(st=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[Ue,Le]}),e[89]=Ue,e[90]=Le,e[91]=st):st=e[91];let Ae;e[92]!==j||e[93]!==Ie||e[94]!==st?(Ae=t.jsxs("div",{className:"flex flex-col gap-4",children:[j,Ie,st]}),e[92]=j,e[93]=Ie,e[94]=st,e[95]=Ae):Ae=e[95];const He=`flex items-center gap-3 ${p?"justify-between":"justify-end"}`;let Fe;e[96]!==b.runAsGoal||e[97]!==p||e[98]!==c||e[99]!==n?(Fe=p?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Es,{checked:b.runAsGoal===!0,onChange:x=>I(L=>({...L,runAsGoal:x})),disabled:c,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:c,onClick:()=>I(cl),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=b.runAsGoal,e[97]=p,e[98]=c,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 Ze;e[103]!==n?(Ze=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=Ze):Ze=e[104];let $e;e[105]!==c||e[106]!==Ye||e[107]!==Ze?($e=t.jsx(ke,{variant:"ghost",size:"sm",onClick:Ye,disabled:c,children:Ze}),e[105]=c,e[106]=Ye,e[107]=Ze,e[108]=$e):$e=e[108];const Je=!_||c;let qe;e[109]!==c||e[110]!==n?(qe=n(c?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=c,e[110]=n,e[111]=qe):qe=e[111];let Ce;e[112]!==le||e[113]!==Je||e[114]!==qe?(Ce=t.jsx(ke,{size:"sm",onClick:le,disabled:Je,children:qe}),e[112]=le,e[113]=Je,e[114]=qe,e[115]=Ce):Ce=e[115];let Te;e[116]!==$e||e[117]!==Ce?(Te=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[$e,Ce]}),e[116]=$e,e[117]=Ce,e[118]=Te):Te=e[118];let ze;e[119]!==He||e[120]!==Fe||e[121]!==Te?(ze=t.jsxs("div",{className:He,children:[Fe,Te]}),e[119]=He,e[120]=Fe,e[121]=Te,e[122]=ze):ze=e[122];let Pe;e[123]!==ce||e[124]!==Ae||e[125]!==ze?(Pe=t.jsxs(Ps,{className:"max-w-md overflow-visible",children:[ce,Ae,ze]}),e[123]=ce,e[124]=Ae,e[125]=ze,e[126]=Pe):Pe=e[126];let lt;return e[127]!==r||e[128]!==J||e[129]!==Pe?(lt=t.jsx(Ts,{open:r,onOpenChange:J,children:Pe}),e[127]=r,e[128]=J,e[129]=Pe,e[130]=lt):lt=e[130],lt}function cl(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function dl(s){return{...s,variant:""}}function ul(s){return Do(s.mode)}function fl(s){return s.currentAgentName||""}function ml(s){return s.currentVariant||""}function hl(s){return s.currentModelId}function pl(s){return s.currentProviderId}function gl(s){return s.providers}function xl(s){return s.loadAgents}function bl(s){return s.loadAgents}function yl(s){return s.loadProviders}const wl=280,tr=4,vl=({transform:s})=>({...s,y:0}),jl=s=>{const e=_e.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:u,setNodeRef:d,transform:l,transition:c,isDragging:g}=$r(a);let h;e[2]!==l?(h=_r.Transform.toString(l),e[2]=l,e[3]=h):h=e[3];let p;e[4]!==h||e[5]!==c?(p={transform:h,transition:c},e[4]=h,e[5]=c,e[6]=p):p=e[6];const m=g&&"opacity-50";let y;e[7]!==o||e[8]!==m?(y=se("h-full rounded-md",o,m),e[7]=o,e[8]=m,e[9]=y):y=e[9];let v;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==u||e[14]!==d||e[15]!==p||e[16]!==y?(v=t.jsx("div",{ref:d,"data-sortable-tab-id":n,style:p,className:y,...i,...u,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=u,e[14]=d,e[15]=p,e[16]=y,e[17]=v):v=e[17],v},kl=s=>{const e=_e.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=_e.c(133),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:u,variant:d,activePillInsetClassName:l,activePillButtonClassName:c,inactiveTabsIconOnly:g,animateActivePill:h,activePillLowercase:p,nonCompositedIndicator:m,className:y}=s,v=u===void 0?"scrollable":u,N=d===void 0?"default":d,S=g===void 0?!1:g,R=p===void 0?!0:p,$=m===void 0?!1:m,{t:w}=Xe(),k=De(Nl),{isTablet:b}=Gs(),I=k||b,P=f.useRef(null);let z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z={left:!1,right:!1},e[0]=z):z=e[0];const[O,K]=f.useState(z);let F;e[1]!==n?(F=n.map(Sl),e[1]=n,e[2]=F):F=e[2];const X=F,M=v==="scrollable",ee=N==="default",G=N==="active-pill",D=G||N==="animated",A=ee,W=D||A,H=G&&M,T=D,_=h??D,Y=typeof i=="function",le=Y?jl:kl;let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te=new Map,e[3]=te):te=e[3];const Q=f.useRef(te),[q,re]=f.useState(null),[J,ce]=f.useState(!1),[oe,ae]=f.useState(null),ue=f.useRef(!1),he=f.useRef(0),j=f.useRef(r),V=f.useRef(null);let Z;e:{if(!W||!oe||!r||oe===r){Z=0;break e}const pe=n.findIndex(Oe=>Oe.id===oe),fe=n.findIndex(Oe=>Oe.id===r);if(pe<0||fe<0){Z=0;break e}Z=pe>fe?tr:-tr}const me=Z;let ne;e[4]===Symbol.for("react.memo_cache_sentinel")?(ne={activationConstraint:{distance:8}},e[4]=ne):ne=e[4];const ye=Mr(Lr(Fr,ne)),Ie=Cl;let Me;e[5]===Symbol.for("react.memo_cache_sentinel")?(Me=(pe,fe)=>{if(fe){Q.current.set(pe,fe);return}Q.current.delete(pe)},e[5]=Me):Me=e[5];const Ue=Me;let tt;e[6]!==r||e[7]!==W?(tt=()=>{if(!W||!r){re(Il);return}const pe=P.current,fe=Q.current.get(r);if(!pe||!fe){re(Tl);return}let Oe=0,ct=0,dt=fe;for(;dt&&dt!==pe;)Oe=Oe+dt.offsetLeft,ct=ct+dt.offsetTop,dt=dt.offsetParent;const vt={left:Oe,top:ct,width:fe.offsetWidth,height:fe.offsetHeight};re(St=>Ie(St,vt)?St:vt)},e[6]=r,e[7]=W,e[8]=tt):tt=e[8];const Le=tt;let st;e[9]!==M?(st=()=>{if(!M){K({left:!1,right:!1});return}const pe=P.current;if(!pe){K({left:!1,right:!1});return}K({left:pe.scrollLeft>2,right:pe.scrollLeft+pe.clientWidth<pe.scrollWidth-2})},e[9]=M,e[10]=st):st=e[10];const Ae=st;let He;e[11]!==M||e[12]!==Ae?(He=()=>{if(!M){K({left:!1,right:!1});return}const pe=P.current;if(!pe)return;Ae(),pe.addEventListener("scroll",Ae,{passive:!0});const fe=new ResizeObserver(Ae);return fe.observe(pe),()=>{pe.removeEventListener("scroll",Ae),fe.disconnect()}},e[11]=M,e[12]=Ae,e[13]=He):He=e[13];let Fe;e[14]!==M||e[15]!==n.length||e[16]!==Ae?(Fe=[M,n.length,Ae],e[14]=M,e[15]=n.length,e[16]=Ae,e[17]=Fe):Fe=e[17],f.useEffect(He,Fe);let Ye;e[18]!==r||e[19]!==Le||e[20]!==W?(Ye=()=>{if(!W){re(null);return}Le();const pe=P.current;if(!pe)return;const fe=new ResizeObserver(()=>{performance.now()-he.current>wl&&ce(!1),Le()});if(fe.observe(pe),r){const Oe=Q.current.get(r);Oe&&fe.observe(Oe)}return()=>{fe.disconnect()}},e[18]=r,e[19]=Le,e[20]=W,e[21]=Ye):Ye=e[21];let Ze;e[22]!==r||e[23]!==n.length||e[24]!==Le||e[25]!==W?(Ze=[r,n.length,Le,W],e[22]=r,e[23]=n.length,e[24]=Le,e[25]=W,e[26]=Ze):Ze=e[26],f.useEffect(Ye,Ze);let $e;e[27]!==Le?($e=()=>{Le()},e[27]=Le,e[28]=$e):$e=e[28],f.useLayoutEffect($e);let Je;e[29]!==X?(Je=X.join("\0"),e[29]=X,e[30]=Je):Je=e[30];const qe=Je;let Ce,Te;e[31]!==r||e[32]!==qe||e[33]!==W?(Ce=()=>{if(!W){ue.current=!1,ce(!1);return}const pe=V.current!==qe;if(V.current=qe,!ue.current){ue.current=!0,j.current=r;return}const fe=j.current!==r;if(j.current=r,!fe||pe){ce(!1);return}he.current=performance.now(),ce(!0)},Te=[r,qe,W],e[31]=r,e[32]=qe,e[33]=W,e[34]=Ce,e[35]=Te):(Ce=e[34],Te=e[35]),f.useLayoutEffect(Ce,Te);let ze;e[36]!==r||e[37]!==M||e[38]!==Ae?(ze=()=>{if(!M||!r)return;const pe=P.current;if(!pe)return;const fe=window.requestAnimationFrame(()=>{const Oe=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),ct=pe.querySelector(`[data-sortable-tab-id="${Oe}"]`);ct&&(ct.scrollIntoView({block:"nearest",inline:"nearest"}),Ae())});return()=>{window.cancelAnimationFrame(fe)}},e[36]=r,e[37]=M,e[38]=Ae,e[39]=ze):ze=e[39];let Pe;e[40]!==r||e[41]!==M||e[42]!==n.length||e[43]!==Ae?(Pe=[r,M,n.length,Ae],e[40]=r,e[41]=M,e[42]=n.length,e[43]=Ae,e[44]=Pe):Pe=e[44],f.useEffect(ze,Pe);let lt;e[45]!==i?(lt=pe=>{if(!i)return;const{active:fe,over:Oe}=pe;!Oe||fe.id===Oe.id||i(String(fe.id),String(Oe.id))},e[45]=i,e[46]=lt):lt=e[46];const x=lt;let L;e[47]!==y?(L=se("relative flex h-full min-w-0 flex-1",y),e[47]=y,e[48]=L):L=e[48];let xe;e[49]!==M||e[50]!==O||e[51]!==D?(xe=M&&O.left?t.jsx("div",{className:se("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",D?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=M,e[50]=O,e[51]=D,e[52]=xe):xe=e[52];let Be;e[53]!==M||e[54]!==O||e[55]!==D?(Be=M&&O.right?t.jsx("div",{className:se("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",D?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=M,e[54]=O,e[55]=D,e[56]=Be):Be=e[56];const Ne=D?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",Ke=D&&"@container/pill-tabs",Qe=D&&"pill-tabs__track",Ve=D&&(l??"gap-0.5 py-0.5"),Ee=A&&"items-center overflow-y-hidden",C=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",be=M?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Se;e[57]!==Ne||e[58]!==Ke||e[59]!==Qe||e[60]!==Ve||e[61]!==Ee||e[62]!==C||e[63]!==be?(Se=se("relative flex h-full min-w-0 flex-1",Ne,Ke,Qe,Ve,Ee,C,be),e[57]=Ne,e[58]=Ke,e[59]=Qe,e[60]=Ve,e[61]=Ee,e[62]=C,e[63]=be,e[64]=Se):Se=e[64];let Re;e[65]!==M?(Re=M?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=M,e[66]=Re):Re=e[66];let ot;e[67]!==w?(ot=w("sortableTabsStrip.aria.tabs"),e[67]=w,e[68]=ot):ot=e[68];let it;e[69]!==$||e[70]!==me||e[71]!==q||e[72]!==J||e[73]!==_||e[74]!==D?(it=D&&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)]",_&&J&&($?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:$?{left:`${q.left+me}px`,top:`${q.top}px`,width:`${q.width}px`,height:`${q.height}px`}:{transform:`translate3d(${q.left+me}px, ${q.top}px, 0)`,width:`${q.width}px`,height:`${q.height}px`}}):null,e[69]=$,e[70]=me,e[71]=q,e[72]=J,e[73]=_,e[74]=D,e[75]=it):it=e[75];let nt;e[76]!==me||e[77]!==q||e[78]!==J||e[79]!==A?(nt=A&&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)]",J&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${q.left+me}px, 0, 0)`,width:`${q.width}px`},"aria-hidden":!0}):null,e[76]=me,e[77]=q,e[78]=J,e[79]=A,e[80]=nt):nt=e[80];let mt;if(e[81]!==le||e[82]!==r||e[83]!==c||e[84]!==R||e[85]!==I||e[86]!==S||e[87]!==G||e[88]!==k||e[89]!==M||e[90]!==n||e[91]!==a||e[92]!==o||e[93]!==H||e[94]!==D||e[95]!==W){let pe;e[97]!==le||e[98]!==r||e[99]!==c||e[100]!==R||e[101]!==I||e[102]!==S||e[103]!==G||e[104]!==k||e[105]!==M||e[106]!==a||e[107]!==o||e[108]!==H||e[109]!==D||e[110]!==W?(pe=fe=>{const Oe=fe.id===r,ct=S&&D&&!Oe&&!!fe.icon,dt=!ct,vt=!!fe.icon,St=S&&D&&Oe&&!M&&!H,pt=fe.closable!==!1&&!!a,gt=pt&&!!fe.icon,jt=M||H?void 0:D?St?"flex-none basis-auto":k?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Nt=pt?ht=>{ht.button===1&&(ht.preventDefault(),ht.stopPropagation(),a?.(fe.id))}:void 0,Tt=pt?Pl:void 0;return t.jsx(le,{id:fe.id,className:jt,children:t.jsxs("div",{ref:ht=>Ue(fe.id,ht),onAuxClick:Nt,onMouseDown:Tt,className:se("group flex h-full min-w-0 flex-nowrap items-center",M||H?"shrink-0":D?"w-full":"w-full min-w-0",D?"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?fe.title??fe.label:void 0,onClick:()=>o(fe.id),onPointerDown:W?()=>{ce(!0),ae(fe.id)}:void 0,onPointerUp:W?()=>ae(null):void 0,onPointerLeave:W?()=>ae(null):void 0,onPointerCancel:W?()=>ae(null):void 0,className:se(D?"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",D&&R?"lowercase":null,D&&(ct?"gap-0":"gap-1.5"),D?H?"shrink-0 whitespace-nowrap px-3 text-center":M?"max-w-56 shrink-0 px-3 text-center":ct?"px-2 !min-w-0 text-center":St?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":M?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",D?c??(G?k?"h-[38px]":"h-[31px]":"h-7"):null,D?Oe?"text-foreground":"text-muted-foreground hover:text-foreground":null,D?"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:fe.title??fe.label,children:D?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&&(I?"opacity-0":"group-hover:opacity-0")),children:fe.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",I?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:Dl,onClick:ht=>{ht.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,dt?t.jsx("span",{className:"animated-tabs__label truncate",children:fe.label}):null]}):t.jsxs("span",{className:se("flex min-w-0 flex-nowrap items-center gap-1.5",!M&&"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&&(I?"opacity-0":"group-hover:opacity-0")),children:fe.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",I?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:El,onClick:ht=>{ht.stopPropagation(),a?.(fe.id)},"aria-label":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,t.jsx("span",{className:"truncate leading-[1.2]",children:fe.label})]})}),pt&&!gt?t.jsx("button",{type:"button",onPointerDown:Rl,onClick:ht=>{ht.stopPropagation(),a?.(fe.id)},className:se("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",D?"-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",D?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":fe.closeLabel??`Close ${fe.label} tab`,title:fe.closeLabel??`Close ${fe.label} tab`,children:t.jsx(E,{name:"close",className:"h-3 w-3"})}):null]})},fe.id)},e[97]=le,e[98]=r,e[99]=c,e[100]=R,e[101]=I,e[102]=S,e[103]=G,e[104]=k,e[105]=M,e[106]=a,e[107]=o,e[108]=H,e[109]=D,e[110]=W,e[111]=pe):pe=e[111],mt=n.map(pe),e[81]=le,e[82]=r,e[83]=c,e[84]=R,e[85]=I,e[86]=S,e[87]=G,e[88]=k,e[89]=M,e[90]=n,e[91]=a,e[92]=o,e[93]=H,e[94]=D,e[95]=W,e[96]=mt}else mt=e[96];let We;e[112]!==Se||e[113]!==Re||e[114]!==ot||e[115]!==it||e[116]!==nt||e[117]!==mt?(We=t.jsxs("div",{ref:P,className:Se,style:Re,role:"tablist","aria-label":ot,children:[it,nt,mt]}),e[112]=Se,e[113]=Re,e[114]=ot,e[115]=it,e[116]=nt,e[117]=mt,e[118]=We):We=e[118];let ut;e[119]!==L||e[120]!==xe||e[121]!==Be||e[122]!==We?(ut=t.jsxs("div",{className:L,children:[xe,Be,We]}),e[119]=L,e[120]=xe,e[121]=Be,e[122]=We,e[123]=ut):ut=e[123];const B=ut;if(!Y)return B;let de;e[124]===Symbol.for("react.memo_cache_sentinel")?(de=[vl],e[124]=de):de=e[124];let ge;e[125]!==X||e[126]!==B?(ge=t.jsx(Wr,{items:X,strategy:Si,children:B}),e[125]=X,e[126]=B,e[127]=ge):ge=e[127];let Ge;e[128]===Symbol.for("react.memo_cache_sentinel")?(Ge=t.jsx(Ni,{dropAnimation:null}),e[128]=Ge):Ge=e[128];let we;return e[129]!==x||e[130]!==ye||e[131]!==ge?(we=t.jsxs(Or,{sensors:ye,collisionDetection:Ur,onDragEnd:x,modifiers:de,children:[ge,Ge]}),e[129]=x,e[130]=ye,e[131]=ge,e[132]=we):we=e[132],we};function Nl(s){return s.isMobile}function Sl(s){return s.id}function Cl(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 Il(s){return s===null?s:null}function Tl(s){return s===null?s:null}function Pl(s){s.button===1&&s.preventDefault()}function Dl(s){s.stopPropagation()}function El(s){s.stopPropagation()}function Rl(s){s.stopPropagation()}const Vt=Hs()(Rr(Ar((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 Lo();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 Mo();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 Bo();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=si()?.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 Pr({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 Ao(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 Ro(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 Eo(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:ti(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=Vt);const Is=Fo,Ot=s=>{const e=_e.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:u,children:d,className:l,contentClassName:c,divider:g}=s,h=g===void 0?!0:g;let p;return e[0]!==d||e[1]!==l||e[2]!==c||e[3]!==r||e[4]!==h||e[5]!==u||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(p=t.jsx(Oo,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:u,divider:h,className:l,contentClassName:c,children:d}),e[0]=d,e[1]=l,e[2]=c,e[3]=r,e[4]=h,e[5]=u,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=p):p=e[10],p},Al=450,Bl=({projectRef:s=null,sections:e="all"})=>{const{t:n}=Xe(),{isMobile:r,isTablet:o}=Gs(),a=r||o,i=Ct(T=>T.getActiveProject()),u=s?.path??i?.path??null,d=at(T=>T.getWorktreeMetadata),l=Uo(),c=Rs(T=>T.homeDirectory),[g,h]=f.useState([]),[p,m]=f.useState(!1),[y,v]=f.useState(!1),[N,S]=f.useState(null),[R,$]=f.useState(null),[w,k]=f.useState([]),[b,I]=f.useState(!1),P=f.useRef(!1),z=f.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!u?null:{id:i.id,path:u},[i?.id,u,s?.id,s?.path]),O=f.useCallback(async()=>{if(!(!z||R===!1))try{const T=await An(z);k(T)}catch{}},[z,R]);f.useEffect(()=>{if(!u)return;let T=!1;return $(null),(async()=>{try{const _=await $o(u);if(T)return;$(_)}catch{}})(),()=>{T=!0}},[u]),f.useEffect(()=>{if(!z){k([]),I(!1);return}if(R===!1){k([]),I(!1);return}let T=!1;return I(!0),k([]),(async()=>{try{const _=await An(z);if(T)return;k(_)}catch{}finally{T||I(!1)}})(),()=>{T=!0}},[z,R]),f.useEffect(()=>{if(!z)return;let T=!1;return v(!0),(async()=>{try{const[_,Y]=await Promise.all([vr(z),jr(z)]);if(!T){const le=_.length>0?_:[""];h(le),S(JSON.stringify(le)),m(Y)}}catch{T||(h([""]),S(JSON.stringify([""])),m(!1))}finally{T||v(!1)}})(),()=>{T=!0}},[z]);const K=f.useCallback(async T=>{if(!z)return!1;const _=T.filter(Y=>Y.trim().length>0);try{return await Wo(z,_)?(S(JSON.stringify(T)),!0):(ve.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1)}catch{return ve.error(n("settings.openchamber.worktrees.setup.toast.saveFailed")),!1}},[z,n]),F=f.useMemo(()=>N===null?!1:N!==JSON.stringify(g),[N,g]);f.useEffect(()=>{if(!F||y||P.current)return;const T=window.setTimeout(()=>{P.current||(P.current=!0,(async()=>{try{await K(g)}finally{P.current=!1}})())},Al);return()=>{window.clearTimeout(T)}},[F,y,K,g]);const X=f.useCallback((T,_)=>{h(Y=>{const le=[...Y];return le[T]=_,le})},[]),M=f.useCallback(()=>{h(T=>[...T,""])},[]),ee=f.useCallback(T=>{h(_=>{const Y=_.filter((le,te)=>te!==T);return Y.length>0?Y:[""]})},[]),G=f.useCallback(()=>{!F||P.current||(P.current=!0,(async()=>{try{await K(g)}finally{P.current=!1}})())},[F,K,g]),U=f.useCallback(T=>{m(T),z&&_o(z,T)},[z]),D=f.useCallback(T=>{const _=oe=>oe.replace(/\\/g,"/").replace(/\/+$/,""),Y=_(T.path),le=l.filter(oe=>{const ae=d(oe.id);if(ae?.path&&_(ae.path)===Y)return!0;const ue=oe.directory;return!!(ue&&_(ue)===Y)}),te=new Set(le.map(oe=>oe.id)),Q=[...hn.getState().activeSessions,...hn.getState().archivedSessions],q=oe=>{const ae=Q.filter(he=>{const j=he.parentID;return j&&oe.has(j)});if(ae.length===0)return[];const ue=new Set(ae.map(he=>he.id));return[...ae,...q(ue)]},re=q(te),J=new Set,ce=[...le,...re].filter(oe=>J.has(oe.id)?!1:(J.add(oe.id),!0));zo.requestDelete({sessions:ce,mode:"worktree",worktree:T})},[l,d]),A=f.useMemo(()=>l.map(T=>T.id).join(","),[l]);f.useEffect(()=>{R&&u&&O()},[A,R,u,O]);const W=t.jsxs(pn,{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")]}),H=t.jsx(pn,{children:n("settings.openchamber.worktrees.list.tooltip")});return u?R===!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",Is),children:[g.map((T,_)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(yt,{value:T,onChange:Y=>X(_,Y.target.value),onBlur:G,placeholder:n("settings.openchamber.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(ke,{type:"button",variant:"ghost",size:"icon",onClick:()=>ee(_),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(E,{name:"close",className:"h-4 w-4"})})]},_)),t.jsxs(ke,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:M,children:[t.jsx(E,{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(Es,{checked:p,onChange:U,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:H,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"&&Is),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:Vo(T.path,c)})]}),t.jsx("button",{type:"button",onClick:()=>D(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(E,{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")})})},sr=(s,e)=>e.updatedAtMs-s.updatedAtMs,nr=Hs((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([qo(),Mn()]),o={};for(const a of r.sort(sr))o[a.id]=a;e().listenerReady||await Yo(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 Ho();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await Mn(),r={};for(const o of n.sort(sr))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 Ko({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=Jo(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Bn(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 Go(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 Bn(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})})),Kr=[{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"}],Hr=Object.fromEntries(Kr.map(s=>[s.key,s.Icon])),Ml="openchamber:project-actions-updated",Ll=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},Wu=(s,e)=>`${Ll(s)}::${e}`,Fl=s=>{const e=s.trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},rr=s=>{if(typeof s!="number"||!Number.isFinite(s))return null;const e=Math.round(s);return e<1||e>65535?null:e},Ol=(s,e)=>{if(!e.enabled||e.type!=="local")return null;const n=rr(e.localPort),r=rr(e.remotePort);if(!n||!r)return null;const o=Fl(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}`}},qr=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=Ol(n,r);o&&e.push(o)}return e},_u=(s,e)=>{const n=(s||"").trim();return n&&qr(e).find(a=>a.id===n)?.url||null},Ul=450,$l=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,Wl=()=>({id:$l(),name:"",command:"",icon:"play"}),_l=({projectRef:s})=>{const{t:e}=Xe(),n=f.useMemo(()=>Dr(),[]),r=nr(k=>k.instances),o=nr(k=>k.load),[a,i]=f.useState([]),[u,d]=f.useState(!1),[l,c]=f.useState(null),[g,h]=f.useState({}),p=f.useRef(!1),m=f.useRef(null);f.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),f.useEffect(()=>{let k=!1;return d(!0),(async()=>{try{const b=await Qo(s);if(k)return;i(b.actions),c(JSON.stringify({actions:b.actions}))}catch{if(k)return;i([]),c(JSON.stringify({actions:[]}))}finally{k||d(!1)}})(),()=>{k=!0}},[s]);const y=f.useMemo(()=>n?qr(r):[],[r,n]),v=f.useMemo(()=>a.some(b=>b.name.trim().length===0||b.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),N=f.useMemo(()=>l===null?!1:l!==JSON.stringify({actions:a}),[a,l]),S=f.useCallback(async k=>await Xo(s,{actions:k,primaryActionId:null})?(c(JSON.stringify({actions:k})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(Ml,{detail:{projectId:s.id}})),!0):(ve.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);f.useEffect(()=>{if(!N||u||v||p.current)return;const k=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await S(a)}finally{p.current=!1}})())},Ul);return()=>{window.clearTimeout(k)}},[a,N,u,S,v]),f.useEffect(()=>{if(!N||!v||u){v||(m.current=null);return}const k=window.setTimeout(()=>{m.current!==v&&(m.current=v,ve.error(v))},1e3);return()=>{window.clearTimeout(k)}},[N,u,v]);const R=f.useCallback(()=>{const k=Wl();i(b=>[...b,k]),h(b=>({...b,[k.id]:!0}))},[]),$=f.useCallback(k=>{i(b=>b.filter(I=>I.id!==k)),h(b=>{const I={...b};return delete I[k],I})},[]),w=f.useCallback((k,b)=>{i(I=>I.map(P=>P.id===k?b(P):P))},[]);return t.jsxs(Ot,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(ke,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:R,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[u?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",Is),children:a.map(k=>{const b=k.icon||"play",I=Hr[b]||"play",P=g[k.id]??!1,z=k.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(ol,{open:P,onOpenChange:O=>{h(K=>({...K,[k.id]:O}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(al,{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:[P?t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):t.jsx(E,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),t.jsx(E,{name:I,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:z})})]}),t.jsx(ke,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>$(k.id),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(il,{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(E,{name:I,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:Kr.map(O=>{const K=O.Icon,F=(k.icon||"play")===O.key;return t.jsx("button",{type:"button",onClick:()=>w(k.id,X=>({...X,icon:O.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)]",F&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:O.label}),children:t.jsx(E,{name:K,className:"h-4 w-4"})},O.key)})})})]}),t.jsx(yt,{value:k.name,onChange:O=>w(k.id,K=>({...K,name:O.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:k.command,onChange:O=>w(k.id,K=>({...K,command:O.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":k.autoOpenUrl===!0,onClick:()=>w(k.id,O=>({...O,...O.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:O=>{(O.key===" "||O.key==="Enter")&&(O.preventDefault(),w(k.id,K=>({...K,...K.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Es,{checked:k.autoOpenUrl===!0,onChange:O=>w(k.id,K=>({...K,...O?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:z})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),k.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(yt,{value:k.openUrl||"",onChange:O=>w(k.id,K=>({...K,openUrl:O.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(pn,{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(Zo,{value:k.desktopOpenSshForward&&y.some(O=>O.id===k.desktopOpenSshForward)?k.desktopOpenSshForward:"__none__",onValueChange:O=>{w(k.id,K=>({...K,...O==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:O}}))},children:[t.jsx(ea,{size:ta,className:"w-full",children:t.jsx(sa,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(na,{children:[t.jsx(Ln,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),y.map(O=>t.jsx(Ln,{value:O.id,children:O.label},O.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},k.id)})}),v&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:v}):null]})},zl=s=>{const e=_e.c(123),{form:n}=s,{t:r}=Xe(),{currentTheme:o}=kr(),{name:a,setName:i,icon:u,setIcon:d,color:l,setColor:c,iconBackground:g,setIconBackground:h,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:y,isRemovingCustomIcon:v,isDiscoveringIcon:N,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:R,pendingUploadIconPreviewUrl:$,setPreviewImageFailed:w,hasPendingUploadImageIcon:k,hasCustomIcon:b,effectiveHasImageIcon:I,hasRemovableImageIcon:P,showImagePreview:z,fileInputRef:O,handleUploadIcon:K,handleRemoveImageIcon:F,handleDiscoverIcon:X,currentIconImage:M,project:ee}=n;if(!ee)return null;const G=l?ra[l]??null:null;let U;e[0]!==r?(U=r("settings.projects.page.field.projectName"),e[0]=r,e[1]=U):U=e[1];let D;e[2]!==i?(D=Pe=>i(Pe.target.value),e[2]=i,e[3]=D):D=e[3];let A;e[4]!==r?(A=r("settings.projects.page.field.projectNamePlaceholder"),e[4]=r,e[5]=A):A=e[5];let W;e[6]===Symbol.for("react.memo_cache_sentinel")?(W=se("h-8 rounded-md px-3",Is),e[6]=W):W=e[6];let H;e[7]!==a||e[8]!==D||e[9]!==A?(H=t.jsx(yt,{value:a,onChange:D,placeholder:A,className:W}),e[7]=a,e[8]=D,e[9]=A,e[10]=H):H=e[10];let T;e[11]!==U||e[12]!==H?(T=t.jsx(Ot,{title:U,settingsItem:"projects.name",divider:!1,children:H}),e[11]=U,e[12]=H,e[13]=T):T=e[13];let _;e[14]!==r?(_=r("settings.projects.page.field.defaultModel"),e[14]=r,e[15]=_):_=e[15];let Y;e[16]!==r?(Y=r("settings.projects.page.field.defaultModelDescription"),e[16]=r,e[17]=Y):Y=e[17];const le=p.providerId,te=p.modelId;let Q;e[18]===Symbol.for("react.memo_cache_sentinel")?(Q=se("h-8 min-h-8 rounded-md px-3 max-w-48",Is),e[18]=Q):Q=e[18];let q;e[19]!==m||e[20]!==p.modelId||e[21]!==p.providerId?(q=t.jsx(wr,{providerId:le,modelId:te,onChange:m,className:Q}),e[19]=m,e[20]=p.modelId,e[21]=p.providerId,e[22]=q):q=e[22];let re;e[23]!==q||e[24]!==_||e[25]!==Y?(re=t.jsx(Ot,{title:_,info:Y,settingsItem:"projects.default-model",children:q}),e[23]=q,e[24]=_,e[25]=Y,e[26]=re):re=e[26];let J;e[27]!==r?(J=r("settings.projects.page.field.accentColor"),e[27]=r,e[28]=J):J=e[28];let ce;e[29]!==c?(ce=()=>c(null),e[29]=c,e[30]=ce):ce=e[30];const oe=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let ae;e[31]!==oe?(ae=se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",oe),e[31]=oe,e[32]=ae):ae=e[32];let ue;e[33]!==r?(ue=r("settings.projects.page.field.none"),e[33]=r,e[34]=ue):ue=e[34];let he;e[35]===Symbol.for("react.memo_cache_sentinel")?(he=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[35]=he):he=e[35];let j;e[36]!==ce||e[37]!==ae||e[38]!==ue?(j=t.jsx("button",{type:"button",onClick:ce,className:ae,title:ue,children:he}),e[36]=ce,e[37]=ae,e[38]=ue,e[39]=j):j=e[39];let V;e[40]!==l||e[41]!==c?(V=oa.map(Pe=>t.jsx("button",{type:"button",onClick:()=>c(Pe.key),className:se("h-7 w-7 rounded-md border transition-colors",l===Pe.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:Pe.cssVar},title:Pe.label},Pe.key)),e[40]=l,e[41]=c,e[42]=V):V=e[42];let Z;e[43]!==j||e[44]!==V?(Z=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[j,V]}),e[43]=j,e[44]=V,e[45]=Z):Z=e[45];let me;e[46]!==J||e[47]!==Z?(me=t.jsx(Ot,{title:J,settingsItem:"projects.accent-color",children:Z}),e[46]=J,e[47]=Z,e[48]=me):me=e[48];let ne;e[49]!==r?(ne=r("settings.projects.page.field.projectIcon"),e[49]=r,e[50]=ne):ne=e[50];let ye;e[51]!==K?(ye=Pe=>{const lt=Pe.target.files?.[0]??null;K(lt),Pe.currentTarget.value=""},e[51]=K,e[52]=ye):ye=e[52];let Ie;e[53]!==O||e[54]!==ye?(Ie=t.jsx("input",{ref:O,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:ye}),e[53]=O,e[54]=ye,e[55]=Ie):Ie=e[55];let Me;e[56]!==d?(Me=()=>d(null),e[56]=d,e[57]=Me):Me=e[57];const Ue=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let tt;e[58]!==Ue?(tt=se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Ue),e[58]=Ue,e[59]=tt):tt=e[59];let Le;e[60]!==r?(Le=r("settings.projects.page.field.none"),e[60]=r,e[61]=Le):Le=e[61];let st;e[62]===Symbol.for("react.memo_cache_sentinel")?(st=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[62]=st):st=e[62];let Ae;e[63]!==Me||e[64]!==tt||e[65]!==Le?(Ae=t.jsx("button",{type:"button",onClick:Me,className:tt,title:Le,children:st}),e[63]=Me,e[64]=tt,e[65]=Le,e[66]=Ae):Ae=e[66];let He;e[67]!==G||e[68]!==u||e[69]!==d?(He=aa.map(Pe=>{const lt=Pe.Icon;return t.jsx("button",{type:"button",onClick:()=>d(Pe.key),className:se("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",u===Pe.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:Pe.label,children:t.jsx(E,{name:lt,className:"w-4 h-4",style:G&&u===Pe.key?{color:G}:void 0})},Pe.key)}),e[67]=G,e[68]=u,e[69]=d,e[70]=He):He=e[70];let Fe;e[71]!==Ae||e[72]!==He?(Fe=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ae,He]}),e[71]=Ae,e[72]=He,e[73]=Fe):Fe=e[73];let Ye;e[74]!==M||e[75]!==o||e[76]!==I||e[77]!==k||e[78]!==g||e[79]!==$||e[80]!==ee||e[81]!==w||e[82]!==z||e[83]!==r?(Ye=I&&z&&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:g?{backgroundColor:g}:void 0,children:k&&$?t.jsx("img",{src:$,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>w(!0)}):t.jsx(ia,{project:{...ee,iconImage:M??ee.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>w(!0)})})})]}),e[74]=M,e[75]=o,e[76]=I,e[77]=k,e[78]=g,e[79]=$,e[80]=ee,e[81]=w,e[82]=z,e[83]=r,e[84]=Ye):Ye=e[84];let Ze;e[85]!==I||e[86]!==g||e[87]!==h||e[88]!==r?(Ze=I&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:g??"#000000",onChange:Pe=>h(Pe.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:g??"",onChange:Pe=>h(Pe.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(ke,{type:"button",size:"xs",variant:"outline",onClick:()=>h(null),className:"h-7 w-7 p-0","aria-label":r("settings.projects.page.field.clearIconBackgroundAria"),title:r("settings.projects.page.field.clearBackground"),disabled:!g,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),e[85]=I,e[86]=g,e[87]=h,e[88]=r,e[89]=Ze):Ze=e[89];let $e;e[90]!==O||e[91]!==X||e[92]!==b||e[93]!==N||e[94]!==y||e[95]!==r?($e=!b&&t.jsxs(t.Fragment,{children:[t.jsx(ke,{size:"xs",className:"h-6 !font-normal",onClick:()=>O.current?.click(),disabled:y,children:r(y?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(ke,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{X()},disabled:N,children:r(N?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[90]=O,e[91]=X,e[92]=b,e[93]=N,e[94]=y,e[95]=r,e[96]=$e):$e=e[96];let Je;e[97]!==F||e[98]!==P||e[99]!==v||e[100]!==r?(Je=P&&t.jsx(ke,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{F()},disabled:v,children:r(v?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[97]=F,e[98]=P,e[99]=v,e[100]=r,e[101]=Je):Je=e[101];let qe;e[102]!==v||e[103]!==S||e[104]!==R||e[105]!==r?(qe=S&&t.jsx(ke,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>R(!1),disabled:v,children:r("settings.projects.page.actions.undoRemove")}),e[102]=v,e[103]=S,e[104]=R,e[105]=r,e[106]=qe):qe=e[106];let Ce;e[107]!==$e||e[108]!==Je||e[109]!==qe?(Ce=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[$e,Je,qe]}),e[107]=$e,e[108]=Je,e[109]=qe,e[110]=Ce):Ce=e[110];let Te;e[111]!==ne||e[112]!==Ie||e[113]!==Fe||e[114]!==Ye||e[115]!==Ze||e[116]!==Ce?(Te=t.jsxs(Ot,{title:ne,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Ie,Fe,Ye,Ze,Ce]}),e[111]=ne,e[112]=Ie,e[113]=Fe,e[114]=Ye,e[115]=Ze,e[116]=Ce,e[117]=Te):Te=e[117];let ze;return e[118]!==re||e[119]!==me||e[120]!==Te||e[121]!==T?(ze=t.jsxs(t.Fragment,{children:[T,re,me,Te]}),e[118]=re,e[119]=me,e[120]=Te,e[121]=T,e[122]=ze):ze=e[122],ze},Vl=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Gl=s=>{if(!s)return null;const e=s.trim();return e&&Vl.test(e)?e.toLowerCase():null},Kl=s=>{const{t:e}=Xe(),n=Ct(J=>J.uploadProjectIcon),r=Ct(J=>J.removeProjectIcon),o=Ct(J=>J.discoverProjectIcon),a=Ct(J=>s?J.projects.find(ce=>ce.id===s.id)?.iconImage??null:null),[i,u]=f.useState(""),[d,l]=f.useState(null),[c,g]=f.useState(null),[h,p]=f.useState(null),[m,y]=f.useState(void 0),[v,N]=f.useState(!1),[S,R]=f.useState(!1),[$,w]=f.useState(!1),[k,b]=f.useState(!1),[I,P]=f.useState(null),[z,O]=f.useState(null),[K,F]=f.useState(!1),X=f.useRef(null),M=f.useCallback(()=>{P(null),O(J=>(J&&URL.revokeObjectURL(J),null))},[]),ee=s?.id??null;f.useEffect(()=>{if(!s){u(""),l(null),g(null),p(null),y(void 0);return}u(s.label??""),l(s.icon??null),g(s.color??null),p(s.iconBackground??null),y(s.defaultModel),b(!1),M(),F(!1)},[s,M]),f.useEffect(()=>()=>{M()},[M]);const G=f.useMemo(()=>Nr(m)??{providerId:"",modelId:""},[m]),U=!!s?.iconImage,D=!!(I&&z),A=s?.iconImage?.source==="custom",W=U&&!k||D,H=W,T=!!(s&&U&&!k),_=!K&&(D||T),Y=!!s&&(i.trim()!==(s?.label??"").trim()||d!==(s?.icon??null)||c!==(s?.color??null)||h!==(s?.iconBackground??null)||(m??void 0)!==(s?.defaultModel??void 0)||k||!!I),le=f.useCallback((J,ce)=>{y(J&&ce?`${J}/${ce}`:void 0)},[]),te=f.useCallback(J=>{!s||!J||v||(b(!1),F(!1),P(J),O(ce=>(ce&&URL.revokeObjectURL(ce),URL.createObjectURL(J))))},[v,s]),Q=f.useCallback(()=>{!s||!H||S||(D&&M(),b(!!U),F(!1))},[M,D,H,U,S,s]),q=f.useCallback(async()=>{if(!(!s||$)){M(),b(!1),F(!1),w(!0);try{const J=await o(s.id);if(!J.ok){ve.error(J.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(J.skipped){ve.success(e("settings.projects.page.toast.customIconAlreadySet"));return}ve.success(e("settings.projects.page.toast.iconDiscovered"))}finally{w(!1)}}},[M,o,$,s,e]),re=f.useCallback(async J=>{const ce=J?.silent===!0;if(!s)return null;const oe=i.trim();if(!oe)return null;if(I){N(!0);const ue=await n(s.id,I);if(N(!1),!ue.ok)return ve.error(ue.error||e("settings.projects.page.toast.uploadIconFailed")),null;ce||ve.success(e("settings.projects.page.toast.iconUpdated")),M(),b(!1)}const ae=k&&!!s.iconImage;if(ae){R(!0);const ue=await r(s.id);if(R(!1),!ue.ok)return ve.error(ue.error||e("settings.projects.page.toast.removeIconFailed")),null;ce||ve.success(e("settings.projects.page.toast.iconRemoved")),b(!1),p(null)}return{label:oe,icon:d,color:c,iconBackground:Gl(ae?null:h),defaultModel:m??null}},[M,c,m,d,h,i,k,I,s,r,e,n]);return f.useEffect(()=>{F(!1)},[ee,a?.updatedAt]),{name:i,setName:u,icon:d,setIcon:l,color:c,setColor:g,iconBackground:h,setIconBackground:p,defaultModel:m,parsedDefaultModel:G,handleDefaultModelChange:le,isUploadingIcon:v,isRemovingCustomIcon:S,isDiscoveringIcon:$,pendingRemoveImageIcon:k,setPendingRemoveImageIcon:b,pendingUploadIconFile:I,pendingUploadIconPreviewUrl:z,previewImageFailed:K,setPreviewImageFailed:F,hasStoredImageIcon:U,hasPendingUploadImageIcon:D,hasCustomIcon:A,effectiveHasImageIcon:W,hasRemovableImageIcon:H,showStoredImagePreview:T,showImagePreview:_,fileInputRef:X,clearPendingUploadIcon:M,handleUploadIcon:te,handleRemoveImageIcon:Q,handleDiscoverIcon:q,hasChanges:Y,prepareSaveData:re,currentIconImage:a,project:s}},Hl=450,ql=(s,e)=>{const{t:n}=Xe(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:u,defaultModel:d,pendingRemoveImageIcon:l,pendingUploadIconFile:c,isUploadingIcon:g,isRemovingCustomIcon:h,prepareSaveData:p}=s,m=f.useRef(!1);f.useEffect(()=>{if(!r||!o.trim()||g||h||m.current)return;const y=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{const v=await p({silent:!0});if(v)try{await e(v)}catch{ve.error(n("settings.projects.page.toast.saveFailed"))}}finally{m.current=!1}})())},Hl);return()=>{window.clearTimeout(y)}},[i,d,r,a,u,h,g,o,e,l,c,p,n])},zu=s=>{const e=_e.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=Kl(n);let u;e:{if(!n){u=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],u=y}const d=u;let l;if(e[3]!==r?(l=async y=>{await r(y)},e[3]=r,e[4]=l):l=e[4],ql(i,l),!n||!d)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]!==d?(h=t.jsx(_l,{projectRef:d}),e[7]=d,e[8]=h):h=e[8];let p;e[9]!==d||e[10]!==a?(p=a?t.jsx(Bl,{projectRef:d}):null,e[9]=d,e[10]=a,e[11]=p):p=e[11];let m;return e[12]!==g||e[13]!==h||e[14]!==p?(m=t.jsxs("div",{className:"space-y-0",children:[g,h,p]}),e[12]=g,e[13]=h,e[14]=p,e[15]=m):m=e[15],m},Vu=s=>{const e=_e.c(17),{percent:n,tonePercent:r,className:o}=s;let a;e[0]!==n?(a=la(n)??0,e[0]=n,e[1]=a):a=e[1];const i=a,u=r??n;let d;e[2]!==u?(d=ca(u),e[2]=u,e[3]=d):d=e[3];const l=d;let c;e[4]!==l?(c=l==="critical"?{backgroundColor:"var(--status-error)"}:l==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=l,e[5]=c):c=e[5];const g=c;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 m;e[8]!==g||e[9]!==p?(m={...g,width:p},e[8]=g,e[9]=p,e[10]=m):m=e[10];let y;e[11]!==i||e[12]!==m?(y=t.jsx("div",{className:"h-full transition-all duration-300",style:m,role:"progressbar","aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),e[11]=i,e[12]=m,e[13]=y):y=e[13];let v;return e[14]!==h||e[15]!==y?(v=t.jsx("div",{className:h,children:y}),e[14]=h,e[15]=y,e[16]=v):v=e[16],v},Yr=()=>{const s=da();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},Gu=()=>{const s=_e.c(2),[e,n]=f.useState(Yl);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(Yr())};i();for(const u of a)typeof u.addEventListener=="function"?u.addEventListener("change",i):typeof u.addListener=="function"&&u.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const u of a)typeof u.removeEventListener=="function"?u.removeEventListener("change",i):typeof u.removeListener=="function"&&u.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),f.useEffect(r,o),e};function Yl(){return Yr()}const Jl=[{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"]}],Ql={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Xl(s){const e=s.trim().toLowerCase();return Jl.find(n=>n.slug===e)??null}function Zl(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Ql[e];if(n)return n;const r=Xl(e);return r?r.slug:"home"}function Ku(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 ec=["chat","git","diff","terminal","files","diagram"],tc=["settings","agents","commands","skills","providers","usage","git-identities"],It={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function or(s){const e=sc();return{sessionId:nc(e),tab:rc(e),settingsPath:oc(e),diffFile:ac(e)}}function sc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function nc(s){const e=s.get(It.SESSION);return!e||e.trim().length===0?null:e.trim()}function rc(s){const e=s.get(It.TAB);if(!e)return null;const n=e.toLowerCase().trim();return ec.includes(n)?n:null}function oc(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":(tc.includes(n),n)}function ac(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 ar(){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 ic="chat";function Jr(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!==ic&&e.set(It.TAB,s.tab),s.tab==="diff"&&s.diffFile&&s.diffFile.trim().length>0&&e.set(It.FILE,s.diffFile),e}function lc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function cc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=Jr(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 ir(s,e={}){if(!(typeof window>"u")&&!(dc()||Br())&&!(!e.force&&cc(s)))try{const n=Jr(s),r=lc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function dc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function uc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function Hu(){const s=f.useMemo(()=>uc(),[]),e=f.useMemo(()=>Br(),[]),n=f.useRef(!1),r=f.useRef(!1),o=at(h=>h.setCurrentSession),a=De(h=>h.setActiveMainTab),i=De(h=>h.setSettingsDialogOpen),u=De(h=>h.setSettingsPage),d=De(h=>h.navigateToDiff),l=f.useCallback(async h=>{if(!r.current){r.current=!0;try{if(h.sessionId){const p=at.getState().currentSessionId;if(h.sessionId!==p){const m=at.getState().getDirectoryForSession(h.sessionId);o(h.sessionId,m)}}if(h.settingsPath){u(Zl(h.settingsPath)),i(!0);return}De.getState().isSettingsDialogOpen&&i(!1),h.tab&&a(h.tab),h.diffFile&&(h.tab==="diff"||!h.tab)&&d(h.diffFile)}finally{r.current=!1}}},[o,a,i,u,d]),c=f.useCallback(()=>{const h=at.getState(),p=De.getState();return{sessionId:h.currentSessionId,tab:p.activeMainTab,isSettingsOpen:p.isSettingsDialogOpen,settingsPath:p.settingsPage,diffFile:p.pendingDiffFile}},[]),g=f.useCallback((h={})=>{if(s||e||r.current)return;const p=c();ir(p,h)},[s,e,c]);f.useEffect(()=>{if(n.current||(n.current=!0,!ar()))return;const h=or();(async()=>(await l(h),!s&&!e&&ir({...c(),sessionId:h.sessionId??at.getState().currentSessionId,tab:h.tab??De.getState().activeMainTab,settingsPath:h.settingsPath??De.getState().settingsPage,diffFile:h.diffFile??De.getState().pendingDiffFile},{replace:!0,force:!0})))()},[l,c,s,e]),f.useEffect(()=>{if(s||e)return;let h=at.getState().currentSessionId;return at.subscribe(m=>{const y=m.currentSessionId;y===h||r.current||(h=y,g())})},[s,e,g]),f.useEffect(()=>{if(s||e)return;let h=De.getState().activeMainTab,p=De.getState().isSettingsDialogOpen,m=De.getState().settingsPage,y=De.getState().pendingDiffFile;return De.subscribe(N=>{if(r.current)return;const S=N.activeMainTab!==h,R=N.isSettingsDialogOpen!==p,$=N.settingsPage!==m,w=N.pendingDiffFile!==y&&N.activeMainTab==="diff";h=N.activeMainTab,p=N.isSettingsDialogOpen,m=N.settingsPage,y=N.pendingDiffFile,(S||R||$||w)&&g()})},[s,e,g]),f.useEffect(()=>{if(typeof window>"u"||s||e)return;const h=()=>{const p=or();if(ar())l(p);else{const m=De.getState();m.isSettingsDialogOpen&&i(!1),m.activeMainTab!=="chat"&&a("chat")}};return window.addEventListener("popstate",h),()=>{window.removeEventListener("popstate",h)}},[l,s,e,a,i])}function qu(){const s=_e.c(5),e=Wi(mc),n=f.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]),f.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let u=!1,d=null;const l=fc,c=g=>{u||(d=window.setTimeout(async()=>{const h=await n.current(),p=typeof h=="number"&&Number.isFinite(h)?l(h):36e5;c(p)},g))};return c(3e3),()=>{u=!0,d!==null&&window.clearTimeout(d)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),f.useEffect(a,i)}function fc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function mc(s){return s.checkForUpdates}const kn=1e3,js=60*kn,tn=60*js,hc=(s,e)=>{const n=Math.max(0,s);return n<js?e("common.duration.secondsCompact",{seconds:Math.floor(n/kn)}):n<tn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/js),seconds:Math.floor(n%js/kn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/tn),minutes:Math.floor(n%tn/js)})},pc=1e3,Yu=s=>{const e=_e.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=Xe(),i=ua(n),u=fa(n),d=ma(r,pc),l=r?Math.max(0,d-(i??d)):u;if(l===void 0)return null;let c,g;e[0]!==l||e[1]!==r||e[2]!==a?(c=hc(l,a),g=r?a("sessions.sidebar.session.status.activeFor",{duration:c}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:c}),e[0]=l,e[1]=r,e[2]=a,e[3]=c,e[4]=g):(c=e[3],g=e[4]);const h=g,p=r?"text-primary":"text-[var(--status-info)]";let m;e[5]!==o||e[6]!==p?(m=se("shrink-0 tabular-nums",p,o),e[5]=o,e[6]=p,e[7]=m):m=e[7];let y;return e[8]!==h||e[9]!==c||e[10]!==m?(y=t.jsx("span",{className:m,"aria-label":h,title:h,children:c}),e[8]=h,e[9]=c,e[10]=m,e[11]=y):y=e[11],y},gc=()=>{const s=_e.c(14),[e,n]=ie.useState(!1),[r,o]=ie.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Dr()),o(ni())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),ie.useEffect(a,i);let u;s[2]!==e?(u=async m=>e?await ri(m):{success:!0,path:m},s[2]=e,s[3]=u):u=s[3];const d=u;let l;s[4]!==e?(l=async m=>e?await oi():{success:!0},s[4]=e,s[5]=l):l=s[5];const c=l;let g;s[6]!==e?(g=async m=>e?await ai():{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]!==d||s[11]!==c||s[12]!==h?(p={isDesktop:e,canRequestAccess:r,requestAccess:d,startAccessing:c,stopAccessing:h},s[8]=r,s[9]=e,s[10]=d,s[11]=c,s[12]=h,s[13]=p):p=s[13],p},xc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),bc=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,onCheckout:o,onCreate:a,remotes:i=[],disabled:u=!1})=>{const{t:d}=Xe(),[l,c]=f.useState(!1),[g,h]=f.useState(""),[p,m]=f.useState(!1),[y,v]=f.useState(!1),[N,S]=f.useState(""),[R,$]=f.useState(!1),w=f.useRef(null),k=f.useCallback(G=>{G.stopPropagation()},[]),b=i.length>1,I=f.useMemo(()=>xc(N),[N]),P=f.useMemo(()=>{const G=g.toLowerCase();return G?e.filter(U=>U.toLowerCase().includes(G)):e},[g,e]),z=f.useMemo(()=>{const G=g.toLowerCase();return G?n.filter(U=>U.toLowerCase().includes(G)):n},[g,n]),O=G=>{if(G===s){c(!1);return}o(G),c(!1),h("")},K=()=>{m(!0),setTimeout(()=>w.current?.focus(),50)},F=async()=>{if(!(!I||R)){if(b){v(!0);return}$(!0);try{await a(I,i[0]),S(""),m(!1),c(!1)}finally{$(!1)}}},X=async G=>{if(!(!I||R)){$(!0);try{await a(I,G),S(""),m(!1),v(!1),c(!1)}finally{$(!1)}}},M=()=>{v(!1)},ee=()=>{S(""),m(!1),v(!1)};return f.useEffect(()=>{l||(h(""),m(!1),v(!1),S(""))},[l]),t.jsxs($t,{open:l,onOpenChange:c,children:[t.jsxs(Kt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(ke,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:u,children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:s||d("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(qt,{sideOffset:8,children:d("gitView.branch.currentBranchTooltip")})]}),t.jsx(_t,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(gn,{className:"h-full min-h-0",children:[t.jsx(xn,{placeholder:d("gitView.branch.searchPlaceholder"),value:g,onValueChange:h,onKeyDown:k}),t.jsxs(bn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(yn,{children:d("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:M,disabled:R,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"arrow-left",className:"size-4"})}),t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:I})," ",d("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:i.map(G=>t.jsxs("button",{type:"button",onClick:()=>X(G),disabled:R,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:[R?t.jsx(E,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,G.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:G.pushUrl})]},G.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:d("gitView.branch.newBranchPlaceholder"),value:N,onChange:G=>S(G.target.value),onClick:G=>G.stopPropagation(),onKeyDown:G=>{k(G),G.key==="Enter"?(G.preventDefault(),F()):G.key==="Escape"&&(G.preventDefault(),ee())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:F,disabled:!I||R,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:R?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"add",className:"size-4"})}),t.jsx("button",{type:"button",onClick:ee,disabled:R,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:t.jsx(E,{name:"close",className:"size-4"})})]}):t.jsxs(Et,{onSelect:K,children:[t.jsx(E,{name:"add",className:"size-4"}),t.jsx("span",{children:d("gitView.branch.create")})]})}),t.jsx(ps,{}),t.jsxs(Ft,{heading:d("gitView.branch.localBranches"),children:[P.map(G=>t.jsxs(Et,{onSelect:()=>O(G),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:G}),(r?.[G]?.ahead||r?.[G]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[G].ahead||0," ahead ·"," ",r[G].behind||0," behind"]})]}),s===G&&t.jsx("span",{className:"typography-micro text-primary",children:d("gitView.branch.currentBadge")})]},`local-${G}`)),P.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:d("gitView.branch.noLocalBranches")})})]}),t.jsx(ps,{}),t.jsxs(Ft,{heading:d("gitView.branch.remoteBranches"),children:[z.map(G=>t.jsx(Et,{onSelect:()=>O(G),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:G})},`remote-${G}`)),z.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:d("gitView.branch.noRemoteBranches")})})]})]})]})})]})},yc=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),wc=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=Xe(),[o,a]=f.useState(!1),[i,u]=f.useState(s||""),[d,l]=f.useState(!1),c=f.useRef(null),g=()=>{!s||!e||(u(s),a(!0),setTimeout(()=>c.current?.focus(),0))},h=async()=>{if(!s||!e||!i.trim())return;const y=yc(i);if(y===s){a(!1);return}l(!0);try{await e(s,y),a(!1),u("")}finally{l(!1)}},p=()=>{a(!1),u("")},m=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(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:c,value:i,onChange:y=>u(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:m,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:d,"aria-label":r(d?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(d?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:d?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"check",className:"size-4"})}),t.jsx("button",{type:"button",onClick:p,disabled:d,"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(E,{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(E,{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(ke,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:g,title:r("gitView.branch.renameTitle"),children:t.jsx(E,{name:"edit",className:"size-4"})})]})]})},vc=s=>{const e=_e.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:u,removingRemoteName:d,aheadCount:l,behindCount:c,trackingRemoteName:g,hasUncommittedChanges:h}=s,p=r===void 0?[]:r,m=d===void 0?null:d,y=l===void 0?0:l,v=c===void 0?0:c,N=h===void 0?!1:h,{t:S}=Xe(),R=f.useRef(!1),$=!!m,w=p.find(me=>me.name===g)??p[0],k=v>0&&N,b=u||n!==null||$||!w||k,I=u||n!==null||$||p.length===0,P=y>0||v>0;let z;e[0]!==S?(z=S("gitView.sync.sync"),e[0]=S,e[1]=z):z=e[1];const O=v>0?`↓${v}`:null,K=y>0?`↑${y}`:null;let F;e[2]!==z||e[3]!==O||e[4]!==K?(F=[z,O,K].filter(Boolean),e[2]=z,e[3]=O,e[4]=K,e[5]=F):F=e[5];const X=F.join(" "),M=k?S("gitView.sync.commitOrStashTooltip"):w?P?S("gitView.sync.syncChangesTooltip",{ahead:y,behind:v}):S("gitView.sync.syncChanges"):S("gitView.sync.noRemoteTooltip"),ee=()=>{w&&a(w)},G="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",U=k?0:void 0;let D;e[6]===Symbol.for("react.memo_cache_sentinel")?(D=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]=D):D=e[6];let A;e[7]!==S?(A=S("gitView.sync.syncChanges"),e[7]=S,e[8]=A):A=e[8];let W;e[9]!==n?(W=n==="sync"?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"}),e[9]=n,e[10]=W):W=e[10];let H;e[11]!==X?(H=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:X}),e[11]=X,e[12]=H):H=e[12];let T;e[13]!==ee||e[14]!==b||e[15]!==A||e[16]!==W||e[17]!==H?(T=t.jsxs("button",{type:"button",onClick:ee,disabled:b,className:D,"aria-label":A,children:[W,H]}),e[13]=ee,e[14]=b,e[15]=A,e[16]=W,e[17]=H,e[18]=T):T=e[18];let _;e[19]!==U||e[20]!==T?(_=t.jsx(Ht,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:U,children:T})}),e[19]=U,e[20]=T,e[21]=_):_=e[21];let Y;e[22]!==M?(Y=t.jsx(qt,{sideOffset:8,children:M}),e[22]=M,e[23]=Y):Y=e[23];let le;e[24]!==_||e[25]!==Y?(le=t.jsxs(Kt,{children:[_,Y]}),e[24]=_,e[25]=Y,e[26]=le):le=e[26];const te=$t;let Q;e[27]===Symbol.for("react.memo_cache_sentinel")?(Q=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]=Q):Q=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(E,{name:"arrow-down-s",className:"size-4"}),e[30]=re):re=e[30];let J;e[31]!==I||e[32]!==q?(J=t.jsx(Wt,{asChild:!0,children:t.jsx("button",{type:"button",className:Q,disabled:I,"aria-label":q,children:re})}),e[31]=I,e[32]=q,e[33]=J):J=e[33];const ce=_t,oe="start",ae=-40,ue="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",he=p.map(me=>t.jsx(At,{onSelect:ne=>{if(R.current){ne.preventDefault(),R.current=!1;return}o(me)},children:t.jsxs("div",{className:"flex w-full items-center gap-2",children:[t.jsx(E,{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:me.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:me.fetchUrl})]})}),i&&me.name!==g?t.jsx(ke,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||$,onPointerDown:ne=>{R.current=!0,ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{R.current=!0,ne.preventDefault(),ne.stopPropagation(),i(me)},"aria-label":S("gitView.header.removeRemoteAria",{name:me.name}),title:S("gitView.header.removeRemoteTitle",{name:me.name}),children:m===me.name?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(E,{name:"close",className:"size-3.5"})}):null]})},me.name));let j;e[34]!==ce||e[35]!==he?(j=t.jsx(ce,{align:oe,alignOffset:ae,className:ue,children:he}),e[34]=ce,e[35]=he,e[36]=j):j=e[36];let V;e[37]!==te||e[38]!==J||e[39]!==j?(V=t.jsxs(te,{children:[J,j]}),e[37]=te,e[38]=J,e[39]=j,e[40]=V):V=e[40];let Z;return e[41]!==le||e[42]!==V?(Z=t.jsxs("div",{className:G,children:[le,V]}),e[41]=le,e[42]=V,e[43]=Z):Z=e[43],Z},jc={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},kc={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 Qr(s){return s&&kc[s]||"var(--primary)"}const lr=s=>{const e=_e.c(8),{icon:n,className:r,colorToken:o}=s,a=jc[n??"branch"]??"user-3";let i;e[0]!==o?(i=Qr(o),e[0]=o,e[1]=i):i=e[1];let u;e[2]!==i?(u={color:i},e[2]=i,e[3]=u):u=e[3];let d;return e[4]!==r||e[5]!==a||e[6]!==u?(d=t.jsx(E,{name:a,className:r,style:u}),e[4]=r,e[5]=a,e[6]=u,e[7]=d):d=e[7],d},Xr=s=>{const e=_e.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,u=i===void 0?!1:i,{t:d}=Xe(),l=a||r.length===0,c=n?.color;let g;e[0]!==c?(g=Qr(c),e[0]=c,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(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(lr,{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 m;e[8]!==n?.name||e[9]!==u||e[10]!==d?(m=!u&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||d("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=u,e[10]=d,e[11]=m):m=e[11];let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=y):y=e[12];let v;e[13]!==l||e[14]!==h||e[15]!==p||e[16]!==m?(v=t.jsx(Ht,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsxs(ke,{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:l,children:[p,m,y]})})}),e[13]=l,e[14]=h,e[15]=p,e[16]=m,e[17]=v):v=e[17];let N;e[18]!==d?(N=d("gitView.header.identityTooltip"),e[18]=d,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 R;e[22]!==S||e[23]!==v?(R=t.jsxs(Kt,{children:[v,S]}),e[22]=S,e[23]=v,e[24]=R):R=e[24];let $;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==d?($=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:d("gitView.header.noProfiles")})}):r.map(b=>{const I=n?.id===b.id;return t.jsx(At,{onSelect:()=>o(b),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(lr,{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})]}),I?t.jsx(E,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},b.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=d,e[29]=$):$=e[29];let w;e[30]!==$?(w=t.jsx(_t,{align:"end",className:"w-64",children:$}),e[30]=$,e[31]=w):w=e[31];let k;return e[32]!==R||e[33]!==w?(k=t.jsxs($t,{children:[R,w]}),e[32]=R,e[33]=w,e[34]=k):k=e[34],k},Nc=s=>{const e=_e.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=Xe(),u=`${n.remote}/${n.branch}`,d=n.ahead===0&&n.behind===0;let l;e[0]!==i||e[1]!==u||e[2]!==r?(l=r?i("gitView.header.upstreamTooltipTracking",{target:u,tracking:r}):i("gitView.header.upstreamTooltip",{target:u}),e[0]=i,e[1]=u,e[2]=r,e[3]=l):l=e[3];const c=l;let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(E,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=g):g=e[4];let h;e[5]!==u?(h=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:u}),e[5]=u,e[6]=h):h=e[6];let p;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==d||e[10]!==i?(p=d?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]=d,e[10]=i,e[11]=p):p=e[11];let m;e[12]!==h||e[13]!==p?(m=t.jsx(Ht,{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]=m):m=e[14];let y;e[15]!==c?(y=t.jsx(qt,{sideOffset:8,children:c}),e[15]=c,e[16]=y):y=e[16];let v;return e[17]!==m||e[18]!==y||e[19]!==a?(v=t.jsxs(Kt,{delayDuration:a,children:[m,y]}),e[17]=m,e[18]=y,e[19]=a,e[20]=v):v=e[20],v},Ju=s=>{const e=_e.c(67),{status:n,localBranches:r,remoteBranches:o,branchInfo:a,syncAction:i,remotes:u,onFetch:d,onSync:l,onRemoveRemote:c,removingRemoteName:g,onCheckoutBranch:h,onCreateBranch:p,onRenameBranch:m,activeIdentityProfile:y,availableIdentities:v,onSelectIdentity:N,isApplyingIdentity:S,isWorktreeMode:R,onOpenHistory:$,onOpenGraph:w,onOpenStashes:k,onOpenUpdateBranch:b,onOpenReintegrateCommits:I,pullRequest:P,prChecks:z,onOpenPullRequest:O}=s,{t:K}=Xe();if(!n)return null;let F;e[0]!==w||e[1]!==$||e[2]!==I||e[3]!==k||e[4]!==b||e[5]!==K?(F=$||w||k||b?t.jsxs($t,{children:[t.jsxs(Kt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx(Wt,{asChild:!0,children:t.jsx(ke,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":K("gitView.header.repositoryViews"),children:t.jsx(E,{name:"more-fill",className:"size-4"})})})}),t.jsx(qt,{sideOffset:8,children:K("gitView.header.repositoryViews")})]}),t.jsxs(_t,{align:"end",children:[$?t.jsxs(At,{onSelect:$,children:[t.jsx(E,{name:"history",className:"size-4"}),K("gitView.history.title")]}):null,w?t.jsxs(At,{onSelect:w,children:[t.jsx(E,{name:"git-branch",className:"size-4"}),K("gitView.graph.title")]}):null,k?t.jsxs(At,{onSelect:k,children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),K("gitView.stashes.title")]}):null,b?t.jsxs(At,{onSelect:b,children:[t.jsx(E,{name:"git-merge",className:"size-4"}),K("gitView.header.updateBranch")]}):null,I?t.jsxs(At,{onSelect:I,children:[t.jsx(E,{name:"split-cells-horizontal",className:"size-4"}),K("gitView.integrate.title")]}):null]})]}):null,e[0]=w,e[1]=$,e[2]=I,e[3]=k,e[4]=b,e[5]=K,e[6]=F):F=e[6];let X;e[7]!==F?(X=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:F}),e[7]=F,e[8]=X):X=e[8];const M=X,ee=z?z.state==="success"?"var(--status-success)":z.state==="failure"?"var(--status-error)":"var(--status-warning)":null,G=P?P.state==="merged"?"merged":P.state==="closed"?"closed":P.draft?"draft":z?.state==="failure"||P.mergeable===!1||P.mergeableState==="blocked"||P.mergeableState==="dirty"?"blocked":"open":null;let U;e[9]!==O||e[10]!==ee||e[11]!==G||e[12]!==P||e[13]!==K?(U=P&&O?t.jsxs(Kt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsxs(ke,{variant:"ghost",size:"sm",onClick:O,className:"h-8 gap-1.5 px-2 typography-micro",children:[t.jsx(E,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${G})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:K("gitView.pr.numberLabel",{number:P.number})}),ee?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:ee}}):null]})}),t.jsx(qt,{sideOffset:8,children:K("gitView.header.openPullRequest")})]}):null,e[9]=O,e[10]=ee,e[11]=G,e[12]=P,e[13]=K,e[14]=U):U=e[14];const D=U,A=!n;let W;e[15]!==n.tracking?(W=n.tracking?.split("/")[0],e[15]=n.tracking,e[16]=W):W=e[16];const H=(n.files?.length??0)>0;let T;e[17]!==d||e[18]!==c||e[19]!==l||e[20]!==u||e[21]!==g||e[22]!==n.ahead||e[23]!==n.behind||e[24]!==i||e[25]!==A||e[26]!==W||e[27]!==H?(T=t.jsx(vc,{syncAction:i,remotes:u,onFetch:d,onSync:l,onRemoveRemote:c,removingRemoteName:g,disabled:A,iconOnly:!0,aheadCount:n.ahead,behindCount:n.behind,trackingRemoteName:W,hasUncommittedChanges:H}),e[17]=d,e[18]=c,e[19]=l,e[20]=u,e[21]=g,e[22]=n.ahead,e[23]=n.behind,e[24]=i,e[25]=A,e[26]=W,e[27]=H,e[28]=T):T=e[28];const _=T;let Y;e[29]!==n.tracking||e[30]!==n.upstreamComparison?(Y=n.upstreamComparison?t.jsx(Nc,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[29]=n.tracking,e[30]=n.upstreamComparison,e[31]=Y):Y=e[31];const le=Y;let te;e[32]!==y||e[33]!==v||e[34]!==S||e[35]!==N?(te=t.jsx(Xr,{activeProfile:y,identities:v,onSelect:N,isApplying:S,iconOnly:!0}),e[32]=y,e[33]=v,e[34]=S,e[35]=N,e[36]=te):te=e[36];const Q=te;let q;e[37]!==a||e[38]!==R||e[39]!==r||e[40]!==h||e[41]!==p||e[42]!==m||e[43]!==o||e[44]!==u||e[45]!==n.current?(q=t.jsx("div",{className:"min-w-0 flex-1",children:R?t.jsx(wc,{currentBranch:n.current,onRename:m}):t.jsx(bc,{currentBranch:n.current,localBranches:r,remoteBranches:o,branchInfo:a,onCheckout:h,onCreate:p,remotes:u})}),e[37]=a,e[38]=R,e[39]=r,e[40]=h,e[41]=p,e[42]=m,e[43]=o,e[44]=u,e[45]=n.current,e[46]=q):q=e[46];let re;e[47]!==Q?(re=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:Q}),e[47]=Q,e[48]=re):re=e[48];let J;e[49]!==q||e[50]!==re?(J=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]=J):J=e[51];let ce;e[52]!==D?(ce=D?t.jsx("div",{className:"shrink-0",children:D}):null,e[52]=D,e[53]=ce):ce=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 ae;e[55]!==le?(ae=le?t.jsx("div",{className:"min-w-0 shrink",children:le}):null,e[55]=le,e[56]=ae):ae=e[56];let ue;e[57]!==_?(ue=t.jsx("div",{className:"shrink-0",children:_}),e[57]=_,e[58]=ue):ue=e[58];let he;e[59]!==M||e[60]!==ce||e[61]!==ae||e[62]!==ue?(he=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[ce,oe,ae,M,ue]}),e[59]=M,e[60]=ce,e[61]=ae,e[62]=ue,e[63]=he):he=e[63];let j;return e[64]!==J||e[65]!==he?(j=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[J,he]}),e[64]=J,e[65]=he,e[66]=j):j=e[66],j},Sc=s=>s==="/",zs=s=>s.replace(/\\/g,"/"),Pn=s=>{if(!s||Sc(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},bs=s=>s.endsWith("/"),Cc=s=>{const e=s.trim();return!e||bs(e)?e:`${e}/`},Dn=s=>s.lastIndexOf("/"),Zr=s=>{if(bs(s))return s;const e=Dn(s);return e<0?s:s.slice(0,e+1)},Ic=s=>{const e=Dn(s);return s.slice(e+1)},eo=s=>{const e=Pn(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Dn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},Tc=s=>bs(s)&&eo(s)!==null,Pc=(s,e)=>`${Zr(s)}${e}/`,zt=s=>{if(!s)return null;const e=Pn(zs(s.trim()));return e?e.toLowerCase():null},cr=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},Dc=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,sn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},Ec=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 zs(e.home.trim())}}catch{}return xs.getFilesystemHome().catch(()=>null)},Qu=({open:s,onOpenChange:e})=>{const{t:n}=Xe(),r=Rs(C=>C.homeDirectory),o=Ct(C=>C.projects),a=Ct(C=>C.addProject),i=De(C=>C.setActiveMainTab),u=De(C=>C.setSessionSwitcherOpen),d=at(C=>C.openNewSessionDraft),l=Vt(C=>C.profiles),c=Vt(C=>C.globalIdentity),g=Vt(C=>C.defaultGitIdentityId),h=Vt(C=>C.loadProfiles),p=Vt(C=>C.loadGlobalIdentity),m=Vt(C=>C.loadDefaultGitIdentityId),{canRequestAccess:y,requestAccess:v,startAccessing:N}=gc(),{isMobile:S}=Gs(),R=f.useRef(null),$=f.useRef(null),w=f.useRef(new Map),[k,b]=f.useState(""),[I,P]=f.useState("~/"),[z,O]=f.useState([]),[K,F]=f.useState(!1),[X,M]=f.useState(!1),[ee,G]=f.useState(null),[U,D]=f.useState(0),[A,W]=f.useState(0),[H,T]=f.useState(!1),[_,Y]=f.useState(!1),[le,te]=f.useState(0),[Q,q]=f.useState(!1),[re,J]=f.useState(""),[ce,oe]=f.useState(null),[ae,ue]=f.useState(!1),he=k||r,j=f.useMemo(()=>new Set(o.map(C=>zt(C.path)).filter(C=>!!C)),[o]);f.useEffect(()=>{if(!s)return;P("~/"),O([]),W(0),T(!1),Y(!1),q(!1),J(""),oe(null),ue(!1),requestAnimationFrame(()=>sn(R.current));let C=!1;return(async()=>{const Se=await Ec();C||(b(Se||r||""),requestAnimationFrame(()=>sn(R.current)))})(),()=>{C=!0}},[r,s]),f.useEffect(()=>{s&&(h(),p(),m())},[m,h,p,s]);const V=f.useMemo(()=>{const C=new Map;c&&C.set(c.id,c);for(const be of l)C.set(be.id,be);return Array.from(C.values())},[l,c]);f.useEffect(()=>{if(!s||!Q||ce!==null)return;const C=typeof g=="string"?g.trim():"";if(C&&V.some(Se=>Se.id===C)){oe(C);return}const be=V.find(Se=>Se.authType==="ssh"||Se.sshKey);be&&oe(be.id)},[V,g,Q,s,ce]);const Z=f.useMemo(()=>V.find(C=>C.id===ce)??null,[V,ce]),me=f.useMemo(()=>Zr(I),[I]),ne=f.useMemo(()=>bs(I)?"":Ic(I),[I]),ye=f.useMemo(()=>he?cr(me,he):"",[me,he]);f.useEffect(()=>{if(!s||!ye){O([]),G(null);return}let C=!1;return F(!0),M(!1),G(null),xs.listLocalDirectory(ye).then(be=>{if(C)return;M(!1),G(null);const Se=be.filter(Re=>Re.isDirectory).map(Re=>({name:Re.name,path:zs(Re.path)})).sort((Re,ot)=>Re.name.localeCompare(ot.name));O(Se)}).catch(be=>{if(!C){O([]);const Se=ii(be)?be.reason:"unknown";G(Se),M(Se==="not-found")}}).finally(()=>{C||F(!1)}),()=>{C=!0}},[ye,U,s]);const Ie=f.useMemo(()=>{const C=ne.toLowerCase(),be=ae||ne.startsWith(".");return z.filter(Se=>Se.name.toLowerCase().startsWith(C)&&(be||!Se.name.startsWith(".")))},[ne,z,ae]),Me=f.useMemo(()=>{const C=[];Tc(I)&&C.push({type:"up",value:"browse:up",name:"..",path:eo(I)});for(const be of Ie){const Se=zt(be.path);C.push({type:"directory",value:`browse:${be.path}`,name:be.name,path:be.path,disabled:!!(Se&&j.has(Se))})}return C},[j,Ie,I]);f.useEffect(()=>{W(0)},[I,Me.length]);const Ue=f.useMemo(()=>he?Pn(cr(I,he)):"",[he,I]),tt=zt(Ue),Le=!!(tt&&j.has(tt)),st=f.useMemo(()=>ne?Ie.find(C=>C.name===ne)??null:null,[ne,Ie]),Ae=!!(Ue&&!Le&&(ee===null||ee==="not-found")&&(bs(I)&&X||!bs(I)&&ne.trim().length>0&&st===null)),He=!H&&!_&&!Le&&ee!=="os-permission"&&ee!=="invalid-response"&&ee!=="unknown"&&!!Ue,Fe=He&&re.trim().length>0,Ye=Me[A]??null,Ze=!!(Ye&&(Ye.type==="up"||Ye.type==="directory"&&!Ye.disabled)),$e=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl",Je=n(Le?"directoryExplorerDialog.actions.alreadyAdded":Q?H?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":H?"directoryExplorerDialog.actions.adding":Ae?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");f.useLayoutEffect(()=>{const C=$.current;if(!C)return;const be=()=>te(Math.ceil(C.getBoundingClientRect().width));if(be(),typeof ResizeObserver>"u")return;const Se=new ResizeObserver(be);return Se.observe(C),()=>Se.disconnect()},[Je]),f.useLayoutEffect(()=>{const C=R.current;C&&(C.scrollLeft=C.scrollWidth)},[le,I]),f.useLayoutEffect(()=>{s&&sn(R.current)},[s]),f.useLayoutEffect(()=>{const C=Me[A];C&&w.current.get(C.value)?.scrollIntoView({block:"nearest"})},[A,Me]);const qe=f.useCallback(()=>{e(!1)},[e]),Ce=f.useCallback((C,be)=>{i("chat"),S&&u(!1),d({selectedProjectId:C,directoryOverride:be}),qe()},[qe,S,d,i,u]),Te=f.useCallback((C,be)=>{C.stopPropagation();const Se=zt(be);if(Se&&j.has(Se))return;const Re=a(be);if(!Re){ve.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Ce(Re.id,Re.path)},[a,j,Ce,n]),ze=f.useCallback(async C=>{if(!C||H)return;const be=zt(C);if(be&&j.has(be))return;let Se=C;T(!0);try{const Re=!Q&&Ae&&zt(C)===zt(Ue);if(Q){const it=re.trim();if(!it){ve.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}Se=(await xs.cloneRepository({remoteUrl:it,destinationPath:C,gitIdentityId:Z?.id??null})).path}else Re&&await xs.createDirectory(C,{asProject:!0});const ot=a(Se);if(!ot){ve.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}Ce(ot.id,ot.path)}catch(Re){ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Re instanceof Error?Re.message:n("directoryExplorerDialog.toast.unknownError")})}finally{T(!1)}},[a,j,re,Q,H,Ce,Z?.id,Ae,Ue,n]),Pe=f.useCallback(C=>{P(Cc(C))},[]),lt=f.useCallback(C=>{P(Pc(I,C.name))},[I]),x=f.useCallback(C=>{if(C){if(C.type==="up"){C.path&&Pe(C.path);return}C.disabled||lt(C)}},[Pe,lt]),L=f.useCallback(async()=>{if(!(!y||_)){Y(!0);try{const C=await v(Ue);if(!C.success||!C.path){C.error&&C.error!=="Directory selection cancelled"&&ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:C.error});return}const be=await N(C.path);if(!be.success){ve.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:be.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}await ze(C.path)}catch(C){ve.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:C instanceof Error?C.message:n("directoryExplorerDialog.toast.unknownError")})}finally{Y(!1)}}},[y,ze,_,v,N,n,Ue]),xe=f.useCallback(C=>{if(C.key==="ArrowDown"){C.preventDefault(),W(be=>Math.min(Me.length-1,be+1));return}if(C.key==="ArrowUp"){C.preventDefault(),W(be=>Math.max(0,be-1));return}if(C.key==="Enter"){if(C.preventDefault(),Dc(C)){ze(Ue);return}Ze&&x(Ye);return}C.key==="Backspace"&&I===""&&(C.preventDefault(),qe())},[x,ze,qe,Ze,Ye,I,Me.length,Ue]),Be=t.jsxs("button",{type:"button",onClick:()=>ue(C=>!C),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:[ae?t.jsx(E,{name:"checkbox",className:"h-4 w-4 text-primary"}):t.jsx(E,{name:"checkbox-blank",className:"h-4 w-4"}),n("directoryExplorerDialog.toggle.showHidden")]}),Ne=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Q?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(yt,{value:re,onChange:C=>J(C.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(Xr,{activeProfile:Z,identities:V,onSelect:C=>oe(C.id),isApplying:H,iconOnly:!0})]}):null,t.jsxs("div",{className:"relative",children:[t.jsx(E,{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:R,value:I,onChange:C=>P(zs(C.target.value)),onKeyDown:xe,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&&le>0?{paddingRight:`${le+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),S?null:t.jsx(ke,{ref:$,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:Q?!Fe:!He,onMouseDown:C=>C.preventDefault(),onClick:()=>{ze(Ue)},title:Je,children:Je})]})]}),Ke=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")}),K?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):ee&&ee!=="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(ee==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[ee==="os-permission"&&y?t.jsx(ke,{size:"xs",onClick:()=>{L()},disabled:_,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(ke,{variant:"outline",size:"xs",onClick:()=>D(C=>C+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):Me.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:Me.map((C,be)=>{const Se=be===A;return t.jsxs("button",{ref:Re=>{Re?w.current.set(C.value,Re):w.current.delete(C.value)},type:"button",disabled:C.type==="directory"&&C.disabled,onMouseEnter:()=>W(be),onMouseDown:Re=>Re.preventDefault(),onClick:()=>x(C),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",Se&&"bg-interactive-selection text-interactive-selection-foreground",!Se&&"hover:bg-interactive-hover/50",C.type==="directory"&&C.disabled&&"cursor-not-allowed opacity-45 hover:bg-transparent"),children:[C.type==="up"?t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/80"}):t.jsx(E,{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:C.name})}),C.type==="directory"&&C.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")}):C.type==="directory"?t.jsx("button",{type:"button",onMouseDown:Re=>Re.stopPropagation(),onClick:Re=>Te(Re,C.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(E,{name:"add",className:"h-3.5 w-3.5"})}):null]},C.value)})})]})}),Qe=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Ne,Ke]}),Ve=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(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"}),t.jsx(E,{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(E,{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:$e}),t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Ee=()=>t.jsxs(t.Fragment,{children:[S?null:Ve,t.jsxs("div",{className:se("flex w-full flex-row justify-end gap-2 sm:w-auto",S&&"justify-stretch"),children:[y?t.jsx(ke,{variant:"ghost",size:"xs",onClick:L,disabled:H||_||Q,children:n(_?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(ke,{variant:"ghost",size:"xs",onClick:()=>q(C=>!C),disabled:H||_,className:se(S&&"flex-1"),children:n(Q?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),S?t.jsx(ke,{size:"xs",onClick:()=>{ze(Ue)},disabled:Q?!Fe:!He,className:"flex-1",children:Je}):null]})]});return S?t.jsx(Ns,{open:s,onClose:qe,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:Be}),Qe]})}):t.jsx(Ts,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Vs,{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(ha,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),Be]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:Qe}),t.jsx(Cn,{className:"flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:Ee()})]})})};function dr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=Fn(e,o,c=>c),i=Fn(n,o,c=>c),u=[],d=a.other,l=i.other;for(const c of a.matching)u.push({label:c,value:c,source:"local"});for(const c of i.matching)u.push({label:c,value:`remotes/${c}`,source:"remote"});return u.sort((c,g)=>{const h=c.label.localeCompare(g.label,void 0,{sensitivity:"accent"});return h!==0?h:c.source!==g.source?c.source.localeCompare(g.source):c.value.localeCompare(g.value)}),{matching:u,otherLocal:d,otherRemote:l}}const nn="oc:lastWorktreeSourceBranch",Rc=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,Ac=({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 Bc({open:s,onOpenChange:e,onSelect:n}){const{t:r}=Xe(),o=De(j=>j.isMobile),{github:a}=In(),i=_s(j=>j.status),u=_s(j=>j.hasChecked),d=De(j=>j.setSettingsDialogOpen),l=De(j=>j.setSettingsPage),c=Ct(j=>j.getActiveProject()),g=c?.path??null,h=ie.useMemo(()=>g&&c?{id:c.id,path:g}:null,[c,g]),[p,m]=ie.useState("issues"),[y,v]=ie.useState(""),[N,S]=ie.useState([]),[R,$]=ie.useState([]),[w,k]=ie.useState(!1),[b,I]=ie.useState(!1),[P,z]=ie.useState(null),[O,K]=ie.useState(null),[F,X]=ie.useState(null),[M,ee]=ie.useState(!1),[G,U]=ie.useState(new Map),[D,A]=ie.useState(1),[W,H]=ie.useState(!1),T=pa(y,350),_=ie.useCallback(async j=>{if(!(!g||!a)&&!(u&&i?.connected===!1)){k(!0),z(null),A(1),H(!1);try{if(p==="issues"&&a.issuesList){const V=await a.issuesList(g,{page:1,query:j});V.connected===!1?(z(r("session.githubIntegration.error.notConnected")),S([])):(S(V.issues??[]),A(V.page??1),H(!!V.hasMore))}else if(p==="prs"&&a.prsList){const V=await a.prsList(g,{page:1,query:j});V.connected===!1?(z(r("session.githubIntegration.error.notConnected")),$([])):($(V.prs??[]),A(V.page??1),H(!!V.hasMore))}}catch(V){z(V instanceof Error?V.message:r("session.githubIntegration.error.loadDataFailed"))}finally{k(!1)}}},[g,a,u,i,p,r]);ie.useEffect(()=>{if(!s||!g||u&&i?.connected===!1||!a)return;if(!T.trim()){_();return}const j=new AbortController;k(!0),z(null),A(1),H(!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){k(!1);return}return V.then(Z=>{j.signal.aborted||("issues"in Z?Z.connected===!1?(z(r("session.githubIntegration.error.notConnected")),S([])):(S(Z.issues??[]),A(Z.page??1),H(!!Z.hasMore)):"prs"in Z&&(Z.connected===!1?(z(r("session.githubIntegration.error.notConnected")),$([])):($(Z.prs??[]),A(Z.page??1),H(!!Z.hasMore))))}).catch(Z=>{j.signal.aborted||z(Z instanceof Error?Z.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{j.signal.aborted||k(!1)}),()=>j.abort()},[s,g,a,u,i,p,T,_,r]);const Y=ie.useCallback(async()=>{if(!(!g||!a)&&!(w||b)&&W){I(!0);try{const j=D+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??[]]),A(V.page??j),H(!!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&&($(Z=>[...Z,...V.prs??[]]),A(V.page??j),H(!!V.hasMore))}}catch{}finally{I(!1)}}},[g,a,p,D,W,w,b,T]);ie.useEffect(()=>{if(!s){m("issues"),v(""),S([]),$([]),K(null),X(null),ee(!1),z(null),U(new Map),A(1),H(!1);return}_()},[s,_]);const le=ie.useCallback(async j=>{if(!(!h||!j)&&!G.has(j))try{const Z=(await Sr(h,{mode:"new",branchName:j,worktreeName:j})).errors.find(me=>me.code==="branch_in_use");U(me=>new Map(me).set(j,{isValid:!Z,error:Z?r(Z.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{U(V=>new Map(V).set(j,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[h,G,r]);ie.useEffect(()=>{!s||p!=="prs"||R.forEach(j=>{j.head&&le(j.head)})},[s,p,R,le]);const te=u&&i?.connected===!0,Q=()=>{l("github"),d(!0)},q=j=>{K(j),X(null)},re=j=>{X(j),K(null)},J=()=>{O?n({type:"issue",item:O}):F&&n({type:"pr",item:F,includeDiff:M}),e(!1)},ce=()=>{K(null),X(null),ee(!1)},oe=O||F&&G.get(F.head??"")?.isValid!==!1,ae=j=>j.head?G.get(j.head)?.isValid===!1:!0,ue=t.jsx(t.Fragment,{children:te?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mt-2",children:[t.jsx(E,{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=>v(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(E,{name:"loader-4",className:"h-5 w-5 animate-spin text-muted-foreground"})}),P&&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(E,{name:"error-warning",className:"h-4 w-4"}),t.jsx("span",{className:"typography-small",children:P})]})}),!w&&!P&&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",O?.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(ke,{variant:"ghost",size:"sm",onClick:()=>{Y()},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(E,{name:"loader-4",className:"h-4 w-4 animate-spin text-muted-foreground"})})]}),!w&&!P&&p==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[R.length>0?R.map(j=>{const V=ae(j),Z=j.head?G.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",F?.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(ke,{variant:"ghost",size:"sm",onClick:()=>{Y()},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(E,{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(E,{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(ke,{onClick:Q,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&&(O||F)&&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(E,{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:O?r("session.githubIntegration.selected.issueNumber",{number:O.number}):r("session.githubIntegration.selected.prNumber",{number:F?.number??""})}),t.jsx("button",{onClick:ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),p==="prs"&&F&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Es,{checked:M,onChange:j=>ee(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(ke,{variant:"outline",size:"sm",onClick:()=>e(!1),className:se(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(ke,{size:"sm",onClick:J,disabled:!oe,className:se(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(Ns,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:te?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(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:V=>{m(V),v("")},variant:"active-pill",layoutMode:"fit"})}),(O||F)&&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(E,{name:"check",className:"h-3.5 w-3.5 text-status-success shrink-0"}),t.jsx("span",{className:"typography-small truncate flex-1",children:O?r("session.githubIntegration.selected.issueNumber",{number:O.number}):r("session.githubIntegration.selected.prNumber",{number:F?.number??""})}),t.jsx("button",{onClick:ce,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]})]}),children:ue}):t.jsx(Ts,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Vs,{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(E,{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(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"prs",label:r("session.githubIntegration.tabs.pullRequests"),icon:t.jsx(E,{name:"git-pull-request",className:"h-3.5 w-3.5"})}],activeId:p,onSelect:j=>{m(j),v("")},variant:"active-pill",layoutMode:"fit"})})]})}),ue,t.jsx(Cn,{className:"mt-1",children:he})]})})})}const ks=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),Mc=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",ur=(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(l=>{const c=l.indexOf("/");return c<=0||c>=l.length-1?!1:l.slice(c+1)===r});if(o){const l=o.indexOf("/"),c=o.slice(0,l);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:c,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${c}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",u=`pr-${Mc(i)}`,d=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!d)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/${u}/${r}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:u,ensureRemoteUrl:d,sourceLabel:`${u}/${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),Lc=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
3
+ ${JSON.stringify(e,null,2)}`},Fc=s=>`GitHub pull request context (JSON)
4
+ ${JSON.stringify(s,null,2)}`;function Xu({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=Xe(),{github:o,git:a}=In(),i=De(x=>x.isMobile),u=_s(x=>x.status),d=_s(x=>x.hasChecked),l=Ct(x=>x.getActiveProject()),c=l?.path??null,g=ie.useMemo(()=>c&&l?{id:l.id,path:c}:null,[l,c]),[h,p]=ie.useState("new-branch"),[m,y]=ie.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1}),[v,N]=ie.useState({selectedBranch:"",worktreeName:""}),S=ga(c),R=xa(c),$=Tn(x=>x.fetchBranches),w=ie.useMemo(()=>S?.all?S.all.filter(x=>!x.startsWith("remotes/")).sort():[],[S]),k=ie.useMemo(()=>S?.all?S.all.filter(x=>x.startsWith("remotes/")).map(x=>x.replace(/^remotes\//,"")).sort():[],[S]),b=at(x=>x.availableWorktreesByProject),I=ie.useMemo(()=>{if(!c)return new Set;const x=b.get(c)??[];return new Set(x.map(L=>L.name))},[b,c]),P=ie.useCallback((x=10)=>{for(let L=0;L<x;L++){const xe=Xs();if(!I.has(xe))return xe}return`${Xs()}-${Date.now().toString(36).slice(-4)}`},[I]),[z,O]=ie.useState(!1),[K,F]=ie.useState(!1),[X,M]=ie.useState(!1),[ee,G]=ie.useState(!1),[U,D]=ie.useState(!1),[A,W]=ie.useState(""),[H,T]=ie.useState(""),_=ie.useRef(null),Y=ie.useRef(null),le=ie.useRef(null),te=ie.useRef(null),Q=ie.useCallback(x=>{x.stopPropagation()},[]),q=ie.useCallback(x=>{let L=x;for(;L&&L!==document.body;){const{overflowY:xe}=window.getComputedStyle(L);if((xe==="auto"||xe==="scroll")&&L.scrollHeight>L.clientHeight)return L;L=L.parentElement}return null},[]),re=ie.useCallback(x=>{x&&(x.scrollTop=0)},[]),J=ie.useCallback(x=>{const L=x.current?.querySelector('[data-slot="command-list"]')??null;re(L)},[re]),ce=ie.useCallback(x=>{const L=q(x.current);re(L)},[q,re]),oe=ie.useMemo(()=>dr({localBranches:w,remoteBranches:k,query:A}),[w,k,A]),ae=ie.useMemo(()=>dr({localBranches:w,remoteBranches:k,query:H}),[w,k,H]),ue=A.trim().length>0,he=H.trim().length>0,j=oe.matching.length>0,V=ae.matching.length>0,Z=!!(c&&a),me=ie.useCallback(()=>{!c||!a||$(c,a)},[c,a,$]);ie.useEffect(()=>{!s||!c||!a||S?.all||$(c,a)},[s,c,a,S?.all,$]),ie.useEffect(()=>{!K&&!ee&&W("")},[K,ee]),ie.useEffect(()=>{!X&&!U&&T("")},[X,U]),ie.useEffect(()=>{K&&J(_),ee&&ce(le)},[K,ee,A,J,ce]),ie.useEffect(()=>{X&&J(Y),U&&ce(te)},[X,U,H,J,ce]);const[ne,ye]=ie.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ie,Me]=ie.useState(!1),[Ue,tt]=ie.useState(null),Le=ie.useCallback(()=>{const x=kt.getState(),L=x.getVisibleAgents();if(x.settingsDefaultAgent){const xe=L.find(Be=>Be.name===x.settingsDefaultAgent);if(xe)return xe.name}return L.find(xe=>xe.name==="build")?.name||L[0]?.name},[]),st=ie.useCallback(()=>{const x=kt.getState(),L=x.settingsDefaultModel;if(!L)return null;const xe=Nr(L);if(!xe)return null;const{providerId:Be,modelId:Ne}=xe;return x.getModelMetadata(Be,Ne)?{providerID:Be,modelID:Ne}:null},[]),Ae=ie.useCallback((x,L)=>{const xe=kt.getState(),Be=xe.settingsDefaultVariant,Ne=xe.currentProviderId===x&&xe.currentModelId===L?xe.currentVariant:void 0,Ve=xe.providers.find(Ee=>Ee.id===x)?.models.find(Ee=>Ee.id===L)?.variants;if(!Ve)return Be||Ne||void 0;if(Be&&Object.prototype.hasOwnProperty.call(Ve,Be))return Be;if(Ne&&Object.prototype.hasOwnProperty.call(Ve,Ne))return Ne},[]),He=ie.useCallback(async x=>{if(!c||!o)return;const L=kt.getState(),xe=Cr.getState().lastUsedProvider,Be=st(),Ne=Be?.providerID||L.currentProviderId||xe?.providerID,Ke=Be?.modelID||L.currentModelId||xe?.modelID,Qe=Le()||L.currentAgentName||void 0;if(!Ne||!Ke){ve.error(r("session.newWorktree.error.noModelSelected"));return}const Ve=Ae(Ne,Ke);if(x.issue){if(!o.issueGet||!o.issueComments)return;const Ee=await o.issueGet(c,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 C=await o.issueComments(c,x.issue.number,{sourceRepo:x.issue.sourceRepo??null});if(C.connected===!1)throw new Error("Failed to load issue comments");const be=await gs("github.issue.review.visible",{issue_number:String(x.issue.number)}),Se=await gs("github.issue.review.instructions"),Re=Lc({repo:Ee.repo,issue:Ee.issue,comments:C.comments??[]});await at.getState().sendMessage(be,Ne,Ke,Qe,void 0,void 0,[{text:Se,synthetic:!0},{text:Re,synthetic:!0}],Ve,void 0,{sessionId:x.sessionId}),On(x.sessionId,x.directory,Un({url:Ee.issue.url,number:Ee.issue.number,title:Ee.issue.title,kind:"issue",author:Ee.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),ve.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(x.pr){if(!o.prContext)return;const Ee=await o.prContext(c,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 C=await gs("github.pr.review.visible",{pr_number:String(x.pr.number)}),be=await gs("github.pr.review.instructions"),Se=Fc(Ee);await at.getState().sendMessage(C,Ne,Ke,Qe,void 0,void 0,[{text:be,synthetic:!0},{text:Se,synthetic:!0}],Ve,void 0,{sessionId:x.sessionId}),On(x.sessionId,x.directory,Un({url:Ee.pr.url,number:Ee.pr.number,title:Ee.pr.title,kind:"pull",author:Ee.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),ve.success(r("session.newWorktree.toast.sessionFromPr"))}},[o,c,Le,st,Ae,r]),Fe=h==="new-branch"?m:v;ie.useEffect(()=>{if(!s||!S?.all||!c||m.sourceBranch)return;const x=m.sourceBranch;let L=!1;return(async()=>{try{const Be=await ba(c).catch(()=>null);if(L)return;const Ne=localStorage.getItem(nn),{sourceBranch:Ke,shouldClearSavedSourceBranch:Qe}=Ac({branches:S.all,savedSourceBranch:Ne,rootBranch:Be});if(Qe&&localStorage.removeItem(nn),L||x)return;Ke&&y(Ve=>({...Ve,sourceBranch:Ke}))}catch{}})(),()=>{L=!0}},[s,S?.all,c,m.sourceBranch]),ie.useLayoutEffect(()=>{if(!s)return;p("new-branch"),N({selectedBranch:"",worktreeName:""}),F(!1),M(!1),G(!1),D(!1),W(""),T(""),ye({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const x=P();y({branchName:x,worktreeName:x,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,includePrDiff:!1})},[s,P]),ie.useEffect(()=>{if(h!=="new-branch"||!m.isSyncingWorktreeName)return;const x=ks(m.branchName),L=xt(x);y(xe=>({...xe,worktreeName:L}))},[h,m.branchName,m.isSyncingWorktreeName]);const Ye=ie.useCallback(async()=>{if(!g||!ne.touched||Ie)return;Ue&&Ue.abort();const x=new AbortController;tt(x),ye(L=>({...L,isValidating:!0}));try{const L=h==="new-branch"?m.branchName:v.selectedBranch,xe=Fe.worktreeName,Be=ks(L),Ne=xt(xe);let Ke=null,Qe=null;if(Be||(Ke=r("session.newWorktree.error.branchNameRequired")),Ne||(Qe=r("session.newWorktree.error.worktreeDirectoryRequired")),Be&&Ne){const Ve=h==="new-branch"?m.linkedPr:null,Ee=Ve?ur(Ve,w,k):null,C=await Sr(g,{mode:h==="existing-branch"||Ee?"existing":"new",branchName:Be,worktreeName:Ne,existingBranch:Ee?.existingBranch??(h==="existing-branch"?Be:void 0),...Ee?.ensureRemoteName?{ensureRemoteName:Ee.ensureRemoteName}:{},...Ee?.ensureRemoteUrl?{ensureRemoteUrl:Ee.ensureRemoteUrl}:{}});if(x.signal.aborted)return;C.ok||C.errors.forEach(be=>{if(be.code==="worktree_exists"){Qe=Qe??be.message;return}be.code.startsWith("branch_")&&(Ke=Ke??be.message)})}x.signal.aborted||ye(Ve=>({...Ve,isValidating:!1,branchError:Ke,worktreeError:Qe}))}catch{x.signal.aborted||ye(L=>({...L,isValidating:!1}))}},[g,h,m.branchName,m.linkedPr,v.selectedBranch,Fe.worktreeName,w,k,ne.touched,Ue,Ie,r]),Ze=h==="new-branch"?m.branchName:v.selectedBranch;ie.useEffect(()=>{if(!s||!g||!ne.touched||Ie)return;const x=setTimeout(()=>{Ye()},300);return()=>clearTimeout(x)},[Fe.worktreeName,Ze,s,g,Ye,ne.touched,Ie]);const $e=async()=>{if(!g||!c){ve.error(r("session.newWorktree.error.noActiveProject"));return}ye(Ne=>({...Ne,touched:!0}));const x=h==="new-branch"?m.branchName:v.selectedBranch,L=Fe.worktreeName,xe=ks(x),Be=xt(L);if(!xe){ve.error(r("session.newWorktree.error.branchNameRequired"));return}if(!Be){ve.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Ue&&(Ue.abort(),tt(null)),ye(Ne=>({...Ne,isValidating:!1,branchError:null,worktreeError:null})),Me(!0);try{const Ne=h==="new-branch"?m.linkedPr:null,Ke=h==="new-branch"?m.linkedIssue:null,Qe=h==="new-branch"?m.linkedPr:null,Ve=h==="new-branch"?m.includePrDiff:!1,Ee=!!(Ke||Qe),C=await vr(g),be=m.sourceBranch;let Se="";const Re=(()=>{if(Ne){const We=ur(Ne,w,k);return Se=We.sourceLabel,{preferredName:xe||Be,mode:"existing",branchName:xe,worktreeName:Be,existingBranch:We.existingBranch,setupCommands:C,setUpstream:We.setUpstream,upstreamRemote:We.upstreamRemote,upstreamBranch:We.upstreamBranch,returnAfterDirectoryCreated:!0,...We.ensureRemoteName?{ensureRemoteName:We.ensureRemoteName}:{},...We.ensureRemoteUrl?{ensureRemoteUrl:We.ensureRemoteUrl}:{}}}return Se=h==="new-branch"?be:"",{preferredName:xe||Be,mode:h==="existing-branch"?"existing":"new",branchName:h==="existing-branch"?void 0:xe,worktreeName:Be,existingBranch:h==="existing-branch"?xe:void 0,setupCommands:C,returnAfterDirectoryCreated:!0,...be&&h==="new-branch"?{startRef:be}:{}}})(),ot=await ya(c,Re),it=await wa(g,ot);let nt=null;if(Ee){await jr(g)&&await va(it.path);const We=Ke?`#${Ke.number} ${Ke.title}`.trim():Qe?`#${Qe.number} ${Qe.title}`.trim():r("session.newWorktree.newSessionTitle"),ut=await ja(We,it.path,null);if(!ut?.id)throw new Error("Failed to create session");nt=ut.id,n?.(it.path,{sessionId:nt}),e(!1),Me(!1),ka(ut.id,We).catch(()=>{});try{at.getState().initializeNewOpenChamberSession(ut.id,kt.getState().agents)}catch{}}else e(!1),Me(!1);const mt=Rc({mode:h,sourceBranch:m.sourceBranch,linkedPr:!!m.linkedPr,selectedBranch:v.selectedBranch});mt&&localStorage.setItem(nn,mt),ve.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${it.branch||it.name}${Se?` ${r("session.newWorktree.fromSource",{source:Se})}`:""}`})}),nt?He({sessionId:nt,directory:it.path,issue:Ke,pr:Qe,includeDiff:Ve}).catch(We=>{const ut=We instanceof Error?We.message:r("session.newWorktree.error.sendGitHubContextFailed");ve.error(r("session.newWorktree.error.sendGitHubContextFailed"),{description:ut})}):n?.(it.path)}catch(Ne){const Ke=Ne instanceof Error?Ne.message:r("session.newWorktree.error.createWorktreeFailed");ve.error(r("session.newWorktree.error.createWorktreeFailed"),{description:Ke})}finally{Me(!1)}},Je=x=>{p(x),ye(L=>({...L,touched:!1,branchError:null,worktreeError:null}))},qe=x=>{if(!x){y(L=>({...L,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:""}));return}if(x.type==="issue"){const L=x.item,xe=`issue-${L.number}-${Xs()}`;y(Be=>({...Be,linkedIssue:L,linkedPr:null,includePrDiff:!1,branchName:xe,worktreeName:xt(xe),isSyncingWorktreeName:!0}))}else if(x.type==="pr"){const L=x.item;y(xe=>({...xe,linkedPr:L,linkedIssue:null,includePrDiff:x.includeDiff??!1,branchName:L.head,worktreeName:xt(L.head),isSyncingWorktreeName:!0}))}},Ce=d&&u?.connected===!0,ze=(h==="existing-branch"?!!v.selectedBranch&&!!v.worktreeName&&!ne.branchError&&!ne.worktreeError:!!ks(m.branchName)&&!!m.worktreeName&&!ne.branchError&&!ne.worktreeError)&&!Ie,Pe=()=>{y(x=>({...x,linkedIssue:null,linkedPr:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},lt=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(E,{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(ke,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,className:se(i&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(ke,{size:"sm",onClick:$e,disabled:!ze||Ie,className:se("gap-1.5",i&&"flex-1"),children:[Ie&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ie?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]});return t.jsxs(t.Fragment,{children:[i?t.jsxs(Ns,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:lt,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(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{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(ke,{variant:"outline",size:"sm",onClick:()=>G(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:v.selectedBranch?"text-foreground":"text-muted-foreground",children:v.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(ke,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:me,disabled:!Z||R,title:r("session.newWorktree.fetchBranches"),children:R?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]}),t.jsx(Ns,{open:ee,title:r("session.newWorktree.selectBranch"),onClose:()=>G(!1),children:t.jsxs("div",{className:"space-y-4",ref:le,children:[t.jsx(yt,{value:A,onChange:x=>W(x.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),R?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&k.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:[ue&&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(L=>({...L,selectedBranch:x.value,worktreeName:xt(x.label)})),ye(L=>({...L,touched:!0})),G(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.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}`))})]}),ue&&!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(ue?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:oe.otherLocal.map(x=>t.jsx("button",{onClick:()=>{N(L=>({...L,selectedBranch:x,worktreeName:xt(x)})),ye(L=>({...L,touched:!0})),G(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.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(ue?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:oe.otherRemote.map(x=>t.jsx("button",{onClick:()=>{N(L=>({...L,selectedBranch:`remotes/${x}`,worktreeName:xt(x)})),ye(L=>({...L,touched:!0})),G(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",v.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"&&Ce&&t.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>O(!0),className:"gap-1.5 h-7",children:[t.jsx(E,{name:"github",className:"size-4 text-status-success"}),m.linkedIssue||m.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:m.branchName,onChange:x=>{y(L=>({...L,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ye(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!m.linkedPr,className:se("h-8",ne.touched&&ne.branchError&&"border-destructive",m.linkedPr&&"bg-muted text-muted-foreground")}),m.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:m.linkedPr.head})})]}),m.linkedIssue&&!m.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:m.linkedIssue.number,title:m.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"?m.branchName:"");y(L=>({...L,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!m.branchName||m.worktreeName===xt(m.branchName),className:se("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",m.worktreeName===xt(m.branchName)||!m.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(E,{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(L=>({...L,worktreeName:x.target.value,isSyncingWorktreeName:!1})):N(L=>({...L,worktreeName:x.target.value}))},onBlur:()=>ye(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:se("h-8",ne.touched&&ne.worktreeError&&"border-destructive")})]}),h==="new-branch"&&!m.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(ke,{variant:"outline",size:"sm",onClick:()=>D(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:m.sourceBranch?"text-foreground":"text-muted-foreground",children:m.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),m.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:m.sourceBranch})}),t.jsx(Ns,{open:U,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>D(!1),children:t.jsxs("div",{className:"space-y-4",ref:te,children:[t.jsx(yt,{value:H,onChange:x=>T(x.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),R?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&k.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:ae.matching.map(x=>t.jsx("button",{onClick:()=>{y(L=>({...L,sourceBranch:x.value})),D(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",m.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")}),ae.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:ae.otherLocal.map(x=>t.jsx("button",{onClick:()=>{y(L=>({...L,sourceBranch:x})),D(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",m.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))})]}),ae.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:ae.otherRemote.map(x=>t.jsx("button",{onClick:()=>{y(L=>({...L,sourceBranch:`remotes/${x}`})),D(!1)},className:se("w-full text-left px-3 py-2.5 rounded-md transition-colors",m.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}`))})]})]})]})})]}),(m.linkedIssue||m.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(E,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),m.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:m.linkedIssue.number})}),m.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:m.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:m.linkedIssue?.title||m.linkedPr?.title}),t.jsx("a",{href:m.linkedIssue?.url||m.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Pe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),m.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:[m.linkedPr.head," → ",m.linkedPr.base]}),m.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(Ts,{open:s,onOpenChange:e,children:t.jsxs(Ps,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Vs,{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(E,{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(E,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"existing-branch",label:r("session.newWorktree.mode.existingBranch"),icon:t.jsx(E,{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:K,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",v.selectedBranch?"text-foreground":"text-muted-foreground"),children:v.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{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:_,children:t.jsxs(gn,{shouldFilter:!1,children:[t.jsx(xn,{placeholder:r("session.newWorktree.searchBranches"),value:A,onValueChange:W,onKeyDown:Q}),t.jsx(bn,{disableHorizontal:!0,children:R?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&k.length===0?t.jsx(yn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[ue&&j&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:oe.matching.map(x=>t.jsx(Et,{value:x.value,onSelect:()=>{N(L=>({...L,selectedBranch:x.value,worktreeName:xt(x.label)})),ye(L=>({...L,touched:!0})),F(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x.label})},`${x.source}-${x.value}`))}),ue&&!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:[ue&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(ue?"session.newWorktree.otherLocalBranches":"session.newWorktree.localBranches"),children:oe.otherLocal.map(x=>t.jsx(Et,{value:x,onSelect:()=>{N(L=>({...L,selectedBranch:x,worktreeName:xt(x)})),ye(L=>({...L,touched:!0})),F(!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||ue)&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(ue?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:oe.otherRemote.map(x=>t.jsx(Et,{value:`remotes/${x}`,onSelect:()=>{N(L=>({...L,selectedBranch:`remotes/${x}`,worktreeName:xt(x)})),ye(L=>({...L,touched:!0})),F(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),t.jsx(ke,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:me,disabled:!Z||R,title:r("session.newWorktree.fetchBranches"),children:R?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{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"&&Ce&&t.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>O(!0),className:"gap-1.5 h-7",children:[t.jsx(E,{name:"github",className:"size-4 text-status-success"}),m.linkedIssue||m.linkedPr?r("session.newWorktree.actions.change"):r("session.newWorktree.actions.startFromGitHubIssuePr")]})]}),t.jsx(yt,{value:m.branchName,onChange:x=>{y(L=>({...L,branchName:x.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>ye(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!m.linkedPr,className:se("h-8",ne.touched&&ne.branchError&&"border-destructive",m.linkedPr&&"bg-muted text-muted-foreground")}),m.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.usingPrBranch",{branch:m.linkedPr.head})})]}),m.linkedIssue&&!m.linkedPr&&t.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(E,{name:"check",className:"h-3.5 w-3.5 text-status-success"}),t.jsx("span",{className:"typography-micro",children:r("session.newWorktree.fromIssue",{number:m.linkedIssue.number,title:m.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"?m.branchName:"");y(L=>({...L,worktreeName:x,isSyncingWorktreeName:!0}))},disabled:!m.branchName||m.worktreeName===xt(m.branchName),className:se("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",m.worktreeName===xt(m.branchName)||!m.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(E,{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(L=>({...L,worktreeName:x.target.value,isSyncingWorktreeName:!1})):N(L=>({...L,worktreeName:x.target.value}))},onBlur:()=>ye(x=>({...x,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:se("h-8",ne.touched&&ne.worktreeError&&"border-destructive")})]}),h==="new-branch"&&!m.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:X,onOpenChange:M,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",m.sourceBranch?"text-foreground":"text-muted-foreground"),children:m.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{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:Y,children:t.jsxs(gn,{shouldFilter:!1,children:[t.jsx(xn,{placeholder:r("session.newWorktree.searchBranches"),value:H,onValueChange:T,onKeyDown:Q}),t.jsx(bn,{disableHorizontal:!0,children:R?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):w.length===0&&k.length===0?t.jsx(yn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[he&&V&&t.jsx(Ft,{heading:r("session.newWorktree.matchingBranches"),children:ae.matching.map(x=>t.jsx(Et,{value:x.value,onSelect:()=>{y(L=>({...L,sourceBranch:x.value})),M(!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")}),ae.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:ae.otherLocal.map(x=>t.jsx(Et,{value:x,onSelect:()=>{y(L=>({...L,sourceBranch:x})),M(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`local-${x}`))})]}),ae.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[(ae.otherLocal.length>0||he)&&t.jsx(ps,{}),t.jsx(Ft,{heading:r(he?"session.newWorktree.otherRemoteBranches":"session.newWorktree.remoteBranches"),children:ae.otherRemote.map(x=>t.jsx(Et,{value:`remotes/${x}`,onSelect:()=>{y(L=>({...L,sourceBranch:`remotes/${x}`})),M(!1)},children:t.jsx("span",{className:"typography-small break-all",children:x})},`remote-${x}`))})]})]})})]})})]}),m.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:m.sourceBranch})})]}),(m.linkedIssue||m.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(E,{name:"github",className:"h-3.5 w-3.5 text-status-success shrink-0"}),m.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:m.linkedIssue.number})}),m.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:m.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:m.linkedIssue?.title||m.linkedPr?.title}),t.jsx("a",{href:m.linkedIssue?.url||m.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:x=>x.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:Pe,className:"text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors",children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),m.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:[m.linkedPr.head," → ",m.linkedPr.base]}),m.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(Cn,{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(E,{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(ke,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,children:r("session.newWorktree.actions.cancel")}),t.jsxs(ke,{size:"sm",onClick:$e,disabled:!ze||Ie,className:"gap-1.5",children:[Ie&&t.jsx(E,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),r(Ie?"session.newWorktree.actions.creating":"session.newWorktree.actions.createWorktree")]})]})]})]})}),t.jsx(Bc,{open:z,onOpenChange:O,onSelect:qe})]})}const Oc=(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}},Uc=s=>{switch(s?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},Zu=({active:s,className:e,headerAction:n,listClassName:r,hideHeader:o=!1,mobileListDensity:a=!1})=>{const{t:i}=Xe(),d=Rs(w=>w.currentDirectory)??null,l=Ms(w=>w.getStatusForDirectory(d)),c=Ms(w=>w.refresh),g=Ms(w=>w.connect),h=Ms(w=>w.disconnect),p=Wn(w=>w.mcpServers),m=Wn(w=>w.loadMcpConfigs),[y,v]=f.useState(!1),[N,S]=f.useState(null);f.useEffect(()=>{c({directory:d,silent:!0})},[c,d]),f.useEffect(()=>{m({force:!0})},[m]),f.useEffect(()=>{s&&Promise.all([c({directory:d,silent:!0}),m({force:!0})])},[s,c,d,m]);const R=f.useMemo(()=>{const w=new Set(Object.keys(l));for(const k of p)k?.name&&w.add(k.name);return Array.from(w).sort((k,b)=>k.localeCompare(b))},[p,l]),$=f.useCallback(w=>{if(w?.preventDefault(),y)return;v(!0);const k=new Promise(b=>setTimeout(b,500));Promise.all([c({directory:d}),k]).finally(()=>{v(!1)})},[y,c,d]);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")}),d&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:d.split("/").pop()||d})]}),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:$,"aria-label":i("mcpDropdown.actions.refreshAria"),children:t.jsx(E,{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&&R.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[R.map(w=>{const k=l[w],b=Uc(k),I=k?.status==="connected",P=N===w,z=Oc(k,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(Kt,{children:[t.jsx(Ht,{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":z})}),t.jsx(qt,{side:"left",children:t.jsx("p",{children:z})})]}),t.jsx("span",{className:se("truncate",a?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:w})]})}),t.jsx(Na,{checked:I,disabled:P,className:"data-[checked]:bg-status-info",onCheckedChange:async O=>{S(w);try{if(!O){await h(w,d);return}const K=l?.[w]?.status;if(K==="needs_auth"||K==="needs_client_registration"){const{opened:F}=await Sa({name:w,directory:d});F||Gn.error(i("mcpDropdown.toast.authorizeOpenFailed"));return}await g(w,d)}catch(K){Gn.error(K instanceof Error?K.message:i("mcpDropdown.toast.authorizeFailed"))}finally{S(null)}}})]},w)}),R.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:i("mcpDropdown.empty.configureInConfig")})]})})]})},En=(s,e)=>s==="global"?"global":`project:${e??""}`,to=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,fr=(s,e)=>s.reduce((n,r)=>to(r,e)?n+1:n,0),so=s=>{const e=_e.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:u,expandLabel:d}=s,{t:l}=Xe(),c=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let g;e[0]!==c?(g=se("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",c),e[0]=c,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 m=n?void 0:"button",y=n?void 0:0,v=n?void 0:d;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]!==l?(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":l("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:l("rightSidebar.contextNotesTodo.notes.actions.collapse"),children:t.jsx(E,{name:"arrow-up-s",className:"h-3.5 w-3.5"})}):null,e[8]=n,e[9]=r,e[10]=l,e[11]=S):S=e[11];let R;e[12]!==i||e[13]!==S?(R=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:$c,onKeyDown:Wc,children:[S,i]}),e[12]=i,e[13]=S,e[14]=R):R=e[14];let $;e[15]!==R||e[16]!==N?($=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[N,R]}),e[15]=R,e[16]=N,e[17]=$):$=e[17];let w;e[18]!==u?(w=u?t.jsx("div",{className:"min-w-0",children:u}):null,e[18]=u,e[19]=w):w=e[19];let k;return e[20]!==$||e[21]!==w||e[22]!==g||e[23]!==h||e[24]!==p||e[25]!==m||e[26]!==y||e[27]!==v?(k=t.jsxs("li",{className:g,onClick:h,onKeyDown:p,role:m,tabIndex:y,"aria-label":v,children:[$,w]}),e[20]=$,e[21]=w,e[22]=g,e[23]=h,e[24]=p,e[25]=m,e[26]=y,e[27]=v,e[28]=k):k=e[28],k};function $c(s){return s.stopPropagation()}function Wc(s){return s.stopPropagation()}const _c=s=>{const e=_e.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:u}=s,{t:d}=Xe(),[l,c]=f.useState(n.title),[g,h]=f.useState(n.body);let p,m;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(p=()=>{o||(c(n.title),h(n.body))},m=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=p,e[4]=m):(p=e[3],m=e[4]),f.useEffect(p,m);let y;e[5]!==g||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==l?(y=()=>{const M=l.trim(),ee=g.trim();if(!M||!ee){c(n.title),h(n.body);return}M===n.title&&ee===n.body||i({title:M,body:ee})},e[5]=g,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=l,e[10]=y):y=e[10];const v=y,N=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let S;e[11]!==d||e[12]!==N?(S=d(N),e[11]=d,e[12]=N,e[13]=S):S=e[13];const R=S;let $;e[14]!==v||e[15]!==o||e[16]!==a?($=()=>{o&&v(),a()},e[14]=v,e[15]=o,e[16]=a,e[17]=$):$=e[17];const w=n.title;let k;e[18]!==n.flagged||e[19]!==d?(k=n.flagged?t.jsxs("span",{className:"flex items-center gap-1 text-[var(--status-error)]",children:[t.jsx(E,{name:"error-warning",className:"h-3 w-3 flex-shrink-0"}),d("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=d,e[20]=k):k=e[20];let b;e[21]!==k||e[22]!==R?(b=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[R,k]}),e[21]=k,e[22]=R,e[23]=b):b=e[23];let I;e[24]!==r||e[25]!==d?(I=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:d(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=d,e[26]=I):I=e[26];let P;e[27]!==d?(P=d("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=d,e[28]=P):P=e[28];let z;e[29]!==d?(z=d("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=d,e[30]=z):z=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=O):O=e[31];let K;e[32]!==u||e[33]!==P||e[34]!==z?(K=t.jsx("button",{type:"button",onClick:u,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":P,title:z,children:O}),e[32]=u,e[33]=P,e[34]=z,e[35]=K):K=e[35];let F;e[36]!==g||e[37]!==v||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==d||e[42]!==l?(F=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(yt,{value:l,onChange:M=>c(M.target.value.slice(0,Ca)),onBlur:v,"aria-label":d("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:M=>h(M.target.value.slice(0,Ia)),onBlur:v,"aria-label":d("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]=v,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=d,e[42]=l,e[43]=F):F=e[43];let X;return e[44]!==n.title||e[45]!==o||e[46]!==I||e[47]!==K||e[48]!==F||e[49]!==$||e[50]!==b?(X=t.jsx(so,{expanded:o,onToggleExpanded:$,expandLabel:w,footer:b,header:I,actions:K,children:F}),e[44]=n.title,e[45]=o,e[46]=I,e[47]=K,e[48]=F,e[49]=$,e[50]=b,e[51]=X):X=e[51],X},zc=s=>{const e=_e.c(55),{projectPath:n,query:r}=s,{t:o}=Xe(),[a,i]=f.useState("project"),[u,d]=f.useState(null),l=Dt(Vc),c=Dt(Gc),g=Dt(Kc),h=Dt(Hc),p=Dt(qc),m=Dt(Yc),y=De(Jc),v=a==="global"?l:c,N=a==="global"?g:h;let S;e[0]!==n||e[1]!==a?(S=En(a,n),e[0]=n,e[1]=a,e[2]=S):S=e[2];const R=S;let $;e[3]!==R?($=Q=>Q.agentMemoryViewedAt[R]??0,e[3]=R,e[4]=$):$=e[4];const w=De($),k=f.useRef(w),[b,I]=f.useState(w);let P,z;e[5]!==y||e[6]!==R?(P=()=>(k.current=De.getState().agentMemoryViewedAt[R]??0,I(k.current),()=>{y(R,Date.now())}),z=[y,R],e[5]=y,e[6]=R,e[7]=P,e[8]=z):(P=e[7],z=e[8]),f.useEffect(P,z);let O;if(e[9]!==v||e[10]!==r){e:{const Q=r.trim().toLowerCase();if(!Q){O=v;break e}O=v.filter(q=>q.title.toLowerCase().includes(Q)||q.body.toLowerCase().includes(Q))}e[9]=v,e[10]=r,e[11]=O}else O=e[11];const K=O;let F;e[12]!==p||e[13]!==a||e[14]!==o?(F=async Q=>{if(!await p(a,Q)){const q=Dt.getState().error;ve.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),q?{description:q}:void 0)}},e[12]=p,e[13]=a,e[14]=o,e[15]=F):F=e[15];const X=F;let M;e[16]!==m||e[17]!==a||e[18]!==o?(M=async(Q,q)=>{if(!await m(a,Q,q)){const re=Dt.getState().error;ve.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),re?{description:re}:void 0)}},e[16]=m,e[17]=a,e[18]=o,e[19]=M):M=e[19];const ee=M;let G;e[20]!==o?(G=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[20]=o,e[21]=G):G=e[21];let U;e[22]!==c.length||e[23]!==G?(U={id:"project",label:G,count:c.length},e[22]=c.length,e[23]=G,e[24]=U):U=e[24];let D;e[25]!==o?(D=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[25]=o,e[26]=D):D=e[26];let A;e[27]!==l.length||e[28]!==D?(A={id:"global",label:D,count:l.length},e[27]=l.length,e[28]=D,e[29]=A):A=e[29];let W;e[30]!==A||e[31]!==U?(W=[U,A],e[30]=A,e[31]=U,e[32]=W):W=e[32];const H=W;let T;e[33]!==o?(T=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[33]=o,e[34]=T):T=e[34];let _;e[35]!==a||e[36]!==H?(_=H.map(Q=>t.jsx(ke,{type:"button",variant:"chip",size:"xs","aria-pressed":a===Q.id,className:"!font-normal",onClick:()=>i(Q.id),children:`${Q.label} ${Q.count}`},Q.id)),e[35]=a,e[36]=H,e[37]=_):_=e[37];let Y;e[38]!==T||e[39]!==_?(Y=t.jsx("div",{role:"group","aria-label":T,className:"flex items-center gap-1",children:_}),e[38]=T,e[39]=_,e[40]=Y):Y=e[40];let le;e[41]!==b||e[42]!==u||e[43]!==X||e[44]!==ee||e[45]!==n||e[46]!==r||e[47]!==a||e[48]!==N||e[49]!==o||e[50]!==K?(le=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")}):K.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:K.map(Q=>t.jsx(_c,{entry:Q,badge:to(Q,b),expanded:u===Q.id,onToggleExpanded:()=>d(u===Q.id?null:Q.id),onSave:q=>{ee(Q.id,q)},onDelete:()=>{X(Q.id)}},Q.id))}),e[41]=b,e[42]=u,e[43]=X,e[44]=ee,e[45]=n,e[46]=r,e[47]=a,e[48]=N,e[49]=o,e[50]=K,e[51]=le):le=e[51];let te;return e[52]!==Y||e[53]!==le?(te=t.jsxs("div",{className:"flex flex-col gap-2",children:[Y,le]}),e[52]=Y,e[53]=le,e[54]=te):te=e[54],te};function Vc(s){return s.global}function Gc(s){return s.project}function Kc(s){return s.globalFailed}function Hc(s){return s.projectFailed}function qc(s){return s.deleteEntry}function Yc(s){return s.saveEntry}function Jc(s){return s.markAgentMemoryViewed}const Qc=400,Xc=s=>{const e=_e.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:u,onDelete:d}=s,{t:l}=Xe(),[c,g]=f.useState(n.body),h=f.useRef(n.body),p=f.useRef(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},e[0]=m):m=e[0];const y=m;let v,N;e[1]!==c||e[2]!==n.body?(v=()=>{n.body!==h.current&&c===h.current&&(h.current=n.body,g(n.body))},N=[c,n.body],e[1]=c,e[2]=n.body,e[3]=v,e[4]=N):(v=e[3],N=e[4]),f.useEffect(v,N);let S,R;e[5]!==c||e[6]!==i?(S=()=>{if(c!==h.current)return p.current=window.setTimeout(()=>{p.current=null,c.trim()&&(h.current=c,i(c))},Qc),y},R=[y,c,i],e[5]=c,e[6]=i,e[7]=S,e[8]=R):(S=e[7],R=e[8]),f.useEffect(S,R);let $,w;e[9]===Symbol.for("react.memo_cache_sentinel")?($=()=>y,w=[y],e[9]=$,e[10]=w):($=e[9],w=e[10]),f.useEffect($,w);let k;e[11]!==c||e[12]!==i?(k=()=>{if(y(),c!==h.current){if(!c.trim()){g(h.current);return}h.current=c,i(c)}},e[11]=c,e[12]=i,e[13]=k):k=e[13];const b=k;let I;e[14]!==n.source||e[15]!==l?(I=n.source==="selection"?l("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?l("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=l,e[16]=I):I=e[16];const P=I;let z;e[17]!==l?(z=l("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=l,e[18]=z):z=e[18];let O;e[19]!==P?(O=P?t.jsx("span",{className:"typography-micro text-muted-foreground",children:P}):null,e[19]=P,e[20]=O):O=e[20];const K=r?"text-primary":"text-muted-foreground hover:text-foreground";let F;e[21]!==K?(F=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",K),e[21]=K,e[22]=F):F=e[22];let X;e[23]!==r||e[24]!==l?(X=l(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=l,e[25]=X):X=e[25];let M;e[26]!==r||e[27]!==l?(M=l(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=l,e[28]=M):M=e[28];const ee=r?"pushpin-2-fill":"pushpin";let G;e[29]!==ee?(G=t.jsx(E,{name:ee,className:"h-3.5 w-3.5"}),e[29]=ee,e[30]=G):G=e[30];let U;e[31]!==u||e[32]!==r||e[33]!==F||e[34]!==X||e[35]!==M||e[36]!==G?(U=t.jsx("button",{type:"button",onClick:u,className:F,"aria-pressed":r,"aria-label":X,title:M,children:G}),e[31]=u,e[32]=r,e[33]=F,e[34]=X,e[35]=M,e[36]=G,e[37]=U):U=e[37];let D;e[38]!==l?(D=l("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=l,e[39]=D):D=e[39];let A;e[40]!==l?(A=l("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=l,e[41]=A):A=e[41];let W;e[42]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[42]=W):W=e[42];let H;e[43]!==d||e[44]!==D||e[45]!==A?(H=t.jsx("button",{type:"button",onClick:d,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,title:A,children:W}),e[43]=d,e[44]=D,e[45]=A,e[46]=H):H=e[46];let T;e[47]!==U||e[48]!==H?(T=t.jsxs(t.Fragment,{children:[U,H]}),e[47]=U,e[48]=H,e[49]=T):T=e[49];let _;e[50]!==c||e[51]!==o||e[52]!==b?(_=o?t.jsx(Ks,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,c.split(`
6
+ `).length+1)),value:c,onChange:le=>g(le.target.value.slice(0,wn)),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:c,children:c}),e[50]=c,e[51]=o,e[52]=b,e[53]=_):_=e[53];let Y;return e[54]!==o||e[55]!==a||e[56]!==z||e[57]!==O||e[58]!==T||e[59]!==_?(Y=t.jsx(so,{expanded:o,onToggleExpanded:a,expandLabel:z,footer:O,actions:T,children:_}),e[54]=o,e[55]=a,e[56]=z,e[57]=O,e[58]=T,e[59]=_,e[60]=Y):Y=e[60],Y},Zc=s=>{const e=_e.c(67),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:u}=s,{t:d}=Xe(),[l,c]=f.useState(""),[g,h]=f.useState(null),p=De(ed),m=De(td),y=Rt(sd),v=Rt(nd),N=Rt(rd);let S;if(e[0]!==r||e[1]!==a){e:{const te=a.trim().toLowerCase();if(!te){S=r;break e}S=r.filter(Q=>Q.body.toLowerCase().includes(te))}e[0]=r,e[1]=a,e[2]=S}else S=e[2];const R=S;let $;e[3]!==n?($=te=>{const Q=Rt.getState().getEntry(n).error;ve.error(te,Q?{description:Q}:void 0)},e[3]=n,e[4]=$):$=e[4];const w=$;let k;e[5]!==l||e[6]!==y||e[7]!==n||e[8]!==w||e[9]!==d?(k=async()=>{const te=l.trim();if(!te)return;if(!await y(n,{body:te})){w(d("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}c("")},e[5]=l,e[6]=y,e[7]=n,e[8]=w,e[9]=d,e[10]=k):k=e[10];const b=k;let I;e[11]!==N||e[12]!==n||e[13]!==w||e[14]!==d?(I=async te=>{await N(n,te)||w(d("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[11]=N,e[12]=n,e[13]=w,e[14]=d,e[15]=I):I=e[15];const P=I;let z;e[16]!==u||e[17]!==w||e[18]!==d?(z=async(te,Q)=>{await u(te,Q)||w(d("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[16]=u,e[17]=w,e[18]=d,e[19]=z):z=e[19];const O=z;let K;e[20]!==n||e[21]!==w||e[22]!==v||e[23]!==d?(K=(te,Q)=>{v(n,te,Q).then(q=>{q||w(d("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[20]=n,e[21]=w,e[22]=v,e[23]=d,e[24]=K):K=e[24];const F=K;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=te=>c(te.target.value.slice(0,wn)),e[25]=X):X=e[25];let M;e[26]!==d?(M=d("rightSidebar.contextNotesTodo.notes.placeholder"),e[26]=d,e[27]=M):M=e[27];let ee;e[28]!==l.length?(ee=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[l.length,"/",wn]}),e[28]=l.length,e[29]=ee):ee=e[29];let G;e[30]!==b?(G=()=>{b()},e[30]=b,e[31]=G):G=e[31];let U;e[32]!==l||e[33]!==o?(U=o||l.trim().length===0,e[32]=l,e[33]=o,e[34]=U):U=e[34];let D;e[35]!==d?(D=d("rightSidebar.contextNotesTodo.notes.addAria"),e[35]=d,e[36]=D):D=e[36];let A;e[37]!==d?(A=d("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=d,e[38]=A):A=e[38];let W;e[39]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[39]=W):W=e[39];let H;e[40]!==G||e[41]!==U||e[42]!==D||e[43]!==A?(H=t.jsx("button",{type:"button",onClick:G,disabled:U,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":D,title:A,children:W}),e[40]=G,e[41]=U,e[42]=D,e[43]=A,e[44]=H):H=e[44];let T;e[45]!==H||e[46]!==ee?(T=t.jsxs(t.Fragment,{children:[ee,H]}),e[45]=H,e[46]=ee,e[47]=T):T=e[47];let _;e[48]!==l||e[49]!==o||e[50]!==p||e[51]!==m||e[52]!==T||e[53]!==M?(_=t.jsx(Ks,{value:l,onChange:X,placeholder:M,resizedHeight:p,onResizeHeightChange:m,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:T}),e[48]=l,e[49]=o,e[50]=p,e[51]=m,e[52]=T,e[53]=M,e[54]=_):_=e[54];let Y;e[55]!==g||e[56]!==P||e[57]!==F||e[58]!==O||e[59]!==i||e[60]!==a||e[61]!==d||e[62]!==R?(Y=t.jsx("div",{children:R.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?d("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):d("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:R.map(te=>t.jsx(Xc,{note:te,pinned:i.has(te.id),expanded:g===te.id,onToggleExpanded:()=>h(Q=>Q===te.id?null:te.id),onSaveBody:Q=>F(te.id,Q),onTogglePinned:()=>{O(te.id,!i.has(te.id))},onDelete:()=>{P(te.id)}},te.id))})}),e[55]=g,e[56]=P,e[57]=F,e[58]=O,e[59]=i,e[60]=a,e[61]=d,e[62]=R,e[63]=Y):Y=e[63];let le;return e[64]!==_||e[65]!==Y?(le=t.jsxs("div",{className:"space-y-2",children:[_,Y]}),e[64]=_,e[65]=Y,e[66]=le):le=e[66],le};function ed(s){return s.notesPanelHeight}function td(s){return s.setNotesPanelHeight}function sd(s){return s.createNote}function nd(s){return s.saveNoteBody}function rd(s){return s.deleteNote}const od=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=Xe(),u=f.useRef(null),[d,l]=f.useState(!1),[c,g]=f.useState(null),h=Rt(b=>b.createPlan),p=Rt(b=>b.deletePlan),m=Rs(b=>b.currentDirectory),y=De(b=>b.openContextPanelTab),v=f.useCallback(async b=>{if(!c){g(b);try{await p(s,b)||ve.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{g(null)}}},[c,s,p,i]),N=f.useCallback(async(b,I)=>{if(!b.trim()){ve.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const P=Ta(b,I||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await h(s,{title:P.title,body:P.body})){ve.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}ve.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[h,s,i]),S=f.useCallback(async()=>{if(d)return;const b=await li({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(b.success&&b.path){l(!0);try{const I=new URLSearchParams({path:b.path,allowOutsideWorkspace:"true"});b.outsideFileGrant&&I.set("outsideFileGrant",b.outsideFileGrant);const P=await Bt(`/api/fs/read?${I.toString()}`,{cache:"no-store"});if(!P.ok){ve.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const z=await P.text(),O=b.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await N(z,O)}catch(I){const P=I instanceof Error?I.message:void 0;ve.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),P?{description:P}:void 0)}finally{l(!1)}return}b.error==="Native file picker not available"&&u.current?.click()},[N,d,s.path,i]),R=f.useCallback(async b=>{if(b){l(!0);try{const I=await b.text(),P=b.name.replace(/\.(md|markdown|txt)$/i,"").trim();await N(I,P)}catch(I){const P=I instanceof Error?I.message:void 0;ve.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),P?{description:P}:void 0)}finally{l(!1)}}},[N,i]),$=f.useCallback(async(b,I)=>{if(!await a(b,I)){const z=Rt.getState().getEntry(s).error;ve.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),z?{description:z}:void 0)}},[a,s,i]),w=f.useMemo(()=>{const b=n.trim().toLowerCase();return b?e.filter(I=>I.title.toLowerCase().includes(b)):e},[e,n]),k=f.useCallback(b=>{if(r){r({id:b.id,title:b.title});return}const I=m?.trim()||s.path.trim();I&&y(I,{mode:"plan",projectPlanId:b.id,dedupeKey:`plan:${b.id}`,label:b.title})},[m,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:u,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:b=>{const I=b.target.files?.[0]??null;R(I),b.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:S,disabled:d,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(E,{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:()=>k(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(yr())})]}),t.jsx("button",{type:"button",onClick:()=>{$(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(E,{name:"pushpin",className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>{v(b.id)},disabled:c===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(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},b.id))})})]})},ad=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,id=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],mr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},ld=s=>{const e=_e.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:u,setActivatorNodeRef:d,transform:l,transition:c,isDragging:g}=$r(o);let h;e[2]!==l?(h=_r.Transform.toString(l),e[2]=l,e[3]=h):h=e[3];let p;e[4]!==h||e[5]!==c?(p={transform:h,transition:c},e[4]=h,e[5]=c,e[6]=p):p=e[6];const m=g&&"opacity-60";let y;e[7]!==m?(y=se(m),e[7]=m,e[8]=y):y=e[8];let v;e[9]!==a||e[10]!==r||e[11]!==g||e[12]!==i||e[13]!==d?(v=r({attributes:a,listeners:i,setActivatorNodeRef:d,isDragging:g}),e[9]=a,e[10]=r,e[11]=g,e[12]=i,e[13]=d,e[14]=v):v=e[14];let N;return e[15]!==u||e[16]!==p||e[17]!==y||e[18]!==v?(N=t.jsx("li",{ref:u,style:p,className:y,children:v}),e[15]=u,e[16]=p,e[17]=y,e[18]=v,e[19]=N):N=e[19],N},cd=s=>{const e=_e.c(80),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:u,onSendToCurrentSession:d,onSendToNewSession:l,onSendToNewWorktreeSession:c}=s,{t:g}=Xe(),[h,p]=f.useState(""),[m,y]=f.useState(dd);let v;e[0]!==h||e[1]!==u||e[2]!==n?(v=()=>{const j=h.trim();j&&(u(mr(n,{id:ad(),text:j.slice(0,Ls),completed:!1,createdAt:Date.now()})),p(""))},e[0]=h,e[1]=u,e[2]=n,e[3]=v):v=e[3];const N=v;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 R=S;let $;e[5]!==u||e[6]!==n?($=(j,V)=>{const Z=n.find(ye=>ye.id===j);if(!Z||Z.completed===V)return;const me=n.filter(ye=>ye.id!==j),ne={...Z,completed:V};u(V?[...me,ne]:mr(me,ne))},e[5]=u,e[6]=n,e[7]=$):$=e[7];const w=$;let k;e[8]!==u||e[9]!==n?(k=j=>{u(n.filter(V=>V.id!==j))},e[8]=u,e[9]=n,e[10]=k):k=e[10];const b=k;let I;e[11]!==u||e[12]!==n?(I=()=>{const j=n.filter(ud);j.length!==n.length&&u(j)},e[11]=u,e[12]=n,e[13]=I):I=e[13];const P=I;let z;e[14]!==u||e[15]!==n?(z=j=>{const{active:V,over:Z}=j;if(!Z||V.id===Z.id)return;const me=n.findIndex(ye=>ye.id===V.id),ne=n.findIndex(ye=>ye.id===Z.id);me===-1||ne===-1||u(id(Ii(n,me,ne)))},e[14]=u,e[15]=n,e[16]=z):z=e[16];const O=z;let K;e[17]===Symbol.for("react.memo_cache_sentinel")?(K={activationConstraint:{distance:8}},e[17]=K):K=e[17];const F=Mr(Lr(Fr,K));let X;e[18]!==h?(X=h.slice(0,Ls),e[18]=h,e[19]=X):X=e[19];const M=X;let ee;e[20]!==n?(ee=n.reduce(fd,0),e[20]=n,e[21]=ee):ee=e[21];const G=ee;let U;if(e[22]!==r||e[23]!==n){e:{const j=r.trim().toLowerCase();if(!j){U=n;break e}U=n.filter(V=>V.text.toLowerCase().includes(j))}e[22]=r,e[23]=n,e[24]=U}else U=e[24];const D=U,A=o||G===0;let W;e[25]!==g?(W=g("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[25]=g,e[26]=W):W=e[26];let H;e[27]!==P||e[28]!==A||e[29]!==W?(H=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:P,disabled:A,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]=P,e[28]=A,e[29]=W,e[30]=H):H=e[30];let T;e[31]!==M.length?(T=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[M.length,"/",Ls]}),e[31]=M.length,e[32]=T):T=e[32];let _;e[33]!==H||e[34]!==T?(_=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[H,T]}),e[33]=H,e[34]=T,e[35]=_):_=e[35];let Y;e[36]===Symbol.for("react.memo_cache_sentinel")?(Y=j=>p(j.target.value.slice(0,Ls)),e[36]=Y):Y=e[36];let le;e[37]!==N?(le=j=>{j.key==="Enter"&&(j.preventDefault(),N())},e[37]=N,e[38]=le):le=e[38];let te;e[39]!==g?(te=g("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[39]=g,e[40]=te):te=e[40];let Q;e[41]!==o||e[42]!==le||e[43]!==te||e[44]!==M?(Q=t.jsx(yt,{value:M,onChange:Y,onKeyDown:le,placeholder:te,disabled:o,className:"h-8"}),e[41]=o,e[42]=le,e[43]=te,e[44]=M,e[45]=Q):Q=e[45];let q;e[46]!==o||e[47]!==M?(q=o||M.trim().length===0,e[46]=o,e[47]=M,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 J;e[51]!==g?(J=g("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=g,e[52]=J):J=e[52];let ce;e[53]===Symbol.for("react.memo_cache_sentinel")?(ce=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[53]=ce):ce=e[53];let oe;e[54]!==N||e[55]!==q||e[56]!==re||e[57]!==J?(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:J,children:ce}),e[54]=N,e[55]=q,e[56]=re,e[57]=J,e[58]=oe):oe=e[58];let ae;e[59]!==Q||e[60]!==oe?(ae=t.jsxs("div",{className:"flex items-center gap-1.5",children:[Q,oe]}),e[59]=Q,e[60]=oe,e[61]=ae):ae=e[61];let ue;e[62]!==a||e[63]!==m||e[64]!==b||e[65]!==O||e[66]!==w||e[67]!==d||e[68]!==l||e[69]!==c||e[70]!==r||e[71]!==i||e[72]!==g||e[73]!==F||e[74]!==D?(ue=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:D.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(Or,{sensors:F,collisionDetection:Ur,onDragEnd:O,children:t.jsx(Wr,{items:D.map(md),strategy:Ci,children:t.jsx("ul",{className:"divide-y divide-border/50",children:D.map(j=>{const V=m.has(j.id);return t.jsx(ld,{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:hd,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(E,{name:"draggable",className:"h-3.5 w-3.5"})}),t.jsx("div",{className:"flex h-6 items-center",children:t.jsx(Es,{checked:j.completed,onChange:me=>w(j.id,me),ariaLabel:g("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:j.text})})}),t.jsx("button",{type:"button",onClick:()=>R(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(E,{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(E,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(_t,{align:"end",className:"w-56",children:[t.jsx(At,{onClick:()=>d(j.text),children:g("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(At,{onClick:()=>l(j.id,j.text),children:g("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(At,{onClick:()=>c(j.id,j.text),disabled:!a,children:g("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},j.id)})})})})}),e[62]=a,e[63]=m,e[64]=b,e[65]=O,e[66]=w,e[67]=d,e[68]=l,e[69]=c,e[70]=r,e[71]=i,e[72]=g,e[73]=F,e[74]=D,e[75]=ue):ue=e[75];let he;return e[76]!==_||e[77]!==ae||e[78]!==ue?(he=t.jsxs("div",{className:"space-y-2",children:[_,ae,ue]}),e[76]=_,e[77]=ae,e[78]=ue,e[79]=he):he=e[79],he};function dd(){return new Set}function ud(s){return!s.completed}function fd(s,e){return s+(e.completed?1:0)}function md(s){return s.id}function hd(s){s.preventDefault(),s.stopPropagation()}const pd=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=Xe(),[a,i]=f.useState(null),[u,d]=f.useState(!1),[l,c]=f.useState(null),g=at(P=>P.currentSessionId),h=at(P=>P.createSession),p=at(P=>P.initializeNewOpenChamberSession),m=at(P=>P.sendMessage),y=at(P=>P.setCurrentSession),v=Pa(P=>P.setPendingInputText),N=De(P=>P.setActiveMainTab),S=De(P=>P.setSessionSwitcherOpen),R=f.useCallback(()=>{N("chat"),S(!1)},[N,S]),$=f.useCallback(P=>{if(!g){ve.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}R();const z=`\`\`\`md
7
+ ${P}
8
+ \`\`\``;v(z,"append"),ve.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[g,r,R,v,o]),w=f.useCallback((P,z)=>{!e||l||i({kind:"session",todoId:P,todoText:z})},[e,l]),k=f.useCallback((P,z)=>{if(!(!e||l)){if(!n){ve.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:P,todoText:z})}},[n,e,l,o]),b=f.useCallback(async P=>{if(!e||!a)return;const z=await gs("plan.todo.visible",{todo_text:a.todoText}),K=[{synthetic:!0,text:await gs("plan.todo.instructions",{todo_text:a.todoText})}];d(!0),c(a.todoId);try{R();let F=null,X=e.path;if(a.kind==="worktree"){if(!n){ve.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const ee=await Da(e.path,Ea());if(!ee?.id)return;F=ee.id,X=ee.path}else{const ee=await h(void 0,e.path,null);if(!ee?.id){ve.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}F=ee.id,X=ee.directory??e.path,p(ee.id,kt.getState().agents??[])}if(!F)return;const M=Cr.getState();M.saveSessionModelSelection(F,P.providerID,P.modelID),P.agent.trim()&&(M.saveSessionAgentSelection(F,P.agent),M.saveAgentModelForSession(F,P.agent,P.providerID,P.modelID),M.saveAgentModelVariantForSession(F,P.agent,P.providerID,P.modelID,P.variant||void 0)),y(F,X),await m(z,P.providerID,P.modelID,P.agent.trim()||void 0,void 0,void 0,K,P.variant||void 0),ve.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(F){const X=F instanceof Error?F.message:void 0;ve.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),X?{description:X}:void 0)}finally{d(!1),c(null)}},[n,h,p,r,a,e,R,m,y,o]),I=f.useCallback(()=>{u||i(null)},[u]);return{pendingSendTarget:a,isSubmitting:u,sendingTodoId:l,sendToCurrentSession:$,sendToNewSession:w,sendToNewWorktreeSession:k,confirmSend:b,closeDialog:I}},gd=f.lazy(()=>Gt(()=>import("./PlanView-UvuxIl9-.js"),__vite__mapDeps([114,2,3,4,5,6,7,8,115,50,51,52,53,54,55,72,48,49,56,116,117,118,1,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,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}))),hr=["notes","todos","plans","memory"],xd=120,bd=320,rn=s=>Math.min(bd,Math.max(xd,Math.round(s))),yd=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],vs=(s,e)=>s.toLowerCase().includes(e),wd=s=>{const e=_e.c(244),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:u}=s,d=o===void 0?!1:o,{t:l}=Xe();let c;e[0]!==n?(c=Ra(n),e[0]=n,e[1]=c):c=e[1];const g=c;let h;e[2]!==g?(h=je=>(g?je.entries[g]:void 0)??Aa,e[2]=g,e[3]=h):h=e[3];const p=Rt(h),m=Rt(vd),y=Rt(jd),v=at(kd),N=at(Nd),S=at(Sd),R=at(Cd);let $;e[4]===Symbol.for("react.memo_cache_sentinel")?($={notes:[],plans:[]},e[4]=$):$=e[4];const[w,k]=f.useState($);let b,I;e[5]!==N||e[6]!==v||e[7]!==S.open||e[8]!==S.projectContextPins?(b=()=>{if(S.open){k(S.projectContextPins??{notes:[],plans:[]});return}let je=!1;return Ba(N,v).then(et=>{je||k({notes:et.notes.map(Id),plans:et.plans.map(Td)})}),()=>{je=!0}},I=[N,v,S.open,S.projectContextPins],e[5]=N,e[6]=v,e[7]=S.open,e[8]=S.projectContextPins,e[9]=b,e[10]=I):(b=e[9],I=e[10]),f.useEffect(b,I);let P;e[11]!==N||e[12]!==v||e[13]!==S.open||e[14]!==R?(P=async(je,et,wt)=>{if(S.open)return R(je,et,wt),!0;if(!v||!N)return!1;const Mt=await Ma(N,v,je,et,wt);return Mt?(k(Mt),!0):!1},e[11]=N,e[12]=v,e[13]=S.open,e[14]=R,e[15]=P):P=e[15];const z=P;let O;e[16]!==w.notes?(O=new Set(w.notes),e[16]=w.notes,e[17]=O):O=e[17];const K=O;let F;e[18]!==w.plans?(F=new Set(w.plans),e[18]=w.plans,e[19]=F):F=e[19];const X=F,M=De(Pd),ee=Dt(Dd),G=M&&!ee,U=Dt(Ed),D=Dt(Rd),A=De(Ad),W=De(Bd);let H;e[20]!==A?(H=hr.includes(A)?A:"notes",e[20]=A,e[21]=H):H=e[21];const T=H,_=T==="memory"&&!G?"notes":T,[Y,le]=f.useState(""),[te,Q]=f.useState(null);let q;e[22]!==Y?(q=Y.trim().toLowerCase(),e[22]=Y,e[23]=q):q=e[23];const re=q;let J;e[24]!==p.todos?(J=yd(p.todos),e[24]=p.todos,e[25]=J):J=e[25];const ce=J,oe=p.loading&&!p.loaded;let ae;e[26]!==U||e[27]!==D?(ae=[...U,...D],e[26]=U,e[27]=D,e[28]=ae):ae=e[28];const ue=ae;let he;e:{if(!re){let ft;e[29]!==p.notes.length||e[30]!==p.plans.length||e[31]!==ue.length||e[32]!==ce.length?(ft={notes:p.notes.length,todos:ce.length,plans:p.plans.length,memory:ue.length},e[29]=p.notes.length,e[30]=p.plans.length,e[31]=ue.length,e[32]=ce.length,e[33]=ft):ft=e[33],he=ft;break e}let je;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],je=p.notes.filter(ft),e[34]=p.notes,e[35]=re,e[36]=je}else je=e[36];const et=je.length;let wt;if(e[39]!==ce||e[40]!==re){let ft;e[42]!==re?(ft=ys=>vs(ys.text,re),e[42]=re,e[43]=ft):ft=e[43],wt=ce.filter(ft),e[39]=ce,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 lo=us.length;let fs;e[49]!==ue||e[50]!==re?(fs=ue.filter(ft=>vs(ft.title,re)||vs(ft.body,re)),e[49]=ue,e[50]=re,e[51]=fs):fs=e[51];let Bs;e[52]!==je.length||e[53]!==wt.length||e[54]!==us.length||e[55]!==fs.length?(Bs={notes:et,todos:Mt,plans:lo,memory:fs.length},e[52]=je.length,e[53]=wt.length,e[54]=us.length,e[55]=fs.length,e[56]=Bs):Bs=e[56],he=Bs}const j=he,V=De(Md);let Z;e[57]!==n?.path?(Z=je=>je.agentMemoryViewedAt[En("project",n?.path??null)]??0,e[57]=n?.path,e[58]=Z):Z=e[58];const me=De(Z),ne=fr(U,V)+fr(D,me),ye=De(Ld),Ie=De(Fd),[Me,Ue]=f.useState(!1),[tt,Le]=f.useState(null),st=tt??ye;let Ae;e[59]!==st?(Ae=rn(st),e[59]=st,e[60]=Ae):Ae=e[60];const He=Ae;let Fe;e[61]!==He?(Fe=je=>{je.currentTarget.setPointerCapture(je.pointerId),Ue(!0),Le(He)},e[61]=He,e[62]=Fe):Fe=e[62];const Ye=Fe;let Ze;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ze=je=>{if(!je.currentTarget.hasPointerCapture(je.pointerId))return;const et=je.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Le(rn(et-je.clientX))},e[63]=Ze):Ze=e[63];const $e=Ze;let Je;e[64]!==Ie?(Je=je=>{je.currentTarget.hasPointerCapture(je.pointerId)&&je.currentTarget.releasePointerCapture(je.pointerId),Ue(!1),Le(et=>(et!==null&&Ie(rn(et)),null))},e[64]=Ie,e[65]=Je):Je=e[65];const qe=Je;let Ce;e[66]!==d||e[67]!==a||e[68]!==n?(Ce={projectRef:n,canCreateWorktree:d,onActionComplete:a},e[66]=d,e[67]=a,e[68]=n,e[69]=Ce):Ce=e[69];const Te=pd(Ce);let ze,Pe;e[70]!==m||e[71]!==n?(ze=()=>{n&&m(n)},Pe=[m,n],e[70]=m,e[71]=n,e[72]=ze,e[73]=Pe):(ze=e[72],Pe=e[73]),f.useEffect(ze,Pe);const lt=f.useRef(null);let x,L;e[74]!==p.error||e[75]!==p.loaded||e[76]!==l?(x=()=>{if(!p.error){lt.current=null;return}lt.current!==p.error&&(lt.current=p.error,p.loaded||ve.error(l("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},L=[p.error,p.loaded,l],e[74]=p.error,e[75]=p.loaded,e[76]=l,e[77]=x,e[78]=L):(x=e[77],L=e[78]),f.useEffect(x,L);let xe;e[79]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{Q(null)},e[79]=xe):xe=e[79];let Be;e[80]!==g?(Be=[g],e[80]=g,e[81]=Be):Be=e[81],f.useEffect(xe,Be);let Ne,Ke;e[82]!==_?(Ne=()=>{_!=="plans"&&Q(null)},Ke=[_],e[82]=_,e[83]=Ne,e[84]=Ke):(Ne=e[83],Ke=e[84]),f.useEffect(Ne,Ke);let Qe;e[85]===Symbol.for("react.memo_cache_sentinel")?(Qe=()=>{le("")},e[85]=Qe):Qe=e[85];let Ve;e[86]!==g?(Ve=[g],e[86]=g,e[87]=Ve):Ve=e[87],f.useEffect(Qe,Ve);let Ee,C;e[88]!==_||e[89]!==j||e[90]!==W||e[91]!==re?(Ee=()=>{if(!re||j[_]>0)return;const je=hr.find(et=>j[et]>0);je&&W(je)},C=[_,j,W,re],e[88]=_,e[89]=j,e[90]=W,e[91]=re,e[92]=Ee,e[93]=C):(Ee=e[92],C=e[93]),f.useEffect(Ee,C);let be;e[94]!==n||e[95]!==y||e[96]!==l?(be=je=>{n&&y(n,je).then(et=>{et||ve.error(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[94]=n,e[95]=y,e[96]=l,e[97]=be):be=e[97];const Se=be;let Re;e[98]!==l?(Re=l("rightSidebar.contextNotesTodo.tabs.notes"),e[98]=l,e[99]=Re):Re=e[99];const ot=String(j.notes);let it;e[100]!==Re||e[101]!==ot?(it={id:"notes",icon:"sticky-note",label:Re,count:ot},e[100]=Re,e[101]=ot,e[102]=it):it=e[102];let nt;e[103]!==l?(nt=l("rightSidebar.contextNotesTodo.tabs.todos"),e[103]=l,e[104]=nt):nt=e[104];const mt=String(j.todos);let We;e[105]!==nt||e[106]!==mt?(We={id:"todos",icon:"checkbox-circle",label:nt,count:mt},e[105]=nt,e[106]=mt,e[107]=We):We=e[107];let ut;e[108]!==l?(ut=l("rightSidebar.contextNotesTodo.tabs.plans"),e[108]=l,e[109]=ut):ut=e[109];const B=String(j.plans);let de;e[110]!==ut||e[111]!==B?(de={id:"plans",icon:"file-text",label:ut,count:B},e[110]=ut,e[111]=B,e[112]=de):de=e[112];let ge;e[113]!==j.memory||e[114]!==ne||e[115]!==G||e[116]!==l?(ge=G?[{id:"memory",icon:"brain-4",label:l("rightSidebar.contextNotesTodo.tabs.memory"),count:ne>0?`${ne}/${j.memory}`:String(j.memory)}]:[],e[113]=j.memory,e[114]=ne,e[115]=G,e[116]=l,e[117]=ge):ge=e[117];let Ge;e[118]!==it||e[119]!==We||e[120]!==de||e[121]!==ge?(Ge=[it,We,de,...ge],e[118]=it,e[119]=We,e[120]=de,e[121]=ge,e[122]=Ge):Ge=e[122];const we=Ge;if(!n){let je;e[123]!==u?(je=se("w-full min-w-0 p-3",u),e[123]=u,e[124]=je):je=e[124];let et;e[125]!==l?(et=l("rightSidebar.contextNotesTodo.empty.selectProject"),e[125]=l,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]!==je||e[130]!==wt?(Mt=t.jsx("div",{className:je,children:wt}),e[129]=je,e[130]=wt,e[131]=Mt):Mt=e[131],Mt}let pe;e[132]!==r||e[133]!==n.path?(pe=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[132]=r,e[133]=n.path,e[134]=pe):pe=e[134];const fe=pe;let Oe;e[135]!==u?(Oe=se("flex h-full min-h-0 w-full min-w-0 flex-col",u),e[135]=u,e[136]=Oe):Oe=e[136];let ct;e[137]!==te||e[138]!==l?(ct=te?t.jsx("button",{type:"button",onClick:()=>Q(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":l("rightSidebar.contextNotesTodo.plans.actions.back"),title:l("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[137]=te,e[138]=l,e[139]=ct):ct=e[139];let dt;e[140]!==n.path||e[141]!==fe?(dt=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:fe}),e[140]=n.path,e[141]=fe,e[142]=dt):dt=e[142];let vt;e[143]===Symbol.for("react.memo_cache_sentinel")?(vt=t.jsx(E,{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 St;e[144]===Symbol.for("react.memo_cache_sentinel")?(St=je=>le(je.target.value),e[144]=St):St=e[144];let pt;e[145]!==l?(pt=l("rightSidebar.contextNotesTodo.search.placeholder"),e[145]=l,e[146]=pt):pt=e[146];let gt;e[147]!==Y||e[148]!==pt?(gt=t.jsx(yt,{value:Y,onChange:St,placeholder:pt,className:"h-8 pl-7 pr-7"}),e[147]=Y,e[148]=pt,e[149]=gt):gt=e[149];let jt;e[150]!==Y||e[151]!==l?(jt=Y?t.jsx("button",{type:"button",onClick:()=>le(""),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":l("rightSidebar.contextNotesTodo.search.clear"),title:l("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null,e[150]=Y,e[151]=l,e[152]=jt):jt=e[152];let Nt;e[153]!==gt||e[154]!==jt?(Nt=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[vt,gt,jt]}),e[153]=gt,e[154]=jt,e[155]=Nt):Nt=e[155];let Tt;e[156]!==ct||e[157]!==dt||e[158]!==Nt?(Tt=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[ct,dt,Nt]}),e[156]=ct,e[157]=dt,e[158]=Nt,e[159]=Tt):Tt=e[159];const ht=te?"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]!==_||e[163]!==p.notes||e[164]!==oe||e[165]!==K||e[166]!==n||e[167]!==Y||e[168]!==z?(Yt=_==="notes"?t.jsx(Zc,{projectRef:n,notes:p.notes,disabled:oe,query:Y,pinnedNoteIds:K,onTogglePinned:(je,et)=>z("note",je,et)}):null,e[162]=_,e[163]=p.notes,e[164]=oe,e[165]=K,e[166]=n,e[167]=Y,e[168]=z,e[169]=Yt):Yt=e[169];let Jt;e[170]!==_||e[171]!==d||e[172]!==Se||e[173]!==oe||e[174]!==Y||e[175]!==Te.sendToCurrentSession||e[176]!==Te.sendToNewSession||e[177]!==Te.sendToNewWorktreeSession||e[178]!==Te.sendingTodoId||e[179]!==ce?(Jt=_==="todos"?t.jsx(cd,{todos:ce,query:Y,disabled:oe,canCreateWorktree:d,sendingTodoId:Te.sendingTodoId,onPersistTodos:Se,onSendToCurrentSession:Te.sendToCurrentSession,onSendToNewSession:Te.sendToNewSession,onSendToNewWorktreeSession:Te.sendToNewWorktreeSession}):null,e[170]=_,e[171]=d,e[172]=Se,e[173]=oe,e[174]=Y,e[175]=Te.sendToCurrentSession,e[176]=Te.sendToNewSession,e[177]=Te.sendToNewWorktreeSession,e[178]=Te.sendingTodoId,e[179]=ce,e[180]=Jt):Jt=e[180];let Qt;e[181]!==_||e[182]!==G||e[183]!==n.path||e[184]!==Y?(Qt=_==="memory"&&G?t.jsx(zc,{projectPath:n.path,query:Y}):null,e[181]=_,e[182]=G,e[183]=n.path,e[184]=Y,e[185]=Qt):Qt=e[185];let Xt;e[186]!==_||e[187]!==p.plans||e[188]!==i||e[189]!==te||e[190]!==X||e[191]!==n||e[192]!==Y||e[193]!==z?(Xt=_==="plans"&&!te?t.jsx(od,{projectRef:n,plans:p.plans,query:Y,pinnedPlanIds:X,onTogglePinned:(je,et)=>z("plan",je,et),onOpenPlan:i??Q}):null,e[186]=_,e[187]=p.plans,e[188]=i,e[189]=te,e[190]=X,e[191]=n,e[192]=Y,e[193]=z,e[194]=Xt):Xt=e[194];let Zt;e[195]!==_||e[196]!==te?(Zt=_==="plans"&&te?t.jsx(f.Suspense,{fallback:null,children:t.jsx(gd,{projectPlanId:te.id,onNavigatedToChat:()=>Q(null)})}):null,e[195]=_,e[196]=te,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 qs=`${He}px`;let ts;e[205]!==qs?(ts={width:qs},e[205]=qs,e[206]=ts):ts=e[206];let ss;e[207]!==l?(ss=l("rightSidebar.contextNotesTodo.sections.label"),e[207]=l,e[208]=ss):ss=e[208];const Ys=Me&&"bg-[var(--interactive-border)]";let ns;e[209]!==Ys?(ns=se("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Ys),e[209]=Ys,e[210]=ns):ns=e[210];let rs;e[211]!==l?(rs=l("rightSidebar.contextNotesTodo.sections.resize"),e[211]=l,e[212]=rs):rs=e[212];let os;e[213]!==qe||e[214]!==Ye||e[215]!==ns||e[216]!==rs?(os=t.jsx("div",{className:ns,onPointerDown:Ye,onPointerMove:$e,onPointerUp:qe,onPointerCancel:qe,role:"separator","aria-orientation":"vertical","aria-label":rs}),e[213]=qe,e[214]=Ye,e[215]=ns,e[216]=rs,e[217]=os):os=e[217];let as;e[218]!==_||e[219]!==we||e[220]!==W?(as=we.map(je=>{const et=_===je.id;return t.jsxs("button",{type:"button",onClick:()=>W(je.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(E,{name:je.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:je.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:je.count})]},je.id)}),e[218]=_,e[219]=we,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 Js=Te.pendingSendTarget!==null;let cs;e[230]!==Te?(cs=je=>{je||Te.closeDialog()},e[230]=Te,e[231]=cs):cs=e[231];const Qs=Te.pendingSendTarget?.kind??"session";let ds;e[232]!==n.path||e[233]!==Te.confirmSend||e[234]!==Te.isSubmitting||e[235]!==Js||e[236]!==cs||e[237]!==Qs?(ds=t.jsx(ll,{open:Js,onOpenChange:cs,target:Qs,projectDirectory:n.path,submitting:Te.isSubmitting,onConfirm:Te.confirmSend}),e[232]=n.path,e[233]=Te.confirmSend,e[234]=Te.isSubmitting,e[235]=Js,e[236]=cs,e[237]=Qs,e[238]=ds):ds=e[238];let As;return e[239]!==Oe||e[240]!==Tt||e[241]!==ls||e[242]!==ds?(As=t.jsxs("div",{className:Oe,children:[Tt,ls,ds]}),e[239]=Oe,e[240]=Tt,e[241]=ls,e[242]=ds,e[243]=As):As=e[243],As};function vd(s){return s.load}function jd(s){return s.saveTodos}function kd(s){return s.currentSessionId}function Nd(s){return s.currentSessionDirectory}function Sd(s){return s.newSessionDraft}function Cd(s){return s.setDraftProjectContextPin}function Id(s){return s.id}function Td(s){return s.id}function Pd(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Dd(s){return s.disabled}function Ed(s){return s.global}function Rd(s){return s.project}function Ad(s){return s.projectContextTab}function Bd(s){return s.setProjectContextTab}function Md(s){return s.agentMemoryViewedAt[En("global",null)]??0}function Ld(s){return s.projectContextSidebarWidth}function Fd(s){return s.setProjectContextSidebarWidth}const ef=s=>{const e=_e.c(19),{onActionComplete:n,onOpenPlan:r}=s,o=Ct(Od),a=Ct(Ud),i=Rs($d),u=Tn(Wd);let d;e:{if(o){let N;e[0]!==o||e[1]!==a?(N=a.find(S=>S.id===o)??a[0]??null,e[0]=o,e[1]=a,e[2]=N):N=e[2],d=N;break e}d=a[0]??null}const l=d;let c;e:{if(!l){c=null;break e}let N;e[3]!==l.id||e[4]!==l.path?(N={id:l.id,path:l.path},e[3]=l.id,e[4]=l.path,e[5]=N):N=e[5],c=N}const g=c;let h;e:{if(!l){h=null;break e}let N;e[6]!==l.label||e[7]!==l.path||e[8]!==i?(N=l.label?.trim()||La(l.path,i)||l.path,e[6]=l.label,e[7]=l.path,e[8]=i,e[9]=N):N=e[9],h=N}const p=h;let m;e:{if(!l){m=!1;break e}let N;e[10]!==l.path||e[11]!==u?(N=u.get(l.path)?.isGitRepo,e[10]=l.path,e[11]=u,e[12]=N):N=e[12],m=N===!0}const y=m;let v;return e[13]!==y||e[14]!==n||e[15]!==r||e[16]!==p||e[17]!==g?(v=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(wd,{projectRef:g,projectLabel:p,canCreateWorktree:y,onActionComplete:n,onOpenPlan:r})}),e[13]=y,e[14]=n,e[15]=r,e[16]=p,e[17]=g,e[18]=v):v=e[18],v};function Od(s){return s.activeProjectId}function Ud(s){return s.projects}function $d(s){return s.homeDirectory}function Wd(s){return s.directories}const Ws=Object.freeze({chunks:Object.freeze([]),byteLength:0,lastSequence:-1}),Nn=512*1024,_d=new TextEncoder,zd=new TextDecoder,on=s=>{const e=_d.encode(s);if(e.byteLength<=Nn)return{text:s,byteLength:e.byteLength};let n=e.byteLength-Nn;for(;n<e.byteLength&&(e[n]&192)===128;)n+=1;const r=e.subarray(n);return{text:zd.decode(r),byteLength:r.byteLength}},hs=(s,e)=>`${s}\0${e}`,an=(s,e)=>{let n=null;for(const r of s.keys())e(r)&&(n??=new Map(s),n.delete(r));return n},Vd="terminal-store";let pr=!1,gr=0;const Us=()=>typeof globalThis.crypto?.randomUUID=="function"?`tab-${globalThis.crypto.randomUUID()}`:(gr+=1,`tab-${Date.now().toString(36)}-${gr.toString(36)}`),ln=s=>typeof s=="object"&&s!==null,Gd=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 Kd=/^Terminal(?: (\d+))?$/,Hd=s=>{let e=0;for(const n of s){const r=Kd.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}`},cn=(s,e)=>({id:s,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),dn=s=>({tabs:[s],activeTabId:s.id}),Pt=(s,e)=>s.tabs.findIndex(n=>n.id===e);let un=null,fn=null;const qd=s=>{if(fn&&un?.sessions===s.sessions&&un.nextTabId===s.nextTabId)return fn;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 un={sessions:s.sessions,nextTabId:s.nextTabId},fn=e,e},Yd=()=>{const s=ki(()=>ci());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))}},rt=Hs()(Rr(Ar((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=Us(),u=cn(i,"Terminal");return a.set(r,dn(u)),{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))??Ws,createTab:n=>{const r=bt(n);if(!r)return"tab-invalid";const o=Us();return s(a=>{const i=new Map(a.sessions),u=i.get(r),d=a.nextTabId+1,l=Hd(u?.tabs??[]),c=cn(o,l);return u?i.set(r,{...u,tabs:[...u.tabs,c]}):i.set(r,dn(c)),{sessions:i,nextTabId:d}}),o},setActiveTab:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);return!u||u.activeTabId===r||Pt(u,r)<0?a:(i.set(o,{...u,activeTabId:r}),{sessions:i})})},setTabLabel:(n,r,o)=>{const a=bt(n),i=o.trim();i&&s(u=>{const d=new Map(u.sessions),l=d.get(a);if(!l)return u;const c=Pt(l,r);if(c<0||l.tabs[c]?.label===i)return u;const g=[...l.tabs];return g[c]={...g[c],label:i},d.set(a,{...l,tabs:g}),{sessions:d}})},setTabIconKey:(n,r,o)=>{const a=bt(n);s(i=>{const u=new Map(i.sessions),d=u.get(a);if(!d)return i;const l=Pt(d,r);if(l<0)return i;const c=o?.trim()||null;if(d.tabs[l]?.iconKey===c)return i;const g=[...d.tabs];return g[l]={...g[l],iconKey:c},u.set(a,{...d,tabs:g}),{sessions:u}})},closeTab:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);if(!u)return a;const d=Pt(u,r);if(d<0)return a;const l=u.tabs.filter(y=>y.id!==r),c=Object.fromEntries(Object.entries(a.projectActionRuns).filter(([,y])=>!(y.directory===o&&y.tabId===r))),g=Object.keys(c).length!==Object.keys(a.projectActionRuns).length,h=hs(o,r),p=a.buffers.has(h)?an(a.buffers,y=>y===h):null;if(l.length===0){const y=Us(),v=cn(y,"Terminal");return i.set(o,dn(v)),{sessions:i,nextTabId:a.nextTabId+1,...p?{buffers:p}:{},...g?{projectActionRuns:c}:{}}}let m=u.activeTabId;return u.activeTabId===r&&(m=l[Math.min(d,l.length-1)]?.id??l[0]?.id??null),i.set(o,{...u,tabs:l,activeTabId:m}),{sessions:i,...p?{buffers:p}:{},...g?{projectActionRuns:c}:{}}})},setTabSessionId:(n,r,o)=>{const a=bt(n);s(i=>{const u=new Map(i.sessions),d=u.get(a);if(!d)return i;const l=Pt(d,r);if(l<0)return i;const c=d.tabs[l],g=o!==null&&c.terminalSessionId!==o,h=o?"running":c.terminalSessionId?"exited":c.lifecycle,p={...c,terminalSessionId:o,lifecycle:h,isConnecting:!1},m=hs(a,r),y=g&&i.buffers.has(m)?an(i.buffers,N=>N===m):null,v=[...d.tabs];return v[l]=p,u.set(a,{...d,tabs:v}),{sessions:u,...y?{buffers:y}:{}}})},setTabLifecycle:(n,r,o)=>{const a=bt(n);s(i=>{const u=new Map(i.sessions),d=u.get(a);if(!d)return i;const l=Pt(d,r);if(l<0)return i;const c=[...d.tabs];return c[l]={...c[l],lifecycle:o,isConnecting:!1},u.set(a,{...d,tabs:c}),{sessions:u}})},setConnecting:(n,r,o)=>{const a=bt(n);s(i=>{const u=new Map(i.sessions),d=u.get(a);if(!d)return i;const l=Pt(d,r);if(l<0)return i;const c=[...d.tabs];return c[l]={...c[l],isConnecting:o},u.set(a,{...d,tabs:c}),{sessions:u}})},replaceBuffer:(n,r,o,a)=>{const i=bt(n);s(u=>{const d=u.sessions.get(i);if(!d||Pt(d,r)<0)return u;const l=hs(i,r),c=u.buffers.get(l)??Ws;if(c.lastSequence>a)return u;const g=on(o);if(c.lastSequence===a&&c.byteLength===g.byteLength&&c.chunks.map(m=>m.data).join("")===g.text)return u;const h=u.nextChunkId,p=new Map(u.buffers);return p.set(l,{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 u=bt(n);s(d=>{const l=d.sessions.get(u);if(!l||Pt(l,r)<0)return d;const c=hs(u,r),g=d.buffers.get(c)??Ws;if(a!==void 0&&a<=g.lastSequence)return d;const h=d.nextChunkId,p=on(o),m=i!==void 0&&i!==o?on(i).text:void 0,y={id:h,data:p.text,...m!==void 0?{replayData:m}:{},byteLength:p.byteLength},v=[...g.chunks,y];let N=g.byteLength+y.byteLength;for(;N>Nn&&v.length>1;){const R=v.shift();if(!R)break;N-=R.byteLength}const S=new Map(d.buffers);return S.set(c,{chunks:v,byteLength:N,lastSequence:a??g.lastSequence}),{buffers:S,nextChunkId:h+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const i=bt(n);s(u=>{const d=new Map(u.sessions),l=d.get(i);if(!l)return u;const c=Pt(l,r);if(c<0)return u;const g=l.tabs[c],h=a.autoOpened??g.previewAutoOpened,p=a.locked??g.previewUrlLocked;if(g.previewUrl===o&&g.previewAutoOpened===h&&g.previewUrlLocked===p)return u;const m=[...l.tabs];return m[c]={...g,previewUrl:o,previewAutoOpened:h,previewUrlLocked:p},d.set(i,{...l,tabs:m}),{sessions:d}})},markPreviewAutoOpened:(n,r)=>{const o=bt(n);s(a=>{const i=new Map(a.sessions),u=i.get(o);if(!u)return a;const d=Pt(u,r);if(d<0)return a;const l=u.tabs[d];if(!l.previewUrl||l.previewAutoOpened)return a;const c=[...u.tabs];return c[d]={...l,previewAutoOpened:!0},i.set(o,{...u,tabs:c}),{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,""),u=an(o.buffers,l=>l.startsWith(i)),d=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,...u?{buffers:u}:{},projectActionRuns:d}})},clearAll:()=>{s({sessions:new Map,buffers:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Vd,storage:Yd(),partialize:qd,merge:(s,e)=>{if(!ln(s))return e;const n=Array.isArray(s.sessions)?s.sessions:[],r=new Map;let o=0;for(const u of n){if(!Array.isArray(u)||u.length!==2)continue;const[d,l]=u;if(typeof d!="string"||!ln(l))continue;const c=Array.isArray(l.tabs)?l.tabs:[],g=[],h=new Map;for(const v of c){if(!ln(v))continue;const N=typeof v.id=="string"?v.id:null;if(!N)continue;const S=Gd(N);S!==null&&(o=Math.max(o,S));const R=S===null?N:Us();h.set(N,R),g.push({id:R,label:typeof v.label=="string"?v.label:"Terminal",iconKey:typeof v.iconKey=="string"?v.iconKey:null,terminalSessionId:null,lifecycle:"idle",createdAt:typeof v.createdAt=="number"?v.createdAt:Date.now(),isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(g.length===0)continue;const p=typeof l.activeTabId=="string"?l.activeTabId:null,m=p?h.get(p)??p:null,y=m?g.some(v=>v.id===m):!1;r.set(d,{tabs:g,activeTabId:y?m: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"&&!pr){pr=!0;const s=rt.persist,e=()=>{rt.getState().hasHydrated||rt.setState({hasHydrated:!0})};s?.hasHydrated?.()?e():s?.onFinishHydration?s.onFinishHydration(e):e()}function Jd(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 Qd(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 mn=["\x1B[0m","\x1B[m"],Xd=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},xr=s=>{const e=Xd(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},Zd=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...mn.map(d=>d.length))-1;for(let d=1;d<=Math.min(a,r.length);d+=1){const l=r.slice(-d);mn.some(c=>c.length>l.length&&c.startsWith(l))&&(o=d)}const i=o>0?r.slice(-o):"";let u=o>0?r.slice(0,-o):r;for(const d of mn)u=u.replaceAll(d,n);return{data:u,carry:i}},eu=(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))}},tu=(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 su=null;const nu=()=>su??=Gt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([121,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),ru=2e3,ou=()=>{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,ru))]).then(()=>{})},au=(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 u=window.getComputedStyle(s),d=(Number.parseInt(u.paddingLeft,10)||0)+(Number.parseInt(u.paddingRight,10)||0),l=(Number.parseInt(u.paddingTop,10)||0)+(Number.parseInt(u.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-d-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-l)/i))}},no=f.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,fontFamily:a,fontSize:i,className:u,enableTouchScroll:d=!1,autoFocus:l=!0,isVisible:c=!0},g)=>{const h=f.useRef(null),p=f.useRef(null),m=f.useRef(null),y=f.useRef(n),v=f.useRef(r),N=f.useRef(null),S=f.useRef(null),R=f.useRef(null),$=f.useRef(""),w=f.useRef(""),k=f.useRef(xr(o.background)),b=f.useRef(!1),I=f.useRef(0),P=f.useRef(c),z=f.useRef(!1),[O,K]=f.useState(0),[F,X]=f.useState(0);y.current=n,v.current=r,P.current=c,k.current=xr(o.background),f.useLayoutEffect(()=>{const U=h.current;if(!U)return;const D=au(U,a,i);S.current=D,D&&v.current(D.cols,D.rows)},[a,i]);const M=f.useCallback(()=>{const U=h.current,D=p.current;if(!U||!D||!m.current||!P.current)return;const A=U.getBoundingClientRect();if(!(A.width<24||A.height<24))try{m.current.fit();const W={cols:D.cols,rows:D.rows};(!N.current||N.current.cols!==W.cols||N.current.rows!==W.rows)&&(N.current=W,v.current(W.cols,W.rows)),z.current||(z.current=!0,K(H=>H+1))}catch{}},[]),ee=f.useCallback(()=>{if(b.current||!$.current||!p.current)return;const U=p.current,D=$.current;$.current="";const A=Zd(D,w.current,k.current);if(w.current=A.carry,!A.data){$.current&&ee();return}b.current=!0;const W=I.current;U.write(A.data,()=>{p.current!==U||I.current!==W||(b.current=!1,$.current&&ee())})},[]),G=f.useCallback(()=>{R.current=null,$.current="",w.current="",b.current=!1,I.current+=1;const U=p.current;if(!U){X(D=>D+1);return}try{U.reset();const D=k.current;D&&U.write(`${D}\x1B[2J\x1B[H`)}catch{X(D=>D+1)}},[]);return f.useEffect(()=>{const U=h.current;if(!U)return;let D=!1,A=null,W=null,H=null,T=null,_=[];const Y=()=>{A&&P.current&&(A.options.cursorBlink=!0)},le=q=>{q.relatedTarget instanceof Node&&U.contains(q.relatedTarget)||A&&(A.options.cursorBlink=!1)},te=()=>{A&&P.current&&U.contains(document.activeElement)&&(A.options.cursorBlink=!0)},Q=()=>{A&&(A.options.cursorBlink=!1)};return U.addEventListener("focusin",Y),U.addEventListener("focusout",le),window.addEventListener("focus",te),window.addEventListener("blur",Q),Promise.all([nu(),ou()]).then(([{module:q,ghostty:re}])=>{if(D)return;A=new q.Terminal({...Qd(a,i,o,re,!1),...S.current??{}});const J=new q.FitAddon;A.loadAddon(J),A.open(U),p.current=A,m.current=J,_=[A.onData(oe=>y.current(oe))],W=new ResizeObserver(()=>{H&&clearTimeout(H),H=setTimeout(M,80)}),W.observe(U),M();const ce=k.current;ce&&A.write(`${ce}\x1B[2J\x1B[H`),T=requestAnimationFrame(M)}),()=>{D=!0;const q=document.activeElement;q instanceof HTMLElement&&U.contains(q)&&(q.blur(),window.Capacitor?.getPlatform?.()==="android"&&Gt(async()=>{const{Keyboard:J}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:J}},__vite__mapDeps([122,123])).then(({Keyboard:J})=>J.hide()).catch(()=>{})),W?.disconnect(),H&&clearTimeout(H),T!==null&&cancelAnimationFrame(T),U.removeEventListener("focusin",Y),U.removeEventListener("focusout",le),window.removeEventListener("focus",te),window.removeEventListener("blur",Q),_.forEach(re=>re.dispose()),A?.dispose(),p.current=null,m.current=null,N.current=null,R.current=null,$.current="",w.current="",b.current=!1,I.current+=1,z.current=!1}},[M,a,i,F,o]),f.useEffect(()=>{const U=p.current,D=h.current;!U||!D||(U.options.cursorBlink=c&&document.hasFocus()&&D.contains(document.activeElement))},[c,O]),f.useEffect(()=>{if(!p.current)return;if(e.length===0){R.current!==null&&G();return}const D=R.current;let A=-1;if(D!==null){for(let T=e.length-1;T>=0;T-=1){const _=e[T].id;if(_===D){A=T;break}if(_<D)break}if(A<0){G();return}}const W=A<0,H=A>=0?e.slice(A+1):e;$.current+=H.map(T=>W?T.replayData??T.data:T.data).join(""),R.current=e.at(-1)?.id??null,ee()},[e,ee,O,G]),f.useEffect(()=>{if(!l||!c)return;const U=requestAnimationFrame(()=>p.current?.focus());return()=>cancelAnimationFrame(U)},[l,c,O,s]),f.useEffect(()=>{const U=h.current;if(!d||!U)return;const D=A=>{const W=A;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 U.addEventListener("beforeinput",D),()=>U.removeEventListener("beforeinput",D)},[d,O]),f.useEffect(()=>{const U=h.current,D=p.current;if(!d||!U||!D)return;let A=null,W=null,H="idle",T=0,_=0,Y=0,le=0,te=null;const Q=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)},J=(V,Z)=>{const me=U.querySelector("canvas");return me?eu(V,Z,me.getBoundingClientRect(),D.cols,D.rows):null},ce=(V,Z)=>{const me=U.querySelector("canvas");if(!me)return;const ne=me.getBoundingClientRect(),ye=ne.left+(Z.column+.5)/D.cols*ne.width,Ie=ne.top+(Z.row+.5)/D.rows*ne.height;me.dispatchEvent(new MouseEvent(V,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:ye,clientY:Ie}))},oe=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},ae=V=>{V.pointerType!=="touch"||A!==null||(A=V.pointerId,H="pending",T=V.clientX,_=V.clientY,Y=V.clientY,le=0,te=null,U.setPointerCapture(V.pointerId),W=setTimeout(()=>{if(W=null,A!==V.pointerId||H!=="pending")return;const Z=J(T,_);if(!Z)return;const me=D.buffer.active,ne=Math.max(0,me.length-D.rows-me.viewportY+Z.row),ye=me.getLine(ne),Ie=Array.from({length:D.cols},(tt,Le)=>ye?.getCell(Le)?.getChars()??""),Me=tu(Ie,Z.column),Ue={column:Me.startColumn,row:Z.row};te={column:Me.endColumn,row:Z.row},H="selecting",ce("mousedown",Ue),ce("mousemove",te)},350))},ue=V=>{if(A!==V.pointerId)return;if(H==="selecting"){const ne=J(V.clientX,V.clientY);ne&&(!te||ne.column!==te.column||ne.row!==te.row)&&(te=ne,ce("mousemove",ne)),V.cancelable&&V.preventDefault();return}if(H==="pending"){if(Math.hypot(V.clientX-T,V.clientY-_)<8)return;re(),H="scrolling"}if(H!=="scrolling")return;const Z=Y-V.clientY;Y=V.clientY,le+=Z;const me=Math.trunc(le/Q);me&&(D.scrollLines(me),le-=me*Q),V.cancelable&&V.preventDefault()},he=V=>{if(A!==V.pointerId)return;const Z=H==="pending",me=H==="selecting";re(),U.hasPointerCapture(V.pointerId)&&U.releasePointerCapture(V.pointerId),A=null,H="idle",me&&oe(),Z&&(D.focus(),q())},j=V=>{if(A!==V.pointerId)return;const Z=H==="selecting";re(),U.hasPointerCapture(V.pointerId)&&U.releasePointerCapture(V.pointerId),A=null,H="idle",Z&&oe()};return U.addEventListener("pointerdown",ae),U.addEventListener("pointermove",ue,{passive:!1}),U.addEventListener("pointerup",he),U.addEventListener("pointercancel",j),()=>{re(),U.removeEventListener("pointerdown",ae),U.removeEventListener("pointermove",ue),U.removeEventListener("pointerup",he),U.removeEventListener("pointercancel",j)}},[d,i,O]),f.useImperativeHandle(g,()=>({focus:()=>p.current?.focus(),fit:M,getSelection:()=>{const U=p.current,D=U?.getSelectionPosition(),A=U?.getSelection()??"";return!D||!A.trim()?null:{text:A,startLine:D.start.y+1,endLine:D.end.y+1}}}),[M]),t.jsx("div",{ref:h,"data-terminal-owner":"main",className:se("terminal-viewport-container h-full w-full overflow-hidden touch-none",u)})});no.displayName="TerminalViewport";const iu="\x1B",ro=new RegExp(`${iu}\\[[0-9;?]*[ -/]*[@-~]`,"g"),lu=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,cu=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,du=/Serving HTTP on .*? port (\d{2,5})/i,uu=new Set([".",",",";",":","!","?"]),oo=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(uu.has(n)){e=e.slice(0,-1);continue}break}return e},Sn=s=>{let e=oo(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},fu=s=>{if(!s)return[];const e=s.replace(ro,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(du);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(!cu.test(i))continue;const u=Array.from(i.matchAll(lu));if(u.length===0)continue;const d=u.find(l=>{try{return!!new URL(Sn(l[1])).port}catch{return!1}});o(Sn((d??u[0])[1]))}return n},ao=s=>fu(s)[0]??null,mu=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)}},hu=/https?:\/\/[^\s<>'"`]+/gi,tf=(s,{requireAnnounced:e=!1}={})=>{const n=ao(s);if(n)return n;if(e)return null;const r=String(s||"").replace(ro,""),o=[];for(const u of r.match(hu)??[])try{const d=new URL(oo(u));d.port&&o.push(d)}catch{}if(o.length===0)return null;const a=u=>{const d=u.hostname.toLowerCase();return(d==="localhost"||d==="127.0.0.1"||d==="0.0.0.0"||d==="::1"?50:0)-(u.search||u.hash?10:0)};let i=o[0];for(const u of o.slice(1))a(u)>a(i)&&(i=u);return Sn(i.toString())},pu={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},gu=(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 pu[s]},io=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},xu=(s,e)=>s&&(e==="ctrl"?io(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),br={cols:80,rows:24},sf=({visible:s})=>{const{t:e}=Xe(),{terminal:n,runtime:r}=In(),{currentTheme:o}=kr(),a=f.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}=Fa(),u=De(B=>B.terminalFontSize),d=De(B=>B.terminalShell),l=De(B=>B.terminalLoginShells.includes(B.terminalShell)),{isMobile:c,isTablet:g,hasTouchOnlyPointer:h}=Gs(),p=c||g,m=(p||h)&&r.platform==="web",y=r.platform!=="vscode",v=De(B=>B.showTerminalQuickKeysOnDesktop),N=p||v,S=at(B=>B.currentSessionId),R=at(B=>B.newSessionDraft),$=S!==null||R?.open===!0,w=Oa()??null,k=rt(B=>w?B.sessions.get(w):void 0),b=rt(B=>B.hasHydrated),I=rt(B=>B.ensureDirectory),P=rt(B=>B.createTab),z=rt(B=>B.setActiveTab),O=rt(B=>B.closeTab),K=rt(B=>B.setTabSessionId),F=rt(B=>B.setTabLifecycle),X=rt(B=>B.setConnecting),M=rt(B=>B.appendToBuffer),ee=rt(B=>B.replaceBuffer),G=rt(B=>B.setTabPreviewUrl),U=Ua(B=>B.addDraft),D=De(B=>B.openContextPreview),A=f.useMemo(()=>k?y?k.activeTabId??k.tabs[0]?.id??null:k.tabs[0]?.id??null:null,[k,y]),W=f.useMemo(()=>{if(k)return A?k.tabs.find(B=>B.id===A)??k.tabs[0]:k.tabs[0]},[k,A]),H=f.useMemo(()=>(k?.tabs??[]).map(B=>({icon:(()=>{const de=B.iconKey?Hr[B.iconKey]??"terminal":"terminal";return t.jsx(E,{name:de,className:"h-4 w-4"})})(),id:B.id,label:B.label,title:B.label,closeLabel:e("terminalView.tabs.closeTabTitle")})),[k?.tabs,e]),T=W?.terminalSessionId??null,_=W?.lifecycle??"idle",Y=rt(B=>w&&A?B.getBuffer(w,A).chunks:Ws.chunks),le=W?.isConnecting??!1,te=W?.previewUrl??null,[Q,q]=f.useState(null),[re,J]=f.useState(!1),[ce,oe]=f.useState(!1),[ae,ue]=f.useState(null),[he,j]=f.useState(!1),V=f.useRef(null),Z=f.useRef(null),me=f.useRef(A),ne=f.useRef(T),ye=f.useRef(w),Ie=f.useRef(null),Me=f.useRef(null),Ue=f.useRef(new Set),tt=f.useRef(""),Le=f.useRef(new Set),st=f.useRef(0),Ae=f.useCallback(()=>{tt.current="",Le.current.clear(),st.current+=1},[]),He=f.useCallback(()=>{m||typeof document<"u"&&!document.hasFocus()||Ie.current?.focus()},[m]),Fe=f.useCallback(()=>{m||Ie.current?.focus()},[m]),Ze=De(B=>B.activeMainTab)==="terminal",$e=s??Ze,[Je,qe]=f.useState($e);f.useEffect(()=>{$e&&qe(!0)},[$e]),f.useEffect(()=>{ne.current=T},[T]),f.useEffect(()=>{!T||!n.updateAppearance||n.updateAppearance(T,a.current).catch(()=>{})},[o.colors.surface.background,o.colors.syntax.base.foreground,o.metadata.variant,n,T]),f.useEffect(()=>{me.current=A,Ae()},[A,Ae]),f.useEffect(()=>{ye.current=w},[w]),f.useEffect(()=>{!N&&ae!==null&&ue(null)},[N,ae,ue]),f.useEffect(()=>{!T&&ae!==null&&ue(null)},[T,ae,ue]);const Ce=f.useCallback(()=>{V.current?.(),V.current=null,Z.current=null,oe(!1)},[]);f.useEffect(()=>()=>{Ce(),ne.current=null},[Ce]);const Te=f.useCallback((B,de,ge)=>{if(!ge)return;const Ge=`${tt.current}${ge}`.replace(/\r\n|\r/g,`
10
+ `),we=Ge.split(`
11
+ `),pe=Ge.endsWith(`
12
+ `)?we.join(`
13
+ `):we.slice(0,-1).join(`
14
+ `);if(tt.current=Ge.endsWith(`
15
+ `)?"":(we[we.length-1]??"").slice(-1024),!pe)return;const fe=ao(pe);if(!fe||Le.current.has(fe))return;const Oe=st.current;Le.current.add(fe),mu(fe).then(ct=>{if(Le.current.delete(fe),!ct||st.current!==Oe)return;const dt=rt.getState().getDirectoryState(B)?.tabs.find(vt=>vt.id===de);!dt||dt.previewUrlLocked||dt.previewUrl===fe||G(B,de,fe,{locked:!1,autoOpened:!1})})},[G]),ze=f.useCallback((B,de,ge)=>{if(Z.current===ge)return;Ce(),Z.current=ge;const Ge=n.connect(ge,{onEvent:we=>{if(Z.current===ge)switch(we.type){case"snapshot":{X(B,de,!1),q(null),J(!1),oe(!1),He(),ee(B,de,we.data??"",we.sequence??0),Te(B,de,we.data??""),we.status==="exited"&&F(B,de,"exited");break}case"reconnecting":{q(null),J(!1),oe(!0);break}case"data":{we.data&&(M(B,de,we.data,we.sequence,we.replayData),Te(B,de,we.data));break}case"exit":{const pe=typeof we.exitCode=="number"?we.exitCode:null,fe=typeof we.signal=="number"?we.signal:null,ct=!!rt.getState().getDirectoryState(B)?.tabs.find(dt=>dt.id===de)?.label?.startsWith("Action:");M(B,de,e("terminalView.stream.processExitedMessage",{exitCodeSegment:pe!==null?e("terminalView.stream.processExitedWithCode",{exitCode:pe}):"",signalSegment:fe!==null?e("terminalView.stream.processExitedWithSignal",{signal:fe}):""})),F(B,de,"exited"),X(B,de,!1),q(ct?null:e("terminalView.error.sessionEnded")),J(!1),oe(!1),Ce();break}}},onError:(we,pe)=>{if(Z.current===ge){if(!pe){q(null),J(!1);return}if(oe(!1),we.code==="SESSION_NOT_FOUND"&&!rt.getState().getDirectoryState(B)?.tabs.find(Oe=>Oe.id===de)?.label?.startsWith("Action:")){q(null),J(!1),X(B,de,!1),K(B,de,null),F(B,de,"idle"),Ce();return}q(e("terminalView.error.connectionFailed",{message:we.message})),J(!0),X(B,de,!1),F(B,de,"exited"),K(B,de,null),Ce()}}});V.current=()=>{Ge.close(),Z.current=null}},[M,ee,Ce,He,Te,X,F,K,e,n]);f.useEffect(()=>{let B=!1;if(!b||!Je)return;if(!w){q(e($?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),Ce();return}return(async()=>{const ge=w;if(!ye.current||ye.current!==ge)return;if(!rt.getState().getDirectoryState(ge)){I(ge);return}const we=rt.getState().getDirectoryState(ge);if(!we||we.tabs.length===0)return;const pe=y?we.activeTabId??we.tabs[0]?.id??null:we.tabs[0]?.id??null;if(!pe)return;const fe=we.tabs.find(pt=>pt.id===pe)??we.tabs[0],Oe=fe?.terminalSessionId??null,ct=fe?.lifecycle??"idle",dt=!!fe?.label?.startsWith("Action:"),vt=rt.getState().getBuffer(ge,pe),St=vt.byteLength>0||vt.chunks.length>0;if(!Oe){if(ct==="exited"){X(ge,pe,!1);return}if(dt&&St){X(ge,pe,!1);return}const pt=`${ge}\0${pe}`;if(Ue.current.has(pt))return;const gt=Me.current??br;Ue.current.add(pt),q(null),J(!1),oe(!1),X(ge,pe,!0);try{const jt=await n.createSession({cwd:ge,sessionId:pe,cols:gt.cols,rows:gt.rows,shell:d,loginShell:l,...a.current}),Nt=!B&&ye.current===ge&&me.current===pe;if(!rt.getState().getDirectoryState(ge)?.tabs.find(Ut=>Ut.id===pe)){try{await n.close(jt.sessionId)}catch{}return}if(K(ge,pe,jt.sessionId),!Nt)return;const ht=Me.current;ht&&(ht.cols!==gt.cols||ht.rows!==gt.rows)&&n.resize({sessionId:jt.sessionId,...ht}).catch(()=>{});return}catch(jt){const Nt=rt.getState().getDirectoryState(ge)?.tabs.find(Tt=>Tt.id===pe);if(!Nt||Nt.terminalSessionId||(X(ge,pe,!1),ye.current!==ge||me.current!==pe))return;q(jt instanceof Error?jt.message:e("terminalView.error.startSessionFailed")),J(!0),oe(!1);return}finally{Ue.current.delete(pt)}}!Oe||B||(ne.current=Oe,ze(ge,pe,Oe))})(),()=>{B=!0,ne.current=null,Ce()}},[$,w,T,_,A,Je,y,b,I,X,F,K,ze,Ce,e,n,l,d]),f.useEffect(()=>{if(!$e||m)return;if(typeof window>"u"){He();return}const B=window.requestAnimationFrame(()=>{He()});return()=>{window.cancelAnimationFrame(B)}},[A,He,$e,m]);const Pe=f.useCallback(async()=>{if(!w||he)return;const B=rt.getState().getDirectoryState(w),de=y?A??B?.activeTabId??B?.tabs[0]?.id??null:B?.tabs[0]?.id??null;if(!de)return;const ge=B?.tabs.find(Ge=>Ge.id===de)?.terminalSessionId??null;if(!(!ge||!n.restartSession)){j(!0),q(null),J(!1),oe(!1),Ce(),Ae();try{const Ge=Me.current??br,we=await n.restartSession(ge,{cwd:w,shell:d,loginShell:l,...Ge,...a.current});if(rt.getState().getDirectoryState(w)?.tabs.find(fe=>fe.id===de)?.terminalSessionId!==ge||(K(w,de,we.sessionId),F(w,de,"running"),ye.current!==w||me.current!==de))return;ne.current=we.sessionId,ze(w,de,we.sessionId)}catch(Ge){if(rt.getState().getDirectoryState(w)?.tabs.find(pe=>pe.id===de)?.terminalSessionId!==ge||ye.current!==w||me.current!==de)return;q(Ge instanceof Error?Ge.message:e("terminalView.error.restartFailed")),J(!1),oe(!1),ne.current=ge,ze(w,de,ge)}finally{j(!1)}}},[A,Ce,w,y,he,Ae,F,K,ze,e,n,l,d]),lt=f.useCallback(async()=>{await Pe()},[Pe]),x=f.useCallback(()=>{if(!w)return;const B=P(w);z(w,B),q(null),J(!1),oe(!1),Ce()},[P,Ce,w,z]),L=f.useCallback(()=>{const B=Ie.current?.getSelection(),de=S??(R?.open?"draft":null);!B||!de||!W||!w||U({directory:w,sessionKey:de},{source:"terminal",fileLabel:W.label,startLine:B.startLine,endLine:B.endLine,code:B.text,language:W.terminalSessionId??W.id,text:""})},[W,U,S,w,R?.open]),xe=f.useCallback(B=>{w&&(z(w,B),q(null),J(!1),oe(!1),Ce())},[Ce,w,z]),Be=f.useCallback(B=>{if(!w)return;B===A&&Ce(),q(null),J(!1),oe(!1);const de=rt.getState().getDirectoryState(w)?.tabs.find(ge=>ge.id===B)?.terminalSessionId;(async()=>{de&&await n.close(de),O(w,B)})().catch(ge=>q(ge instanceof Error?ge.message:e("terminalView.error.sessionEnded")))},[A,O,Ce,w,e,n]),Ne=f.useCallback(B=>{if(!B||ce)return;let de=B,ge=!1;ae&&B.length>0&&(de=xu(B,ae),ge=!0);const Ge=ne.current;Ge&&(n.sendInput(Ge,de).catch(we=>{ce||q(we instanceof Error?we.message:e("terminalView.error.sendInputFailed"))}),ge&&(ue(null),Fe()))},[ae,Fe,ce,ue,e,n]),Ke=f.useCallback((B,de)=>{const ge=Me.current;if((!ge||ge.cols!==B||ge.rows!==de)&&(Me.current={cols:B,rows:de}),!$e)return;const Ge=ne.current;Ge&&n.resize({sessionId:Ge,cols:B,rows:de}).catch(()=>{})},[$e,n]),Qe=f.useCallback(B=>{ue(de=>de===B?null:B),Fe()},[Fe,ue]),Ve=f.useCallback(B=>{const de=gu(B,ae);de&&(Ne(de),ue(null),Fe())},[ae,Fe,Ne,ue]),Ee=f.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),C=f.useCallback(B=>{if(B.repeat)return;const de=B.key;if(!de||de==="Control"||de==="Meta"||de==="Alt"||de==="Shift")return;const ge=de.length===1?de.toLowerCase():de;if(ge in Ee){B.preventDefault(),B.stopPropagation(),Ve(Ee[ge]);return}if(ae!=="ctrl")return;const Ge=B.code??"",we=de.length===1&&/[a-zA-Z]/.test(de)?de.toUpperCase():Ge.startsWith("Key")&&Ge.length===4?Ge.slice(3).toUpperCase():null;if(we&&we.length===1&&we>="A"&&we<="Z"){const pe=io(we);if(!pe)return;B.preventDefault(),B.stopPropagation(),Ne(pe),ue(null),Fe()}},[ae,Fe,Ve,Ne,Ee,ue]);f.useEffect(()=>{if(!(!N||!ae||!T))return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[ae,C,N,T]);const be=f.useMemo(()=>{const B=ws[en].stack;if(typeof window>"u")return(ws[i]??ws[en]).stack;const ge=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return ge&&ge.trim().length>0?ge.trim():(ws[i]??ws[en]).stack??B},[i]),Se=f.useMemo(()=>Jd(o),[o]),Re=`${w??"no-dir"}::${A??"no-tab"}`;if(f.useEffect(()=>{if(!$e||m)return;const B=Ie.current;if(!B)return;const de=()=>{B.fit()};if(typeof window<"u"){const ge=window.requestAnimationFrame(()=>{de(),He()}),Ge=[220,400].map(we=>window.setTimeout(de,we));return()=>{window.cancelAnimationFrame(ge),Ge.forEach(we=>window.clearTimeout(we))}}de()},[He,$e,m,Re,T]),f.useEffect(()=>{if(!$e||!m)return;let B=null;const de=()=>{B!==null&&window.cancelAnimationFrame(B),B=window.requestAnimationFrame(()=>{B=null,Ie.current?.fit()})};return window.addEventListener("oc:keyboard-settled",de),()=>{window.removeEventListener("oc:keyboard-settled",de),B!==null&&window.cancelAnimationFrame(B)}},[$e,Re,m]),!$)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:Pe,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 ot=!T||le||he||ce,it=Je,nt=p?"lg":"xs",mt=p?"w-10 p-0":"w-9 p-0",We=B=>{p&&B.preventDefault()},ut=t.jsxs(t.Fragment,{children:[t.jsx(ke,{type:"button",size:nt,variant:"outline",onPointerDown:We,onClick:()=>Ve("esc"),disabled:ot,children:e("terminalView.quickKeys.escape")}),t.jsxs(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("tab"),disabled:ot,children:[t.jsx(E,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.tabAria")})]}),t.jsxs(ke,{type:"button",size:nt,variant:"chip","aria-pressed":ae==="ctrl",className:p?"px-3":"px-2",onPointerDown:We,onClick:()=>Qe("ctrl"),disabled:ot,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(ke,{type:"button",size:nt,variant:"chip","aria-pressed":ae==="alt",className:p?"px-3":"px-2",onPointerDown:We,onClick:()=>Qe("alt"),disabled:ot,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(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("arrow-up"),disabled:ot,children:[t.jsx(E,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("arrow-left"),disabled:ot,children:[t.jsx(E,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("arrow-down"),disabled:ot,children:[t.jsx(E,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("arrow-right"),disabled:ot,children:[t.jsx(E,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:e("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(ke,{type:"button",size:nt,variant:"outline",className:mt,onPointerDown:We,onClick:()=>Ve("enter"),disabled:ot,children:[t.jsx(E,{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&&k?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:H,activeId:A,onSelect:xe,onClose:Be,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(ke,{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(E,{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(ke,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Pe()},disabled:he,title:e("terminalView.actions.restart"),"aria-label":e("terminalView.actions.restart"),children:t.jsx(E,{name:"restart",className:"h-4 w-4"})}),t.jsx(ke,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:L,title:e("terminalView.actions.attachSelection"),"aria-label":e("terminalView.actions.attachSelection"),children:t.jsx(E,{name:"attachment-2",className:"h-4 w-4"})}),te?t.jsxs(ke,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{w&&D(w,te)},title:e("terminalView.preview.openTitle"),children:[t.jsx(E,{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&&k?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:ut}):null,!p&&N&&(!y||!k)?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:Se.background},children:[t.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:it?t.jsx(no,{ref:B=>{Ie.current=B},sessionKey:Re,chunks:Y,onInput:Ne,onResize:Ke,theme:Se,fontFamily:be,fontSize:u,enableTouchScroll:m,autoFocus:$e,isVisible:$e},Re):null}),!ce&&Q&&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:Q}),re&&p&&t.jsx(ke,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:lt,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]})},nf=()=>{Er(),xs.reconnectToRuntimeBaseUrl(),Ir()},rf=s=>{at.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),De.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&$a.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),Er(),rt.getState().clearAll(),xs.reconnectToRuntimeBaseUrl(),kt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),Ct.getState().resetForRuntimeSwitch(),Rt.getState().reset(),hn.getState().resetForRuntimeSwitch(),Wa.setState({statusById:new Map}),_a(),za(),Va.getState().reset(),di.getState().resetForRuntimeSwitch(),Tn.getState().resetForRuntimeSwitch(s.runtimeKey),Ga.getState().resetForRuntimeSwitch(),Ka.getState().resetForRuntimeSwitch(s.runtimeKey),ui.getState().resetForRuntimeSwitch(s.runtimeKey),at.getState().restoreForRuntimeSwitch(s.runtimeKey),De.getState().restoreForRuntimeSwitch(s.runtimeKey),Ir(),queueMicrotask(()=>{fi()})};export{Lu as A,Jl as B,Bu as C,Qu as D,Ku as E,zu as F,Ac as G,Gu as H,Ru as I,Vt as J,Xl as K,nn as L,Zu as M,Xu as N,Au as O,ef as P,Zl as Q,ll as R,Yu as S,sf as T,Eu as U,Du as V,Bl as W,Ju as X,vc as a,Cs as b,rf as c,qu as d,Hu as e,Mu as f,Pu as g,nr as h,rt as i,Ml as j,_u as k,Hr as l,fu as m,Ll as n,tf as o,Vu as p,ol as q,nf as r,al as s,Wu as t,Wi as u,il as v,Ou as w,$u as x,Uu as y,Fu as z};