@aiworker/web 1.22.2 → 1.23.1

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 (217) hide show
  1. package/bin/cli.js +7 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-CSICpWQD.js → CodeMirrorCommentWidgets-teB3HmBT.js} +1 -1
  3. package/dist/assets/DiffView-DC9RX3MF.js +4 -0
  4. package/dist/assets/{DirtyBranchSwitchDialog-C22HdWj4.js → DirtyBranchSwitchDialog-DwPkzXsS.js} +1 -1
  5. package/dist/assets/FilesView-BFZkuu4O.js +13 -0
  6. package/dist/assets/{GitView-VQQkYuUw.js → GitView-B_x52MHY.js} +4 -4
  7. package/dist/assets/{JsonTreeView-6lrhwD3q.js → JsonTreeView-cmAzUTiw.js} +1 -1
  8. package/dist/assets/{LinearIssuesView-Ba6Q9569.js → LinearIssuesView-Dehh5afm.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-DgNOqqhE.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-DusmMZ_p.js +12 -0
  11. package/dist/assets/OnboardingScreen-B8fm1H4m.js +1 -0
  12. package/dist/assets/{PatchDiff-BzcZPlOq.js → PatchDiff-BVr7gJU0.js} +1 -1
  13. package/dist/assets/PierreDiffViewer-DzLt-nel.js +161 -0
  14. package/dist/assets/PlanView-BmQUYT_z.js +5 -0
  15. package/dist/assets/SettingsView-ChWmAcZT.js +28 -0
  16. package/dist/assets/{SettingsWindow-DDQYaKWQ.js → SettingsWindow-Dy3M6ZB9.js} +1 -1
  17. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  18. package/dist/assets/{ToolOutputDialog-iYF8Y2bz.js → ToolOutputDialog-cTl_eLIH.js} +5 -5
  19. package/dist/assets/{ToolPartDiffPreview-CdjbOVMM.js → ToolPartDiffPreview-C_3iYNJQ.js} +1 -1
  20. package/dist/assets/{VirtualizedFileDiff-fFFm2QgH.js → VirtualizedFileDiff-CAWthkoy.js} +4 -4
  21. package/dist/assets/WalkthroughView-C7AHOpCA.js +4 -0
  22. package/dist/assets/{computeVirtualFileMetrics-CzgLum_K.js → computeVirtualFileMetrics-BkiDSlTW.js} +2 -2
  23. package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
  24. package/dist/assets/de-DJsQr-p7.js +10 -0
  25. package/dist/assets/es-BuYMlA9g.js +16 -0
  26. package/dist/assets/fr-ePDay33C.js +14 -0
  27. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  28. package/dist/assets/index-BD8ILbxF.js +40 -0
  29. package/dist/assets/{index-Bl3LSbjn.js → index-n6O3hklM.js} +1 -1
  30. package/dist/assets/index-zhgg-SDz.css +1 -0
  31. package/dist/assets/{isDiffPlainText-Dx-dB_8l.js → isDiffPlainText-GMdPz-71.js} +1 -1
  32. package/dist/assets/{isFilePlainText-CWFPwmnU.js → isFilePlainText-BVuH1zH9.js} +1 -1
  33. package/dist/assets/ja-BzR9xOY_.js +16 -0
  34. package/dist/assets/ko-BEjHAm14.js +16 -0
  35. package/dist/assets/main-BydQ1tr_.js +930 -0
  36. package/dist/assets/{main-DnBAoktx.js → main-D3ZDQglc.js} +2 -2
  37. package/dist/assets/markdownCore-Cb2MdZnV.js +5 -0
  38. package/dist/assets/{miniChat-BKyvLseN.js → miniChat-d01k801U.js} +2 -2
  39. package/dist/assets/{mobile-DKjeFgMN.js → mobile-D7VV-Ufz.js} +2 -2
  40. package/dist/assets/patchFileDiff-CdztVMz0.js +13 -0
  41. package/dist/assets/pl-rQmpxNIF.js +16 -0
  42. package/dist/assets/pt-BR-CorbsSW-.js +16 -0
  43. package/dist/assets/renderElectronMiniChatApp-BGG9UIlh.js +2 -0
  44. package/dist/assets/renderMobileApp-BRP3J1iv.js +25 -0
  45. package/dist/assets/runtimeEndpointReset-BhT_-c52.js +41 -0
  46. package/dist/assets/scheduledTasksApi-BEuUF_cj.js +1 -0
  47. package/dist/assets/{shikiHighlight-TEQCmzW8.js → shikiHighlight-BzXUjlby.js} +1 -1
  48. package/dist/assets/surface-COKb77Ua.js +1 -0
  49. package/dist/assets/tr-CoAMXPtI.js +7 -0
  50. package/dist/assets/uk-YlAX0rRU.js +16 -0
  51. package/dist/assets/{useAppFontEffects-D7sNpuL2.js → useAppFontEffects-Cwyhjfl5.js} +141 -140
  52. package/dist/assets/useGitComparison-BCZVefdE.js +1 -0
  53. package/dist/assets/useInlineCommentController-DDkpBEU8.js +2 -0
  54. package/dist/assets/useRootScrollLock-CwjoWuC4.js +1 -0
  55. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-BY_5qla_.js} +1 -1
  56. package/dist/assets/{vendor-codemirror-language-data-Dp3KMRQG.js → vendor-codemirror-language-data-Cb1YnICj.js} +2 -2
  57. package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
  58. package/dist/assets/vendor-zod-B6551dwG.js +39 -0
  59. package/dist/assets/{web-components-_mNEMjFY.js → web-components-LV3vjTxy.js} +1 -1
  60. package/dist/assets/zh-CN-DDYg0Jl7.js +16 -0
  61. package/dist/assets/zh-TW-CQKaCayr.js +16 -0
  62. package/dist/index.html +5 -43
  63. package/dist/mini-chat.html +4 -4
  64. package/dist/mobile.html +4 -4
  65. package/package.json +2 -3
  66. package/server/index.d.ts +15 -0
  67. package/server/index.js +48 -22
  68. package/server/lib/agent-memory/runtime.js +7 -2
  69. package/server/lib/agent-memory/runtime.test.js +22 -0
  70. package/server/lib/data-dir-migration.js +40 -0
  71. package/server/lib/data-dir-migration.test.js +59 -0
  72. package/server/lib/event-stream/DOCUMENTATION.md +3 -0
  73. package/server/lib/event-stream/global-hub.js +29 -4
  74. package/server/lib/event-stream/global-hub.test.js +22 -0
  75. package/server/lib/event-stream/global-ws-bridge.js +15 -18
  76. package/server/lib/event-stream/protocol.js +21 -7
  77. package/server/lib/event-stream/runtime.js +9 -6
  78. package/server/lib/event-stream/runtime.test.js +72 -12
  79. package/server/lib/fs/DOCUMENTATION.md +3 -0
  80. package/server/lib/fs/routes.js +31 -0
  81. package/server/lib/fs/routes.test.js +110 -1
  82. package/server/lib/git/DOCUMENTATION.md +39 -6
  83. package/server/lib/git/routes.js +45 -12
  84. package/server/lib/git/routes.test.js +78 -0
  85. package/server/lib/git/service.js +343 -202
  86. package/server/lib/git/service.test.js +496 -25
  87. package/server/lib/github/DOCUMENTATION.md +5 -0
  88. package/server/lib/github/routes.js +2 -2
  89. package/server/lib/inherited-env.js +16 -9
  90. package/server/lib/inherited-env.test.js +8 -9
  91. package/server/lib/message-queue/DOCUMENTATION.md +11 -1
  92. package/server/lib/message-queue/runtime.js +13 -0
  93. package/server/lib/message-queue/runtime.test.js +31 -1
  94. package/server/lib/network-defaults.js +23 -0
  95. package/server/lib/network-defaults.test.js +52 -0
  96. package/server/lib/notifications/DOCUMENTATION.md +1 -1
  97. package/server/lib/notifications/emitter-runtime.js +4 -3
  98. package/server/lib/opencode/DOCUMENTATION.md +35 -5
  99. package/server/lib/opencode/bootstrap-runtime.js +2 -0
  100. package/server/lib/opencode/env-runtime.js +5 -1
  101. package/server/lib/opencode/env-runtime.test.js +72 -0
  102. package/server/lib/opencode/feature-routes-runtime.js +17 -1
  103. package/server/lib/opencode/lifecycle.js +4 -3
  104. package/server/lib/opencode/lifecycle.test.js +29 -0
  105. package/server/lib/opencode/managed-plugin-config.js +1 -1
  106. package/server/lib/opencode/openchamber-routes.js +64 -4
  107. package/server/lib/opencode/openchamber-routes.test.js +128 -1
  108. package/server/lib/opencode/proxy.js +33 -0
  109. package/server/lib/opencode/routes.js +5 -3
  110. package/server/lib/opencode/settings-files.js +214 -0
  111. package/server/lib/opencode/settings-helpers.js +88 -41
  112. package/server/lib/opencode/settings-helpers.test.js +176 -1
  113. package/server/lib/opencode/settings-registry.json +750 -0
  114. package/server/lib/opencode/settings-runtime.js +175 -27
  115. package/server/lib/opencode/settings-runtime.test.js +321 -7
  116. package/server/lib/project-context/DOCUMENTATION.md +38 -4
  117. package/server/lib/project-context/routes.http.test.js +18 -0
  118. package/server/lib/project-context/routes.js +15 -0
  119. package/server/lib/project-context/runtime.js +256 -25
  120. package/server/lib/project-context/runtime.test.js +160 -3
  121. package/server/lib/projects/DOCUMENTATION.md +77 -0
  122. package/server/lib/projects/project-config.js +179 -17
  123. package/server/lib/projects/project-config.test.js +97 -0
  124. package/server/lib/projects/project-id.js +43 -0
  125. package/server/lib/projects/project-setup.js +409 -0
  126. package/server/lib/projects/project-setup.test.js +557 -0
  127. package/server/lib/projects/routes.js +59 -0
  128. package/server/lib/quota/DOCUMENTATION.md +31 -1
  129. package/server/lib/quota/providers/cline-pass.js +125 -0
  130. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  131. package/server/lib/quota/providers/index.js +7 -0
  132. package/server/lib/quota/providers/neuralwatt.js +3 -6
  133. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  134. package/server/lib/quota/providers/ollama-cloud.js +31 -0
  135. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  136. package/server/lib/quota/providers/opencode-go.js +1 -1
  137. package/server/lib/quota/providers/opencode-go.test.js +26 -1
  138. package/server/lib/quota/providers/openrouter.js +119 -24
  139. package/server/lib/quota/providers/openrouter.test.js +330 -0
  140. package/server/lib/relay/DOCUMENTATION.md +75 -0
  141. package/server/lib/relay/cross-compat.test.js +26 -0
  142. package/server/lib/relay/downstream-scheduler.js +154 -0
  143. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  144. package/server/lib/relay/e2ee.js +10 -8
  145. package/server/lib/relay/flow-control.test.js +177 -0
  146. package/server/lib/relay/host-client.js +44 -8
  147. package/server/lib/relay/host-client.test.js +14 -0
  148. package/server/lib/relay/tunnel-codec.js +9 -0
  149. package/server/lib/relay/tunnel-host.js +66 -17
  150. package/server/lib/scheduled-tasks/DOCUMENTATION.md +9 -1
  151. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +28 -0
  152. package/server/lib/scheduled-tasks/runtime.js +12 -2
  153. package/server/lib/scheduled-tasks/runtime.test.js +53 -0
  154. package/server/lib/session-assist/DOCUMENTATION.md +131 -66
  155. package/server/lib/session-assist/context.js +127 -0
  156. package/server/lib/session-assist/context.test.js +132 -0
  157. package/server/lib/session-assist/prompt.js +54 -0
  158. package/server/lib/session-assist/runtime.js +117 -267
  159. package/server/lib/session-assist/runtime.test.js +203 -0
  160. package/server/lib/session-goal/runtime.js +4 -9
  161. package/server/lib/small-model/DOCUMENTATION.md +3 -2
  162. package/server/lib/small-model/call.js +9 -4
  163. package/server/lib/small-model/call.test.js +29 -0
  164. package/server/lib/small-model/index.js +5 -10
  165. package/server/lib/small-model/runtime-providers.js +15 -7
  166. package/server/lib/small-model/runtime-providers.test.js +7 -1
  167. package/server/lib/terminal/DOCUMENTATION.md +4 -4
  168. package/server/lib/terminal/runtime.js +11 -6
  169. package/server/lib/terminal/runtime.test.js +20 -13
  170. package/server/lib/walkthrough/DOCUMENTATION.md +49 -20
  171. package/server/lib/walkthrough/model-settings.js +8 -12
  172. package/server/lib/walkthrough/pr-source.test.js +21 -0
  173. package/server/lib/walkthrough/prompt.js +3 -1
  174. package/server/lib/walkthrough/pull-request.js +7 -4
  175. package/server/lib/walkthrough/pull-request.test.js +16 -0
  176. package/server/lib/walkthrough/routes.js +19 -0
  177. package/server/lib/walkthrough/routes.test.js +26 -0
  178. package/server/lib/walkthrough/sources.js +36 -4
  179. package/server/opencode-worktree-readiness.test.js +130 -0
  180. package/dist/assets/DiffView-hDBKesA_.js +0 -4
  181. package/dist/assets/FilesView-CdWzeOp9.js +0 -17
  182. package/dist/assets/MarkdownImageGallery-Czv_mhvS.js +0 -1
  183. package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +0 -12
  184. package/dist/assets/OnboardingScreen-ChxQoAkx.js +0 -1
  185. package/dist/assets/PierreDiffViewer-BchBtZlp.js +0 -157
  186. package/dist/assets/PlanView-DyDt_nZ_.js +0 -5
  187. package/dist/assets/SettingsView-BKf5xBsP.js +0 -28
  188. package/dist/assets/WalkthroughView-DOeCsMju.js +0 -4
  189. package/dist/assets/contextPanelEmbeddedChat-C0ZLAepL.js +0 -1
  190. package/dist/assets/de-B5JaA3SA.js +0 -10
  191. package/dist/assets/es-EPIH88ii.js +0 -16
  192. package/dist/assets/fr-CAMfxUdZ.js +0 -14
  193. package/dist/assets/index-DF5kMP-i.js +0 -39
  194. package/dist/assets/index-Dl3xbAB_.css +0 -1
  195. package/dist/assets/ja-CifOE1VN.js +0 -16
  196. package/dist/assets/ko-BBDyAyYQ.js +0 -16
  197. package/dist/assets/main-MhSaOZoB.js +0 -930
  198. package/dist/assets/markdownCore-BrBwOOMn.js +0 -3
  199. package/dist/assets/patchFileDiff-o8ms1me8.js +0 -10
  200. package/dist/assets/pl-DgEHYfFM.js +0 -16
  201. package/dist/assets/pt-BR-DuWHojUw.js +0 -16
  202. package/dist/assets/renderElectronMiniChatApp-CDgBwwCS.js +0 -2
  203. package/dist/assets/renderMobileApp-DJIKIK1r.js +0 -25
  204. package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +0 -17
  205. package/dist/assets/scheduledTasksApi-D8yamh1b.js +0 -1
  206. package/dist/assets/tr-D5m2yIWL.js +0 -7
  207. package/dist/assets/uk-D_q60oog.js +0 -16
  208. package/dist/assets/useInlineCommentController-Brz_cLcQ.js +0 -2
  209. package/dist/assets/useRootScrollLock-lXEnWlaU.js +0 -1
  210. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  211. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
  212. package/dist/assets/vendor-zod-CK21ihK-.js +0 -39
  213. package/dist/assets/zh-CN-D8QvsVeg.js +0 -16
  214. package/dist/assets/zh-TW-B9t7rQQO.js +0 -16
  215. package/server/lib/mcp-reconnect/DOCUMENTATION.md +0 -55
  216. package/server/lib/mcp-reconnect/runtime.js +0 -122
  217. package/server/lib/mcp-reconnect/runtime.test.js +0 -140
@@ -1,17 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bl3LSbjn.js","assets/useAppFontEffects-D7sNpuL2.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DF5kMP-i.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-CK21ihK-.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-Dl3xbAB_.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BeMD8X_w.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-C0ZLAepL.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Dp3KMRQG.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/computeVirtualFileMetrics-CzgLum_K.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-CWFPwmnU.js","assets/isDiffPlainText-Dx-dB_8l.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/PlanView-DyDt_nZ_.js","assets/shikiHighlight-TEQCmzW8.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-Brz_cLcQ.js","assets/CodeMirrorCommentWidgets-CSICpWQD.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 Xt}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as $e,r as le,j as t,R as d}from"./vendor-react-BUCujlKS.js";import{ea as wo,eb as Bn,c4 as yr,c5 as wr,aU as vo,f as st,o as So,bF as Is,bG as Ts,bI as Ps,I as E,c0 as jo,bZ as Mn,h as ae,B as Pe,bg as vr,g as No,t as je,ec as ko,ed as Co,ee as Io,O as To,dU as Po,ef as Do,eg as Eo,eh as Ro,y as tt,ei as Ao,l as kt,ej as Bo,du as Sr,ek as Mo,dv as Lo,b_ as Ds,cR as Fo,bH as Gs,bb as Oo,be as _o,bd as $o,b7 as gs,el as Uo,em as Wo,en as Vo,eo as zo,ep as Go,eq as Ho,er as Ko,es as qo,b as Tt,c8 as Jo,a3 as Ln,bh as Yo,dO as jr,dD as Nr,dF as Qo,et as Xo,u as Jt,cD as Zo,eu as Os,T as St,dl as ea,ev as Fn,ew as ta,ex as sa,ey as On,ez as na,eA as ra,eB as oa,eC as aa,b8 as ia,eD as la,b6 as Gt,b3 as Ht,b5 as Kt,bY as Hs,bT as _s,bU as $s,eE as ca,eF as un,bV as fn,bW as Us,bX as Yt,N as kr,eG as da,Q as ua,eH as fa,eI as _n,eJ as ma,U as ha,V as pa,S as ga,eK as Cr,eL as xa,e0 as ba,r as Ir,W as Ks,eM as ya,eN as wa,eO as va,a1 as mn,eP as Sa,M as us,a7 as ms,a8 as hs,a9 as ps,cy as hn,cz as pn,cA as gn,cB as xn,ct as At,cu as Et,eQ as js,b2 as Bt,bC as bn,bJ as ja,bK as Cn,av as Ns,c6 as Na,eR as Tr,aw as yn,af as ka,dK as Ca,ai as In,eS as As,m as Pr,cV as Vt,eT as Ia,eU as Qs,eV as Ta,eW as $n,cT as Un,eX as Pa,b$ as Da,dC as Ea,dE as Ra,eY as Aa,eZ as Ba,cx as Ma,$ as La,H as Fa,c as Oa,d as _a,cO as $a,e_ as Dr,_ as Er,X as Ua,e1 as Dt,e$ as Wa,f0 as Va,f1 as Rr,a0 as qs,f2 as Rt,f3 as wn,f4 as za,f5 as Ar,f6 as Bs,cf as Ga,f7 as Ha,f8 as Ka,f9 as qa,fa as Ja,fb as Ya,de as Qa,dq as Xa,Z as vn,b9 as Za,c$ as ei,fc as ti,at as si,ac as ni,bR as ri,fd as Br,e7 as oi,fe as ai,ff as ii,fg as li,fh as ci,bO as di,cZ as ui,n as fi,a5 as mi,fi as hi}from"./useAppFontEffects-D7sNpuL2.js";import{av as pi,aw as Wn,ax as gi,i as xi,ay as bi,G as Mr,a7 as yi,r as Lt,u as Ue,A as wi,b as vi,v as Lr,a as zt,d as Vn,a8 as Fr,a0 as Si,az as _t,o as ji,m as xs,z as Or,E as lt,ad as Ni,ae as ki,aA as Ci,aB as Ii,I as Ws,w as fs,_ as Ti,aC as Pi,ab as Tn,aD as Di,aE as Ei,aF as zn,aG as ys,aH as Xs,aI as _r,aJ as Ri,Z as Ai,n as Bi,y as Mi}from"./index-DF5kMP-i.js";import{g as Li,h as Fi,i as Oi,d as _i,C as $i,c as Ui,M as Wi,S as Vi,a as zi,b as Gi}from"./vendor-base-ui-BeMD8X_w.js";import{c as Pn,d as Hi,p as Ki}from"./vendor-zustand-BAGL70zf.js";import{i as $r}from"./contextPanelEmbeddedChat-C0ZLAepL.js";import{r as qi,a as Ji,s as Gn}from"./vendor-zod-CK21ihK-.js";import{f as Ur,h as Wr,P as Vr,k as Yi,D as zr,j as Gr}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as Hr,S as Kr,h as Qi,v as Xi,a as Zi}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as qr}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";const el=["typescript","javascript","tsx","jsx","json","markdown"],Jr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-alt"}};let Hn=null;const Yr=()=>(Hn??=Promise.all([Xt(()=>import("./index-Bl3LSbjn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112])),Xt(()=>import("./workerFactory-tw7cIdmV.js"),[]),Xt(()=>import("./appThemeRegistry-BK0dHKa6.js"),__vite__mapDeps([113,114,100,101,5,85,86,87,88,89,90,91,92,93,94,95,96,97,98]))]).then(([s,e,n])=>({WorkerPoolManager:s.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:n.ensurePierreThemeRegistered})),Hn),ks={},Kn=new Set,Sn=new Set;let Fs={light:"pierre-light",dark:"pierre-dark"};const tl=()=>{for(const s of Sn)s()},Qr=(s,e)=>{e.setRenderOptions({theme:Fs,lineDiffType:Jr[s].lineDiffType})},jn=s=>{typeof window>"u"||Kn.has(s)||(Kn.add(s),Yr().then(e=>{if(ks[s])return;const n=Jr[s],r=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:n.poolSize,totalASTLRUCacheSize:n.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:el,lineDiffType:n.lineDiffType,preferredHighlighter:"shiki-wasm"});r.initialize(),ks[s]=r,Qr(s,r),tl()}))},sl=s=>(Sn.add(s),()=>Sn.delete(s)),nl=s=>{if(!(Fs.light===s.light&&Fs.dark===s.dark)){Fs=s;for(const e of Object.keys(ks)){const n=ks[e];n&&Qr(e,n)}}},Kf=s=>{const e=$e.c(15),{children:n}=s,r=wo();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Bn(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=Bn(!0),e[1]=i):i=e[1];const c=i,l=r?.lightThemeId??a.metadata.id,f=r?.darkThemeId??c.metadata.id;let u;e[2]!==l||e[3]!==r?.availableThemes?(u=r?.availableThemes.find(C=>C.metadata.id===l)??a,e[2]=l,e[3]=r?.availableThemes,e[4]=u):u=e[4];const m=u;let w;e[5]!==f||e[6]!==r?.availableThemes?(w=r?.availableThemes.find(C=>C.metadata.id===f)??c,e[5]=f,e[6]=r?.availableThemes,e[7]=w):w=e[7];const h=w;let b,g;e[8]!==h||e[9]!==m?(b=()=>{let C=!1;return Yr().then(L=>{C||(L.ensurePierreThemeRegistered(m),L.ensurePierreThemeRegistered(h),nl({light:m.metadata.id,dark:h.metadata.id}))}),()=>{C=!0}},g=[h,m],e[8]=h,e[9]=m,e[10]=b,e[11]=g):(b=e[10],g=e[11]),le.useEffect(b,g);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[12]=j):j=e[12],le.useEffect(ol,j);let p;return e[13]!==n?(p=t.jsx(t.Fragment,{children:n}),e[13]=n,e[14]=p):p=e[14],p},qf=s=>{const e=$e.c(5),n=s===void 0?"unified":s;let r;e[0]!==n?(r=()=>ks[n],e[0]=n,e[1]=r):r=e[1];const o=le.useSyncExternalStore(sl,r,al);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]),le.useEffect(a,i),o};function rl(){jn("unified"),jn("split")}function ol(){if(typeof window>"u")return;const s=rl;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 al(){}const Zs=(s,e)=>yr(wr.getState().dictionary,s,e),il=s=>{const e=s.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},ll=s=>{const e=il(s);return e==="signature"?Zs("updateDialog.error.signatureRejected"):e==="updater-disabled"?Zs("updateDialog.error.updaterDisabled"):s.message.trim()||Zs("updateDialog.error.restartFailed")},qn="aiworker.update-install-id";function cl(){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 dl(){if(typeof window>"u")return"unknown";try{const{deviceType:s}=vo();return s}catch{return"unknown"}}function ul(){const s=typeof window<"u"?window.__AIWORKER_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 fl(){const s=vi();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 ml(s){const e=Ue.getState().reportUsage,n=new URLSearchParams({reportUsage:e?"true":"false"});if(n.set("deviceClass",dl()),n.set("arch",ul()),n.set("platform",fl()),e&&(s==="desktop"||s==="mobile")){const r=cl();r&&n.set("installId",r)}return s==="desktop"?(n.set("appType","desktop-electron"),n.set("instanceMode",wi()?"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 Ms(s,e){try{const n=ml(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 Lt(`/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 hl(){return xi()?"mobile":bi()?"desktop":Mr()?"vscode":yi()?"web":null}const Jn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},pl=Pn()((s,e)=>({...Jn,checkForUpdates:async()=>{const n=hl();if(!n)return null;s({checking:!0,error:null,runtimeType:n});try{let r=null,o=null;if(n==="desktop"){const a="1.22.2",[i,c]=await Promise.allSettled([Wn(),Ms("desktop",a)]),l=i.status==="fulfilled"?i.value:null;return o=c.status==="fulfilled"?c.value?.nextSuggestedCheckInSec??null:null,s({checking:!1,available:l?.available??!1,info:l,lastChecked:Date.now(),nextCheckInSec:o}),o}else n==="web"?(r=await Ms("web"),o=r?.nextSuggestedCheckInSec??null):n==="vscode"?o=(await Ms("vscode"))?.nextSuggestedCheckInSec??null:n==="mobile"&&(r=await Ms("mobile","1.22.2"),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 Wn();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 gi(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)){s({error:null});try{if(!await pi())throw new Error(yr(wr.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(o){s({error:ll(o instanceof Error?o:new Error(String(o)))})}}},dismiss:()=>{s({available:!1,downloaded:!1,info:null})},reset:()=>{s(Jn)}})),Yn="https://roweb.cn/roweb/openchamber/releases";function gl(s){const e=new Date(`${s}T00:00:00`);return Number.isNaN(e.getTime())?s:new Intl.DateTimeFormat(vr(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function xl(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 bl(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 yl(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,c=s.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:c}})}const Xn=2e3,wl=600*1e3;async function vl(){try{const s=await Lt("/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 Sl(){try{return(await Lt("/health",{method:"GET",headers:{Accept:"application/json"}})).ok}catch{return!1}}async function jl(s,e=Math.ceil(wl/Xn),n=Xn){for(let r=0;r<e;r++){try{const o=await Lt("/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 Sl())return!0}catch{}await new Promise(o=>setTimeout(o,n))}return!1}const Jf=({open:s,onOpenChange:e,info:n,downloading:r,downloaded:o,progress:a,error:i,onDownload:c,onRestart:l,runtimeType:f="desktop"})=>{const{t:u}=st(),[m,w]=le.useState(!1),[h,b]=le.useState("idle"),[g,j]=le.useState(null),p=n?.version?n.releaseUrl||`${Yn}/tag/v${n.version}`:Yn,C=n?.downloadUrl||p,L=a?.total?Math.round(a.downloaded/a.total*100):0,_=f==="web",F=f==="mobile",T=n?.updateCommand||"aiworker update";le.useEffect(()=>{s||(b("idle"),j(null))},[s]);const x=async()=>{(await No(T)).ok&&(w(!0),setTimeout(()=>w(!1),2e3))},S=le.useCallback(async q=>{await So(q)},[]),I=le.useCallback(async()=>{b("updating"),j(null);const q=await vl();if(!q.success){b("error"),j(q.error||u("updateDialog.error.updateFailed"));return}q.autoRestart&&(b("restarting"),await new Promise(Q=>setTimeout(Q,2e3))),b("reconnecting"),await jl(n?.currentVersion)?window.location.reload():(b("error"),j(u("updateDialog.error.takingLonger")))},[n?.currentVersion,u]),$=le.useCallback(()=>{S(C)},[S,C]),R=h!=="idle"&&h!=="error",z=le.useMemo(()=>{if(!n?.body)return null;const q=n.body.trim();if(!q)return null;const ne=yl(q);if(ne.length===0)return{kind:"raw",title:u("updateDialog.changelog.title"),content:Qn(q)};const Q=[...ne].sort((H,X)=>bl(H.version,X.version));return{kind:"sections",title:u("updateDialog.changelog.title"),sections:Q.map(H=>({version:H.version,dateLabel:gl(H.date),content:Qn(xl(H.raw)||q)}))}},[n?.body,u]);return t.jsx(Is,{open:s,onOpenChange:R?void 0:e,children:t.jsxs(Ts,{className:"max-w-4xl p-5 bg-background border-[var(--interactive-border)]",showCloseButton:!0,children:[t.jsxs("div",{className:"flex items-center mb-1",children:[t.jsxs(Ps,{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:u(h==="restarting"||h==="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:[_&&R&&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:[h==="updating"&&u("updateDialog.status.installingUpdate"),h==="restarting"&&u("updateDialog.status.serverRestarting"),h==="reconnecting"&&u("updateDialog.status.waitingForServer")]})]}),t.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:u("updateDialog.status.autoReloadHint")})]}),z&&!R&&t.jsx("div",{className:"rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 overflow-hidden",children:t.jsx(jo,{className:"max-h-[400px] p-0",fillContainer:!1,children:z.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 [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:q=>{const Q=q.target.closest("a");Q&&Q.href&&(q.preventDefault(),q.stopPropagation(),S(Q.href))},children:t.jsx(Mn,{content:z.content,disableLinkSafety:!0,enableFileReferences:!1})}):t.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:z.sections.map(q=>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",q.version]}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:q.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 [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:ne=>{const H=ne.target.closest("a");H&&H.href&&(ne.preventDefault(),ne.stopPropagation(),S(H.href))},children:t.jsx(Mn,{content:q.content,disableLinkSafety:!0,enableFileReferences:!1})})]},q.version))})})}),_&&h==="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:u("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:T}),t.jsx("button",{onClick:x,className:ae("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",m&&"text-[var(--status-success)]"),title:u(m?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:m?t.jsx(E,{name:"check",className:"h-4 w-4"}):t.jsx(E,{name:"clipboard",className:"h-4 w-4"})})]})]}),!_&&!F&&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:u("updateDialog.status.downloadingPayload")}),t.jsxs("span",{className:"font-mono text-foreground",children:[L,"%"]})]}),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:`${L}%`}})})]}),(i||g)&&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||g})})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[t.jsxs("a",{href:p,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:[!_&&!F&&!o&&!r&&t.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[t.jsx(E,{name:"download",className:"h-4 w-4"}),u("updateDialog.actions.downloadUpdate")]}),!_&&!F&&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"}),u("updateDialog.status.downloading")]}),!_&&!F&&o&&t.jsxs("button",{onClick:l,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"}),u("updateDialog.actions.restartToUpdate")]}),F&&t.jsxs(Pe,{onClick:$,size:"default",children:[t.jsx(E,{name:"external-link",className:"h-4 w-4"}),u("updateDialog.actions.openMobileUpdate")]}),_&&!R&&t.jsxs("button",{onClick:I,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"}),u("updateDialog.actions.updateNow")]}),_&&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"}),u("updateDialog.status.updating")]})]})]})]})})},Yf=s=>!(s.dismissed==="true"||s.sessionShown==="true"||s.hasActiveToast),Nl=s=>!(!s.version||s.seenVersions.has(s.version)||s.dismissedVersion!==null&&s.dismissedVersion===s.version),kl=s=>{if(s===null||typeof s!="object")return"";const e=s.version;return typeof e!="string"?"":e.trim()},Cl=s=>!s||s.upgrade?.supported!==!0||s.available!==!0||typeof s.latestVersion!="string"?"":s.latestVersion.trim(),ds="opencode-update-available",Ls="opencode-upgrade-progress",Il=5e3,Tl=[1e4,6e4],Zn="opencode-update-toast-dismissed-version",Qf=()=>{const{t:s}=st(),e=Ue(i=>i.showOpenCodeUpdateNotifications),n=le.useRef(new Set),r=le.useRef(!1);le.useEffect(()=>{e||je.dismiss(ds)},[e]);const o=le.useCallback(()=>{je.dismiss(Ls),ko({message:s("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[s]),a=le.useCallback(async()=>{if(!r.current){r.current=!0,je.dismiss(ds),je.message(s("opencodeUpdate.toast.upgrading.title"),{id:Ls,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 Lt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),c=await i.json().catch(()=>null);if(!i.ok||c?.success===!1)throw new Error(c?.error||i.statusText||s("opencodeUpdate.toast.failed.description"));je.success(s("opencodeUpdate.toast.updated.title"),{id:Ls,description:c?.version?s("opencodeUpdate.toast.updated.descriptionWithVersion",{version:c.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){je.error(s("opencodeUpdate.toast.failed.title"),{id:Ls,description:i instanceof Error?i.message:s("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{r.current=!1}}},[o,s]);return le.useEffect(()=>{const i=w=>{if(!Ue.getState().showOpenCodeUpdateNotifications){je.dismiss(ds);return}Nl({version:w,dismissedVersion:Vn().getItem(Zn),seenVersions:n.current})&&(n.current.add(w),je.info(s("opencodeUpdate.toast.available.title"),{id:ds,description:s("opencodeUpdate.toast.available.description",{version:w}),duration:1/0,action:{label:s("opencodeUpdate.toast.actions.update"),onClick:a},cancel:{label:s("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Vn().setItem(Zn,w),Fr({openCodeUpdateToastDismissedVersion:w}),je.dismiss(ds)}}}))};let c=!1;const l=[],f=async(w,h=zt())=>{try{const b=await Lt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!b.ok)throw new Error(b.statusText||"OpenCode upgrade status check failed");const g=await b.json().catch(()=>null),j=Cl(g);!c&&h===zt()&&j&&i(j)}catch{const b=Tl[w];!c&&h===zt()&&b!==void 0&&l.push(setTimeout(()=>{f(w+1,h)},b))}},u=w=>{kl(w.detail)&&f(0)};e&&l.push(setTimeout(()=>{f(0)},Il));const m=Lr(({runtimeKey:w})=>{n.current.clear(),je.dismiss(ds),Ue.getState().showOpenCodeUpdateNotifications&&f(0,w)});return window.addEventListener("aiworker:opencode-update-available",u),()=>{c=!0;for(const w of l)clearTimeout(w);m(),window.removeEventListener("aiworker:opencode-update-available",u)}},[a,e,s]),null},Xf=()=>{const s=$e.c(3),[e,n]=d.useState(Pl),{isUpdating:r}=e;let o,a;if(s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>Io(n),a=[],s[0]=o,s[1]=a):(o=s[0],a=s[1]),d.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(To,{width:80,height:80,isAnimated:!0})}),s[2]=i):i=s[2],i};function Pl(){return Co()}class Dl extends d.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(Po,{className:"w-full max-w-md",children:[t.jsx(Do,{className:"text-center",children:t.jsxs(Eo,{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(Ro,{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(Pe,{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 El(s){const e=$e.c(22),{t:n}=st();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 c;e[8]!==n?(c=n("chat.errorBoundary.resetAction"),e[8]=n,e[9]=c):c=e[9];let l;e[10]!==n?(l=n("chat.errorBoundary.persistentHint"),e[10]=n,e[11]=l):l=e[11];let f;e[12]!==r||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==c||e[17]!==l?(f={title:r,description:o,sessionLabel:a,detailsSummary:i,resetAction:c,persistentHint:l},e[12]=r,e[13]=o,e[14]=a,e[15]=i,e[16]=c,e[17]=l,e[18]=f):f=e[18];let u;return e[19]!==s||e[20]!==f?(u=t.jsx(Dl,{...s,texts:f}),e[19]=s,e[20]=f,e[21]=u):u=e[21],u}const Zf=s=>{const e=$e.c(8),{active:n,messagesEnabled:r,readOnly:o,initialAllowPromptingSubagentSessions:a}=s,i=n===void 0?!0:n,c=o===void 0?!1:o,f=tt(Rl)||void 0;let u;e[0]!==i||e[1]!==a||e[2]!==r||e[3]!==c?(u=t.jsx(Ao,{active:i,messagesEnabled:r,readOnly:c,initialAllowPromptingSubagentSessions:a}),e[0]=i,e[1]=a,e[2]=r,e[3]=c,e[4]=u):u=e[4];let m;return e[5]!==f||e[6]!==u?(m=t.jsx(El,{sessionId:f,children:u}),e[5]=f,e[6]=u,e[7]=m):m=e[7],m};function Rl(s){return s.currentSessionId}const Al=Li,Bl=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&&le.isValidElement(r)?{render:r}:{children:r},e[5]=n,e[6]=r,e[7]=i):i=e[7];const c=i;let l;e[8]!==o?(l=ae("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]=l):l=e[9];let f;return e[10]!==a||e[11]!==c||e[12]!==l?(f=t.jsx(Fi,{className:l,...a,...c}),e[10]=a,e[11]=c,e[12]=l,e[13]=f):f=e[13],f},Ml=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=ae("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(Oi,{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}=st(),{open:r,onOpenChange:o,target:a,projectDirectory:i,submitting:c,allowRunAsGoal:l,onConfirm:f}=s,u=c===void 0?!1:c,m=l===void 0?!1:l;let w;e[0]!==m?(w=m&&!Mr(),e[0]=m,e[1]=w):w=e[1];const h=w,b=kt(Kl),g=kt(Hl),j=Bo(Gl),p=kt(zl),C=kt(Vl),L=kt(Wl),_=kt(Ul),F=kt($l);let T;e[2]!==F||e[3]!==L||e[4]!==C||e[5]!==_?(T=()=>er({providerID:C,modelID:L,variant:_,agent:F}),e[2]=F,e[3]=L,e[4]=C,e[5]=_,e[6]=T):T=e[6];const[x,S]=d.useState(T);let I,$;e[7]!==j||e[8]!==g||e[9]!==b||e[10]!==r||e[11]!==i?(I=()=>{r&&(b({directory:i,source:"todoSendDialog"}),g({directory:i}),j())},$=[r,b,g,j,i],e[7]=j,e[8]=g,e[9]=b,e[10]=r,e[11]=i,e[12]=I,e[13]=$):(I=e[12],$=e[13]),d.useEffect(I,$);let R,z;e[14]!==F||e[15]!==L||e[16]!==C||e[17]!==_||e[18]!==r?(R=()=>{r&&S(er({providerID:C,modelID:L,variant:_,agent:F}))},z=[r,C,L,_,F],e[14]=F,e[15]=L,e[16]=C,e[17]=_,e[18]=r,e[19]=R,e[20]=z):(R=e[19],z=e[20]),d.useEffect(R,z);let q,ne;e[21]!==x.modelID||e[22]!==x.providerID||e[23]!==r||e[24]!==p?(q=()=>{if(!r||p.length===0)return;const Me=p.find(qe=>qe.id===x.providerID)??p[0],ke=Array.isArray(Me?.models)?Me.models:[],Qe=ke.some(qe=>qe.id===x.modelID),Ee=ke[0]?.id??"";Me?.id===x.providerID&&Qe||S(qe=>({...qe,providerID:Me?.id??"",modelID:Qe?qe.modelID:Ee,variant:""}))},ne=[r,p,x.providerID,x.modelID],e[21]=x.modelID,e[22]=x.providerID,e[23]=r,e[24]=p,e[25]=q,e[26]=ne):(q=e[25],ne=e[26]),d.useEffect(q,ne);const Q=_l;let H;if(e[27]!==x.modelID||e[28]!==x.providerID||e[29]!==p){let Me;e[31]!==x.providerID?(Me=Qe=>Qe.id===x.providerID,e[31]=x.providerID,e[32]=Me):Me=e[32],H=p.find(Me)?.models?.find(Qe=>Qe.id===x.modelID),e[27]=x.modelID,e[28]=x.providerID,e[29]=p,e[30]=H}else H=e[30];const X=H;let ue;e[33]!==X?(ue=X?.variants?Object.keys(X.variants):[],e[33]=X,e[34]=ue):ue=e[34];const V=ue,P=V.length>0;let W,U;e[35]!==x.variant||e[36]!==P?(W=()=>{P||!x.variant||S(Ol)},U=[P,x.variant],e[35]=x.variant,e[36]=P,e[37]=W,e[38]=U):(W=e[37],U=e[38]),d.useEffect(W,U);let D;e[39]!==x.modelID||e[40]!==x.providerID?(D=x.providerID.trim().length>0&&x.modelID.trim().length>0,e[39]=x.modelID,e[40]=x.providerID,e[41]=D):D=e[41];const Y=D;let M;e[42]!==Y||e[43]!==x||e[44]!==f||e[45]!==u?(M=()=>{!Y||u||f(x)},e[42]=Y,e[43]=x,e[44]=f,e[45]=u,e[46]=M):M=e[46];const K=M;let A,Z;e[47]!==K||e[48]!==r?(A=()=>{if(!r)return;const Me=ke=>{(ke.metaKey||ke.ctrlKey)&&ke.key==="Enter"&&(ke.preventDefault(),K())};return window.addEventListener("keydown",Me),()=>window.removeEventListener("keydown",Me)},Z=[r,K],e[47]=K,e[48]=r,e[49]=A,e[50]=Z):(A=e[49],Z=e[50]),d.useEffect(A,Z);let ee;e[51]!==n||e[52]!==a?(ee=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[51]=n,e[52]=a,e[53]=ee):ee=e[53];const te=ee;let fe;e[54]!==o||e[55]!==u?(fe=Me=>{u||o(Me)},e[54]=o,e[55]=u,e[56]=fe):fe=e[56];let ce;e[57]!==te?(ce=t.jsx(Gs,{children:t.jsx(Ps,{children:te})}),e[57]=te,e[58]=ce):ce=e[58];let me;e[59]!==n?(me=n("chat.modelControls.model"),e[59]=n,e[60]=me):me=e[60];let re;e[61]!==me?(re=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:me}),e[61]=me,e[62]=re):re=e[62];let he;e[63]===Symbol.for("react.memo_cache_sentinel")?(he=(Me,ke)=>{S(Qe=>({...Qe,providerID:Me,modelID:ke,variant:""}))},e[63]=he):he=e[63];let ge;e[64]!==x.modelID||e[65]!==x.providerID?(ge=t.jsx(Sr,{providerId:x.providerID,modelId:x.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:he}),e[64]=x.modelID,e[65]=x.providerID,e[66]=ge):ge=e[66];let v;e[67]!==re||e[68]!==ge?(v=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[re,ge]}),e[67]=re,e[68]=ge,e[69]=v):v=e[69];let J;e[70]!==n?(J=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[70]=n,e[71]=J):J=e[71];let B;e[72]!==J?(B=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:J}),e[72]=J,e[73]=B):B=e[73];const oe=!P;let de;e[74]===Symbol.for("react.memo_cache_sentinel")?(de=Me=>S(ke=>({...ke,variant:Me})),e[74]=de):de=e[74];let pe;e[75]!==x.variant||e[76]!==oe||e[77]!==V?(pe=t.jsx(Mo,{value:x.variant,options:V,disabled:oe,onChange:de}),e[75]=x.variant,e[76]=oe,e[77]=V,e[78]=pe):pe=e[78];let Ne;e[79]!==B||e[80]!==pe?(Ne=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[B,pe]}),e[79]=B,e[80]=pe,e[81]=Ne):Ne=e[81];let We;e[82]!==n?(We=n("sessions.scheduledTasks.editor.agent.label"),e[82]=n,e[83]=We):We=e[83];let _e;e[84]!==We?(_e=t.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:We}),e[84]=We,e[85]=_e):_e=e[85];let be;e[86]===Symbol.for("react.memo_cache_sentinel")?(be=Me=>S(ke=>({...ke,agent:Me})),e[86]=be):be=e[86];let De;e[87]!==x.agent?(De=t.jsx(Lo,{agentName:x.agent,filter:Q,dropdownPortalToBody:!0,onChange:be}),e[87]=x.agent,e[88]=De):De=e[88];let Ie;e[89]!==_e||e[90]!==De?(Ie=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[_e,De]}),e[89]=_e,e[90]=De,e[91]=Ie):Ie=e[91];let Be;e[92]!==v||e[93]!==Ne||e[94]!==Ie?(Be=t.jsxs("div",{className:"flex flex-col gap-4",children:[v,Ne,Ie]}),e[92]=v,e[93]=Ne,e[94]=Ie,e[95]=Be):Be=e[95];const Fe=`flex items-center gap-3 ${h?"justify-between":"justify-end"}`;let He;e[96]!==x.runAsGoal||e[97]!==h||e[98]!==u||e[99]!==n?(He=h?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ds,{checked:x.runAsGoal===!0,onChange:Me=>S(ke=>({...ke,runAsGoal:Me})),disabled:u,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:u,onClick:()=>S(Fl),children:n("sessions.scheduledTasks.editor.goal.label")})]}):null,e[96]=x.runAsGoal,e[97]=h,e[98]=u,e[99]=n,e[100]=He):He=e[100];let Ke;e[101]!==o?(Ke=()=>o(!1),e[101]=o,e[102]=Ke):Ke=e[102];let nt;e[103]!==n?(nt=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[103]=n,e[104]=nt):nt=e[104];let Ze;e[105]!==u||e[106]!==Ke||e[107]!==nt?(Ze=t.jsx(Pe,{variant:"ghost",size:"sm",onClick:Ke,disabled:u,children:nt}),e[105]=u,e[106]=Ke,e[107]=nt,e[108]=Ze):Ze=e[108];const rt=!Y||u;let Je;e[109]!==u||e[110]!==n?(Je=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[109]=u,e[110]=n,e[111]=Je):Je=e[111];let Ve;e[112]!==K||e[113]!==rt||e[114]!==Je?(Ve=t.jsx(Pe,{size:"sm",onClick:K,disabled:rt,children:Je}),e[112]=K,e[113]=rt,e[114]=Je,e[115]=Ve):Ve=e[115];let Ye;e[116]!==Ze||e[117]!==Ve?(Ye=t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ze,Ve]}),e[116]=Ze,e[117]=Ve,e[118]=Ye):Ye=e[118];let ze;e[119]!==Fe||e[120]!==He||e[121]!==Ye?(ze=t.jsxs("div",{className:Fe,children:[He,Ye]}),e[119]=Fe,e[120]=He,e[121]=Ye,e[122]=ze):ze=e[122];let xe;e[123]!==ce||e[124]!==Be||e[125]!==ze?(xe=t.jsxs(Ts,{className:"max-w-md overflow-visible",children:[ce,Be,ze]}),e[123]=ce,e[124]=Be,e[125]=ze,e[126]=xe):xe=e[126];let et;return e[127]!==r||e[128]!==fe||e[129]!==xe?(et=t.jsx(Is,{open:r,onOpenChange:fe,children:xe}),e[127]=r,e[128]=fe,e[129]=xe,e[130]=et):et=e[130],et}function Fl(s){return{...s,runAsGoal:s.runAsGoal!==!0}}function Ol(s){return{...s,variant:""}}function _l(s){return Fo(s.mode)}function $l(s){return s.currentAgentName||""}function Ul(s){return s.currentVariant||""}function Wl(s){return s.currentModelId}function Vl(s){return s.currentProviderId}function zl(s){return s.providers}function Gl(s){return s.loadAgents}function Hl(s){return s.loadAgents}function Kl(s){return s.loadProviders}function ql(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(_i,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Jl(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($i,{...n}),e[2]=n,e[3]=r):r=e[3],r}function Yl(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 c;e[6]!==o?(c=ae("app-region-no-drag z-50",o),e[6]=o,e[7]=c):c=e[7];let l;e[8]!==i?(l={color:"var(--surface-elevated-foreground)",...i},e[8]=i,e[9]=l):l=e[9];let f;e[10]!==r?(f=ae(Oo,r),e[10]=r,e[11]=f):f=e[11];let u;e[12]!==n||e[13]!==a||e[14]!==l||e[15]!==f?(u=t.jsx(Ui,{"data-slot":"dropdown-menu-content",style:l,className:f,...a,children:n}),e[12]=n,e[13]=a,e[14]=l,e[15]=f,e[16]=u):u=e[16];let m;return e[17]!==c||e[18]!==u?(m=t.jsx(zi,{children:t.jsx(Gi,{className:c,children:u})}),e[17]=c,e[18]=u,e[19]=m):m=e[19],m}function em(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=ae(_o,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Wi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}function tm(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=ae($o,n),e[3]=n,e[4]=o):o=e[4];let a;return e[5]!==r||e[6]!==o?(a=t.jsx(Vi,{className:o,...r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a}const Ql=280,tr=4,Xl=({transform:s})=>({...s,y:0}),Zl=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:c,setNodeRef:l,transform:f,transition:u,isDragging:m}=Hr(a);let w;e[2]!==f?(w=qr.Transform.toString(f),e[2]=f,e[3]=w):w=e[3];let h;e[4]!==w||e[5]!==u?(h={transform:w,transition:u},e[4]=w,e[5]=u,e[6]=h):h=e[6];const b=m&&"opacity-50";let g;e[7]!==o||e[8]!==b?(g=ae("h-full rounded-md",o,b),e[7]=o,e[8]=b,e[9]=g):g=e[9];let j;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==c||e[14]!==l||e[15]!==h||e[16]!==g?(j=t.jsx("div",{ref:l,"data-sortable-tab-id":n,style:h,className:g,...i,...c,children:r}),e[10]=i,e[11]=r,e[12]=n,e[13]=c,e[14]=l,e[15]=h,e[16]=g,e[17]=j):j=e[17],j},ec=s=>{const e=$e.c(6),{id:n,children:r,className:o}=s;let a;e[0]!==o?(a=ae("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(137),{items:n,activeId:r,onSelect:o,onClose:a,onReorder:i,layoutMode:c,variant:l,activePillInsetClassName:f,activePillButtonClassName:u,inactiveTabsIconOnly:m,animateActivePill:w,activePillLowercase:h,nonCompositedIndicator:b,tabContextMenu:g,className:j}=s,p=c===void 0?"scrollable":c,C=l===void 0?"default":l,L=m===void 0?!1:m,_=h===void 0?!0:h,F=b===void 0?!1:b,{t:T}=st(),x=Ue(tc),{isTablet:S}=gs(),I=x||S,$=d.useRef(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={left:!1,right:!1},e[0]=R):R=e[0];const[z,q]=d.useState(R);let ne;e[1]!==n?(ne=n.map(sc),e[1]=n,e[2]=ne):ne=e[2];const Q=ne,H=p==="scrollable",X=C==="default",ue=C==="active-pill",P=ue||C==="animated",W=X,U=P||W,D=ue&&H,Y=P,M=w??P,K=typeof i=="function",A=K?Zl:ec;let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z=new Map,e[3]=Z):Z=e[3];const ee=d.useRef(Z),[te,fe]=d.useState(null),[ce,me]=d.useState(!1),[re,he]=d.useState(null),ge=d.useRef(!1),v=d.useRef(0),J=d.useRef(r),B=d.useRef(null);let oe;e:{if(!U||!re||!r||re===r){oe=0;break e}const k=n.findIndex(se=>se.id===re),O=n.findIndex(se=>se.id===r);if(k<0||O<0){oe=0;break e}oe=k>O?tr:-tr}const de=oe;let pe;e[4]===Symbol.for("react.memo_cache_sentinel")?(pe={activationConstraint:{distance:8}},e[4]=pe):pe=e[4];const Ne=Ur(Wr(Vr,pe)),We=nc;let _e;e[5]===Symbol.for("react.memo_cache_sentinel")?(_e=(k,O)=>{if(O){ee.current.set(k,O);return}ee.current.delete(k)},e[5]=_e):_e=e[5];const be=_e;let De;e[6]!==r||e[7]!==U?(De=()=>{if(!U||!r){fe(rc);return}const k=$.current,O=ee.current.get(r);if(!k||!O){fe(oc);return}let se=0,Ce=0,Ae=O;for(;Ae&&Ae!==k;)se=se+Ae.offsetLeft,Ce=Ce+Ae.offsetTop,Ae=Ae.offsetParent;const Te={left:se,top:Ce,width:O.offsetWidth,height:O.offsetHeight};fe(it=>We(it,Te)?it:Te)},e[6]=r,e[7]=U,e[8]=De):De=e[8];const Ie=De;let Be;e[9]!==H?(Be=()=>{if(!H){q({left:!1,right:!1});return}const k=$.current;if(!k){q({left:!1,right:!1});return}q({left:k.scrollLeft>2,right:k.scrollLeft+k.clientWidth<k.scrollWidth-2})},e[9]=H,e[10]=Be):Be=e[10];const Fe=Be;let He;e[11]!==H||e[12]!==Fe?(He=()=>{if(!H){q({left:!1,right:!1});return}const k=$.current;if(!k)return;Fe(),k.addEventListener("scroll",Fe,{passive:!0});const O=new ResizeObserver(Fe);return O.observe(k),()=>{k.removeEventListener("scroll",Fe),O.disconnect()}},e[11]=H,e[12]=Fe,e[13]=He):He=e[13];let Ke;e[14]!==H||e[15]!==n.length||e[16]!==Fe?(Ke=[H,n.length,Fe],e[14]=H,e[15]=n.length,e[16]=Fe,e[17]=Ke):Ke=e[17],d.useEffect(He,Ke);let nt;e[18]!==r||e[19]!==Ie||e[20]!==U?(nt=()=>{if(!U){fe(null);return}Ie();const k=$.current;if(!k)return;const O=new ResizeObserver(()=>{performance.now()-v.current>Ql&&me(!1),Ie()});if(O.observe(k),r){const se=ee.current.get(r);se&&O.observe(se)}return()=>{O.disconnect()}},e[18]=r,e[19]=Ie,e[20]=U,e[21]=nt):nt=e[21];let Ze;e[22]!==r||e[23]!==n.length||e[24]!==Ie||e[25]!==U?(Ze=[r,n.length,Ie,U],e[22]=r,e[23]=n.length,e[24]=Ie,e[25]=U,e[26]=Ze):Ze=e[26],d.useEffect(nt,Ze);let rt;e[27]!==Ie?(rt=()=>{Ie()},e[27]=Ie,e[28]=rt):rt=e[28],d.useLayoutEffect(rt);let Je;e[29]!==Q?(Je=Q.join("\0"),e[29]=Q,e[30]=Je):Je=e[30];const Ve=Je;let Ye,ze;e[31]!==r||e[32]!==Ve||e[33]!==U?(Ye=()=>{if(!U){ge.current=!1,me(!1);return}const k=B.current!==Ve;if(B.current=Ve,!ge.current){ge.current=!0,J.current=r;return}const O=J.current!==r;if(J.current=r,!O||k){me(!1);return}v.current=performance.now(),me(!0)},ze=[r,Ve,U],e[31]=r,e[32]=Ve,e[33]=U,e[34]=Ye,e[35]=ze):(Ye=e[34],ze=e[35]),d.useLayoutEffect(Ye,ze);let xe;e[36]!==r||e[37]!==H||e[38]!==Fe?(xe=()=>{if(!H||!r)return;const k=$.current;if(!k)return;const O=window.requestAnimationFrame(()=>{const se=typeof window.CSS?.escape=="function"?window.CSS.escape(r):r.replace(/"/g,'\\"'),Ce=k.querySelector(`[data-sortable-tab-id="${se}"]`);Ce&&(Ce.scrollIntoView({block:"nearest",inline:"nearest"}),Fe())});return()=>{window.cancelAnimationFrame(O)}},e[36]=r,e[37]=H,e[38]=Fe,e[39]=xe):xe=e[39];let et;e[40]!==r||e[41]!==H||e[42]!==n.length||e[43]!==Fe?(et=[r,H,n.length,Fe],e[40]=r,e[41]=H,e[42]=n.length,e[43]=Fe,e[44]=et):et=e[44],d.useEffect(xe,et);let Me;e[45]!==i?(Me=k=>{if(!i)return;const{active:O,over:se}=k;!se||O.id===se.id||i(String(O.id),String(se.id))},e[45]=i,e[46]=Me):Me=e[46];const ke=Me;let Qe;e[47]!==j?(Qe=ae("relative flex h-full min-w-0 flex-1",j),e[47]=j,e[48]=Qe):Qe=e[48];let Ee;e[49]!==H||e[50]!==z||e[51]!==P?(Ee=H&&z.left?t.jsx("div",{className:ae("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[49]=H,e[50]=z,e[51]=P,e[52]=Ee):Ee=e[52];let qe;e[53]!==H||e[54]!==z||e[55]!==P?(qe=H&&z.right?t.jsx("div",{className:ae("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",P?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e[53]=H,e[54]=z,e[55]=P,e[56]=qe):qe=e[56];const pt=P?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",ft=P&&"@container/pill-tabs",gt=P&&"pill-tabs__track",Ct=P&&(f??"gap-0.5 py-0.5"),y=W&&"items-center overflow-y-hidden",G=Y&&"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",Re=H?"overflow-x-auto scrollbar-none":"overflow-x-hidden";let Le;e[57]!==pt||e[58]!==ft||e[59]!==gt||e[60]!==Ct||e[61]!==y||e[62]!==G||e[63]!==Re?(Le=ae("relative flex h-full min-w-0 flex-1",pt,ft,gt,Ct,y,G,Re),e[57]=pt,e[58]=ft,e[59]=gt,e[60]=Ct,e[61]=y,e[62]=G,e[63]=Re,e[64]=Le):Le=e[64];let N;e[65]!==H?(N=H?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,e[65]=H,e[66]=N):N=e[66];let ie;e[67]!==T?(ie=T("sortableTabsStrip.aria.tabs"),e[67]=T,e[68]=ie):ie=e[68];let ye;e[69]!==F||e[70]!==de||e[71]!==te||e[72]!==ce||e[73]!==M||e[74]!==P?(ye=P&&te?t.jsx("div",{className:ae("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)]",M&&ce&&(F?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:F?{left:`${te.left+de}px`,top:`${te.top}px`,width:`${te.width}px`,height:`${te.height}px`}:{transform:`translate3d(${te.left+de}px, ${te.top}px, 0)`,width:`${te.width}px`,height:`${te.height}px`}}):null,e[69]=F,e[70]=de,e[71]=te,e[72]=ce,e[73]=M,e[74]=P,e[75]=ye):ye=e[75];let ve;e[76]!==de||e[77]!==te||e[78]!==ce||e[79]!==W?(ve=W&&te?t.jsx("div",{className:ae("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",ce&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${te.left+de}px, 0, 0)`,width:`${te.width}px`},"aria-hidden":!0}):null,e[76]=de,e[77]=te,e[78]=ce,e[79]=W,e[80]=ve):ve=e[80];let Se;if(e[81]!==A||e[82]!==r||e[83]!==u||e[84]!==_||e[85]!==I||e[86]!==L||e[87]!==ue||e[88]!==x||e[89]!==H||e[90]!==Q||e[91]!==n||e[92]!==a||e[93]!==o||e[94]!==g||e[95]!==D||e[96]!==P||e[97]!==U){let k;e[99]!==A||e[100]!==r||e[101]!==u||e[102]!==_||e[103]!==I||e[104]!==L||e[105]!==ue||e[106]!==x||e[107]!==H||e[108]!==Q||e[109]!==a||e[110]!==o||e[111]!==g||e[112]!==D||e[113]!==P||e[114]!==U?(k=(O,se)=>{const Ce=O.id===r,Ae=L&&P&&!Ce&&!!O.icon,Te=!Ae,it=!!O.icon,xt=L&&P&&Ce&&!H&&!D,vt=O.closable!==!1&&!!a,mt=vt&&!!O.icon,yt=H||D?void 0:P?xt?"flex-none basis-auto":x?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",Pt=vt?dt=>{dt.button===1&&(dt.preventDefault(),dt.stopPropagation(),a?.(O.id))}:void 0,jt=vt?ac:void 0,It=!x&&g?g({id:O.id,index:se,isActive:Ce,allIds:Q,close:()=>a?.(O.id)}):null,Ft=t.jsxs("div",{ref:dt=>be(O.id,dt),onAuxClick:Pt,onMouseDown:jt,className:ae("group flex h-full min-w-0 flex-nowrap items-center",H||D?"shrink-0":P?"w-full":"w-full min-w-0",P?"relative z-10 bg-transparent":Ce?"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":Ce,"aria-label":Ae?O.title??O.label:void 0,onClick:()=>o(O.id),onPointerDown:U?()=>{me(!0),he(O.id)}:void 0,onPointerUp:U?()=>he(null):void 0,onPointerLeave:U?()=>he(null):void 0,onPointerCancel:U?()=>he(null):void 0,className:ae(P?"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",P&&_?"lowercase":null,P&&(Ae?"gap-0":"gap-1.5"),P?D?"shrink-0 whitespace-nowrap px-3 text-center":H?"max-w-56 shrink-0 px-3 text-center":Ae?"px-2 !min-w-0 text-center":xt?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":H?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",P?u??(ue?x?"h-[38px]":"h-[31px]":"h-7"):null,P?Ce?"text-foreground":"text-muted-foreground hover:text-foreground":null,P?"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:O.title??O.label,children:P?t.jsxs(t.Fragment,{children:[it?t.jsxs("span",{className:"relative flex h-4 w-4 shrink-0 items-center justify-center",children:[t.jsx("span",{className:ae("flex items-center justify-center transition-opacity",mt&&(I?"opacity-0":"group-hover:opacity-0")),children:O.icon}),mt?t.jsx("span",{role:"button",tabIndex:-1,className:ae("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:ic,onClick:dt=>{dt.stopPropagation(),a?.(O.id)},"aria-label":O.closeLabel??`Close ${O.label} tab`,title:O.closeLabel??`Close ${O.label} tab`,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null,Te?t.jsx("span",{className:"animated-tabs__label truncate",children:O.label}):null]}):t.jsxs("span",{className:ae("flex min-w-0 flex-nowrap items-center gap-1.5",!H&&"justify-center"),children:[it?t.jsxs("span",{className:ae("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",Ce?"text-[var(--primary-base)]":"text-muted-foreground"),children:[t.jsx("span",{className:ae("flex items-center justify-center transition-opacity",mt&&(I?"opacity-0":"group-hover:opacity-0")),children:O.icon}),mt?t.jsx("span",{role:"button",tabIndex:-1,className:ae("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:lc,onClick:dt=>{dt.stopPropagation(),a?.(O.id)},"aria-label":O.closeLabel??`Close ${O.label} tab`,title:O.closeLabel??`Close ${O.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:O.label})]})}),vt&&!mt?t.jsx("button",{type:"button",onPointerDown:cc,onClick:dt=>{dt.stopPropagation(),a?.(O.id)},className:ae("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",P?"-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",P?Ce?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":Ce?"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":O.closeLabel??`Close ${O.label} tab`,title:O.closeLabel??`Close ${O.label} tab`,children:t.jsx(E,{name:"close",className:"h-3 w-3"})}):null]});return t.jsx(A,{id:O.id,className:yt,children:It?t.jsxs(ql,{children:[t.jsx(Jl,{render:dt=>t.jsx("div",{...dt,className:ae("flex h-full min-w-0",dt.className),children:Ft})}),t.jsx(Yl,{className:"w-52",children:It})]}):Ft},O.id)},e[99]=A,e[100]=r,e[101]=u,e[102]=_,e[103]=I,e[104]=L,e[105]=ue,e[106]=x,e[107]=H,e[108]=Q,e[109]=a,e[110]=o,e[111]=g,e[112]=D,e[113]=P,e[114]=U,e[115]=k):k=e[115],Se=n.map(k),e[81]=A,e[82]=r,e[83]=u,e[84]=_,e[85]=I,e[86]=L,e[87]=ue,e[88]=x,e[89]=H,e[90]=Q,e[91]=n,e[92]=a,e[93]=o,e[94]=g,e[95]=D,e[96]=P,e[97]=U,e[98]=Se}else Se=e[98];let Oe;e[116]!==Le||e[117]!==N||e[118]!==ie||e[119]!==ye||e[120]!==ve||e[121]!==Se?(Oe=t.jsxs("div",{ref:$,className:Le,style:N,role:"tablist","aria-label":ie,children:[ye,ve,Se]}),e[116]=Le,e[117]=N,e[118]=ie,e[119]=ye,e[120]=ve,e[121]=Se,e[122]=Oe):Oe=e[122];let Ge;e[123]!==Qe||e[124]!==Ee||e[125]!==qe||e[126]!==Oe?(Ge=t.jsxs("div",{className:Qe,children:[Ee,qe,Oe]}),e[123]=Qe,e[124]=Ee,e[125]=qe,e[126]=Oe,e[127]=Ge):Ge=e[127];const at=Ge;if(!K)return at;let ct;e[128]===Symbol.for("react.memo_cache_sentinel")?(ct=[Xl],e[128]=ct):ct=e[128];let ut;e[129]!==Q||e[130]!==at?(ut=t.jsx(Kr,{items:Q,strategy:Qi,children:at}),e[129]=Q,e[130]=at,e[131]=ut):ut=e[131];let ot;e[132]===Symbol.for("react.memo_cache_sentinel")?(ot=t.jsx(Yi,{dropAnimation:null}),e[132]=ot):ot=e[132];let bt;return e[133]!==ke||e[134]!==Ne||e[135]!==ut?(bt=t.jsxs(zr,{sensors:Ne,collisionDetection:Gr,onDragEnd:ke,modifiers:ct,children:[ut,ot]}),e[133]=ke,e[134]=Ne,e[135]=ut,e[136]=bt):bt=e[136],bt};function tc(s){return s.isMobile}function sc(s){return s.id}function nc(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 rc(s){return s===null?s:null}function oc(s){return s===null?s:null}function ac(s){s.button===1&&s.preventDefault()}function ic(s){s.stopPropagation()}function lc(s){s.stopPropagation()}function cc(s){s.stopPropagation()}const qt=Pn()(Hi(Ki((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 Ho();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 Go();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 zo();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=ji()?.settings;if(o)try{const i=(await o.load())?.settings||{};r=n(i.defaultGitIdentityId)}catch{}}if(r===null)try{const o=await Lt("/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 Fr({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 _t("saving"),await Vo(r),_t("saved"),await e().loadProfiles(),!0}catch(r){return _t("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 _t("saving"),await Wo(n,a),_t("saved"),await e().loadProfiles(),!0}catch(o){return _t("error"),console.error("Failed to update git identity profile:",o),!1}},deleteProfile:async n=>{try{return _t("saving"),await Uo(n),_t("saved"),e().selectedProfileId===n&&s({selectedProfileId:null}),await e().loadProfiles(),!0}catch(r){return _t("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:Si(),partialize:s=>({selectedProfileId:s.selectedProfileId})}),{name:"git-identities-store"}));typeof window<"u"&&(window.__zustand_git_identities_store__=qt);const Vs=Ko,Ut=s=>{const e=$e.c(11),{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:c,children:l,className:f,contentClassName:u,divider:m}=s,w=m===void 0?!0:m;let h;return e[0]!==l||e[1]!==f||e[2]!==u||e[3]!==r||e[4]!==w||e[5]!==c||e[6]!==o||e[7]!==a||e[8]!==n||e[9]!==i?(h=t.jsx(qo,{title:n,description:r,info:o,settingsItem:a,titleAccessory:i,headerAction:c,divider:w,className:f,contentClassName:u,children:l}),e[0]=l,e[1]=f,e[2]=u,e[3]=r,e[4]=w,e[5]=c,e[6]=o,e[7]=a,e[8]=n,e[9]=i,e[10]=h):h=e[10],h},dc=450,uc=({projectRef:s=null,sections:e="all"})=>{const{t:n}=st(),{isMobile:r,isTablet:o}=gs(),a=r||o,i=Tt(D=>D.getActiveProject()),c=s?.path??i?.path??null,l=tt(D=>D.getWorktreeMetadata),f=Jo(),u=xs(D=>D.homeDirectory),[m,w]=d.useState([]),[h,b]=d.useState(!1),[g,j]=d.useState(!1),[p,C]=d.useState(null),[L,_]=d.useState(null),[F,T]=d.useState([]),[x,S]=d.useState(!1),I=d.useRef(!1),$=d.useMemo(()=>s?.id&&s?.path?{id:s.id,path:s.path}:!i?.id||!c?null:{id:i.id,path:c},[i?.id,c,s?.id,s?.path]),R=d.useCallback(async()=>{if(!(!$||L===!1))try{const D=await Ln($);T(D)}catch{}},[$,L]);d.useEffect(()=>{if(!c)return;let D=!1;return _(null),(async()=>{try{const Y=await Yo(c);if(D)return;_(Y)}catch{}})(),()=>{D=!0}},[c]),d.useEffect(()=>{if(!$){T([]),S(!1);return}if(L===!1){T([]),S(!1);return}let D=!1;return S(!0),T([]),(async()=>{try{const Y=await Ln($);if(D)return;T(Y)}catch{}finally{D||S(!1)}})(),()=>{D=!0}},[$,L]),d.useEffect(()=>{if(!$)return;let D=!1;return j(!0),(async()=>{try{const[Y,M]=await Promise.all([jr($),Nr($)]);if(!D){const K=Y.length>0?Y:[""];w(K),C(JSON.stringify(K)),b(M)}}catch{D||(w([""]),C(JSON.stringify([""])),b(!1))}finally{D||j(!1)}})(),()=>{D=!0}},[$]);const z=d.useCallback(async D=>{if(!$)return!1;const Y=D.filter(M=>M.trim().length>0);try{return await Qo($,Y)?(C(JSON.stringify(D)),!0):(je.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1)}catch{return je.error(n("settings.aiworker.worktrees.setup.toast.saveFailed")),!1}},[$,n]),q=d.useMemo(()=>p===null?!1:p!==JSON.stringify(m),[p,m]);d.useEffect(()=>{if(!q||g||I.current)return;const D=window.setTimeout(()=>{I.current||(I.current=!0,(async()=>{try{await z(m)}finally{I.current=!1}})())},dc);return()=>{window.clearTimeout(D)}},[q,g,z,m]);const ne=d.useCallback((D,Y)=>{w(M=>{const K=[...M];return K[D]=Y,K})},[]),Q=d.useCallback(()=>{w(D=>[...D,""])},[]),H=d.useCallback(D=>{w(Y=>{const M=Y.filter((K,A)=>A!==D);return M.length>0?M:[""]})},[]),X=d.useCallback(()=>{!q||I.current||(I.current=!0,(async()=>{try{await z(m)}finally{I.current=!1}})())},[q,z,m]),ue=d.useCallback(D=>{b(D),$&&Xo($,D)},[$]),V=d.useCallback(D=>{const Y=me=>me.replace(/\\/g,"/").replace(/\/+$/,""),M=Y(D.path),K=f.filter(me=>{const re=l(me.id);if(re?.path&&Y(re.path)===M)return!0;const he=me.directory;return!!(he&&Y(he)===M)}),A=new Set(K.map(me=>me.id)),Z=[...Jt.getState().activeSessions,...Jt.getState().archivedSessions],ee=me=>{const re=Z.filter(ge=>{const v=ge.parentID;return v&&me.has(v)});if(re.length===0)return[];const he=new Set(re.map(ge=>ge.id));return[...re,...ee(he)]},te=ee(A),fe=new Set,ce=[...K,...te].filter(me=>fe.has(me.id)?!1:(fe.add(me.id),!0));Zo.requestDelete({sessions:ce,mode:"worktree",worktree:D})},[f,l]),P=d.useMemo(()=>f.map(D=>D.id).join(","),[f]);d.useEffect(()=>{L&&c&&R()},[P,L,c,R]);const W=t.jsxs(Os,{children:[n("settings.aiworker.worktrees.setup.tooltipPrefix")," ",t.jsx("code",{className:"font-mono text-xs bg-sidebar-accent/50 px-1 rounded",children:"$ROOT_PROJECT_PATH"})," ",n("settings.aiworker.worktrees.setup.tooltipSuffix")]}),U=t.jsx(Os,{children:n("settings.aiworker.worktrees.list.tooltip")});return c?L===!1?t.jsx(Ut,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.gitOnly")})}):t.jsxs(t.Fragment,{children:[e==="all"?t.jsx(Ut,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",titleAccessory:W,children:g?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.setup.loading")}):t.jsxs("div",{className:ae("space-y-2",Vs),children:[m.map((D,Y)=>t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(St,{value:D,onChange:M=>ne(Y,M.target.value),onBlur:X,placeholder:n("settings.aiworker.worktrees.setup.commandPlaceholder"),className:"h-7 min-w-0 flex-1 font-mono text-xs"}),t.jsx(Pe,{type:"button",variant:"ghost",size:"icon",onClick:()=>H(Y),className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":n("settings.aiworker.worktrees.setup.removeCommandAria"),children:t.jsx(E,{name:"close",className:"h-4 w-4"})})]},Y)),t.jsxs(Pe,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:Q,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),n("settings.aiworker.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(Ds,{checked:h,onChange:ue,ariaLabel:n("settings.aiworker.worktrees.setup.waitForCommandsAria")}),t.jsx("span",{className:ae("typography-ui-label font-normal",h?"text-foreground":"text-foreground/60"),children:n("settings.aiworker.worktrees.setup.waitForCommands")})]})]})}):null,t.jsx(Ut,{title:n("settings.aiworker.worktrees.list.title"),titleAccessory:U,children:x?t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.list.loading")}):F.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground/70",children:n("settings.aiworker.worktrees.list.empty")}):t.jsx("div",{className:ae("space-y-1",e==="all"&&Vs),children:F.map(D=>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:D.label||D.branch||n("settings.aiworker.worktrees.list.detachedHead")})}),t.jsx("p",{className:"typography-micro truncate text-muted-foreground/60",children:ea(D.path,u)})]}),t.jsx("button",{type:"button",onClick:()=>V(D),className:ae("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.aiworker.worktrees.list.deleteWorktreeAria",{name:D.branch||D.label||D.path}),children:t.jsx(E,{name:"delete-bin",className:"h-4 w-4"})})]},D.path))})})]}):t.jsx(Ut,{title:n("settings.projects.page.section.worktree"),settingsItem:"projects.worktree",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.aiworker.worktrees.state.selectProject")})})},sr=(s,e)=>e.updatedAtMs-s.updatedAtMs,nr=Pn((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([ra(),On()]),o={};for(const a of r.sort(sr))o[a.id]=a;e().listenerReady||await oa(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 na();s({importCandidates:n,isImportsLoading:!1})}catch(n){s({isImportsLoading:!1,error:n instanceof Error?n.message:String(n)})}}},refreshStatuses:async()=>{try{const n=await On(),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 sa({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=aa(n,r);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async n=>{await Fn(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 ta(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 Fn(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})})),Dn=[{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"}],fc=Object.fromEntries(Dn.map(s=>[s.key,s.Icon])),mc="aiworker:project-actions-updated",hc=s=>{const e=(s||"").trim().replace(/\\/g,"/");return e?e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e:""},sm=(s,e)=>`${hc(s)}::${e}`,pc=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},gc=(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=pc(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}`}},Xr=s=>{const e=[];for(const n of s)if(!(!n?.id||!Array.isArray(n.portForwards)))for(const r of n.portForwards){const o=gc(n,r);o&&e.push(o)}return e},nm=(s,e)=>{const n=(s||"").trim();return n&&Xr(e).find(a=>a.id===n)?.url||null},xc=450,en="__project__",bc=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,yc=()=>({id:bc(),name:"",command:"",icon:"play"}),wc=({projectRef:s})=>{const{t:e}=st(),n=d.useMemo(()=>Or(),[]),r=nr(T=>T.instances),o=nr(T=>T.load),[a,i]=d.useState([]),[c,l]=d.useState(!1),[f,u]=d.useState(null),[m,w]=d.useState({}),h=d.useRef(!1),b=d.useRef(null);d.useEffect(()=>{n&&o().catch(()=>{})},[n,o]),d.useEffect(()=>{let T=!1;return l(!0),(async()=>{try{const x=await ia(s);if(T)return;i(x.actions),u(JSON.stringify({actions:x.actions}))}catch{if(T)return;i([]),u(JSON.stringify({actions:[]}))}finally{T||l(!1)}})(),()=>{T=!0}},[s]);const g=d.useMemo(()=>n?Xr(r):[],[r,n]),j=d.useMemo(()=>a.some(x=>x.name.trim().length===0||x.command.trim().length===0)?e("settings.projects.actions.validation.fillNameAndCommand"):null,[a,e]),p=d.useMemo(()=>f===null?!1:f!==JSON.stringify({actions:a}),[a,f]),C=d.useCallback(async T=>await la(s,{actions:T,primaryActionId:null})?(u(JSON.stringify({actions:T})),typeof window<"u"&&window.dispatchEvent(new CustomEvent(mc,{detail:{projectId:s.id}})),!0):(je.error(e("settings.projects.actions.toast.saveFailed")),!1),[s,e]);d.useEffect(()=>{if(!p||c||j||h.current)return;const T=window.setTimeout(()=>{h.current||(h.current=!0,(async()=>{try{await C(a)}finally{h.current=!1}})())},xc);return()=>{window.clearTimeout(T)}},[a,p,c,C,j]),d.useEffect(()=>{if(!p||!j||c){j||(b.current=null);return}const T=window.setTimeout(()=>{b.current!==j&&(b.current=j,je.error(j))},1e3);return()=>{window.clearTimeout(T)}},[p,c,j]);const L=d.useCallback(()=>{const T=yc();i(x=>[...x,T]),w(x=>({...x,[T.id]:!0}))},[]),_=d.useCallback(T=>{i(x=>x.filter(S=>S.id!==T)),w(x=>{const S={...x};return delete S[T],S})},[]),F=d.useCallback((T,x)=>{i(S=>S.map(I=>I.id===T?x(I):I))},[]);return t.jsxs(Ut,{title:e("settings.projects.actions.title"),info:e("settings.projects.actions.description"),settingsItem:"projects.actions",headerAction:t.jsxs(Pe,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:L,children:[t.jsx(E,{name:"add",className:"h-3.5 w-3.5"}),e("settings.projects.actions.actions.add")]}),contentClassName:"space-y-0",children:[c?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:ae("space-y-0",Vs),children:a.map(T=>{const x=T.icon||"play",S=fc[x]||"play",I=m[T.id]??!1,$=T.name.trim()||e("settings.projects.actions.state.untitled");return t.jsxs(Al,{open:I,onOpenChange:R=>{w(z=>({...z,[T.id]:R}))},className:"py-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs(Bl,{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:[I?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:S,className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:$})})]}),t.jsx(Pe,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>_(T.id),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),t.jsx(Ml,{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(Gt,{children:[t.jsx(Ht,{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:S,className:"h-4 w-4"})})}),t.jsx(Kt,{align:"start",className:"w-56 p-2",children:t.jsx("div",{className:"grid grid-cols-6 gap-1",children:Dn.map(R=>{const z=R.Icon,q=(T.icon||"play")===R.key;return t.jsx("button",{type:"button",onClick:()=>F(T.id,ne=>({...ne,icon:R.key})),className:ae("inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]",q&&"border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]"),"aria-label":e("settings.projects.actions.field.iconAria",{icon:R.label}),children:t.jsx(E,{name:z,className:"h-4 w-4"})},R.key)})})})]}),t.jsx(St,{value:T.name,onChange:R=>F(T.id,z=>({...z,name:R.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(Hs,{value:T.command,onChange:R=>F(T.id,z=>({...z,command:R.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:"mb-0.5 flex items-center gap-2",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.runIn.label")}),t.jsx(Os,{contentClassName:"max-w-xs",children:e("settings.projects.actions.runIn.info")})]}),t.jsxs(_s,{value:T.runIn==="parent"?en:"worktree",onValueChange:R=>{F(T.id,z=>R===en?{...z,runIn:"parent"}:{...z,runIn:void 0})},children:[t.jsx($s,{size:un,className:ca,"aria-label":e("settings.projects.actions.runIn.aria"),children:t.jsx(fn,{children:R=>e(R==="worktree"?"settings.projects.actions.runIn.worktree":"settings.projects.actions.runIn.project")})}),t.jsxs(Us,{children:[t.jsx(Yt,{value:en,children:e("settings.projects.actions.runIn.project")}),t.jsx(Yt,{value:"worktree",children:e("settings.projects.actions.runIn.worktree")})]})]})]}),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":T.autoOpenUrl===!0,onClick:()=>F(T.id,R=>({...R,...R.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:R=>{(R.key===" "||R.key==="Enter")&&(R.preventDefault(),F(T.id,z=>({...z,...z.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[t.jsx(Ds,{checked:T.autoOpenUrl===!0,onChange:R=>F(T.id,z=>({...z,...R?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:e("settings.projects.actions.field.autoOpenUrlForAria",{title:$})}),t.jsx("span",{className:"typography-ui-label font-normal text-foreground/80",children:e("settings.projects.actions.field.autoOpenUrlDescription")})]})]}),T.autoOpenUrl===!0?t.jsxs("div",{className:"mt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(St,{value:T.openUrl||"",onChange:R=>F(T.id,z=>({...z,openUrl:R.target.value})),placeholder:e("settings.projects.actions.field.overrideUrlPlaceholder"),className:"h-7 w-full max-w-[24rem]"}),t.jsx(Os,{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")}),g.length>0?t.jsxs(_s,{value:T.desktopOpenSshForward&&g.some(R=>R.id===T.desktopOpenSshForward)?T.desktopOpenSshForward:"__none__",onValueChange:R=>{F(T.id,z=>({...z,...R==="__none__"?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:R}}))},children:[t.jsx($s,{size:un,className:"w-full",children:t.jsx(fn,{placeholder:e("settings.projects.actions.field.useOutputManualUrl")})}),t.jsxs(Us,{children:[t.jsx(Yt,{value:"__none__",children:e("settings.projects.actions.field.useOutputManualUrl")}),g.map(R=>t.jsx(Yt,{value:R.id,children:R.label},R.id))]})]}):t.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.projects.actions.state.noDesktopSshForwards")})]}):null]}):null]})]})})]},T.id)})}),j&&a.length>0?t.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:j}):null]})},tn="__default__",Zr=s=>s.charAt(0).toUpperCase()+s.slice(1),vc=s=>{const e=$e.c(138),{form:n}=s,{t:r}=st(),{currentTheme:o}=kr(),a=kt(Sc),{name:i,setName:c,icon:l,setIcon:f,color:u,setColor:m,iconBackground:w,setIconBackground:h,parsedDefaultModel:b,defaultVariant:g,handleDefaultModelChange:j,handleDefaultVariantChange:p,isUploadingIcon:C,isRemovingCustomIcon:L,isDiscoveringIcon:_,pendingRemoveImageIcon:F,setPendingRemoveImageIcon:T,pendingUploadIconPreviewUrl:x,setPreviewImageFailed:S,hasPendingUploadImageIcon:I,hasCustomIcon:$,effectiveHasImageIcon:R,hasRemovableImageIcon:z,showImagePreview:q,fileInputRef:ne,handleUploadIcon:Q,handleRemoveImageIcon:H,handleDiscoverIcon:X,currentIconImage:ue,project:V}=n;let P;e:{const{providerId:Ee,modelId:qe}=b;if(!Ee||!qe){let ft;e[0]===Symbol.for("react.memo_cache_sentinel")?(ft=[],e[0]=ft):ft=e[0],P=ft;break e}let pt;if(e[1]!==qe||e[2]!==Ee||e[3]!==a){const ft=a.find(gt=>gt.id===Ee)?.models.find(gt=>gt.id===qe);pt=da(ft),e[1]=qe,e[2]=Ee,e[3]=a,e[4]=pt}else pt=e[4];P=pt}const W=P;if(!V)return null;const U=u?ua[u]??null:null;let D;e[5]!==r?(D=r("settings.projects.page.field.projectName"),e[5]=r,e[6]=D):D=e[6];let Y;e[7]!==c?(Y=Ee=>c(Ee.target.value),e[7]=c,e[8]=Y):Y=e[8];let M;e[9]!==r?(M=r("settings.projects.page.field.projectNamePlaceholder"),e[9]=r,e[10]=M):M=e[10];let K;e[11]===Symbol.for("react.memo_cache_sentinel")?(K=ae("h-8 rounded-md px-3",Vs),e[11]=K):K=e[11];let A;e[12]!==i||e[13]!==Y||e[14]!==M?(A=t.jsx(St,{value:i,onChange:Y,placeholder:M,className:K}),e[12]=i,e[13]=Y,e[14]=M,e[15]=A):A=e[15];let Z;e[16]!==D||e[17]!==A?(Z=t.jsx(Ut,{title:D,settingsItem:"projects.name",divider:!1,children:A}),e[16]=D,e[17]=A,e[18]=Z):Z=e[18];let ee;e[19]!==r?(ee=r("settings.projects.page.section.chatDefaults"),e[19]=r,e[20]=ee):ee=e[20];let te;e[21]!==r?(te=r("settings.projects.page.section.chatDefaultsDescription"),e[21]=r,e[22]=te):te=e[22];let fe;e[23]!==r?(fe=r("settings.projects.page.field.projectModel"),e[23]=r,e[24]=fe):fe=e[24];let ce;e[25]!==j||e[26]!==b.modelId||e[27]!==b.providerId?(ce=t.jsx(Sr,{providerId:b.providerId,modelId:b.modelId,onChange:j,className:fa}),e[25]=j,e[26]=b.modelId,e[27]=b.providerId,e[28]=ce):ce=e[28];let me;e[29]!==fe||e[30]!==ce?(me=t.jsx(_n,{settingsItem:"projects.default-model",label:fe,children:ce}),e[29]=fe,e[30]=ce,e[31]=me):me=e[31];let re;e[32]!==W||e[33]!==g||e[34]!==p||e[35]!==r?(re=W.length>0?t.jsx(_n,{settingsItem:"projects.default-thinking",label:r("settings.projects.page.field.projectThinking"),children:t.jsxs(_s,{value:g??tn,onValueChange:Ee=>p(Ee===tn?void 0:Ee),children:[t.jsx($s,{size:un,className:ma,"aria-label":r("settings.projects.page.field.projectThinking"),children:t.jsx(fn,{children:g?Zr(g):r("settings.projects.page.option.thinkingDefault")})}),t.jsxs(Us,{children:[t.jsx(Yt,{value:tn,children:r("settings.projects.page.option.thinkingDefault")}),W.map(jc)]})]})}):null,e[32]=W,e[33]=g,e[34]=p,e[35]=r,e[36]=re):re=e[36];let he;e[37]!==me||e[38]!==re||e[39]!==ee||e[40]!==te?(he=t.jsxs(Ut,{title:ee,info:te,contentClassName:"space-y-0",children:[me,re]}),e[37]=me,e[38]=re,e[39]=ee,e[40]=te,e[41]=he):he=e[41];let ge;e[42]!==r?(ge=r("settings.projects.page.field.accentColor"),e[42]=r,e[43]=ge):ge=e[43];let v;e[44]!==m?(v=()=>m(null),e[44]=m,e[45]=v):v=e[45];const J=u===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let B;e[46]!==J?(B=ae("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",J),e[46]=J,e[47]=B):B=e[47];let oe;e[48]!==r?(oe=r("settings.projects.page.field.none"),e[48]=r,e[49]=oe):oe=e[49];let de;e[50]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[50]=de):de=e[50];let pe;e[51]!==v||e[52]!==B||e[53]!==oe?(pe=t.jsx("button",{type:"button",onClick:v,className:B,title:oe,children:de}),e[51]=v,e[52]=B,e[53]=oe,e[54]=pe):pe=e[54];let Ne;e[55]!==u||e[56]!==m?(Ne=ha.map(Ee=>t.jsx("button",{type:"button",onClick:()=>m(Ee.key),className:ae("h-7 w-7 rounded-md border transition-colors",u===Ee.key?"border-2 border-foreground ring-1 ring-[var(--primary-base)]/40":"border-transparent hover:border-border/70"),style:{backgroundColor:Ee.cssVar},title:Ee.label},Ee.key)),e[55]=u,e[56]=m,e[57]=Ne):Ne=e[57];let We;e[58]!==pe||e[59]!==Ne?(We=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[pe,Ne]}),e[58]=pe,e[59]=Ne,e[60]=We):We=e[60];let _e;e[61]!==ge||e[62]!==We?(_e=t.jsx(Ut,{title:ge,settingsItem:"projects.accent-color",children:We}),e[61]=ge,e[62]=We,e[63]=_e):_e=e[63];let be;e[64]!==r?(be=r("settings.projects.page.field.projectIcon"),e[64]=r,e[65]=be):be=e[65];let De;e[66]!==Q?(De=Ee=>{const qe=Ee.target.files?.[0]??null;Q(qe),Ee.currentTarget.value=""},e[66]=Q,e[67]=De):De=e[67];let Ie;e[68]!==ne||e[69]!==De?(Ie=t.jsx("input",{ref:ne,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:De}),e[68]=ne,e[69]=De,e[70]=Ie):Ie=e[70];let Be;e[71]!==f?(Be=()=>f(null),e[71]=f,e[72]=Be):Be=e[72];const Fe=l===null?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-border/40 hover:border-border hover:bg-[var(--surface-muted)]";let He;e[73]!==Fe?(He=ae("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",Fe),e[73]=Fe,e[74]=He):He=e[74];let Ke;e[75]!==r?(Ke=r("settings.projects.page.field.none"),e[75]=r,e[76]=Ke):Ke=e[76];let nt;e[77]===Symbol.for("react.memo_cache_sentinel")?(nt=t.jsx(E,{name:"close",className:"h-4 w-4 text-muted-foreground"}),e[77]=nt):nt=e[77];let Ze;e[78]!==Be||e[79]!==He||e[80]!==Ke?(Ze=t.jsx("button",{type:"button",onClick:Be,className:He,title:Ke,children:nt}),e[78]=Be,e[79]=He,e[80]=Ke,e[81]=Ze):Ze=e[81];let rt;e[82]!==U||e[83]!==l||e[84]!==f?(rt=pa.map(Ee=>{const qe=Ee.Icon;return t.jsx("button",{type:"button",onClick:()=>f(Ee.key),className:ae("h-7 w-7 rounded-md border transition-colors flex items-center justify-center",l===Ee.key?"border-2 border-foreground bg-[var(--primary-base)]/10":"border-transparent hover:border-border hover:bg-[var(--surface-muted)]"),title:Ee.label,children:t.jsx(E,{name:qe,className:"w-4 h-4",style:U&&l===Ee.key?{color:U}:void 0})},Ee.key)}),e[82]=U,e[83]=l,e[84]=f,e[85]=rt):rt=e[85];let Je;e[86]!==Ze||e[87]!==rt?(Je=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Ze,rt]}),e[86]=Ze,e[87]=rt,e[88]=Je):Je=e[88];let Ve;e[89]!==ue||e[90]!==o||e[91]!==R||e[92]!==I||e[93]!==w||e[94]!==x||e[95]!==V||e[96]!==S||e[97]!==q||e[98]!==r?(Ve=R&&q&&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:w?{backgroundColor:w}:void 0,children:I&&x?t.jsx("img",{src:x,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>S(!0)}):t.jsx(ga,{project:{...V,iconImage:ue??V.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>S(!0)})})})]}),e[89]=ue,e[90]=o,e[91]=R,e[92]=I,e[93]=w,e[94]=x,e[95]=V,e[96]=S,e[97]=q,e[98]=r,e[99]=Ve):Ve=e[99];let Ye;e[100]!==R||e[101]!==w||e[102]!==h||e[103]!==r?(Ye=R&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"color",value:w??"#000000",onChange:Ee=>h(Ee.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(St,{value:w??"",onChange:Ee=>h(Ee.target.value),placeholder:"#000000",className:"h-7 w-[8rem]"}),t.jsx(Pe,{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:!w,children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})})]}),e[100]=R,e[101]=w,e[102]=h,e[103]=r,e[104]=Ye):Ye=e[104];let ze;e[105]!==ne||e[106]!==X||e[107]!==$||e[108]!==_||e[109]!==C||e[110]!==r?(ze=!$&&t.jsxs(t.Fragment,{children:[t.jsx(Pe,{size:"xs",className:"h-6 !font-normal",onClick:()=>ne.current?.click(),disabled:C,children:r(C?"settings.projects.page.actions.uploading":"settings.projects.page.actions.uploadIcon")}),t.jsx(Pe,{size:"xs",className:"h-6 !font-normal",variant:"outline",onClick:()=>{X()},disabled:_,children:r(_?"settings.projects.page.actions.discovering":"settings.projects.page.actions.discoverFavicon")})]}),e[105]=ne,e[106]=X,e[107]=$,e[108]=_,e[109]=C,e[110]=r,e[111]=ze):ze=e[111];let xe;e[112]!==H||e[113]!==z||e[114]!==L||e[115]!==r?(xe=z&&t.jsx(Pe,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>{H()},disabled:L,children:r(L?"settings.projects.page.actions.removing":"settings.projects.page.actions.removeProjectIcon")}),e[112]=H,e[113]=z,e[114]=L,e[115]=r,e[116]=xe):xe=e[116];let et;e[117]!==L||e[118]!==F||e[119]!==T||e[120]!==r?(et=F&&t.jsx(Pe,{size:"xs",className:"!font-normal",variant:"outline",onClick:()=>T(!1),disabled:L,children:r("settings.projects.page.actions.undoRemove")}),e[117]=L,e[118]=F,e[119]=T,e[120]=r,e[121]=et):et=e[121];let Me;e[122]!==ze||e[123]!==xe||e[124]!==et?(Me=t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ze,xe,et]}),e[122]=ze,e[123]=xe,e[124]=et,e[125]=Me):Me=e[125];let ke;e[126]!==be||e[127]!==Ie||e[128]!==Je||e[129]!==Ve||e[130]!==Ye||e[131]!==Me?(ke=t.jsxs(Ut,{title:be,settingsItem:"projects.icon",contentClassName:"space-y-3",children:[Ie,Je,Ve,Ye,Me]}),e[126]=be,e[127]=Ie,e[128]=Je,e[129]=Ve,e[130]=Ye,e[131]=Me,e[132]=ke):ke=e[132];let Qe;return e[133]!==he||e[134]!==_e||e[135]!==ke||e[136]!==Z?(Qe=t.jsxs(t.Fragment,{children:[Z,he,_e,ke]}),e[133]=he,e[134]=_e,e[135]=ke,e[136]=Z,e[137]=Qe):Qe=e[137],Qe};function Sc(s){return s.providers}function jc(s){return t.jsx(Yt,{value:s,children:Zr(s)},s)}const Nc=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,kc=s=>{if(!s)return null;const e=s.trim();return e&&Nc.test(e)?e.toLowerCase():null},Cc=s=>{const{t:e}=st(),n=Tt(re=>re.uploadProjectIcon),r=Tt(re=>re.removeProjectIcon),o=Tt(re=>re.discoverProjectIcon),a=Tt(re=>s?re.projects.find(he=>he.id===s.id)?.iconImage??null:null),[i,c]=d.useState(""),[l,f]=d.useState(null),[u,m]=d.useState(null),[w,h]=d.useState(null),[b,g]=d.useState(void 0),[j,p]=d.useState(void 0),[C,L]=d.useState(!1),[_,F]=d.useState(!1),[T,x]=d.useState(!1),[S,I]=d.useState(!1),[$,R]=d.useState(null),[z,q]=d.useState(null),[ne,Q]=d.useState(!1),H=d.useRef(null),X=d.useCallback(()=>{R(null),q(re=>(re&&URL.revokeObjectURL(re),null))},[]),ue=s?.id??null;d.useEffect(()=>{if(!s){c(""),f(null),m(null),h(null),g(void 0),p(void 0);return}c(s.label??""),f(s.icon??null),m(s.color??null),h(s.iconBackground??null),g(s.defaultModel),p(s.defaultVariant),I(!1),X(),Q(!1)},[s,X]),d.useEffect(()=>()=>{X()},[X]);const V=d.useMemo(()=>Cr(b)??{providerId:"",modelId:""},[b]),P=!!s?.iconImage,W=!!($&&z),U=s?.iconImage?.source==="custom",D=P&&!S||W,Y=D,M=!!(s&&P&&!S),K=!ne&&(W||M),A=!!s&&(i.trim()!==(s?.label??"").trim()||l!==(s?.icon??null)||u!==(s?.color??null)||w!==(s?.iconBackground??null)||(b??void 0)!==(s?.defaultModel??void 0)||(j??void 0)!==(s?.defaultVariant??void 0)||S||!!$),Z=d.useCallback((re,he)=>{g(re&&he?`${re}/${he}`:void 0),p(void 0)},[]),ee=d.useCallback(re=>{p(re)},[]),te=d.useCallback(re=>{!s||!re||C||(I(!1),Q(!1),R(re),q(he=>(he&&URL.revokeObjectURL(he),URL.createObjectURL(re))))},[C,s]),fe=d.useCallback(()=>{!s||!Y||_||(W&&X(),I(!!P),Q(!1))},[X,W,Y,P,_,s]),ce=d.useCallback(async()=>{if(!(!s||T)){X(),I(!1),Q(!1),x(!0);try{const re=await o(s.id);if(!re.ok){je.error(re.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(re.skipped){je.success(e("settings.projects.page.toast.customIconAlreadySet"));return}je.success(e("settings.projects.page.toast.iconDiscovered"))}finally{x(!1)}}},[X,o,T,s,e]),me=d.useCallback(async re=>{const he=re?.silent===!0;if(!s)return null;const ge=i.trim();if(!ge)return null;if($){L(!0);const J=await n(s.id,$);if(L(!1),!J.ok)return je.error(J.error||e("settings.projects.page.toast.uploadIconFailed")),null;he||je.success(e("settings.projects.page.toast.iconUpdated")),X(),I(!1)}const v=S&&!!s.iconImage;if(v){F(!0);const J=await r(s.id);if(F(!1),!J.ok)return je.error(J.error||e("settings.projects.page.toast.removeIconFailed")),null;he||je.success(e("settings.projects.page.toast.iconRemoved")),I(!1),h(null)}return{label:ge,icon:l,color:u,iconBackground:kc(v?null:w),defaultModel:b??null,defaultVariant:b?j??null:null}},[X,u,b,j,l,w,i,S,$,s,r,e,n]);return d.useEffect(()=>{Q(!1)},[ue,a?.updatedAt]),{name:i,setName:c,icon:l,setIcon:f,color:u,setColor:m,iconBackground:w,setIconBackground:h,defaultModel:b,defaultVariant:j,parsedDefaultModel:V,handleDefaultModelChange:Z,handleDefaultVariantChange:ee,isUploadingIcon:C,isRemovingCustomIcon:_,isDiscoveringIcon:T,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:I,pendingUploadIconFile:$,pendingUploadIconPreviewUrl:z,previewImageFailed:ne,setPreviewImageFailed:Q,hasStoredImageIcon:P,hasPendingUploadImageIcon:W,hasCustomIcon:U,effectiveHasImageIcon:D,hasRemovableImageIcon:Y,showStoredImagePreview:M,showImagePreview:K,fileInputRef:H,clearPendingUploadIcon:X,handleUploadIcon:te,handleRemoveImageIcon:fe,handleDiscoverIcon:ce,hasChanges:A,prepareSaveData:me,currentIconImage:a,project:s}},Ic=450,Tc=(s,e)=>{const{t:n}=st(),{hasChanges:r,name:o,icon:a,color:i,iconBackground:c,defaultModel:l,pendingRemoveImageIcon:f,pendingUploadIconFile:u,isUploadingIcon:m,isRemovingCustomIcon:w,prepareSaveData:h}=s,b=d.useRef(!1);d.useEffect(()=>{if(!r||!o.trim()||m||w||b.current)return;const g=window.setTimeout(()=>{b.current||(b.current=!0,(async()=>{try{const j=await h({silent:!0});if(j)try{await e(j)}catch{je.error(n("settings.projects.page.toast.saveFailed"))}}finally{b.current=!1}})())},Ic);return()=>{window.clearTimeout(g)}},[i,l,r,a,c,w,m,o,e,f,u,h,n])},rm=s=>{const e=$e.c(16),{project:n,onIdentitySave:r,showWorktrees:o}=s,a=o===void 0?!0:o,i=Cc(n);let c;e:{if(!n){c=null;break e}let g;e[0]!==n.id||e[1]!==n.path?(g={id:n.id,path:n.path},e[0]=n.id,e[1]=n.path,e[2]=g):g=e[2],c=g}const l=c;let f;if(e[3]!==r?(f=async g=>{await r(g)},e[3]=r,e[4]=f):f=e[4],Tc(i,f),!n||!l)return null;let m;e[5]!==i?(m=t.jsx(vc,{form:i}),e[5]=i,e[6]=m):m=e[6];let w;e[7]!==l?(w=t.jsx(wc,{projectRef:l}),e[7]=l,e[8]=w):w=e[8];let h;e[9]!==l||e[10]!==a?(h=a?t.jsx(uc,{projectRef:l}):null,e[9]=l,e[10]=a,e[11]=h):h=e[11];let b;return e[12]!==m||e[13]!==w||e[14]!==h?(b=t.jsxs("div",{className:"space-y-0",children:[m,w,h]}),e[12]=m,e[13]=w,e[14]=h,e[15]=b):b=e[15],b},eo=()=>{const s=xa();return{displayMode:s,installed:s!=="browser",browserTab:s==="browser"}},om=()=>{const s=$e.c(2),[e,n]=d.useState(Pc);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(eo())};i();for(const c of a)typeof c.addEventListener=="function"?c.addEventListener("change",i):typeof c.addListener=="function"&&c.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const c of a)typeof c.removeEventListener=="function"?c.removeEventListener("change",i):typeof c.removeListener=="function"&&c.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],s[0]=r,s[1]=o):(r=s[0],o=s[1]),d.useEffect(r,o),e};function Pc(){return eo()}const Dc=[{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","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji"],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","connect","oauth","github","linear"],isAvailable:s=>!s.isVSCode}],Ec={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function Rc(s){const e=s.trim().toLowerCase();return Dc.find(n=>n.slug===e)??null}function Ac(s){const e=(s??"").trim().toLowerCase();if(!e)return"home";const n=Ec[e];if(n)return n;const r=Rc(e);return r?r.slug:"home"}function am(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 Bc=["chat","git","diff","terminal","files"],Mc=["settings","agents","commands","skills","providers","usage","git-identities"],Mt={SESSION:"session",TAB:"tab",SETTINGS:"settings",FILE:"file"};function or(s){const e=Lc();return{sessionId:Fc(e),tab:Oc(e),settingsPath:_c(e),diffFile:$c(e)}}function Lc(){if(typeof window>"u")return new URLSearchParams;try{return new URLSearchParams(window.location.search)}catch{return new URLSearchParams}}function Fc(s){const e=s.get(Mt.SESSION);return!e||e.trim().length===0?null:e.trim()}function Oc(s){const e=s.get(Mt.TAB);if(!e)return null;const n=e.toLowerCase().trim();return Bc.includes(n)?n:null}function _c(s){const e=s.get(Mt.SETTINGS);if(!e)return null;const n=e.toLowerCase().trim();return n.length===0?null:n==="aiworker"||n==="general"||n==="preferences"?"home":(Mc.includes(n),n)}function $c(s){const e=s.get(Mt.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(Mt.SESSION)||s.has(Mt.TAB)||s.has(Mt.SETTINGS)||s.has(Mt.FILE)}catch{return!1}}function to(s){const e=new URLSearchParams;if(s.sessionId&&s.sessionId.trim().length>0&&e.set(Mt.SESSION,s.sessionId),s.isSettingsOpen){const n=s.settingsPath.trim().length>0?s.settingsPath:"home";return e.set(Mt.SETTINGS,n),e}return e}function Uc(s,e){const n=typeof window<"u"?window.location.pathname:"/",r=s.toString();return r?`${n}?${r}`:n}function Wc(s){if(typeof window>"u")return!0;try{const e=new URLSearchParams(window.location.search),n=to(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")&&!(Vc()||$r())&&!(!e.force&&Wc(s)))try{const n=to(s),r=Uc(n);e.replace?window.history.replaceState({...window.history.state,route:s},"",r):window.history.pushState({route:s},"",r)}catch{}}function Vc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}async function zc(s){const e=s.trim();if(!e)return;const n=tt.getState();n.currentSessionId!==e&&n.setCurrentSession(e,n.getDirectoryForSession(e));const r=await ba().catch(()=>null);if(!r)return;const o=tt.getState();if(o.currentSessionId!==e)return;const a=[...r.activeSessions,...r.archivedSessions].find(c=>c.id===e);if(!a)return;const i=Ir(a);!i||i===o.currentSessionDirectory||o.setCurrentSession(e,i)}function Gc(){return typeof window>"u"?!1:window.__VSCODE_CONFIG__!==void 0}function im(){const s=d.useMemo(()=>Gc(),[]),e=d.useMemo(()=>$r(),[]),n=d.useRef(!1),r=d.useRef(!1),o=Ue(u=>u.setSettingsDialogOpen),a=Ue(u=>u.setSettingsPage),i=Ue(u=>u.navigateToDiff),c=d.useCallback(async u=>{if(!r.current){r.current=!0;try{if(u.sessionId&&await zc(u.sessionId),u.settingsPath){a(Ac(u.settingsPath)),o(!0);return}if(Ue.getState().isSettingsDialogOpen&&o(!1),u.tab&&u.tab!=="chat"){const m=xs.getState().currentDirectory;if(m){const w=u.tab==="files"?"file":u.tab;Ue.getState().openContextSurface(m,w)}}u.diffFile&&(u.tab==="diff"||!u.tab)&&i(u.diffFile)}finally{r.current=!1}}},[o,a,i]),l=d.useCallback(()=>{const u=tt.getState(),m=Ue.getState();return{sessionId:u.currentSessionId,isSettingsOpen:m.isSettingsDialogOpen,settingsPath:m.settingsPage}},[]),f=d.useCallback((u={})=>{if(s||e||r.current)return;const m=l();ir(m,u)},[s,e,l]);d.useEffect(()=>{if(n.current||(n.current=!0,!ar()))return;const u=or();(async()=>(await c(u),!s&&!e&&ir({...l(),sessionId:u.sessionId??tt.getState().currentSessionId,settingsPath:u.settingsPath??Ue.getState().settingsPage},{replace:!0,force:!0})))()},[c,l,s,e]),d.useEffect(()=>{if(s||e)return;let u=tt.getState().currentSessionId;return tt.subscribe(w=>{const h=w.currentSessionId;h===u||r.current||(u=h,f())})},[s,e,f]),d.useEffect(()=>{if(s||e)return;let u=Ue.getState().isSettingsDialogOpen,m=Ue.getState().settingsPage;return Ue.subscribe(h=>{if(r.current)return;const b=h.isSettingsDialogOpen!==u,g=h.settingsPage!==m;u=h.isSettingsDialogOpen,m=h.settingsPage,(b||g)&&f()})},[s,e,f]),d.useEffect(()=>{if(typeof window>"u"||s||e)return;const u=()=>{const m=or();ar()?c(m):Ue.getState().isSettingsDialogOpen&&o(!1)};return window.addEventListener("popstate",u),()=>{window.removeEventListener("popstate",u)}},[c,s,e,o])}const Hc=600*1e3,lm=()=>{const s=$e.c(3),{terminal:e}=Ks();let n,r;s[0]!==e?(n=()=>{if(!e.touchSessions)return;const o=()=>{if(globalThis.navigator?.onLine===!1)return;const i=[];for(const c of lt.getState().sessions.values())for(const l of c.tabs)l.terminalSessionId&&l.lifecycle!=="exited"&&i.push(l.terminalSessionId);i.length>0&&e.touchSessions?.(i).catch(Kc)};o();const a=setInterval(o,Hc);return()=>clearInterval(a)},r=[e],s[0]=e,s[1]=n,s[2]=r):(n=s[1],r=s[2]),d.useEffect(n,r)};function Kc(){}function cm(){const s=$e.c(5),e=pl(Jc),n=d.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]),d.useEffect(r,o);let a,i;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{let c=!1,l=null;const f=qc,u=m=>{c||(l=window.setTimeout(async()=>{const w=await n.current(),h=typeof w=="number"&&Number.isFinite(w)?f(w):36e5;u(h)},m))};return u(3e3),()=>{c=!0,l!==null&&window.clearTimeout(l)}},i=[],s[3]=a,s[4]=i):(a=s[3],i=s[4]),d.useEffect(a,i)}function qc(s){const e=Math.round(s*1e3);return Math.max(3e5,Math.min(864e5,e))}function Jc(s){return s.checkForUpdates}const Nn=1e3,vs=60*Nn,sn=60*vs,Yc=(s,e)=>{const n=Math.max(0,s);return n<vs?e("common.duration.secondsCompact",{seconds:Math.floor(n/Nn)}):n<sn?e("common.duration.minutesSecondsCompact",{minutes:Math.floor(n/vs),seconds:Math.floor(n%vs/Nn)}):e("common.duration.hoursMinutesCompact",{hours:Math.floor(n/sn),minutes:Math.floor(n%sn/vs)})},Qc=1e3,dm=s=>{const e=$e.c(12),{sessionId:n,running:r,className:o}=s,{t:a}=st(),i=ya(n),c=wa(n),l=va(r,Qc),f=r?Math.max(0,l-(i??l)):c;if(f===void 0)return null;let u,m;e[0]!==f||e[1]!==r||e[2]!==a?(u=Yc(f,a),m=r?a("sessions.sidebar.session.status.activeFor",{duration:u}):a("sessions.sidebar.session.status.lastTurnDuration",{duration:u}),e[0]=f,e[1]=r,e[2]=a,e[3]=u,e[4]=m):(u=e[3],m=e[4]);const w=m,h=r?"text-primary":"text-[var(--status-info)]";let b;e[5]!==o||e[6]!==h?(b=ae("shrink-0 tabular-nums",h,o),e[5]=o,e[6]=h,e[7]=b):b=e[7];let g;return e[8]!==w||e[9]!==u||e[10]!==b?(g=t.jsx("span",{className:b,"aria-label":w,title:w,children:u}),e[8]=w,e[9]=u,e[10]=b,e[11]=g):g=e[11],g},Xc=()=>{const s=$e.c(14),[e,n]=le.useState(!1),[r,o]=le.useState(!1);let a,i;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{n(Or()),o(Ni())},i=[],s[0]=a,s[1]=i):(a=s[0],i=s[1]),le.useEffect(a,i);let c;s[2]!==e?(c=async b=>e?await ki(b):{success:!0,path:b},s[2]=e,s[3]=c):c=s[3];const l=c;let f;s[4]!==e?(f=async b=>e?await Ci():{success:!0},s[4]=e,s[5]=f):f=s[5];const u=f;let m;s[6]!==e?(m=async b=>e?await Ii():{success:!0},s[6]=e,s[7]=m):m=s[7];const w=m;let h;return s[8]!==r||s[9]!==e||s[10]!==l||s[11]!==u||s[12]!==w?(h={isDesktop:e,canRequestAccess:r,requestAccess:l,startAccessing:u,stopAccessing:w},s[8]=r,s[9]=e,s[10]=l,s[11]=u,s[12]=w,s[13]=h):h=s[13],h},so="aiworker:recent-git-branches:v1",no=5,Zc=qi(Gn(),Ji(Gn())),ro=s=>{const e=Ws(s);return e?`${zt()}:${e}`:null},oo=()=>{try{const s=localStorage.getItem(so),e=Zc.safeParse(s?JSON.parse(s):null);return e.success?Object.fromEntries(Object.entries(e.data).map(([n,r])=>[n,r.slice(0,no)])):{}}catch{return{}}},lr=s=>{const e=ro(s);return e?oo()[e]??[]:[]},cr=(s,e)=>{const n=ro(s);if(!n||!e)return[];const r=oo(),o=[e,...(r[n]??[]).filter(a=>a!==e)].slice(0,no);try{localStorage.setItem(so,JSON.stringify({...r,[n]:o}))}catch{}return o},ed=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),td=({currentBranch:s,localBranches:e,remoteBranches:n,branchInfo:r,currentBranchAhead:o=0,onCheckout:a,onCreate:i,remotes:c=[],disabled:l=!1,directory:f,switchBlockedNotice:u=null})=>{const{t:m}=st(),{isMobile:w}=gs(),[h,b]=d.useState(!1),[g,j]=d.useState(""),[p,C]=d.useState(!1),[L,_]=d.useState(!1),[F,T]=d.useState(""),[x,S]=d.useState(!1),[I,$]=d.useState(()=>lr(f)),[R,z]=d.useState({}),q=d.useRef(null),ne=d.useCallback(M=>{M.stopPropagation()},[]),Q=c.length>1,H=d.useMemo(()=>ed(F),[F]),X=d.useMemo(()=>mn(e,g,M=>[M]),[g,e]),ue=d.useMemo(()=>mn(n,g,M=>[M]),[g,n]),V=M=>{if(M===s){b(!1);return}$(cr(f,M)),a(M),b(!1),j("")},P=()=>{C(!0),setTimeout(()=>q.current?.focus(),50)},W=async()=>{if(!(!H||x)){if(Q){_(!0);return}S(!0);try{await i(H,c[0]),T(""),C(!1),b(!1)}finally{S(!1)}}},U=async M=>{if(!(!H||x)){S(!0);try{await i(H,M),T(""),C(!1),_(!1),b(!1)}finally{S(!1)}}},D=()=>{_(!1)},Y=()=>{T(""),C(!1),_(!1)};if(d.useEffect(()=>{h||(j(""),C(!1),_(!1),T(""))},[h]),d.useEffect(()=>{f&&$(s?cr(f,s):lr(f))},[s,f]),d.useEffect(()=>{if(!h)return;const M=I.filter(A=>e.includes(A)).slice(0,5);if(M.length===0)return z({});let K=!1;return Sa(f,M).then(({counts:A})=>{K||z(A)}).catch(()=>{K||z({})}),()=>{K=!0}},[f,h,e,I]),w){const M=I.filter(A=>e.includes(A)),K=(A,Z=!1)=>{const ee=R[A]??(A===s?o:0),te=ee===1?m("gitView.branch.unpushedSingle"):m("gitView.branch.unpushedPlural",{count:ee});return t.jsxs("button",{type:"button",onClick:()=>V(A),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-interactive-hover",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:A}),ee>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:te,"aria-label":te,children:[t.jsx(E,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:ee})]}):null,s===A?t.jsx(E,{name:"check",className:"size-4 shrink-0 text-primary"}):null]},`${Z?"remote":"local"}-${A}`)};return t.jsxs(t.Fragment,{children:[t.jsxs(Pe,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,onClick:()=>b(!0),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||m("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]}),t.jsx(us,{open:h,title:m("gitView.branch.currentBranchTooltip"),onClose:()=>b(!1),children:t.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[t.jsx("input",{autoFocus:!0,value:g,onChange:A=>j(A.target.value),placeholder:m("gitView.branch.searchPlaceholder"),className:"h-9 w-full rounded-lg border border-border bg-transparent px-3 typography-meta outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-primary"}),u?t.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[t.jsx(E,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,M.length>0?t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:m("gitView.branch.recentBranches")}),M.map(A=>K(A))]}):null,t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:m("gitView.branch.localBranches")}),X.map(A=>K(A))]}),t.jsxs("section",{children:[t.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:m("gitView.branch.remoteBranches")}),ue.map(A=>K(A,!0))]})]})})]})}return t.jsxs(Gt,{open:h,onOpenChange:b,children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Ht,{asChild:!0,children:t.jsxs(Pe,{variant:"ghost",size:"sm",className:"h-8 min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,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||m("gitView.branch.detachedHead")}),t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),t.jsx(ps,{sideOffset:8,children:m("gitView.branch.currentBranchTooltip")})]}),t.jsx(Kt,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:t.jsxs(hn,{className:"h-full min-h-0",shouldFilter:!1,children:[t.jsx(pn,{placeholder:m("gitView.branch.searchPlaceholder"),value:g,onValueChange:j,onKeyDown:ne}),u?t.jsxs("div",{className:"flex items-start gap-2 border-b border-border/60 px-3 py-2",children:[t.jsx(E,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"typography-micro text-muted-foreground",children:u})]}):null,t.jsxs(gn,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[t.jsx(xn,{children:m("gitView.branch.empty")}),t.jsx(At,{children:L?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:D,disabled:x,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:[m("gitView.branch.pushToPrefix")," ",t.jsx("span",{className:"text-foreground font-medium",children:H})," ",m("gitView.branch.pushToSuffix")]})]}),t.jsx("div",{className:"flex flex-col gap-1",children:c.map(M=>t.jsxs("button",{type:"button",onClick:()=>U(M),disabled:x,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:[x?t.jsx(E,{name:"loader-4",className:"inline size-3 mr-1.5 animate-spin"}):null,M.name]}),t.jsx("span",{className:"typography-micro text-muted-foreground truncate max-w-full",children:M.pushUrl})]},M.name))})]}):p?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[t.jsx("input",{ref:q,placeholder:m("gitView.branch.newBranchPlaceholder"),value:F,onChange:M=>T(M.target.value),onClick:M=>M.stopPropagation(),onKeyDown:M=>{ne(M),M.key==="Enter"?(M.preventDefault(),W()):M.key==="Escape"&&(M.preventDefault(),Y())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:W,disabled:!H||x,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:x?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:Y,disabled:x,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:P,children:[t.jsx(E,{name:"add",className:"size-4"}),t.jsx("span",{children:m("gitView.branch.create")})]})}),t.jsx(js,{}),I.filter(M=>e.includes(M)).length>0?t.jsxs(t.Fragment,{children:[t.jsx(At,{heading:m("gitView.branch.recentBranches"),children:I.filter(M=>e.includes(M)).map(M=>t.jsxs(Et,{onSelect:()=>V(M),children:[t.jsxs("span",{className:"flex flex-1 items-center gap-2 min-w-0",children:[t.jsx("span",{className:"typography-ui-label text-foreground truncate",children:M}),(()=>{const K=R[M]??(M===s?o:0),A=K===1?m("gitView.branch.unpushedSingle"):m("gitView.branch.unpushedPlural",{count:K});return K>0?t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 typography-micro text-muted-foreground",title:A,"aria-label":A,children:[t.jsx(E,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:K})]}):null})()]}),s===M?t.jsx("span",{className:"typography-micro text-primary",children:m("gitView.branch.currentBadge")}):null]},`recent-${M}`))}),t.jsx(js,{})]}):null,t.jsxs(At,{heading:m("gitView.branch.localBranches"),children:[X.map(M=>t.jsxs(Et,{onSelect:()=>V(M),children:[t.jsxs("span",{className:"flex flex-1 flex-col",children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:M}),(r?.[M]?.ahead||r?.[M]?.behind)&&t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[r[M].ahead||0," ahead ·"," ",r[M].behind||0," behind"]})]}),s===M&&t.jsx("span",{className:"typography-micro text-primary",children:m("gitView.branch.currentBadge")})]},`local-${M}`)),X.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:m("gitView.branch.noLocalBranches")})})]}),t.jsx(js,{}),t.jsxs(At,{heading:m("gitView.branch.remoteBranches"),children:[ue.map(M=>t.jsx(Et,{onSelect:()=>V(M),children:t.jsx("span",{className:"typography-ui-label text-foreground",children:M})},`remote-${M}`)),ue.length===0&&t.jsx(Et,{disabled:!0,className:"justify-center",children:t.jsx("span",{className:"typography-meta text-muted-foreground",children:m("gitView.branch.noRemoteBranches")})})]})]})]})})]})},sd=s=>s.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._/-]/g,"-").replace(/-+/g,"-").replace(/\/{2,}/g,"/").replace(/\/-+/g,"/").replace(/-+\//g,"/").replace(/^[-/]+/,"").replace(/[-/]+$/,""),nd=({currentBranch:s,onRename:e,showEditButton:n=!0})=>{const{t:r}=st(),[o,a]=d.useState(!1),[i,c]=d.useState(s||""),[l,f]=d.useState(!1),u=d.useRef(null),m=()=>{!s||!e||(c(s),a(!0),setTimeout(()=>u.current?.focus(),0))},w=async()=>{if(!s||!e||!i.trim())return;const g=sd(i);if(g===s){a(!1);return}f(!0);try{await e(s,g),a(!1),c("")}finally{f(!1)}},h=()=>{a(!1),c("")},b=g=>{g.key==="Enter"?(g.preventDefault(),w()):g.key==="Escape"&&(g.preventDefault(),h())};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:g=>{g.preventDefault(),w()},children:[t.jsx(E,{name:"git-branch",className:"size-4 text-primary"}),t.jsx("input",{ref:u,value:i,onChange:g=>c(g.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:b,autoFocus:!0}),t.jsx("button",{type:"submit",disabled:l,"aria-label":r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:r(l?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:l?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:h,disabled:l,"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(Pe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:m,title:r("gitView.branch.renameTitle"),children:t.jsx(E,{name:"edit",className:"size-4"})})]})]})},rd=s=>{const e=$e.c(44),{syncAction:n,remotes:r,onFetch:o,onSync:a,onRemoveRemote:i,disabled:c,removingRemoteName:l,aheadCount:f,behindCount:u,trackingRemoteName:m,hasUncommittedChanges:w}=s,h=r===void 0?[]:r,b=l===void 0?null:l,g=f===void 0?0:f,j=u===void 0?0:u,p=w===void 0?!1:w,{t:C}=st(),L=d.useRef(!1),_=!!b,F=h.find(oe=>oe.name===m)??h[0],T=j>0&&p,x=c||n!==null||_||!F||T,S=c||n!==null||_||h.length===0,I=g>0||j>0;let $;e[0]!==C?($=C("gitView.sync.sync"),e[0]=C,e[1]=$):$=e[1];const R=j>0?`↓${j}`:null,z=g>0?`↑${g}`:null;let q;e[2]!==$||e[3]!==R||e[4]!==z?(q=[$,R,z].filter(Boolean),e[2]=$,e[3]=R,e[4]=z,e[5]=q):q=e[5];const ne=q.join(" "),Q=T?C("gitView.sync.commitOrStashTooltip"):F?I?C("gitView.sync.syncChangesTooltip",{ahead:g,behind:j}):C("gitView.sync.syncChanges"):C("gitView.sync.noRemoteTooltip"),H=()=>{F&&a(F)},X="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",ue=T?0:void 0;let V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=ae("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]=V):V=e[6];let P;e[7]!==C?(P=C("gitView.sync.syncChanges"),e[7]=C,e[8]=P):P=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 U;e[11]!==ne?(U=t.jsx("span",{className:"whitespace-nowrap tabular-nums",children:ne}),e[11]=ne,e[12]=U):U=e[12];let D;e[13]!==H||e[14]!==x||e[15]!==P||e[16]!==W||e[17]!==U?(D=t.jsxs("button",{type:"button",onClick:H,disabled:x,className:V,"aria-label":P,children:[W,U]}),e[13]=H,e[14]=x,e[15]=P,e[16]=W,e[17]=U,e[18]=D):D=e[18];let Y;e[19]!==ue||e[20]!==D?(Y=t.jsx(hs,{asChild:!0,children:t.jsx("span",{className:"inline-flex",tabIndex:ue,children:D})}),e[19]=ue,e[20]=D,e[21]=Y):Y=e[21];let M;e[22]!==Q?(M=t.jsx(ps,{sideOffset:8,children:Q}),e[22]=Q,e[23]=M):M=e[23];let K;e[24]!==Y||e[25]!==M?(K=t.jsxs(ms,{children:[Y,M]}),e[24]=Y,e[25]=M,e[26]=K):K=e[26];const A=Gt;let Z;e[27]===Symbol.for("react.memo_cache_sentinel")?(Z=ae("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]=Z):Z=e[27];let ee;e[28]!==C?(ee=C("gitView.sync.moreActionsAria"),e[28]=C,e[29]=ee):ee=e[29];let te;e[30]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(E,{name:"arrow-down-s",className:"size-4"}),e[30]=te):te=e[30];let fe;e[31]!==S||e[32]!==ee?(fe=t.jsx(Ht,{asChild:!0,children:t.jsx("button",{type:"button",className:Z,disabled:S,"aria-label":ee,children:te})}),e[31]=S,e[32]=ee,e[33]=fe):fe=e[33];const ce=Kt,me="start",re=-40,he="w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",ge=h.map(oe=>t.jsx(Bt,{onSelect:de=>{if(L.current){de.preventDefault(),L.current=!1;return}o(oe)},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:C("gitView.sync.fetchFromRemote",{name:oe.name})}),t.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:oe.fetchUrl})]})}),i&&oe.name!==m?t.jsx(Pe,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:n!==null||_,onPointerDown:de=>{L.current=!0,de.preventDefault(),de.stopPropagation()},onClick:de=>{L.current=!0,de.preventDefault(),de.stopPropagation(),i(oe)},"aria-label":C("gitView.header.removeRemoteAria",{name:oe.name}),title:C("gitView.header.removeRemoteTitle",{name:oe.name}),children:b===oe.name?t.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(E,{name:"close",className:"size-3.5"})}):null]})},oe.name));let v;e[34]!==ce||e[35]!==ge?(v=t.jsx(ce,{align:me,alignOffset:re,className:he,children:ge}),e[34]=ce,e[35]=ge,e[36]=v):v=e[36];let J;e[37]!==A||e[38]!==fe||e[39]!==v?(J=t.jsxs(A,{children:[fe,v]}),e[37]=A,e[38]=fe,e[39]=v,e[40]=J):J=e[40];let B;return e[41]!==K||e[42]!==J?(B=t.jsxs("div",{className:X,children:[K,J]}),e[41]=K,e[42]=J,e[43]=B):B=e[43],B},od=s=>{const e=$e.c(27),{repositories:n,selectedRepository:r,onSelectRepository:o,repositoryRoot:a}=s,{t:i}=st();let c;e[0]!==a?(c=L=>{const _=`${a??""}/`;return L.startsWith(_)?L.slice(_.length):L},e[0]=a,e[1]=c):c=e[1];const l=c,f=r??void 0;let u;e[2]!==o?(u=L=>{L&&o(L)},e[2]=o,e[3]=u):u=e[3];let m;e[4]!==i?(m=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=m):m=e[5];let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(E,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=w):w=e[6];let h;e[7]!==l||e[8]!==r?(h=r?l(r):"",e[7]=l,e[8]=r,e[9]=h):h=e[9];let b;e[10]!==h?(b=t.jsx("span",{className:"min-w-0 truncate font-medium text-left",children:h}),e[10]=h,e[11]=b):b=e[11];let g;e[12]!==m||e[13]!==b?(g=t.jsxs($s,{size:"sm",className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":m,children:[w,b]}),e[12]=m,e[13]=b,e[14]=g):g=e[14];let j;if(e[15]!==l||e[16]!==n){let L;e[18]!==l?(L=_=>t.jsx(Yt,{value:_,children:t.jsx("span",{className:"truncate",children:l(_)})},_),e[18]=l,e[19]=L):L=e[19],j=n.map(L),e[15]=l,e[16]=n,e[17]=j}else j=e[17];let p;e[20]!==j?(p=t.jsx(Us,{align:"start",children:j}),e[20]=j,e[21]=p):p=e[21];let C;return e[22]!==p||e[23]!==f||e[24]!==u||e[25]!==g?(C=t.jsxs(_s,{value:f,onValueChange:u,children:[g,p]}),e[22]=p,e[23]=f,e[24]=u,e[25]=g,e[26]=C):C=e[26],C},ad={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint"},id={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 ao(s){return s&&id[s]||"var(--primary)"}const dr=s=>{const e=$e.c(8),{icon:n,className:r,colorToken:o}=s,a=ad[n??"branch"]??"user-3";let i;e[0]!==o?(i=ao(o),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c={color:i},e[2]=i,e[3]=c):c=e[3];let l;return e[4]!==r||e[5]!==a||e[6]!==c?(l=t.jsx(E,{name:a,className:r,style:c}),e[4]=r,e[5]=a,e[6]=c,e[7]=l):l=e[7],l},io=s=>{const e=$e.c(35),{activeProfile:n,identities:r,onSelect:o,isApplying:a,iconOnly:i}=s,c=i===void 0?!1:i,{t:l}=st(),f=a||r.length===0,u=n?.color;let m;e[0]!==u?(m=ao(u),e[0]=u,e[1]=m):m=e[1];let w;e[2]!==m?(w={color:m},e[2]=m,e[3]=w):w=e[3];let h;e[4]!==n?.color||e[5]!==n?.icon||e[6]!==a?(h=a?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(dr,{icon:n?.icon,colorToken:n?.color,className:"size-4"}),e[4]=n?.color,e[5]=n?.icon,e[6]=a,e[7]=h):h=e[7];let b;e[8]!==n?.name||e[9]!==c||e[10]!==l?(b=!c&&t.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-left",children:n?.name||l("gitView.header.noIdentity")}),e[8]=n?.name,e[9]=c,e[10]=l,e[11]=b):b=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(E,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[12]=g):g=e[12];let j;e[13]!==f||e[14]!==w||e[15]!==h||e[16]!==b?(j=t.jsx(hs,{asChild:!0,children:t.jsx(Ht,{asChild:!0,children:t.jsxs(Pe,{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:w,disabled:f,children:[h,b,g]})})}),e[13]=f,e[14]=w,e[15]=h,e[16]=b,e[17]=j):j=e[17];let p;e[18]!==l?(p=l("gitView.header.identityTooltip"),e[18]=l,e[19]=p):p=e[19];let C;e[20]!==p?(C=t.jsx(ps,{sideOffset:8,children:p}),e[20]=p,e[21]=C):C=e[21];let L;e[22]!==C||e[23]!==j?(L=t.jsxs(ms,{children:[j,C]}),e[22]=C,e[23]=j,e[24]=L):L=e[24];let _;e[25]!==n?.id||e[26]!==r||e[27]!==o||e[28]!==l?(_=r.length===0?t.jsx("div",{className:"px-2 py-1.5",children:t.jsx("p",{className:"typography-meta text-muted-foreground",children:l("gitView.header.noProfiles")})}):r.map(x=>{const S=n?.id===x.id;return t.jsx(Bt,{onSelect:()=>o(x),children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(dr,{icon:x.icon,colorToken:x.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:x.name}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x.userEmail})]}),S?t.jsx(E,{name:"check",className:"ml-auto size-4 text-foreground"}):null]})},x.id)}),e[25]=n?.id,e[26]=r,e[27]=o,e[28]=l,e[29]=_):_=e[29];let F;e[30]!==_?(F=t.jsx(Kt,{align:"end",className:"w-64",children:_}),e[30]=_,e[31]=F):F=e[31];let T;return e[32]!==L||e[33]!==F?(T=t.jsxs(Gt,{children:[L,F]}),e[32]=L,e[33]=F,e[34]=T):T=e[34],T},ld=s=>{const e=$e.c(21),{comparison:n,trackingBranch:r,tooltipDelayMs:o}=s,a=o===void 0?1e3:o,{t:i}=st(),c=`${n.remote}/${n.branch}`,l=n.ahead===0&&n.behind===0;let f;e[0]!==i||e[1]!==c||e[2]!==r?(f=r?i("gitView.header.upstreamTooltipTracking",{target:c,tracking:r}):i("gitView.header.upstreamTooltip",{target:c}),e[0]=i,e[1]=c,e[2]=r,e[3]=f):f=e[3];const u=f;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(E,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=m):m=e[4];let w;e[5]!==c?(w=t.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:c}),e[5]=c,e[6]=w):w=e[6];let h;e[7]!==n.ahead||e[8]!==n.behind||e[9]!==l||e[10]!==i?(h=l?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]=l,e[10]=i,e[11]=h):h=e[11];let b;e[12]!==w||e[13]!==h?(b=t.jsx(hs,{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:[m,w,h]})}),e[12]=w,e[13]=h,e[14]=b):b=e[14];let g;e[15]!==u?(g=t.jsx(ps,{sideOffset:8,children:u}),e[15]=u,e[16]=g):g=e[16];let j;return e[17]!==b||e[18]!==g||e[19]!==a?(j=t.jsxs(ms,{delayDuration:a,children:[b,g]}),e[17]=b,e[18]=g,e[19]=a,e[20]=j):j=e[20],j},um=s=>{const e=$e.c(84),{directory:n,status:r,localBranches:o,remoteBranches:a,branchInfo:i,syncAction:c,remotes:l,onFetch:f,onSync:u,onRemoveRemote:m,removingRemoteName:w,onCheckoutBranch:h,onCreateBranch:b,onRenameBranch:g,activeIdentityProfile:j,availableIdentities:p,onSelectIdentity:C,isApplyingIdentity:L,isWorktreeMode:_,onOpenHistory:F,onOpenGraph:T,onOpenStashes:x,onOpenUpdateBranch:S,onOpenReintegrateCommits:I,pullRequest:$,prChecks:R,onOpenPullRequest:z,repositoryOptions:q,selectedRepository:ne,onSelectRepository:Q,repositoryRoot:H}=s,{t:X}=st(),{isMobile:ue}=gs();if(!r)return null;let V;e[0]!==q?(V=q??[],e[0]=q,e[1]=V):V=e[1];let P;e[2]!==V?(P=V.filter(Boolean),e[2]=V,e[3]=P):P=e[3];const W=P;let U;e[4]!==T||e[5]!==F||e[6]!==I||e[7]!==x||e[8]!==S||e[9]!==X?(U=F||T||x||S?t.jsxs(Gt,{children:[t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsx(Ht,{asChild:!0,children:t.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0","aria-label":X("gitView.header.repositoryViews"),children:t.jsx(E,{name:"more-fill",className:"size-4"})})})}),t.jsx(ps,{sideOffset:8,children:X("gitView.header.repositoryViews")})]}),t.jsxs(Kt,{align:"end",children:[F?t.jsxs(Bt,{onSelect:F,children:[t.jsx(E,{name:"history",className:"size-4"}),X("gitView.history.title")]}):null,T?t.jsxs(Bt,{onSelect:T,children:[t.jsx(E,{name:"git-branch",className:"size-4"}),X("gitView.graph.title")]}):null,x?t.jsxs(Bt,{onSelect:x,children:[t.jsx(E,{name:"archive-stack",className:"size-4"}),X("gitView.stashes.title")]}):null,S?t.jsxs(Bt,{onSelect:S,children:[t.jsx(E,{name:"git-merge",className:"size-4"}),X("gitView.header.updateBranch")]}):null,I?t.jsxs(Bt,{onSelect:I,children:[t.jsx(E,{name:"split-cells-horizontal",className:"size-4"}),X("gitView.integrate.title")]}):null]})]}):null,e[4]=T,e[5]=F,e[6]=I,e[7]=x,e[8]=S,e[9]=X,e[10]=U):U=e[10];let D;e[11]!==U?(D=t.jsx("div",{className:"flex items-center gap-1 shrink-0",children:U}),e[11]=U,e[12]=D):D=e[12];const Y=D,M=R?R.state==="success"?"var(--status-success)":R.state==="failure"?"var(--status-error)":"var(--status-warning)":null,K=$?$.state==="merged"?"merged":$.state==="closed"?"closed":$.draft?"draft":R?.state==="failure"||$.mergeable===!1||$.mergeableState==="blocked"||$.mergeableState==="dirty"?"blocked":"open":null;let A;e[13]!==z||e[14]!==M||e[15]!==K||e[16]!==$||e[17]!==X?(A=$&&z?t.jsxs(ms,{children:[t.jsx(hs,{asChild:!0,children:t.jsxs(Pe,{variant:"ghost",size:"sm",onClick:z,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-${K})`}}),t.jsx("span",{className:"tabular-nums text-foreground/80",children:X("gitView.pr.numberLabel",{number:$.number})}),M?t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:M}}):null]})}),t.jsx(ps,{sideOffset:8,children:X("gitView.header.openPullRequest")})]}):null,e[13]=z,e[14]=M,e[15]=K,e[16]=$,e[17]=X,e[18]=A):A=e[18];const Z=A,ee=!r;let te;e[19]!==r.tracking?(te=r.tracking?.split("/")[0],e[19]=r.tracking,e[20]=te):te=e[20];const fe=(r.files?.length??0)>0;let ce;e[21]!==f||e[22]!==m||e[23]!==u||e[24]!==l||e[25]!==w||e[26]!==r.ahead||e[27]!==r.behind||e[28]!==c||e[29]!==ee||e[30]!==te||e[31]!==fe?(ce=t.jsx(rd,{syncAction:c,remotes:l,onFetch:f,onSync:u,onRemoveRemote:m,removingRemoteName:w,disabled:ee,iconOnly:!0,aheadCount:r.ahead,behindCount:r.behind,trackingRemoteName:te,hasUncommittedChanges:fe}),e[21]=f,e[22]=m,e[23]=u,e[24]=l,e[25]=w,e[26]=r.ahead,e[27]=r.behind,e[28]=c,e[29]=ee,e[30]=te,e[31]=fe,e[32]=ce):ce=e[32];const me=ce;let re;e[33]!==r.tracking||e[34]!==r.upstreamComparison?(re=r.upstreamComparison?t.jsx(ld,{comparison:r.upstreamComparison,trackingBranch:r.tracking,tooltipDelayMs:1e3}):null,e[33]=r.tracking,e[34]=r.upstreamComparison,e[35]=re):re=e[35];const he=re;let ge;e[36]!==j||e[37]!==p||e[38]!==L||e[39]!==C?(ge=t.jsx(io,{activeProfile:j,identities:p,onSelect:C,isApplying:L,iconOnly:!0}),e[36]=j,e[37]=p,e[38]=L,e[39]=C,e[40]=ge):ge=e[40];const v=ge;let J;e[41]!==i||e[42]!==n||e[43]!==ue||e[44]!==_||e[45]!==o||e[46]!==h||e[47]!==b||e[48]!==g||e[49]!==a||e[50]!==l||e[51]!==r.ahead||e[52]!==r.current||e[53]!==r.files?.length||e[54]!==X?(J=_&&!ue?t.jsx(nd,{currentBranch:r.current,onRename:g}):t.jsx(td,{directory:n,currentBranch:r.current,localBranches:o,remoteBranches:a,branchInfo:i,currentBranchAhead:r.ahead,onCheckout:h,onCreate:b,remotes:l,switchBlockedNotice:(r.files?.length??0)>0?X("gitView.branch.switchBlockedNotice"):null}),e[41]=i,e[42]=n,e[43]=ue,e[44]=_,e[45]=o,e[46]=h,e[47]=b,e[48]=g,e[49]=a,e[50]=l,e[51]=r.ahead,e[52]=r.current,e[53]=r.files?.length,e[54]=X,e[55]=J):J=e[55];let B;e[56]!==Q||e[57]!==W||e[58]!==H||e[59]!==ne?(B=W.length>0&&Q?t.jsx(od,{repositories:W,selectedRepository:ne??null,onSelectRepository:Q,repositoryRoot:H}):null,e[56]=Q,e[57]=W,e[58]=H,e[59]=ne,e[60]=B):B=e[60];let oe;e[61]!==J||e[62]!==B?(oe=t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[J,B]}),e[61]=J,e[62]=B,e[63]=oe):oe=e[63];let de;e[64]!==v?(de=t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:v}),e[64]=v,e[65]=de):de=e[65];let pe;e[66]!==oe||e[67]!==de?(pe=t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[oe,de]}),e[66]=oe,e[67]=de,e[68]=pe):pe=e[68];let Ne;e[69]!==Z?(Ne=Z?t.jsx("div",{className:"shrink-0",children:Z}):null,e[69]=Z,e[70]=Ne):Ne=e[70];let We;e[71]===Symbol.for("react.memo_cache_sentinel")?(We=t.jsx("div",{className:"min-w-0 flex-1"}),e[71]=We):We=e[71];let _e;e[72]!==he?(_e=he?t.jsx("div",{className:"min-w-0 shrink",children:he}):null,e[72]=he,e[73]=_e):_e=e[73];let be;e[74]!==me?(be=t.jsx("div",{className:"shrink-0",children:me}),e[74]=me,e[75]=be):be=e[75];let De;e[76]!==Y||e[77]!==Ne||e[78]!==_e||e[79]!==be?(De=t.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[Ne,We,_e,Y,be]}),e[76]=Y,e[77]=Ne,e[78]=_e,e[79]=be,e[80]=De):De=e[80];let Ie;return e[81]!==pe||e[82]!==De?(Ie=t.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[pe,De]}),e[81]=pe,e[82]=De,e[83]=Ie):Ie=e[83],Ie},cd=s=>s==="/",zs=s=>s.replace(/\\/g,"/"),En=s=>{if(!s||cd(s))return s;let e=s;for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e},Qt=s=>s.endsWith("/"),dd=s=>{const e=s.trim();return!e||Qt(e)?e:`${e}/`},Rn=s=>s.lastIndexOf("/"),lo=s=>{if(Qt(s))return s;const e=Rn(s);return e<0?s:s.slice(0,e+1)},ud=s=>{const e=Rn(s);return s.slice(e+1)},co=s=>{const e=En(s.trim());if(!e||e==="~"||e==="~/"||e==="/")return null;const n=Rn(e);return n<0?null:e.startsWith("~/")&&n<=1?"~/":n===0?"/":`${e.slice(0,n)}/`},fd=s=>Qt(s)&&co(s)!==null,md=(s,e)=>`${lo(s)}${e}/`,$t=s=>{if(!s)return null;const e=En(zs(s.trim()));return e?e.toLowerCase():null},ur=(s,e)=>{const n=s.trim();return n==="~"?e:n.startsWith("~/")?`${e}${n.slice(1)}`:n},hd=s=>typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?s.metaKey&&!s.ctrlKey:s.ctrlKey&&!s.metaKey,nn=s=>{if(!s)return;s.focus({preventScroll:!0});const e=s.value.length;s.setSelectionRange(e,e),s.scrollLeft=s.scrollWidth},pd=async()=>{try{const s=await Lt("/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 fs.getFilesystemHome().catch(()=>null)},fm=({open:s,onOpenChange:e})=>{const{t:n}=st(),r=xs(N=>N.homeDirectory),o=Tt(N=>N.projects),a=Tt(N=>N.addProject),i=Ue(N=>N.setSessionSwitcherOpen),c=tt(N=>N.openNewSessionDraft),l=Tt(N=>N.addProjects),f=qt(N=>N.profiles),u=qt(N=>N.globalIdentity),m=qt(N=>N.defaultGitIdentityId),w=qt(N=>N.loadProfiles),h=qt(N=>N.loadGlobalIdentity),b=qt(N=>N.loadDefaultGitIdentityId),{canRequestAccess:g,requestAccess:j,startAccessing:p}=Xc(),{isMobile:C}=gs(),L=d.useRef(null),_=d.useRef(null),F=d.useRef(new Map),[T,x]=d.useState(""),[S,I]=d.useState("~/"),[$,R]=d.useState([]),[z,q]=d.useState(!1),[ne,Q]=d.useState(!1),[H,X]=d.useState(null),[ue,V]=d.useState(0),[P,W]=d.useState(0),[U,D]=d.useState(!1),[Y,M]=d.useState(!1),[K,A]=d.useState(0),[Z,ee]=d.useState(!1),[te,fe]=d.useState(""),[ce,me]=d.useState(null),[re,he]=d.useState(!1),[ge,v]=d.useState([]),J=T||r,B=d.useMemo(()=>new Set(o.map(N=>$t(N.path)).filter(N=>!!N)),[o]);d.useEffect(()=>{if(!s)return;I("~/"),R([]),W(0),D(!1),M(!1),ee(!1),fe(""),me(null),he(!1),v([]),requestAnimationFrame(()=>nn(L.current));let N=!1;return(async()=>{const ye=await pd();N||(x(ye||r||""),requestAnimationFrame(()=>nn(L.current)))})(),()=>{N=!0}},[r,s]),d.useEffect(()=>{s&&(w(),h(),b())},[b,w,h,s]);const oe=d.useMemo(()=>{const N=new Map;u&&N.set(u.id,u);for(const ie of f)N.set(ie.id,ie);return Array.from(N.values())},[f,u]);d.useEffect(()=>{if(!s||!Z||ce!==null)return;const N=typeof m=="string"?m.trim():"";if(N&&oe.some(ye=>ye.id===N)){me(N);return}const ie=oe.find(ye=>ye.authType==="ssh"||ye.sshKey);ie&&me(ie.id)},[oe,m,Z,s,ce]);const de=d.useMemo(()=>oe.find(N=>N.id===ce)??null,[oe,ce]),pe=d.useMemo(()=>lo(S),[S]),Ne=d.useMemo(()=>Qt(S)?"":ud(S),[S]),We=d.useMemo(()=>J?ur(pe,J):"",[pe,J]);d.useEffect(()=>{if(!s||!We){R([]),X(null);return}let N=!1;return q(!0),Q(!1),X(null),fs.listLocalDirectory(We).then(ie=>{if(N)return;Q(!1),X(null);const ye=ie.filter(ve=>ve.isDirectory).map(ve=>({name:ve.name,path:zs(ve.path)})).sort((ve,Se)=>ve.name.localeCompare(Se.name));R(ye)}).catch(ie=>{if(!N){R([]);const ye=Ti(ie)?ie.reason:"unknown";X(ye),Q(ye==="not-found")}}).finally(()=>{N||q(!1)}),()=>{N=!0}},[We,ue,s]);const _e=d.useMemo(()=>{const N=Ne.toLowerCase(),ie=re||Ne.startsWith(".");return $.filter(ye=>ye.name.toLowerCase().startsWith(N)&&(ie||!ye.name.startsWith(".")))},[Ne,$,re]),be=d.useMemo(()=>{const N=[];fd(S)&&N.push({type:"up",value:"browse:up",name:"..",path:co(S)});for(const ie of _e){const ye=$t(ie.path);N.push({type:"directory",value:`browse:${ie.path}`,name:ie.name,path:ie.path,disabled:!!(ye&&B.has(ye))})}return N},[B,_e,S]);d.useEffect(()=>{W(0)},[S,be.length]),d.useEffect(()=>{v([])},[We]);const De=d.useMemo(()=>ge.filter(N=>{const ie=$t(N);return!!(ie&&!B.has(ie))}),[B,ge]),Ie=d.useCallback(N=>{v(ie=>ie.includes(N)?ie.filter(ye=>ye!==N):[...ie,N])},[]),Be=d.useMemo(()=>J?En(ur(S,J)):"",[J,S]),Fe=$t(Be),He=!!(Fe&&B.has(Fe)),Ke=d.useMemo(()=>Ne?_e.find(N=>N.name===Ne)??null:null,[Ne,_e]),nt=!!(Be&&!He&&(H===null||H==="not-found")&&(Qt(S)&&ne||!Qt(S)&&Ne.trim().length>0&&Ke===null)),Ze=!U&&!Y&&H!=="os-permission"&&H!=="invalid-response"&&H!=="unknown"&&(!Z&&De.length>0||!He&&!!Be),rt=Ze&&te.trim().length>0,Je=be[P]??null,Ve=!!(Je&&(Je.type==="up"||Je.type==="directory")),Ye=bn("mod"),ze=!Z&&De.length>0?n("directoryExplorerDialog.actions.addSelected"):n(He?"directoryExplorerDialog.actions.alreadyAdded":Z?U?"directoryExplorerDialog.actions.cloning":"directoryExplorerDialog.actions.cloneAndAdd":U?"directoryExplorerDialog.actions.adding":nt?"directoryExplorerDialog.actions.createAndAdd":"directoryExplorerDialog.actions.addProject");d.useLayoutEffect(()=>{const N=_.current;if(!N)return;const ie=()=>A(Math.ceil(N.getBoundingClientRect().width));if(ie(),typeof ResizeObserver>"u")return;const ye=new ResizeObserver(ie);return ye.observe(N),()=>ye.disconnect()},[ze]),d.useLayoutEffect(()=>{const N=L.current;N&&(N.scrollLeft=N.scrollWidth)},[K,S]),d.useLayoutEffect(()=>{s&&nn(L.current)},[s]),d.useLayoutEffect(()=>{const N=be[P];N&&F.current.get(N.value)?.scrollIntoView({block:"nearest"})},[P,be]);const xe=d.useCallback(()=>{e(!1)},[e]),et=d.useCallback((N,ie)=>{C&&i(!1),c({selectedProjectId:N,directoryOverride:ie}),xe()},[xe,C,c,i]),Me=d.useCallback(async(N,ie)=>{N.stopPropagation();const ye=$t(ie);if(ye&&B.has(ye))return;const ve=await a(ie);if(!ve){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}et(ve.id,ve.path)},[a,B,et,n]),ke=d.useCallback(async N=>{if(U)return;const ie=$t(N),ye=Z?[]:ge.filter(Se=>{const Oe=$t(Se);return!!(Oe&&!B.has(Oe))});if(ye.length===0&&(!N||ie&&B.has(ie)))return;let ve=N;D(!0);try{const Se=!Z&&nt&&$t(N)===$t(Be);if(Z){const Ge=te.trim();if(!Ge){je.error(n("directoryExplorerDialog.toast.cloneUrlRequired"));return}ve=(await fs.cloneRepository({remoteUrl:Ge,destinationPath:N,gitIdentityId:de?.id??null})).path}else if(ye.length>0){const Ge=await l(ye);if(Ge.length===0){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}je.success(n("directoryExplorerDialog.toast.addedProjects",{count:Ge.length})),v([]),xe();return}else Se&&await fs.createDirectory(N,{asProject:!0});const Oe=await a(ve);if(!Oe){je.error(n("directoryExplorerDialog.toast.failedToAddProject"),{description:n("directoryExplorerDialog.toast.selectValidDirectoryPath")});return}et(Oe.id,Oe.path)}catch(Se){je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:Se instanceof Error?Se.message:n("directoryExplorerDialog.toast.unknownError")})}finally{D(!1)}},[a,l,B,te,xe,Z,U,et,de?.id,ge,nt,Be,n]),Qe=d.useCallback(N=>{I(dd(N))},[]),Ee=d.useCallback(N=>{I(md(S,N.name))},[S]),qe=d.useCallback(N=>{if(N){if(N.type==="up"){N.path&&Qe(N.path);return}Ee(N)}},[Qe,Ee]),pt=d.useCallback(async()=>{if(!(!g||Y)){M(!0);try{const N=await j(Be);if(!N.success||!N.path){N.error&&N.error!=="Directory selection cancelled"&&je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:N.error});return}const ie=await p(N.path);if(!ie.success){je.error(n("directoryExplorerDialog.toast.failedToOpenDirectory"),{description:ie.error||n("directoryExplorerDialog.toast.desktopCouldNotGrantAccess")});return}v([]),await ke(N.path)}catch(N){je.error(n("directoryExplorerDialog.toast.failedToSelectDirectory"),{description:N instanceof Error?N.message:n("directoryExplorerDialog.toast.unknownError")})}finally{M(!1)}}},[g,ke,Y,j,p,n,Be]),ft=d.useCallback(N=>{if(N.key==="ArrowDown"){N.preventDefault(),W(ie=>Math.min(be.length-1,ie+1));return}if(N.key==="ArrowUp"){N.preventDefault(),W(ie=>Math.max(0,ie-1));return}if(N.key===" "){if(Qt(S)){N.preventDefault(),Je&&Je.type==="directory"&&!Je.disabled&&Ie(Je.path);return}return}if(N.key==="Enter"){if(N.preventDefault(),hd(N)){ke(Be);return}Ve&&qe(Je);return}N.key==="Backspace"&&S===""&&(N.preventDefault(),xe())},[qe,ke,xe,Ve,Je,S,be.length,Be,Ie]),gt=t.jsxs("button",{type:"button",onClick:()=>he(N=>!N),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:[re?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")]}),Ct=t.jsxs("div",{className:"px-2.5 py-1.5",children:[Z?t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[t.jsx(St,{value:te,onChange:N=>fe(N.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(io,{activeProfile:de,identities:oe,onSelect:N=>me(N.id),isApplying:U,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(St,{ref:L,value:S,onChange:N=>I(zs(N.target.value)),onKeyDown:ft,placeholder:n("directoryExplorerDialog.pathInput.placeholder"),className:"border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0",style:!C&&K>0?{paddingRight:`${K+24}px`}:void 0,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"}),C?null:t.jsx(Pe,{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:Z?!rt:!Ze,onMouseDown:N=>N.preventDefault(),onClick:()=>{ke(Be)},title:ze,children:ze})]})]}),y=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")}),z?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.loading")}):H&&H!=="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(H==="os-permission"?"directoryExplorerDialog.browse.permissionDenied":"directoryExplorerDialog.browse.loadFailed")}),t.jsxs("div",{className:"flex items-center gap-2",children:[H==="os-permission"&&g?t.jsx(Pe,{size:"xs",onClick:()=>{pt()},disabled:Y,children:n("directoryExplorerDialog.browse.grantAccess")}):null,t.jsx(Pe,{variant:"outline",size:"xs",onClick:()=>V(N=>N+1),children:n("directoryExplorerDialog.browse.retry")})]})]}):be.length===0?t.jsx("div",{className:"py-10 text-center typography-ui-label text-muted-foreground",children:n("directoryExplorerDialog.browse.empty")}):t.jsx("div",{className:"space-y-0.5",children:be.map((N,ie)=>{const ye=ie===P;return t.jsxs("button",{ref:ve=>{ve?F.current.set(N.value,ve):F.current.delete(N.value)},type:"button",onMouseEnter:()=>W(ie),onMouseDown:ve=>ve.preventDefault(),onClick:()=>qe(N),className:ae("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",ye&&"bg-interactive-selection text-interactive-selection-foreground",!ye&&"hover:bg-interactive-hover/50",N.type==="directory"&&N.disabled&&"opacity-45"),children:[N.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:N.name})}),N.type==="directory"&&N.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")}):N.type==="directory"?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>{ve.stopPropagation(),Ie(N.path)},title:n("directoryExplorerDialog.browse.selectForAdd"),"aria-label":n("directoryExplorerDialog.browse.selectForAdd"),"aria-pressed":ge.includes(N.path),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",children:t.jsx(E,{name:ge.includes(N.path)?"checkbox":"checkbox-blank",className:"h-4 w-4"})}),t.jsx("button",{type:"button",onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>Me(ve,N.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]},N.value)})})]})}),G=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[Ct,y]}),Re=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:Ye}),t.jsx(E,{name:"corner-down-left",className:"h-3.5 w-3.5"}),n("directoryExplorerDialog.footer.add")]})]}),Le=()=>t.jsxs(t.Fragment,{children:[C?null:Re,t.jsxs("div",{className:ae("flex w-full flex-row justify-end gap-2 sm:w-auto",C&&"justify-stretch"),children:[g?t.jsx(Pe,{variant:"ghost",size:"xs",onClick:pt,disabled:U||Y||Z,children:n(Y?"directoryExplorerDialog.actions.openingFinder":"directoryExplorerDialog.actions.openInFinder")}):null,t.jsx(Pe,{variant:"ghost",size:"xs",onClick:()=>{ee(N=>!N),v([])},disabled:U||Y,className:ae(C&&"flex-1"),children:n(Z?"directoryExplorerDialog.actions.addLocalProject":"directoryExplorerDialog.actions.cloneRepository")}),C?t.jsx(Pe,{size:"xs",onClick:()=>{ke(Be)},disabled:Z?!rt:!Ze,className:"flex-1",children:ze}):null]})]});return C?t.jsx(us,{open:s,onClose:xe,title:n("directoryExplorerDialog.title"),className:"h-[88dvh] max-h-[720px]",contentMaxHeightClassName:"flex-1",footer:t.jsx("div",{className:"flex flex-col gap-2",children:Le()}),children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[t.jsx("div",{className:"flex justify-end",children:gt}),G]})}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]",initialFocus:!1,children:[t.jsx(Gs,{className:"px-5 pb-2 pt-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(Ps,{children:n("directoryExplorerDialog.title")}),t.jsx(ja,{className:"mt-2",children:n("directoryExplorerDialog.description")})]}),gt]})}),t.jsx("div",{className:"min-h-0 flex-1 px-2 pb-0",children:G}),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:Le()})]})})};function fr(s){const{localBranches:e,remoteBranches:n,query:r}=s,o=r.trim();if(!o)return{matching:[],otherLocal:e,otherRemote:n};const a=[...e.map(l=>({label:l,value:l,source:"local"})),...n.map(l=>({label:l,value:`remotes/${l}`,source:"remote"}))],i=mn(a,o,l=>[l.label]),c=new Set(i);return{matching:i,otherLocal:a.filter(l=>l.source==="local"&&!c.has(l)).map(l=>l.label),otherRemote:a.filter(l=>l.source==="remote"&&!c.has(l)).map(l=>l.label)}}const rn="oc:lastWorktreeSourceBranch",gd=({mode:s,sourceBranch:e,linkedPr:n,selectedBranch:r})=>s==="existing-branch"?r||null:n?null:e||null,xd=({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 bd({open:s,onOpenChange:e,onSelect:n}){const{t:r}=st(),o=Ue(v=>v.isMobile),{github:a}=Ks(),i=Ns(v=>v.status),c=Ns(v=>v.hasChecked),l=Ue(v=>v.setSettingsDialogOpen),f=Ue(v=>v.setSettingsPage),u=Tt(v=>v.getActiveProject()),m=u?.path??null,w=le.useMemo(()=>m&&u?{id:u.id,path:m}:null,[u,m]),[h,b]=le.useState("issues"),[g,j]=le.useState(""),[p,C]=le.useState([]),[L,_]=le.useState([]),[F,T]=le.useState(!1),[x,S]=le.useState(!1),[I,$]=le.useState(null),[R,z]=le.useState(null),[q,ne]=le.useState(null),[Q,H]=le.useState(!1),[X,ue]=le.useState(new Map),[V,P]=le.useState(1),[W,U]=le.useState(!1),D=Na(g,350),Y=le.useCallback(async v=>{if(!(!m||!a)&&!(c&&i?.connected===!1)){T(!0),$(null),P(1),U(!1);try{if(h==="issues"&&a.issuesList){const J=await a.issuesList(m,{page:1,query:v});J.connected===!1?($(r("session.githubIntegration.error.notConnected")),C([])):(C(J.issues??[]),P(J.page??1),U(!!J.hasMore))}else if(h==="prs"&&a.prsList){const J=await a.prsList(m,{page:1,query:v});J.connected===!1?($(r("session.githubIntegration.error.notConnected")),_([])):(_(J.prs??[]),P(J.page??1),U(!!J.hasMore))}}catch(J){$(J instanceof Error?J.message:r("session.githubIntegration.error.loadDataFailed"))}finally{T(!1)}}},[m,a,c,i,h,r]);le.useEffect(()=>{if(!s||!m||c&&i?.connected===!1||!a)return;if(!D.trim()){Y();return}const v=new AbortController;T(!0),$(null),P(1),U(!1);const J=h==="issues"&&a.issuesList?a.issuesList(m,{page:1,query:D.trim()}):h==="prs"&&a.prsList?a.prsList(m,{page:1,query:D.trim()}):null;if(!J){T(!1);return}return J.then(B=>{v.signal.aborted||("issues"in B?B.connected===!1?($(r("session.githubIntegration.error.notConnected")),C([])):(C(B.issues??[]),P(B.page??1),U(!!B.hasMore)):"prs"in B&&(B.connected===!1?($(r("session.githubIntegration.error.notConnected")),_([])):(_(B.prs??[]),P(B.page??1),U(!!B.hasMore))))}).catch(B=>{v.signal.aborted||$(B instanceof Error?B.message:r("session.githubIntegration.error.loadDataFailed"))}).finally(()=>{v.signal.aborted||T(!1)}),()=>v.abort()},[s,m,a,c,i,h,D,Y,r]);const M=le.useCallback(async()=>{if(!(!m||!a)&&!(F||x)&&W){S(!0);try{const v=V+1;if(h==="issues"&&a.issuesList){const J=D.trim()?await a.issuesList(m,{page:v,query:D.trim()}):await a.issuesList(m,{page:v});J.connected!==!1&&(C(B=>[...B,...J.issues??[]]),P(J.page??v),U(!!J.hasMore))}else if(h==="prs"&&a.prsList){const J=D.trim()?await a.prsList(m,{page:v,query:D.trim()}):await a.prsList(m,{page:v});J.connected!==!1&&(_(B=>[...B,...J.prs??[]]),P(J.page??v),U(!!J.hasMore))}}catch{}finally{S(!1)}}},[m,a,h,V,W,F,x,D]);le.useEffect(()=>{if(!s){b("issues"),j(""),C([]),_([]),z(null),ne(null),H(!1),$(null),ue(new Map),P(1),U(!1);return}Y()},[s,Y]);const K=le.useCallback(async v=>{if(!(!w||!v)&&!X.has(v))try{const B=(await Tr(w,{mode:"new",branchName:v,worktreeName:v})).errors.find(oe=>oe.code==="branch_in_use");ue(oe=>new Map(oe).set(v,{isValid:!B,error:B?r(B.code==="branch_exists"?"session.githubIntegration.validation.branchAlreadyExists":"session.githubIntegration.validation.branchAlreadyCheckedOut"):null}))}catch{ue(J=>new Map(J).set(v,{isValid:!1,error:r("session.githubIntegration.validation.failed")}))}},[w,X,r]);le.useEffect(()=>{!s||h!=="prs"||L.forEach(v=>{v.head&&K(v.head)})},[s,h,L,K]);const A=c&&i?.connected===!0,Z=()=>{f("integrations"),l(!0)},ee=v=>{z(v),ne(null)},te=v=>{ne(v),z(null)},fe=()=>{R?n({type:"issue",item:R}):q&&n({type:"pr",item:q,includeDiff:Q}),e(!1)},ce=()=>{z(null),ne(null),H(!1)},me=R||q&&X.get(q.head??"")?.isValid!==!1,re=v=>v.head?X.get(v.head)?.isValid===!1:!0,he=t.jsx(t.Fragment,{children:A?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(St,{value:g,onChange:v=>j(v.target.value),placeholder:r(h==="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:[F&&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"})}),I&&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:I})]})}),!F&&!I&&h==="issues"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[p.length>0?p.map(v=>t.jsx("button",{onClick:()=>ee(v),className:ae("w-full text-left px-2 py-1.5 rounded transition-colors",R?.number===v.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:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-2",children:v.title}),v.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:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.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&&!x&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{M()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),x&&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"})})]}),!F&&!I&&h==="prs"&&t.jsxs("div",{className:"space-y-0.5 min-h-full",children:[L.length>0?L.map(v=>{const J=re(v),B=v.head?X.get(v.head):void 0;return t.jsx("button",{onClick:()=>!J&&te(v),disabled:J,className:ae("w-full text-left px-2 py-1.5 rounded transition-colors",q?.number===v.number?"bg-interactive-selection text-interactive-selection-foreground":J?"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:["#",v.number]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"typography-small line-clamp-1",children:v.title}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsxs("span",{className:"typography-micro text-muted-foreground",children:[v.head," → ",v.base]}),v.sourceRepo?.source==="upstream"?t.jsxs("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info",children:[v.sourceRepo.owner,"/",v.sourceRepo.repo]}):null,J&&B?.error&&t.jsx("span",{className:"typography-micro text-destructive",children:B.error})]})]})]})},`${v.sourceRepo?.owner??""}-${v.sourceRepo?.repo??""}-${v.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&&!x&&t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{M()},className:"h-7 text-xs",children:r("session.githubIntegration.actions.loadMore")})}),x&&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(Pe,{onClick:Z,size:"sm",children:r("session.githubIntegration.connect.action")})]})}),ge=t.jsxs("div",{className:ae("w-full",o?"flex flex-col gap-2":"flex flex-row items-center"),children:[t.jsxs("div",{className:ae("flex items-center gap-4",o?"w-full justify-center order-1":"flex-1"),children:[!o&&(R||q)&&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:R?r("session.githubIntegration.selected.issueNumber",{number:R.number}):r("session.githubIntegration.selected.prNumber",{number:q?.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"})})]}),h==="prs"&&q&&t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer h-8",children:[t.jsx(Ds,{checked:Q,onChange:v=>H(v),ariaLabel:r("session.githubIntegration.includeDiffAria")}),t.jsx("span",{className:"typography-small text-foreground",children:r("session.githubIntegration.includeDiff")})]})]}),t.jsxs("div",{className:ae("flex gap-2",o?"w-full order-2":"justify-end"),children:[t.jsx(Pe,{variant:"outline",size:"sm",onClick:()=>e(!1),className:ae(o&&"flex-1"),children:r("session.githubIntegration.actions.cancel")}),t.jsx(Pe,{size:"sm",onClick:fe,disabled:!me,className:ae(o&&"flex-1"),children:r("session.githubIntegration.actions.select")})]})]});return t.jsx(t.Fragment,{children:o?t.jsx(us,{open:s,title:r("session.githubIntegration.title"),onClose:()=>e(!1),footer:A?ge:void 0,renderHeader:v=>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")}),v]}),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:h,onSelect:J=>{b(J),j("")},variant:"active-pill",layoutMode:"fit"})}),(R||q)&&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:R?r("session.githubIntegration.selected.issueNumber",{number:R.number}):r("session.githubIntegration.selected.prNumber",{number:q?.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:he}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[t.jsx(Gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ps,{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:h,onSelect:v=>{b(v),j("")},variant:"active-pill",layoutMode:"fit"})})]})}),he,t.jsx(Cn,{className:"mt-1",children:ge})]})})})}const Ss=s=>s.trim().replace(/^refs\/heads\//,"").replace(/^heads\//,"").replace(/\s+/g,"-").replace(/^\/+|\/+$/g,""),yd=s=>String(s).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"pr-head",mr=(s,e,n)=>{const r=Ss(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(f=>{const u=f.indexOf("/");return u<=0||u>=f.length-1?!1:f.slice(u+1)===r});if(o){const f=o.indexOf("/"),u=o.slice(0,f);return{existingBranch:`remotes/${o}`,setUpstream:!0,upstreamRemote:u,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${u}/${r}`}}const a=String(s.headLabel||"").split(":")[0]?.trim(),i=s.headRepo?.owner||a||"pr-head",c=`pr-${yd(i)}`,l=s.headRepo?.cloneUrl||s.headRepo?.sshUrl||"";if(!l)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/${c}/${r}`,setUpstream:!0,upstreamRemote:c,upstreamBranch:r,ensureRemoteName:c,ensureRemoteUrl:l,sourceLabel:`${c}/${r}`}},wt=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),wd=s=>{const e={repo:s.repo??null,issue:s.issue,comments:s.comments};return`GitHub issue context (JSON)
3
- ${JSON.stringify(e,null,2)}`},vd=s=>`GitHub pull request context (JSON)
4
- ${JSON.stringify(s,null,2)}`,Sd=s=>{const e={issue:s.issue,comments:s.comments};return`Linear issue context (JSON)
5
- ${JSON.stringify(e,null,2)}`};function mm({open:s,onOpenChange:e,onWorktreeCreated:n}){const{t:r}=st(),{github:o,git:a,linear:i}=Ks(),c=Ue(y=>y.isMobile),l=Ns(y=>y.status),f=Ns(y=>y.hasChecked),u=yn(y=>y.status),m=yn(y=>y.hasChecked),w=Tt(y=>y.getActiveProject()),h=w?.path??null,b=le.useMemo(()=>h&&w?{id:w.id,path:h}:null,[w,h]),[g,j]=le.useState("new-branch"),[p,C]=le.useState({branchName:"",worktreeName:"",isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1}),[L,_]=le.useState({selectedBranch:"",worktreeName:""}),F=ka(h),T=Ca(h),x=In(y=>y.fetchBranches),S=le.useMemo(()=>F?.all?F.all.filter(y=>!y.startsWith("remotes/")).sort():[],[F]),I=le.useMemo(()=>F?.all?F.all.filter(y=>y.startsWith("remotes/")).map(y=>y.replace(/^remotes\//,"")).sort():[],[F]),$=tt(y=>y.availableWorktreesByProject),R=le.useMemo(()=>{if(!h)return new Set;const y=$.get(h)??[];return new Set(y.map(G=>G.name))},[$,h]),z=le.useCallback((y=10)=>{for(let G=0;G<y;G++){const Re=As();if(!R.has(Re))return Re}return`${As()}-${Date.now().toString(36).slice(-4)}`},[R]),[q,ne]=le.useState(!1),[Q,H]=le.useState(!1),[X,ue]=le.useState(!1),[V,P]=le.useState(!1),[W,U]=le.useState(!1),[D,Y]=le.useState(!1),[M,K]=le.useState(""),[A,Z]=le.useState(""),ee=le.useRef(null),te=le.useRef(null),fe=le.useRef(null),ce=le.useRef(null),me=le.useCallback(y=>{y.stopPropagation()},[]),re=le.useCallback(y=>{let G=y;for(;G&&G!==document.body;){const{overflowY:Re}=window.getComputedStyle(G);if((Re==="auto"||Re==="scroll")&&G.scrollHeight>G.clientHeight)return G;G=G.parentElement}return null},[]),he=le.useCallback(y=>{y&&(y.scrollTop=0)},[]),ge=le.useCallback(y=>{const G=y.current?.querySelector('[data-slot="command-list"]')??null;he(G)},[he]),v=le.useCallback(y=>{const G=re(y.current);he(G)},[re,he]),J=le.useMemo(()=>fr({localBranches:S,remoteBranches:I,query:M}),[S,I,M]),B=le.useMemo(()=>fr({localBranches:S,remoteBranches:I,query:A}),[S,I,A]),oe=M.trim().length>0,de=A.trim().length>0,pe=J.matching.length>0,Ne=B.matching.length>0,We=!!(h&&a),_e=le.useCallback(()=>{!h||!a||x(h,a)},[h,a,x]);le.useEffect(()=>{!s||!h||!a||F?.all||x(h,a)},[s,h,a,F?.all,x]),le.useEffect(()=>{!X&&!W&&K("")},[X,W]),le.useEffect(()=>{!V&&!D&&Z("")},[V,D]),le.useEffect(()=>{X&&ge(ee),W&&v(fe)},[X,W,M,ge,v]),le.useEffect(()=>{V&&ge(te),D&&v(ce)},[V,D,A,ge,v]);const[be,De]=le.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Ie,Be]=le.useState(!1),[Fe,He]=le.useState(null),Ke=le.useRef(!1),nt=le.useCallback(()=>{const y=kt.getState(),G=y.getVisibleAgents();if(y.settingsDefaultAgent){const Re=G.find(Le=>Le.name===y.settingsDefaultAgent);if(Re)return Re.name}return G.find(Re=>Re.name==="build")?.name||G[0]?.name},[]),Ze=le.useCallback(()=>{const y=kt.getState(),G=y.settingsDefaultModel;if(!G)return null;const Re=Cr(G);if(!Re)return null;const{providerId:Le,modelId:N}=Re;return y.getModelMetadata(Le,N)?{providerID:Le,modelID:N}:null},[]),rt=le.useCallback((y,G)=>{const Re=kt.getState(),Le=Re.settingsDefaultVariant,N=Re.currentProviderId===y&&Re.currentModelId===G?Re.currentVariant:void 0,ve=Re.providers.find(Se=>Se.id===y)?.models.find(Se=>Se.id===G)?.variants;if(!ve)return Le||N||void 0;if(Le&&Object.prototype.hasOwnProperty.call(ve,Le))return Le;if(N&&Object.prototype.hasOwnProperty.call(ve,N))return N},[]),Je=le.useCallback(async y=>{const G=kt.getState(),Re=Pr.getState().lastUsedProvider,Le=Ze(),N=Le?.providerID||G.currentProviderId||Re?.providerID,ie=Le?.modelID||G.currentModelId||Re?.modelID,ye=nt()||G.currentAgentName||void 0;if(!N||!ie){je.error(r("session.newWorktree.error.noModelSelected"));return}const ve=rt(N,ie);if(y.linearIssue){if(!i?.issueGet)return;const Se=await i.issueGet(y.linearIssue.identifier);if(Se.connected===!1||!Se.issue)throw new Error("Failed to load issue context");const Oe=Se.issue,Ge=Oe.comments??[],at=Oe.assignee?.displayName||Oe.assignee?.name,ct=await Vt("linear.issue.review.visible",{identifier:Oe.identifier}),ut=await Vt("linear.issue.review.instructions"),ot=Sd({issue:Oe,comments:Ge});Ia(i,{sessionId:y.sessionId,issueIdentifier:Oe.identifier}),await tt.getState().sendMessage(ct,N,ie,ye,void 0,void 0,[{text:ut,synthetic:!0},{text:ot,synthetic:!0}],ve,void 0,{sessionId:y.sessionId,directory:y.directory}),Qs(y.sessionId,y.directory,Ta({identifier:Oe.identifier,title:Oe.title,url:Oe.url,author:at?{login:at,avatarUrl:Oe.assignee?.avatarUrl||void 0}:y.linearIssue.author,linkedAt:Date.now()}),!0).catch(()=>{}),je.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(!(!h||!o)){if(y.issue){if(!o.issueGet||!o.issueComments)return;const Se=await o.issueGet(h,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(Se.connected===!1||!Se.repo||!Se.issue)throw new Error("Failed to load issue context");const Oe=await o.issueComments(h,y.issue.number,{sourceRepo:y.issue.sourceRepo??null});if(Oe.connected===!1)throw new Error("Failed to load issue comments");const Ge=await Vt("github.issue.review.visible",{issue_number:String(y.issue.number)}),at=await Vt("github.issue.review.instructions"),ct=wd({repo:Se.repo,issue:Se.issue,comments:Oe.comments??[]});await tt.getState().sendMessage(Ge,N,ie,ye,void 0,void 0,[{text:at,synthetic:!0},{text:ct,synthetic:!0}],ve,void 0,{sessionId:y.sessionId}),Qs(y.sessionId,y.directory,$n({url:Se.issue.url,number:Se.issue.number,title:Se.issue.title,kind:"issue",author:Se.issue.author,linkedAt:Date.now()}),!0).catch(()=>{}),je.success(r("session.newWorktree.toast.sessionFromIssue"));return}if(y.pr){if(!o.prContext)return;const Se=await o.prContext(h,y.pr.number,{sourceRepo:y.pr.sourceRepo??null,includeDiff:y.includeDiff,includeCheckDetails:!1});if(Se.connected===!1||!Se.repo||!Se.pr)throw new Error("Failed to load PR context");const Oe=await Vt("github.pr.review.visible",{pr_number:String(y.pr.number)}),Ge=await Vt("github.pr.review.instructions"),at=vd(Se);await tt.getState().sendMessage(Oe,N,ie,ye,void 0,void 0,[{text:Ge,synthetic:!0},{text:at,synthetic:!0}],ve,void 0,{sessionId:y.sessionId}),Qs(y.sessionId,y.directory,$n({url:Se.pr.url,number:Se.pr.number,title:Se.pr.title,kind:"pull",author:Se.pr.author,linkedAt:Date.now()}),!0).catch(()=>{}),je.success(r("session.newWorktree.toast.sessionFromPr"))}}},[o,i,h,nt,Ze,rt,r]),Ve=g==="new-branch"?p:L;le.useEffect(()=>{if(!s||!F?.all||!h||p.sourceBranch)return;const y=p.sourceBranch;let G=!1;return(async()=>{try{const Le=await Da(h).catch(()=>null);if(G)return;const N=localStorage.getItem(rn),{sourceBranch:ie,shouldClearSavedSourceBranch:ye}=xd({branches:F.all,savedSourceBranch:N,rootBranch:Le});if(ye&&localStorage.removeItem(rn),G||y)return;ie&&C(ve=>({...ve,sourceBranch:ie}))}catch{}})(),()=>{G=!0}},[s,F?.all,h,p.sourceBranch]),le.useLayoutEffect(()=>{if(!s){Ke.current=!1;return}if(Ke.current)return;Ke.current=!0,j("new-branch"),_({selectedBranch:"",worktreeName:""}),ue(!1),P(!1),U(!1),Y(!1),K(""),Z(""),De({isValidating:!1,branchError:null,worktreeError:null,touched:!1});const y=z();C({branchName:y,worktreeName:y,isSyncingWorktreeName:!0,sourceBranch:"",linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1})},[s,z]),le.useEffect(()=>{if(g!=="new-branch"||!p.isSyncingWorktreeName)return;const y=Ss(p.branchName),G=wt(y);C(Re=>({...Re,worktreeName:G}))},[g,p.branchName,p.isSyncingWorktreeName]);const Ye=le.useCallback(async()=>{if(!b||!be.touched||Ie)return;Fe&&Fe.abort();const y=new AbortController;He(y),De(G=>({...G,isValidating:!0}));try{const G=g==="new-branch"?p.branchName:L.selectedBranch,Re=Ve.worktreeName,Le=Ss(G),N=wt(Re);let ie=null,ye=null;if(Le||(ie=r("session.newWorktree.error.branchNameRequired")),N||(ye=r("session.newWorktree.error.worktreeDirectoryRequired")),Le&&N){const ve=g==="new-branch"?p.linkedPr:null,Se=ve?mr(ve,S,I):null,Oe={mode:g==="existing-branch"||Se?"existing":"new",branchName:Le,worktreeName:N,existingBranch:Se?.existingBranch??(g==="existing-branch"?Le:void 0)};Se?.ensureRemoteName&&(Oe.ensureRemoteName=Se.ensureRemoteName),Se?.ensureRemoteUrl&&(Oe.ensureRemoteUrl=Se.ensureRemoteUrl);const Ge=await Tr(b,Oe);if(y.signal.aborted)return;Ge.ok||Ge.errors.forEach(at=>{if(at.code==="worktree_exists"){ye=ye??at.message;return}at.code.startsWith("branch_")&&(ie=ie??at.message)})}y.signal.aborted||De(ve=>({...ve,isValidating:!1,branchError:ie,worktreeError:ye}))}catch{y.signal.aborted||De(G=>({...G,isValidating:!1}))}},[b,g,p.branchName,p.linkedPr,L.selectedBranch,Ve.worktreeName,S,I,be.touched,Fe,Ie,r]),ze=g==="new-branch"?p.branchName:L.selectedBranch;le.useEffect(()=>{if(!s||!b||!be.touched||Ie)return;const y=setTimeout(()=>{Ye()},300);return()=>clearTimeout(y)},[Ve.worktreeName,ze,s,b,Ye,be.touched,Ie]);const xe=async()=>{if(!b||!h){je.error(r("session.newWorktree.error.noActiveProject"));return}De(N=>({...N,touched:!0}));const y=g==="new-branch"?p.branchName:L.selectedBranch,G=Ve.worktreeName,Re=Ss(y),Le=wt(G);if(!Re){je.error(r("session.newWorktree.error.branchNameRequired"));return}if(!Le){je.error(r("session.newWorktree.error.worktreeDirectoryRequired"));return}Fe&&(Fe.abort(),He(null)),De(N=>({...N,isValidating:!1,branchError:null,worktreeError:null})),Be(!0);try{const N=g==="new-branch"?p.linkedPr:null,ie=g==="new-branch"?p.linkedIssue:null,ye=g==="new-branch"?p.linkedLinearIssue:null,ve=g==="new-branch"?p.linkedPr:null,Se=g==="new-branch"?p.includePrDiff:!1,Oe=!!(ie||ve||ye),Ge=await jr(b),at=p.sourceBranch;let ct="";const ut=(()=>{if(N){const se=mr(N,S,I);ct=se.sourceLabel;const Ce={preferredName:Re||Le,mode:"existing",branchName:Re,worktreeName:Le,existingBranch:se.existingBranch,setupCommands:Ge,setUpstream:se.setUpstream,upstreamRemote:se.upstreamRemote,upstreamBranch:se.upstreamBranch,returnAfterDirectoryCreated:!0};return se.ensureRemoteName&&(Ce.ensureRemoteName=se.ensureRemoteName),se.ensureRemoteUrl&&(Ce.ensureRemoteUrl=se.ensureRemoteUrl),Ce}ct=g==="new-branch"?at:"";const O={preferredName:Re||Le,mode:g==="existing-branch"?"existing":"new",branchName:g==="existing-branch"?void 0:Re,worktreeName:Le,existingBranch:g==="existing-branch"?Re:void 0,setupCommands:Ge,returnAfterDirectoryCreated:!0};return at&&g==="new-branch"&&(O.startRef=at),O})(),ot=await Ea(b,ut);let bt=null;if(Oe){await Nr(b)&&await Ra(ot.path);const O=ye?`${ye.identifier} ${ye.title}`.trim():ie?`#${ie.number} ${ie.title}`.trim():ve?`#${ve.number} ${ve.title}`.trim():r("session.newWorktree.newSessionTitle"),se=await Aa(O,ot.path,null);if(!se?.id)throw new Error("Failed to create session");bt=se.id,n?.(ot.path,{sessionId:bt}),e(!1),Be(!1),Ba(se.id,O).catch(()=>{});try{tt.getState().initializeNewAiWorkerSession(se.id,kt.getState().agents)}catch{}}else e(!1),Be(!1);const k=gd({mode:g,sourceBranch:p.sourceBranch,linkedPr:!!p.linkedPr,selectedBranch:L.selectedBranch});k&&localStorage.setItem(rn,k),je.success(r("session.newWorktree.toast.worktreeCreated"),{description:r("session.newWorktree.toast.worktreeCreatedDescription",{target:`${ot.branch||ot.name}${ct?` ${r("session.newWorktree.fromSource",{source:ct})}`:""}`})}),bt?Je({sessionId:bt,directory:ot.path,issue:ie,pr:ve,linearIssue:ye,includeDiff:Se}).catch(O=>{const se=r(ye?"session.newWorktree.error.sendLinearContextFailed":"session.newWorktree.error.sendGitHubContextFailed"),Ce=O instanceof Error?O.message:se;je.error(se,{description:Ce})}):n?.(ot.path)}catch(N){const ie=N instanceof Error?N.message:r("session.newWorktree.error.createWorktreeFailed");je.error(r("session.newWorktree.error.createWorktreeFailed"),{description:ie})}finally{Be(!1)}},et=y=>{j(y),De(G=>({...G,touched:!1,branchError:null,worktreeError:null}))},Me=y=>{if(!y){C(G=>({...G,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:""}));return}if(y.type==="issue"){const G=y.item,Re=`issue-${G.number}-${As()}`;C(Le=>({...Le,linkedIssue:G,linkedPr:null,linkedLinearIssue:null,includePrDiff:!1,branchName:Re,worktreeName:wt(Re),isSyncingWorktreeName:!0}))}else if(y.type==="pr"){const G=y.item;C(Re=>({...Re,linkedPr:G,linkedIssue:null,linkedLinearIssue:null,includePrDiff:y.includeDiff??!1,branchName:G.head,worktreeName:wt(G.head),isSyncingWorktreeName:!0}))}},ke=y=>{const G=`issue-${y.identifier}-${As()}`;C(Re=>({...Re,linkedLinearIssue:{identifier:y.identifier,title:y.title,url:y.url,author:y.author},linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:G,worktreeName:wt(G),isSyncingWorktreeName:!0}))},Qe=f&&l?.connected===!0,Ee=!!i&&m&&u?.connected===!0,pt=(g==="existing-branch"?!!L.selectedBranch&&!!L.worktreeName&&!be.branchError&&!be.worktreeError:!!Ss(p.branchName)&&!!p.worktreeName&&!be.branchError&&!be.worktreeError)&&!Ie,ft=()=>{C(y=>({...y,linkedIssue:null,linkedPr:null,linkedLinearIssue:null,branchName:"",includePrDiff:!1,isSyncingWorktreeName:!0}))},gt=g==="new-branch"&&(Qe||Ee)?t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[Qe&&t.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>ne(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromGitHubIssuePr"),"aria-label":r("session.newWorktree.actions.startFromGitHubIssuePr"),children:t.jsx(E,{name:"github",className:"size-4 text-status-success"})}),Ee&&t.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"h-8 w-8 px-0",title:r("session.newWorktree.actions.startFromLinearIssue"),"aria-label":r("session.newWorktree.actions.startFromLinearIssue"),children:t.jsx(E,{name:"linear",className:"size-4"})})]}):null,Ct=t.jsxs("div",{className:ae("flex gap-2",c?"flex-col w-full":"flex-row items-center"),children:[t.jsx("div",{className:ae("flex items-center gap-1.5 text-destructive",c?"w-full justify-center order-first":"mr-auto"),children:be.touched&&(be.branchError||be.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:be.branchError||be.worktreeError})]})}),t.jsxs("div",{className:ae("flex gap-2",c&&"w-full"),children:[t.jsx(Pe,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,className:ae(c&&"flex-1"),children:r("session.newWorktree.actions.cancel")}),t.jsxs(Pe,{size:"sm",onClick:xe,disabled:!pt||Ie,className:ae("gap-1.5",c&&"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:[c?t.jsxs(us,{open:s,title:r("session.newWorktree.title"),onClose:()=>e(!1),footer:Ct,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:g,onSelect:y=>{(y==="new-branch"||y==="existing-branch")&&et(y)},variant:"active-pill",layoutMode:"fit",className:"w-full"})}),t.jsxs("div",{className:"space-y-6",children:[g==="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(Pe,{variant:"outline",size:"sm",onClick:()=>U(!0),className:"flex-1 justify-between h-9",children:[t.jsx("span",{className:L.selectedBranch?"text-foreground":"text-muted-foreground",children:L.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:_e,disabled:!We||T,title:r("session.newWorktree.fetchBranches"),children:T?t.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(E,{name:"refresh",className:"size-4"})})]}),t.jsx(us,{open:W,title:r("session.newWorktree.selectBranch"),onClose:()=>U(!1),children:t.jsxs("div",{className:"space-y-4",ref:fe,children:[t.jsx(St,{value:M,onChange:y=>K(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),T?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&I.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:[oe&&pe&&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:J.matching.map(y=>t.jsx("button",{onClick:()=>{_(G=>({...G,selectedBranch:y.value,worktreeName:wt(y.label)})),De(G=>({...G,touched:!0})),U(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",L.selectedBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),oe&&!pe&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!oe&&J.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("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:J.otherLocal.map(y=>t.jsx("button",{onClick:()=>{_(G=>({...G,selectedBranch:y,worktreeName:wt(y)})),De(G=>({...G,touched:!0})),U(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",L.selectedBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!oe&&J.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("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:J.otherRemote.map(y=>t.jsx("button",{onClick:()=>{_(G=>({...G,selectedBranch:`remotes/${y}`,worktreeName:wt(y)})),De(G=>({...G,touched:!0})),U(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",L.selectedBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),gt]}),t.jsx(St,{value:p.branchName,onChange:y=>{C(G=>({...G,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>De(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:ae("h-8",be.touched&&be.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.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:p.linkedPr.head})})]}),p.linkedIssue&&!p.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:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&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.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.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")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=wt(g==="new-branch"?p.branchName:"");C(G=>({...G,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===wt(p.branchName),className:ae("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===wt(p.branchName)||!p.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(St,{value:Ve.worktreeName,onChange:y=>{g==="new-branch"?C(G=>({...G,worktreeName:y.target.value,isSyncingWorktreeName:!1})):_(G=>({...G,worktreeName:y.target.value}))},onBlur:()=>De(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ae("h-8",be.touched&&be.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.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(Pe,{variant:"outline",size:"sm",onClick:()=>Y(!0),className:"w-full justify-between h-9",children:[t.jsx("span",{className:p.sourceBranch?"text-foreground":"text-muted-foreground",children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})}),t.jsx(us,{open:D,title:r("session.newWorktree.selectSourceBranch"),onClose:()=>Y(!1),children:t.jsxs("div",{className:"space-y-4",ref:ce,children:[t.jsx(St,{value:A,onChange:y=>Z(y.target.value),placeholder:r("session.newWorktree.searchBranches"),className:"h-8"}),T?t.jsx("div",{className:"px-2 py-8 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&I.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:[de&&Ne&&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:B.matching.map(y=>t.jsx("button",{onClick:()=>{C(G=>({...G,sourceBranch:y.value})),Y(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y.value?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))})]}),de&&!Ne&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!de&&B.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("session.newWorktree.localBranches")}),t.jsx("div",{className:"space-y-1",children:B.otherLocal.map(y=>t.jsx("button",{onClick:()=>{C(G=>({...G,sourceBranch:y})),Y(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===y?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},y))})]}),!de&&B.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("session.newWorktree.remoteBranches")}),t.jsx("div",{className:"space-y-1",children:B.otherRemote.map(y=>t.jsx("button",{onClick:()=>{C(G=>({...G,sourceBranch:`remotes/${y}`})),Y(!1)},className:ae("w-full text-left px-3 py-2.5 rounded-md transition-colors",p.sourceBranch===`remotes/${y}`?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:t.jsx("span",{className:"typography-small break-all",children:y})},`remotes/${y}`))})]})]})]})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="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:p.linkedLinearIssue?"linear":"github",className:ae("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ft,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.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:[p.linkedPr.head," → ",p.linkedPr.base]}),p.includePrDiff&&t.jsx("span",{className:"typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success",children:r("session.newWorktree.includeDiffBadge")})]})]})]})]}):t.jsx(Is,{open:s,onOpenChange:e,children:t.jsxs(Ts,{className:"max-w-lg max-h-[80vh] flex flex-col",children:[t.jsx(Gs,{className:"flex flex-row items-center justify-between",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(Ps,{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:g,onSelect:y=>{(y==="new-branch"||y==="existing-branch")&&et(y)},variant:"active-pill",layoutMode:"fit",className:"w-full"})})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto mt-2 space-y-6",children:[g==="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(Gt,{open:X,onOpenChange:ue,children:[t.jsx(Ht,{asChild:!0,children:t.jsxs("button",{type:"button",className:ae(Un({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ae("truncate",L.selectedBranch?"text-foreground":"text-muted-foreground"),children:L.selectedBranch||r("session.newWorktree.chooseBranch")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Kt,{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:ee,children:t.jsxs(hn,{shouldFilter:!1,children:[t.jsx(pn,{placeholder:r("session.newWorktree.searchBranches"),value:M,onValueChange:K,onKeyDown:me}),t.jsx(gn,{disableHorizontal:!0,children:T?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&I.length===0?t.jsx(xn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[oe&&pe&&t.jsx(At,{heading:r("session.newWorktree.matchingBranches"),children:J.matching.map(y=>t.jsx(Et,{value:y.value,onSelect:()=>{_(G=>({...G,selectedBranch:y.value,worktreeName:wt(y.label)})),De(G=>({...G,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),oe&&!pe&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!oe&&J.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(At,{heading:r("session.newWorktree.localBranches"),children:J.otherLocal.map(y=>t.jsx(Et,{value:y,onSelect:()=>{_(G=>({...G,selectedBranch:y,worktreeName:wt(y)})),De(G=>({...G,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!oe&&J.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[J.otherLocal.length>0&&t.jsx(js,{}),t.jsx(At,{heading:r("session.newWorktree.remoteBranches"),children:J.otherRemote.map(y=>t.jsx(Et,{value:`remotes/${y}`,onSelect:()=>{_(G=>({...G,selectedBranch:`remotes/${y}`,worktreeName:wt(y)})),De(G=>({...G,touched:!0})),ue(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),t.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 shrink-0",onClick:_e,disabled:!We||T,title:r("session.newWorktree.fetchBranches"),children:T?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 gap-2",children:[t.jsx("label",{className:"typography-ui-label text-foreground font-semibold shrink-0",children:r("session.newWorktree.branchName")}),gt]}),t.jsx(St,{value:p.branchName,onChange:y=>{C(G=>({...G,branchName:y.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null,linkedLinearIssue:null}))},onBlur:()=>De(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.branchNamePlaceholder"),disabled:!!p.linkedPr,className:ae("h-8",be.touched&&be.branchError&&"border-destructive",p.linkedPr&&"bg-muted text-muted-foreground")}),p.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:p.linkedPr.head})})]}),p.linkedIssue&&!p.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:p.linkedIssue.number,title:p.linkedIssue.title})})]}),p.linkedLinearIssue&&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.fromLinearIssue",{identifier:p.linkedLinearIssue.identifier,title:p.linkedLinearIssue.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")}),g!=="existing-branch"&&t.jsxs("button",{onClick:()=>{const y=wt(g==="new-branch"?p.branchName:"");C(G=>({...G,worktreeName:y,isSyncingWorktreeName:!0}))},disabled:!p.branchName||p.worktreeName===wt(p.branchName),className:ae("flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded",p.worktreeName===wt(p.branchName)||!p.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(St,{value:Ve.worktreeName,onChange:y=>{g==="new-branch"?C(G=>({...G,worktreeName:y.target.value,isSyncingWorktreeName:!1})):_(G=>({...G,worktreeName:y.target.value}))},onBlur:()=>De(y=>({...y,touched:!0})),placeholder:r("session.newWorktree.worktreeDirectoryPlaceholder"),className:ae("h-8",be.touched&&be.worktreeError&&"border-destructive")})]}),g==="new-branch"&&!p.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(Gt,{open:V,onOpenChange:P,children:[t.jsx(Ht,{asChild:!0,children:t.jsxs("button",{type:"button",className:ae(Un({size:"default"}),"min-w-[220px] max-w-full"),children:[t.jsx("span",{className:ae("truncate",p.sourceBranch?"text-foreground":"text-muted-foreground"),children:p.sourceBranch||r("session.newWorktree.selectSourceBranchPlaceholder")}),t.jsx(E,{name:"arrow-down-s",className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),t.jsx(Kt,{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:te,children:t.jsxs(hn,{shouldFilter:!1,children:[t.jsx(pn,{placeholder:r("session.newWorktree.searchBranches"),value:A,onValueChange:Z,onKeyDown:me}),t.jsx(gn,{disableHorizontal:!0,children:T?t.jsx("div",{className:"px-2 py-4 text-center typography-small text-muted-foreground",children:r("session.newWorktree.loadingBranches")}):S.length===0&&I.length===0?t.jsx(xn,{children:r("session.newWorktree.noBranchesFound")}):t.jsxs(t.Fragment,{children:[de&&Ne&&t.jsx(At,{heading:r("session.newWorktree.matchingBranches"),children:B.matching.map(y=>t.jsx(Et,{value:y.value,onSelect:()=>{C(G=>({...G,sourceBranch:y.value})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y.label})},`${y.source}-${y.value}`))}),de&&!Ne&&t.jsx("div",{className:"px-2 py-1 text-center typography-small text-muted-foreground",children:r("session.newWorktree.noMatchingBranches")}),!de&&B.otherLocal.length>0&&t.jsx(t.Fragment,{children:t.jsx(At,{heading:r("session.newWorktree.localBranches"),children:B.otherLocal.map(y=>t.jsx(Et,{value:y,onSelect:()=>{C(G=>({...G,sourceBranch:y})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`local-${y}`))})}),!de&&B.otherRemote.length>0&&t.jsxs(t.Fragment,{children:[B.otherLocal.length>0&&t.jsx(js,{}),t.jsx(At,{heading:r("session.newWorktree.remoteBranches"),children:B.otherRemote.map(y=>t.jsx(Et,{value:`remotes/${y}`,onSelect:()=>{C(G=>({...G,sourceBranch:`remotes/${y}`})),P(!1)},children:t.jsx("span",{className:"typography-small break-all",children:y})},`remote-${y}`))})]})]})})]})})]}),p.sourceBranch&&t.jsx("div",{className:"typography-micro text-muted-foreground",children:r("session.newWorktree.newBranchFromSource",{source:p.sourceBranch})})]}),(p.linkedIssue||p.linkedPr||p.linkedLinearIssue)&&g==="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:p.linkedLinearIssue?"linear":"github",className:ae("h-3.5 w-3.5 shrink-0",p.linkedLinearIssue?"text-foreground":"text-status-success")}),p.linkedLinearIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:p.linkedLinearIssue.identifier}),p.linkedIssue&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.issueNumber",{number:p.linkedIssue.number})}),p.linkedPr&&t.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:r("session.newWorktree.prNumber",{number:p.linkedPr.number})}),t.jsx("span",{className:"typography-micro text-foreground truncate flex-1",children:p.linkedLinearIssue?.title||p.linkedIssue?.title||p.linkedPr?.title}),t.jsx("a",{href:p.linkedLinearIssue?.url||p.linkedIssue?.url||p.linkedPr?.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0",onClick:y=>y.stopPropagation(),children:t.jsx(E,{name:"external-link",className:"h-3 w-3"})}),t.jsx("button",{onClick:ft,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.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:[p.linkedPr.head," → ",p.linkedPr.base]}),p.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:be.touched&&(be.branchError||be.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:be.branchError||be.worktreeError})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pe,{variant:"outline",size:"sm",onClick:()=>e(!1),disabled:Ie,children:r("session.newWorktree.actions.cancel")}),t.jsxs(Pe,{size:"sm",onClick:xe,disabled:!pt||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(bd,{open:q,onOpenChange:ne,onSelect:Me}),t.jsx(Pa,{open:Q,onOpenChange:H,mode:"select",onSelect:ke})]})}const jd=2880*60*1e3,Nd=s=>!!s.parentID,kd=s=>!!s.time?.archived,Cd=s=>{const e=s.time?.updated,n=s.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},Id=(s,e,n=Date.now())=>{const r=n-jd;return s.filter(o=>kd(o)||Nd(o)?!1:e.has(o.id)||Cd(o)>=r)},hm=({sessions:s,getSessionLocation:e,getSessionNode:n,query:r})=>[{key:"active-now",items:s.flatMap(o=>{const a=typeof o.title=="string"?o.title.toLowerCase():"";if(r&&!a.includes(r))return[];const i=e(o.id);return[{node:n?.(o)??{session:o,children:[],worktree:null},projectId:i?.projectId??null,groupDirectory:i?.groupDirectory??o.directory??null,secondaryMeta:i?{projectLabel:i.projectLabel,branchLabel:i.branchLabel}:null}]})}],uo=s=>s.parentID??null,Td=(s,e)=>{const n=[],r=[];for(const o of s)if(!Ma(o)){if(La(o.directory)){if(e)continue;r.push(o);continue}n.push(o)}return{projectSessions:n,chatSessions:r}},Pd=new Set,Dd=(s,e,n)=>{if(s.time?.archived)return!0;const r=Ws(Ir(s))?.toLowerCase();return!r||e.size===0?!n:e.has(r)},Ed=(s,e)=>{const n=[...s],r=new Set(s.map(o=>o.id));for(const o of e)r.has(o.id)||(r.add(o.id),n.push(o));return n},Rd=(s,e)=>{const n=[],r=new Set([e]),o=a=>{for(const i of s.get(a)??[])r.has(i.id)||(r.add(i.id),n.push(i.id),o(i.id))};return o(e),n},Ad=({globalActiveSessions:s,liveSessions:e,knownDirectories:n,isVSCode:r,globalStructure:o})=>{Dr("sidebarStructureBuilds");const i=Ed(s??[],e),c=Td(i,r),l=c.projectSessions.filter(g=>Dd(g,n,r)),f=[...l,...c.chatSessions],u=new Map(f.map(g=>[g.id,g])),m=new Set(l.map(g=>g.id)),w=o?.activeRootIds??[],h=new Set(w),b=[...w.flatMap(g=>{if(!m.has(g))return[];const j=u.get(g);return j?[j]:[]}),...l.filter(g=>!h.has(g.id)&&!uo(g))];return{chatSessionIds:new Set(c.chatSessions.map(g=>g.id)),projectSessions:l,rootSessions:b,sessionById:u,sessions:f,hierarchy:o?{rootIds:o.activeRootIds,childrenByParentId:o.activeChildrenByParentId}:void 0}},Bd=(s,e,n)=>{const r=Er(s.sessions,e,n,s.hierarchy),o=new Map;for(const a of r){const i=uo(a);if(!i)continue;const c=o.get(i)??[];c.push(a),o.set(i,c)}return{chatSessions:r.filter(a=>s.chatSessionIds.has(a.id)),childrenMap:o,orderedSessions:r}},pm=s=>{const e=$e.c(33),{knownDirectories:n,isVSCode:r,isVisible:o}=s,a=Jt(Md),i=Jt(Ld),c=Jt(Fd),l=Jt(Od),f=Fa(),u=Oa(_d);let m;e[0]!==o?(m=R=>o?R.rankById:Ua,e[0]=o,e[1]=m):m=e[1];const w=_a(m);let h;e[2]!==a||e[3]!==i||e[4]!==r||e[5]!==n||e[6]!==f?(h=Ad({globalActiveSessions:a,globalStructure:i,liveSessions:f,knownDirectories:n,isVSCode:r}),e[2]=a,e[3]=i,e[4]=r,e[5]=n,e[6]=f,e[7]=h):h=e[7];const b=h;let g;e[8]!==u||e[9]!==w||e[10]!==b?(g=Bd(b,u,w),e[8]=u,e[9]=w,e[10]=b,e[11]=g):g=e[11];const j=g,{chatSessions:p,orderedSessions:C}=j,L=b.projectSessions;let _;e[12]!==c||e[13]!==b.sessions?(_=new Map([...b.sessions,...c].map($d)),e[12]=c,e[13]=b.sessions,e[14]=_):_=e[14];const F=_;let T;if(e[15]!==c||e[16]!==j.childrenMap){T=new Map(j.childrenMap);for(const R of c){const z=R.parentID;if(!z)continue;const q=T.get(z)??[];q.push(R),T.set(z,q)}e[15]=c,e[16]=j.childrenMap,e[17]=T}else T=e[17];const x=T;let S;e[18]!==x||e[19]!==F?(S=(R,z)=>Rd(x,R).filter(q=>z.includeArchived||!F.get(q)?.time?.archived),e[18]=x,e[19]=F,e[20]=S):S=e[20];const I=S;let $;return e[21]!==c||e[22]!==p||e[23]!==x||e[24]!==I||e[25]!==l||e[26]!==f||e[27]!==C||e[28]!==u||e[29]!==w||e[30]!==L||e[31]!==b.rootSessions?($={archivedSessions:c,childrenMap:x,chatSessions:p,getDescendantIds:I,hasAuthoritativeGlobalSessions:l,liveSessions:f,orderedSessions:C,pinnedSessionIds:u,sessionOrderRanks:w,sessions:L,rootSessions:b.rootSessions},e[21]=c,e[22]=p,e[23]=x,e[24]=I,e[25]=l,e[26]=f,e[27]=C,e[28]=u,e[29]=w,e[30]=L,e[31]=b.rootSessions,e[32]=$):$=e[32],$},gm=s=>{const e=$e.c(9),{enabled:n,isVSCode:r,pinnedSessionIds:o,sessionOrderRanks:a,sessions:i}=s;let c;e[0]!==n||e[1]!==r?(c=u=>n&&!r?u.activeSessionIds:Pd,e[0]=n,e[1]=r,e[2]=c):c=e[2];const l=$a(c);let f;e:{if(!n||r){let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[3]=m):m=e[3],f=m;break e}Dr("recentCandidatesVisited",i.length);let u;e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==i?(u=Er(Id(i,l),o,a),e[4]=l,e[5]=o,e[6]=a,e[7]=i,e[8]=u):u=e[8],f=u}return f};function Md(s){return s.activeSessions}function Ld(s){return s.structure}function Fd(s){return s.archivedSessions}function Od(s){return s.status==="ready"}function _d(s){return s.ids}function $d(s){return[s.id,s]}const An=(s,e)=>s==="global"?"global":`project:${e??""}`,fo=(s,e)=>s.createdAt>e?"new":s.updatedAt>e?"changed":null,hr=(s,e)=>s.reduce((n,r)=>fo(r,e)?n+1:n,0),mo=s=>{const e=$e.c(29),{expanded:n,onToggleExpanded:r,header:o,children:a,actions:i,footer:c,expandLabel:l}=s,{t:f}=st(),u=!n&&"cursor-pointer hover:border-[var(--interactive-border)] hover:bg-interactive-hover/30";let m;e[0]!==u?(m=ae("flex flex-col gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 py-1.5",u),e[0]=u,e[1]=m):m=e[1];const w=n?void 0:r;let h;e[2]!==n||e[3]!==r?(h=n?void 0:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r())},e[2]=n,e[3]=r,e[4]=h):h=e[4];const b=n?void 0:"button",g=n?void 0:0,j=n?void 0:l;let p;e[5]!==a||e[6]!==o?(p=t.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[5]=a,e[6]=o,e[7]=p):p=e[7];let C;e[8]!==n||e[9]!==r||e[10]!==f?(C=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":f("rightSidebar.contextNotesTodo.notes.actions.collapse"),title:f("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]=f,e[11]=C):C=e[11];let L;e[12]!==i||e[13]!==C?(L=t.jsxs("div",{className:"flex flex-shrink-0 flex-col items-center gap-0.5",onClick:Ud,onKeyDown:Wd,children:[C,i]}),e[12]=i,e[13]=C,e[14]=L):L=e[14];let _;e[15]!==L||e[16]!==p?(_=t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[p,L]}),e[15]=L,e[16]=p,e[17]=_):_=e[17];let F;e[18]!==c?(F=c?t.jsx("div",{className:"min-w-0",children:c}):null,e[18]=c,e[19]=F):F=e[19];let T;return e[20]!==_||e[21]!==F||e[22]!==m||e[23]!==w||e[24]!==h||e[25]!==b||e[26]!==g||e[27]!==j?(T=t.jsxs("li",{className:m,onClick:w,onKeyDown:h,role:b,tabIndex:g,"aria-label":j,children:[_,F]}),e[20]=_,e[21]=F,e[22]=m,e[23]=w,e[24]=h,e[25]=b,e[26]=g,e[27]=j,e[28]=T):T=e[28],T};function Ud(s){return s.stopPropagation()}function Wd(s){return s.stopPropagation()}const Vd=s=>{const e=$e.c(52),{entry:n,badge:r,expanded:o,onToggleExpanded:a,onSave:i,onDelete:c}=s,{t:l}=st(),[f,u]=d.useState(n.title),[m,w]=d.useState(n.body);let h,b;e[0]!==n.body||e[1]!==n.title||e[2]!==o?(h=()=>{o||(u(n.title),w(n.body))},b=[n.body,n.title,o],e[0]=n.body,e[1]=n.title,e[2]=o,e[3]=h,e[4]=b):(h=e[3],b=e[4]),d.useEffect(h,b);let g;e[5]!==m||e[6]!==n.body||e[7]!==n.title||e[8]!==i||e[9]!==f?(g=()=>{const Q=f.trim(),H=m.trim();if(!Q||!H){u(n.title),w(n.body);return}Q===n.title&&H===n.body||i({title:Q,body:H})},e[5]=m,e[6]=n.body,e[7]=n.title,e[8]=i,e[9]=f,e[10]=g):g=e[10];const j=g,p=`rightSidebar.contextNotesTodo.memory.type.${n.type}`;let C;e[11]!==l||e[12]!==p?(C=l(p),e[11]=l,e[12]=p,e[13]=C):C=e[13];const L=C;let _;e[14]!==j||e[15]!==o||e[16]!==a?(_=()=>{o&&j(),a()},e[14]=j,e[15]=o,e[16]=a,e[17]=_):_=e[17];const F=n.title;let T;e[18]!==n.flagged||e[19]!==l?(T=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"}),l("rightSidebar.contextNotesTodo.memory.flagged")]}):null,e[18]=n.flagged,e[19]=l,e[20]=T):T=e[20];let x;e[21]!==T||e[22]!==L?(x=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 typography-micro text-muted-foreground",children:[L,T]}),e[21]=T,e[22]=L,e[23]=x):x=e[23];let S;e[24]!==r||e[25]!==l?(S=r?t.jsx("span",{className:ae("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:l(r==="new"?"rightSidebar.contextNotesTodo.memory.badge.new":"rightSidebar.contextNotesTodo.memory.badge.changed")}):null,e[24]=r,e[25]=l,e[26]=S):S=e[26];let I;e[27]!==l?(I=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[27]=l,e[28]=I):I=e[28];let $;e[29]!==l?($=l("rightSidebar.contextNotesTodo.memory.actions.delete"),e[29]=l,e[30]=$):$=e[30];let R;e[31]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"}),e[31]=R):R=e[31];let z;e[32]!==c||e[33]!==I||e[34]!==$?(z=t.jsx("button",{type:"button",onClick:c,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":I,title:$,children:R}),e[32]=c,e[33]=I,e[34]=$,e[35]=z):z=e[35];let q;e[36]!==m||e[37]!==j||e[38]!==n.body||e[39]!==n.title||e[40]!==o||e[41]!==l||e[42]!==f?(q=o?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(St,{value:f,onChange:Q=>u(Q.target.value.slice(0,Wa)),onBlur:j,"aria-label":l("rightSidebar.contextNotesTodo.memory.actions.editTitle"),className:"h-7 typography-ui-label"}),t.jsx(Hs,{simple:!0,rows:Math.min(20,Math.max(3,m.split(`
6
- `).length+1)),value:m,onChange:Q=>w(Q.target.value.slice(0,Va)),onBlur:j,"aria-label":l("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]=m,e[37]=j,e[38]=n.body,e[39]=n.title,e[40]=o,e[41]=l,e[42]=f,e[43]=q):q=e[43];let ne;return e[44]!==n.title||e[45]!==o||e[46]!==S||e[47]!==z||e[48]!==q||e[49]!==_||e[50]!==x?(ne=t.jsx(mo,{expanded:o,onToggleExpanded:_,expandLabel:F,footer:x,header:S,actions:z,children:q}),e[44]=n.title,e[45]=o,e[46]=S,e[47]=z,e[48]=q,e[49]=_,e[50]=x,e[51]=ne):ne=e[51],ne},zd=s=>{const e=$e.c(59),{projectPath:n,query:r}=s,{t:o}=st(),[a,i]=d.useState("project"),[c,l]=d.useState(null),f=Dt(Gd);let u;e[0]!==n?(u=ee=>Rr(ee,n),e[0]=n,e[1]=u):u=e[1];const m=Dt(u),w=Dt(Hd),h=Dt(Kd),b=Dt(qd),g=Dt(Jd),j=Ue(Yd),p=a==="global"?f:m,C=a==="global"?w:h;let L;e[2]!==n||e[3]!==a?(L=An(a,n),e[2]=n,e[3]=a,e[4]=L):L=e[4];const _=L;let F;e[5]!==_?(F=ee=>ee.agentMemoryViewedAt[_]??0,e[5]=_,e[6]=F):F=e[6];const T=Ue(F),x=d.useRef(T),[S,I]=d.useState(T);let $,R;e[7]!==j||e[8]!==_?($=()=>(x.current=Ue.getState().agentMemoryViewedAt[_]??0,I(x.current),()=>{j(_,Date.now())}),R=[j,_],e[7]=j,e[8]=_,e[9]=$,e[10]=R):($=e[9],R=e[10]),d.useEffect($,R);let z;if(e[11]!==p||e[12]!==r){let ee;e[14]!==r?(ee=te=>qs([te.title,te.body],r),e[14]=r,e[15]=ee):ee=e[15],z=p.filter(ee),e[11]=p,e[12]=r,e[13]=z}else z=e[13];const q=z;let ne;e[16]!==b||e[17]!==a||e[18]!==o?(ne=async ee=>{if(!await b(a,ee)){const te=Dt.getState().error;je.error(o("rightSidebar.contextNotesTodo.memory.toast.deleteFailed"),te?{description:te}:void 0)}},e[16]=b,e[17]=a,e[18]=o,e[19]=ne):ne=e[19];const Q=ne;let H;e[20]!==g||e[21]!==a||e[22]!==o?(H=async(ee,te)=>{if(!await g(a,ee,te)){const fe=Dt.getState().error;je.error(o("rightSidebar.contextNotesTodo.memory.toast.saveFailed"),fe?{description:fe}:void 0)}},e[20]=g,e[21]=a,e[22]=o,e[23]=H):H=e[23];const X=H;let ue;e[24]!==o?(ue=o("rightSidebar.contextNotesTodo.memory.scope.project"),e[24]=o,e[25]=ue):ue=e[25];let V;e[26]!==m.length||e[27]!==ue?(V={id:"project",label:ue,count:m.length},e[26]=m.length,e[27]=ue,e[28]=V):V=e[28];let P;e[29]!==o?(P=o("rightSidebar.contextNotesTodo.memory.scope.global"),e[29]=o,e[30]=P):P=e[30];let W;e[31]!==f.length||e[32]!==P?(W={id:"global",label:P,count:f.length},e[31]=f.length,e[32]=P,e[33]=W):W=e[33];let U;e[34]!==V||e[35]!==W?(U=[V,W],e[34]=V,e[35]=W,e[36]=U):U=e[36];const D=U;let Y;e[37]!==o?(Y=o("rightSidebar.contextNotesTodo.memory.scope.label"),e[37]=o,e[38]=Y):Y=e[38];let M;e[39]!==a||e[40]!==D?(M=D.map(ee=>t.jsx(Pe,{type:"button",variant:"chip",size:"xs","aria-pressed":a===ee.id,className:"!font-normal",onClick:()=>i(ee.id),children:`${ee.label} ${ee.count}`},ee.id)),e[39]=a,e[40]=D,e[41]=M):M=e[41];let K;e[42]!==Y||e[43]!==M?(K=t.jsx("div",{role:"group","aria-label":Y,className:"flex items-center gap-1",children:M}),e[42]=Y,e[43]=M,e[44]=K):K=e[44];let A;e[45]!==S||e[46]!==c||e[47]!==Q||e[48]!==X||e[49]!==n||e[50]!==r||e[51]!==a||e[52]!==C||e[53]!==o||e[54]!==q?(A=a==="project"&&!n?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.noProject")}):C?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o("rightSidebar.contextNotesTodo.memory.empty.unavailable")}):q.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:q.map(ee=>t.jsx(Vd,{entry:ee,badge:fo(ee,S),expanded:c===ee.id,onToggleExpanded:()=>l(c===ee.id?null:ee.id),onSave:te=>{X(ee.id,te)},onDelete:()=>{Q(ee.id)}},ee.id))}),e[45]=S,e[46]=c,e[47]=Q,e[48]=X,e[49]=n,e[50]=r,e[51]=a,e[52]=C,e[53]=o,e[54]=q,e[55]=A):A=e[55];let Z;return e[56]!==K||e[57]!==A?(Z=t.jsxs("div",{className:"flex flex-col gap-2",children:[K,A]}),e[56]=K,e[57]=A,e[58]=Z):Z=e[58],Z};function Gd(s){return s.global}function Hd(s){return s.globalFailed}function Kd(s){return s.projectFailed}function qd(s){return s.deleteEntry}function Jd(s){return s.saveEntry}function Yd(s){return s.markAgentMemoryViewed}const Qd=400,Xd=s=>{const e=$e.c(61),{note:n,pinned:r,expanded:o,onToggleExpanded:a,onSaveBody:i,onTogglePinned:c,onDelete:l}=s,{t:f}=st(),[u,m]=d.useState(n.body),w=d.useRef(n.body),h=d.useRef(null);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},e[0]=b):b=e[0];const g=b;let j,p;e[1]!==u||e[2]!==n.body?(j=()=>{n.body!==w.current&&u===w.current&&(w.current=n.body,m(n.body))},p=[u,n.body],e[1]=u,e[2]=n.body,e[3]=j,e[4]=p):(j=e[3],p=e[4]),d.useEffect(j,p);let C,L;e[5]!==u||e[6]!==i?(C=()=>{if(u!==w.current)return h.current=window.setTimeout(()=>{h.current=null,u.trim()&&(w.current=u,i(u))},Qd),g},L=[g,u,i],e[5]=u,e[6]=i,e[7]=C,e[8]=L):(C=e[7],L=e[8]),d.useEffect(C,L);let _,F;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>g,F=[g],e[9]=_,e[10]=F):(_=e[9],F=e[10]),d.useEffect(_,F);let T;e[11]!==u||e[12]!==i?(T=()=>{if(g(),u!==w.current){if(!u.trim()){m(w.current);return}w.current=u,i(u)}},e[11]=u,e[12]=i,e[13]=T):T=e[13];const x=T;let S;e[14]!==n.source||e[15]!==f?(S=n.source==="selection"?f("rightSidebar.contextNotesTodo.notes.source.selection"):n.source==="agent"?f("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[14]=n.source,e[15]=f,e[16]=S):S=e[16];const I=S;let $;e[17]!==f?($=f("rightSidebar.contextNotesTodo.notes.actions.expand"),e[17]=f,e[18]=$):$=e[18];let R;e[19]!==I?(R=I?t.jsx("span",{className:"typography-micro text-muted-foreground",children:I}):null,e[19]=I,e[20]=R):R=e[20];const z=r?"text-primary":"text-muted-foreground hover:text-foreground";let q;e[21]!==z?(q=ae("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",z),e[21]=z,e[22]=q):q=e[22];let ne;e[23]!==r||e[24]!==f?(ne=f(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[23]=r,e[24]=f,e[25]=ne):ne=e[25];let Q;e[26]!==r||e[27]!==f?(Q=f(r?"rightSidebar.contextNotesTodo.notes.actions.unpin":"rightSidebar.contextNotesTodo.notes.actions.pin"),e[26]=r,e[27]=f,e[28]=Q):Q=e[28];const H=r?"pushpin-2-fill":"pushpin";let X;e[29]!==H?(X=t.jsx(E,{name:H,className:"h-3.5 w-3.5"}),e[29]=H,e[30]=X):X=e[30];let ue;e[31]!==c||e[32]!==r||e[33]!==q||e[34]!==ne||e[35]!==Q||e[36]!==X?(ue=t.jsx("button",{type:"button",onClick:c,className:q,"aria-pressed":r,"aria-label":ne,title:Q,children:X}),e[31]=c,e[32]=r,e[33]=q,e[34]=ne,e[35]=Q,e[36]=X,e[37]=ue):ue=e[37];let V;e[38]!==f?(V=f("rightSidebar.contextNotesTodo.notes.actions.delete"),e[38]=f,e[39]=V):V=e[39];let P;e[40]!==f?(P=f("rightSidebar.contextNotesTodo.notes.actions.delete"),e[40]=f,e[41]=P):P=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 U;e[43]!==l||e[44]!==V||e[45]!==P?(U=t.jsx("button",{type:"button",onClick:l,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":V,title:P,children:W}),e[43]=l,e[44]=V,e[45]=P,e[46]=U):U=e[46];let D;e[47]!==ue||e[48]!==U?(D=t.jsxs(t.Fragment,{children:[ue,U]}),e[47]=ue,e[48]=U,e[49]=D):D=e[49];let Y;e[50]!==u||e[51]!==o||e[52]!==x?(Y=o?t.jsx(Hs,{simple:!0,autoFocus:!0,rows:Math.min(20,Math.max(3,u.split(`
7
- `).length+1)),value:u,onChange:K=>m(K.target.value.slice(0,wn)),onBlur:x,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:u,children:u}),e[50]=u,e[51]=o,e[52]=x,e[53]=Y):Y=e[53];let M;return e[54]!==o||e[55]!==a||e[56]!==$||e[57]!==R||e[58]!==D||e[59]!==Y?(M=t.jsx(mo,{expanded:o,onToggleExpanded:a,expandLabel:$,footer:R,actions:D,children:Y}),e[54]=o,e[55]=a,e[56]=$,e[57]=R,e[58]=D,e[59]=Y,e[60]=M):M=e[60],M},Zd=s=>{const e=$e.c(69),{projectRef:n,notes:r,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:c}=s,{t:l}=st(),[f,u]=d.useState(""),[m,w]=d.useState(null),h=Ue(eu),b=Ue(tu),g=Rt(su),j=Rt(nu),p=Rt(ru);let C;if(e[0]!==r||e[1]!==a){let A;e[3]!==a?(A=Z=>qs([Z.body],a),e[3]=a,e[4]=A):A=e[4],C=r.filter(A),e[0]=r,e[1]=a,e[2]=C}else C=e[2];const L=C;let _;e[5]!==n?(_=A=>{const Z=Rt.getState().getEntry(n).error;je.error(A,Z?{description:Z}:void 0)},e[5]=n,e[6]=_):_=e[6];const F=_;let T;e[7]!==f||e[8]!==g||e[9]!==n||e[10]!==F||e[11]!==l?(T=async()=>{const A=f.trim();if(!A)return;if(!await g(n,{body:A})){F(l("rightSidebar.contextNotesTodo.toast.createNoteFailed"));return}u("")},e[7]=f,e[8]=g,e[9]=n,e[10]=F,e[11]=l,e[12]=T):T=e[12];const x=T;let S;e[13]!==p||e[14]!==n||e[15]!==F||e[16]!==l?(S=async A=>{await p(n,A)||F(l("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))},e[13]=p,e[14]=n,e[15]=F,e[16]=l,e[17]=S):S=e[17];const I=S;let $;e[18]!==c||e[19]!==F||e[20]!==l?($=async(A,Z)=>{await c(A,Z)||F(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[18]=c,e[19]=F,e[20]=l,e[21]=$):$=e[21];const R=$;let z;e[22]!==n||e[23]!==F||e[24]!==j||e[25]!==l?(z=(A,Z)=>{j(n,A,Z).then(ee=>{ee||F(l("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[22]=n,e[23]=F,e[24]=j,e[25]=l,e[26]=z):z=e[26];const q=z;let ne;e[27]===Symbol.for("react.memo_cache_sentinel")?(ne=A=>u(A.target.value.slice(0,wn)),e[27]=ne):ne=e[27];let Q;e[28]!==l?(Q=l("rightSidebar.contextNotesTodo.notes.placeholder"),e[28]=l,e[29]=Q):Q=e[29];let H;e[30]!==f.length?(H=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[f.length,"/",wn]}),e[30]=f.length,e[31]=H):H=e[31];let X;e[32]!==x?(X=()=>{x()},e[32]=x,e[33]=X):X=e[33];let ue;e[34]!==f||e[35]!==o?(ue=o||f.trim().length===0,e[34]=f,e[35]=o,e[36]=ue):ue=e[36];let V;e[37]!==l?(V=l("rightSidebar.contextNotesTodo.notes.addAria"),e[37]=l,e[38]=V):V=e[38];let P;e[39]!==l?(P=l("rightSidebar.contextNotesTodo.notes.addAria"),e[39]=l,e[40]=P):P=e[40];let W;e[41]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[41]=W):W=e[41];let U;e[42]!==X||e[43]!==ue||e[44]!==V||e[45]!==P?(U=t.jsx("button",{type:"button",onClick:X,disabled:ue,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":V,title:P,children:W}),e[42]=X,e[43]=ue,e[44]=V,e[45]=P,e[46]=U):U=e[46];let D;e[47]!==U||e[48]!==H?(D=t.jsxs(t.Fragment,{children:[H,U]}),e[47]=U,e[48]=H,e[49]=D):D=e[49];let Y;e[50]!==f||e[51]!==o||e[52]!==h||e[53]!==b||e[54]!==D||e[55]!==Q?(Y=t.jsx(Hs,{value:f,onChange:ne,placeholder:Q,resizedHeight:h,onResizeHeightChange:b,useScrollShadow:!0,scrollShadowSize:56,disabled:o,endSlot:D}),e[50]=f,e[51]=o,e[52]=h,e[53]=b,e[54]=D,e[55]=Q,e[56]=Y):Y=e[56];let M;e[57]!==m||e[58]!==I||e[59]!==q||e[60]!==R||e[61]!==i||e[62]!==a||e[63]!==l||e[64]!==L?(M=t.jsx("div",{children:L.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:a.trim()?l("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()}):l("rightSidebar.contextNotesTodo.notes.empty")}):t.jsx("ul",{className:"flex flex-col gap-1.5",children:L.map(A=>t.jsx(Xd,{note:A,pinned:i.has(A.id),expanded:m===A.id,onToggleExpanded:()=>w(Z=>Z===A.id?null:A.id),onSaveBody:Z=>q(A.id,Z),onTogglePinned:()=>{R(A.id,!i.has(A.id))},onDelete:()=>{I(A.id)}},A.id))})}),e[57]=m,e[58]=I,e[59]=q,e[60]=R,e[61]=i,e[62]=a,e[63]=l,e[64]=L,e[65]=M):M=e[65];let K;return e[66]!==Y||e[67]!==M?(K=t.jsxs("div",{className:"space-y-2",children:[Y,M]}),e[66]=Y,e[67]=M,e[68]=K):K=e[68],K};function eu(s){return s.notesPanelHeight}function tu(s){return s.setNotesPanelHeight}function su(s){return s.createNote}function nu(s){return s.saveNoteBody}function ru(s){return s.deleteNote}const ou=({projectRef:s,plans:e,query:n,onOpenPlan:r,pinnedPlanIds:o,onTogglePinned:a})=>{const{t:i}=st(),c=d.useRef(null),[l,f]=d.useState(!1),[u,m]=d.useState(null),w=Rt(x=>x.createPlan),h=Rt(x=>x.deletePlan),b=xs(x=>x.currentDirectory),g=Ue(x=>x.openContextPanelTab),j=d.useCallback(async x=>{if(!u){m(x);try{await h(s,x)||je.error(i("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))}finally{m(null)}}},[u,s,h,i]),p=d.useCallback(async(x,S)=>{if(!x.trim()){je.error(i("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const I=za(x,S||i("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await w(s,{title:I.title,body:I.body})){je.error(i("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}je.success(i("rightSidebar.contextNotesTodo.toast.planImported"))},[w,s,i]),C=d.useCallback(async()=>{if(l)return;const x=await Pi({defaultPath:s.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(x.success&&x.path){f(!0);try{const S=new URLSearchParams({path:x.path,allowOutsideWorkspace:"true"});x.outsideFileGrant&&S.set("outsideFileGrant",x.outsideFileGrant);const I=await Lt(`/api/fs/read?${S.toString()}`,{cache:"no-store"});if(!I.ok){je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const $=await I.text(),R=x.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await p($,R)}catch(S){const I=S instanceof Error?S.message:void 0;je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),I?{description:I}:void 0)}finally{f(!1)}return}x.error==="Native file picker not available"&&c.current?.click()},[p,l,s.path,i]),L=d.useCallback(async x=>{if(x){f(!0);try{const S=await x.text(),I=x.name.replace(/\.(md|markdown|txt)$/i,"").trim();await p(S,I)}catch(S){const I=S instanceof Error?S.message:void 0;je.error(i("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),I?{description:I}:void 0)}finally{f(!1)}}},[p,i]),_=d.useCallback(async(x,S)=>{if(!await a(x,S)){const $=Rt.getState().getEntry(s).error;je.error(i("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),$?{description:$}:void 0)}},[a,s,i]),F=d.useMemo(()=>e.filter(x=>qs([x.title],n)),[e,n]),T=d.useCallback(x=>{if(r){r({id:x.id,title:x.title,projectRef:s});return}const S=b?.trim()||s.path.trim();S&&g(S,{mode:"plan",projectPlanId:x.id,projectPlanRef:s,dedupeKey:`plan:${Ar(s)}:${x.id}`,label:x.title})},[b,r,g,s]);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:c,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:x=>{const S=x.target.files?.[0]??null;L(S),x.currentTarget.value=""}}),t.jsx("button",{type:"button",onClick:C,disabled:l,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:F.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:F.map(x=>t.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>T(x),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:x.title}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(x.createdAt).toLocaleDateString(vr())})]}),t.jsx("button",{type:"button",onClick:()=>{_(x.id,!o.has(x.id))},className:ae("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(x.id)?"text-primary":"text-muted-foreground hover:text-foreground"),"aria-pressed":o.has(x.id),"aria-label":o.has(x.id)?i("rightSidebar.contextNotesTodo.notes.actions.unpin"):i("rightSidebar.contextNotesTodo.notes.actions.pin"),title:o.has(x.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:()=>{j(x.id)},disabled:u===x.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:x.title}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},x.id))})})]})},au=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,iu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],pr=(s,e)=>{const n=s.findIndex(r=>r.completed);return n===-1?[...s,e]:[...s.slice(0,n),e,...s.slice(n)]},lu=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:c,setActivatorNodeRef:l,transform:f,transition:u,isDragging:m}=Hr(o);let w;e[2]!==f?(w=qr.Transform.toString(f),e[2]=f,e[3]=w):w=e[3];let h;e[4]!==w||e[5]!==u?(h={transform:w,transition:u},e[4]=w,e[5]=u,e[6]=h):h=e[6];const b=m&&"opacity-60";let g;e[7]!==b?(g=ae(b),e[7]=b,e[8]=g):g=e[8];let j;e[9]!==a||e[10]!==r||e[11]!==m||e[12]!==i||e[13]!==l?(j=r({attributes:a,listeners:i,setActivatorNodeRef:l,isDragging:m}),e[9]=a,e[10]=r,e[11]=m,e[12]=i,e[13]=l,e[14]=j):j=e[14];let p;return e[15]!==c||e[16]!==h||e[17]!==g||e[18]!==j?(p=t.jsx("li",{ref:c,style:h,className:g,children:j}),e[15]=c,e[16]=h,e[17]=g,e[18]=j,e[19]=p):p=e[19],p},cu=s=>{const e=$e.c(82),{todos:n,query:r,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:c,onSendToCurrentSession:l,onSendToNewSession:f,onSendToNewWorktreeSession:u}=s,{t:m}=st(),[w,h]=d.useState(""),[b,g]=d.useState(du);let j;e[0]!==w||e[1]!==c||e[2]!==n?(j=()=>{const v=w.trim();v&&(c(pr(n,{id:au(),text:v.slice(0,Bs),completed:!1,createdAt:Date.now()})),h(""))},e[0]=w,e[1]=c,e[2]=n,e[3]=j):j=e[3];const p=j;let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C=v=>{g(J=>{const B=new Set(J);return B.has(v)?B.delete(v):B.add(v),B})},e[4]=C):C=e[4];const L=C;let _;e[5]!==c||e[6]!==n?(_=(v,J)=>{const B=n.find(pe=>pe.id===v);if(!B||B.completed===J)return;const oe=n.filter(pe=>pe.id!==v),de={...B,completed:J};c(J?[...oe,de]:pr(oe,de))},e[5]=c,e[6]=n,e[7]=_):_=e[7];const F=_;let T;e[8]!==c||e[9]!==n?(T=v=>{c(n.filter(J=>J.id!==v))},e[8]=c,e[9]=n,e[10]=T):T=e[10];const x=T;let S;e[11]!==c||e[12]!==n?(S=()=>{const v=n.filter(uu);v.length!==n.length&&c(v)},e[11]=c,e[12]=n,e[13]=S):S=e[13];const I=S;let $;e[14]!==c||e[15]!==n?($=v=>{const{active:J,over:B}=v;if(!B||J.id===B.id)return;const oe=n.findIndex(pe=>pe.id===J.id),de=n.findIndex(pe=>pe.id===B.id);oe===-1||de===-1||c(iu(Zi(n,oe,de)))},e[14]=c,e[15]=n,e[16]=$):$=e[16];const R=$;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z={activationConstraint:{distance:8}},e[17]=z):z=e[17];const q=Ur(Wr(Vr,z));let ne;e[18]!==w?(ne=w.slice(0,Bs),e[18]=w,e[19]=ne):ne=e[19];const Q=ne;let H;e[20]!==n?(H=n.reduce(fu,0),e[20]=n,e[21]=H):H=e[21];const X=H;let ue;if(e[22]!==r||e[23]!==n){let v;e[25]!==r?(v=J=>qs([J.text],r),e[25]=r,e[26]=v):v=e[26],ue=n.filter(v),e[22]=r,e[23]=n,e[24]=ue}else ue=e[24];const V=ue,P=o||X===0;let W;e[27]!==m?(W=m("rightSidebar.contextNotesTodo.todo.clearCompleted"),e[27]=m,e[28]=W):W=e[28];let U;e[29]!==I||e[30]!==P||e[31]!==W?(U=t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:I,disabled:P,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[29]=I,e[30]=P,e[31]=W,e[32]=U):U=e[32];let D;e[33]!==Q.length?(D=t.jsxs("span",{className:"typography-meta text-muted-foreground",children:[Q.length,"/",Bs]}),e[33]=Q.length,e[34]=D):D=e[34];let Y;e[35]!==U||e[36]!==D?(Y=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[U,D]}),e[35]=U,e[36]=D,e[37]=Y):Y=e[37];let M;e[38]===Symbol.for("react.memo_cache_sentinel")?(M=v=>h(v.target.value.slice(0,Bs)),e[38]=M):M=e[38];let K;e[39]!==p?(K=v=>{v.key==="Enter"&&(v.preventDefault(),p())},e[39]=p,e[40]=K):K=e[40];let A;e[41]!==m?(A=m("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[41]=m,e[42]=A):A=e[42];let Z;e[43]!==o||e[44]!==K||e[45]!==A||e[46]!==Q?(Z=t.jsx(St,{value:Q,onChange:M,onKeyDown:K,placeholder:A,disabled:o,className:"h-8"}),e[43]=o,e[44]=K,e[45]=A,e[46]=Q,e[47]=Z):Z=e[47];let ee;e[48]!==o||e[49]!==Q?(ee=o||Q.trim().length===0,e[48]=o,e[49]=Q,e[50]=ee):ee=e[50];let te;e[51]!==m?(te=m("rightSidebar.contextNotesTodo.todo.addAria"),e[51]=m,e[52]=te):te=e[52];let fe;e[53]!==m?(fe=m("rightSidebar.contextNotesTodo.todo.addAria"),e[53]=m,e[54]=fe):fe=e[54];let ce;e[55]===Symbol.for("react.memo_cache_sentinel")?(ce=t.jsx(E,{name:"add",className:"h-4 w-4"}),e[55]=ce):ce=e[55];let me;e[56]!==p||e[57]!==ee||e[58]!==te||e[59]!==fe?(me=t.jsx("button",{type:"button",onClick:p,disabled:ee,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":te,title:fe,children:ce}),e[56]=p,e[57]=ee,e[58]=te,e[59]=fe,e[60]=me):me=e[60];let re;e[61]!==Z||e[62]!==me?(re=t.jsxs("div",{className:"flex items-center gap-1.5",children:[Z,me]}),e[61]=Z,e[62]=me,e[63]=re):re=e[63];let he;e[64]!==a||e[65]!==b||e[66]!==x||e[67]!==R||e[68]!==F||e[69]!==l||e[70]!==f||e[71]!==u||e[72]!==r||e[73]!==i||e[74]!==m||e[75]!==q||e[76]!==V?(he=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:V.length===0?t.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:r.trim()?m("rightSidebar.contextNotesTodo.search.noResults",{query:r.trim()}):m("rightSidebar.contextNotesTodo.todo.empty")}):t.jsx(zr,{sensors:q,collisionDetection:Gr,onDragEnd:R,children:t.jsx(Kr,{items:V.map(mu),strategy:Xi,children:t.jsx("ul",{className:"divide-y divide-border/50",children:V.map(v=>{const J=b.has(v.id);return t.jsx(lu,{id:v.id,children:B=>t.jsxs("div",{className:ae("flex gap-1.5 px-2.5 py-1.5",J?"items-start":"items-center"),children:[t.jsx("button",{type:"button",ref:B.setActivatorNodeRef,...B.attributes,...B.listeners,onClick:hu,className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":m("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:v.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(Ds,{checked:v.completed,onChange:oe=>F(v.id,oe),ariaLabel:m("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:v.text})})}),t.jsx("button",{type:"button",onClick:()=>L(v.id),className:ae("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",J?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",v.completed&&"text-muted-foreground line-through"),title:J?void 0:v.text,"aria-label":J?m("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:v.text}):m("rightSidebar.contextNotesTodo.todo.actions.expand",{text:v.text}),children:v.text}),t.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[t.jsx("button",{type:"button",onClick:()=>x(v.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":m("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.delete",{text:v.text}),children:t.jsx(E,{name:"delete-bin",className:"h-3.5 w-3.5"})}),t.jsxs(Gt,{children:[t.jsx(Ht,{asChild:!0,children:t.jsx("button",{type:"button",disabled:i===v.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":m("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),title:m("rightSidebar.contextNotesTodo.todo.actions.send",{text:v.text}),children:t.jsx(E,{name:"send-plane",className:"h-3.5 w-3.5"})})}),t.jsxs(Kt,{align:"end",className:"w-56",children:[t.jsx(Bt,{onClick:()=>l(v.text),children:m("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),t.jsx(Bt,{onClick:()=>f(v.id,v.text),children:m("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),t.jsx(Bt,{onClick:()=>u(v.id,v.text),disabled:!a,children:m("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},v.id)})})})})}),e[64]=a,e[65]=b,e[66]=x,e[67]=R,e[68]=F,e[69]=l,e[70]=f,e[71]=u,e[72]=r,e[73]=i,e[74]=m,e[75]=q,e[76]=V,e[77]=he):he=e[77];let ge;return e[78]!==Y||e[79]!==re||e[80]!==he?(ge=t.jsxs("div",{className:"space-y-2",children:[Y,re,he]}),e[78]=Y,e[79]=re,e[80]=he,e[81]=ge):ge=e[81],ge};function du(){return new Set}function uu(s){return!s.completed}function fu(s,e){return s+(e.completed?1:0)}function mu(s){return s.id}function hu(s){s.preventDefault(),s.stopPropagation()}const pu=s=>{const{projectRef:e,canCreateWorktree:n,onActionComplete:r}=s,{t:o}=st(),[a,i]=d.useState(null),[c,l]=d.useState(!1),[f,u]=d.useState(null),m=tt(S=>S.currentSessionId),w=tt(S=>S.createSession),h=tt(S=>S.initializeNewAiWorkerSession),b=tt(S=>S.sendMessage),g=tt(S=>S.setCurrentSession),j=Ga(S=>S.setPendingInputText),p=Ue(S=>S.setSessionSwitcherOpen),C=d.useCallback(()=>{p(!1)},[p]),L=d.useCallback(S=>{if(!m){je.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}C();const I=`\`\`\`md
8
- ${S}
9
- \`\`\``;j(I,"append"),je.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[m,r,C,j,o]),_=d.useCallback((S,I)=>{!e||f||i({kind:"session",todoId:S,todoText:I})},[e,f]),F=d.useCallback((S,I)=>{if(!(!e||f)){if(!n){je.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:S,todoText:I})}},[n,e,f,o]),T=d.useCallback(async S=>{if(!e||!a)return;const I=await Vt("plan.todo.visible",{todo_text:a.todoText}),R=[{synthetic:!0,text:await Vt("plan.todo.instructions",{todo_text:a.todoText})}];l(!0),u(a.todoId);try{C();let z=null,q=e.path;if(a.kind==="worktree"){if(!n){je.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const Q=await Ha(e.path,Ka());if(!Q?.id)return;z=Q.id,q=Q.path}else{const Q=await w(void 0,e.path,null);if(!Q?.id){je.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}z=Q.id,q=Q.directory??e.path,h(Q.id,kt.getState().agents??[])}if(!z)return;const ne=Pr.getState();ne.saveSessionModelSelection(z,S.providerID,S.modelID),S.agent.trim()&&(ne.saveSessionAgentSelection(z,S.agent),ne.saveAgentModelForSession(z,S.agent,S.providerID,S.modelID),ne.saveAgentModelVariantForSession(z,S.agent,S.providerID,S.modelID,S.variant||void 0)),g(z,q),await b(I,S.providerID,S.modelID,S.agent.trim()||void 0,void 0,void 0,R,S.variant||void 0),je.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),r?.()}catch(z){const q=z instanceof Error?z.message:void 0;je.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),q?{description:q}:void 0)}finally{l(!1),u(null)}},[n,w,h,r,a,e,C,b,g,o]),x=d.useCallback(()=>{c||i(null)},[c]);return{pendingSendTarget:a,isSubmitting:c,sendingTodoId:f,sendToCurrentSession:L,sendToNewSession:_,sendToNewWorktreeSession:F,confirmSend:T,closeDialog:x}},gu=d.lazy(()=>Xt(()=>import("./PlanView-DyDt_nZ_.js"),__vite__mapDeps([115,2,3,4,5,6,7,8,9,116,57,58,59,60,61,62,79,55,56,63,117,118,119,1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,120,121,113,114,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(s=>({default:s.PlanView}))),gr=["notes","todos","plans","memory"],xu=120,bu=320,on=s=>Math.min(bu,Math.max(xu,Math.round(s))),yu=s=>[...s.filter(e=>!e.completed),...s.filter(e=>e.completed)],ws=(s,e)=>s.toLowerCase().includes(e),wu=s=>{const e=$e.c(242),{projectRef:n,projectLabel:r,canCreateWorktree:o,onActionComplete:a,onOpenPlan:i,className:c}=s,l=o===void 0?!1:o,{t:f}=st();let u;e[0]!==n?(u=Ar(n),e[0]=n,e[1]=u):u=e[1];const m=u;let w;e[2]!==m?(w=we=>(m?we.entries[m]:void 0)??qa,e[2]=m,e[3]=w):w=e[3];const h=Rt(w),b=Rt(vu),g=Rt(Su),j=tt(ju),p=tt(Nu),C=tt(ku),L=tt(Cu);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_={notes:[],plans:[]},e[4]=_):_=e[4];const[F,T]=d.useState(_);let x,S;e[5]!==p||e[6]!==j||e[7]!==C.open||e[8]!==C.projectContextPins?(x=()=>{if(C.open){T(C.projectContextPins??{notes:[],plans:[]});return}let we=!1;return Ja(p,j).then(Xe=>{we||T({notes:Xe.notes.map(Iu),plans:Xe.plans.map(Tu)})}),()=>{we=!0}},S=[p,j,C.open,C.projectContextPins],e[5]=p,e[6]=j,e[7]=C.open,e[8]=C.projectContextPins,e[9]=x,e[10]=S):(x=e[9],S=e[10]),d.useEffect(x,S);let I;e[11]!==p||e[12]!==j||e[13]!==C.open||e[14]!==L?(I=async(we,Xe,Nt)=>{if(C.open)return L(we,Xe,Nt),!0;if(!j||!p)return!1;const Ot=await Ya(p,j,we,Xe,Nt);return Ot?(T(Ot),!0):!1},e[11]=p,e[12]=j,e[13]=C.open,e[14]=L,e[15]=I):I=e[15];const $=I;let R;e[16]!==F.notes?(R=new Set(F.notes),e[16]=F.notes,e[17]=R):R=e[17];const z=R;let q;e[18]!==F.plans?(q=new Set(F.plans),e[18]=F.plans,e[19]=q):q=e[19];const ne=q,Q=Ue(Pu),H=Dt(Du),X=Q&&!H,ue=Dt(Eu);let V;e[20]!==n?.path?(V=we=>Rr(we,n?.path??null),e[20]=n?.path,e[21]=V):V=e[21];const P=Dt(V),W=Ue(Ru),U=Ue(Au),D=Ue(Bu);let Y;e[22]!==U?(Y=gr.includes(U)?U:"notes",e[22]=U,e[23]=Y):Y=e[23];const M=Y,K=M==="memory"&&!X?"notes":M,[A,Z]=d.useState(""),[ee,te]=d.useState(null);let fe;e[24]!==A?(fe=A.trim().toLowerCase(),e[24]=A,e[25]=fe):fe=e[25];const ce=fe;let me;e[26]!==h.todos?(me=yu(h.todos),e[26]=h.todos,e[27]=me):me=e[27];const re=me,he=h.loading&&!h.loaded;let ge;e[28]!==ue||e[29]!==P?(ge=[...ue,...P],e[28]=ue,e[29]=P,e[30]=ge):ge=e[30];const v=ge;let J;e:{if(!ce){let ht;e[31]!==h.notes.length||e[32]!==h.plans.length||e[33]!==v.length||e[34]!==re.length?(ht={notes:h.notes.length,todos:re.length,plans:h.plans.length,memory:v.length},e[31]=h.notes.length,e[32]=h.plans.length,e[33]=v.length,e[34]=re.length,e[35]=ht):ht=e[35],J=ht;break e}let we;if(e[36]!==h.notes||e[37]!==ce){let ht;e[39]!==ce?(ht=bs=>ws(bs.body,ce),e[39]=ce,e[40]=ht):ht=e[40],we=h.notes.filter(ht),e[36]=h.notes,e[37]=ce,e[38]=we}else we=e[38];const Xe=we.length;let Nt;if(e[41]!==re||e[42]!==ce){let ht;e[44]!==ce?(ht=bs=>ws(bs.text,ce),e[44]=ce,e[45]=ht):ht=e[45],Nt=re.filter(ht),e[41]=re,e[42]=ce,e[43]=Nt}else Nt=e[43];const Ot=Nt.length;let ls;if(e[46]!==h.plans||e[47]!==ce){let ht;e[49]!==ce?(ht=bs=>ws(bs.title,ce),e[49]=ce,e[50]=ht):ht=e[50],ls=h.plans.filter(ht),e[46]=h.plans,e[47]=ce,e[48]=ls}else ls=e[48];const yo=ls.length;let cs;e[51]!==v||e[52]!==ce?(cs=v.filter(ht=>ws(ht.title,ce)||ws(ht.body,ce)),e[51]=v,e[52]=ce,e[53]=cs):cs=e[53];let Rs;e[54]!==we.length||e[55]!==Nt.length||e[56]!==ls.length||e[57]!==cs.length?(Rs={notes:Xe,todos:Ot,plans:yo,memory:cs.length},e[54]=we.length,e[55]=Nt.length,e[56]=ls.length,e[57]=cs.length,e[58]=Rs):Rs=e[58],J=Rs}const B=J,oe=Ue(Mu);let de;e[59]!==n?.path?(de=we=>we.agentMemoryViewedAt[An("project",n?.path??null)]??0,e[59]=n?.path,e[60]=de):de=e[60];const pe=Ue(de),Ne=hr(ue,oe)+hr(P,pe),We=Ue(Lu),_e=Ue(Fu),[be,De]=d.useState(!1),[Ie,Be]=d.useState(null),Fe=Ie??We;let He;e[61]!==Fe?(He=on(Fe),e[61]=Fe,e[62]=He):He=e[62];const Ke=He;let nt;e[63]!==Ke?(nt=we=>{we.currentTarget.setPointerCapture(we.pointerId),De(!0),Be(Ke)},e[63]=Ke,e[64]=nt):nt=e[64];const Ze=nt;let rt;e[65]===Symbol.for("react.memo_cache_sentinel")?(rt=we=>{if(!we.currentTarget.hasPointerCapture(we.pointerId))return;const Xe=we.currentTarget.closest("nav")?.getBoundingClientRect().right??0;Be(on(Xe-we.clientX))},e[65]=rt):rt=e[65];const Je=rt;let Ve;e[66]!==_e?(Ve=we=>{we.currentTarget.hasPointerCapture(we.pointerId)&&we.currentTarget.releasePointerCapture(we.pointerId),De(!1),Be(Xe=>(Xe!==null&&_e(on(Xe)),null))},e[66]=_e,e[67]=Ve):Ve=e[67];const Ye=Ve;let ze;e[68]!==l||e[69]!==a||e[70]!==n?(ze={projectRef:n,canCreateWorktree:l,onActionComplete:a},e[68]=l,e[69]=a,e[70]=n,e[71]=ze):ze=e[71];const xe=pu(ze);let et,Me;e[72]!==b||e[73]!==n?(et=()=>{n&&b(n)},Me=[b,n],e[72]=b,e[73]=n,e[74]=et,e[75]=Me):(et=e[74],Me=e[75]),d.useEffect(et,Me);const ke=d.useRef(null);let Qe,Ee;e[76]!==h.error||e[77]!==h.loaded||e[78]!==f?(Qe=()=>{if(!h.error){ke.current=null;return}ke.current!==h.error&&(ke.current=h.error,h.loaded||je.error(f("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},Ee=[h.error,h.loaded,f],e[76]=h.error,e[77]=h.loaded,e[78]=f,e[79]=Qe,e[80]=Ee):(Qe=e[79],Ee=e[80]),d.useEffect(Qe,Ee);let qe;e[81]===Symbol.for("react.memo_cache_sentinel")?(qe=()=>{te(null)},e[81]=qe):qe=e[81];let pt;e[82]!==m?(pt=[m],e[82]=m,e[83]=pt):pt=e[83],d.useEffect(qe,pt);let ft,gt;e[84]!==K?(ft=()=>{K!=="plans"&&te(null)},gt=[K],e[84]=K,e[85]=ft,e[86]=gt):(ft=e[85],gt=e[86]),d.useEffect(ft,gt);let Ct;e[87]===Symbol.for("react.memo_cache_sentinel")?(Ct=()=>{Z("")},e[87]=Ct):Ct=e[87];let y;e[88]!==m?(y=[m],e[88]=m,e[89]=y):y=e[89],d.useEffect(Ct,y);let G,Re;e[90]!==K||e[91]!==B||e[92]!==D||e[93]!==ce?(G=()=>{if(!ce||B[K]>0)return;const we=gr.find(Xe=>B[Xe]>0);we&&D(we)},Re=[K,B,D,ce],e[90]=K,e[91]=B,e[92]=D,e[93]=ce,e[94]=G,e[95]=Re):(G=e[94],Re=e[95]),d.useEffect(G,Re);let Le;e[96]!==n||e[97]!==g||e[98]!==f?(Le=we=>{n&&g(n,we).then(Xe=>{Xe||je.error(f("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[96]=n,e[97]=g,e[98]=f,e[99]=Le):Le=e[99];const N=Le;let ie;e[100]!==f?(ie=f("rightSidebar.contextNotesTodo.tabs.notes"),e[100]=f,e[101]=ie):ie=e[101];const ye=String(B.notes);let ve;e[102]!==ie||e[103]!==ye?(ve={id:"notes",icon:"sticky-note",label:ie,count:ye},e[102]=ie,e[103]=ye,e[104]=ve):ve=e[104];let Se;e[105]!==f?(Se=f("rightSidebar.contextNotesTodo.tabs.todos"),e[105]=f,e[106]=Se):Se=e[106];const Oe=String(B.todos);let Ge;e[107]!==Se||e[108]!==Oe?(Ge={id:"todos",icon:"checkbox-circle",label:Se,count:Oe},e[107]=Se,e[108]=Oe,e[109]=Ge):Ge=e[109];let at;e[110]!==f?(at=f("rightSidebar.contextNotesTodo.tabs.plans"),e[110]=f,e[111]=at):at=e[111];const ct=String(B.plans);let ut;e[112]!==at||e[113]!==ct?(ut={id:"plans",icon:"file-text",label:at,count:ct},e[112]=at,e[113]=ct,e[114]=ut):ut=e[114];let ot;e[115]!==B.memory||e[116]!==Ne||e[117]!==X||e[118]!==f?(ot=X?[{id:"memory",icon:"brain-4",label:f("rightSidebar.contextNotesTodo.tabs.memory"),count:Ne>0?`${Ne}/${B.memory}`:String(B.memory)}]:[],e[115]=B.memory,e[116]=Ne,e[117]=X,e[118]=f,e[119]=ot):ot=e[119];let bt;e[120]!==ve||e[121]!==Ge||e[122]!==ut||e[123]!==ot?(bt=[ve,Ge,ut,...ot],e[120]=ve,e[121]=Ge,e[122]=ut,e[123]=ot,e[124]=bt):bt=e[124];const k=bt;if(!n){let we;e[125]!==c?(we=ae("w-full min-w-0 p-3",c),e[125]=c,e[126]=we):we=e[126];let Xe;e[127]!==f?(Xe=f("rightSidebar.contextNotesTodo.empty.selectProject"),e[127]=f,e[128]=Xe):Xe=e[128];let Nt;e[129]!==Xe?(Nt=t.jsx("p",{className:"typography-meta text-muted-foreground",children:Xe}),e[129]=Xe,e[130]=Nt):Nt=e[130];let Ot;return e[131]!==we||e[132]!==Nt?(Ot=t.jsx("div",{className:we,children:Nt}),e[131]=we,e[132]=Nt,e[133]=Ot):Ot=e[133],Ot}let O;e[134]!==r||e[135]!==n.path?(O=r?.trim()||n.path.split("/").filter(Boolean).pop()||n.path,e[134]=r,e[135]=n.path,e[136]=O):O=e[136];const se=O;let Ce;e[137]!==c?(Ce=ae("flex h-full min-h-0 w-full min-w-0 flex-col",c),e[137]=c,e[138]=Ce):Ce=e[138];let Ae;e[139]!==ee||e[140]!==f?(Ae=ee?t.jsx("button",{type:"button",onClick:()=>te(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":f("rightSidebar.contextNotesTodo.plans.actions.back"),title:f("rightSidebar.contextNotesTodo.plans.actions.back"),children:t.jsx(E,{name:"arrow-left-s",className:"h-4 w-4"})}):null,e[139]=ee,e[140]=f,e[141]=Ae):Ae=e[141];let Te;e[142]!==n.path||e[143]!==se?(Te=t.jsx("h3",{className:"min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",title:n.path,children:se}),e[142]=n.path,e[143]=se,e[144]=Te):Te=e[144];let it;e[145]===Symbol.for("react.memo_cache_sentinel")?(it=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[145]=it):it=e[145];let xt;e[146]===Symbol.for("react.memo_cache_sentinel")?(xt=we=>Z(we.target.value),e[146]=xt):xt=e[146];let vt;e[147]!==f?(vt=f("rightSidebar.contextNotesTodo.search.placeholder"),e[147]=f,e[148]=vt):vt=e[148];let mt;e[149]!==A||e[150]!==vt?(mt=t.jsx(St,{value:A,onChange:xt,placeholder:vt,className:"h-8 pl-7 pr-7"}),e[149]=A,e[150]=vt,e[151]=mt):mt=e[151];let yt;e[152]!==A||e[153]!==f?(yt=A?t.jsx("button",{type:"button",onClick:()=>Z(""),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":f("rightSidebar.contextNotesTodo.search.clear"),title:f("rightSidebar.contextNotesTodo.search.clear"),children:t.jsx(E,{name:"close",className:"h-3.5 w-3.5"})}):null,e[152]=A,e[153]=f,e[154]=yt):yt=e[154];let Pt;e[155]!==mt||e[156]!==yt?(Pt=t.jsxs("div",{className:"relative w-40 flex-shrink-0",children:[it,mt,yt]}),e[155]=mt,e[156]=yt,e[157]=Pt):Pt=e[157];let jt;e[158]!==Ae||e[159]!==Te||e[160]!==Pt?(jt=t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2 p-3 pb-2",children:[Ae,Te,Pt]}),e[158]=Ae,e[159]=Te,e[160]=Pt,e[161]=jt):jt=e[161];let It;e[162]!==K||e[163]!==W||e[164]!==k||e[165]!==D||e[166]!==f?(It=W?t.jsx("nav",{className:"flex flex-shrink-0 items-center gap-1.5 overflow-x-auto px-3 pb-2","aria-label":f("rightSidebar.contextNotesTodo.sections.label"),children:k.map(we=>{const Xe=K===we.id;return t.jsxs("button",{type:"button",onClick:()=>D(we.id),"aria-current":Xe?"page":void 0,className:ae("flex flex-shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",Xe?"border-transparent bg-interactive-active text-foreground":"border-[var(--interactive-border)] text-muted-foreground"),children:[t.jsx(E,{name:we.icon,className:"h-4 w-4 flex-shrink-0"}),Xe?t.jsx("span",{className:"whitespace-nowrap typography-meta",children:we.label}):null,t.jsx("span",{className:"typography-micro text-muted-foreground",children:we.count})]},we.id)})}):null,e[162]=K,e[163]=W,e[164]=k,e[165]=D,e[166]=f,e[167]=It):It=e[167];const Ft=ee?"overflow-hidden":"overflow-y-auto";let dt;e[168]!==Ft?(dt=ae("min-h-0 min-w-0 flex-1 p-3",Ft),e[168]=Ft,e[169]=dt):dt=e[169];let Wt;e[170]!==K||e[171]!==h.notes||e[172]!==he||e[173]!==z||e[174]!==n||e[175]!==A||e[176]!==$?(Wt=K==="notes"?t.jsx(Zd,{projectRef:n,notes:h.notes,disabled:he,query:A,pinnedNoteIds:z,onTogglePinned:(we,Xe)=>$("note",we,Xe)}):null,e[170]=K,e[171]=h.notes,e[172]=he,e[173]=z,e[174]=n,e[175]=A,e[176]=$,e[177]=Wt):Wt=e[177];let Zt;e[178]!==K||e[179]!==l||e[180]!==N||e[181]!==he||e[182]!==A||e[183]!==xe.sendToCurrentSession||e[184]!==xe.sendToNewSession||e[185]!==xe.sendToNewWorktreeSession||e[186]!==xe.sendingTodoId||e[187]!==re?(Zt=K==="todos"?t.jsx(cu,{todos:re,query:A,disabled:he,canCreateWorktree:l,sendingTodoId:xe.sendingTodoId,onPersistTodos:N,onSendToCurrentSession:xe.sendToCurrentSession,onSendToNewSession:xe.sendToNewSession,onSendToNewWorktreeSession:xe.sendToNewWorktreeSession}):null,e[178]=K,e[179]=l,e[180]=N,e[181]=he,e[182]=A,e[183]=xe.sendToCurrentSession,e[184]=xe.sendToNewSession,e[185]=xe.sendToNewWorktreeSession,e[186]=xe.sendingTodoId,e[187]=re,e[188]=Zt):Zt=e[188];let es;e[189]!==K||e[190]!==X||e[191]!==n.path||e[192]!==A?(es=K==="memory"&&X?t.jsx(zd,{projectPath:n.path,query:A}):null,e[189]=K,e[190]=X,e[191]=n.path,e[192]=A,e[193]=es):es=e[193];let ts;e[194]!==K||e[195]!==h.plans||e[196]!==i||e[197]!==ee||e[198]!==ne||e[199]!==n||e[200]!==A||e[201]!==$?(ts=K==="plans"&&!ee?t.jsx(ou,{projectRef:n,plans:h.plans,query:A,pinnedPlanIds:ne,onTogglePinned:(we,Xe)=>$("plan",we,Xe),onOpenPlan:i??te}):null,e[194]=K,e[195]=h.plans,e[196]=i,e[197]=ee,e[198]=ne,e[199]=n,e[200]=A,e[201]=$,e[202]=ts):ts=e[202];let ss;e[203]!==K||e[204]!==ee||e[205]!==n?(ss=K==="plans"&&ee&&n?t.jsx(d.Suspense,{fallback:null,children:t.jsx(gu,{savedProjectPlan:{projectRef:n,planId:ee.id},onNavigatedToChat:()=>te(null)})}):null,e[203]=K,e[204]=ee,e[205]=n,e[206]=ss):ss=e[206];let ns;e[207]!==dt||e[208]!==Wt||e[209]!==Zt||e[210]!==es||e[211]!==ts||e[212]!==ss?(ns=t.jsxs("div",{className:dt,children:[Wt,Zt,es,ts,ss]}),e[207]=dt,e[208]=Wt,e[209]=Zt,e[210]=es,e[211]=ts,e[212]=ss,e[213]=ns):ns=e[213];let rs;e[214]!==K||e[215]!==Ye||e[216]!==Ze||e[217]!==W||e[218]!==be||e[219]!==k||e[220]!==D||e[221]!==Ke||e[222]!==f?(rs=W?null: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:{width:`${Ke}px`},"aria-label":f("rightSidebar.contextNotesTodo.sections.label"),children:[t.jsx("div",{className:ae("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",be&&"bg-[var(--interactive-border)]"),onPointerDown:Ze,onPointerMove:Je,onPointerUp:Ye,onPointerCancel:Ye,role:"separator","aria-orientation":"vertical","aria-label":f("rightSidebar.contextNotesTodo.sections.resize")}),k.map(we=>{const Xe=K===we.id;return t.jsxs("button",{type:"button",onClick:()=>D(we.id),"aria-current":Xe?"page":void 0,className:ae("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",Xe?"bg-interactive-active text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),style:{minHeight:0},children:[t.jsx(E,{name:we.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",children:we.label}),t.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:we.count})]},we.id)})]}),e[214]=K,e[215]=Ye,e[216]=Ze,e[217]=W,e[218]=be,e[219]=k,e[220]=D,e[221]=Ke,e[222]=f,e[223]=rs):rs=e[223];let os;e[224]!==ns||e[225]!==rs?(os=t.jsxs("div",{className:"flex min-h-0 flex-1",children:[ns,rs]}),e[224]=ns,e[225]=rs,e[226]=os):os=e[226];const Js=xe.pendingSendTarget!==null;let as;e[227]!==xe?(as=we=>{we||xe.closeDialog()},e[227]=xe,e[228]=as):as=e[228];const Ys=xe.pendingSendTarget?.kind??"session";let is;e[229]!==n.path||e[230]!==xe.confirmSend||e[231]!==xe.isSubmitting||e[232]!==Js||e[233]!==as||e[234]!==Ys?(is=t.jsx(Ll,{open:Js,onOpenChange:as,target:Ys,projectDirectory:n.path,submitting:xe.isSubmitting,onConfirm:xe.confirmSend}),e[229]=n.path,e[230]=xe.confirmSend,e[231]=xe.isSubmitting,e[232]=Js,e[233]=as,e[234]=Ys,e[235]=is):is=e[235];let Es;return e[236]!==Ce||e[237]!==jt||e[238]!==It||e[239]!==os||e[240]!==is?(Es=t.jsxs("div",{className:Ce,children:[jt,It,os,is]}),e[236]=Ce,e[237]=jt,e[238]=It,e[239]=os,e[240]=is,e[241]=Es):Es=e[241],Es};function vu(s){return s.load}function Su(s){return s.saveTodos}function ju(s){return s.currentSessionId}function Nu(s){return s.currentSessionDirectory}function ku(s){return s.newSessionDraft}function Cu(s){return s.setDraftProjectContextPin}function Iu(s){return s.id}function Tu(s){return s.id}function Pu(s){return s.agentMemoryFeatureAvailable&&s.agentMemoryToolEnabled}function Du(s){return s.disabled}function Eu(s){return s.global}function Ru(s){return s.isMobile}function Au(s){return s.projectContextTab}function Bu(s){return s.setProjectContextTab}function Mu(s){return s.agentMemoryViewedAt[An("global",null)]??0}function Lu(s){return s.projectContextSidebarWidth}function Fu(s){return s.setProjectContextSidebarWidth}const Ou=({projects:s,worktreesByProject:e,directory:n,activeProjectId:r,chatDraftOpen:o,chatDraftTarget:a,homeDirectory:i})=>{const c=Qa(n)??Xa(i),l=Ws(n),f=Ws(c);if((o?a==="chat":!!(l&&f&&(l===f||l.startsWith(`${f}/`))))&&c)return{id:vn,path:c};const m=Za(s,e,n);if(m)return{id:m.id,path:m.path};if(l)return null;const w=s.find(h=>h.id===r)??null;return w?{id:w.id,path:w.path}:null},_u=s=>{const e=$e.c(8),n=Tt($u),r=Tt(Uu),o=xs(Wu),a=tt(Vu),i=tt(zu),c=tt(Gu);let l;return e[0]!==r||e[1]!==i||e[2]!==c||e[3]!==s||e[4]!==o||e[5]!==n||e[6]!==a?(l=Ou({projects:n,worktreesByProject:a,directory:s,activeProjectId:r,chatDraftOpen:i,chatDraftTarget:c,homeDirectory:o}),e[0]=r,e[1]=i,e[2]=c,e[3]=s,e[4]=o,e[5]=n,e[6]=a,e[7]=l):l=e[7],l};function $u(s){return s.projects}function Uu(s){return s.activeProjectId}function Wu(s){return s.homeDirectory}function Vu(s){return s.availableWorktreesByProject}function zu(s){return s.newSessionDraft.open}function Gu(s){return s.newSessionDraft.target}const xm=s=>{const e=$e.c(18),{onActionComplete:n,onOpenPlan:r}=s,o=xs(Hu),{t:a}=st(),i=In(Ku),c=tt(qu),l=_u(c),f=Tt(Ju);let u;e[0]!==l||e[1]!==f?(u=l?f.find(p=>p.id===l.id)??null:null,e[0]=l,e[1]=f,e[2]=u):u=e[2];const m=u;let w;e:{if(!l){w=null;break e}if(l.id===vn){let C;e[3]!==a?(C=a("sessions.sidebar.activity.chatsTitle"),e[3]=a,e[4]=C):C=e[4],w=C;break e}let p;e[5]!==o||e[6]!==m?.label||e[7]!==l.path?(p=m?.label?.trim()||ei(l.path,o)||l.path,e[5]=o,e[6]=m?.label,e[7]=l.path,e[8]=p):p=e[8],w=p}const h=w;let b;e:{if(!l||l.id===vn){b=!1;break e}let p;e[9]!==i||e[10]!==l.path?(p=i.get(l.path)?.isGitRepo,e[9]=i,e[10]=l.path,e[11]=p):p=e[11],b=p===!0}const g=b;let j;return e[12]!==g||e[13]!==n||e[14]!==r||e[15]!==h||e[16]!==l?(j=t.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:t.jsx(wu,{projectRef:l,projectLabel:h,canCreateWorktree:g,onActionComplete:n,onOpenPlan:r})}),e[12]=g,e[13]=n,e[14]=r,e[15]=h,e[16]=l,e[17]=j):j=e[17],j};function Hu(s){return s.homeDirectory}function Ku(s){return s.directories}function qu(s){return s.currentSessionDirectory}function Ju(s){return s.projects}function Yu(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 Qu(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 an=["\x1B[0m","\x1B[m"],Xu=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=Xu(s);return e?`\x1B[0;48;2;${e[0]};${e[1]};${e[2]}m`:null},Zu=(s,e,n)=>{const r=e+s;if(!n)return{data:r,carry:""};let o=0;const a=Math.max(...an.map(l=>l.length))-1;for(let l=1;l<=Math.min(a,r.length);l+=1){const f=r.slice(-l);an.some(u=>u.length>f.length&&u.startsWith(f))&&(o=l)}const i=o>0?r.slice(-o):"";let c=o>0?r.slice(0,-o):r;for(const l of an)c=c.replaceAll(l,n);return{data:c,carry:i}},ef=(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))}},tf=(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}};function sf(s,e){if(s.length===0)return{reset:e!==null,replay:!1,pending:[]};if(e===null)return{reset:!1,replay:!0,pending:s};let n=-1;for(let r=s.length-1;r>=0;r-=1){const o=s[r].id;if(o===e){n=r;break}if(o<e)break}return n<0?{reset:!0,replay:!0,pending:s}:{reset:!1,replay:!1,pending:s.slice(n+1)}}let nf=null;const rf=()=>nf??=Xt(()=>import("./vendor-ghostty-web-CrxinGGH.js"),__vite__mapDeps([122,5])).then(async s=>({module:s,ghostty:await s.Ghostty.load()})),of=2e3,af=()=>Promise.resolve(window.__aiworkerEnsureNerdFonts?.()).catch(()=>{}),lf=s=>{const e=Promise.all([ti(s),af()]).then(()=>{}),n=new Promise(r=>{const o=setTimeout(()=>r(!1),of);e.then(()=>{clearTimeout(o),r(!0)})});return{loaded:e,loadedBeforeTimeout:n}},cf=(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 c=window.getComputedStyle(s),l=(Number.parseInt(c.paddingLeft,10)||0)+(Number.parseInt(c.paddingRight,10)||0),f=(Number.parseInt(c.paddingTop,10)||0)+(Number.parseInt(c.paddingBottom,10)||0);return{cols:Math.max(2,Math.floor((s.clientWidth-l-15)/a)),rows:Math.max(1,Math.floor((s.clientHeight-f)/i))}},ho=d.forwardRef(({sessionKey:s,chunks:e,onInput:n,onResize:r,theme:o,monoFont:a,fontFamily:i,fontSize:c,className:l,enableTouchScroll:f=!1,autoFocus:u=!0,isVisible:m=!0},w)=>{const h=d.useRef(null),b=d.useRef(null),g=d.useRef(null),j=d.useRef(n),p=d.useRef(r),C=d.useRef(null),L=d.useRef(null),_=d.useRef(null),F=d.useRef(""),T=d.useRef(""),x=d.useRef(xr(o.background)),S=d.useRef(!1),I=d.useRef(0),$=d.useRef(m),R=d.useRef(!1),[z,q]=d.useState(0),[ne,Q]=d.useState(0);j.current=n,p.current=r,$.current=m,x.current=xr(o.background),d.useLayoutEffect(()=>{const V=h.current;if(!V)return;const P=cf(V,i,c);L.current=P,P&&p.current(P.cols,P.rows)},[i,c]);const H=d.useCallback(()=>{const V=h.current,P=b.current;if(!V||!P||!g.current||!$.current)return;const W=V.getBoundingClientRect();if(!(W.width<24||W.height<24))try{g.current.fit();const U={cols:P.cols,rows:P.rows};(!C.current||C.current.cols!==U.cols||C.current.rows!==U.rows)&&(C.current=U,p.current(U.cols,U.rows)),R.current||(R.current=!0,q(D=>D+1))}catch{}},[]),X=d.useCallback(()=>{if(S.current||!F.current||!b.current)return;const V=b.current,P=F.current;F.current="";const W=Zu(P,T.current,x.current);if(T.current=W.carry,!W.data){F.current&&X();return}S.current=!0;const U=I.current;V.write(W.data,()=>{b.current!==V||I.current!==U||(S.current=!1,F.current&&X())})},[]),ue=d.useCallback(()=>{_.current=null,F.current="",T.current="",S.current=!1,I.current+=1;const V=b.current;if(!V){Q(P=>P+1);return}try{V.reset();const P=x.current;P&&V.write(`${P}\x1B[2J\x1B[H`)}catch{Q(P=>P+1)}},[]);return d.useEffect(()=>{const V=h.current;if(!V)return;let P=!1,W=null,U=null,D=null,Y=null,M=[];const K=()=>{W&&$.current&&(W.options.cursorBlink=!0)},A=fe=>{fe.relatedTarget instanceof Node&&V.contains(fe.relatedTarget)||W&&(W.options.cursorBlink=!1)},Z=()=>{W&&$.current&&V.contains(document.activeElement)&&(W.options.cursorBlink=!0)},ee=()=>{W&&(W.options.cursorBlink=!1)};V.addEventListener("focusin",K),V.addEventListener("focusout",A),window.addEventListener("focus",Z),window.addEventListener("blur",ee);const te=lf(a);return Promise.all([rf(),te.loadedBeforeTimeout]).then(([{module:fe,ghostty:ce},me])=>{if(P)return;W=new fe.Terminal({...Qu(i,c,o,ce,!1),...L.current??{}});const re=new fe.FitAddon;W.loadAddon(re),W.open(V),V.setAttribute("autocapitalize","off"),V.setAttribute("autocorrect","off"),V.setAttribute("spellcheck","false"),b.current=W,g.current=re,M=[W.onData(ge=>j.current(ge))],U=new ResizeObserver(()=>{D&&clearTimeout(D),D=setTimeout(H,80)}),U.observe(V),H();const he=x.current;he&&W.write(`${he}\x1B[2J\x1B[H`),Y=requestAnimationFrame(H),me||te.loaded.then(()=>{!P&&b.current===W&&Q(ge=>ge+1)})}),()=>{P=!0;const fe=document.activeElement;fe instanceof HTMLElement&&V.contains(fe)&&(fe.blur(),window.Capacitor?.getPlatform?.()==="android"&&Xt(async()=>{const{Keyboard:me}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:me}},__vite__mapDeps([123,124])).then(({Keyboard:me})=>me.hide()).catch(()=>{})),U?.disconnect(),D&&clearTimeout(D),Y!==null&&cancelAnimationFrame(Y),V.removeEventListener("focusin",K),V.removeEventListener("focusout",A),window.removeEventListener("focus",Z),window.removeEventListener("blur",ee),M.forEach(ce=>ce.dispose()),W?.dispose(),b.current=null,g.current=null,C.current=null,_.current=null,F.current="",T.current="",S.current=!1,I.current+=1,R.current=!1}},[H,i,c,a,ne,o]),d.useEffect(()=>{const V=b.current,P=h.current;!V||!P||(V.options.cursorBlink=m&&document.hasFocus()&&P.contains(document.activeElement))},[m,z]),d.useEffect(()=>{if(!b.current)return;const{reset:P,replay:W,pending:U}=sf(e,_.current);P&&ue(),U.length!==0&&(F.current+=U.map(D=>W?D.replayData??D.data:D.data).join(""),_.current=e.at(-1)?.id??null,X())},[e,X,z,ue]),d.useEffect(()=>{if(!u||!m)return;const V=requestAnimationFrame(()=>b.current?.focus());return()=>cancelAnimationFrame(V)},[u,m,z,s]),d.useEffect(()=>{const V=h.current;if(!f||!V)return;const P=W=>{const U=W;if(!U.isComposing)switch(U.inputType){case"insertText":U.data&&j.current(U.data);break;case"insertLineBreak":case"insertParagraph":j.current("\r");break;case"deleteContentBackward":j.current("");break}};return V.addEventListener("beforeinput",P),()=>V.removeEventListener("beforeinput",P)},[f,z]),d.useEffect(()=>{const V=h.current,P=b.current;if(!f||!V||!P)return;let W=null,U=null,D="idle",Y=0,M=0,K=0,A=0,Z=null;const ee=Math.max(12,c+2),te=()=>{window.Capacitor?.getPlatform?.()==="android"&&Xt(async()=>{const{Keyboard:oe}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:oe}},__vite__mapDeps([123,124])).then(({Keyboard:oe})=>oe.show()).catch(()=>{})},fe=()=>{U&&(clearTimeout(U),U=null)},ce=(B,oe)=>{const de=V.querySelector("canvas");return de?ef(B,oe,de.getBoundingClientRect(),P.cols,P.rows):null},me=(B,oe)=>{const de=V.querySelector("canvas");if(!de)return;const pe=de.getBoundingClientRect(),Ne=pe.left+(oe.column+.5)/P.cols*pe.width,We=pe.top+(oe.row+.5)/P.rows*pe.height;de.dispatchEvent(new MouseEvent(B,{bubbles:!0,cancelable:!0,button:0,buttons:1,clientX:Ne,clientY:We}))},re=()=>{document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0,buttons:0}))},he=B=>{B.pointerType!=="touch"||W!==null||(W=B.pointerId,D="pending",Y=B.clientX,M=B.clientY,K=B.clientY,A=0,Z=null,V.setPointerCapture(B.pointerId),U=setTimeout(()=>{if(U=null,W!==B.pointerId||D!=="pending")return;const oe=ce(Y,M);if(!oe)return;const de=P.buffer.active,pe=Math.max(0,de.length-P.rows-de.viewportY+oe.row),Ne=de.getLine(pe),We=Array.from({length:P.cols},(De,Ie)=>Ne?.getCell(Ie)?.getChars()??""),_e=tf(We,oe.column),be={column:_e.startColumn,row:oe.row};Z={column:_e.endColumn,row:oe.row},D="selecting",me("mousedown",be),me("mousemove",Z)},350))},ge=B=>{if(W!==B.pointerId)return;if(D==="selecting"){const pe=ce(B.clientX,B.clientY);pe&&(!Z||pe.column!==Z.column||pe.row!==Z.row)&&(Z=pe,me("mousemove",pe)),B.cancelable&&B.preventDefault();return}if(D==="pending"){if(Math.hypot(B.clientX-Y,B.clientY-M)<8)return;fe(),D="scrolling"}if(D!=="scrolling")return;const oe=K-B.clientY;K=B.clientY,A+=oe;const de=Math.trunc(A/ee);de&&(P.scrollLines(de),A-=de*ee),B.cancelable&&B.preventDefault()},v=B=>{if(W!==B.pointerId)return;const oe=D==="pending",de=D==="selecting";fe(),V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),W=null,D="idle",de&&re(),oe&&(P.focus(),te())},J=B=>{if(W!==B.pointerId)return;const oe=D==="selecting";fe(),V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),W=null,D="idle",oe&&re()};return V.addEventListener("pointerdown",he),V.addEventListener("pointermove",ge,{passive:!1}),V.addEventListener("pointerup",v),V.addEventListener("pointercancel",J),()=>{fe(),V.removeEventListener("pointerdown",he),V.removeEventListener("pointermove",ge),V.removeEventListener("pointerup",v),V.removeEventListener("pointercancel",J)}},[f,c,z]),d.useImperativeHandle(w,()=>({focus:()=>b.current?.focus(),fit:H,getSelection:()=>{const V=b.current,P=V?.getSelectionPosition(),W=V?.getSelection()??"";return!P||!W.trim()?null:{text:W,startLine:P.start.y+1,endLine:P.end.y+1}}}),[H]),t.jsx("div",{ref:h,"data-terminal-owner":"main",className:ae("terminal-viewport-container h-full w-full overflow-hidden touch-none",l)})});ho.displayName="TerminalViewport";const df="\x1B",po=new RegExp(`${df}\\[[0-9;?]*[ -/]*[@-~]`,"g"),uf=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,ff=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,mf=/Serving HTTP on .*? port (\d{2,5})/i,hf=new Set([".",",",";",":","!","?"]),go=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(hf.has(n)){e=e.slice(0,-1);continue}break}return e},kn=s=>{let e=go(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},pf=s=>{if(!s)return[];const e=s.replace(po,""),n=[],r=new Set,o=i=>{r.has(i)||(r.add(i),n.push(i))},a=e.match(mf);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(`
10
- `)){if(!ff.test(i))continue;const c=Array.from(i.matchAll(uf));if(c.length===0)continue;const l=c.find(f=>{try{return!!new URL(kn(f[1])).port}catch{return!1}});o(kn((l??c[0])[1]))}return n},xo=s=>pf(s)[0]??null,gf=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 Lt("/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)}},xf=/https?:\/\/[^\s<>'"`]+/gi,bm=(s,{requireAnnounced:e=!1}={})=>{const n=xo(s);if(n)return n;if(e)return null;const r=String(s||"").replace(po,""),o=[];for(const c of r.match(xf)??[])try{const l=new URL(go(c));l.port&&o.push(l)}catch{}if(o.length===0)return null;const a=c=>{const l=c.hostname.toLowerCase();return(l==="localhost"||l==="127.0.0.1"||l==="0.0.0.0"||l==="::1"?50:0)-(c.search||c.hash?10:0)};let i=o[0];for(const c of o.slice(1))a(c)>a(i)&&(i=c);return kn(i.toString())},bf={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},yf=(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 bf[s]},bo=s=>{const e=s[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},wf=(s,e)=>s&&(e==="ctrl"?bo(s)??s:s.length===1&&s!=="\x1B"?`\x1B${s}`:s),vf="COMMAND_MODE_UNSUPPORTED",Sf="PROJECT_ACTION_RUN_CANCELLED",jf="PROJECT_ACTION_PURPOSE_UNSUPPORTED",Nf=s=>new Error(s),kf=async(s,e)=>{try{await s.close(e)}catch{}},ln=async(s,e,n,r)=>{throw e.sessionId===n&&await kf(s,e.sessionId),Nf(r)},Cf=s=>{const e=s.trim().replace(/\r\n|\r/g,`
11
- `);let n="";for(let r=0;r<e.length;r+=1){const o=e.charCodeAt(r);o>=0&&o<=8||o===11||o===12||o>=14&&o<=31||o===127||(n+=e[r])}return n},If=s=>s.mode==="command",Tf=s=>s?.type==="project-action",Pf=(s,e)=>Tf(s)&&s.actionId===e&&s.executionId.trim().length>0,ym=async({terminal:s,createOptions:e,command:n,isRunStillExpected:r,purpose:o})=>{const a=await s.createSession({...e,sessionId:o.executionId,mode:"command",command:Cf(n),purpose:o});return If(a)||await ln(s,a,o.executionId,vf),Pf(a.purpose,o.actionId)||await ln(s,a,o.executionId,jf),r()||await ln(s,a,o.executionId,Sf),a},Df=(s,e,n)=>new Promise(r=>{let o=!1,a=null,i=null;const c=l=>{o||(o=!0,i&&clearTimeout(i),a?.close(),r(l))};a=s.connect(e,{onEvent:l=>{(l.type==="exit"||l.type==="snapshot"&&l.status==="exited")&&c(!0)},onError:(l,f)=>{f&&c(!0)}}),o?a.close():i=setTimeout(()=>c(!1),n)}),wm=async({terminal:s,sessionId:e,isExecutionStillCurrent:n,markStopping:r,restoreRunning:o,clearSession:a,finalizeExit:i,timeoutMs:c=1e3})=>{r();const l=Df(s,e,c);try{n()&&await s.sendInput(e,"")}catch{}const f=await l;if(n()){if(!f){let u=!1;if(s.forceKill)try{n()&&await s.forceKill({sessionId:e})}catch{u=!0}else try{n()&&await s.close(e)}catch{u=!0}if(!n())return;if(u){o();return}a()}n()&&i()}},cn=new WeakMap,Ef=(s,e,n={})=>{if(!s.listSessions)return Promise.resolve(null);const r=Tn(e),o=zt(),a=`${o}\0${r}`;let i=cn.get(s);i||(i=new Map,cn.set(s,i));const c=i.get(a);if(c)return c;const l=n.captureStartedActionMutationRevisions?.(r)??new Map,f=s.listSessions(r).then(u=>o===zt()?{sessions:u,startedActionMutationRevisions:l}:null).catch(()=>null).finally(()=>{i.get(a)===f&&(i.delete(a),i.size===0&&cn.delete(s))});return i.set(a,f),f},Rf=s=>{const e=new Map;for(const n of s){const r=Tn(n.cwd),o=e.get(r);o?o.push(n):e.set(r,[n])}return e},Af=5e3,dn=new WeakMap,Bf=(s,e,n,r)=>{if(!s.listSessions)return()=>{};const o=Tn(e);let a=dn.get(s);if(!a){const c=new Map;let l=!1,f=!1,u=!1,m=!1,w=null,h=0;const b=()=>document.visibilityState!=="hidden"&&navigator.onLine!==!1,g=()=>{w!==null&&clearTimeout(w),w=null},j=()=>{if(g(),!(l||!b())){if(f){u=!0;return}m||(m=!0,queueMicrotask(()=>{if(m=!1,l||!b())return;f=!0,u=!1;const L=h,_=zt(),F=new Map(c);Ef(s,"",{captureStartedActionMutationRevisions:()=>{const T=new Map;for(const[x,S]of F)for(const[I,$]of S.capture(x))T.set(I,$);return T}}).then(T=>{if(l||h!==L||_!==zt()||!T)return;const x=Rf(T.sessions);for(const[S,I]of F){if(c.get(S)!==I)continue;const $=S?x.get(S)??[]:T.sessions;for(const R of I.listeners)R({...T,sessions:$})}}).finally(()=>{f=!1,!(l||!b())&&(u?j():w=setTimeout(j,Af))})}))}},p=()=>{h+=1,j()};window.addEventListener("focus",j),window.addEventListener("online",j),window.addEventListener("offline",g),document.addEventListener("visibilitychange",j);const C=Lr(p);a={scopes:c,refresh:j,close:()=>{l=!0,g(),window.removeEventListener("focus",j),window.removeEventListener("online",j),window.removeEventListener("offline",g),document.removeEventListener("visibilitychange",j),C()}},dn.set(s,a)}let i=a.scopes.get(o);return i||(i={listeners:new Set,capture:n},a.scopes.set(o,i),a.refresh()),i.listeners.add(r),()=>{i.listeners.delete(r),!(i.listeners.size>0)&&(a.scopes.delete(o),!(a.scopes.size>0)&&(a.close(),dn.delete(s)))}},br={cols:80,rows:24},Mf=s=>Dn.find(n=>n.key===s)?.Icon??"terminal",vm=({visible:s,directory:e})=>{const{t:n}=st(),{terminal:r,runtime:o}=Ks(),a=d.useCallback(()=>{const k=tt.getState().currentSessionId;k&&tt.getState().recoverMissingSessionDirectory(k)},[]),{currentTheme:i}=kr(),c=d.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});c.current={themeMode:i.metadata.variant==="light"?"light":"dark",terminalBackground:i.colors.surface.background,terminalForeground:i.colors.syntax.base.foreground};const{monoFont:l}=si(),f=Ue(k=>k.terminalFontSize),u=Ue(k=>k.terminalShell),m=Ue(k=>k.terminalLoginShells.includes(k.terminalShell)),{isMobile:w,isTablet:h,hasTouchOnlyPointer:b}=gs(),g=w||h,j=(g||b)&&o.platform==="web",p=o.platform!=="vscode",C=Ue(k=>k.showTerminalQuickKeysOnDesktop),L=g||C,_=tt(k=>k.currentSessionId),F=tt(k=>k.newSessionDraft),T=_!==null||F?.open===!0,x=ni()??null,S=e??null,I=S||x,$=S!==null,R=lt(k=>I?k.getDirectoryState(I):void 0),z=lt(k=>k.hasHydrated),q=lt(k=>k.ensureDirectory),ne=lt(k=>k.createTab),Q=lt(k=>k.setActiveTab),H=lt(k=>k.closeTab),X=lt(k=>k.setTabSessionId),ue=lt(k=>k.reconcileServerSessions),V=lt(k=>k.captureStartedActionMutationRevisions),P=lt(k=>k.setTabLifecycle),W=lt(k=>k.setConnecting),U=lt(k=>k.appendToBuffer),D=lt(k=>k.replaceBuffer),Y=lt(k=>k.setTabPreviewUrl),M=ri(k=>k.addDraft),K=Ue(k=>k.openContextPreview),A=d.useMemo(()=>R?p?R.activeTabId??R.tabs[0]?.id??null:R.tabs[0]?.id??null:null,[R,p]),Z=d.useMemo(()=>{if(R)return A?R.tabs.find(k=>k.id===A)??R.tabs[0]:R.tabs[0]},[R,A]),ee=d.useMemo(()=>(R?.tabs??[]).map(k=>({icon:(()=>{const O=k.purpose.type==="project-action"&&Di.has(k.lifecycle),se=O?"loader-4":Mf(k.iconKey);return t.jsx(E,{name:se,className:ae("h-4 w-4",O&&"animate-spin text-muted-foreground motion-reduce:animate-none")})})(),id:k.id,label:k.label,title:k.label,closeLabel:n("terminalView.tabs.closeTabTitle")})),[R?.tabs,n]),te=Z?.terminalSessionId??null,fe=Z?.lifecycle??"idle",ce=Z?.purpose.type==="project-action",me=lt(k=>I&&A?k.getBuffer(I,A).chunks:Ei.chunks),re=Z?.isConnecting??!1,he=Z?.previewUrl??null,[ge,v]=d.useState(null),[J,B]=d.useState(!1),[oe,de]=d.useState(!1),[pe,Ne]=d.useState(null),[We,_e]=d.useState(!1),be=d.useRef(null),De=d.useRef(null),Ie=d.useRef(A),Be=d.useRef(te),Fe=d.useRef(I),He=d.useRef(null),Ke=d.useRef(null),nt=d.useRef(new Set),Ze=d.useRef(""),rt=d.useRef(new Set),Je=d.useRef(0),Ve=d.useCallback(()=>{Ze.current="",rt.current.clear(),Je.current+=1},[]),Ye=d.useCallback(()=>{j||typeof document<"u"&&!document.hasFocus()||He.current?.focus()},[j]),ze=d.useCallback(()=>{j||He.current?.focus()},[j]),xe=s??!1,[et,Me]=d.useState(xe);d.useEffect(()=>{xe&&Me(!0)},[xe]),d.useEffect(()=>{Be.current=te},[te]),d.useEffect(()=>{!te||!r.updateAppearance||r.updateAppearance(te,c.current).catch(()=>{})},[i.colors.surface.background,i.colors.syntax.base.foreground,i.metadata.variant,r,te]),d.useEffect(()=>{Ie.current=A,Ve()},[A,Ve]),d.useEffect(()=>{Fe.current=I},[I]),d.useEffect(()=>{if(!(!z||!I||!xe))return Bf(r,I,V,k=>{ue(I,k.sessions,{startedActionMutationRevisions:k.startedActionMutationRevisions})})},[V,xe,z,I,r,ue]),d.useEffect(()=>{!L&&pe!==null&&Ne(null)},[L,pe,Ne]),d.useEffect(()=>{!te&&pe!==null&&Ne(null)},[te,pe,Ne]);const ke=d.useCallback(()=>{be.current?.(),be.current=null,De.current=null,de(!1)},[]);d.useEffect(()=>()=>{ke(),Be.current=null},[ke]);const Qe=d.useCallback((k,O,se)=>{if(!se)return;const Ce=`${Ze.current}${se}`.replace(/\r\n|\r/g,`
12
- `),Ae=Ce.split(`
13
- `),Te=Ce.endsWith(`
14
- `)?Ae.join(`
15
- `):Ae.slice(0,-1).join(`
16
- `);if(Ze.current=Ce.endsWith(`
17
- `)?"":(Ae[Ae.length-1]??"").slice(-1024),!Te)return;const it=xo(Te);if(!it||rt.current.has(it))return;const xt=Je.current;rt.current.add(it),gf(it).then(vt=>{if(rt.current.delete(it),!vt||Je.current!==xt)return;const mt=lt.getState().getDirectoryState(k)?.tabs.find(yt=>yt.id===O);!mt||mt.previewUrlLocked||mt.previewUrl===it||Y(k,O,it,{locked:!1,autoOpened:!1})})},[Y]),Ee=d.useCallback((k,O,se)=>{if(De.current===se)return;ke(),De.current=se;const Ce=()=>De.current===se&&lt.getState().getDirectoryState(k)?.tabs.some(Te=>Te.id===O&&Te.terminalSessionId===se),Ae=r.connect(se,{onEvent:Te=>{if(Ce())switch(Te.type){case"snapshot":{W(k,O,!1),v(null),B(!1),de(!1),Ye(),D(k,O,Te.data??"",Te.sequence??0),Qe(k,O,Te.data??""),Te.status==="exited"&&P(k,O,"exited");break}case"reconnecting":{v(null),B(!1),de(!0);break}case"data":{Te.data&&(U(k,O,Te.data,Te.sequence,Te.replayData),Qe(k,O,Te.data));break}case"exit":{const it=typeof Te.exitCode=="number"?Te.exitCode:null,xt=typeof Te.signal=="number"?Te.signal:null,mt=lt.getState().getDirectoryState(k)?.tabs.find(yt=>yt.id===O)?.purpose.type==="project-action";U(k,O,n("terminalView.stream.processExitedMessage",{exitCodeSegment:it!==null?n("terminalView.stream.processExitedWithCode",{exitCode:it}):"",signalSegment:xt!==null?n("terminalView.stream.processExitedWithSignal",{signal:xt}):""})),P(k,O,"exited"),W(k,O,!1),v(mt?null:n("terminalView.error.sessionEnded")),B(!1),de(!1),ke();break}}},onError:(Te,it)=>{if(!Ce())return;if(!it){v(null),B(!1);return}if(de(!1),Te.code==="SESSION_NOT_FOUND"&&lt.getState().getDirectoryState(k)?.tabs.find(mt=>mt.id===O)?.purpose.type!=="project-action"){v(null),B(!1),W(k,O,!1),X(k,O,null),P(k,O,"idle"),ke();return}const xt=Te.code==="SUPERSEDED";v(xt?null:n("terminalView.error.connectionFailed",{message:Te.message})),B(!xt),W(k,O,!1),P(k,O,"exited"),X(k,O,null),ke()}});be.current=()=>{Ae.close(),De.current=null}},[U,D,ke,Ye,Qe,W,P,X,n,r]);d.useEffect(()=>{let k=!1;if(!z||!et)return;if(!I){v(n(T?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),ke();return}return(async()=>{const se=I;if(!Fe.current||Fe.current!==se)return;if(!lt.getState().getDirectoryState(se)){if($)return;q(se);return}const Ae=lt.getState().getDirectoryState(se);if(!Ae||Ae.tabs.length===0)return;const Te=p?Ae.activeTabId??Ae.tabs[0]?.id??null:Ae.tabs[0]?.id??null;if(!Te)return;const it=Ae.tabs.find(yt=>yt.id===Te)??Ae.tabs[0],xt=it?.terminalSessionId??null,vt=it?.lifecycle??"idle",mt=it?.purpose.type==="project-action";if(!xt){if(vt==="exited"){W(se,Te,!1);return}if(mt){W(se,Te,!1);return}const yt=`${se}\0${Te}`;if(nt.current.has(yt))return;const Pt=Ke.current??br;nt.current.add(yt),v(null),B(!1),de(!1),W(se,Te,!0);try{const jt=await r.createSession({cwd:se,sessionId:Te,cols:Pt.cols,rows:Pt.rows,shell:u,loginShell:m,...c.current}),It=!k&&Fe.current===se&&Ie.current===Te;if(!lt.getState().getDirectoryState(se)?.tabs.find(Wt=>Wt.id===Te)){try{await r.close(jt.sessionId)}catch{}return}if(X(se,Te,jt.sessionId),!It)return;const dt=Ke.current;dt&&(dt.cols!==Pt.cols||dt.rows!==Pt.rows)&&r.resize({sessionId:jt.sessionId,...dt}).catch(()=>{});return}catch(jt){const It=lt.getState().getDirectoryState(se)?.tabs.find(Ft=>Ft.id===Te);if(!It||It.terminalSessionId||(W(se,Te,!1),Fe.current!==se||Ie.current!==Te))return;zn(jt)&&a(),v(jt instanceof Error?jt.message:n("terminalView.error.startSessionFailed")),B(!0),de(!1);return}finally{nt.current.delete(yt)}}!xt||k||(Be.current=xt,Ee(se,Te,xt))})(),()=>{k=!0,Be.current=null,ke()}},[T,I,$,te,fe,A,et,p,z,q,W,P,X,Ee,ke,a,n,r,m,u]),d.useEffect(()=>{if(!xe||j)return;if(typeof window>"u"){Ye();return}const k=window.requestAnimationFrame(()=>{Ye()});return()=>{window.cancelAnimationFrame(k)}},[A,Ye,xe,j]);const qe=d.useCallback(async()=>{if(!I||We||ce)return;const k=lt.getState().getDirectoryState(I),O=p?A??k?.activeTabId??k?.tabs[0]?.id??null:k?.tabs[0]?.id??null;if(!O)return;const se=k?.tabs.find(Ce=>Ce.id===O)?.terminalSessionId??null;if(!(!se||!r.restartSession)){_e(!0),v(null),B(!1),de(!1),ke(),Ve();try{const Ce=Ke.current??br,Ae=await r.restartSession(se,{cwd:I,shell:u,loginShell:m,...Ce,...c.current});if(lt.getState().getDirectoryState(I)?.tabs.find(it=>it.id===O)?.terminalSessionId!==se||(X(I,O,Ae.sessionId),P(I,O,"running"),Fe.current!==I||Ie.current!==O))return;Be.current=Ae.sessionId,Ee(I,O,Ae.sessionId)}catch(Ce){if(lt.getState().getDirectoryState(I)?.tabs.find(Te=>Te.id===O)?.terminalSessionId!==se||Fe.current!==I||Ie.current!==O)return;zn(Ce)&&a(),v(Ce instanceof Error?Ce.message:n("terminalView.error.restartFailed")),B(!1),de(!1),Be.current=se,Ee(I,O,se)}finally{_e(!1)}}},[A,ke,I,p,ce,We,a,Ve,P,X,Ee,n,r,m,u]),pt=d.useCallback(async()=>{await qe()},[qe]),ft=d.useCallback(()=>{if(!I)return;const k=ne(I);Q(I,k),v(null),B(!1),de(!1),ke()},[ne,ke,I,Q]),gt=d.useCallback(()=>{const k=He.current?.getSelection(),O=_??(F?.open?"draft":null);!k||!O||!Z||!x||M({directory:x,sessionKey:O},{source:"terminal",fileLabel:Z.label,startLine:k.startLine,endLine:k.endLine,code:k.text,language:"",terminalId:Z.terminalSessionId??Z.id,text:""})},[Z,M,x,_,F?.open]),Ct=d.useCallback(k=>{I&&(Q(I,k),v(null),B(!1),de(!1),ke())},[ke,I,Q]),y=d.useCallback(k=>{if(!I)return;k===A&&ke(),v(null),B(!1),de(!1);const O=lt.getState().getDirectoryState(I)?.tabs.find(se=>se.id===k)?.terminalSessionId;(async()=>{O&&await r.close(O),H(I,k)})().catch(se=>v(se instanceof Error?se.message:n("terminalView.error.sessionEnded")))},[A,H,ke,I,n,r]),G=d.useCallback(k=>{if(!k||oe)return;let O=k,se=!1;pe&&k.length>0&&(O=wf(k,pe),se=!0);const Ce=Be.current;Ce&&(r.sendInput(Ce,O).catch(Ae=>{oe||v(Ae instanceof Error?Ae.message:n("terminalView.error.sendInputFailed"))}),se&&(Ne(null),ze()))},[pe,ze,oe,Ne,n,r]),Re=d.useCallback((k,O)=>{const se=Ke.current;if((!se||se.cols!==k||se.rows!==O)&&(Ke.current={cols:k,rows:O}),!xe)return;const Ce=Be.current;Ce&&r.resize({sessionId:Ce,cols:k,rows:O}).catch(()=>{})},[xe,r]),Le=d.useCallback(k=>{Ne(O=>O===k?null:k),ze()},[ze,Ne]),N=d.useCallback(k=>{const O=yf(k,pe);O&&(G(O),Ne(null),ze())},[pe,ze,G,Ne]),ie=d.useMemo(()=>({Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc"}),[]),ye=d.useCallback(k=>{if(k.repeat)return;const O=k.key;if(!O||O==="Control"||O==="Meta"||O==="Alt"||O==="Shift")return;const se=O.length===1?O.toLowerCase():O;if(se in ie){k.preventDefault(),k.stopPropagation(),N(ie[se]);return}if(pe!=="ctrl")return;const Ce=k.code??"",Ae=O.length===1&&/[a-zA-Z]/.test(O)?O.toUpperCase():Ce.startsWith("Key")&&Ce.length===4?Ce.slice(3).toUpperCase():null;if(Ae&&Ae.length===1&&Ae>="A"&&Ae<="Z"){const Te=bo(Ae);if(!Te)return;k.preventDefault(),k.stopPropagation(),G(Te),Ne(null),ze()}},[pe,ze,N,G,ie,Ne]);d.useEffect(()=>{if(!(!L||!pe||!te))return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},[pe,ye,L,te]);const ve=d.useMemo(()=>{const k=ys[Xs].stack;if(typeof window>"u")return(ys[l]??ys[Xs]).stack;const se=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return se&&se.trim().length>0?se.trim():(ys[l]??ys[Xs]).stack??k},[l]),Se=d.useMemo(()=>Yu(i),[i]),Oe=`${I??"no-dir"}::${A??"no-tab"}`;if(d.useEffect(()=>{if(!xe||j)return;const k=He.current;if(!k)return;const O=()=>{k.fit()};if(typeof window<"u"){const se=window.requestAnimationFrame(()=>{O(),Ye()}),Ce=[220,400].map(Ae=>window.setTimeout(O,Ae));return()=>{window.cancelAnimationFrame(se),Ce.forEach(Ae=>window.clearTimeout(Ae))}}O()},[Ye,xe,j,Oe,te]),d.useEffect(()=>{if(!xe||!j)return;let k=null;const O=()=>{k!==null&&window.cancelAnimationFrame(k),k=window.requestAnimationFrame(()=>{k=null,He.current?.fit()})};return window.addEventListener("oc:keyboard-settled",O),()=>{window.removeEventListener("oc:keyboard-settled",O),k!==null&&window.cancelAnimationFrame(k)}},[xe,Oe,j]),!T)return t.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:n("terminalView.empty.selectSession")});if(!I)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:n("terminalView.empty.noWorkingDirectoryForSession")}),t.jsx("button",{onClick:qe,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:n("terminalView.actions.retry")})]});const Ge=!te||re||We||oe,at=et,ct=g?"lg":"xs",ut=g?"w-10 p-0":"w-9 p-0",ot=k=>{g&&k.preventDefault()},bt=t.jsxs(t.Fragment,{children:[t.jsx(Pe,{type:"button",size:ct,variant:"outline",onPointerDown:ot,onClick:()=>N("esc"),disabled:Ge,children:n("terminalView.quickKeys.escape")}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("tab"),disabled:Ge,children:[t.jsx(E,{name:"arrow-right",className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.tabAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"chip","aria-pressed":pe==="ctrl",className:g?"px-3":"px-2",onPointerDown:ot,onClick:()=>Le("ctrl"),disabled:Ge,children:[t.jsx("span",{className:"text-xs font-medium",children:bn("ctrl")}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.controlModifierAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"chip","aria-pressed":pe==="alt",className:g?"px-3":"px-2",onPointerDown:ot,onClick:()=>Le("alt"),disabled:Ge,children:[t.jsx("span",{className:"text-xs font-medium",children:bn("alt")}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.altModifierAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("arrow-up"),disabled:Ge,children:[t.jsx(E,{name:"arrow-up"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowUpAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("arrow-left"),disabled:Ge,children:[t.jsx(E,{name:"arrow-left"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowLeftAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("arrow-down"),disabled:Ge,children:[t.jsx(E,{name:"arrow-down"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowDownAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("arrow-right"),disabled:Ge,children:[t.jsx(E,{name:"arrow-right"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.arrowRightAria")})]}),t.jsxs(Pe,{type:"button",size:ct,variant:"outline",className:ut,onPointerDown:ot,onClick:()=>N("enter"),disabled:Ge,children:[t.jsx(E,{name:"arrow-go-back"}),t.jsx("span",{className:"sr-only",children:n("terminalView.quickKeys.enterAria")})]})]});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[t.jsxs("div",{className:ae("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",g?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[p&&R?t.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[t.jsx("div",{className:ae("min-w-0 flex-1",g?"h-8":"h-7"),children:t.jsx(Cs,{items:ee,activeId:A,onSelect:Ct,onClose:y,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),t.jsx(Pe,{type:"button",size:"xs",variant:"ghost",className:ae("shrink-0",g?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:ft,title:n("terminalView.tabs.newTabTitle"),children:t.jsx(E,{name:"add",className:`${g?"h-[18px] w-[18px]":"h-4 w-4"}`})}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[t.jsx(Pe,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{qe()},disabled:We||ce,title:n("terminalView.actions.restart"),"aria-label":n("terminalView.actions.restart"),children:t.jsx(E,{name:"restart",className:"h-4 w-4"})}),t.jsx(Pe,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 p-0",onClick:gt,title:n("terminalView.actions.attachSelection"),"aria-label":n("terminalView.actions.attachSelection"),children:t.jsx(E,{name:"attachment-2",className:"h-4 w-4"})}),he?t.jsxs(Pe,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{x&&K(x,he)},title:n("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:n("terminalView.preview.open")})]}):null]})]}):null,!g&&L&&p&&R?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:bt}):null,!g&&L&&(!p||!R)?t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:bt}):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:at?t.jsx(ho,{ref:k=>{He.current=k},sessionKey:Oe,chunks:me,onInput:G,onResize:Re,theme:Se,monoFont:l,fontFamily:ve,fontSize:f,enableTouchScroll:j,autoFocus:xe,isVisible:xe},Oe):null}),!oe&&ge&&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:ge}),J&&g&&t.jsx(Pe,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:pt,disabled:We,title:n("terminalView.actions.hardRestartTitle"),type:"button",children:n("terminalView.actions.hardRestart")})]})]}),g&&L?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:bt})}):null]})},Sm=s=>{const e=$e.c(31),{rootIsGitRepo:n,resolvedIsGitRepo:r,nestedRepos:o,onRetryDiscovery:a,emptyStateFooter:i}=s,{t:c}=st();if(n!==!1||r===!0)return null;if(o==null){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[0]=m):m=e[0];let w;e[1]!==o||e[2]!==c?(w=c(o===null?"gitView.empty.discoverFailed":"gitView.empty.discoveringRepositories"),e[1]=o,e[2]=c,e[3]=w):w=e[3];let h;e[4]!==w?(h=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:w}),e[4]=w,e[5]=h):h=e[5];let b;e[6]!==o||e[7]!==a||e[8]!==c?(b=o===null?t.jsxs(Pe,{type:"button",variant:"outline",size:"sm",className:"mt-3 gap-1.5",onClick:a,children:[t.jsx(E,{name:"refresh",className:"size-4"}),c("gitView.empty.retryDiscovery")]}):null,e[6]=o,e[7]=a,e[8]=c,e[9]=b):b=e[9];let g;return e[10]!==h||e[11]!==b?(g=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[m,h,b]}),e[10]=h,e[11]=b,e[12]=g):g=e[12],g}if(o==="unsupported"||o.length===0){let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(E,{name:"git-branch",className:"mb-3 size-6 text-muted-foreground"}),e[13]=m):m=e[13];let w;e[14]!==c?(w=c("gitView.empty.notGitRepository"),e[14]=c,e[15]=w):w=e[15];let h;e[16]!==w?(h=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:w}),e[16]=w,e[17]=h):h=e[17];let b;e[18]!==c?(b=c("gitView.empty.notGitRepositoryDescription"),e[18]=c,e[19]=b):b=e[19];let g;e[20]!==b?(g=t.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:b}),e[20]=b,e[21]=g):g=e[21];let j;return e[22]!==i||e[23]!==h||e[24]!==g?(j=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[m,h,g,i]}),e[22]=i,e[23]=h,e[24]=g,e[25]=j):j=e[25],j}let l;e[26]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(E,{name:"loader-4",className:"mb-3 size-6 animate-spin text-muted-foreground"}),e[26]=l):l=e[26];let f;e[27]!==c?(f=c("gitView.loading.checkingRepository"),e[27]=c,e[28]=f):f=e[28];let u;return e[29]!==f?(u=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center",children:[l,t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:f})]}),e[29]=f,e[30]=u):u=e[30],u},jm=()=>{_r(),fs.reconnectToRuntimeBaseUrl(),Br()},Nm=s=>{tt.getState().prepareForRuntimeSwitch(s.previousRuntimeKey),s.previousRuntimeKey&&oi.getState().stopRunningRunsForRuntime(s.previousRuntimeKey),_r(),lt.getState().clearAll(),fs.reconnectToRuntimeBaseUrl(),kt.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),Tt.getState().resetForRuntimeSwitch(),Rt.getState().reset(),Jt.getState().resetForRuntimeSwitch(),ai(new Map),ii(),li(),ci.getState().reset(),Ri.getState().resetForRuntimeSwitch(s.previousRuntimeKey),Ai.getState().resetForRuntimeSwitch(),In.getState().resetForRuntimeSwitch(s.runtimeKey),di.getState().resetForRuntimeSwitch(),ui.getState().resetForRuntimeSwitch(s.runtimeKey),Bi.getState().resetForRuntimeSwitch(s.runtimeKey),yn.getState().resetForRuntimeSwitch(),Ns.getState().resetForRuntimeSwitch(),fi.getState().resetForRuntimeSwitch(),mi.getState().resetForRuntimeSwitch(),hi.getState().resetForRuntimeSwitch(),Dt.getState().reset(),Ue.getState().applyLinearIssueListFiltersForRuntime(),tt.getState().restoreForRuntimeSwitch(s.runtimeKey),Br(),queueMicrotask(()=>{Mi()})};export{_u as $,Al as A,td as B,Xf as C,fm as D,Ml as E,Bl as F,Yl as G,tm as H,em as I,Jl as J,ql as K,Dc as L,am as M,mm as N,Qf as O,xm as P,rm as Q,Rf as R,dm as S,vm as T,Jf as U,hm as V,pm as W,gm as X,uc as Y,rn as Z,xd as _,rd as a,om as a0,Yf as a1,qt as a2,Rc as a3,Ac as a4,Ll as a5,qf as a6,um as a7,od as b,Sm as c,Cs as d,Nm as e,cm as f,im as g,lm as h,Zf as i,Kf as j,nr as k,mc as l,Cf as m,hc as n,Bf as o,Td as p,nm as q,jm as r,Ef as s,sm as t,pl as u,ym as v,wm as w,pf as x,bm as y,Dn as z};