@yuriai/web 0.3.3-beta.7 → 0.3.3

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 (172) hide show
  1. package/dist/assets/{AgentAvatar-BMyOvw1S.js → AgentAvatar-CHCjMxCF.js} +1 -1
  2. package/dist/assets/{AgentSelector-DjvFTge_.js → AgentSelector-DpOQ7dyw.js} +1 -1
  3. package/dist/assets/ArchivedSessionsDialog-nqnWb-Vc.js +1 -0
  4. package/dist/assets/{AssistantConversationSurface-CbB08eUc.js → AssistantConversationSurface-CKXgty02.js} +3 -3
  5. package/dist/assets/{AssistantSessionCard-B5uaSamD.js → AssistantSessionCard-C2-2fJul.js} +2 -2
  6. package/dist/assets/{AssistantUnreadBadge-CrffD9Ox.js → AssistantUnreadBadge-p9mkpbMC.js} +1 -1
  7. package/dist/assets/{AssistantView-CWPh6KhU.js → AssistantView-BR8hsjOv.js} +1 -1
  8. package/dist/assets/{AssistantWorkingAvatar-C7TLqC2c.js → AssistantWorkingAvatar-CoxhuMvM.js} +1 -1
  9. package/dist/assets/{AssistantsSettingsPage-CqUeZz_6.js → AssistantsSettingsPage-Bwid1xE0.js} +1 -1
  10. package/dist/assets/{BinaryFileFallback-D85qP-k5.js → BinaryFileFallback-Cb3uP7y1.js} +1 -1
  11. package/dist/assets/BtwPanel-9VAdk_qa.js +6 -0
  12. package/dist/assets/BusyDots-DeDkh4Ke.js +4 -0
  13. package/dist/assets/{ChatContainer-B7K4osTN.js → ChatContainer-wP6o_O4K.js} +21 -21
  14. package/dist/assets/ChatView-DU_2-cfD.js +3 -0
  15. package/dist/assets/{DiagramView-DPUg5cMA.js → DiagramView-CaefmjA4.js} +1 -1
  16. package/dist/assets/{DiffView-C6DEdXdm.js → DiffView-BaqthIvq.js} +1 -1
  17. package/dist/assets/{DiffViewToggle-BTeyGjzp.js → DiffViewToggle-BwJ6MYB7.js} +1 -1
  18. package/dist/assets/{ErrorBoundary-DtsSmzjn.js → ErrorBoundary-_5B1xjgZ.js} +1 -1
  19. package/dist/assets/{FadeInOnReveal-CsCYrMAl.js → FadeInOnReveal-BYHr1gqj.js} +1 -1
  20. package/dist/assets/{GuiPluginMount-CivDyUvN.js → GuiPluginMount-Btp3mJT2.js} +1 -1
  21. package/dist/assets/{GuiPluginPage-BeFJN9rd.js → GuiPluginPage-DM_RLx6u.js} +1 -1
  22. package/dist/assets/{GuiPluginSurface-C770Vmoc.js → GuiPluginSurface-KiyqqEKU.js} +1 -1
  23. package/dist/assets/{GuiPluginTitlebarItems-CjphhXcO.js → GuiPluginTitlebarItems-DxFINwbr.js} +1 -1
  24. package/dist/assets/{GuiPluginWindow-LOsErAXl.js → GuiPluginWindow-BkAFJyFd.js} +1 -1
  25. package/dist/assets/{Icon-BLvjcKMe.js → Icon-DmykXZL1.js} +1 -1
  26. package/dist/assets/{ImageLoadingPlaceholder-CepamQfa.js → ImageLoadingPlaceholder-DgM_EFHn.js} +1 -1
  27. package/dist/assets/{LoadingImage-CJQhmN6k.js → LoadingImage-Df22Rkor.js} +1 -1
  28. package/dist/assets/MarkdownRenderer-D7p9Iflj.js +2 -0
  29. package/dist/assets/{MarkdownRendererImpl-BBmjvHcO.js → MarkdownRendererImpl-BZc_jUrV.js} +2 -2
  30. package/dist/assets/{MarkstreamRendererImpl-BrUwQjka.js → MarkstreamRendererImpl-BUk_c3g1.js} +1 -1
  31. package/dist/assets/{MobileAssistantSettingsPage-DBl7VNVJ.js → MobileAssistantSettingsPage-BBIiFN2g.js} +1 -1
  32. package/dist/assets/{MobileAssistantTab-BsxiOYep.js → MobileAssistantTab-CMIQansR.js} +1 -1
  33. package/dist/assets/{MobileBtwPage-CdFSaIWx.js → MobileBtwPage-DVZm5hrZ.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-G84PMQ4F.js → MobileChangesSurface-CiqsGZsg.js} +1 -1
  35. package/dist/assets/{MobileChatScreen-BxkkAw15.js → MobileChatScreen-DDenVTX8.js} +1 -1
  36. package/dist/assets/{MobileDetailNavigation-DzmPZiX2.js → MobileDetailNavigation-ldTzGo19.js} +1 -1
  37. package/dist/assets/{MobileFilesSurface-CXb_s2LT.js → MobileFilesSurface-DIVH9aPV.js} +2 -2
  38. package/dist/assets/{MobileHtmlNetworkBoundary-Dnzk1vzw.js → MobileHtmlNetworkBoundary-TBxrF4jJ.js} +2 -2
  39. package/dist/assets/{MobileOverlayPanel-Bqorq1sh.js → MobileOverlayPanel-C36VWWmN.js} +1 -1
  40. package/dist/assets/{MobileResizableSheet-DqBQmWZR.js → MobileResizableSheet-CqphcaKq.js} +1 -1
  41. package/dist/assets/{MobileSettingsTab-CtVgHZJU.js → MobileSettingsTab-MmDnxG47.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-BoZE2atm.js → MobileShareBridge-DAlGSXoj.js} +1 -1
  43. package/dist/assets/{MobileSurface-qkgXdsHc.js → MobileSurface-cmaGf3hZ.js} +1 -1
  44. package/dist/assets/{MobileTabPageHeader-BcxLuIaE.js → MobileTabPageHeader-D6P4K98S.js} +1 -1
  45. package/dist/assets/{ModelLogo-DTkCJzj-.js → ModelLogo-BkbD514M.js} +1 -1
  46. package/dist/assets/{ModelSelector-BN7tJsu7.js → ModelSelector-HJmXcB3j.js} +1 -1
  47. package/dist/assets/{MultiRunWindow-BOLguz2X.js → MultiRunWindow-BmxVnblA.js} +1 -1
  48. package/dist/assets/{OnboardingScreen-C8BRto1e.js → OnboardingScreen-DnEtIaxG.js} +1 -1
  49. package/dist/assets/{OverlayScrollbar-lHvfLKuz.js → OverlayScrollbar-D6vmoMkQ.js} +1 -1
  50. package/dist/assets/{PierreDiffViewer-CW1R8hHt.js → PierreDiffViewer-B1e1H6br.js} +1 -1
  51. package/dist/assets/{ProviderLogo-BcbWSLI8.js → ProviderLogo-DA98yu7M.js} +1 -1
  52. package/dist/assets/{RemoteAssistantSessionCard-B53bp3bD.js → RemoteAssistantSessionCard-BgL7oxAK.js} +1 -1
  53. package/dist/assets/{RemoteDesktopPanel-DgiOjJIb.js → RemoteDesktopPanel-DBrEQwpr.js} +1 -1
  54. package/dist/assets/{ScheduledTasksDialog-CgzzcaoZ.js → ScheduledTasksDialog-BVh0yaZR.js} +2 -2
  55. package/dist/assets/{ScrollableOverlay-By9Xj7Dt.js → ScrollableOverlay-stxT7gLf.js} +1 -1
  56. package/dist/assets/{SettingsGroup-HFyD41Fr.js → SettingsGroup-CvaPYznp.js} +1 -1
  57. package/dist/assets/{SettingsView-Dq1ykKpv.js → SettingsView-CLE6ra3s.js} +10 -10
  58. package/dist/assets/{SettingsWindow-CIMjBpqt.js → SettingsWindow-DpzeOekS.js} +1 -1
  59. package/dist/assets/{SetupTourDialog-CMiSn6j9.js → SetupTourDialog-CY_CU5qU.js} +1 -1
  60. package/dist/assets/{SyncActions-CIrflsf0.js → SyncActions-CrOoREWF.js} +1 -1
  61. package/dist/assets/{TerminalView-CuvylS2B.js → TerminalView-mO5f0Axl.js} +1 -1
  62. package/dist/assets/{TextSelectionMenu-Cu7FN5ja.js → TextSelectionMenu-VsKriqtT.js} +1 -1
  63. package/dist/assets/{ToolOutputDialog-ph2fXE2y.js → ToolOutputDialog-DqCCsC-N.js} +1 -1
  64. package/dist/assets/{YuriLogo-Dh6Zy7-k.js → YuriLogo-Cp6vWDWp.js} +1 -1
  65. package/dist/assets/{assistantMessagePreview-CDi-qTU6.js → assistantMessagePreview-DLBvPQtq.js} +1 -1
  66. package/dist/assets/{assistantQueries-DlXx9G2k.js → assistantQueries-NdPqu6rx.js} +1 -1
  67. package/dist/assets/{auto-read-context-CgvMs7Ew.js → auto-read-context-DVGIDEr6.js} +1 -1
  68. package/dist/assets/{capgoAdapter-LNbcqkI5.js → capgoAdapter-94K243Zv.js} +1 -1
  69. package/dist/assets/{card-DG0czc0D.js → card-DmysoUAV.js} +1 -1
  70. package/dist/assets/{chatUpwardIntent-PAbn9QBv.js → chatUpwardIntent-tvLWGs9Q.js} +1 -1
  71. package/dist/assets/{checkbox-B6qJy2q5.js → checkbox-BMN5hAVm.js} +1 -1
  72. package/dist/assets/{collapsible-7JLOH-sI.js → collapsible-Z0IjDAMO.js} +1 -1
  73. package/dist/assets/{connection-hint-B5jzYxF5.js → connection-hint-B-kOWome.js} +1 -1
  74. package/dist/assets/{context-menu-DLkbq4VB.js → context-menu-CKlB6wxo.js} +1 -1
  75. package/dist/assets/{diagram-BjjqtBwW.js → diagram-CzY6n_4N.js} +1 -1
  76. package/dist/assets/{dialog-BjoDEvdt.js → dialog-BeFBA6ja.js} +1 -1
  77. package/dist/assets/{dropdown-menu-1XT-gOct.js → dropdown-menu-BblI9sN2.js} +1 -1
  78. package/dist/assets/{es-CgrPbaq2.js → es-DqYZgeC6.js} +1 -1
  79. package/dist/assets/{fileMentionTouchSelection-i5rR1buz.js → fileMentionTouchSelection-BQEUty_A.js} +1 -1
  80. package/dist/assets/{fr-B6DCYpJP.js → fr-BHaun7Zq.js} +1 -1
  81. package/dist/assets/{gitApi-D_jhXTt_.js → gitApi-BWsBS_2N.js} +1 -1
  82. package/dist/assets/{i18n-ByGlB3HF.js → i18n-DXc6czdR.js} +1 -1
  83. package/dist/assets/{icons-C-c38sK-.js → icons-Bd-INsoy.js} +1 -1
  84. package/dist/assets/{input-DCG7mwtP.js → input-Cf16qJ6g.js} +1 -1
  85. package/dist/assets/insertionBoundaries-BSDUOMHN.js +1 -0
  86. package/dist/assets/{ja-2cg_IC2I.js → ja-BGNugvrx.js} +1 -1
  87. package/dist/assets/{kbd-DUjBYHW8.js → kbd-CamdaxHJ.js} +1 -1
  88. package/dist/assets/{ko-Cu4ZaN5G.js → ko-CGbNBfDe.js} +1 -1
  89. package/dist/assets/{main-BBrAYdja.js → main-CHO9s_kb.js} +2 -2
  90. package/dist/assets/main-DAbyAg5_.js +169 -0
  91. package/dist/assets/{markdownHeightCache-RG3lV4ki.js → markdownHeightCache-CHGGNhWI.js} +1 -1
  92. package/dist/assets/{mcpQueries-w3NIPhbC.js → mcpQueries-1WNtiFYh.js} +1 -1
  93. package/dist/assets/miniChat-BZMkNMht.js +2 -0
  94. package/dist/assets/{mobile-UvHaKFPy.js → mobile-C9XDDOHq.js} +2 -2
  95. package/dist/assets/{mobileBackNavigation-4qLXJUZN.js → mobileBackNavigation-DF_uhF-i.js} +1 -1
  96. package/dist/assets/{mobileConnections-Dpq17An0.js → mobileConnections-DjT1L-_m.js} +2 -2
  97. package/dist/assets/multirun-D34EMeEj.js +3 -0
  98. package/dist/assets/{native-config-DFjLIuqz.js → native-config-DSpTDz3F.js} +1 -1
  99. package/dist/assets/{nativeComposerCover-CivHtrWS.js → nativeComposerCover-DXFy97OQ.js} +1 -1
  100. package/dist/assets/{navigation-B_4E2p49.js → navigation-jU0HUH9s.js} +1 -1
  101. package/dist/assets/{openRemoteProjectSession-DAER2JWb.js → openRemoteProjectSession-Bm_nafYw.js} +1 -1
  102. package/dist/assets/{pl-7PeuQHGy.js → pl-k8-4URiE.js} +1 -1
  103. package/dist/assets/{pluginPresentation-BDGZINXk.js → pluginPresentation-DexqrdQ0.js} +2 -2
  104. package/dist/assets/{pt-BR-B18khyq7.js → pt-BR-DdwCzXBH.js} +1 -1
  105. package/dist/assets/pwa-BaWpUiOR.js +2 -0
  106. package/dist/assets/{queue-abort-optimistic-Coy1T1Qy.js → queue-abort-optimistic-UwpgXn4g.js} +1 -1
  107. package/dist/assets/{quota-CfWnlc-n.js → quota-CqWNkFzw.js} +1 -1
  108. package/dist/assets/{reference-history-BlQiy_nb.js → reference-history-DBxnA_fF.js} +1 -1
  109. package/dist/assets/{remoteSessionReference-CLzAvFKI.js → remoteSessionReference-Cug8RfIG.js} +1 -1
  110. package/dist/assets/{renderElectronMiniChatApp-BqxpFP6D.js → renderElectronMiniChatApp-CqrlQAsJ.js} +2 -2
  111. package/dist/assets/renderMobileApp-CwcwGOox.js +17 -0
  112. package/dist/assets/{runtimeConfig-lcYYeoCg.js → runtimeConfig-zzeYHX6k.js} +1 -1
  113. package/dist/assets/{runtimeEndpointReset-CwRG2_aT.js → runtimeEndpointReset-DUD-TCLY.js} +4 -4
  114. package/dist/assets/{select-BjsrUiHl.js → select-vZCgcnYG.js} +1 -1
  115. package/dist/assets/{session-startup-barrier-BfAFvTz_.js → session-startup-barrier-DT-hIBRf.js} +1 -1
  116. package/dist/assets/{sessionLookup-C-6PgSD0.js → sessionLookup-4zOaVAuF.js} +1 -1
  117. package/dist/assets/{sessionOwnership-QwBlmZrm.js → sessionOwnership-CEkPFbS4.js} +1 -1
  118. package/dist/assets/{shortcuts-kbr1xn9y.js → shortcuts-WkN3Gh8v.js} +1 -1
  119. package/dist/assets/{sortable-tabs-strip-CitX5Org.js → sortable-tabs-strip-DmtfYPz0.js} +1 -1
  120. package/dist/assets/{speechSettingsQueries-BV_Pl_yS.js → speechSettingsQueries-DQnPLEf3.js} +1 -1
  121. package/dist/assets/src-QTj33Z0x.css +2 -0
  122. package/dist/assets/{store-CHWK-CqR.js → store-C1ifDY0C.js} +3 -3
  123. package/dist/assets/{switch-DiEXd4Rk.js → switch-CNmsFYfY.js} +1 -1
  124. package/dist/assets/{textarea-BXKtOkSw.js → textarea-ZiXxEOHK.js} +1 -1
  125. package/dist/assets/{timeFormat-CkKq2gbp.js → timeFormat-dCsf2MQv.js} +1 -1
  126. package/dist/assets/{tooltip-ccmDDb27.js → tooltip-CpTbxEOE.js} +1 -1
  127. package/dist/assets/{truncated-path-WQoHq84P.js → truncated-path-CcmWjgCQ.js} +1 -1
  128. package/dist/assets/types-s_oc_LRs.js +2 -0
  129. package/dist/assets/{ui-BBJAK87V.js → ui-DrAJTWV6.js} +9 -9
  130. package/dist/assets/{uk-B8oVVfyT.js → uk-DU-7fAP4.js} +1 -1
  131. package/dist/assets/{useAppFontEffects-Qz_MYSp2.js → useAppFontEffects-nvkTSYHB.js} +4 -4
  132. package/dist/assets/{useDesktopWindowControlsLayout-jzHx4r3Z.js → useDesktopWindowControlsLayout-i6qqpMbd.js} +1 -1
  133. package/dist/assets/{useDictation-DxbKP53d.js → useDictation-CZzAlsW0.js} +1 -1
  134. package/dist/assets/{useEffectiveDirectory-BjJFgVDo.js → useEffectiveDirectory-BxolHzt4.js} +1 -1
  135. package/dist/assets/{useGitStore-__WQm2ss.js → useGitStore-B641o_o0.js} +1 -1
  136. package/dist/assets/{useInlineCommentDraftStore-DDVhdall.js → useInlineCommentDraftStore-B2mkmAZd.js} +1 -1
  137. package/dist/assets/{useMcpConfigStore-B9xxBbIA.js → useMcpConfigStore-BUSvv0Bl.js} +1 -1
  138. package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +1 -0
  139. package/dist/assets/useMobileTranscriptSyncHint-86i3xO8J.js +10 -0
  140. package/dist/assets/{useModelLists-BSDtEidb.js → useModelLists-Ca085-di.js} +1 -1
  141. package/dist/assets/{useOpenCodeReadiness-4gtPD0YS.js → useOpenCodeReadiness-CsNcdsCJ.js} +1 -1
  142. package/dist/assets/usePluginsStore-ZHQOW-R5.js +1 -0
  143. package/dist/assets/{useProjectGitActions-B4Gr0aOm.js → useProjectGitActions-1QRsD7Rb.js} +1 -1
  144. package/dist/assets/{useProjectGitStore-YLxAq2tN.js → useProjectGitStore-C1K6WpCe.js} +1 -1
  145. package/dist/assets/{useProjectRuntimeAPIs-KvnGYSW7.js → useProjectRuntimeAPIs-BItoD9Bt.js} +1 -1
  146. package/dist/assets/{useQuotaStore-BiF4Uh3a.js → useQuotaStore-CSn2pk3T.js} +1 -1
  147. package/dist/assets/{useSessionBtwStore-D0X_QY4j.js → useSessionBtwStore-BCHq3UOB.js} +1 -1
  148. package/dist/assets/{useStreamingTextThrottle-n7T02P5g.js → useStreamingTextThrottle-DGAjmaMZ.js} +1 -1
  149. package/dist/assets/{worktreeManager-DG7xNQ2O.js → worktreeManager-QmahFqHc.js} +1 -1
  150. package/dist/assets/{worktreeSourceBranchPreference-CkNHSsTL.js → worktreeSourceBranchPreference-B5Fldnhm.js} +1 -1
  151. package/dist/assets/{zh-CN-q5EBLCd8.js → zh-CN-DOHH7nht.js} +1 -1
  152. package/dist/assets/{zh-TW-B8dWtU1k.js → zh-TW-t1qlXGOg.js} +1 -1
  153. package/dist/index.html +6 -6
  154. package/dist/mini-chat.html +6 -6
  155. package/dist/mobile.html +2 -2
  156. package/package.json +1 -1
  157. package/dist/assets/ArchivedSessionsDialog-WPrvCBi1.js +0 -1
  158. package/dist/assets/BtwPanel-CtLW0udb.js +0 -6
  159. package/dist/assets/BusyDots-DbMzMIeN.js +0 -4
  160. package/dist/assets/ChatView-BFrPmZ4J.js +0 -3
  161. package/dist/assets/MarkdownRenderer-CSkl6FsA.js +0 -2
  162. package/dist/assets/insertionBoundaries-98_64UQf.js +0 -1
  163. package/dist/assets/main-BoXIEInN.js +0 -169
  164. package/dist/assets/miniChat-DsAFkq0l.js +0 -2
  165. package/dist/assets/multirun-Bzf-9V4P.js +0 -3
  166. package/dist/assets/pwa-ax7afoF2.js +0 -2
  167. package/dist/assets/renderMobileApp-CCZSPYop.js +0 -17
  168. package/dist/assets/src-CGjpov7O.css +0 -2
  169. package/dist/assets/types-C2asfTP5.js +0 -2
  170. package/dist/assets/useMobileSwipeActions-DAujwA-Y.js +0 -1
  171. package/dist/assets/useMobileTranscriptSyncHint-CI8AZGRi.js +0 -10
  172. package/dist/assets/usePluginsStore-BJYXkska.js +0 -1
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-C6UIEZxp.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-auth-DA-qfGHk.js","assets/platform-CiUKDeXd.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CTekDqaS.js","assets/vendor-base-ui-wXsskyKm.js","assets/prompt-attachment-upload-B5DHrw6U.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-file-resource-Bc_ss-sW.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/yuriEvents-BFrD5fMU.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/input-store-BSJBQTMi.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/uuid-D-SDZijH.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{d as r}from"./platform-CiUKDeXd.js";import{a as i}from"./vendor-zustand-CTekDqaS.js";import{ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{St as s}from"./gitApiHttp-Dd-FwgCq.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as c,R as l,Wt as u,Xt as d,at as f,dr as p,en as m,it as h,n as g,nr as _,on as v,rt as y,tn as b,tr as x}from"./client-B_907PBv.js";import{n as S}from"./vendor-react-BkccXcWz.js";import{o as C,s as w}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as T}from"./yuriEvents-BFrD5fMU.js";import{A as E,E as D,I as O,R as k,k as A}from"./runtime-file-resource-Bc_ss-sW.js";import{r as ee}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as j}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as M}from"./useUIStore-C3ewjGgP.js";import{s as N}from"./spacedFileMention-Ds4GtgiF.js";import{i as P,o as F,r as I}from"./session-startup-barrier-BfAFvTz_.js";import{n as L}from"./Icon-BLvjcKMe.js";import{Ar as R,B as te,Bi as z,Da as ne,Er as B,Fa as V,Fn as re,Gt as ie,H as ae,Jr as H,Li as oe,Ma as se,Mn as U,Nn as ce,Or as W,Pn as le,Qr as ue,Ri as de,Tn as fe,U as pe,Vi as me,Xn as he,Yr as ge,bt as _e,ci as ve,dt as ye,f as G,ft as be,gt as xe,ht as Se,j as Ce,kr as we,li as Te,ln as Ee,lt as De,mt as Oe,nr as ke,oi as Ae,on as je,pt as Me,qi as Ne,qr as Pe,si as K,t as q,ui as J,ur as Y,wn as Fe}from"./ui-BBJAK87V.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-C8382jM8.js";import{t as ze}from"./i18n-ByGlB3HF.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-By9Xj7Dt.js";import{t as He}from"./MobileResizableSheet-DqBQmWZR.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-BjoDEvdt.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-ccmDDb27.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-1XT-gOct.js";import{n as et}from"./useProjectRuntimeAPIs-KvnGYSW7.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-D_jhXTt_.js";import{o as at,t as ot}from"./useProjectGitStore-YLxAq2tN.js";import{t as st}from"./input-DCG7mwtP.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-B6qJy2q5.js";import{t as ut}from"./MobileOverlayPanel-Bqorq1sh.js";import{t as dt}from"./githubAuthQueries-DqregESf.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-DG7xNQ2O.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-CkNHSsTL.js";import{s as St}from"./remote-input-store-C6UIEZxp.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-CitX5Org.js";import{f as Tt,m as Et}from"./auto-read-context-CgvMs7Ew.js";var Dt=2e3,Ot=i((e,t)=>({pending:!1,expiresAt:null,arm:(t=Dt)=>{let n=Date.now()+t;return e({pending:!0,expiresAt:n}),n},clear:()=>{!t().pending&&t().expiresAt===null||e({pending:!1,expiresAt:null})}})),X=e(o(),1),kt=new class{inFlightByScope=new WeakMap;generationByScope=new WeakMap;run(e){let t=this.inFlightByScope.get(e.scope);t||(t=new Map,this.inFlightByScope.set(e.scope,t));let n=t.get(e.key);if(n)return n;let r=this.generationByScope.get(e.scope);r||(r=new Map,this.generationByScope.set(e.scope,r));let i=(r.get(e.key)??0)+1;r.set(e.key,i);let a=e.request(()=>r?.get(e.key)!==i);return t.set(e.key,a),a.finally(()=>{t?.get(e.key)===a&&t.delete(e.key)}).catch(()=>{}),a}},At=e=>C({queryKey:[e.transport,`sessionChildren`,e.generation,r(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>T.fetchQuery(At(e)),Mt=(e,t)=>e.id<t.id?-1:+(e.id>t.id),Nt=(e,t,n)=>{let r=new Set(e.map(e=>e.id)),i=t.filter(e=>!e?.id||r.has(e.id)||e.parentID!==n?!1:(r.add(e.id),!0));return i.length===0?e:[...e,...i].sort(Mt)},Pt=30,Ft=new Map;function It(e,t=!1){return{limit:e.loadedTurns,cursor:e.kind===`has-more`?e.cursor:void 0,complete:e.kind===`exhausted`,loading:t}}function Lt(e,t){let n=d();if(!n)return!1;let r=n.getTranscript(v(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>R()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=re.search(r,t,e=>e.id);i.found?r[i.index]=n:r.splice(i.index,0,n),e.setState({session:r})}function Bt(){let e=_e(),r=ae(),i=te(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=d();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=v(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),s=(0,X.useCallback)((e,t)=>{if(t.length===0)return;let n=i.getChild(e);if(!n)return;let r=n.getState(),a={session_status:{...r.session_status},session_status_observed_at:{...r.session_status_observed_at},session_error_at:{...r.session_error_at},session_diff:{...r.session_diff},todo:{...r.todo},permission:{...r.permission},question:{...r.question}};U(a,t),Ce(n,t),n.setState(a);for(let n of t)m(e,n)},[i]),l=(0,X.useCallback)((t=e)=>{let n=Ft.get(t);if(n)return Ft.delete(t),Ft.set(t,n),n;let r=new Set;for(Ft.set(t,r);Ft.size>Pt;){let e=Ft.keys().next().value;if(!e)break;let t=[...Ft.get(e)??[]];Ft.delete(e),s(e,t)}return r},[e,s]),f=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=l(n),c=ce(a.getState()),u=W(),f=le({seen:o,keep:t,limit:u,preserve:c});if(s(n,f),we()){let e=new Set([t,...o,...c]),r=(d()?.getCacheBudget?.().listCanonical({directory:n})??[]).map(e=>e.scope.sessionID),i=(r.length>0?r:Array.from(o)).filter(r=>r===t||e.has(r)?!1:Lt(n,r));if(i.length>0){for(let e of i)o.delete(e);s(n,i)}}},[i,e,l,s,r]),h=(0,X.useCallback)(async(t,n)=>{let a=n?.directory??e;if(!t||!a||a===`global`)return;let o=a===e?r:i.ensureChild(a,{bootstrap:!1}),s=o.getState(),l=s.session_status?.[t],u=s.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await c(a,t):await b(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=d()?.getTranscript(v(a,t));Ee({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await Y({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:u,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),_=(0,X.useCallback)(async(t,n)=>{await I();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o);f(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=d(),a=v(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,u=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},f=re.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&u.kind!==`unknown`&&m?.status!==`error`&&f&&B(o,t)){Ee({directory:o,sessionID:t,store:s,isStale:e});return}let g=!!(r||!l||f),_=Rt({hasSession:f,shouldLoadMessages:g,force:!!r});await Promise.all([_?(async()=>{try{let n=await de(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=oe(p(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),g?h(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,f,h,e]),y=ee(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,f=await jt({transport:u,generation:l,directory:o,sessionID:r,request:async e=>{let i=[],a=new Set,s;do{if(e.throwIfAborted(),l!==n()||u!==t())throw new DOMException(`Session children runtime changed`,`AbortError`);let d=await c.session.list(s?{cursor:s,limit:50}:{directory:o,parentID:r,limit:50},{signal:e});if(!Array.isArray(d?.data))throw Error(`session.list children returned no data`);if(i.push(...d.data.map(p)),d.data.length<50)break;if(s=d.cursor?.next??void 0,!s||a.has(s))throw Error(`session.list children pagination did not advance`);a.add(s)}while(s);return i}}).catch(e=>{if(d())return null;throw e});!f||d()||s.setState(e=>{let t=Nt(e.session,f,r);return t===e.session?e:{session:t,limit:Math.max(e.limit,t.length)}})}),x=(0,X.useCallback)((t,n)=>{let r=o(t,n?.directory??e);return!r.complete&&!!r.cursor},[e,o]),S=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).loading,[e,o]),C=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).complete,[e,o]),w=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),E=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),D=ee(async(r,a)=>{if(!r)return;await I();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),u=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await b(o,r),u())return;Ee({directory:o,sessionID:r,store:s}),await Y({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(d()?.getTranscript(v(o,r)).messageOrder.length??0)>0,isStale:u})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:_,syncSession:_,loadChildren:y,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:D,optimistic:{add:w,remove:T,confirm:E}}),[_,y,x,S,C,D,w,T,E])}var Z=S(),Q=a(),Vt=(e,t)=>{if(!e)return t;let n=e.ready&&!e.loading;return{modelsReady:!e.error&&(e.modelsReady??n),agentsReady:!e.error&&(e.agentsReady??n)}},Ht=e=>{let t=e?.variants;if(!t)return[];if(Array.isArray(t)){let e=[],n=new Set;for(let r of t){let t=typeof r==`string`?r:r&&typeof r==`object`&&!Array.isArray(r)&&typeof r.id==`string`?r.id:``;!t||n.has(t)||(n.add(t),e.push(t))}return e}return typeof t==`object`?Object.keys(t):[]},Ut=(e,t,n,r)=>{if(e.providerID!==n||e.modelID!==r||t?.variantsReady===!1)return[];if(t?.variants)return[...t.variants];let i=(t?.providers?.find(e=>e.id===n))?.models?.find(e=>e.id===r);return Ht(i)},Wt=()=>!0,Gt=(e,t)=>(e.commandPolicy??Wt)(t),Kt=X.createContext(null),qt=()=>X.useContext(Kt),Jt=e=>e,Yt=(e,t)=>t??e,Xt=e=>{if(e.kind!==`primary`&&(!e.sessionID||!e.directory||!e.draftKey||!e.transportIdentity||!Number.isSafeInteger(e.runtimeGeneration)||!e.resources||typeof e.resources.busy!=`boolean`||!e.activity||!e.commands||!e.shortcuts))throw Error(`chat-input-secondary-surface-incomplete`)},Zt=(e,t)=>e.kind===`secondary`?e.resources?.busy??!1:t,Qt=e=>!e.sessionID||!e.directory?null:{deliveryTarget:e.deliveryTarget,sessionID:e.queueSessionID??e.sessionID,directory:e.directory,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration},$t=(e,t,n)=>{if(e.kind===`secondary`){if(!e.commands)throw Error(`chat-input-secondary-commands-incomplete`);return e.commands}return e.commands?e.commands:{sessionID:e.sessionID,hasMessages:t,hasNewDraft:n}},en={phase:`idle`,isWorking:!1,isBusy:!1,isCooldown:!1},tn=e=>e.hasPendingAssistant?e.messages.some(e=>e.role===`assistant`&&typeof e.time?.completed==`number`):!1;function nn(e,t){let n=(0,Z.c)(6),r=Oe(e??``,t),i=Se(e??``,t),a=De(e??``,t),o=be(e??``,t),s=Me(e??``,t),c=xe(t),l;bb0:{if(!e){l=en;break bb0}if(o.length>0||s.length>0){l=en;break bb0}let t=r?.type??`idle`,u=a[a.length-1],d=!!(u&&u.role===`assistant`&&typeof u.time?.completed!=`number`),f=a,p;n[0]!==d||n[1]!==f?(p=tn({messages:f,hasPendingAssistant:d}),n[0]=d,n[1]=f,n[2]=p):p=n[2];let m=p,h=u?.time?.created,g=!!(m&&typeof c==`number`&&typeof h==`number`&&h<=c),_=r!==void 0,v=_&&t!==`idle`,y=v||m&&!g;if(_&&!v&&(!m||_&&!v&&typeof i==`number`&&typeof h==`number`&&h<=i)){l=en;break bb0}if(!y){l=en;break bb0}let b=v?t:`busy`,x=t===`busy`||!v&&m,S;n[3]!==b||n[4]!==x?(S={phase:b,isWorking:!0,isBusy:x,isCooldown:!1},n[3]=b,n[4]=x,n[5]=S):S=n[5],l=S}return l}var rn=`data-mobile-overlay-active`,an=e=>Array.from(e).some(e=>e.getAttribute(rn)!==`false`),on=`artful.bionic.cosmic.disco.focal.groovy.jammy.kinetic.lunar.noble.bold.brave.calm.eager.gentle.happy.keen.lively.merry.swift.warm.wise.bright.clever.daring.agile.crisp.fresh.lucid.quick.sharp.vivid.zealous`.split(`.`),sn=`aardvark.beaver.chipmunk.dolphin.falcon.gopher.hedgehog.jackal.koala.lemur.mongoose.narwhal.otter.pangolin.quokka.raccoon.salamander.toucan.walrus.yak.zebra.badger.condor.dingo.egret.ferret.gecko.heron.iguana`.split(`.`);function cn(){return`${on[Math.floor(Math.random()*on.length)]}-${sn[Math.floor(Math.random()*sn.length)]}`}function ln(e){let t=cn();return e&&e.trim()?`${e.trim().replace(/\/+$/,``)}/${t}`:t}async function un(e,t,n){if(!e.hostId||!e.hubId)throw Error(`Remote Project Host scope is unavailable`);let i=V.getState().remoteSession,a=O(),o=await Re();if(a.assertCurrent(),!o.supported||o.hubId!==e.hubId||!o.projects.some(t=>t.id===e.id&&t.hostId===e.hostId&&t.path===e.path))throw Error(`Remote Project is not referenced by the current Hub`);let s=Ie(o);await s.connectHost(e.hostId);let c=s.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),l=O(c),u=he(c);if(!await u.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let d=await H(e,c),p=d.commands,m=Array.isArray(p)?p.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>ue(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,g=await u.getGitStatus(e.path),_=await u.getGitBranches(e.path),v=await u.listGitWorktrees(e.path),b=r(e.path),x=v.map(e=>r(e.path)).filter(e=>b===e||b.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=x?b.slice(x.length):``,C=(_.branches?.[g.current]?.tracking||g.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...m?{startCommand:m}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},E=await u.previewGitWorktree(e.path,T);if(!E.path)throw Error(`Remote worktree preview missing path`);let D=K();J(D).catch(()=>void 0);let k=S?`${E.path.replace(/[\\/]+$/,``)}${S}`:E.path,A={...c.location,directory:k},ee={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:d.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:D,bootstrapPendingDirectory:k,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(A,n.initialPrompt),l.assertCurrent()}catch(e){throw ve(D,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&V.getState().remoteSession===i&&V.getState().openRemoteSession(e,A,null,ee);let M=V.getState().remoteSession,N=M?.draft?.pendingWorktreeRequestId===D,P=()=>{if(!n.isSelected()||!N)return!1;let t=V.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===D?(M=t,!0):t===M};try{let r=await u.createGitWorktree(e.path,T);if(!r.path||!r.name)throw Error(`Remote worktree create missing name/path`);let i=r.bootstrapStatus,a=Date.now()+12e4;for(;i?.status===`pending`&&d.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),l.assertCurrent(),i=await u.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);l.assertCurrent();let o=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...c.location,directory:o},m={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:o,worktreeRoot:r.path,projectDirectory:e.path,relativePath:S.replace(/^\//,``)||void 0,branch:r.branch,label:r.branch||r.name,source:`sdk`,worktreeSource:`created-for-session`,headState:r.branch?`branch`:`unborn`,worktreeStatus:i?.status===`pending`?`pending`:`ready`,createdFromBranch:n.createdFromBranch||g.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:d.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(o!==k){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await j(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-C6UIEZxp.js`).then(e=>e.a);return{getRemoteInputStore:e,remoteSessionDraftKey:t}},__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])),n=e(p),r=t(A,null),i=n.getState().getDraft(r),a=await n.getState().moveDraftWithAttachments(r,t(p,null),i?.revision);if(i&&!a)throw Error(`Remote draft changed while the worktree target was being finalized; the original draft was retained`);l.assertCurrent()}!n.createSession&&P()&&M&&(V.getState().updateRemoteDraft(M,m,p),M=V.getState().remoteSession),n.createSession||Te(D,o);let _;if(n.createSession)try{let t=s.resolve(p).service(),r=P()?M?.draft?.title??n.title:n.title,i=await t.createSession({title:r},o);_=i.id,l.assertCurrent();let a=await t.getConfig(o).catch(()=>void 0);l.assertCurrent();let c=e.defaultModel||a?.model,u=typeof c==`string`?c:void 0,d=u?.indexOf(`/`)??-1,m=d>0?u.slice(0,d):h(i),g=d>0?u.slice(d+1):y(i),v=a?.default_agent||i.agent,b=typeof v==`string`?v:void 0,x=Ne.getState();m&&g&&x.saveSessionModelSelection(i.id,m,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&m&&g&&(x.saveAgentModelForSession(i.id,b,m,g,p),x.saveAgentModelVariantForSession(i.id,b,m,g,f(i),p))}catch(t){throw await u.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return l.assertCurrent(),n.createSession&&P()&&V.getState().openRemoteSession(e,p,_??null,{...M?.draft,...m}),n.createSession&&Te(D,o),{path:o,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw P()&&M&&V.getState().updateRemoteDraft(M,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),ve(D,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=se.getState().getActiveProject();return t?.id===e.id&&t?.hostId===e.hostId&&t?.hubId===e.hubId&&t?.path===e.path},pn=e=>({agentName:e.currentAgentName,providerId:e.currentProviderId,modelId:e.currentModelId,variant:e.currentVariant}),mn=(e,t,n)=>{let r=t.agentName?.trim()||void 0,i=t.providerId?.trim()||void 0,a=t.modelId?.trim()||void 0;!r||!i||!a||(n.saveSessionAgentSelection(e,r),n.saveSessionModelSelection(e,i,a),n.saveAgentModelForSession(e,r,i,a),n.saveAgentModelVariantForSession(e,r,i,a,t.variant))},hn=async(e,t)=>{await ge(e)&&await Ae(t)},gn=e=>{let t=dn(e),n=se.getState().projects;if(n.length===0)return null;let r=n.filter(e=>{if(e.hostId)return!1;let n=dn(e.path);return t===n||t.startsWith(`${n}/`)}).sort((e,t)=>dn(t.path).length-dn(e.path).length)[0];return r?{id:r.id,path:r.path}:null},_n=!1,vn=async(e,t)=>{try{let n=se.getState().projects.find(e=>e.id===t.id)??se.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=z(t.path);await me.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=me.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(me.getState()),Ne.getState())}catch{}},yn=async(e,t,n)=>{let r=G.getState(),i=me.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),s.getState().setDirectory(t.path,{showOverlay:!1})},bn=e=>e.trim().replace(/^remotes\//,``).replace(/[^A-Za-z0-9._/-]+/g,`-`).replace(/\/+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`worktree`,xn=async e=>{if(_n)return null;let t=se.getState().getActiveProject();if(t?.hostId){_n=!0;let n=fn(t);try{let r=e?.existingBranch?.trim().replace(/^remotes\//,``),i=r?bn(r):ln();return(await un(t,{mode:r?`existing`:`new`,worktreeName:i,...r?{existingBranch:r}:{branchName:i}},{...e,isSelected:n})).path}catch(e){return q.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}finally{_n=!1}}let n=e?.projectDirectory?.trim()||t?.path;if(!n)return q.error(`No active project`,{description:`Please select a project first.`}),null;let r=gn(n)??(t?.path?{id:t.id,path:t.path}:null);if(!r)return q.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return q.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;_n=!0;try{let t=K(),n=e?.existingBranch?.trim().replace(/^remotes\//,``)||``,i=n?bn(n):ln(),a=n?`existing`:`new`,o=G.getState();o.newSessionDraft?.open?o.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:o.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):o.openNewSessionDraft({selectedProjectId:r.id,directoryOverride:r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt});let c=await nt(r.path,{mode:a,...a===`new`?{branchName:i,worktreeName:i}:{existingBranch:n,worktreeName:i}}).catch(()=>null);c?.path&&(G.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(c.path,{showOverlay:!1}));let l=await Pe(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return Te(t,u.path),G.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=G.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(ve(n,e instanceof Error?e:Error(t)),G.getState().resolvePendingDraftWorktreeTarget(n,null)),G.getState().setDraftBootstrapPendingDirectory(null),q.error(`Failed to create worktree`,{description:t}),null}finally{_n=!1}};async function Sn(){return xn()}async function Cn(e){let t=e.branch?.trim();return t?xn({existingBranch:t,projectDirectory:e.projectDirectory,initialPrompt:e.initialPrompt,title:e.title}):null}async function wn(e,t,n,r){if(_n)return null;_n=!0;try{let i=se.getState().getActiveProject();if(i?.hostId){let e=fn(i);try{if(!t.trim())throw Error(`Branch name is required`);let a=await un(i,{mode:`new`,branchName:t.trim(),worktreeName:r?.worktreeName||t.trim(),startRef:n?.trim()||`HEAD`,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl},{createSession:!0,isSelected:e,kind:r?.kind,createdFromBranch:r?.createdFromBranch});if(!a.id)throw Error(`Could not create a remote session for the worktree`);return{id:a.id,branch:a.branch,path:a.path}}catch(e){return q.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}}let a=n?.trim()||`HEAD`,o=t?.trim();if(!o)throw Error(`Branch name is required`);let s=r?.kind??`standard`,c=gn(e);if(!c)throw Error(`Project is not registered in Yuri`);let l=!1;try{l=await rt(c.path)}catch{}if(!l)return q.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await Pe(c),d=await mt(c.path);try{let e=await _t(c,{preferredName:o,mode:`new`,branchName:o,worktreeName:r?.worktreeName||o,startRef:a,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl,setupCommands:u,returnAfterDirectoryCreated:r?.returnAfterDirectoryCreated}),t={...e,createdFromBranch:r?.createdFromBranch||d||a,kind:s};await hn(c,e.worktreeRoot??e.path);let n=await G.getState().createSession(void 0,e.path);if(!n)throw await pt(c,e,{deleteLocalBranch:!0}).catch(()=>void 0),Error(`Could not create a session for the worktree.`);return await yn(n.id,t,c),{id:n.id,branch:e.branch||o,path:e.path}}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree session`;return q.error(`Failed to create worktree`,{description:t}),null}}finally{_n=!1}}function Tn(e){let t=(0,Z.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,style:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a={color:`var(--surface-elevated-foreground)`,...i},t[4]=i,t[5]=a);let o;t[6]===n?o=t[7]:(o=F(`flex h-full w-full flex-col overflow-hidden rounded-xl`,n),t[6]=n,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Q.jsx)(Ct,{"data-slot":`command`,style:a,className:o,...r}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var En=X.forwardRef((e,t)=>{let n=(0,Z.c)(16),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=(a===void 0?`default`:a)===`mobileGlass`?`yuri-mobile-glass-control rounded-full`:`bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,s;n[4]===o?s=n[5]:(s=F(`flex h-8 items-center gap-2 rounded-lg px-3`,o),n[4]=o,n[5]=s);let c;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(L,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=F(`placeholder:text-muted-foreground flex h-8 w-full bg-transparent typography-meta outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,r),n[7]=r,n[8]=l);let u;n[9]!==i||n[10]!==t||n[11]!==l?(u=(0,Q.jsx)(Ct.Input,{ref:t,"data-slot":`command-input`,className:l,...i}),n[9]=i,n[10]=t,n[11]=l,n[12]=u):u=n[12];let d;return n[13]!==s||n[14]!==u?(d=(0,Q.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{"data-slot":`command-input-field`,className:s,children:[c,u]})}),n[13]=s,n[14]=u,n[15]=d):d=n[15],d});En.displayName=`CommandInput`;function Dn(e){let t=(0,Z.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,scrollbarClassName:o,disableHorizontal:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=F(`scroll-py-1 overflow-x-hidden h-full min-h-0`,r),t[6]=r,t[7]=s);let c=o??`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,l=i??!0,u;return t[8]!==n||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(Ve,{as:Ct.List,"data-slot":`command-list`,outerClassName:`max-h-[min(600px,calc(100vh-10rem))] overflow-x-hidden p-0 w-full h-full min-h-0`,className:s,scrollbarClassName:c,disableHorizontal:l,...a,children:n}),t[8]=n,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function On(e){let t=(0,Z.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Ct.Empty,{"data-slot":`command-empty`,className:`py-6 text-center typography-ui-label`,...n}),t[2]=n,t[3]=r),r}function kn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typography-meta [&_[cmdk-group-heading]]:font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`bg-border -mx-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Separator,{"data-slot":`command-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`data-[selected=true]:bg-interactive-selection data-[selected=true]:text-interactive-selection-foreground data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 typography-meta outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,Z.c)(27),{branches:n,search:r,local:i,currentBranch:a,branchInfo:o,onCheckout:s}=e,{t:c}=ze(),l;if(t[0]!==n||t[1]!==r){let e=r.trim();l=e?N(n,e,Pn).map(Nn):n,t[0]=n,t[1]=r,t[2]=l}else l=t[2];let u=l,d=i?`gitView.branch.localBranches`:`gitView.branch.remoteBranches`,f;t[3]!==c||t[4]!==d?(f=c(d),t[3]=c,t[4]=d,t[5]=f):f=t[5];let p;if(t[6]!==o||t[7]!==a||t[8]!==u||t[9]!==i||t[10]!==s||t[11]!==c){let e;t[13]!==o||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==c?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>s(e),children:[i?(0,Q.jsxs)(`span`,{className:`flex flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),(o?.[e]?.ahead||o?.[e]?.behind)&&(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[o[e].ahead||0,` ahead ·`,` `,o[e].behind||0,` behind`]})]}):(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),i&&a===e&&(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:c(`gitView.branch.currentBadge`)})]},`${i?`local`:`remote`}-${e}`),t[13]=o,t[14]=a,t[15]=i,t[16]=s,t[17]=c,t[18]=e):e=t[18],p=u.map(e),t[6]=o,t[7]=a,t[8]=u,t[9]=i,t[10]=s,t[11]=c,t[12]=p}else p=t[12];let m;t[19]!==u.length||t[20]!==i||t[21]!==c?(m=u.length===0&&(0,Q.jsx)(jn,{disabled:!0,className:`justify-center`,children:(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(i?`gitView.branch.noLocalBranches`:`gitView.branch.noRemoteBranches`)})}),t[19]=u.length,t[20]=i,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Q.jsxs)(kn,{heading:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Nn(e){return e.item}function Pn(e){return e}function Fn(e){let t=(0,Z.c)(9),{options:n,selectedDirectory:r,onSelect:i}=e,{t:a}=ze(),o;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>i(e.value),children:[(0,Q.jsxs)(`span`,{className:`truncate typography-ui-label text-foreground`,children:[e.pending?`⏳ `:``,e.label]}),r===e.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:a(`gitView.branch.currentBadge`)}):null]},`worktree-${e.value}`),t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else o=t[4];return o}var In=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ln=({currentBranch:e,localBranches:t,remoteBranches:n,branchInfo:r,onCheckout:i,onCreate:a,remotes:o=[],disabled:s=!1,iconOnly:c=!1,trigger:l,triggerLabel:u,contentAlign:d,hideTooltip:f=!1,projectRootOption:p=null,worktreeOptions:m=[],selectedDirectory:h=null,onSelectDirectory:g,onCreateWorktree:_,worktreesLabel:v,worktreeNewLabel:y,projectRootLabel:b,onOpenChange:x,open:S,presentation:C=`dropdown`})=>{let{t:w}=ze(),[T,E]=X.useState(!1),[D,O]=X.useState(``),[k,A]=X.useState(!1),[ee,j]=X.useState(!1),[M,F]=X.useState(``),[I,R]=X.useState(!1),te=X.useRef(null),z=X.useId(),ne=S??T,B=e=>{S===void 0&&E(e),x?.(e)},V=X.useCallback(e=>{e.stopPropagation()},[]),re=o.length>1,ie=!!(g||_),ae=X.useMemo(()=>In(M),[M]),H=X.useMemo(()=>{let e=D.trim();return e?N(m,e,e=>e.label).map(e=>e.item):m},[D,m]),oe=X.useMemo(()=>{if(!p)return!1;let e=D.trim();return!e||N([p],e,e=>[e.label,b??``]).length>0},[b,p,D]),se=t=>{if(t===e){B(!1);return}i(t),B(!1),O(``)},U=e=>{g?.(e),B(!1),O(``)},ce=()=>{A(!0),setTimeout(()=>te.current?.focus(),50)},W=async()=>{if(!(!ae||I)){if(re){j(!0);return}R(!0);try{await a(ae,o[0]),F(``),A(!1),B(!1)}finally{R(!1)}}},le=async e=>{if(!(!ae||I)){R(!0);try{await a(ae,e),F(``),A(!1),j(!1),B(!1)}finally{R(!1)}}},ue=()=>{j(!1)},de=()=>{F(``),A(!1),j(!1)};X.useEffect(()=>{ne||(O(``),A(!1),j(!1),F(``))},[ne]);let fe=u||e||w(`gitView.branch.detachedHead`),pe=d??(c?`end`:`start`),me=v??w(`chat.chatInput.worktrees`),he=y??w(`chat.chatInput.worktreeNew`),ge=b??w(`chat.chatInput.projectRoot`),_e=c?(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,disabled:s,"aria-label":fe,children:(0,Q.jsx)(L,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(P,{variant:`ghost`,size:`xs`,className:`h-6 min-w-0 max-w-full justify-start gap-1 px-0 hover:bg-transparent`,disabled:s,"aria-label":fe,children:[(0,Q.jsx)(L,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate typography-ui-label font-semibold text-left text-foreground`,children:fe}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),ve=(0,Q.jsx)(Ze,{asChild:!0,disabled:s,children:l??_e}),ye=(0,Q.jsxs)(Tn,{className:`h-full min-h-0`,children:[(0,Q.jsx)(`div`,{"data-mobile-sheet-no-dismiss":C===`mobile-sheet`?``:void 0,children:(0,Q.jsx)(En,{placeholder:w(`gitView.branch.searchPlaceholder`),value:D,onValueChange:O,onKeyDown:V})}),(0,Q.jsxs)(Dn,{scrollbarClassName:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,disableHorizontal:!0,children:[(0,Q.jsx)(On,{children:w(`gitView.branch.empty`)}),(0,Q.jsx)(kn,{children:ee?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:ue,disabled:I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(L,{name:`arrow-left`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[w(`gitView.branch.pushToPrefix`),` `,(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:ae}),` `,w(`gitView.branch.pushToSuffix`)]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>le(e),disabled:I,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:[(0,Q.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[I?(0,Q.jsx)(L,{name:`loader-4`,className:`inline size-3 mr-1.5 animate-spin`}):null,e.name]}),(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground truncate max-w-full`,children:e.pushUrl})]},e.name))})]}):k?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:te,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:M,onChange:e=>F(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{V(e),e.key===`Enter`?(e.preventDefault(),W()):e.key===`Escape`&&(e.preventDefault(),de())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:W,disabled:!ae||I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:I?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(L,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(L,{name:`add`,className:`size-4`}),(0,Q.jsx)(`span`,{children:w(`gitView.branch.create`)})]})}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:t,search:D,local:!0,currentBranch:e,branchInfo:r,onCheckout:se}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:D,onCheckout:se}),ie?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{}),(0,Q.jsxs)(kn,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground typography-meta`,children:me}),_?(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer text-muted-foreground typography-meta hover:text-foreground`,onPointerDown:e=>{e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),B(!1),_()},children:he}):null]}),p&&oe?(0,Q.jsxs)(jn,{onSelect:()=>U(p.value),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ge}),(0,Q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:p.label})]}),h===p.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:w(`gitView.branch.currentBadge`)}):null]}):null,(0,Q.jsx)(Fn,{options:H,selectedDirectory:h,onSelect:U})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>B(!0),"data-popup-open":ne?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${z}`,open:ne,onOpenChange:B,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:ne,onOpenChange:B,children:[f||l?ve:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:ve}),(0,Q.jsx)(Ye,{sideOffset:8,children:c?fe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:pe,className:`w-72 p-0 max-h-[60vh] flex flex-col`,children:ye})]})};function Rn(e){let{localBranches:t,remoteBranches:n,query:r}=e,i=r.trim();if(!i)return{matching:[],otherLocal:t,otherRemote:n};let a=N(t,i,e=>e),o=N(n,i,e=>e),s=new Set(a.map(e=>e.item)),c=new Set(o.map(e=>e.item));return{matching:[...a.map(e=>({label:e.item,value:e.item,source:`local`,score:e.score})),...o.map(e=>({label:e.item,value:`remotes/${e.item}`,source:`remote`,score:e.score}))].sort((e,t)=>e.score===t.score?e.source===t.source?e.label.length===t.label.length?e.label.localeCompare(t.label,void 0,{sensitivity:`accent`}):e.label.length-t.label.length:e.source===`local`?-1:1:e.score-t.score).map(({label:e,value:t,source:n})=>({label:e,value:t,source:n})),otherLocal:t.filter(e=>!s.has(e)),otherRemote:n.filter(e=>!c.has(e))}}function zn(e){let t=O(e),n=(e,n={})=>t.json(`/api/github/${e}`,{query:n}),r=e=>e?{owner:e.owner,repo:e.repo}:{};return{authStatus:()=>n(`auth/status`),issuesList:(e,t)=>n(`issues/list`,{directory:e,page:t?.page,query:t?.query}),prsList:(e,t)=>n(`pulls/list`,{directory:e,page:t?.page,query:t?.query}),issueGet:(e,t,i)=>n(`issues/get`,{directory:e,number:t,...r(i?.sourceRepo)}),issueComments:(e,t,i)=>n(`issues/comments`,{directory:e,number:t,...r(i?.sourceRepo)}),prContext:(e,t,i)=>n(`pulls/context`,{directory:e,number:t,...r(i?.sourceRepo),diff:i?.includeDiff?`1`:void 0,checkDetails:i?.includeCheckDetails?`1`:void 0})}}var Bn=e=>({queryKey:[...e.queryScope,`worktree-dialog`,`github-auth`],queryFn:({signal:t})=>O(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=k(),i=e?void 0:r.github,a;n[0]!==e||n[1]!==i?(a=e?zn(e):i,n[0]=e,n[1]=i,n[2]=a):a=n[2];let o=a,s;n[3]!==e||n[4]!==r?(s=e?Bn(e):dt(r.github),n[3]=e,n[4]=r,n[5]=s):s=n[5];let c;n[6]!==t||n[7]!==s?(c={...s,enabled:t},n[6]=t,n[7]=s,n[8]=c):c=n[8];let l=w(c,T),u;return n[9]!==l||n[10]!==o?(u={github:o,auth:l},n[9]=l,n[10]=o,n[11]=u):u=n[11],u}async function Hn(e,t,n={}){let r=await O(e).json(`/api/magic-prompts`);return(typeof r.overrides?.[t]==`string`?r.overrides[t]:it(t)).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]??``:``)}async function Un(e,t,n,r,i,a){let o=zn(t),s=i.issue,c=i.pr;if(!s&&!c)return;let u=s?`issue`:`pr`,d=s?.number??c.number,f=await Hn(t,`github.${u}.review.visible`,{[`${u}_number`]:String(d)}),p=await Hn(t,`github.${u}.review.instructions`),m;if(s){let e=await o.issueGet(t.location.directory,d,{sourceRepo:s.sourceRepo}),n=await o.issueComments(t.location.directory,d,{sourceRepo:s.sourceRepo});if(e.connected===!1||!e.issue||n.connected===!1)throw Error(a);m=`GitHub issue context (JSON)\n${JSON.stringify({repo:e.repo??null,issue:e.issue,comments:n.comments??[]},null,2)}`}else{let e=await o.prContext(t.location.directory,d,{sourceRepo:c.sourceRepo,includeDiff:i.includeDiff,includeCheckDetails:!1});if(e.connected===!1||!e.pr)throw Error(a);m=`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`}t.sdk();let h=e.resolve({...t.location,directory:n});await ke(e,h).state.send({sessionID:r,messageID:l(`msg`),text:[f,p,m].join(`
3
-
4
- `)})}function Wn(e){let t=(0,Z.c)(41),{project:n,open:r,onClose:i,children:a}=e,o=D(),s=n?.hostId&&o&&o.entry.location.hubId===n.hubId&&o.entry.location.hostId===n.hostId&&o.entry.location.directory===n.path,c=Le(!!(r&&n?.hostId&&!s)),{t:l}=ze();if(!n?.hostId){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(E.Provider,{value:null,children:a}),t[0]=a,t[1]=e),e}if(s)return a;if(!r)return null;if(!c.registry||c.registry.hubId!==n.hubId){let e;t[2]===i?e=t[3]:(e=e=>{e||i()},t[2]=i,t[3]=e);let n;t[4]===l?n=t[5]:(n=l(`session.newWorktree.title`),t[4]=l,t[5]=n);let r;t[6]===n?r=t[7]:(r=(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:n})}),t[6]=n,t[7]=r);let a=c.isPending?`status`:`alert`,o;t[8]!==c.error?.message||t[9]!==c.isPending||t[10]!==l?(o=c.isPending?l(`remoteProjects.running`):c.error?.message||l(`remoteProjects.host-unavailable`),t[8]=c.error?.message,t[9]=c.isPending,t[10]=l,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,Q.jsx)(`p`,{role:a,children:o}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let u;t[15]===l?u=t[16]:(u=l(`session.newWorktree.actions.cancel`),t[15]=l,t[16]=u);let d;t[17]!==i||t[18]!==u?(d=(0,Q.jsx)(P,{onClick:i,children:u}),t[17]=i,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==c.isPending||t[21]!==l?(f=c.isPending?null:(0,Q.jsx)(P,{onClick:Gn,children:l(`remoteProjects.retry`)}),t[20]=c.isPending,t[21]=l,t[22]=f):f=t[22];let p;t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(We,{children:[d,f]}),t[23]=d,t[24]=f,t[25]=p):p=t[25];let m;t[26]!==p||t[27]!==r||t[28]!==s?(m=(0,Q.jsxs)(Ge,{children:[r,s,p]}),t[26]=p,t[27]=r,t[28]=s,t[29]=m):m=t[29];let h;return t[30]!==e||t[31]!==m?(h=(0,Q.jsx)(qe,{open:!0,onOpenChange:e,children:m}),t[30]=e,t[31]=m,t[32]=h):h=t[32],h}let u;t[33]!==n.hostId||t[34]!==n.hubId||t[35]!==n.path?(u={hubId:n.hubId,hostId:n.hostId,directory:n.path},t[33]=n.hostId,t[34]=n.hubId,t[35]=n.path,t[36]=u):u=t[36];let d;return t[37]!==a||t[38]!==c.registry||t[39]!==u?(d=(0,Q.jsx)(A,{registry:c.registry,location:u,children:a}),t[37]=a,t[38]=c.registry,t[39]=u,t[40]=d):d=t[40],d}function Gn(){Re().catch(Kn)}function Kn(){}var qn=(e,t,n)=>{let r=n??t;return r?e.find(e=>e.id===r)??null:null};function Jn(e,t){return`${e}\0${t}`}function Yn(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=se(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(Xn,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Xn({open:e,onOpenChange:t,onSelect:n,projectId:r}){let{t:i}=ze(),a=M(e=>e.isMobile),o=D(),s=o?.entry.location.hostId?o.entry:void 0,{git:c}=et(),{github:l,auth:u}=Vn(s,e),d=u.data??null,f=u.isFetched,p=M(e=>e.setSettingsDialogOpen),m=M(e=>e.setSettingsPage),h=se(e=>qn(e.projects,e.activeProjectId,r)),g=h?.id??null,_=h?.path??null,v=X.useMemo(()=>_&&g?{id:g,path:_,hostId:h?.hostId,hubId:h?.hubId}:null,[g,_,h?.hostId,h?.hubId]),[y,b]=X.useState(`issues`),[x,S]=X.useState(``),[C,w]=X.useState([]),[T,E]=X.useState([]),[O,k]=X.useState(!1),[A,j]=X.useState(!1),[N,I]=X.useState(null),[R,te]=X.useState(null),[z,ne]=X.useState(null),[B,V]=X.useState(!1),[re,ie]=X.useState(new Map),[ae,H]=X.useState(1),[oe,U]=X.useState(!1),ce=X.useRef(0),W=ct(x,350),le=ee(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){k(!0),I(null),H(1),U(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),H(t.page??1),U(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),H(t.page??1),U(!!t.hasMore))}}catch(e){I(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{k(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!W.trim()){le();return}let t=new AbortController;k(!0),I(null),H(1),U(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:W.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:W.trim()}):null;if(!n){k(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),H(e.page??1),U(!!e.hasMore)):`prs`in e&&(e.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),H(e.page??1),U(!!e.hasMore))))}).catch(e=>{t.signal.aborted||I(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||k(!1)}),()=>t.abort()},[e,_,l,f,d,y,W,le,i]);let ue=ee(async()=>{if(!(!_||!l)&&!(O||A)&&oe){j(!0);try{let e=ae+1;if(y===`issues`&&l.issuesList){let t=W.trim()?await l.issuesList(_,{page:e,query:W.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),H(t.page??e),U(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=W.trim()?await l.prsList(_,{page:e,query:W.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),H(t.page??e),U(!!t.hasMore))}}catch{}finally{j(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),te(null),ne(null),V(!1),I(null),ie(new Map),H(1),U(!1);return}le()},[e,le]),X.useEffect(()=>{ce.current+=1,ie(new Map)},[_,v]);let de=ee(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(re.has(t))return;let n=ce.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==ce.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ie(e=>new Map(e).set(t,{isValid:!o,error:o?i(o.code===`branch_exists`?`session.githubIntegration.validation.branchAlreadyExists`:`session.githubIntegration.validation.branchAlreadyCheckedOut`):null}))}catch{if(n!==ce.current)return;ie(e=>new Map(e).set(t,{isValid:!1,error:i(`session.githubIntegration.validation.failed`)}))}});X.useEffect(()=>{!e||y!==`prs`||T.forEach(e=>{e.head&&de(e.head)})},[e,y,T,_,v,de]);let fe=f&&d?.connected===!0,pe=()=>{if(s){q.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{te(e),ne(null)},he=e=>{ne(e),te(null)},ge=()=>{R?n({type:`issue`,item:R}):z&&n({type:`pr`,item:z,includeDiff:B}),t(!1)},_e=()=>{te(null),ne(null),V(!1)},ve=R||(z?.head&&_?re.get(Jn(_,z.head))?.isValid!==!1:!1),ye=e=>!e.head||(_?re.get(Jn(_,e.head)):void 0)?.isValid===!1,G=(0,Q.jsxs)(Q.Fragment,{children:[s&&u.error?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-small text-destructive`,children:[u.error.message,(0,Q.jsx)(P,{variant:`ghost`,size:`xs`,onClick:()=>{u.refetch()},children:i(`remoteProjects.retry`)})]}):null,fe?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,Q.jsx)(L,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(st,{value:x,onChange:e=>S(e.target.value),placeholder:i(y===`issues`?`session.githubIntegration.search.issuesPlaceholder`:`session.githubIntegration.search.prsPlaceholder`),className:`h-8 pl-9`})]}),(0,Q.jsx)(`div`,{className:`yuri-picker-list mt-2 h-[300px] overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[O&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),N&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive`,children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:N})]})}),!O&&!N&&y===`issues`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[C.length>0?C.map(e=>(0,Q.jsx)(`button`,{onClick:()=>me(e),className:F(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,R?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-2`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noIssuesFound`)}),oe&&!A&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),A&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!O&&!N&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ye(e),n=e.head&&_?re.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:F(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,z?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:t?`opacity-50 cursor-not-allowed`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-1`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[e.head,` → `,e.base]}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null,t&&n?.error&&(0,Q.jsx)(`span`,{className:`typography-micro text-destructive`,children:n.error})]})]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noPullRequestsFound`)}),oe&&!A&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),A&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 gap-4`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-12 w-12 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:i(`session.githubIntegration.connect.title`)}),(0,Q.jsx)(`p`,{className:`typography-small text-muted-foreground mt-1`,children:i(`session.githubIntegration.connect.description`)})]}),(0,Q.jsx)(P,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),be=(0,Q.jsxs)(`div`,{className:F(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:F(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(R||z)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate max-w-[150px]`,children:R?i(`session.githubIntegration.selected.issueNumber`,{number:R.number}):i(`session.githubIntegration.selected.prNumber`,{number:z?.number??``})}),(0,Q.jsx)(`button`,{onClick:_e,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&z&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:B,onChange:e=>V(e),ariaLabel:i(`session.githubIntegration.includeDiffAria`)}),(0,Q.jsx)(`span`,{className:`typography-small text-foreground`,children:i(`session.githubIntegration.includeDiff`)})]})]}),(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:F(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(P,{size:`sm`,onClick:ge,disabled:!ve,className:F(a&&`flex-1`),children:i(`session.githubIntegration.actions.select`)})]})]});return(0,Q.jsx)(Q.Fragment,{children:a?(0,Q.jsx)(ut,{open:e,title:i(`session.githubIntegration.title`),onClose:()=>t(!1),footer:fe?be:void 0,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 border-b border-border/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:i(`session.githubIntegration.title`)}),e]}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(L,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(R||z)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate flex-1`,children:R?i(`session.githubIntegration.selected.issueNumber`,{number:R.number}):i(`session.githubIntegration.selected.prNumber`,{number:z?.number??``})}),(0,Q.jsx)(`button`,{onClick:_e,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:G}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{presentation:`picker`,children:[(0,Q.jsx)(Ue,{className:`yuri-picker-header`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Q.jsx)(Ke,{className:`yuri-picker-title`,children:i(`session.githubIntegration.title`)}),(0,Q.jsx)(`div`,{className:`w-[220px]`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(L,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),G,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:be})]})})})}var Zn=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),$=e=>e.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),Qn=e=>String(e||``).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`pr-head`,$n=(e,t,n)=>{let r=Zn(e.head||``);if(!r)throw Error(`PR head branch is missing`);if(t.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};let i=n.find(e=>{let t=e.indexOf(`/`);return t<=0||t>=e.length-1?!1:e.slice(t+1)===r});if(i){let e=i.indexOf(`/`),t=i.slice(0,e);return{existingBranch:`remotes/${i}`,setUpstream:!0,upstreamRemote:t,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${t}/${r}`}}let a=String(e.headLabel||``).split(`:`)[0]?.trim(),o=`pr-${Qn(e.headRepo?.owner||a||`pr-head`)}`,s=e.headRepo?.sshUrl||e.headRepo?.cloneUrl||``;if(!s)throw Error(`PR head repository URL is unavailable`);return{existingBranch:`remotes/${o}/${r}`,setUpstream:!0,upstreamRemote:o,upstreamBranch:r,ensureRemoteName:o,ensureRemoteUrl:s,sourceLabel:`${o}/${r}`}},er=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`},tr=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function nr(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=se(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(rr,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function rr({open:e,onOpenChange:t,onWorktreeCreated:n,projectId:r}){let{t:i}=ze(),{git:a}=et(),o=D(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=M(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=se(e=>qn(e.projects,e.activeProjectId,r)),h=m?.path??null,g=X.useMemo(()=>h&&m?{id:m.id,path:h,hostId:m.hostId,hubId:m.hubId}:null,[m,h]),[_,v]=X.useState(`new-branch`),[y,b]=X.useState({branchName:``,worktreeName:``,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,S]=X.useState({selectedBranch:``,worktreeName:``}),C=ot(h),E=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),O=at(e=>e.fetchBranches),k=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),A=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),ee=G(e=>e.availableWorktreesByProject),j=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},T),N=X.useMemo(()=>{if(!h)return new Set;let e=s?j.data??[]:ee.get(h)??[];return new Set(e.map(e=>e.name))},[ee,h,s,j.data]),I=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!N.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[N]),[R,te]=X.useState(!1),[z,B]=X.useState(!1),[re,ae]=X.useState(!1),[H,oe]=X.useState(!1),[U,ce]=X.useState(!1),[W,le]=X.useState(``),[ue,de]=X.useState(``),fe=X.useRef(null),pe=X.useRef(null),he=X.useRef(null),_e=X.useRef(null),ve=X.useCallback(e=>{e.stopPropagation()},[]),ye=X.useCallback(e=>{let t=e;for(;t&&t!==document.body;){let{overflowY:e}=window.getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null},[]),be=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),xe=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;be(t)},[be]),Se=X.useCallback(e=>{let t=ye(e.current);be(t)},[ye,be]),Ce=X.useMemo(()=>Rn({localBranches:k,remoteBranches:A,query:W}),[k,A,W]),we=X.useMemo(()=>Rn({localBranches:k,remoteBranches:A,query:ue}),[k,A,ue]),Te=W.trim().length>0,Ee=ue.trim().length>0,De=Ce.matching.length>0,Oe=we.matching.length>0,ke=!!(h&&a),Me=X.useCallback(()=>{!h||!a||O(h,a)},[h,a,O]);X.useEffect(()=>{!e||!h||!a||C?.all||O(h,a)},[e,h,a,C?.all,O]),X.useEffect(()=>{!z&&!H&&le(``)},[z,H]),X.useEffect(()=>{!re&&!U&&de(``)},[re,U]),X.useEffect(()=>{z&&xe(fe),H&&Se(he)},[z,H,W,xe,Se]),X.useEffect(()=>{re&&xe(pe),U&&Se(_e)},[re,U,ue,xe,Se]);let[K,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Y,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=me.getState(),t=e.getVisibleAgents();if(e.settingsDefaultAgent){let n=t.find(t=>t.name===e.settingsDefaultAgent);if(n)return n.name}return t.find(e=>e.name===`build`)?.name||t[0]?.name},[]),Be=X.useCallback(()=>{let e=me.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=ne(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=me.getState(),r=ne(n.settingsDefaultModel??n.opencodeDefaultModel),i=r?.providerId===e&&r.modelId===t?r.variant??n.settingsDefaultVariant:void 0,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0;return i??a},[]),Ye=X.useCallback(async e=>{if(!h||!c)return;let t=me.getState(),n=Ne.getState().lastUsedProvider,r=Be(),a=r?.providerID||t.currentProviderId||n?.providerID,o=r?.modelID||t.currentModelId||n?.modelID,s=Re()||t.currentAgentName||void 0;if(!a||!o){q.error(i(`session.newWorktree.error.noModelSelected`));return}let l=Je(a,o);if(e.issue){if(!c.issueGet||!c.issueComments)return;let t=await c.issueGet(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(t.connected===!1||!t.repo||!t.issue)throw Error(`Failed to load issue context`);let n=await c.issueComments(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(n.connected===!1)throw Error(`Failed to load issue comments`);let r=await tt(`github.issue.review.visible`,{issue_number:String(e.issue.number)}),u=await tt(`github.issue.review.instructions`),d=er({repo:t.repo,issue:t.issue,comments:n.comments??[]});await G.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),q.success(i(`session.newWorktree.toast.sessionFromIssue`));return}if(e.pr){if(!c.prContext)return;let t=await c.prContext(h,e.pr.number,{sourceRepo:e.pr.sourceRepo??null,includeDiff:e.includeDiff,includeCheckDetails:!1});if(t.connected===!1||!t.repo||!t.pr)throw Error(`Failed to load PR context`);let n=await tt(`github.pr.review.visible`,{pr_number:String(e.pr.number)}),r=await tt(`github.pr.review.instructions`),u=tr(t);await G.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),q.success(i(`session.newWorktree.toast.sessionFromPr`))}},[c,h,Re,Be,Je,i]),Xe=_===`new-branch`?y:x;X.useEffect(()=>{if(!e||!C?.all||!h||y.sourceBranch)return;let t=y.sourceBranch,n=!1;return(async()=>{try{let e=s?(await a.getGitStatus(h)).current:await mt(h).catch(()=>null);if(n)return;let r=localStorage.getItem(xt),{sourceBranch:i,shouldClearSavedSourceBranch:o}=vt({branches:C.all,savedSourceBranch:r,rootBranch:e});if(o&&localStorage.removeItem(xt),n||t)return;i&&b(e=>({...e,sourceBranch:i}))}catch{}})(),()=>{n=!0}},[e,C?.all,h,y.sourceBranch,s,a]),X.useLayoutEffect(()=>{if(!e)return;v(`new-branch`),S({selectedBranch:``,worktreeName:``}),B(!1),ae(!1),oe(!1),ce(!1),le(``),de(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=I();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,I]),X.useEffect(()=>{if(_!==`new-branch`||!y.isSyncingWorktreeName)return;let e=$(Zn(y.branchName));b(t=>({...t,worktreeName:e}))},[_,y.branchName,y.isSyncingWorktreeName]);let nt=X.useCallback(async()=>{if(!g||!K.touched||Y)return;Ie&&Ie.abort();let e=new AbortController;Le(e),J(e=>({...e,isValidating:!0}));try{let t=_===`new-branch`?y.branchName:x.selectedBranch,n=Xe.worktreeName,r=Zn(t),o=$(n),c=null,l=null;if(r||(c=i(`session.newWorktree.error.branchNameRequired`)),o||(l=i(`session.newWorktree.error.worktreeDirectoryRequired`)),r&&o){let t=_===`new-branch`?y.linkedPr:null,n=t?$n(t,k,A):null,i={mode:_===`existing-branch`||n?`existing`:`new`,branchName:r,worktreeName:o,existingBranch:n?.existingBranch??(_===`existing-branch`?r:void 0),...n?.ensureRemoteName?{ensureRemoteName:n.ensureRemoteName}:{},...n?.ensureRemoteUrl?{ensureRemoteUrl:n.ensureRemoteUrl}:{}},u=s?await a.validateGitWorktree(h,i):await ft(g,i);if(e.signal.aborted)return;u.ok||u.errors.forEach(e=>{if(e.code===`worktree_exists`){l??=e.message;return}e.code.startsWith(`branch_`)&&(c??=e.message)})}e.signal.aborted||J(e=>({...e,isValidating:!1,branchError:c,worktreeError:l}))}catch{e.signal.aborted||J(e=>({...e,isValidating:!1}))}},[s,a,h,g,_,y.branchName,y.linkedPr,x.selectedBranch,Xe.worktreeName,k,A,K.touched,Ie,Y,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!K.touched||Y)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,K.touched,Y]);let it=async()=>{if(!g||!h){q.error(i(`session.newWorktree.error.noActiveProject`));return}J(e=>({...e,touched:!0}));let e=_===`new-branch`?y.branchName:x.selectedBranch,r=Xe.worktreeName,a=Zn(e),c=$(r);if(!a){q.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){q.error(i(`session.newWorktree.error.worktreeDirectoryRequired`));return}Ie&&(Ie.abort(),Le(null)),J(e=>({...e,isValidating:!1,branchError:null,worktreeError:null})),Fe(!0);try{let e=_===`new-branch`?y.linkedPr:null,r=_===`new-branch`?y.linkedIssue:null,l=_===`new-branch`?y.linkedPr:null,u=_===`new-branch`&&y.includePrDiff,d=!!(r||l);if(s&&o&&m?.hostId){let l=m;se.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,k,A):null,p=r?`#${r.number} ${r.title}`.trim():e?`#${e.number} ${e.title}`.trim():void 0,h=await un(l,{mode:f||_===`existing-branch`?`existing`:`new`,worktreeName:c,branchName:_===`new-branch`?a:void 0,existingBranch:f?.existingBranch??(_===`existing-branch`?a:void 0),..._===`new-branch`&&!f&&y.sourceBranch?{startRef:y.sourceBranch}:{},...f?{setUpstream:f.setUpstream,upstreamRemote:f.upstreamRemote,upstreamBranch:f.upstreamBranch,...f.ensureRemoteName?{ensureRemoteName:f.ensureRemoteName}:{},...f.ensureRemoteUrl?{ensureRemoteUrl:f.ensureRemoteUrl}:{}}:{}},{title:p,createSession:d,kind:e?`pr`:`standard`,createdFromBranch:f?.sourceLabel??y.sourceBranch,isSelected:()=>se.getState().activeProjectId===l.id});s.sdk();let g=V.getState().remoteSession;g?.projectId===l.id&&g.location.hubId===s.location.hubId&&g.location.hostId===s.location.hostId&&g.location.directory===h.path&&g.sessionId===(h.id??null)&&n?.(h.path,{...h.id?{sessionId:h.id}:{},remote:!0}),t(!1),q.success(i(`session.newWorktree.toast.worktreeCreated`)),h.id&&d&&Un(o.registry,s,h.path,h.id,{issue:r,pr:e,includeDiff:u},i(`session.newWorktree.error.sendGitHubContextFailed`)).catch(e=>{q.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([Pe(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,k,A);return b=t.sourceLabel,{preferredName:a||c,mode:`existing`,branchName:a,worktreeName:c,existingBranch:t.existingBranch,setupCommands:f,setUpstream:t.setUpstream,upstreamRemote:t.upstreamRemote,upstreamBranch:t.upstreamBranch,returnAfterDirectoryCreated:!0,...t.ensureRemoteName?{ensureRemoteName:t.ensureRemoteName}:{},...t.ensureRemoteUrl?{ensureRemoteUrl:t.ensureRemoteUrl}:{}}}return b=_===`new-branch`?v:``,{preferredName:a||c,mode:_===`existing-branch`?`existing`:`new`,branchName:_===`existing-branch`?void 0:a,worktreeName:c,existingBranch:_===`existing-branch`?a:void 0,setupCommands:f,returnAfterDirectoryCreated:!0,...v&&_===`new-branch`?{startRef:v}:{}}})(),C=await yt(h,S,{resolvedRootTrackingRemote:p}),w=await ht(g,C),T=null;if(d){await ge(g)&&await Ae(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await ie(e,w.path,null);if(!a?.id)throw Error(`Failed to create session`);T=a.id,n?.(w.path,{sessionId:T}),t(!1),Fe(!1),je(a.id,e).catch(()=>void 0);try{G.getState().initializeNewYuriSession(a.id,me.getState().agents)}catch{}}else t(!1),Fe(!1);let E=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});E&&localStorage.setItem(xt,E),q.success(i(`session.newWorktree.toast.worktreeCreated`),{description:i(`session.newWorktree.toast.worktreeCreatedDescription`,{target:`${w.branch||w.name}${b?` ${i(`session.newWorktree.fromSource`,{source:b})}`:``}`})}),T?Ye({sessionId:T,directory:w.path,issue:r,pr:l,includeDiff:u}).catch(e=>{let t=e instanceof Error?e.message:i(`session.newWorktree.error.sendGitHubContextFailed`);q.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:t})}):n?.(w.path)}catch(e){let t=e instanceof Error?e.message:i(`session.newWorktree.error.createWorktreeFailed`);q.error(i(`session.newWorktree.error.createWorktreeFailed`),{description:t})}finally{Fe(!1)}},ct=e=>{v(e),J(e=>({...e,touched:!1,branchError:null,worktreeError:null}))},lt=e=>{if(!e){b(e=>({...e,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:``}));return}if(e.type===`issue`){let t=e.item,n=`issue-${t.number}-${cn()}`;b(e=>({...e,linkedIssue:t,linkedPr:null,includePrDiff:!1,branchName:n,worktreeName:$(n),isSyncingWorktreeName:!0}))}else if(e.type===`pr`){let t=e.item;b(n=>({...n,linkedPr:t,linkedIssue:null,includePrDiff:e.includeDiff??!1,branchName:t.head,worktreeName:$(t.head),isSyncingWorktreeName:!0}))}},dt=p&&f?.connected===!0,pt=(_===`existing-branch`?!!x.selectedBranch&&!!x.worktreeName&&!K.branchError&&!K.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!K.branchError&&!K.worktreeError)&&!Y,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(j.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(j.error||l.error)?.message,(0,Q.jsx)(P,{size:`xs`,variant:`ghost`,onClick:()=>{j.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:F(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:K.touched&&(K.branchError||K.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:K.branchError||K.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Y,className:F(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(P,{size:`sm`,onClick:it,disabled:!pt||Y,className:F(`gap-1.5`,u&&`flex-1`),children:[Y&&(0,Q.jsx)(L,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Y?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(He,{id:`new-worktree-sheet-${d}`,open:e,onOpenChange:t,title:(0,Q.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`session.newWorktree.title`)}),ariaLabel:i(`session.newWorktree.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`overscroll-contain px-4 pb-4 pt-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mb-4`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(L,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>oe(!0),className:`flex-1 justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:x.selectedBranch?`text-foreground`:`text-muted-foreground`,children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(L,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Me,disabled:!ke||E,title:i(`session.newWorktree.fetchBranches`),children:E?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:H,title:i(`session.newWorktree.selectBranch`),onClose:()=>oe(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:he,children:[(0,Q.jsx)(st,{value:W,onChange:e=>le(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),E?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Te&&De&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),oe(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>te(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(L,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:F(`h-8`,K.touched&&K.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:F(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(L,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:F(`h-8`,K.touched&&K.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>ce(!0),className:`w-full justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:y.sourceBranch?`text-foreground`:`text-muted-foreground`,children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(L,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})}),(0,Q.jsx)(ut,{open:U,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>ce(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:_e,children:[(0,Q.jsx)(st,{value:ue,onChange:e=>de(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),E?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Ee&&Oe&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:we.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),ce(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),we.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:we.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),ce(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),we.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:we.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ce(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(L,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-3 pt-2`,children:Ct})]})}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{className:`max-w-lg max-h-[80vh] flex flex-col`,children:[(0,Q.jsx)(Ue,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Ke,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(L,{name:`git-branch`,className:`h-5 w-5`}),i(`session.newWorktree.title`)]}),(0,Q.jsx)(`div`,{className:`w-[280px] shrink-0`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(L,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto mt-2 space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)($e,{open:z,onOpenChange:B,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:F(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{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:fe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:W,onValueChange:le,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:E?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Te&&De&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ce.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Te&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ce.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ce.otherLocal.length>0||Te)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ce.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Me,disabled:!ke||E,title:i(`session.newWorktree.fetchBranches`),children:E?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`refresh`,className:`size-4`})})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>te(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(L,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:F(`h-8`,K.touched&&K.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:F(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(L,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:F(`h-8`,K.touched&&K.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)($e,{open:re,onOpenChange:ae,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:F(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{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:pe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:ue,onValueChange:de,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:E?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Ee&&Oe&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:we.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ae(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),we.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Ee&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:we.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ae(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),we.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(we.otherLocal.length>0||Ee)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:we.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ae(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(L,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]}),(0,Q.jsxs)(We,{className:`mt-1 flex items-center justify-between`,children:[St,(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 text-destructive`,children:K.touched&&(K.branchError||K.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:K.branchError||K.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Y,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(P,{size:`sm`,onClick:it,disabled:!pt||Y,className:`gap-1.5`,children:[Y&&(0,Q.jsx)(L,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Y?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:R,onOpenChange:te,onSelect:lt})]})}var ir=null,ar=new Set,or=()=>{for(let e of ar)e()},sr=e=>e===`chat`||e===`assistant`,cr=()=>ir,lr=e=>{ir!==e&&(ir=e,or())},ur=e=>{ir&&(e&&ir.surfaceID!==e||(ir=null,or()))},dr=(e,t)=>{if(e.transportIdentity!==t.transportIdentity||e.runtimeGeneration!==t.runtimeGeneration)throw Error(`chat-input-delivery-runtime-stale`)},fr=e=>{let t=e.options?.delivery===`steer`?`steer`:e.options?.delivery===`queue`?`queue`:void 0,n={...t?{delivery:t}:{},...e.options?.commitStagedMessageEdit===void 0?{}:{commitStagedMessageEdit:e.options.commitStagedMessageEdit},...e.options?.messageID?{messageID:e.options.messageID}:{},...e.options?.ticket?{ticket:e.options.ticket}:{}},r=e.options?.sessionId??e.sessionID??void 0;if(!r)return n;let i=e.options?.directoryHint===void 0?e.directory||null:e.options.directoryHint;return{...n,sessionId:r,directoryHint:i}},pr=(e,t,n={})=>({operation:t,surfaceID:e.surfaceID,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration,sessionID:e.sessionID,directory:e.directory??``,draftKey:e.draftKey,deliveryTarget:e.deliveryTarget,...n}),mr=e=>{if(!e.active||!e.draftKey||!e.directory)return null;let t=e.activity?.phase??`idle`,n=e.activity?.canAbort??(t===`busy`||t===`retry`);return{send:async t=>{let n=pr(e,`send`,t);return await e.selection.flush(),e.kind===`secondary`&&await e.shortcuts.submit(),e.backend.send(n)},sendQueued:async(t,n={})=>{let{manual:r,...i}=n,a=pr(e,`send`,i),o=Qt(e);if(await e.selection.flush(),!o)throw Error(`chat-input-queue-scope-incomplete`);return e.backend.sendQueued({...a,queueItemID:t,manual:r,queueScope:o})},create:async()=>{let t=pr(e,`create`);return await e.selection.flush(),e.backend.create(t)},compact:async t=>{let n=pr(e,`compact`,t);return await e.selection.flush(),e.backend.compact(n)},abort:async()=>{let t=pr(e,`abort`);return await e.selection.flush(),e.backend.abort(t)},queueScope:Qt(e),canAbort:n,canQueue:t===`busy`||t===`retry`,allowsCommand:t=>Gt(e,{name:t,source:`yuri`}),shortcut:async(t,n=1)=>{if(e.kind===`secondary`){t===`cycle`?await e.shortcuts.cycle(n):t===`new`?await e.shortcuts.new():t===`abort`?await e.shortcuts.abort():await e.shortcuts.submit();return}if(t===`abort`){let t=pr(e,`abort`);await e.selection.flush(),await e.backend.abort(t);return}if(t===`new`){let t=pr(e,`create`);await e.selection.flush(),await e.backend.create(t);return}t!==`submit`&&await e.shortcuts?.cycle(n)},resources:e.resources??null}},hr=e=>e.type===`tool`&&e.metadata?.providerExecuted===!0,gr=e=>{if(e.type!==`tool`)return!1;let t=e.state;return t?.status===`error`&&t.metadata?.interrupted===!0},_r=e=>e.type!==`tool`||hr(e)?!1:!gr(e),vr=e=>{let t=0;for(let n of e)_r(n)&&(t+=1);return t},yr=(e,t)=>e===`stop`&&vr(t)===0,br=e=>{if(e.type!==`text`||e.synthetic===!0)return!1;let t=e.text;return typeof t==`string`&&Tt(t)},xr=e=>{if(vr(e)!==0)return-1;for(let t=e.length-1;t>=0;--t){let n=e[t];if(br(n))return t;if(n.type===`tool`||n.type===`reasoning`||n.type===`file`||n.type===`agent`||n.type===`subtask`)break}return-1},Sr=(e,t,n)=>{if(n||!yr(e,t))return!1;for(let e of t)if(br(e))return!0;return!1},Cr=e=>e===`streaming`||e===`cooldown`,wr=e=>e.parts.some(br),Tr=e=>Cr(e.streamPhase)?wr(e):!1,Er=e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``},Dr=e=>{let t=e?.type;return t===`compaction`?!_(e):t===`text`&&Er(e).trim()===`/compact`},Or=e=>e?e.some(e=>Dr(e)):!1,kr=e=>Or(e.parts),Ar=e=>e?Or(e.sourceParts)||Or(e.parts):!1,jr=e=>{if(!kr(e))return e;let t=!1,n=e.parts.map(e=>e?.type!==`compaction`||_(e)?e:(t=!0,{type:`text`,text:`/compact`})),r=e.info.clientRole!==`user`;return!t&&!r?e:{...e,info:r?{...e.info,clientRole:`user`}:e.info,parts:t?n:e.parts}},Mr=e=>{let t=Et(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},Nr=new WeakMap,Pr=e=>{let t=Nr.get(e);if(t)return t;let n=jr(Mr(e)),r=n.parts,i=Fe(r),a=i===r?n:{...n,parts:i,sourceParts:r};return Nr.set(e,a),a},Fr={activity:`idle`,hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:null,turnStartedAt:void 0},Ir=[],Lr=`\0`,Rr=new Set([`edit`,`write`,`apply_patch`]),zr={read:`chat.assistantStatus.readingFile`,write:`chat.assistantStatus.writingFile`,edit:`chat.assistantStatus.editingFile`,apply_patch:`chat.assistantStatus.applyingPatch`,bash:`chat.assistantStatus.runningCommand`,grep:`chat.assistantStatus.searchingContent`,glob:`chat.assistantStatus.findingFiles`,list:`chat.assistantStatus.listingDirectory`,task:`chat.assistantStatus.delegatingTask`,webfetch:`chat.assistantStatus.fetchingUrl`,websearch:`chat.assistantStatus.searchingWeb`,codesearch:`chat.assistantStatus.webCodeSearch`,todowrite:`chat.assistantStatus.updatingTodos`,todoread:`chat.assistantStatus.readingTodos`,skill:`chat.assistantStatus.learningSkill`,question:`chat.assistantStatus.askingQuestion`,execute:`chat.assistantStatus.executing`,session_rename:`chat.assistantStatus.renamingSession`,session_move:`chat.assistantStatus.movingSession`,browser:`chat.assistantStatus.usingBrowser`},Br=[`chat.assistantStatus.working`,`chat.assistantStatus.processing`,`chat.assistantStatus.preparing`,`chat.assistantStatus.warmingUp`,`chat.assistantStatus.gearsTurning`,`chat.assistantStatus.computing`,`chat.assistantStatus.calculating`,`chat.assistantStatus.analyzing`,`chat.assistantStatus.wheelsSpinning`,`chat.assistantStatus.calibrating`,`chat.assistantStatus.synthesizing`,`chat.assistantStatus.connectingDots`,`chat.assistantStatus.inspectingLogic`,`chat.assistantStatus.weighingOptions`],Vr=(e,t)=>{let n=zr[Be(e)];return n?t(n):t(`chat.assistantStatus.usingTool`,{tool:e})},Hr=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},Ur=(e,t)=>t(Br[Hr(e)%Br.length]??`chat.assistantStatus.working`),Wr=(e,t,n)=>{let r,i;if(!fe(e))for(let t=e.length-1;t>=0;--t){let n=e[t];if(n)switch(n.type){case`reasoning`:{let e=n.time??Xr(n);(!e||e.end===void 0)&&!r&&(r=`reasoning`);break}case`tool`:{let e=n.state?.status;if((e===`running`||e===`pending`)&&!r){let e=Be(Zr(n));Rr.has(e)?(r=`editing`,i=e):(r=`tool`,i=e)}break}case`text`:{let e=Yr(n)??``;if(typeof e==`string`&&e.trim().length>0){let e=Xr(n);(!e||e.end===void 0)&&!r&&(r=`text`)}break}}}let a=r===void 0,o=r===`editing`?n(`chat.assistantStatus.editingFile`):r===`tool`&&i?Vr(i,n):r===`reasoning`?n(`chat.assistantStatus.thinking`):r===`text`?n(`chat.assistantStatus.composing`):Ur(t,n);return{activePartType:r,activeToolName:i,statusText:o,isGenericStatus:a}},Gr=e=>[e.activePartType??``,e.activeToolName??``,e.statusText,e.isGenericStatus?`1`:`0`].join(Lr),Kr=e=>{let[t,n,r=`working`,i]=e.split(Lr);return{activePartType:t===`text`||t===`tool`||t===`reasoning`||t===`editing`?t:void 0,activeToolName:n||void 0,statusText:r,isGenericStatus:i===`1`}},qr=e=>e.type===`reasoning`,Jr=e=>e.type===`text`,Yr=e=>{if(Jr(e))return e.text;let t=e;if(typeof t.text==`string`)return t.text;if(typeof t.content==`string`)return t.content;if(typeof t.value==`string`)return t.value},Xr=e=>(Jr(e)||qr(e),e.time),Zr=e=>{if(e.tool)return e.tool;let t=e;return typeof t.name==`string`?t.name:`tool`};function Qr(e,t){let{t:n}=ze(),r=G(e=>e.currentSessionId),i=G(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=pe(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=G(c),u=De(a??``,o??void 0),d=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`assistant`)return{id:t.id,index:e,finish:t.finish,error:t.error,isCompaction:t.clientRole===`compaction`,startedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,finish:void 0,error:void 0,isCompaction:!1,startedAt:void 0}},[u]),f=d.id,p=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`user`&&!x(t))return{id:t.id,index:e,turnStartedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,turnStartedAt:void 0}},[u]),m=p.id,h=ye(f??``,o??void 0,a??void 0),g=ye(m??``,o??void 0,a??void 0),_=!!m&&Or(g),v=d.isCompaction&&d.index>p.index?h.find(e=>e.type===`compaction`):void 0,y=v?.reason===`manual`?d.startedAt:p.turnStartedAt,b=!!(f&&d.index>p.index&&(v?v.status===`failed`||v.reason===`manual`&&v.status===`completed`:Sr(d.finish,h,d.error))),S=X.useMemo(()=>{let e=`${a??``}:${f??``}`;return Gr(Wr(f&&!d.error&&d.index>p.index?h:Ir,e,n))},[a,f,d.error,d.index,p.index,h,n]),C=be(a??``,o??void 0),w=Me(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),E=G(T),{phase:D,isWorking:O}=nn(a,o??void 0),k=!!(d.error&&d.index>p.index),A=Oe(a??``,o??void 0),ee=A?.type===`retry`?A.attempt:void 0,j=A?.type===`retry`?A.next:void 0,M=X.useMemo(()=>Kr(S),[S]),N=X.useMemo(()=>{let e=!!(E&&!E.acknowledged);return{wasAborted:e,abortActive:e}},[E]),P=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:O};if(k&&D!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:O};if(N.wasAborted)return{...Fr,wasAborted:!0,abortActive:N.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(b)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=O,t=D===`busy`,r=D===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(M.activePartType===`tool`||M.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:ee,next:j,message:A?.type===`retry`?A.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(M.activePartType===`tool`||M.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):M.statusText:null,isGenericStatus:!e||!i&&M.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?M.activePartType:void 0,activeToolName:e&&!i?M.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,k,D,O,b,_,v?.status,y,M,N,ee,j,A,n]);return{forming:X.useMemo(()=>({isActive:!s&&!k&&O&&M.activePartType===`text`,characterCount:0}),[s,k,O,M.activePartType]),working:X.useMemo(()=>{if(s||P.wasAborted||P.abortActive)return P;if(l)return{...P,activity:`streaming`,hasWorkingContext:!0,isWorking:!0,isStreaming:!0,isCooldown:!1,lifecyclePhase:`streaming`,statusText:n(`chat.assistantStatus.sendingMessage`),isGenericStatus:!1,isWaitingForPermission:!1,canAbort:!0,activePartType:void 0,activeToolName:void 0,isComplete:!1,isTurnSettled:!1,retryInfo:null};let e=C.length>0,t=w.length>0;return!e&&!t?P:t?{...P,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...P,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,P,l,C,w,n])}}var $r=`--yuri-mobile-header-collapse`,ei=e=>e.closest(`.mobile-chat-screen`)?.querySelector(`:scope > [data-yuri-collapsible-header="true"]`)??null,ti=e=>{e.style.removeProperty($r),delete e.dataset.yuriHeaderCollapsePhase,delete e.dataset.yuriHeaderCollapseRest},ni=(e,t,n)=>{let r=String(t.progress),i=t.phase,a=t.rest===`compact`?`collapsed`:`expanded`;return n?.phase!==i&&(e.dataset.yuriHeaderCollapsePhase=i,i===`snapping`&&n&&n.phase!==`snapping`&&e.offsetWidth),n?.progress!==r&&e.style.setProperty($r,r),n?.rest!==a&&(e.dataset.yuriHeaderCollapseRest=a),{progress:r,phase:i,rest:a}},ri=e=>{let t=e.startsWith(`#`)?e.slice(1):e;if(!t)return null;let n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:`turn`,id:n[1]};let r=t.match(/^message-(.+)$/);return r?.[1]?{kind:`message`,id:r[1]}:null},ii=(e,t,n)=>{if(n===0||e.length===0)return{kind:`noop`};let r=t?e.indexOf(t):e.length-1,i=(r>=0?r:e.length-1)+n;if(i>=e.length)return{kind:`resume`};let a=e[Math.max(0,i)];return a?{kind:`turn`,turnId:a}:{kind:`noop`}},ai=e=>{if(typeof window>`u`)return;let t=e?`#${e}`:``,n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,``,n),e&&window.dispatchEvent(new HashChangeEvent(`hashchange`))},oi=e=>{e&&ai(`message-${e}`)},si=e=>{let t=(0,Z.c)(29),{sessionId:n,turnIds:r,activeTurnId:i,scrollToTurn:a,scrollToMessage:o,resumeToBottom:s}=e,c=X.useRef(r),l=X.useRef(i),u,d;t[0]===r?(u=t[1],d=t[2]):(u=()=>{c.current=r},d=[r],t[0]=r,t[1]=u,t[2]=d),X.useEffect(u,d);let f,p;t[3]===i?(f=t[4],p=t[5]):(f=()=>{l.current=i},p=[i],t[3]=i,t[4]=f,t[5]=p),X.useEffect(f,p);let m;t[6]===a?m=t[7]:(m=async(e,t)=>e?(t?.updateHash!==!1&&ai(`turn-${e}`),a(e,{behavior:t?.behavior})):!1,t[6]=a,t[7]=m);let h=m,g;t[8]===o?g=t[9]:(g=async(e,t)=>e?(t?.updateHash!==!1&&ai(`message-${e}`),o(e,{behavior:t?.behavior})):!1,t[8]=o,t[9]=g);let _=g,v;t[10]!==s||t[11]!==h?(v=async(e,t)=>{let n=c.current,r=ii(n,l.current,e);if(r.kind===`noop`)return e===0;if(r.kind===`resume`){if(t?.resumePastEnd===!1){let e=n[n.length-1];return e?h(e,{behavior:`auto`}):!1}return ai(null),s(),!0}return h(r.turnId,{behavior:`auto`})},t[10]=s,t[11]=h,t[12]=v):v=t[12];let y=v,b;t[13]===s?b=t[14]:(b=()=>{ai(null),s()},t[13]=s,t[14]=b);let x=b,S;t[15]!==_||t[16]!==h||t[17]!==n?(S=()=>{if(!n||typeof window>`u`)return;let e=()=>{let e=ri(window.location.hash);if(e){if(e.kind===`turn`){h(e.id,{behavior:`auto`,updateHash:!1});return}_(e.id,{behavior:`auto`,updateHash:!1})}};return e(),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`hashchange`,e)}},t[15]=_,t[16]=h,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==_||t[20]!==h||t[21]!==n||t[22]!==r.length?(C=[n,_,h,r.length],t[19]=_,t[20]=h,t[21]=n,t[22]=r.length,t[23]=C):C=t[23],X.useEffect(S,C);let w;return t[24]!==x||t[25]!==y||t[26]!==_||t[27]!==h?(w={scrollToTurnId:h,scrollToMessageId:_,scrollByTurnOffset:y,resumeToLatest:x},t[24]=x,t[25]=y,t[26]=_,t[27]=h,t[28]=w):w=t[28],w},ci=[0,200,400],li=e=>{let t=(0,Z.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=F(`inline-flex`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=ci.map(ui),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsxs)(Q.Fragment,{children:[`\xA0`,(0,Q.jsx)(`span`,{className:r,"aria-hidden":`true`,children:i})]}),t[3]=r,t[4]=a),a};function ui(e){return(0,Q.jsx)(`span`,{className:`animate-busy-pulse`,style:{animationDelay:`${e}ms`},children:`.`},e)}export{En as A,Xt as B,sr as C,Tn as D,Ln as E,wn as F,Ut as G,Vt as H,cn as I,qt as J,Yt as K,rn as L,Dn as M,Cn as N,On as O,Sn as P,Ot as Q,an as R,cr as S,nr as T,$t as U,Gt as V,Zt as W,Bt as X,Jt as Y,Dt as Z,Tr as _,ti as a,fr as b,Qr as c,wr as d,vr as f,br as g,yr as h,$r as i,jn as j,kn as k,Pr as l,Sr as m,oi as n,ni as o,xr as p,Ht as q,si as r,ei as s,li as t,Ar as u,dr as v,lr as w,ur as x,mr as y,nn as z};
@@ -1,3 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{R as n,f as r,s as i}from"./platform-CiUKDeXd.js";import{o as a}from"./vendor-zustand-CTekDqaS.js";import{ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{Lt as c,n as l}from"./client-B_907PBv.js";import{n as u}from"./vendor-react-BkccXcWz.js";import{o as d,s as f,u as p}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{l as m}from"./yuriEvents-BFrD5fMU.js";import{E as h,O as g}from"./runtime-file-resource-Bc_ss-sW.js";import{h as _,r as v,u as y}from"./vendor-reactuses-core-DjKFMfz7.js";import{n as b,r as x,t as S}from"./useUIStore-C3ewjGgP.js";import{r as C}from"./vendor-sonner-DX3nfJx4.js";import{i as w,o as T}from"./session-startup-barrier-BfAFvTz_.js";import{n as E}from"./Icon-BLvjcKMe.js";import{Fa as D,H as O,Ma as k,U as A,Wr as j,Xn as M,ar as N,cn as P,f as F,it as ee,nr as te,qa as I,un as L}from"./ui-BBJAK87V.js";import{t as R}from"./i18n-ByGlB3HF.js";import{n as z}from"./react-CPBNl-S9.js";import{n as B}from"./useEffectiveDirectory-BjJFgVDo.js";import{n as V}from"./useProjectRuntimeAPIs-KvnGYSW7.js";import{a as ne,o as re,r as H,s as ie}from"./useProjectGitStore-YLxAq2tN.js";import{t as ae}from"./AgentAvatar-BMyOvw1S.js";import{i as U,n as W,r as G,t as oe}from"./card-DG0czc0D.js";import{g as K,h as q,m as J,t as se,v as ce}from"./ChatContainer-B7K4osTN.js";import{f as le,g as ue,h as Y,m as X,p as de}from"./ToolOutputDialog-ph2fXE2y.js";var Z=u(),Q=t(s(),1),$=o(),fe=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(oe,{className:`w-full max-w-md`,children:[(0,$.jsx)(G,{className:`text-center`,children:(0,$.jsxs)(U,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(E,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(W,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(w,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(E,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function pe(e){let t=(0,Z.c)(22),{t:n}=R(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(fe,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var me=1440,he=e=>{let t=(0,Z.c)(10),{isMobile:n,isVSCode:r,directory:i}=e,a=y(`(min-width: ${me}px)`),o;t[0]===i?o=t[1]:(o=i?b(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=S(e,s);return t?.isOpen?(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null)?.mode!==`chat`:!1},t[2]=s,t[3]=c);let l=x(c),u=x(ge),d;t[4]===s?d=t[5]:(d=e=>e.isRightSidebarOpen&&!!S(e,s)?.isOpen,t[4]=s,t[5]=d);let f=x(d),p=!n&&!r&&!l&&!f,m=p&&a,h=u&&m,g;return t[6]!==m||t[7]!==p||t[8]!==h?(g={visible:h,fits:m,layoutAllows:p},t[6]=m,t[7]=p,t[8]=h,t[9]=g):g=t[9],g};function ge(e){return e.workStatusPanelEnabled}var _e=async({directory:e,sessionID:t,signal:n})=>{let r=await l.getScopedSdkClient(e).session.list({directory:e,parentID:t,limit:200},{signal:n});if(!Array.isArray(r?.data))throw Error(`session.list children returned no data`);return r.data.flatMap(e=>{if(!e?.id)return[];let t=typeof e.title==`string`?e.title:void 0;return[{id:e.id,title:t}]})},ve=(e,t,n={})=>{let r=n.entry,i=n.listChildren??(r?async({directory:e,sessionID:t,signal:n})=>{let i=await r.sdk().session.list({directory:e,parentID:t,limit:200},{signal:n});if(r.sdk(),!Array.isArray(i?.data))throw Error(`session.list children returned no data`);return i.data.map(e=>({id:e.id,title:e.title}))}:_e);return d({queryKey:[...m.workStatusChildren.list(e,t,n.transport),...r?.queryScope??[]],enabled:!!(e&&t),queryFn:({signal:n})=>i({directory:e,sessionID:t,signal:n}),staleTime:5e3,refetchInterval:1e4})},ye=[],be=(...e)=>{let t=K(...e);return t?t.charAt(0).toUpperCase()+t.slice(1):``},xe=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.description;if(typeof e!=`string`)continue;let n=e.trim();if(n)return n}return``},Se=e=>e===`pending`||e===`running`,Ce=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&J(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:q(e),label:be(r?.input,r?.metadata,e.metadata),description:xe(r?.input,e.metadata,r?.metadata),running:Se(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):``,description:o,running:Se(r.status)})}}return t.length===0?ye:t},we=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.description!==i.description||r.running!==i.running)return!1}return!0},Te=e=>e.childTitle||e.description||e.agent,Ee=e=>({key:e.key,sessionID:e.sessionID,seed:e.key,label:Te(e),phase:e.working?`working`:`done`}),De=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[],o=new Map,s=e=>{let t=e.sessionID;if(!t){a.push(e);return}i.add(t);let n=o.get(t);if(n===void 0){o.set(t,a.length),a.push({...e,key:t,sessionID:t});return}let r=a[n];r&&(a[n]={...r,description:r.description||e.description,agent:r.agent||e.agent,childTitle:e.childTitle||r.childTitle,working:r.working||e.working})};for(let t of e){let e=t.sessionID?r.get(t.sessionID):void 0;s({key:t.id,sessionID:t.sessionID,description:t.description,agent:t.label,childTitle:e?.title?.trim()||``,working:t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID))})}for(let e of t)i.has(e.id)||s({key:e.id,sessionID:e.id,description:``,agent:``,childTitle:e.title?.trim()||``,working:e.busy});let c=a.map(Ee),l=c.filter(e=>e.phase===`working`),u=c.filter(e=>e.phase===`done`);return l.length===0?u:u.length===0?l:[...l,...u]},Oe=new Set,ke=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
2
- `)},Ae=(e,t)=>{let n=(0,Z.c)(4),r;n[0]===t?r=n[1]:(r=e=>t?ke(e.session_status):``,n[0]=t,n[1]=r);let i=a(e,r),o;return n[2]===i?o=n[3]:(o=i?new Set(i.split(`
3
- `)):Oe,n[2]=i,n[3]=o),o},je=(e,t)=>{let n=[];for(let r of e)!r.id||r.parentID!==t||n.push(`${r.id}\u0001${r.title??``}`);return n.join(``)},Me=e=>e?e.split(``).map(e=>{let t=e.indexOf(``);return{id:e.slice(0,t),title:e.slice(t+1)}}):[],Ne=(e,t,n)=>{let r=new Map;for(let t of e)t.id&&r.set(t.id,{id:t.id,title:t.title,busy:n.has(t.id)});for(let e of t??[]){if(!e.id)continue;let t=r.get(e.id),i=e.title?.trim()||t?.title;r.set(e.id,{id:e.id,title:i,busy:n.has(e.id)})}return[...r.values()]},Pe=(e,t)=>{let n=(0,Z.c)(18),r=!!(e&&t),i;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={bootstrap:!1},n[0]=i):i=n[0];let o=O(t||void 0,i),s;n[1]!==r||n[2]!==e?(s=t=>r&&e?je(t.session,e):``,n[1]=r,n[2]=e,n[3]=s):s=n[3];let l=a(o,s),u=t??``,d=e??``,p;n[4]!==u||n[5]!==d?(p=ve(u,d),n[4]=u,n[5]=d,n[6]=p):p=n[6];let m;n[7]!==r||n[8]!==p?(m={...p,enabled:r},n[7]=r,n[8]=p,n[9]=m):m=n[9];let h=f(m),g;n[10]===r?g=n[11]:(g={enabled:r},n[10]=r,n[11]=g);let _=c(e??``,t??``,o,Ce,we,g),v=Ae(o,r),y;bb0:{if(!e){let e;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[12]=e):e=n[12],y=e;break bb0}let t;n[13]!==v||n[14]!==l||n[15]!==h.data||n[16]!==_?(t=De(_,Ne(Me(l),h.data,v),v),n[13]=v,n[14]=l,n[15]=h.data,n[16]=_,n[17]=t):t=n[17],y=t}return y},Fe=[],Ie=e=>{let t=(0,Z.c)(11),{sessionId:n,directory:r}=e,i;t[0]===n?i=t[1]:(i=e=>(n?e.todo[n]:void 0)??Fe,t[0]=n,t[1]=i);let a=A(i,r??void 0),o;t[2]===n?o=t[3]:(o=e=>{let t=n?e.session_status?.[n]?.type:void 0;return t===`busy`||t===`retry`},t[2]=n,t[3]=o);let s=A(o,r??void 0),c;t[4]===n?c=t[5]:(c=e=>n?e.sessions[n]?.todos:void 0,t[4]=n,t[5]=c);let l=L(c),u=ee(n??``,r??void 0)??(a.length>0?a:l??Fe),d;t[6]===u?d=t[7]:(d=u.filter(ze),t[6]=u,t[7]=d);let f=d,p;return t[8]!==s||t[9]!==f?(p=(0,$.jsx)(Re,{todos:f,isWorking:s}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p},Le=e=>{let t=(0,Z.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({remote:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=r?(0,$.jsx)(Re,{...r}):(0,$.jsx)(Ie,{...n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i},Re=e=>{let t=(0,Z.c)(52),{todos:n,isWorking:r}=e,{t:i}=R(),a=Q.useId(),[o,s]=Q.useState(!0),[c,l]=Q.useState(!1),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(!0)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),Q.useEffect(u,d);let f;t[2]===n?f=t[3]:(f=n.filter(Be),t[2]=n,t[3]=f);let p=f.length,m;t[4]===n?m=t[5]:(m=n.filter(ue),t[4]=n,t[5]=m);let h=m.length,g=Q.useRef(null),_=n.findIndex(Ve),v,y;if(t[6]===_?(v=t[7],y=t[8]):(v=()=>{_<0||g.current?.children[_]?.scrollIntoView?.({block:`nearest`})},y=[_],t[6]=_,t[7]=v,t[8]=y),Q.useEffect(v,y),n.length===0)return null;let b=h===n.length,x=r&&!b,S;t[9]===i?S=t[10]:(S=i(`chat.workStatus.todos.title`),t[9]=i,t[10]=S);let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>s(He),t[11]=C):C=t[11];let E=b?`done`:`open`,D=c&&`yuri-todo-icon-pop`,O;t[12]===D?O=t[13]:(O=T(`inline-flex shrink-0`,D),t[12]=D,t[13]=O);let k;t[14]!==b||t[15]!==p||t[16]!==x||t[17]!==n.length?(k=b?(0,$.jsx)(le,{}):(0,$.jsx)(Y,{done:p,total:n.length,spinning:x}),t[14]=b,t[15]=p,t[16]=x,t[17]=n.length,t[18]=k):k=t[18];let A;t[19]!==O||t[20]!==k||t[21]!==E?(A=(0,$.jsx)(`span`,{className:O,children:k},E),t[19]=O,t[20]=k,t[21]=E,t[22]=A):A=t[22];let j;t[23]===i?j=t[24]:(j=i(`chat.workStatus.todos.title`),t[23]=i,t[24]=j);let M;t[25]===j?M=t[26]:(M=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:j}),t[25]=j,t[26]=M);let N;t[27]!==p||t[28]!==n.length?(N=(0,$.jsx)(de,{done:p,total:n.length,className:`text-[0.92em]`}),t[27]=p,t[28]=n.length,t[29]=N):N=t[29];let P;t[30]!==o||t[31]!==a||t[32]!==A||t[33]!==M||t[34]!==N?(P=(0,$.jsxs)(w,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 px-2 text-left text-[1em] font-normal leading-5 tracking-normal text-muted-foreground [&_svg]:size-3.5`,"aria-expanded":o,"aria-controls":a,onClick:C,children:[A,M,N]}),t[30]=o,t[31]=a,t[32]=A,t[33]=M,t[34]=N,t[35]=P):P=t[35];let F=!o,ee=!o,te=o?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,I;t[36]===te?I=t[37]:(I=T(`grid min-w-0 transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,te),t[36]=te,t[37]=I);let L;t[38]!==r||t[39]!==c||t[40]!==n?(L=(0,$.jsx)(X,{id:void 0,todos:n,isWorking:r,animate:c,listRef:g,rowClassName:`px-2 gap-2 [&_svg]:size-3.5 [&>span:first-child]:w-3.5`,className:`max-h-[15em] min-h-0 overflow-y-auto pt-[0.125em]`}),t[38]=r,t[39]=c,t[40]=n,t[41]=L):L=t[41];let z;t[42]!==a||t[43]!==F||t[44]!==ee||t[45]!==I||t[46]!==L?(z=(0,$.jsx)(`div`,{id:a,"aria-hidden":F,inert:ee,className:I,children:L}),t[42]=a,t[43]=F,t[44]=ee,t[45]=I,t[46]=L,t[47]=z):z=t[47];let B;return t[48]!==P||t[49]!==z||t[50]!==S?(B=(0,$.jsxs)(`div`,{role:`group`,"aria-label":S,className:`mt-2 flex min-w-0 flex-col text-[13px]`,children:[P,z]}),t[48]=P,t[49]=z,t[50]=S,t[51]=B):B=t[51],B};function ze(e){return e.content.length>0}function Be(e){return e.status===`completed`}function Ve(e){return e.status===`in_progress`}function He(e){return!e}var Ue=Q.memo(function(e){let t=(0,Z.c)(19),{host:n,entry:r,input:i}=e,a=Q.useRef(null),o=Q.useRef(null),s;t[0]!==r||t[1]!==n||t[2]!==i?(s=e=>n.mountWorkStatus(r,e,i),t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c=v(s),l;t[4]===c?l=t[5]:(l=()=>{if(!a.current)return;let e=c(a.current);return o.current=e,()=>{o.current=null,e.dispose()}},t[4]=c,t[5]=l);let u;t[6]!==r.generation||t[7]!==r.key||t[8]!==n||t[9]!==i.directory||t[10]!==i.scope||t[11]!==i.sessionId||t[12]!==c?(u=[n,r.key,r.generation,i.sessionId,i.directory,i.scope,c],t[6]=r.generation,t[7]=r.key,t[8]=n,t[9]=i.directory,t[10]=i.scope,t[11]=i.sessionId,t[12]=c,t[13]=u):u=t[13],Q.useLayoutEffect(l,u);let d,f;t[14]===i?(d=t[15],f=t[16]):(d=()=>{o.current?.update(i)},f=[i],t[14]=i,t[15]=d,t[16]=f),Q.useLayoutEffect(d,f);let p;return t[17]===r.key?p=t[18]:(p=(0,$.jsx)(`div`,{ref:a,"data-gui-plugin-mount":`work-status`,"data-gui-work-status":r.key,className:`min-w-0 empty:hidden`}),t[17]=r.key,t[18]=p),p}),We=Q.memo(function(e){let t=(0,Z.c)(9),{host:n,input:r}=e,i=Q.useSyncExternalStore(n.workStatus.subscribe,n.workStatus.getSnapshot,n.workStatus.getSnapshot),a;if(t[0]!==i||t[1]!==n||t[2]!==r){let e;t[4]!==n||t[5]!==r?(e=e=>(0,$.jsx)(Ue,{host:n,entry:e,input:r},e.key),t[4]=n,t[5]=r,t[6]=e):e=t[6],a=i.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)($.Fragment,{children:a}),t[7]=a,t[8]=o),o}),Ge=Q.memo(function(e){let t=(0,Z.c)(3),{input:n}=e,r=Q.useContext(z),i;return t[0]!==r||t[1]!==n?(i=r?(0,$.jsx)(We,{host:r,input:n}):null,t[0]=r,t[1]=n,t[2]=i):i=t[2],i}),Ke=[],qe=(e,t)=>{let n=r(e),i=r(t);return!!(n&&i&&(n===i||n.startsWith(`${i}/`)))};function Je(e){let t=(0,Z.c)(103),n=h();if(!n?.entry.location.hostId)throw Error(`Remote work status requires Host scope`);let{entry:i,registry:a}=n,{directory:o,hubId:s}=i.location,c=i.location.hostId,l;t[0]!==i||t[1]!==a?(l=te(a,i),t[0]=i,t[1]=a,t[2]=l):l=t[2];let u=l,m,_;t[3]===u?(m=t[4],_=t[5]):(m=()=>u.retain(),_=[u],t[3]=u,t[4]=m,t[5]=_),Q.useEffect(m,_);let[v,y]=Q.useState(),b;t[6]!==u.state||t[7]!==e?(b=()=>e?u.state.observe(e,y):void 0,t[6]=u.state,t[7]=e,t[8]=b):b=t[8];let x;t[9]!==u||t[10]!==e?(x=[u,e],t[9]=u,t[10]=e,t[11]=x):x=t[11],Q.useEffect(b,x);let S;t[12]!==u.state||t[13]!==e?(S=t=>e?u.state.repository.subscribe(u.state.scope(e),t):et,t[12]=u.state,t[13]=e,t[14]=S):S=t[14];let C=S,w;t[15]!==u.state||t[16]!==e?(w=()=>e?u.state.repository.getTranscript(u.state.scope(e)):null,t[15]=u.state,t[16]=e,t[17]=w):w=t[17];let T=w,E=Q.useSyncExternalStore(C,T,T),O=u.state.subscribeSnapshot,A;t[18]!==u.state||t[19]!==e?(A=()=>u.state.getSnapshot(e??``),t[18]=u.state,t[19]=e,t[20]=A):A=t[20];let j=A,F=Q.useSyncExternalStore(O,j,j),ee=k($e),I=D(Qe),L;t[21]===i?L=t[22]:(L=M(i),t[21]=i,t[22]=L);let R=L,z=re(Ze),B;if(t[23]!==o||t[24]!==i.queryScope||t[25]!==R){let e;t[27]!==o||t[28]!==R?(e=()=>R.listGitWorktrees(o),t[27]=o,t[28]=R,t[29]=e):e=t[29],B=d({queryKey:[...i.queryScope,`work-status`,`worktrees`],queryFn:e,staleTime:3e4}),t[23]=o,t[24]=i.queryScope,t[25]=R,t[26]=B}else B=t[26];let V=B,ne;t[30]===i?ne=t[31]:(ne=N(i),t[30]=i,t[31]=ne);let H=ne,ie=e??``,ae;t[32]!==o||t[33]!==i||t[34]!==ie?(ae=ve(o,ie,{entry:i}),t[32]=o,t[33]=i,t[34]=ie,t[35]=ae):ae=t[35];let U=ae,W=f(V),G=f(H),oe=!!e,K;t[36]!==U||t[37]!==oe?(K={...U,enabled:oe},t[36]=U,t[37]=oe,t[38]=K):K=t[38];let q=f(K),J=p(),se;t[39]!==U||t[40]!==J||t[41]!==o||t[42]!==z||t[43]!==R||t[44]!==H||t[45]!==V?(se=async()=>{await Promise.all([J.fetchQuery({...V,staleTime:0}),J.fetchQuery({...H,staleTime:0}),J.fetchQuery({...U,staleTime:0}),z(o,R,{silent:!0})]),y(void 0)},t[39]=U,t[40]=J,t[41]=o,t[42]=z,t[43]=R,t[44]=H,t[45]=V,t[46]=se):se=t[46],g(e,se,y);let ce,le;t[47]!==U.queryKey||t[48]!==J||t[49]!==o||t[50]!==z||t[51]!==R||t[52]!==c||t[53]!==a||t[54]!==H.queryKey||t[55]!==V.queryKey?(ce=()=>a.subscribeEvents(c,e=>{if(e.directory&&r(e.directory)!==r(o))return;let t=e.payload?.type??``;t.startsWith(`session.`)&&!t.startsWith(`session.message.`)&&!t.startsWith(`session.tool.`)&&(/status|execution|retry|idle/.test(t)&&J.invalidateQueries({queryKey:H.queryKey}),/created|updated|renamed|deleted/.test(t)&&J.invalidateQueries({queryKey:U.queryKey})),t.startsWith(`worktree.`)||t===`vcs.branch.updated`?(J.invalidateQueries({queryKey:V.queryKey}),z(o,R,{silent:!0})):/^session\.(execution\.(succeeded|failed|interrupted)|idle)$/.test(t)&&z(o,R,{silent:!0})}),le=[a,c,o,J,H.queryKey,U.queryKey,V.queryKey,z,R],t[47]=U.queryKey,t[48]=J,t[49]=o,t[50]=z,t[51]=R,t[52]=c,t[53]=a,t[54]=H.queryKey,t[55]=V.queryKey,t[56]=ce,t[57]=le):(ce=t[56],le=t[57]),Q.useEffect(ce,le);let ue;if(t[58]!==o||t[59]!==c||t[60]!==s||t[61]!==ee||t[62]!==I||t[63]!==W.data){bb0:{let e;t[65]!==c||t[66]!==s?(e=e=>e.hostId===c&&e.hubId===s,t[65]=c,t[66]=s,t[67]=e):e=t[67];let n=ee.filter(e),i=I&&I.location.hostId===c&&I.location.hubId===s?n.find(e=>e.id===I.projectId):void 0;if(i){ue=i;break bb0}let a;t[68]!==o||t[69]!==W.data?(a=e=>qe(o,e.path)||W.data?.some(t=>r(t.path)===r(e.path)),t[68]=o,t[69]=W.data,t[70]=a):a=t[70],ue=n.filter(a).sort(Xe)[0]}t[58]=o,t[59]=c,t[60]=s,t[61]=ee,t[62]=I,t[63]=W.data,t[64]=ue}else ue=t[64];let Y=ue,X;t[71]!==o||t[72]!==Y?.path||t[73]!==W.data?(X=()=>{let e=W.data?.filter(e=>qe(o,e.path)).sort(Ye)[0];if(e)return{...e,projectDirectory:Y?.path??o,label:e.name,worktreeStatus:`ready`}},t[71]=o,t[72]=Y?.path,t[73]=W.data,t[74]=X):X=t[74],Y?.path;let de;t[75]===X?de=t[76]:(de=X(),t[75]=X,t[76]=de);let $=de,fe;if(t[77]!==q.data||t[78]!==G.data||t[79]!==E){let e;t[81]===G.data?e=t[82]:(e=G.data??{},t[81]=G.data,t[82]=e);let n=new Set(Object.keys(e));fe=De(E?Ce(E):[],(q.data??[]).map(e=>({...e,busy:n.has(e.id)})),n),t[77]=q.data,t[78]=G.data,t[79]=E,t[80]=fe}else fe=t[80];let pe=fe,me;t[83]!==F.session?.revert?.messageID||t[84]!==F.status?.type||t[85]!==E?(me=()=>({todos:(E?P(E,F.session?.revert?.messageID):void 0)??Ke,isWorking:F.status?.type===`busy`||F.status?.type===`retry`}),t[83]=F.session?.revert?.messageID,t[84]=F.status?.type,t[85]=E,t[86]=me):me=t[86],F.session?.revert?.messageID;let he;t[87]===me?he=t[88]:(he=me(),t[87]=me,t[88]=he);let ge=he,_e;t[89]!==q||t[90]!==u.state||t[91]!==e||t[92]!==G||t[93]!==W?(_e=async()=>{y(void 0),await Promise.allSettled([W.refetch(),G.refetch(),q.refetch(),e?u.state.refreshMetadata(e):Promise.resolve()])},t[89]=q,t[90]=u.state,t[91]=e,t[92]=G,t[93]=W,t[94]=_e):_e=t[94];let ye=_e,be=v??W.error??G.error??q.error,xe;return t[95]!==i.key||t[96]!==Y||t[97]!==ge||t[98]!==ye||t[99]!==pe||t[100]!==be||t[101]!==$?(xe={project:Y,worktree:$,subagents:pe,remoteTodos:ge,stateKey:i.key,error:be,retry:ye},t[95]=i.key,t[96]=Y,t[97]=ge,t[98]=ye,t[99]=pe,t[100]=be,t[101]=$,t[102]=xe):xe=t[102],xe}function Ye(e,t){return t.path.length-e.path.length}function Xe(e,t){return t.path.length-e.path.length}function Ze(e){return e.fetchStatus}function Qe(e){return e.remoteSession}function $e(e){return e.projects}function et(){}var tt=`flex w-full min-w-0 items-center justify-start gap-2 text-left text-[13px] font-normal leading-5 tracking-normal text-muted-foreground`,nt=`size-3.5 shrink-0`,rt=`yuri-work-status-action pointer-events-none shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/copy:pointer-events-auto group-hover/copy:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,it=e=>e.split(/[\\/]/).filter(Boolean).pop()||e,at=e=>{let t=(0,Z.c)(3),n=h(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(ot,{...e},n.entry.key):(0,$.jsx)(st,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},ot=Q.memo(function(e){let t=(0,Z.c)(9),{t:n}=R(),r=Je(e.sessionId),i;t[0]!==r||t[1]!==e?(i=(0,$.jsx)(ct,{...e,...r}),t[0]=r,t[1]=e,t[2]=i):i=t[2];let a;t[3]!==r||t[4]!==n?(a=r.error?(0,$.jsxs)(`div`,{role:`status`,className:`px-2 text-xs text-muted-foreground`,title:String(r.error),children:[n(`common.unavailable`),(0,$.jsx)(w,{variant:`ghost`,size:`xs`,onClick:()=>void r.retry(),children:n(`chat.history.retry`)})]}):null,t[3]=r,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==i||t[7]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[6]=i,t[7]=a,t[8]=o):o=t[8],o}),st=e=>{let t=(0,Z.c)(16),{sessionId:n,directory:i}=e,a=k(lt),o=F(ut),s;t[0]===n?s=t[1]:(s=e=>n?e.worktreeMetadata.get(n):void 0,t[0]=n,t[1]=s);let c=F(s),l,u;if(t[2]!==o||t[3]!==i||t[4]!==a||t[5]!==c){let e=r(i),n=t=>{let n=r(t);return!!(e&&n&&(e===n||e.startsWith(`${n}/`)))},s=c&&n(c.path)?c:void 0;l=j(a.filter(dt),o,s?.projectDirectory||i);let d=l?o.get(l.path):void 0;u=s??d?.filter(e=>n(e.path)).sort(ft)[0],t[2]=o,t[3]=i,t[4]=a,t[5]=c,t[6]=l,t[7]=u}else l=t[6],u=t[7];let d=u,f;t[8]!==l||t[9]!==d?(f={project:l,worktree:d},t[8]=l,t[9]=d,t[10]=f):f=t[10];let{project:p,worktree:m}=f,h=Pe(n,i),g=p??void 0,_;return t[11]!==e||t[12]!==h||t[13]!==g||t[14]!==m?(_=(0,$.jsx)(ct,{...e,project:g,worktree:m,subagents:h}),t[11]=e,t[12]=h,t[13]=g,t[14]=m,t[15]=_):_=t[15],_},ct=({sessionId:e,directory:t,active:n=!0,placement:i=`inline`,project:a,worktree:o,subagents:s,remoteTodos:c,stateKey:l})=>{let{t:u}=R(),{git:d}=V(),f=h(),p=f?.entry.location.hostId?f.entry:void 0,m=re(e=>e.ensureStatus),g=ne(t),y=H(t),b=ie(t),S=a?.path||o?.projectDirectory||t,T=a?.label?.trim()||(S?it(S):null),D=o&&r(o.path)!==r(S)?o.name?.trim()||it(o.path):null,O=[{phase:`working`,labelKey:`chat.workStatus.subagent.workingCount`,items:s.filter(e=>e.phase===`working`)},{phase:`done`,labelKey:`chat.workStatus.subagent.doneCount`,items:s.filter(e=>e.phase===`done`)}],k=O[0].items,A=(k.length>0?k:s).slice(0,3),[j,M]=Q.useState(!1),N=Q.useId(),P=x(e=>e.setRightSidebarOpen),F=x(e=>e.openContextPanel),ee=x(e=>e.openContextPanelTab),te=x(e=>e.setRightSidebarTab),[L,z]=Q.useState(null),[,B]=_(()=>z(null),1500,{immediate:!1}),U=v(async(e,t)=>{try{let n=await I(t);if(!n.ok)throw Error(n.error);z(e),B()}catch{C.error(u(`gitView.toast.copyFailed`))}});Q.useEffect(()=>{!t||!d||m(t,d)},[t,m,d]);let W=g?.current||null,G=o?.worktreeStatus===`pending`?0:g?.files.length??0,{additions:oe,deletions:K}=Q.useMemo(()=>{let e=0,t=0;for(let n of Object.values(g?.diffStats??{}))e+=n?.insertions??0,t+=n?.deletions??0;return{additions:e,deletions:t}},[g?.diffStats]),q=o?.worktreeStatus===`pending`,J=!q&&!!g&&b!==!1,se=q?`unknown`:b===!1?`not-repository`:J?`ready`:`unknown`,ce=J&&!!g?.diffStats,le=Q.useMemo(()=>({state:se,loading:y,branch:J?W:null,changedFiles:J?G:null,additions:ce?oe:null,deletions:ce?K:null}),[se,y,J,W,G,ce,oe,K]),ue=Q.useMemo(()=>({sessionId:e,directory:t,placement:i,scope:p,project:S&&T?{id:a?.id,name:T,directory:S}:null,worktree:o?{name:o.name?.trim()||it(o.path),directory:o.path}:null,git:le}),[e,t,i,p,S,T,a?.id,o,le]),Y=W?`branch:${W}`:``,X=o?.path?`worktree:${o.path}`:``,de=!!(Y&&L===Y),Z=!!(X&&L===X),fe=v(()=>{W&&U(Y,W)}),pe=v(()=>{let e=o?.path;e&&U(X,e)}),me=v(()=>{t&&(F(l??t),te(`git`),P(!0))});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[T?(0,$.jsxs)(`div`,{className:`${tt} h-8 px-2`,title:`${u(`chat.workStatus.section.project`)}: ${S}`,children:[(0,$.jsx)(E,{name:`folder`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:T})]}):null,W?(0,$.jsxs)(`div`,{className:`${tt} group/copy h-8 px-2`,title:`${u(`gitView.branch.currentBranchTooltip`)}: ${W}`,children:[(0,$.jsx)(E,{name:`git-branch`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:W}),(0,$.jsx)(w,{variant:`ghost`,size:`xs`,className:rt,"aria-label":u(`chat.workStatus.action.copyBranch`),title:u(de?`contextSidebar.actions.copied`:`chat.workStatus.action.copyBranch`),onClick:fe,children:(0,$.jsx)(E,{name:de?`check`:`file-copy`,className:nt})})]}):null,D?(0,$.jsxs)(`div`,{className:`${tt} group/copy h-8 px-2`,title:`${u(`sessions.sidebar.sessionDialogs.worktree.label`)}: ${o?.path}`,children:[(0,$.jsx)(E,{name:`node-tree`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:D}),(0,$.jsx)(w,{variant:`ghost`,size:`xs`,className:rt,"aria-label":u(`agentManager.detail.actions.copyWorktreePath`),title:u(Z?`contextSidebar.actions.copied`:`agentManager.detail.actions.copyWorktreePath`),onClick:pe,children:(0,$.jsx)(E,{name:Z?`check`:`file-copy`,className:nt})})]}):null,G>0?(0,$.jsxs)(w,{variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${tt}`,title:u(G===1?`chat.workStatus.git.changedFileSingle`:`chat.workStatus.git.changedFilePlural`,{count:G}),"aria-label":u(`chat.workStatus.action.openGit`),onClick:me,children:[(0,$.jsx)(E,{name:`changes`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:u(`chat.workStatus.compact.changes`)}),oe>0||K>0?(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 gap-1.5 text-[12px] tabular-nums`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-success)]`,children:`+${oe}`}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`−${K}`})]}):(0,$.jsx)(`span`,{className:`ml-auto tabular-nums`,children:G})]}):null,n?(0,$.jsx)(Ge,{input:ue}):null,(0,$.jsx)(Le,{sessionId:e,directory:t,remote:c}),s.length>0?(0,$.jsxs)(`div`,{role:`group`,"aria-label":u(`chat.workStatus.section.subagents`),className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(w,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${tt} gap-1.5`,"aria-expanded":j,"aria-controls":N,onClick:()=>M(e=>!e),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 items-center`,children:A.map((e,t)=>{let n=e.label.trim()||u(`chat.workStatus.subagent.untitled`);return(0,$.jsx)(ae,{name:e.seed,label:n,size:14,className:`relative bg-background ring-2 ring-background ${t>0?`-ml-1`:``}`},e.key)})}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-x-1 whitespace-nowrap text-left text-[11px] leading-5 tabular-nums`,children:O.filter(e=>e.items.length>0).map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,$.jsx)(`span`,{children:u(e.labelKey,{count:e.items.length})})]},e.phase))}),(0,$.jsx)(E,{name:j?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 text-muted-foreground opacity-70`})]}),(0,$.jsx)(`div`,{id:N,hidden:!j,className:j?`mt-1 mb-1 flex min-w-0 flex-col gap-1`:`hidden`,children:j?O.filter(e=>e.items.length>0).map(e=>(0,$.jsxs)(`section`,{"aria-label":u(e.labelKey,{count:e.items.length}),className:`flex min-w-0 flex-col gap-1 [&+section]:mt-2`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[11px] leading-4 text-muted-foreground/70`,children:u(e.labelKey,{count:e.items.length})}),e.items.map(e=>{let n=e.label.trim()||u(`chat.workStatus.subagent.untitled`);return(0,$.jsxs)(w,{variant:`ghost`,size:`sm`,disabled:!e.sessionID||!t,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 text-left text-[12px] font-normal leading-5 text-muted-foreground`,onClick:()=>{!e.sessionID||!t||ee(l??t,{mode:`chat`,dedupeKey:`session:${e.sessionID}`,label:n,readOnly:!0})},children:[(0,$.jsx)(ae,{name:e.seed,label:n,size:14}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:n,children:n})]},e.key)})]},e.phase)):null})]}):null]})};function lt(e){return e.projects}function ut(e){return e.availableWorktreesByProject}function dt(e){return!e.hostId}function ft(e,t){return t.path.length-e.path.length}var pt=200,mt=264,ht=e=>{let t=(0,Z.c)(31),{sessionId:n,directory:r,visible:i,overlay:a}=e,o=a!==void 0&&a,{t:s}=R(),c=x(gt),l=Q.useRef(null),[u,d]=Q.useState(i),f,p;t[0]===i?(f=t[1],p=t[2]):(f=()=>{if(i){d(!0);return}let e=window.setTimeout(()=>d(!1),pt);return()=>window.clearTimeout(e)},p=[i],t[0]=i,t[1]=f,t[2]=p),Q.useEffect(f,p);let m,h;t[3]!==o||t[4]!==c||t[5]!==i?(m=()=>{if(!o||!i)return;let e=e=>{let t=e.target instanceof Element?e.target:null;l.current?.contains(t)||t?.closest(`[data-work-status-toggle]`)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},h=[o,c,i],t[3]=o,t[4]=c,t[5]=i,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]===s?g=t[9]:(g=s(`chat.workStatus.ariaLabel`),t[8]=s,t[9]=g);let _=!i,v=!i,y=o?`top-3 z-30 max-h-[calc(100%-1.5rem)] rounded-xl p-2 ${ce}`:`top-2`,b;t[10]===y?b=t[11]:(b=T(`absolute z-20 flex max-h-[calc(100%-1rem)] flex-col overflow-x-hidden overflow-y-auto scrollbar-hidden bg-transparent`,y),t[10]=y,t[11]=b);let S=o?mt:i?196:0,C=+!!i,w=i?`none`:o?`translateY(-6px)`:`translateX(24px)`,E=o?`opacity, transform`:`none`,D=i?void 0:`none`,O;t[12]!==S||t[13]!==C||t[14]!==w||t[15]!==E||t[16]!==D?(O={right:14,width:S,opacity:C,transform:w,transitionProperty:E,transitionDuration:`${pt}ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`,pointerEvents:D},t[12]=S,t[13]=C,t[14]=w,t[15]=E,t[16]=D,t[17]=O):O=t[17];let k;t[18]!==u||t[19]!==r||t[20]!==o||t[21]!==n||t[22]!==i?(k=i||o&&u?(0,$.jsx)(at,{sessionId:n,directory:r,active:i,placement:o?`popover`:`inline`}):null,t[18]=u,t[19]=r,t[20]=o,t[21]=n,t[22]=i,t[23]=k):k=t[23];let A;return t[24]!==b||t[25]!==O||t[26]!==k||t[27]!==g||t[28]!==_||t[29]!==v?(A=(0,$.jsx)(`aside`,{ref:l,"aria-label":g,"aria-hidden":_,inert:v,className:b,style:O,children:k}),t[24]=b,t[25]=O,t[26]=k,t[27]=g,t[28]=_,t[29]=v,t[30]=A):A=t[30],A};function gt(e){return e.setWorkStatusOverlayOpen}var _t=e({ChatView:()=>yt}),vt=e=>{let t=(0,Z.c)(10),{sessionId:n,directory:r,visible:i,overlay:a,publishVisible:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=x(bt),u,d;t[0]!==c||t[1]!==l||t[2]!==i?(u=()=>{if(c)return l(i),()=>l(!1)},d=[c,l,i],t[0]=c,t[1]=l,t[2]=i,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;return t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=(0,$.jsx)(ht,{overlay:s,visible:i,sessionId:n,directory:r}),t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9],f},yt=({readOnly:e=!1,active:t=!0,selectionOverride:r})=>{let a=h(),o=D(e=>e.remoteSession),s=r?.location??(a?.entry.location.hostId?a.entry.location:void 0),c=r?{...r,active:t,...s?{location:s,directory:r.directory??s.directory,sessionId:r.sessionId||(o&&i(o.location)===i(s)?o.sessionId:null)}:{}}:void 0,l=F(e=>e.currentSessionId),u=F(e=>e.currentSessionDirectory),d=F(e=>!!e.newSessionDraft?.open),f=F(e=>!!(e.newSessionDraft?.open&&e.newSessionDraft.pendingUserMessage&&(e.newSessionDraft.draftEstablishing||e.newSessionDraft.draftSubmitting))),p=B(),m=x(e=>e.isMobile),g=x(e=>e.isExpandedInput),_=n(),v=x(e=>e.workStatusPanelEnabled),y=x(e=>e.workStatusOverlayOpen),b=x(e=>e.setWorkStatusPanelFits),S=s&&o&&i(o.location)===i(s)?o:null,C=s?c?.sessionId??S?.sessionId??null:r?.sessionId??l,w=C,E=s?s.directory:r?.directory??u??p??null,{visible:O,fits:k,layoutAllows:A}=he({isMobile:m,isVSCode:_,directory:s?i(s):E}),j=s?!!C:r?!!r.sessionId:d?f:!!C,M=t&&!m&&!_&&!g&&j,N=M&&O,P=M&&v&&!k&&y;return Q.useEffect(()=>(b(M&&k),()=>b(!1)),[k,M,b]),(0,$.jsxs)(`div`,{className:T(`relative h-full min-h-0 min-w-0`,N&&`yuri-chat-work-status-inline`),style:N?{"--yuri-work-status-reserve":`210px`}:void 0,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 min-h-0 min-w-0`,children:(0,$.jsx)(pe,{sessionId:w||void 0,children:(0,$.jsx)(se,{readOnly:e,active:t,explicitSession:c})})}),M&&A?(0,$.jsx)(vt,{publishVisible:!0,visible:N,sessionId:C,directory:E}):null,M&&v&&!k?(0,$.jsx)(vt,{overlay:!0,visible:P,sessionId:C,directory:E}):null]})};function bt(e){return e.setWorkStatusPanelVisible}export{_t as n,yt as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-BrUwQjka.js","assets/rolldown-runtime-hePW80VL.js","assets/platform-CiUKDeXd.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/runtime-file-resource-Bc_ss-sW.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/yuriEvents-BFrD5fMU.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-C3ewjGgP.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/vendor-markstream-react-BqCCtUAV.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/session-startup-barrier-BfAFvTz_.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/ui-BBJAK87V.js","assets/gitApiHttp-Dd-FwgCq.js","assets/client-B_907PBv.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-B5DHrw6U.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/remoteProjectQueries-C8382jM8.js","assets/i18n-ByGlB3HF.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-CHWK-CqR.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-BSJBQTMi.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-CpJZ4Rqs.js","assets/vendor-framer-motion-D5NyyC73.js","assets/tooltip-ccmDDb27.js","assets/useThemeSystem-BIXghnHj.js","assets/useEffectiveDirectory-BjJFgVDo.js","assets/LoadingImage-CJQhmN6k.js","assets/ImageLoadingPlaceholder-CepamQfa.js","assets/image-loading-DA9JEHD8.css","assets/markdownHeightCache-RG3lV4ki.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-BR4C9TuS.js","assets/FadeInOnReveal-CsCYrMAl.js","assets/useStreamingTextThrottle-n7T02P5g.js","assets/MarkdownRendererImpl-BBmjvHcO.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/inlineMessageLinks-DC78iKO5.js","assets/vendor-marked-S3gCOYp1.js","assets/markdownTheme-D84XyNiT.js","assets/vendor-pierre-diffs-B0OmIhMO.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-TmbrIHBI.js","assets/fileReferenceParser-1HHDBUum.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-CTekDqaS.js";import{ot as n,st as r}from"./vendor-base-ui-wXsskyKm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-BkccXcWz.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{o}from"./session-startup-barrier-BfAFvTz_.js";import{t as s}from"./useEffectiveDirectory-BjJFgVDo.js";import{i as c,n as l,t as u}from"./markdownHeightCache-RG3lV4ki.js";var d=i(),f=e(r(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.3.3-beta.7:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},w=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},T=`yuri:markstream-react`,E=e=>C(T,e),D=t(e=>({markstreamReactEnabled:E(),setMarkstreamReactEnabled:t=>{w(T,t),e({markstreamReactEnabled:t})}})),O=null,k=()=>(O??=a(()=>import(`./MarkstreamRendererImpl-BrUwQjka.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])).catch(e=>{throw O=null,e}),O),A=()=>{k().catch(()=>void 0)},j=null,M=()=>(j??=a(()=>import(`./MarkdownRendererImpl-BBmjvHcO.js`).then(e=>e.n),__vite__mapDeps([65,1,4,3,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,66,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,55,67,56,60,61,62,68,69,70,71,72,73,74,75,76,77,78,79,80,81,63,82,83,84,85,86,87,59])).catch(e=>{throw j=null,e}),j),N=()=>{E()?A():M().catch(()=>void 0)},P=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},F=f.createContext(!0),I=()=>f.useContext(F),L=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),R=n(),z=S(()=>M().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>k().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>M().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=D(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=I(),r=D(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(P,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!L(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!I()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{N as a,F as i,G as n,S as o,L as r,W as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{R as t,l as n,u as r}from"./platform-CiUKDeXd.js";import{a as i,i as a,r as o}from"./vendor-zustand-CTekDqaS.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,an as u,jt as d,on as f}from"./gitApiHttp-Dd-FwgCq.js";import{t as p}from"./safeStorage-DTOhKN0V.js";import{i as m,t as h}from"./vendor-pathe-vBmvQE8f.js";import{n as g}from"./vendor-react-BkccXcWz.js";import{s as _,u as v}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as y}from"./runtime-file-resource-Bc_ss-sW.js";import{o as b}from"./path-utils-jGozTg9d.js";import{r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-C3ewjGgP.js";import{o as C,s as w}from"./spacedFileMention-Ds4GtgiF.js";import{o as T,p as E}from"./session-startup-barrier-BfAFvTz_.js";import{n as D}from"./Icon-BLvjcKMe.js";import{Di as O,Ea as ee,L as k,Ma as A,Vi as j,_ as M,b as N,bi as P,f as F,ja as I,lt as L,na as te,pa as R,yt as z}from"./ui-BBJAK87V.js";import{s as ne}from"./remoteProjectQueries-C8382jM8.js";import{t as re}from"./i18n-ByGlB3HF.js";import{t as ie}from"./ScrollableOverlay-By9Xj7Dt.js";import{t as ae}from"./useDebouncedValue-BHlMPqY8.js";import{t as oe}from"./AgentAvatar-BMyOvw1S.js";import{c as se,d as ce,l as le,n as ue,r as de,t as fe}from"./fileMentionTouchSelection-i5rR1buz.js";import{a as pe,o as me,s as he}from"./fileMentionAutocompleteState-B9411b4o.js";var ge=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=w([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},_e=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),ve=(e,t)=>e.highlightedIndex===t.highlightedIndex&&_e(e.rows,t.rows),ye=(e,t)=>_e(e,t)?e:t.slice(),be=(e,t,n)=>{e&&(t.current&&ve(t.current,n)||(t.current=n,e(n)))},xe=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},B=e(c(),1),V=g(),Se=e=>e.directories.flatMap(e=>e.sessions),H=(e,t)=>({...ne(e,t.location.hostId),select:Se}),Ce=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(H(t,n));return n.sdk(),Se(r)},U=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(H(t,n).queryKey);for(let e of i?.directories??[]){let t=e.sessions.find(e=>e.id===r);if(t)return t.title||r}return r},W=(e,t,n,r={})=>({queryKey:[...e.queryScope,`composer-files`,t,n,r],staleTime:3e4,gcTime:3e4,queryFn:async({signal:i})=>{let a=await e.sdk().file.find({query:t,location:{directory:e.location.directory},limit:n,type:r.type},{signal:i});if(e.sdk(),i.throwIfAborted(),!Array.isArray(a.data))throw Error(`File search returned no data`);return a.data.map(t=>{let n=m(t.path),r=h(n);return{name:r,path:b(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),G=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},K=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,q=e=>e.startsWith(`yuri-remote-location:`)?n(e):G(e),J=(e,t)=>{let n=G(r(t,`local`).directory),i=G(e);if(!n||!i)return!1;let a=K(n),o=K(i);return o===a||o.startsWith(a.endsWith(`/`)?a:`${a}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=q(e)}catch{continue}if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>G(e)).filter(e=>J(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>G(e)).filter(e=>J(e,t)))):[],s=typeof i.selectedPath==`string`?G(i.selectedPath):null,c=s&&J(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Y=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},X=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Z=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=q((t||``).trim()),a=G((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=e=>K(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=K(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=K(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=K(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Y({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=q((t||``).trim()),a=n?G(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!J(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=q((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=q((t||``).trim()),i=G((n||``).trim());!r||!i||!J(i,r)||e(e=>{let t=e.byRoot[r],n=X(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=q((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>G((e||``).trim())).filter(e=>e&&J(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=X(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:p(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},merge:(e,t)=>({...t,byRoot:we(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),Q=()=>{let e=(0,V.c)(17),t=F(Te),n=z(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=N(r),a=F(Ee),o=F(De),s=A(Oe),c=A(ke),u=l(Ae);if(t){let r;e[2]===i?r=e[3]:(r=M(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return u??void 0};function Te(e){return e.currentSessionId}function Ee(e){return e.worktreeMetadata}function De(e){return e.newSessionDraft}function Oe(e){return e.activeProjectId}function ke(e){return e.projects}function Ae(e){return e.currentDirectory}var $=s(),je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,$.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=B.forwardRef((e,t)=>{let n=(0,V.c)(4),r=y(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,$.jsx)(Le,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,$.jsx)(Pe,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Pe=B.forwardRef((e,t)=>{let n=(0,V.c)(22),r=Q()??``,i=F(ze),a=O(Be),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=k(s),l=A(Ve),u=A(He),f;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;f=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=f}else f=n[5];let p=f,m;n[6]===p?m=n[7]:(m=e=>p?e.byRoot[p]:void 0,n[6]=p,n[7]=m);let h=Z(m),g=j(Ue),_=d(We),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?P(a,c):[],n[8]=a,n[9]=c,n[10]=e.onSessionSelect,n[11]=v):v=n[11];let y=v,b=e.currentSessionId??i,x;return n[12]!==g||n[13]!==r||n[14]!==p||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:p,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=p,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Fe=[],Ie=[],Le=B.forwardRef((e,t)=>{let n=(0,V.c)(32),{entry:r,registry:i}=e,a=v(),o;n[0]===r?o=n[1]:(o=ee(r.location.directory,void 0,r),n[0]=r,n[1]=o);let s=!!e.onAgentSelect,c;n[2]!==o||n[3]!==s?(c={...o,enabled:s},n[2]=o,n[3]=s,n[4]=c):c=n[4];let l=_(c),u;n[5]!==r||n[6]!==i?(u=H(i,r),n[5]=r,n[6]=i,n[7]=u):u=n[7];let d=!!e.onSessionSelect,f;n[8]!==u||n[9]!==d?(f={...u,enabled:d},n[8]=u,n[9]=d,n[10]=f):f=n[10];let p=_(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Z(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(W(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let y=x(g),b=r.location.directory,S;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],S=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=S}else S=n[17];let C=l.data??Ie,w=p.data??Fe,T=l.error??p.error,E;n[19]===r?E=n[20]:(E=()=>{r.sdk()},n[19]=r,n[20]=E);let D;return n[21]!==r.location.directory||n[22]!==h||n[23]!==e||n[24]!==t||n[25]!==y||n[26]!==C||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==S?(D=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:b,projectRoot:S,projectTabs:h,agentCatalog:C,sessions:w,searchFiles:y,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=y,n[26]=C,n[27]=w,n[28]=T,n[29]=E,n[30]=S,n[31]=D):D=n[31],D}),Re=B.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:d,projectTabs:p,agentCatalog:m,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=re(),w=ae(e,180),O=f(),ee=u(),[k,A]=B.useState([]),[j,M]=B.useState(!1),[N,P]=B.useState(null),[F,I]=B.useState(0),L=B.useRef(0),z=B.useRef({query:e,directory:c,ids:[]}),[ne,ce]=B.useState(360),[le,ge]=B.useState({}),[_e,ve]=B.useState({}),ye=B.useRef([]),V=B.useRef([]),Se=B.useRef([]),H=B.useRef(null),Ce=B.useRef(null),U=B.useRef(null);U.current||=fe();let W=S(e=>e.isMobile),G=(e??``).trim(),K=R({directory:c||null}),q=B.useMemo(()=>r?K.data??[]:[],[r,K.data]),J=B.useMemo(()=>{if(!d||!p)return[];let e=[p.selectedPath,...p.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${d}/`)?e.slice(d.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return he(n,G,{limit:6})},[G,d,p]),we=B.useMemo(()=>n?te(m).filter(e=>e.mode!==`primary`):[],[m,n]),Y=B.useMemo(()=>i?pe({sessions:h,currentSessionId:l??null,searchQuery:G}):[],[h,l,G,i]),X=J,Z=k,Q=B.useMemo(()=>se({skills:q,agents:we,sessions:Y,recentFiles:X,pathHits:Z,searchQuery:G,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[q,we,Y,X,Z,G,b]);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!H.current||H.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),B.useEffect(()=>{if(!c){A([]),M(!1),P(null);return}let e=(w??``).trim(),t=C(e);if(!t){A([]),M(!1),P(null);return}let n=!1;M(!0),P(null);let r={includeHidden:O,respectGitignore:!ee};return Promise.all([g(c,t,80,{...r,type:`file`}),g(c,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(J.map(e=>e.path));A(me({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||P(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||M(!1)}),()=>{n=!0}},[c,w,J,g,O,ee]),B.useLayoutEffect(()=>{let t=z.current,n=t.ids[L.current],r=t.query===e&&t.directory===c?Math.max(0,Q.findIndex(e=>e.id===n)):0;z.current={query:e,directory:c,ids:Q.map(e=>e.id)},L.current=r,I(r)},[Q,e,c]),B.useEffect(()=>{ge({}),ve({})},[Q]),B.useEffect(()=>{ye.current[F]?.scrollIntoView({block:`nearest`})},[F]),B.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};V.current.forEach((n,r)=>{if(!n)return;let i=Se.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),ge(e),ve(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Q]),B.useEffect(()=>{let e=V.current[F];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&ce(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[F]);let Te=x(e=>{t(e)}),Ee=x(e=>{n?.(e)}),De=x(e=>{i?.(e)}),Oe=x(e=>{r?.(e)}),ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&U.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&U.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(U.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>U.current?.pointerCancel(),onClick:()=>{U.current?.click(t)},onMouseMove:()=>{L.current=e,I(e)}}),Ae=e=>{try{v?.()}catch(e){P(e instanceof Error?e:Error(String(e)));return}let t=Q.length;if(t===0)return;let n=(e%t+t)%t,r=Q[n];if(r.agentName!==void 0){Ee(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=q.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Oe(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&De(e);return}let i=r.id.startsWith(`recent:`)?X.find(e=>r.id===`recent:${e.path}`):Z.find(e=>r.id===`file:${e.path}`);i&&Te(i)};B.useEffect(()=>{be(s,Ce,{rows:Q,highlightedIndex:F})},[s,F,Q]);let je=B.useRef(s);return je.current=s,B.useEffect(()=>()=>{xe(je.current,Ce)},[]),B.useImperativeHandle(y,()=>({acceptIndex:e=>{Ae(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=Q.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,I(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,I(L.current);return}(e===`Enter`||e===`Tab`)&&Ae(L.current)}}})),(0,$.jsxs)(ue,{ref:H,isMobile:W,className:`max-w-[640px] max-h-64`,style:o,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsxs)(`div`,{className:`py-1`,children:[_||K.error||N?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??K.error??N)?.message}):null,Q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?E(e.title,{maxLength:60}):e.title,i=F===t,a=le[t]??!1,o=_e[t]??2.6;return(0,$.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{ye.current[t]=e},className:T(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,W&&`min-h-11`,de(W,i),!W&&i&&`text-interactive-selection-foreground`),...ke(t,()=>Ae(t)),children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,$.jsx)(D,{name:e.iconName,className:`size-3.5 text-current`}):(0,$.jsx)(oe,{name:e.agentName,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{ref:e=>{V.current[t]=e},className:T(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${ne}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,$.jsx)(`span`,{ref:e=>{Se.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,$.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,G)}):(0,$.jsx)(`span`,{className:`block truncate`,children:Me(r,G)})]}),e.trailingLabel?(0,$.jsx)(`span`,{className:T(`max-w-[40%] shrink-0 truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,$.jsx)(`div`,{className:T(`truncate text-muted-foreground`,W?`typography-micro`:`typography-meta`),children:Me(e.subtitle,G)}):null]})]},e.id)}),j&&Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!j&&Q.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!W&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function ze(e){return e.currentSessionId}function Be(e){return e.activeSessions}function Ve(e){return e.activeProjectId}function He(e){return e.projects}function Ue(e){return e.agents}function We(e){return e.searchFiles}var Ge=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Ke=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Ge.has(n))},qe=(e,t)=>!e||t({name:e}),Je=` `,Ye=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Je&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Xe=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ze=T(Xe,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),Qe=T(Xe,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),$e=T(Xe,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),et=T(Xe,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),tt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),nt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},rt=B.forwardRef(({searchQuery:e,onCommandSelect:n,onClose:r,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=re(),d=S(e=>e.isMobile),f=F(e=>e.currentSessionId),p=F(e=>!!e.newSessionDraft?.open),m=F(B.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=L(f??``,m??void 0),g=B.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=B.useMemo(()=>nt(g),[g]),y=g.hasMessages,[b,x]=B.useState([]),[C,w]=B.useState(!1),E=I({directory:i}),O=B.useMemo(()=>E.data??[],[E.data]),ee=E.isFetching,[k,A]=B.useState(0),j=B.useRef(0),M=B.useRef(!1),N=B.useRef([]),P=B.useRef(null),te=B.useRef(!1),R=B.useRef(null),z=B.useRef(!1),ne=B.useRef(null);B.useEffect(()=>{let e=e=>{let t=e.target;!t||!P.current||P.current.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[r]),B.useEffect(()=>{(async()=>{w(ee);try{let n=O.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),r=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...n],i=!y,a=ge(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,a)?e:a)}catch{let n=!y,r=ge([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(n||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,r)?e:r)}finally{w(!1)}})()},[e,y,_,v,O,ee,u,o]),B.useEffect(()=>{A(0)},[b]),B.useEffect(()=>{j.current=k},[k]),B.useEffect(()=>{N.current[k]?.scrollIntoView({block:`nearest`})},[k]),B.useEffect(()=>{be(c,ne,{rows:le(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:k})},[b,c,k,u]);let ae=B.useRef(c);ae.current=c,B.useEffect(()=>()=>{xe(ae.current,ne)},[]),B.useImperativeHandle(l,()=>({acceptIndex:(e,t=!0)=>{let r=b[e];r&&n(r,Ke(r,t))},handleKeyDown:e=>{let t=b.length;if(e===`Escape`){r();return}if(t!==0){if(e===`ArrowDown`){M.current=!0,A(e=>(e+1)%t);return}if(e===`ArrowUp`){M.current=!0,A(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let r=(j.current%t+t)%t,i=b[r];i&&n(i,Ke(i,e===`Enter`))}}}}),[b,r,n]);let oe=e=>{let t=ce(e);switch(e.name){case`new`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,$.jsxs)(ue,{ref:P,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,$.jsx)(ie,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:C?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{children:[b.map((t,r)=>{let i=t.isBuiltIn,a=t.isYuri;return(0,$.jsxs)(`div`,{ref:e=>{N.current[r]=e},className:T(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,de(d,r===k),!d&&r===k&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(R.current={x:e.clientX,y:e.clientY},z.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!R.current)return;let t=e.clientX-R.current.x,n=e.clientY-R.current.y;Math.hypot(t,n)>6&&(z.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=z.current;R.current=null,z.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),te.current=!0,n(t,Ke(t,d)))},onPointerCancel:()=>{R.current=null,z.current=!1},onClick:()=>{if(te.current){te.current=!1;return}n(t,Ke(t,d))},onMouseMove:()=>{M.current=!1,A(r)},children:[(0,$.jsx)(`div`,{className:T(!d&&`mt-0.5`),children:oe(t)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(t.name,e)]}),t.isSkill?(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,$.jsx)(`span`,{className:et,children:`Yuri`}):i?(0,$.jsx)(`span`,{className:et,children:u(`chat.commandAutocomplete.badge.system`)}):t.scope?(0,$.jsx)(`span`,{className:t.scope===`project`?$e:Qe,children:t.scope}):null,t.agent&&(0,$.jsx)(`span`,{className:et,children:t.agent})]}),t.description&&!d&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(t.description,e)})]})]},t.id)}),b.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});rt.displayName=`CommandAutocomplete`;var it=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},at=(e,t,n)=>{let r=it(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ot=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=at(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},st=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},ct=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{rt as a,Ne as c,Ce as d,U as f,at as i,Q as l,st as n,Ye as o,ye as p,ot as r,qe as s,ct as t,Z as u};