@yuriai/web 0.3.6-beta.11 → 0.3.6-beta.13

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 (183) hide show
  1. package/README.md +19 -3
  2. package/bin/install-portable.sh +102 -0
  3. package/bin/install-portable.test.js +112 -0
  4. package/bin/lib/DOCUMENTATION.md +2 -0
  5. package/bin/lib/cli-startup.js +7 -2
  6. package/bin/lib/cli-startup.portable.test.js +30 -0
  7. package/bin/lib/commands-serve.js +4 -1
  8. package/bin/lib/commands-update.js +3 -0
  9. package/bin/lib/commands-update.test.js +18 -0
  10. package/dist/assets/{AgentAvatar-Ce3xIokt.js → AgentAvatar-CEr1CtLO.js} +1 -1
  11. package/dist/assets/{AgentSelector-CMGO3rt5.js → AgentSelector-B0Owr1ZK.js} +1 -1
  12. package/dist/assets/{ArchivedSessionsDialog-7SxXt_dN.js → ArchivedSessionsDialog-cbyQcG7B.js} +1 -1
  13. package/dist/assets/{AssistantConversationSurface-DN_0TqBx.js → AssistantConversationSurface-DOwN0Ip3.js} +3 -3
  14. package/dist/assets/{AssistantSessionCard-CpXxEZ9s.js → AssistantSessionCard-1CWSy8Bt.js} +2 -2
  15. package/dist/assets/{AssistantUnreadBadge-DMz3nOHJ.js → AssistantUnreadBadge-Bi7Dojgx.js} +1 -1
  16. package/dist/assets/{AssistantView-hrY8xNCO.js → AssistantView-D91RZ13W.js} +1 -1
  17. package/dist/assets/{AssistantWorkingAvatar-D8BEeeXa.js → AssistantWorkingAvatar-DgzJEVuK.js} +1 -1
  18. package/dist/assets/{AssistantsSettingsPage-6dBzudvs.js → AssistantsSettingsPage-DmwV91xW.js} +1 -1
  19. package/dist/assets/{BinaryFileFallback-Ck_aBVmU.js → BinaryFileFallback-1wT0ClU8.js} +1 -1
  20. package/dist/assets/{BtwPanel-CXo0GBAo.js → BtwPanel-FrJmmj9W.js} +1 -1
  21. package/dist/assets/{BusyDots-CWyfTnAt.js → BusyDots-DWKGX3Sn.js} +1 -1
  22. package/dist/assets/{ChatContainer-C0aZYA_a.js → ChatContainer-BJadx4zz.js} +4 -4
  23. package/dist/assets/{ChatView-tz6gA9q_.js → ChatView-Bb-K_GE2.js} +1 -1
  24. package/dist/assets/{DiagramView-CzXoWMbU.js → DiagramView-CUCcpmvd.js} +1 -1
  25. package/dist/assets/{DiffView-CC2W_84v.js → DiffView-CMWTZ175.js} +1 -1
  26. package/dist/assets/{DiffViewToggle-CI88C8kG.js → DiffViewToggle-BVpHBxQo.js} +1 -1
  27. package/dist/assets/{ErrorBoundary-DBZXhhMA.js → ErrorBoundary-74-IYvi5.js} +1 -1
  28. package/dist/assets/{FadeInOnReveal-Crw10nRn.js → FadeInOnReveal-5j0frOAV.js} +1 -1
  29. package/dist/assets/{GuiPluginMount-wQ9DWE6I.js → GuiPluginMount-CXnJtW4N.js} +1 -1
  30. package/dist/assets/{GuiPluginPage-CqHPTVP4.js → GuiPluginPage-BrRwHot0.js} +1 -1
  31. package/dist/assets/{GuiPluginSurface-sDPisFX3.js → GuiPluginSurface-BMM8XK9q.js} +1 -1
  32. package/dist/assets/{GuiPluginTitlebarItems-Dx5pTQiP.js → GuiPluginTitlebarItems-YkwCMWDl.js} +1 -1
  33. package/dist/assets/{GuiPluginWindow-BP8DRUZz.js → GuiPluginWindow-D49q7RQT.js} +1 -1
  34. package/dist/assets/{Icon-DrO1MlqW.js → Icon-BxuNTD1G.js} +1 -1
  35. package/dist/assets/{ImageLoadingPlaceholder-Brhbk0iP.js → ImageLoadingPlaceholder-wOEYYae9.js} +1 -1
  36. package/dist/assets/{LoadingImage-k1x9Kvl1.js → LoadingImage-fSoPxfqK.js} +1 -1
  37. package/dist/assets/{MarkdownRenderer-BHnonkuY.js → MarkdownRenderer-BcCmyx3J.js} +2 -2
  38. package/dist/assets/{MarkdownRendererImpl-CnPzG_rJ.js → MarkdownRendererImpl-BBxjlBBW.js} +1 -1
  39. package/dist/assets/{MarkstreamRendererImpl-CBGT2iHG.js → MarkstreamRendererImpl-asOdM6LF.js} +1 -1
  40. package/dist/assets/{MobileAssistantSettingsPage-C3BxNP1l.js → MobileAssistantSettingsPage-B3nRw-O9.js} +1 -1
  41. package/dist/assets/{MobileAssistantTab-BRkzsLvg.js → MobileAssistantTab-DTvSg17F.js} +1 -1
  42. package/dist/assets/{MobileBtwPage-BjuxFp6a.js → MobileBtwPage-CaaoPuuZ.js} +1 -1
  43. package/dist/assets/{MobileChangesSurface-B2flw1Ap.js → MobileChangesSurface-BPI4-e0L.js} +1 -1
  44. package/dist/assets/{MobileChatScreen-D9fpOOvH.js → MobileChatScreen-CWBCZ4IZ.js} +1 -1
  45. package/dist/assets/{MobileDetailNavigation-BVA0JCsG.js → MobileDetailNavigation-CXC4GjdP.js} +1 -1
  46. package/dist/assets/{MobileFilesSurface-CMBH785S.js → MobileFilesSurface-WPw1GU8X.js} +2 -2
  47. package/dist/assets/{MobileHtmlNetworkBoundary-BJj2vivL.js → MobileHtmlNetworkBoundary-CToMn0v-.js} +2 -2
  48. package/dist/assets/{MobileOverlayPanel-DPgcB7AO.js → MobileOverlayPanel-DRs4pHcd.js} +1 -1
  49. package/dist/assets/{MobileResizableSheet-D5HcC4ME.js → MobileResizableSheet-DaQdMNe9.js} +1 -1
  50. package/dist/assets/{MobileSettingsTab-B0-1WZRt.js → MobileSettingsTab-BzAKd9oe.js} +1 -1
  51. package/dist/assets/{MobileShareBridge-8X_vdmZN.js → MobileShareBridge-BU4o7zvA.js} +1 -1
  52. package/dist/assets/{MobileSurface-41iI-7Zd.js → MobileSurface-BAhIeu5y.js} +1 -1
  53. package/dist/assets/{MobileTabPageHeader-CPz8P10R.js → MobileTabPageHeader-BuGRgBJG.js} +1 -1
  54. package/dist/assets/{ModelLogo-D4aymugJ.js → ModelLogo-B4ia9c7r.js} +1 -1
  55. package/dist/assets/{ModelSelector-BUSeXkcU.js → ModelSelector-CoV0ELh9.js} +1 -1
  56. package/dist/assets/{MultiRunWindow-BbYMumwu.js → MultiRunWindow-CyGYoQ6V.js} +1 -1
  57. package/dist/assets/{OnboardingScreen-DMLpMUuF.js → OnboardingScreen-Bctdl4oS.js} +1 -1
  58. package/dist/assets/{OverlayScrollbar-B0O9-JfD.js → OverlayScrollbar-BbUv42hT.js} +1 -1
  59. package/dist/assets/{PierreDiffViewer-DFDVqbNq.js → PierreDiffViewer-0bSxnzcB.js} +1 -1
  60. package/dist/assets/{ProviderLogo-CBoJS4Di.js → ProviderLogo-BhzPiC4G.js} +1 -1
  61. package/dist/assets/{RemoteAssistantSessionCard-1MEZ6Wc_.js → RemoteAssistantSessionCard-BDsAcZX4.js} +1 -1
  62. package/dist/assets/{RemoteDesktopPanel-CkwyCtui.js → RemoteDesktopPanel-yBr4UO58.js} +1 -1
  63. package/dist/assets/{ScheduledTasksDialog-Cb_as8Cv.js → ScheduledTasksDialog-1HTvbmGQ.js} +1 -1
  64. package/dist/assets/{ScrollableOverlay-Cuq3KKRE.js → ScrollableOverlay-CAdxdD7C.js} +1 -1
  65. package/dist/assets/{SettingsGroup-BE-0Ya_e.js → SettingsGroup-C1ui69yn.js} +1 -1
  66. package/dist/assets/{SettingsView-Q23asKrK.js → SettingsView-RULyRRQP.js} +2 -2
  67. package/dist/assets/{SettingsWindow-C5quZoiL.js → SettingsWindow-DPPmIElK.js} +1 -1
  68. package/dist/assets/{SetupTourDialog-nJgPu0Kk.js → SetupTourDialog-D5UX8kw1.js} +1 -1
  69. package/dist/assets/{SyncActions-DddhcMDs.js → SyncActions-CtuW0cF8.js} +1 -1
  70. package/dist/assets/{TerminalView-DUwwOkqI.js → TerminalView-CvTlu81P.js} +1 -1
  71. package/dist/assets/{TextSelectionMenu-Cd9EOoKM.js → TextSelectionMenu-Cnd0PPeZ.js} +1 -1
  72. package/dist/assets/{ToolOutputDialog-DjekF5-2.js → ToolOutputDialog-Bk8GsZTN.js} +1 -1
  73. package/dist/assets/{YuriLogo-CnV3RxpE.js → YuriLogo-Cexwa29m.js} +1 -1
  74. package/dist/assets/{assistantMessagePreview-CR3sWqIa.js → assistantMessagePreview-DsmKo-Rd.js} +1 -1
  75. package/dist/assets/{assistantQueries-wJSqumUZ.js → assistantQueries-DFR7-2m4.js} +1 -1
  76. package/dist/assets/{auto-read-context-0SET_04C.js → auto-read-context-CFc8sopy.js} +1 -1
  77. package/dist/assets/{capgoAdapter-DgVdXFZa.js → capgoAdapter-CrrR1sb7.js} +1 -1
  78. package/dist/assets/{card-Br81AS-C.js → card-Bjer7G59.js} +1 -1
  79. package/dist/assets/{chatUpwardIntent-D8gCJWE9.js → chatUpwardIntent-ZOlImhuf.js} +1 -1
  80. package/dist/assets/{checkbox-Cs7zimcx.js → checkbox-BnafV7fE.js} +1 -1
  81. package/dist/assets/{collapsible-BqnGY5G1.js → collapsible-J-qWuNzr.js} +1 -1
  82. package/dist/assets/{connection-hint--2YSFO6b.js → connection-hint-CVsiZdCj.js} +1 -1
  83. package/dist/assets/{context-menu-C6YvSFUQ.js → context-menu-0Bkpdmag.js} +1 -1
  84. package/dist/assets/{diagram-IShCLLT-.js → diagram-Clzpe5jY.js} +1 -1
  85. package/dist/assets/{dialog-C67GCo29.js → dialog-BhhUro-8.js} +1 -1
  86. package/dist/assets/{dropdown-menu-B6hbejyF.js → dropdown-menu-low64f9u.js} +1 -1
  87. package/dist/assets/{es-BelVk9R_.js → es-Bg0nG0fE.js} +2 -2
  88. package/dist/assets/{fileMentionTouchSelection-SC-2eaMJ.js → fileMentionTouchSelection-B48eLkS9.js} +1 -1
  89. package/dist/assets/{fr-DtUzwB6h.js → fr-D7KYfgtA.js} +2 -2
  90. package/dist/assets/{gitApi-BZ4ZoWbQ.js → gitApi-uOSHjWy6.js} +1 -1
  91. package/dist/assets/{i18n-BU8XOKjS.js → i18n-WsU03nwB.js} +1 -1
  92. package/dist/assets/{icons-YECUJPe2.js → icons-BjHPg9QC.js} +1 -1
  93. package/dist/assets/{input-B2oH-nQc.js → input-Bn5-lrjt.js} +1 -1
  94. package/dist/assets/{insertionBoundaries-B2RO01sd.js → insertionBoundaries-B--nM0ah.js} +1 -1
  95. package/dist/assets/{ja-CWta3CAu.js → ja-6g8rtjOl.js} +2 -2
  96. package/dist/assets/{kbd-B7_YRVny.js → kbd-BiidNm-N.js} +1 -1
  97. package/dist/assets/{ko-CJFoAZPE.js → ko-Cmx7IPM8.js} +2 -2
  98. package/dist/assets/{main-DCJxCPr0.js → main-4G_VHm4a.js} +2 -2
  99. package/dist/assets/{main-DM5FeSEG.js → main-D0KOHcSW.js} +4 -4
  100. package/dist/assets/{markdownHeightCache-BO7vbFmt.js → markdownHeightCache-CfBcQ5c-.js} +1 -1
  101. package/dist/assets/{mcpQueries-CojZBAVK.js → mcpQueries-BDdMur9_.js} +1 -1
  102. package/dist/assets/miniChat-SErezL-O.js +2 -0
  103. package/dist/assets/{mobile-IXaFJ00O.js → mobile-IIghKCW_.js} +2 -2
  104. package/dist/assets/{mobileBackNavigation-CJq7EFq0.js → mobileBackNavigation-CihY-ZWs.js} +1 -1
  105. package/dist/assets/{mobileConnections--cUobzs-.js → mobileConnections-C6FuJ0fM.js} +2 -2
  106. package/dist/assets/{multirun-CphZu9f5.js → multirun-D3ah7H0A.js} +1 -1
  107. package/dist/assets/{native-config-Bes4FTeA.js → native-config-6EqKnDU2.js} +1 -1
  108. package/dist/assets/{nativeComposerCover-C6VDH0H0.js → nativeComposerCover-F38clCeD.js} +1 -1
  109. package/dist/assets/{navigation-DRRQnuzD.js → navigation-BFoRE4u8.js} +1 -1
  110. package/dist/assets/{openRemoteProjectSession-B4_B76XM.js → openRemoteProjectSession-FtIejPwF.js} +1 -1
  111. package/dist/assets/{openSessionFromDeepLink-DnoNsjzY.js → openSessionFromDeepLink-DMS6SIo7.js} +2 -2
  112. package/dist/assets/{pl-BwZ6CWJm.js → pl-TBhIGAPK.js} +2 -2
  113. package/dist/assets/{pluginPresentation-DxjMvNYM.js → pluginPresentation-BnpV06pV.js} +1 -1
  114. package/dist/assets/{pt-BR-DPAcgEDe.js → pt-BR-R4yjA2X6.js} +2 -2
  115. package/dist/assets/pwa-BsyIaDZ4.js +2 -0
  116. package/dist/assets/{queue-abort-optimistic-BX5gCxYj.js → queue-abort-optimistic-BrAat9L-.js} +1 -1
  117. package/dist/assets/{quota-BEyQ6n-w.js → quota-C7uYEfoX.js} +1 -1
  118. package/dist/assets/{reference-history-DV-P9xV1.js → reference-history-B5vQfNKz.js} +1 -1
  119. package/dist/assets/{remoteSessionReference-C2q6a218.js → remoteSessionReference-d8IANkUB.js} +1 -1
  120. package/dist/assets/{renderElectronMiniChatApp-CdLIP8ke.js → renderElectronMiniChatApp-DZV4b3Rq.js} +2 -2
  121. package/dist/assets/{renderMobileApp-YszxdkcG.js → renderMobileApp-C6zKgF6w.js} +4 -4
  122. package/dist/assets/{runtimeConfig-CMNPCJna.js → runtimeConfig-DILpDGx-.js} +1 -1
  123. package/dist/assets/runtimeEndpointReset-r655-D3H.js +4 -0
  124. package/dist/assets/{select-DU75Zpg-.js → select-CETtrHQE.js} +1 -1
  125. package/dist/assets/{sessionLookup-D-QJrAW9.js → sessionLookup-D0gUdT8J.js} +1 -1
  126. package/dist/assets/{sessionOwnership-WB9z_776.js → sessionOwnership-nyTiak2m.js} +1 -1
  127. package/dist/assets/{shortcuts-CDljO5Z0.js → shortcuts-DFgnwGd5.js} +1 -1
  128. package/dist/assets/{sortable-tabs-strip-D_QG6WdD.js → sortable-tabs-strip-D6tQk6nW.js} +1 -1
  129. package/dist/assets/{speechSettingsQueries-Ccs4XLfn.js → speechSettingsQueries-B8UP0Kkn.js} +1 -1
  130. package/dist/assets/src-BacdFOCS.css +2 -0
  131. package/dist/assets/{store-DWS9gJPW.js → store-BDr-X6Ry.js} +4 -4
  132. package/dist/assets/{switch-CYejZ7B8.js → switch-B8h1KUmC.js} +1 -1
  133. package/dist/assets/{textarea-D-k4tYDG.js → textarea-f9PtvCNG.js} +1 -1
  134. package/dist/assets/{timeFormat-CUbYRR40.js → timeFormat-D1hdmWbu.js} +1 -1
  135. package/dist/assets/{tooltip-DxtaOQnv.js → tooltip-BQKvkayK.js} +1 -1
  136. package/dist/assets/{truncated-path-DDDJbtPi.js → truncated-path-DUsIWNhL.js} +1 -1
  137. package/dist/assets/{types-BXjMc92F.js → types-B0G9z6G6.js} +1 -1
  138. package/dist/assets/{ui-DLZtbTLJ.js → ui-CBjYsEHe.js} +6 -6
  139. package/dist/assets/{uk-Dw75NtHH.js → uk-stP6moLG.js} +2 -2
  140. package/dist/assets/{useAppFontEffects-DpMTXkXR.js → useAppFontEffects-BQLHroVK.js} +2 -2
  141. package/dist/assets/{useDesktopWindowControlsLayout-3qd6LXL-.js → useDesktopWindowControlsLayout-BiQv3xA1.js} +1 -1
  142. package/dist/assets/{useDictation-CUADIj-o.js → useDictation-DUR68U4T.js} +1 -1
  143. package/dist/assets/{useEffectiveDirectory-CXt-KLYT.js → useEffectiveDirectory-DynS0IQR.js} +1 -1
  144. package/dist/assets/{useGitStore-CAj3309H.js → useGitStore-CHE0pTk_.js} +1 -1
  145. package/dist/assets/{useInlineCommentDraftStore-DEzJN8u2.js → useInlineCommentDraftStore-CvpvoffS.js} +1 -1
  146. package/dist/assets/{useMcpConfigStore-CCsT0TQj.js → useMcpConfigStore-CGenk3_j.js} +1 -1
  147. package/dist/assets/{useMobileSwipeActions-BnJa2tLR.js → useMobileSwipeActions-BYD4Qa5k.js} +1 -1
  148. package/dist/assets/{useMobileTranscriptSyncHint-DwBUhnBr.js → useMobileTranscriptSyncHint-CDAa-k2e.js} +1 -1
  149. package/dist/assets/{useModelLists-Bd8KjZ16.js → useModelLists-85Cks36l.js} +1 -1
  150. package/dist/assets/{useOpenCodeReadiness-BodiUrhs.js → useOpenCodeReadiness-BvD_kM-L.js} +1 -1
  151. package/dist/assets/{usePluginsStore-BLP01bCp.js → usePluginsStore-DEIJXUJp.js} +1 -1
  152. package/dist/assets/{useProjectGitActions-iY0OP_M-.js → useProjectGitActions-DQvIHmjR.js} +1 -1
  153. package/dist/assets/{useProjectGitStore-aVtBQPmn.js → useProjectGitStore-BZLEIJPC.js} +1 -1
  154. package/dist/assets/{useProjectRuntimeAPIs-ACsFy7es.js → useProjectRuntimeAPIs-Ct3aOMyH.js} +1 -1
  155. package/dist/assets/{useQuotaStore-CZU1NU_Z.js → useQuotaStore-BqPJ1nzk.js} +1 -1
  156. package/dist/assets/{useSessionBtwStore-DwgrTiCi.js → useSessionBtwStore-DWvYSycl.js} +1 -1
  157. package/dist/assets/{useStreamingTextThrottle-aFrPa42L.js → useStreamingTextThrottle-B8qFhmN9.js} +1 -1
  158. package/dist/assets/{worktreeManager-B1qB2-Pa.js → worktreeManager-DcqLFxEk.js} +1 -1
  159. package/dist/assets/{worktreeSourceBranchPreference-DOyD0AQN.js → worktreeSourceBranchPreference-DyEaTtIU.js} +1 -1
  160. package/dist/assets/{zh-CN-D5Jwengx.js → zh-CN-C52Ikw5n.js} +2 -2
  161. package/dist/assets/zh-TW-nR1tyoMc.js +15 -0
  162. package/dist/index.html +6 -6
  163. package/dist/mini-chat.html +6 -6
  164. package/dist/mobile.html +2 -2
  165. package/package.json +2 -1
  166. package/server/lib/gui-customization/DOCUMENTATION.md +4 -0
  167. package/server/lib/gui-customization/remote-connections.js +1 -0
  168. package/server/lib/gui-customization/remote-connections.test.js +17 -0
  169. package/server/lib/gui-customization/session-skill.test.js +5 -0
  170. package/server/lib/gui-customization/skill/references/remote-connections.md +3 -0
  171. package/server/lib/host-update/DOCUMENTATION.md +5 -0
  172. package/server/lib/host-update/cli.js +5 -2
  173. package/server/lib/host-update/cli.test.js +15 -2
  174. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  175. package/server/lib/package-manager.js +14 -0
  176. package/server/lib/package-manager.test.js +7 -0
  177. package/server/lib/portable-installation.js +34 -0
  178. package/server/lib/portable-installation.test.js +38 -0
  179. package/dist/assets/miniChat-VubQ-eH-.js +0 -2
  180. package/dist/assets/pwa-Duem_qqG.js +0 -2
  181. package/dist/assets/runtimeEndpointReset-DUTNA8O6.js +0 -4
  182. package/dist/assets/src-Dv9gb-Yy.css +0 -2
  183. package/dist/assets/zh-TW-CbbaPcxZ.js +0 -15
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-DjekF5-2.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-CNdx57HN.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DKJJoOOc.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/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-P32bzAJc.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/runtime-file-download-wMVtKk2v.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/ui-DLZtbTLJ.js","assets/gitApiHttp-C8AU1uiY.js","assets/client-QcYZg8_d.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-D1c308Ba.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-BunVM5PM.js","assets/i18n-BU8XOKjS.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DWS9gJPW.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-PqhVEhUI.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-DEiMjSqf.js","assets/Icon-DrO1MlqW.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-C67GCo29.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-CXt-KLYT.js","assets/mobileBackNavigation-CJq7EFq0.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-Brhbk0iP.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-BHnonkuY.js","assets/markdownHeightCache-BO7vbFmt.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-B39pFDdo.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-CI88C8kG.js","assets/touch-gestures-DOoBxhz5.js","assets/TerminalView-DUwwOkqI.js","assets/terminalApi-D2ECmoAo.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/OverlayScrollbar-B0O9-JfD.js","assets/device-CtdJ8KBJ.js","assets/useProjectRuntimeAPIs-ACsFy7es.js","assets/sortable-tabs-strip-D_QG6WdD.js","assets/vendor-dnd-kit-core-qy5stxu5.js","assets/vendor-dnd-kit-accessibility-u0XSXxKq.js","assets/vendor-dnd-kit-sortable-CiTIuX4o.js","assets/useFontPreferences-BY0TXvWI.js","assets/project-preview-CIkGbBPZ.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-D84EVh3q.js","assets/DiagramView-CzXoWMbU.js","assets/diagram-IShCLLT-.js","assets/vendor-react-drawio-C9rszQEJ.js","assets/SettingsView-Q23asKrK.js","assets/desktopHosts-DFa3lf0i.js","assets/desktopRelayRestore-CGq-Ylgq.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/ScrollableOverlay-Cuq3KKRE.js","assets/tooltip-DxtaOQnv.js","assets/react-CPBNl-S9.js","assets/dropdown-menu-B6hbejyF.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/context-menu-C6YvSFUQ.js","assets/collapsible-BqnGY5G1.js","assets/textarea-D-k4tYDG.js","assets/gitApi-BZ4ZoWbQ.js","assets/GuiPluginMount-wQ9DWE6I.js","assets/MobileHtmlNetworkBoundary-BJj2vivL.js","assets/input-B2oH-nQc.js","assets/shortcuts-CDljO5Z0.js","assets/assistantQueries-wJSqumUZ.js","assets/MobileDetailNavigation-BVA0JCsG.js","assets/pwa-Duem_qqG.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/ErrorBoundary-DBZXhhMA.js","assets/card-Br81AS-C.js","assets/ProviderLogo-CBoJS4Di.js","assets/zhipuai-coding-plan-CcFj8zKy.js","assets/select-DU75Zpg-.js","assets/MobileResizableSheet-D5HcC4ME.js","assets/githubAuthQueries-IJPWBo0B.js","assets/projectMeta-vIaGFaQr.js","assets/timeFormat-CUbYRR40.js","assets/permission-rules-DoQUXKll.js","assets/useQuotaStore-CZU1NU_Z.js","assets/quota-BEyQ6n-w.js","assets/router-DXUi1sBd.js","assets/contextPanelEmbeddedChat-Dm5R_b5X.js","assets/sessionOwnership-WB9z_776.js","assets/types-BXjMc92F.js","assets/checkbox-Cs7zimcx.js","assets/mcpQueries-CojZBAVK.js","assets/usePluginsStore-BLP01bCp.js","assets/switch-CYejZ7B8.js","assets/SettingsGroup-BE-0Ya_e.js","assets/useMcpConfigStore-CCsT0TQj.js","assets/native-config-Bes4FTeA.js","assets/YuriLogo-CnV3RxpE.js","assets/MobileTabPageHeader-CPz8P10R.js","assets/MobileSurface-41iI-7Zd.js","assets/GuiPluginWindow-BP8DRUZz.js","assets/pluginPresentation-DxjMvNYM.js","assets/ModelLogo-D4aymugJ.js","assets/useDictation-CUADIj-o.js","assets/audio-session-BFWjrDbp.js","assets/browserVoiceService-x5Pci8L3.js","assets/speechSettingsQueries-Ccs4XLfn.js","assets/pluginPresentation-C0HSdVvS.css","assets/ModelSelector-BUSeXkcU.js","assets/useModelLists-Bd8KjZ16.js","assets/useOpenCodeReadiness-BodiUrhs.js","assets/AgentSelector-CMGO3rt5.js","assets/AgentAvatar-Ce3xIokt.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/AssistantsSettingsPage-6dBzudvs.js","assets/MobileShareBridge-8X_vdmZN.js","assets/mobileConnections--cUobzs-.js","assets/assistantPresentation-DRbsH1Ej.js","assets/scheduledTaskNavigation-DpfZSGu8.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/ArchivedSessionsDialog-7SxXt_dN.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/MobileOverlayPanel-DPgcB7AO.js","assets/worktreeManager-B1qB2-Pa.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-C5quZoiL.js","assets/MultiRunWindow-BbYMumwu.js","assets/multirun-CphZu9f5.js","assets/useGitStore-CAj3309H.js","assets/insertionBoundaries-B2RO01sd.js","assets/spacedFileMention-Ds4GtgiF.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useDebouncedValue-BHlMPqY8.js","assets/fileMentionTouchSelection-SC-2eaMJ.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionAutocompleteState-B9411b4o.js","assets/worktreeSourceBranchPreference-DOyD0AQN.js","assets/AssistantView-hrY8xNCO.js","assets/mobileAppContext-BQgdTp5T.js","assets/AssistantConversationSurface-DN_0TqBx.js","assets/LoadingImage-k1x9Kvl1.js","assets/chatUpwardIntent-D8gCJWE9.js","assets/reference-history-DV-P9xV1.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-vLNN8EMu.js","assets/assistant-attachment-cache-Y7yhlQcv.js","assets/AssistantWorkingAvatar-D8BEeeXa.js","assets/AssistantSessionCard-CpXxEZ9s.js","assets/sessionChangeSummary-BCF9VwAA.js","assets/sessionLookup-D-QJrAW9.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-DMz3nOHJ.js","assets/sortAssistantContacts-CcEdm3mS.js","assets/assistantMessagePreview-CR3sWqIa.js","assets/navigation-DRRQnuzD.js","assets/OnboardingScreen-DMLpMUuF.js","assets/openSessionFromDeepLink-DnoNsjzY.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,F as y,G as b,H as x,I as S,L as C,O as w,P as T,Q as E,R as D,U as O,W as k,X as A,a as j,c as M,ct as N,d as P,dt as F,f as I,g as L,it as R,k as z,l as B,lt as V,s as ee,st as te,u as ne,ut as re,z as ie}from"./platform-CNdx57HN.js";import{n as ae,t as H}from"./runtimeAPIRegistry-C2VogTny.js";import{d as U,h as oe,m as W,r as se,v as ce}from"./desktopHosts-DFa3lf0i.js";import{a as le,i as ue,t as de}from"./vendor-zustand-CTekDqaS.js";import{A as fe,B as pe,C as me,H as he,M as ge,P as _e,S as ve,V as ye,b as be,it as xe,j as Se,k as Ce,ot as we,st as Te,v as Ee,x as De,y as Oe,z as ke}from"./vendor-base-ui-wXsskyKm.js";import{Ct as Ae,Et as je,Ft as Me,Mt as Ne,Pt as Pe,St as Fe,Tt as G,an as Ie,jt as Le,on as Re,wt as ze,xt as Be}from"./gitApiHttp-C8AU1uiY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Ve,r as He,t as Ue}from"./safeStorage-DTOhKN0V.js";import{B as We,H as Ge,Jt as Ke,Rt as qe,St as Je,Xt as Ye,Zt as Xe,an as Ze,ft as Qe,ht as $e,mt as et,n as tt,on as nt,qt as rt,rn as it,tn as at,vr as ot,zt as st}from"./client-QcYZg8_d.js";import{P as ct,d as lt,z as ut}from"./prompt-attachment-upload-D1c308Ba.js";import{n as dt}from"./pathNormalization-ewtPqJWn.js";import{n as ft,t as pt}from"./vendor-react-BkccXcWz.js";import{f as mt,u as ht}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as gt,o as _t,s as vt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as yt,I as bt,O as xt,P as St,R as Ct,W as wt,c as Tt,r as Et,s as Dt,t as Ot,y as kt,z as At}from"./runtime-file-resource-DKJJoOOc.js";import{a as jt,n as Mt}from"./path-utils-jGozTg9d.js";import{h as Nt,m as Pt,r as K}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as Ft}from"./summaries-BQMyJaaw.js";import{o as It}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Lt,i as Rt,o as zt,r as q,s as Bt,t as Vt}from"./useUIStore-P32bzAJc.js";import{o as Ht}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Ut,r as Wt}from"./terminalApi-D2ECmoAo.js";import{a as Gt}from"./types-BXjMc92F.js";import{t as Kt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as qt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Jt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Yt,A as Xt,Ai as Zt,Ba as Qt,Bi as $t,Br as en,Ct as tn,Di as nn,F as rn,Fi as an,Gr as on,H as sn,Ha as cn,Hr as ln,I as un,Ji as dn,Jr as fn,Kt as pn,Mi as mn,Na as hn,Pi as gn,Pn as _n,Qr as vn,R as yn,S as bn,Si as xn,Tt as Sn,U as Cn,Ua as wn,Vr as Tn,W as En,Wr as Dn,Xr as On,Yi as kn,Yn as J,an as An,ao as jn,ar as Mn,b as Nn,br as Pn,bt as Fn,co as In,ct as Ln,dt as Rn,et as zn,f as Bn,gn as Vn,h as Hn,ht as Un,in as Wn,io as Gn,it as Kn,ji as qn,k as Jn,ki as Yn,la as Xn,li as Zn,lt as Qn,mt as $n,no as Y,o as er,oo as tr,ot as nr,p as rr,pi as ir,pt as ar,qi as or,ro as sr,si as cr,so as lr,st as ur,t as X,ta as dr,to as fr,tt as pr,un as mr,v as hr,wt as gr,x as _r,xt as vr,y as yr,yr as br,yt as xr,zi as Sr}from"./ui-DLZtbTLJ.js";import{n as Z,t as Cr}from"./Icon-DrO1MlqW.js";import{d as wr,h as Tr,m as Er,p as Dr}from"./remoteProjectQueries-BunVM5PM.js";import{a as Or,i as kr,n as Ar,r as jr,t as Mr}from"./i18n-BU8XOKjS.js";import{n as Nr}from"./store-DWS9gJPW.js";import{n as Pr}from"./input-store-PqhVEhUI.js";import{a as Fr,c as Ir,i as Lr,l as Rr,o as zr,s as Br}from"./toolHelpers-iEHVHQ9p.js";import{n as Vr}from"./useAssistantUIStore-DEiMjSqf.js";import{n as Hr,t as Ur}from"./ScrollableOverlay-Cuq3KKRE.js";import{n as Wr,o as Gr}from"./vendor-framer-motion-D5NyyC73.js";import{a as Kr,i as qr,n as Jr,o as Yr,r as Xr,t as Zr}from"./dialog-C67GCo29.js";import{i as Qr,n as $r,r as ei,t as ti}from"./tooltip-DxtaOQnv.js";import{n as ni,t as ri}from"./useInlineCommentDraftStore-DEzJN8u2.js";import{n as ii}from"./useThemeSystem-BIXghnHj.js";import{a as ai,i as oi,n as si,r as ci,t as li}from"./useProjectGitActions-iY0OP_M-.js";import{a as ui,r as di}from"./device-CtdJ8KBJ.js";import{t as fi}from"./SyncActions-DddhcMDs.js";import{i as pi,n as mi,r as hi,t as gi}from"./dropdown-menu.styles-BDla58Rm.js";import{c as _i,i as vi,n as yi,r as bi,s as xi,t as Si}from"./dropdown-menu-B6hbejyF.js";import{a as Ci,i as wi,n as Ti,r as Ei,t as Di}from"./context-menu-C6YvSFUQ.js";import{n as Oi,r as ki,t as Ai}from"./collapsible-BqnGY5G1.js";import{a as ji,i as Mi,n as Ni,o as Pi,r as Fi}from"./PierreDiffViewer-DFDVqbNq.js";import{n as Ii,t as Li}from"./kbd-B7_YRVny.js";import{t as Ri}from"./DiffWorkerProvider-VFPkag9y.js";import{n as zi,t as Bi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Vi}from"./themes-BgDJcxRc.js";import{n as Hi,t as Ui}from"./useEffectiveDirectory-CXt-KLYT.js";import{n as Wi,t as Gi}from"./useProjectRuntimeAPIs-ACsFy7es.js";import{b as Ki,h as qi,m as Ji}from"./gitApi-BZ4ZoWbQ.js";import{a as Yi,o as Xi,s as Zi}from"./useGitStore-CAj3309H.js";import{a as Qi,i as $i,n as ea,o as ta,r as na,s as ra,t as ia}from"./useProjectGitStore-aVtBQPmn.js";import{i as aa,n as oa,r as sa}from"./MobileHtmlNetworkBoundary-BJj2vivL.js";import{n as ca,t as la}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as ua,i as da,n as fa,r as pa,t as ma}from"./BinaryFileFallback-Ck_aBVmU.js";import{t as ha}from"./ImageLoadingPlaceholder-Brhbk0iP.js";import{t as ga}from"./LoadingImage-k1x9Kvl1.js";import{t as _a}from"./input-B2oH-nQc.js";import{n as va,o as ya}from"./MarkdownRenderer-BHnonkuY.js";import{c as ba,i as xa,l as Sa,n as Ca,o as wa,s as Ta}from"./shortcuts-CDljO5Z0.js";import{n as Ea,r as Da}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as Oa}from"./useSessionBtwStore-DwgrTiCi.js";import{t as ka}from"./useDebouncedValue-BHlMPqY8.js";import{m as Aa,x as ja,y as Ma}from"./assistantQueries-wJSqumUZ.js";import{A as Na,C as Pa,D as Fa,E as Ia,F as La,I as Ra,M as za,N as Ba,O as Va,P as Ha,R as Ua,S as Wa,T as Ga,_ as Ka,b as qa,c as Ja,d as Ya,f as Xa,g as Za,h as Qa,i as $a,j as eo,k as to,l as no,m as ro,n as io,p as ao,s as oo,t as so,u as co,v as lo,w as uo,x as fo,y as po,z as mo}from"./useAppFontEffects-DpMTXkXR.js";import{D as ho,E as go,J as _o,S as vo,_ as yo,b as bo,c as xo,d as So,f as Co,it as wo,m as To,u as Eo,v as Do,x as Oo,y as ko}from"./pwa-Duem_qqG.js";import{t as Ao}from"./YuriLogo-CnV3RxpE.js";import{t as jo}from"./card-Br81AS-C.js";import{t as Mo}from"./ErrorBoundary-DBZXhhMA.js";import{a as No,n as Po,o as Fo,r as Io}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{i as Lo,r as Ro}from"./connection-hint--2YSFO6b.js";import{u as zo}from"./insertionBoundaries-B2RO01sd.js";import{t as Bo}from"./ModelLogo-D4aymugJ.js";import{_ as Vo,a as Ho,c as Uo,d as Wo,f as Go,i as Ko,l as qo,n as Jo,o as Yo,p as Xo,r as Zo,s as Qo,u as $o,y as es}from"./ChatContainer-C0aZYA_a.js";import{C as ts,i as ns,n as rs,r as is}from"./BtwPanel-CXo0GBAo.js";import{A as as,D as os,E as ss,M as cs,O as ls,P as us,T as ds,X as fs,j as ps,k as ms}from"./BusyDots-CWyfTnAt.js";import{_ as hs,i as gs,l as _s,n as vs,s as ys,t as bs,v as xs}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as Ss,n as Cs,s as ws,t as Ts}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Es}from"./MobileOverlayPanel-DPgcB7AO.js";import{t as Ds}from"./ProviderLogo-CBoJS4Di.js";import{d as Os}from"./ToolOutputDialog-DjekF5-2.js";import{t as ks}from"./vendor-motion-vLNN8EMu.js";import{c as As,i as js,n as Ms,s as Ns,t as Ps}from"./select-DU75Zpg-.js";import{a as Fs}from"./githubAuthQueries-IJPWBo0B.js";import{c as Is,i as Ls,n as Rs,s as zs}from"./worktreeManager-B1qB2-Pa.js";import{t as Bs}from"./sortable-tabs-strip-D_QG6WdD.js";import{i as Vs}from"./auto-read-context-0SET_04C.js";import{n as Hs,t as Us}from"./timeFormat-CUbYRR40.js";import{a as Ws,c as Gs,i as Ks,n as qs,o as Js,r as Ys,u as Xs}from"./useQuotaStore-CZU1NU_Z.js";import{a as Zs,i as Qs,n as $s,s as ec,t as tc}from"./quota-BEyQ6n-w.js";import{i as nc,n as rc,r as ic,t as ac}from"./useDesktopWindowControlsLayout-3qd6LXL-.js";import{n as oc,t as sc}from"./sessionChangeSummary-BCF9VwAA.js";import{n as cc,t as lc}from"./openRemoteProjectSession-B4_B76XM.js";import{n as uc}from"./useFontPreferences-BY0TXvWI.js";import{$ as dc,A as fc,At as pc,B as mc,Bt as hc,Ct as gc,D as _c,Dt as vc,E as yc,F as bc,Ft as xc,G as Sc,H as Cc,Ht as wc,I as Tc,It as Ec,J as Dc,K as Oc,L as kc,Lt as Ac,M as jc,Mt as Mc,N as Nc,Nt as Pc,O as Fc,Ot as Ic,P as Lc,Pt as Rc,Q as zc,R as Bc,Rt as Vc,S as Hc,St as Uc,U as Wc,Vt as Gc,W as Kc,Y as qc,Z as Jc,a as Yc,at as Xc,b as Zc,bt as Qc,et as $c,g as el,i as tl,it as nl,j as rl,jt as il,k as al,kt as ol,n as sl,nt as cl,o as ll,ot as ul,q as dl,r as fl,rt as pl,s as ml,tt as hl,v as gl,vt as _l,w as vl,x as yl,xt as bl,y as xl,yt as Sl,z as Cl,zt as wl}from"./runtimeEndpointReset-DUTNA8O6.js";import{t as Tl}from"./YuriWordmark-Bn5KdqMC.js";import{_ as El,d as Dl,g as Ol,h as kl,m as Al,p as jl,r as Ml,t as Nl,v as Pl,y as Fl}from"./sessionOwnership-WB9z_776.js";import{i as Il,n as Ll}from"./icons-YECUJPe2.js";import{r as Rl,t as zl}from"./navigation-DRRQnuzD.js";import{t as Bl}from"./AssistantUnreadBadge-DMz3nOHJ.js";import{n as Vl,t as Hl}from"./GuiPluginPage-CqHPTVP4.js";import{d as Ul,i as Wl,n as Gl,r as Kl,u as ql}from"./historyImportQueries-B3QBdaKo.js";import{n as Jl}from"./ScheduledTasksDialog-Cb_as8Cv.js";import{t as Yl}from"./ChatView-tz6gA9q_.js";import{t as Xl}from"./diagram-IShCLLT-.js";import{t as Zl}from"./DiffView-CC2W_84v.js";import{a as Ql,i as $l,n as eu,o as tu,r as nu,t as ru}from"./multirun-CphZu9f5.js";import{_ as iu,a as au,c as ou,d as su,f as cu,g as lu,h as uu,i as du,l as fu,m as pu,o as mu,p as hu,r as gu,s as _u,t as vu,u as yu}from"./ArchivedSessionsDialog-7SxXt_dN.js";import{a as bu,i as xu,n as Su,r as Cu,t as wu}from"./projectActions-D84EVh3q.js";import{t as Tu}from"./GuiPluginTitlebarItems-Dx5pTQiP.js";import{t as Eu}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Du,t as Ou}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(Te(),1),ku=pt(),Au=ft(),$=we();function ju(e){let t=(0,Au.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var Mu=!1,Nu=0,Pu=new Set,Fu=async()=>{let e=++Nu;try{let t=await v(`desktop_is_window_fullscreen`);if(e!==Nu||t===Mu)return;Mu=t===!0,Pu.forEach(e=>e())}catch{}},Iu=e=>y()?(Pu.add(e),Pu.size===1&&(window.addEventListener(`yuri:window-resized`,Fu),Fu()),()=>{Pu.delete(e),Pu.size===0&&(window.removeEventListener(`yuri:window-resized`,Fu),Nu++,Mu=!1)}):()=>{};function Lu(){return(0,Q.useSyncExternalStore)(Iu,zu,Ru)}function Ru(){return!1}function zu(){return Mu}function Bu(){let e=(0,Au.c)(19),{t}=Mr(),n=q(Gu),r=q(Wu),i=q(Uu),a=q(Hu),o=q(Vu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=Y(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Vu(e){return e.setWorkStatusOverlayOpen}function Hu(e){return e.setWorkStatusPanelEnabled}function Uu(e){return e.workStatusOverlayOpen}function Wu(e){return e.workStatusPanelFits}function Gu(e){return e.workStatusPanelEnabled}var Ku=(e,t,n)=>_t({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await se(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await _o();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>W(e,i)||t===`host:${e.id}`||!!(n&&oe(n,U(e)))),sshIds:i}}});function qu(e){let t=(0,Au.c)(18),{onClick:n,open:r}=e,{t:i}=Mr(),a=Q.useSyncExternalStore(c,u,u),o=q(Ju),s=p(),l=h(),d=T(),{data:f}=vt({...Ku(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&oe(l,U(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?ce(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=La({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ti,b=Qr,x=J,S=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),C;t[0]===v?C=t[1]:(C=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=w):w=t[2];let E;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==S||t[7]!==C?(E=(0,$.jsxs)(x,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":S,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[C,w]}),t[3]=x,t[4]=n,t[5]=r,t[6]=S,t[7]=C,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)($r,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function Ju(e){return e.isSettingsDialogOpen}var Yu=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Xu=`finder`,Zu=new Set([`finder`,`terminal`]),Qu=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,$u=e=>{if(!e)return null;let t=Yu.find(t=>t.id===e)??null;return t?Qu(t):null},ed=()=>Yu.filter(e=>Zu.has(e.id)).map(e=>({...Qu(e)})),td=e=>{let t=new Map(e.map(e=>[e.name,e]));return Yu.filter(e=>t.has(e.appName)||Zu.has(e.id)).map(e=>{let n=t.get(e.appName);return{...Qu(e),...e.id===`terminal`&&n?.appName&&n.label?{appName:n.appName,label:n.label}:{},iconDataUrl:n?.iconDataUrl??void 0}})},nd=()=>{if(typeof window>`u`)return Xu;let e=window.localStorage.getItem(`openInAppId`);return e&&$u(e)?e:Xu},rd=!1,id=!1,ad=!1,od=0,sd=null,cd=()=>{sd&&=(clearTimeout(sd),null)},ld=le()((e,t)=>({selectedAppId:nd(),availableApps:ed(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(rd||typeof window>`u`)return;rd=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:ed(),hasLoadedApps:n});return}e({availableApps:td(t),hasLoadedApps:!0})},r=async i=>{if(!y()||id||t().hasLoadedApps&&!i)return;let a=Yu.map(e=>e.appName);cd(),i&&e({hasLoadedApps:!1}),id=!0,ad=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await L(a,i),l=o&&!s&&t.length===0&&od<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][od]??3200;od+=1,ad=!0,sd=setTimeout(()=>{r()},e);return}od=0,ad=!1;return}if(od<3){let e=[1e3,3e3,7e3][od]??7e3;od+=1,ad=!0,sd=setTimeout(()=>{r()},e)}}finally{id=!1,ad||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&$u(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(od=3,ad=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(rd||t().initialize(),!y()||id||t().hasLoadedApps&&!n)return;let r=Yu.map(e=>e.appName);cd(),n&&e({hasLoadedApps:!1}),id=!0,ad=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await L(r,n),o=td(t);e({availableApps:o.length>0?o:ed(),hasLoadedApps:o.length>0,isCacheStale:i?a:!1})}finally{id=!1,ad||e({isScanning:!1})}},selectApp:async t=>{$u(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Me({openInAppId:t}))}})),ud=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:y()&&z()&&n!==null,queryFn:async({signal:e})=>{let t=await v(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},dd=()=>{let e=(0,Au.c)(3),t=(0,Q.useSyncExternalStore)(c,p,fd),n=(0,Q.useSyncExternalStore)(c,u,pd),r;return e[0]!==t||e[1]!==n?(r=ud(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],vt(r)};function fd(){return``}function pd(){return``}var md=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,hd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,gd=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?md:e.id===`terminal`&&e.label===`Terminal`?hd:void 0}),_d=e=>{let t=(0,Au.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},vd=({directory:e,className:t})=>{let{t:n}=Mr(),r=ld(e=>e.selectedAppId),i=ld(e=>e.availableApps),a=ld(e=>e.isCacheStale),o=ld(e=>e.isScanning),s=ld(e=>e.initialize),c=ld(e=>e.loadInstalledApps),l=ld(e=>e.selectApp),{data:u}=dd(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=y()&&T(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?gd(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await b(e,t.id,t.appName,u?.hostId);!r&&!u?await k(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await fr(e)};return(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:Y(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(_d,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(yi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(xi,{}),d.map(e=>{let t=gd(e);return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(_d,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},yd=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],bd=[`dev`,`start`,`preview`,`serve`];async function xd(e,t,n,r){if(!e)return null;let i=wd(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Td(n);if(t){let n=await Ed(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await Sd(e,r)){let e=await Cd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function Sd(e,t){let n=await Dd(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function Cd(e){if(e){let t=await bt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function wd(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(bd.some(t=>e.includes(t)))return t}return null}function Td(e){for(let{pattern:t}of yd)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Ed(e,t){let n=await Dd(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Dd(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Dd(e,t,n){if(n){let r=bt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=H()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function Od(e,t){try{let n=await Dd(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var kd=e=>new Promise(t=>{window.setTimeout(t,e)}),Ad=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),jd=/https?:\/\/[^\s<>'"`]+/gi,Md=`__yuri_auto_discover_preview__`,Nd=15e3,Pd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Fd=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Id=e=>{let t=e.replace(Ad,``).match(jd);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Ld=e=>{let t=(0,Au.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Er(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):zd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(Rd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},Rd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Mr(),{terminal:s,runtime:c}=Ct(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&bt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Wt(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=di(),h=Q.useMemo(()=>y(),[]),g=_u(e=>e.instances),_=_u(e=>e.load),v=q(e=>e.setBottomTerminalOpen),b=q(e=>e.setActiveMainTab),x=q(e=>e.setSettingsPage),S=q(e=>e.setSettingsDialogOpen),C=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=uc(e=>e.sessions),E=uc(e=>e.ensureDirectory),D=uc(e=>e.setTabLabel),O=uc(e=>e.setTabIconKey),k=uc(e=>e.setActiveTab),A=uc(e=>e.setConnecting),j=uc(e=>e.setTabSessionId),M=uc(e=>e.setTabPreviewUrl),N=uc(e=>e.projectActionRuns),P=uc(e=>e.setProjectActionRun),F=uc(e=>e.updateProjectActionRunStatus),I=uc(e=>e.removeProjectActionRun),[L,R]=Q.useState([]),[z,V]=Q.useState(null),[te,ne]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),H=Q.useRef({}),U=Q.useRef(0),oe=Q.useRef(new Set),W=e?.id??null,se=e?.path??``,ce=Q.useMemo(()=>W?{id:W,path:se,hostId:e?.hostId,hubId:e?.hubId}:null,[W,se,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=H.current;return()=>{u.current=!1,U.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Ht(e)}),ue=K(async()=>{if(!ce)return;let e=U.current+1;U.current=e,ne(!0);try{d();let t=await Yt(ce,a);if(U.current!==e)return;let n=t.actions;R(n),V(e=>e===Md||e&&n.some(t=>t.id===e)?e:null)}catch{if(U.current!==e)return}finally{U.current===e&&ne(!1)}}),de=t||ce?.path||``,fe=Q.useMemo(()=>a?B(ee({...a.location,directory:de})):ce?.hostId?ce.hubId?B(ee({hubId:ce.hubId,hostId:ce.hostId,directory:de})):``:Cu(de),[de,ce,a]),pe=Q.useMemo(()=>z?L.find(e=>e.id===z)??null:null,[L,z]),me=Q.useMemo(()=>({id:Md,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...L]:L,[L,me,he]);Q.useEffect(()=>{ue()},[ue,ce,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;W&&(t?.projectId&&t.projectId!==W||ue())};return window.addEventListener(wu,e),()=>{window.removeEventListener(wu,e)}},[ue,W]),Q.useEffect(()=>{z&&(z===Md&&he||L.some(e=>e.id===z)||V(null))},[L,he,z]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[fe,N,I,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Id(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(H.current[e]),delete H.current[e],w(t.directory,u))}else a||ce?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),X.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(H.current[e]),delete H.current[e])},[fe,a,ce?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=bu(fe,e.id);E(fe);let r=uc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),v(!0),b(`terminal`));let c=uc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){X.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=bu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!oe.current.has(t)){oe.current.add(t);try{d();let t=e.id===Md?await(async()=>{let[e,t]=await Promise.all([Yt({...ce,id:ce?.id??``,path:de},a),Od(de,a)]),n=await xd(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Md,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==Md}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await kd(350),d(),t.id===Md&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Ut)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&uc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(uc.getState().setTabLifecycle(fe,i,`exited`),uc.getState().setConnecting(fe,i,!1),uc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(H.current[r]),delete H.current[r])}},()=>{u.current&&uc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Fd(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?xu(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Md&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(H.current[r]),delete H.current[r],t.id===Md&&!_&&(H.current[r]=window.setTimeout(()=>{uc.getState().updateProjectActionRunStatus(r,`running`),delete H.current[r]},Nd)),v?(M(fe,i,null,{locked:!0}),le(v),X.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),X.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Md};let y=Pd(t.command.trim().replace(/\r\n|\r/g,`
3
- `));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t],X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{oe.current.delete(t)}}}),ye=K(async e=>{let t=bu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||ce?.hostId){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),uc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||ce?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=bu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(V(e.id),!t){ve(e);return}let n=bu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(ce?.id){if(a||ce.hostId){X.info(o(`remoteProjects.configurationReadOnly`)),x(`remoteInstances`),S(!0);return}C(ce.id),x(`projects`),S(!0)}});if(c.isVSCode||!i&&m||!ce||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===Md?`search`:Su[we]||`play`,Ee=N[bu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:te||De,className:Y(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)($r,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(yi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(xi,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Md?`search`:Su[t]||`play`,r=bu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:te||De,className:Y(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)($r,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(yi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(xi,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Md?`search`:Su[t]||`play`,r=bu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function zd(){}function Bd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Vd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Hd=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Ud=Q.memo(function(e){let t=(0,Au.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??Vd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=Y(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ti,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Wd=Q.memo(function(e){let t=(0,Au.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Mr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=Y(Vd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(vi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(xi,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(bi,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(yi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Si,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Gd=Q.memo(function(e){let t=(0,Au.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Mr(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(_i,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Bs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Dl,{})]})}):null,(0,$.jsx)(Ha,{embedded:!0,open:i&&s===`instance`,onOpenChange:tf,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(Vc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:qd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Bs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(Ds,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Ll(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:$s(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-tc(s.elapsedRatio):tc(s.elapsedRatio),l=Zs(i.valueLabel,o),u=Qs(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ec(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(mu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(au,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(Ai,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(ki,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Oi,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=$s(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-tc(a.elapsedRatio):tc(a.elapsedRatio),s=Zs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Ws(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(mu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(au,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(yi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Si,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Kd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),qd=(e,t)=>{if(!e)return`-`;try{return Hs(e,t,{fallback:`-`})}catch{return`-`}},Jd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Yd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Xd=e=>{let t=(0,Au.c)(3),n=Qt(nf),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Zd,{...e,hostId:n}):(0,$.jsx)(ef,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Zd=e=>{let t=(0,Au.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=yt(),a=Er(!0),o=Dr(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(ef,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},Qd=Q.memo(e=>{let t=(0,Au.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:mt,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=vt(s,wt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),$d=Q.memo(e=>{let t=(0,Au.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(Ze,Xe,Xe),c;t[0]===o?c=t[1]:(c=Ye(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?nt(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):rf,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=hn(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=vt(b,wt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=dr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=st([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=qe(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(nc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),ef=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Mr(),l=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),f=q(e=>e.isSidebarOpen),m=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),b=q(e=>e.openContextOverview),x=q(e=>e.openContextBrowser),S=q(e=>e.closeContextPanel),C=q(e=>e.activeMainTab),E=q(e=>e.setActiveMainTab),O=q(e=>e.shortcutOverrides),k=q(e=>e.timeFormatPreference),A=kn(e=>e.getCurrentModel),j=Ct(),M=Bn(e=>!!e.newSessionDraft?.open),N=Bn(e=>e.currentSessionId),P=Qt(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),F=!!P?.hostId,L=wn(e=>e.remoteSession),z=P?.hostId&&L?.projectId===P.id&&L.location.hostId===P.hostId&&(!P.hubId||L.location.hubId===P.hubId)?L:null,B=F?z?.sessionId??null:N,V=F?!z?.sessionId:M,te=Rn(F?``:B??``),ne=sn(F?null:B),re=Qt(e=>e.projects),ie=Q.useMemo(()=>{if(!F)return ne;let e=z?.location.directory??P?.path,t=P?.hubId??s?.hubId,n=P?.hostId;if(!(!e||!t||!n||Ft(re,t,n,e,a?.worktrees)?.id!==P?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===B&&t.directory===e)},[F,ne,z?.location.directory,P,s?.hubId,re,a,B]),ae=Q.useMemo(()=>{if(!P)return null;let e=P.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[P]),H=Ys(e=>e.results),W=Ys(e=>e.fetchAllQuotas),le=Ys(e=>e.isLoading),ue=Ys(e=>e.lastUpdated),de=Ys(e=>e.displayMode),fe=Ys(e=>e.showPredValues),pe=Ys(e=>e.dropdownProviderIds),me=Ys(e=>e.loadSettings),he=Ys(e=>e.setDisplayMode),{isMobile:ge}=di(),_e=Fs().data??null,ve=Ml(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:y()),Se=Q.useMemo(()=>I(),[]),Ce=be&&w()===`win32`,we=ui(),Te=Lu(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=ac(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(y())},[]);let Ae=A(),je=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Ne=je&&typeof je.context==`number`?je.context:0,Pe=je&&typeof je.output==`number`?je.output:0,Fe=pr(F?``:B??``,Ne,Pe),G=V?null:Fe,[Ie,Le]=Q.useState(null),Re=!B||te;(0,Q.useEffect)(()=>{if(!B){Le(e=>e===null?e:null);return}if(G){Le(e=>Kd(e,G)?e:G);return}Re&&Le(e=>e===null?e:null)},[G,B,Re]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>D(),[]),ot=!at&&C===`chat`&&!!Ie,st=Ie&&Ie.contextLimit>0?Math.min(999,Ie.totalTokens/Ie.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(T()){Qe(`Local`),et(!1);return}let e=u(),t=await se();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?oe(n,U(e)):!1);if(h()!==n)return;if(et(!!n),a?.label?.trim()){Qe(ce(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),qs();let lt=Ys(e=>e.selectedModels),ut=Ys(e=>e.expandedFamilies),dt=Ys(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Xs(H)){if(!pe.includes(t.id))continue;let n=H.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Il(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=Js(i,t.id),a=Ks(t.id),s=Gs(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,H,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await Me({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([W(),e]).finally(()=>{Xe(!1)})},[W,Ye]),gt=Bn(e=>F||!B?``:e.worktreeMetadata.get(B)?.path??``),_t=Q.useMemo(()=>Jd(gt||``),[gt]),vt=Q.useMemo(()=>Jd((typeof ie?.directory==`string`?ie.directory:``)||``),[ie?.directory]),yt=Bn(e=>e.newSessionDraft?.open?Jd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>F?z?.location.directory??P?.path??``:_t||vt||yt,[F,z?.location.directory,P?.path,yt,vt,_t]),xt=Hi(),St=z?ee(z.location):P?.hostId&&P.hubId?ee({hubId:P.hubId,hostId:P.hostId,directory:xt??P.path}):``,wt=Q.useMemo(()=>F?St:Jd(xt||bt||P?.path||``),[F,St,P?.path,xt,bt]),Tt=q(e=>Vt(e,wt)),Et=!!Tt?.isOpen,Dt=K(()=>_(wt)),Ot=Q.useMemo(()=>{if(!B)return ae??`Yuri`;let e=ie?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ae,ie?.title,B]),kt=Q.useMemo(()=>F?bt:Jd(bt||P?.path||``),[F,P?.path,bt]),At=Q.useMemo(()=>P?{id:P.id,path:P.path,hostId:P.hostId,hubId:P.hubId}:null,[P]),jt=Q.useRef(null);Q.useEffect(()=>{!At||!kt||(jt.current={projectRef:At,directory:kt})},[kt,At]);let Mt=Q.useMemo(()=>At&&kt?{projectRef:At,directory:kt}:jt.current,[kt,At]),Nt=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=j.github?await j.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,j.github,ve]),It=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){It(),l(!ze);return}d()},[It,ge,ze,l,d]),Rt=Q.useCallback(()=>{F||v(`desktop_open_draft_mini_chat_window`,{directory:Jd(bt||P?.path||``),projectId:P?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[F,P?.id,P?.path,bt]),zt=Q.useCallback(()=>{if(!F){if(V){Rt();return}B&&v(`desktop_open_session_mini_chat_window`,{sessionId:B,directory:Jd(bt||P?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[F,P?.path,B,Rt,V,bt]),Bt=Q.useCallback(()=>{let e=wt;if(e){if(Yd(Tt)===`context`){S(e);return}b(e)}},[S,wt,Tt,b]),Ht=Q.useMemo(()=>wt?Yd(Tt)===`context`:!1,[wt,Tt]),Ut=Q.useCallback(()=>{let e=wt;if(e){if(Yd(Tt)===`browser`){S(e);return}x(e)}},[S,wt,Tt,x]),Wt=Q.useMemo(()=>wt?Yd(Tt)===`browser`:!1,[wt,Tt]),Gt=Vd,Kt=Hd,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:C,[C,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&t&&t(),!e&&ze&&l(!1)},[ze,r,e,t,i,l]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),t?.()},[t,i]),Zt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Zt)},[Zt]);let $t=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,en=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,tn=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),nn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Et?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Et,De]),rn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Pt(ye,([e])=>{e&&rn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{rn(ye.current?.getBoundingClientRect().height)},[rn,ge,tn]);let an=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await R()},[be]),on=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),cn=Q.useCallback(e=>xa(wa(e,O)),[O]);(0,Q.useEffect)(()=>{!ge&&(C===`git`||C===`terminal`||C===`diff`||C===`files`)&&E(`chat`)},[C,ge,E]);let ln=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}),e},[be,c]),un=Q.useMemo(()=>ln.map(e=>({id:e.value,label:e.label,icon:e.icon})),[ln]),dn=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),fn=Q.useMemo(()=>dn.map(e=>({id:e.value,label:e.label})),[dn]),pn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if(lr(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=on.length&&(e.preventDefault(),ge&&(It(),Jt()),E(on[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[It,Jt,ge,E,on]);let mn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&W()});(0,Q.useEffect)(()=>{let e=e=>{let t=wa(`toggle_services_menu`,O);if(Ca(e,t)){e.preventDefault();let t=Bd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?mn(t.tab):Je(!1);return}let n=wa(`cycle_services_tab`,O);if(Ca(e,n)){e.preventDefault();let t=ln.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&W();return}let r=wa(`open_usage`,O);if(Ca(e,r)){e.preventDefault();let t=Bd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?mn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,be,qe,tt,ln,ue,W,ct,mn]);let hn=e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(ju,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e.id),className:Y(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},gn=!F&&Se&&(V||!!B),_n=Q.useCallback(e=>{window.setTimeout(e,0)},[]),vn=Q.useCallback(e=>{mn(e)},[mn]),yn=Q.useRef(null),bn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:yn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Si,{children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:Y(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(yi,{align:`start`,className:`min-w-[14rem]`,children:[gn?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(zt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(V?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`toggle_services_menu`)})]}):null,(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`open_usage`)})]}),(0,$.jsx)(xi,{}),(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(m),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`toggle_terminal`)})]}),(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Gd,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:W,servicesTabItems:un,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:fn,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:le,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:k,anchorRef:yn})]}),xn=(0,$.jsxs)($.Fragment,{children:[!F&&!ge&&!at&&C===`chat`?(0,$.jsx)(Bu,{}):null,F?null:(0,$.jsx)(vd,{directory:kt}),be&&(0,$.jsx)(qu,{open:qe&&tt===`instance`,onClick:()=>mn(`instance`)}),(0,$.jsx)(Ud,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:cn(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Et,onClick:Dt,className:Y(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Et?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Wd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Nt})]}),Sn=()=>(0,$.jsxs)(`div`,{onMouseDown:an,className:Y(`app-region-drag relative flex h-12 select-none items-center pr-3`,tn),style:nn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ic,{scopeProjectId:F?P?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:V?c(`sessions.switcher.draftTitle`):F&&s&&z?.sessionId?(0,$.jsx)(Qd,{entry:s.resolve(z.location),sessionId:z.sessionId,fallback:Ot},ee(z.location)):Ot})})}),F?(0,$.jsxs)(`span`,{"data-remote-header-host":P?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&P?.hostId?(0,$.jsx)(Ro,{registry:s,hostId:P.hostId}):null]}):null]}),on.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:on.map(e=>hn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[bn,F&&!at&&C===`chat`&&s&&z?.sessionId?(0,$.jsx)($d,{entry:s.resolve(z.location),sessionId:z.sessionId,onClick:Bt,pressed:Ht},ee(z.location)):null,ot&&Ie?(0,$.jsx)(nc,{pending:Ie.pending,totalTokens:Ie.totalTokens,percentage:st,colorPercentage:Ie.percentage,contextLimit:Ie.contextLimit,outputLimit:Ie.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Bt,pressed:Ht}):null,xn,(0,$.jsx)(rc,{visible:De&&Oe===`right`&&!Et,position:`right`})]})]})]}),Cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:Y(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[F?(0,$.jsxs)(`span`,{"data-remote-header-host":P?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&P?.hostId?(0,$.jsx)(Ro,{registry:s,hostId:P.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:on.map(e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(It(),Jt()),E(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:Y(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(ju,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Tu,{mobile:!0}),Mt&&(0,$.jsx)(Ld,{projectRef:Mt.projectRef,directory:Mt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Si,{open:Ge,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),Ke(n),n&&ue===null&&W()},children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:Y(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(yi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Bs,{items:pn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&W()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(Vc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:qd(ue,k)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:le||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(Ds,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Ll(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:$s(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-tc(o.elapsedRatio):tc(o.elapsedRatio),c=Zs(n.valueLabel,a),l=Qs(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,k);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ec(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(mu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(au,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(Ai,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(ki,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Oi,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=$s(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-tc(i.elapsedRatio):tc(i.elapsedRatio),o=Zs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Ws(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(mu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(au,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:Y(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),Tn=Y(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:Tn,style:{"--padding-scale":`1`},children:ge?Cn():Sn()})})};function tf(){}function nf(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function rf(){}var af=180,of=640,sf=110,cf=e=>{let t=(0,Au.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Mr(),o=q(lf),s=q(uf),c=q(df),l=q(ff),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(of,Math.max(af,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(of,Math.max(af,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=sf&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=Y(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:Y(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=Y(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function lf(e){return e.bottomTerminalHeight}function uf(e){return e.isBottomTerminalExpanded}function df(e){return e.setBottomTerminalHeight}function ff(e){return e.setBottomTerminalOpen}var pf=260,mf=260,hf=500,gf=e=>Math.min(hf,Math.max(mf,e)),_f=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Mr(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||pf),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(hf,Math.max(mf,o||pf)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=gf(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=gf(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:Y(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:Y(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:Y(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Mo,{children:n})})]})]})},vf=()=>{let e=(0,Au.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},yf=e=>{let t=(0,Au.c)(26),{className:n}=e,{t:r}=Mr(),i=q(bf),a=gu(xf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(Sf);if(Q.useEffect(()=>{c&&io()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=Y(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=J,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=Y(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(Ao,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Y(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Tl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function bf(e){return e.openSettingsAtItem}function xf(e){return e.sidebarBrandName}function Sf(e){return e!==`Yuri`}var Cf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,wf=()=>{let e=(0,Au.c)(50),{t}=Mr(),n=Qt(Tf),r=wn(Ef),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ee(i.location):n?.hostId&&n.hubId?ee({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(Df),c=q(Of),l=q(kf),u=q(Af),d=gu(jf),f=Q.useRef(null),p=xa(wa(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=ac(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=y(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!D()&&!_&&ie(),e[4]=b):b=e[4];let x=b,S=Nf,C,w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},w=[],e[5]=C,e[6]=w):(C=e[5],w=e[6]),Q.useEffect(C,w);let T=o||void 0,E=x&&s?`${c||260}px`:void 0,O;e[7]===E?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:E},e[7]=E,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=Y(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(yf,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(rc,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:Y(Cf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(al,{}):null,e[19]=v,e[20]=P);let F=ti,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(Cf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let B=$r,V=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),te;e[28]===V?te=e[29]:(te=(0,$.jsx)(`p`,{children:V}),e[28]=V,e[29]=te);let ne;e[30]!==B||e[31]!==te?(ne=(0,$.jsx)(B,{children:te}),e[30]=B,e[31]=te,e[32]=ne):ne=e[32];let re;e[33]!==F||e[34]!==z||e[35]!==ne?(re=(0,$.jsxs)(F,{children:[z,ne]}),e[33]=F,e[34]=z,e[35]=ne,e[36]=re):re=e[36];let ae;e[37]!==P||e[38]!==re?(ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,re]}),e[37]=P,e[38]=re,e[39]=ae):ae=e[39];let H;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ae?(H=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ae]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ae,e[45]=H):H=e[45];let U;return e[46]!==H||e[47]!==T||e[48]!==O?(U=(0,$.jsx)(`div`,{"data-titlebar-location":T,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:H}),e[46]=H,e[47]=T,e[48]=O,e[49]=U):U=e[49],U};function Tf(e){return e.projects.find(t=>t.id===e.activeProjectId)}function Ef(e){return e.remoteSession}function Df(e){return e.isSidebarOpen}function Of(e){return e.sidebarWidth}function kf(e){return e.toggleSidebar}function Af(e){return e.shortcutOverrides}function jf(e){return e.sidebarBrandName.trim().length>0}function Mf(e){console.warn(`[titlebar] failed to open app menu`,e)}function Nf(e){let t=e.currentTarget.getBoundingClientRect();v(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Mf)}var Pf=(e,t)=>{let n=Mt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},Ff=(e,t,n=10)=>{let r=jt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=jt(t.path);if(!e||i.has(e))continue;let o=Pf(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},If=e=>e.some(e=>!!jt(e)),Lf=(e,t)=>{let n=new Set(t.map(e=>jt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},Rf=(e,t,n)=>t.length===0?e.length===0:Lf(e,t).length>0?!1:t.every(e=>n.has(jt(e))),zf=ya(()=>It(()=>import(`./ToolOutputDialog-DjekF5-2.js`).then(e=>e.n),__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]))),Bf=e=>{let t=Uf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},Vf=e=>{let t=(0,Au.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Hf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Uf=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},Wf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Gf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Kf=(e,t)=>{let n=Uf(t),r=Uf(e);if(!n||!r)return!1;let i=Gf(n),a=Gf(r);return a===i||a.startsWith(`${i}/`)},qf=(e,t)=>{let n=Uf(t),r=Uf(e);if(!Kf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Jf=(e,t)=>{if(!t)return``;let n=Uf(t);if(!e||!Kf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Yf=new Set([`node_modules`]),Xf=e=>{let t=(0,Au.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Zf=e=>{let t=(0,Au.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},Qf=e=>Yf.has(e),$f=e=>{let t=Uf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},ep=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},tp=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},np=2e5,rp=`yuri:files:auto-save-enabled`,ip=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-Bk8GsZTN.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-CNdx57HN.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DKJJoOOc.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/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-P32bzAJc.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/runtime-file-download-wMVtKk2v.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/ui-CBjYsEHe.js","assets/gitApiHttp-C8AU1uiY.js","assets/client-QcYZg8_d.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-D1c308Ba.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-BunVM5PM.js","assets/i18n-WsU03nwB.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-BDr-X6Ry.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-PqhVEhUI.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-DEiMjSqf.js","assets/Icon-BxuNTD1G.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-BhhUro-8.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-DynS0IQR.js","assets/mobileBackNavigation-CihY-ZWs.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-wOEYYae9.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-BcCmyx3J.js","assets/markdownHeightCache-CfBcQ5c-.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-B39pFDdo.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-BVpHBxQo.js","assets/touch-gestures-DOoBxhz5.js","assets/TerminalView-CvTlu81P.js","assets/terminalApi-D2ECmoAo.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/OverlayScrollbar-BbUv42hT.js","assets/device-CtdJ8KBJ.js","assets/useProjectRuntimeAPIs-Ct3aOMyH.js","assets/sortable-tabs-strip-D6tQk6nW.js","assets/vendor-dnd-kit-core-qy5stxu5.js","assets/vendor-dnd-kit-accessibility-u0XSXxKq.js","assets/vendor-dnd-kit-sortable-CiTIuX4o.js","assets/useFontPreferences-BY0TXvWI.js","assets/project-preview-CIkGbBPZ.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-D84EVh3q.js","assets/DiagramView-CUCcpmvd.js","assets/diagram-Clzpe5jY.js","assets/vendor-react-drawio-C9rszQEJ.js","assets/SettingsView-RULyRRQP.js","assets/desktopHosts-DFa3lf0i.js","assets/desktopRelayRestore-CGq-Ylgq.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/ScrollableOverlay-CAdxdD7C.js","assets/tooltip-BQKvkayK.js","assets/react-CPBNl-S9.js","assets/dropdown-menu-low64f9u.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/context-menu-0Bkpdmag.js","assets/collapsible-J-qWuNzr.js","assets/textarea-f9PtvCNG.js","assets/gitApi-uOSHjWy6.js","assets/GuiPluginMount-CXnJtW4N.js","assets/MobileHtmlNetworkBoundary-CToMn0v-.js","assets/input-Bn5-lrjt.js","assets/shortcuts-DFgnwGd5.js","assets/assistantQueries-DFR7-2m4.js","assets/MobileDetailNavigation-CXC4GjdP.js","assets/pwa-BsyIaDZ4.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/ErrorBoundary-74-IYvi5.js","assets/card-Bjer7G59.js","assets/ProviderLogo-BhzPiC4G.js","assets/zhipuai-coding-plan-CcFj8zKy.js","assets/select-CETtrHQE.js","assets/MobileResizableSheet-DaQdMNe9.js","assets/githubAuthQueries-IJPWBo0B.js","assets/projectMeta-vIaGFaQr.js","assets/timeFormat-D1hdmWbu.js","assets/permission-rules-DoQUXKll.js","assets/useQuotaStore-BqPJ1nzk.js","assets/quota-C7uYEfoX.js","assets/router-DXUi1sBd.js","assets/contextPanelEmbeddedChat-Dm5R_b5X.js","assets/sessionOwnership-nyTiak2m.js","assets/types-B0G9z6G6.js","assets/checkbox-BnafV7fE.js","assets/mcpQueries-BDdMur9_.js","assets/usePluginsStore-DEIJXUJp.js","assets/switch-B8h1KUmC.js","assets/SettingsGroup-C1ui69yn.js","assets/useMcpConfigStore-CGenk3_j.js","assets/native-config-6EqKnDU2.js","assets/YuriLogo-Cexwa29m.js","assets/MobileTabPageHeader-BuGRgBJG.js","assets/MobileSurface-BAhIeu5y.js","assets/GuiPluginWindow-D49q7RQT.js","assets/pluginPresentation-BnpV06pV.js","assets/ModelLogo-B4ia9c7r.js","assets/useDictation-DUR68U4T.js","assets/audio-session-BFWjrDbp.js","assets/browserVoiceService-x5Pci8L3.js","assets/speechSettingsQueries-B8UP0Kkn.js","assets/pluginPresentation-C0HSdVvS.css","assets/ModelSelector-CoV0ELh9.js","assets/useModelLists-85Cks36l.js","assets/useOpenCodeReadiness-BvD_kM-L.js","assets/AgentSelector-B0Owr1ZK.js","assets/AgentAvatar-CEr1CtLO.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/AssistantsSettingsPage-DmwV91xW.js","assets/MobileShareBridge-BU4o7zvA.js","assets/mobileConnections-C6FuJ0fM.js","assets/assistantPresentation-DRbsH1Ej.js","assets/scheduledTaskNavigation-DpfZSGu8.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/ArchivedSessionsDialog-cbyQcG7B.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/MobileOverlayPanel-DRs4pHcd.js","assets/worktreeManager-DcqLFxEk.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-DPPmIElK.js","assets/MultiRunWindow-CyGYoQ6V.js","assets/multirun-D3ah7H0A.js","assets/useGitStore-CHE0pTk_.js","assets/insertionBoundaries-B--nM0ah.js","assets/spacedFileMention-Ds4GtgiF.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useDebouncedValue-BHlMPqY8.js","assets/fileMentionTouchSelection-B48eLkS9.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionAutocompleteState-B9411b4o.js","assets/worktreeSourceBranchPreference-DyEaTtIU.js","assets/AssistantView-D91RZ13W.js","assets/mobileAppContext-BQgdTp5T.js","assets/AssistantConversationSurface-DOwN0Ip3.js","assets/LoadingImage-fSoPxfqK.js","assets/chatUpwardIntent-ZOlImhuf.js","assets/reference-history-B5vQfNKz.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-vLNN8EMu.js","assets/assistant-attachment-cache-Y7yhlQcv.js","assets/AssistantWorkingAvatar-DgzJEVuK.js","assets/AssistantSessionCard-1CWSy8Bt.js","assets/sessionChangeSummary-BCF9VwAA.js","assets/sessionLookup-D0gUdT8J.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-Bi7Dojgx.js","assets/sortAssistantContacts-CcEdm3mS.js","assets/assistantMessagePreview-DsmKo-Rd.js","assets/navigation-BFoRE4u8.js","assets/OnboardingScreen-Bctdl4oS.js","assets/openSessionFromDeepLink-DMS6SIo7.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,F as y,G as b,H as x,I as S,L as C,O as w,P as T,Q as E,R as D,U as O,W as k,X as A,a as j,c as M,ct as N,d as P,dt as F,f as I,g as L,it as R,k as z,l as B,lt as V,s as ee,st as te,u as ne,ut as re,z as ie}from"./platform-CNdx57HN.js";import{n as ae,t as H}from"./runtimeAPIRegistry-C2VogTny.js";import{d as U,h as oe,m as W,r as se,v as ce}from"./desktopHosts-DFa3lf0i.js";import{a as le,i as ue,t as de}from"./vendor-zustand-CTekDqaS.js";import{A as fe,B as pe,C as me,H as he,M as ge,P as _e,S as ve,V as ye,b as be,it as xe,j as Se,k as Ce,ot as we,st as Te,v as Ee,x as De,y as Oe,z as ke}from"./vendor-base-ui-wXsskyKm.js";import{Ct as Ae,Et as je,Ft as Me,Mt as Ne,Pt as Pe,St as Fe,Tt as G,an as Ie,jt as Le,on as Re,wt as ze,xt as Be}from"./gitApiHttp-C8AU1uiY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Ve,r as He,t as Ue}from"./safeStorage-DTOhKN0V.js";import{B as We,H as Ge,Jt as Ke,Rt as qe,St as Je,Xt as Ye,Zt as Xe,an as Ze,ft as Qe,ht as $e,mt as et,n as tt,on as nt,qt as rt,rn as it,tn as at,vr as ot,zt as st}from"./client-QcYZg8_d.js";import{P as ct,d as lt,z as ut}from"./prompt-attachment-upload-D1c308Ba.js";import{n as dt}from"./pathNormalization-ewtPqJWn.js";import{n as ft,t as pt}from"./vendor-react-BkccXcWz.js";import{f as mt,u as ht}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as gt,o as _t,s as vt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as yt,I as bt,O as xt,P as St,R as Ct,W as wt,c as Tt,r as Et,s as Dt,t as Ot,y as kt,z as At}from"./runtime-file-resource-DKJJoOOc.js";import{a as jt,n as Mt}from"./path-utils-jGozTg9d.js";import{h as Nt,m as Pt,r as K}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as Ft}from"./summaries-BQMyJaaw.js";import{o as It}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Lt,i as Rt,o as zt,r as q,s as Bt,t as Vt}from"./useUIStore-P32bzAJc.js";import{o as Ht}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Ut,r as Wt}from"./terminalApi-D2ECmoAo.js";import{a as Gt}from"./types-B0G9z6G6.js";import{t as Kt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as qt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Jt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Yt,A as Xt,Ai as Zt,Ba as Qt,Bi as $t,Br as en,Ct as tn,Di as nn,F as rn,Fi as an,Gr as on,H as sn,Ha as cn,Hr as ln,I as un,Ji as dn,Jr as fn,Kt as pn,Mi as mn,Na as hn,Pi as gn,Pn as _n,Qr as vn,R as yn,S as bn,Si as xn,Tt as Sn,U as Cn,Ua as wn,Vr as Tn,W as En,Wr as Dn,Xr as On,Yi as kn,Yn as J,an as An,ao as jn,ar as Mn,b as Nn,br as Pn,bt as Fn,co as In,ct as Ln,dt as Rn,et as zn,f as Bn,gn as Vn,h as Hn,ht as Un,in as Wn,io as Gn,it as Kn,ji as qn,k as Jn,ki as Yn,la as Xn,li as Zn,lt as Qn,mt as $n,no as Y,o as er,oo as tr,ot as nr,p as rr,pi as ir,pt as ar,qi as or,ro as sr,si as cr,so as lr,st as ur,t as X,ta as dr,to as fr,tt as pr,un as mr,v as hr,wt as gr,x as _r,xt as vr,y as yr,yr as br,yt as xr,zi as Sr}from"./ui-CBjYsEHe.js";import{n as Z,t as Cr}from"./Icon-BxuNTD1G.js";import{d as wr,h as Tr,m as Er,p as Dr}from"./remoteProjectQueries-BunVM5PM.js";import{a as Or,i as kr,n as Ar,r as jr,t as Mr}from"./i18n-WsU03nwB.js";import{n as Nr}from"./store-BDr-X6Ry.js";import{n as Pr}from"./input-store-PqhVEhUI.js";import{a as Fr,c as Ir,i as Lr,l as Rr,o as zr,s as Br}from"./toolHelpers-iEHVHQ9p.js";import{n as Vr}from"./useAssistantUIStore-DEiMjSqf.js";import{n as Hr,t as Ur}from"./ScrollableOverlay-CAdxdD7C.js";import{n as Wr,o as Gr}from"./vendor-framer-motion-D5NyyC73.js";import{a as Kr,i as qr,n as Jr,o as Yr,r as Xr,t as Zr}from"./dialog-BhhUro-8.js";import{i as Qr,n as $r,r as ei,t as ti}from"./tooltip-BQKvkayK.js";import{n as ni,t as ri}from"./useInlineCommentDraftStore-CvpvoffS.js";import{n as ii}from"./useThemeSystem-BIXghnHj.js";import{a as ai,i as oi,n as si,r as ci,t as li}from"./useProjectGitActions-DQvIHmjR.js";import{a as ui,r as di}from"./device-CtdJ8KBJ.js";import{t as fi}from"./SyncActions-CtuW0cF8.js";import{i as pi,n as mi,r as hi,t as gi}from"./dropdown-menu.styles-BDla58Rm.js";import{c as _i,i as vi,n as yi,r as bi,s as xi,t as Si}from"./dropdown-menu-low64f9u.js";import{a as Ci,i as wi,n as Ti,r as Ei,t as Di}from"./context-menu-0Bkpdmag.js";import{n as Oi,r as ki,t as Ai}from"./collapsible-J-qWuNzr.js";import{a as ji,i as Mi,n as Ni,o as Pi,r as Fi}from"./PierreDiffViewer-0bSxnzcB.js";import{n as Ii,t as Li}from"./kbd-BiidNm-N.js";import{t as Ri}from"./DiffWorkerProvider-VFPkag9y.js";import{n as zi,t as Bi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Vi}from"./themes-BgDJcxRc.js";import{n as Hi,t as Ui}from"./useEffectiveDirectory-DynS0IQR.js";import{n as Wi,t as Gi}from"./useProjectRuntimeAPIs-Ct3aOMyH.js";import{b as Ki,h as qi,m as Ji}from"./gitApi-uOSHjWy6.js";import{a as Yi,o as Xi,s as Zi}from"./useGitStore-CHE0pTk_.js";import{a as Qi,i as $i,n as ea,o as ta,r as na,s as ra,t as ia}from"./useProjectGitStore-BZLEIJPC.js";import{i as aa,n as oa,r as sa}from"./MobileHtmlNetworkBoundary-CToMn0v-.js";import{n as ca,t as la}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as ua,i as da,n as fa,r as pa,t as ma}from"./BinaryFileFallback-1wT0ClU8.js";import{t as ha}from"./ImageLoadingPlaceholder-wOEYYae9.js";import{t as ga}from"./LoadingImage-fSoPxfqK.js";import{t as _a}from"./input-Bn5-lrjt.js";import{n as va,o as ya}from"./MarkdownRenderer-BcCmyx3J.js";import{c as ba,i as xa,l as Sa,n as Ca,o as wa,s as Ta}from"./shortcuts-DFgnwGd5.js";import{n as Ea,r as Da}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as Oa}from"./useSessionBtwStore-DWvYSycl.js";import{t as ka}from"./useDebouncedValue-BHlMPqY8.js";import{m as Aa,x as ja,y as Ma}from"./assistantQueries-DFR7-2m4.js";import{A as Na,C as Pa,D as Fa,E as Ia,F as La,I as Ra,M as za,N as Ba,O as Va,P as Ha,R as Ua,S as Wa,T as Ga,_ as Ka,b as qa,c as Ja,d as Ya,f as Xa,g as Za,h as Qa,i as $a,j as eo,k as to,l as no,m as ro,n as io,p as ao,s as oo,t as so,u as co,v as lo,w as uo,x as fo,y as po,z as mo}from"./useAppFontEffects-BQLHroVK.js";import{D as ho,E as go,J as _o,S as vo,_ as yo,b as bo,c as xo,d as So,f as Co,it as wo,m as To,u as Eo,v as Do,x as Oo,y as ko}from"./pwa-BsyIaDZ4.js";import{t as Ao}from"./YuriLogo-Cexwa29m.js";import{t as jo}from"./card-Bjer7G59.js";import{t as Mo}from"./ErrorBoundary-74-IYvi5.js";import{a as No,n as Po,o as Fo,r as Io}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{i as Lo,r as Ro}from"./connection-hint-CVsiZdCj.js";import{u as zo}from"./insertionBoundaries-B--nM0ah.js";import{t as Bo}from"./ModelLogo-B4ia9c7r.js";import{_ as Vo,a as Ho,c as Uo,d as Wo,f as Go,i as Ko,l as qo,n as Jo,o as Yo,p as Xo,r as Zo,s as Qo,u as $o,y as es}from"./ChatContainer-BJadx4zz.js";import{C as ts,i as ns,n as rs,r as is}from"./BtwPanel-FrJmmj9W.js";import{A as as,D as os,E as ss,M as cs,O as ls,P as us,T as ds,X as fs,j as ps,k as ms}from"./BusyDots-DWKGX3Sn.js";import{_ as hs,i as gs,l as _s,n as vs,s as ys,t as bs,v as xs}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as Ss,n as Cs,s as ws,t as Ts}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Es}from"./MobileOverlayPanel-DRs4pHcd.js";import{t as Ds}from"./ProviderLogo-BhzPiC4G.js";import{d as Os}from"./ToolOutputDialog-Bk8GsZTN.js";import{t as ks}from"./vendor-motion-vLNN8EMu.js";import{c as As,i as js,n as Ms,s as Ns,t as Ps}from"./select-CETtrHQE.js";import{a as Fs}from"./githubAuthQueries-IJPWBo0B.js";import{c as Is,i as Ls,n as Rs,s as zs}from"./worktreeManager-DcqLFxEk.js";import{t as Bs}from"./sortable-tabs-strip-D6tQk6nW.js";import{i as Vs}from"./auto-read-context-CFc8sopy.js";import{n as Hs,t as Us}from"./timeFormat-D1hdmWbu.js";import{a as Ws,c as Gs,i as Ks,n as qs,o as Js,r as Ys,u as Xs}from"./useQuotaStore-BqPJ1nzk.js";import{a as Zs,i as Qs,n as $s,s as ec,t as tc}from"./quota-C7uYEfoX.js";import{i as nc,n as rc,r as ic,t as ac}from"./useDesktopWindowControlsLayout-BiQv3xA1.js";import{n as oc,t as sc}from"./sessionChangeSummary-BCF9VwAA.js";import{n as cc,t as lc}from"./openRemoteProjectSession-FtIejPwF.js";import{n as uc}from"./useFontPreferences-BY0TXvWI.js";import{$ as dc,A as fc,At as pc,B as mc,Bt as hc,Ct as gc,D as _c,Dt as vc,E as yc,F as bc,Ft as xc,G as Sc,H as Cc,Ht as wc,I as Tc,It as Ec,J as Dc,K as Oc,L as kc,Lt as Ac,M as jc,Mt as Mc,N as Nc,Nt as Pc,O as Fc,Ot as Ic,P as Lc,Pt as Rc,Q as zc,R as Bc,Rt as Vc,S as Hc,St as Uc,U as Wc,Vt as Gc,W as Kc,Y as qc,Z as Jc,a as Yc,at as Xc,b as Zc,bt as Qc,et as $c,g as el,i as tl,it as nl,j as rl,jt as il,k as al,kt as ol,n as sl,nt as cl,o as ll,ot as ul,q as dl,r as fl,rt as pl,s as ml,tt as hl,v as gl,vt as _l,w as vl,x as yl,xt as bl,y as xl,yt as Sl,z as Cl,zt as wl}from"./runtimeEndpointReset-r655-D3H.js";import{t as Tl}from"./YuriWordmark-Bn5KdqMC.js";import{_ as El,d as Dl,g as Ol,h as kl,m as Al,p as jl,r as Ml,t as Nl,v as Pl,y as Fl}from"./sessionOwnership-nyTiak2m.js";import{i as Il,n as Ll}from"./icons-BjHPg9QC.js";import{r as Rl,t as zl}from"./navigation-BFoRE4u8.js";import{t as Bl}from"./AssistantUnreadBadge-Bi7Dojgx.js";import{n as Vl,t as Hl}from"./GuiPluginPage-BrRwHot0.js";import{d as Ul,i as Wl,n as Gl,r as Kl,u as ql}from"./historyImportQueries-B3QBdaKo.js";import{n as Jl}from"./ScheduledTasksDialog-1HTvbmGQ.js";import{t as Yl}from"./ChatView-Bb-K_GE2.js";import{t as Xl}from"./diagram-Clzpe5jY.js";import{t as Zl}from"./DiffView-CMWTZ175.js";import{a as Ql,i as $l,n as eu,o as tu,r as nu,t as ru}from"./multirun-D3ah7H0A.js";import{_ as iu,a as au,c as ou,d as su,f as cu,g as lu,h as uu,i as du,l as fu,m as pu,o as mu,p as hu,r as gu,s as _u,t as vu,u as yu}from"./ArchivedSessionsDialog-cbyQcG7B.js";import{a as bu,i as xu,n as Su,r as Cu,t as wu}from"./projectActions-D84EVh3q.js";import{t as Tu}from"./GuiPluginTitlebarItems-YkwCMWDl.js";import{t as Eu}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Du,t as Ou}from"./vendor-html-to-image-BDMm2v6d.js";var Q=e(Te(),1),ku=pt(),Au=ft(),$=we();function ju(e){let t=(0,Au.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var Mu=!1,Nu=0,Pu=new Set,Fu=async()=>{let e=++Nu;try{let t=await v(`desktop_is_window_fullscreen`);if(e!==Nu||t===Mu)return;Mu=t===!0,Pu.forEach(e=>e())}catch{}},Iu=e=>y()?(Pu.add(e),Pu.size===1&&(window.addEventListener(`yuri:window-resized`,Fu),Fu()),()=>{Pu.delete(e),Pu.size===0&&(window.removeEventListener(`yuri:window-resized`,Fu),Nu++,Mu=!1)}):()=>{};function Lu(){return(0,Q.useSyncExternalStore)(Iu,zu,Ru)}function Ru(){return!1}function zu(){return Mu}function Bu(){let e=(0,Au.c)(19),{t}=Mr(),n=q(Gu),r=q(Wu),i=q(Uu),a=q(Hu),o=q(Vu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=K(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=Y(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Z,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Vu(e){return e.setWorkStatusOverlayOpen}function Hu(e){return e.setWorkStatusPanelEnabled}function Uu(e){return e.workStatusOverlayOpen}function Wu(e){return e.workStatusPanelFits}function Gu(e){return e.workStatusPanelEnabled}var Ku=(e,t,n)=>_t({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await se(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await _o();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>W(e,i)||t===`host:${e.id}`||!!(n&&oe(n,U(e)))),sshIds:i}}});function qu(e){let t=(0,Au.c)(18),{onClick:n,open:r}=e,{t:i}=Mr(),a=Q.useSyncExternalStore(c,u,u),o=q(Ju),s=p(),l=h(),d=T(),{data:f}=vt({...Ku(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&oe(l,U(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?ce(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=La({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ti,b=Qr,x=J,S=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),C;t[0]===v?C=t[1]:(C=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(Z,{name:v,className:`size-5`})}),t[0]=v,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=w):w=t[2];let E;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==S||t[7]!==C?(E=(0,$.jsxs)(x,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":S,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[C,w]}),t[3]=x,t[4]=n,t[5]=r,t[6]=S,t[7]=C,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)($r,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function Ju(e){return e.isSettingsDialogOpen}var Yu=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Xu=`finder`,Zu=new Set([`finder`,`terminal`]),Qu=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,$u=e=>{if(!e)return null;let t=Yu.find(t=>t.id===e)??null;return t?Qu(t):null},ed=()=>Yu.filter(e=>Zu.has(e.id)).map(e=>({...Qu(e)})),td=e=>{let t=new Map(e.map(e=>[e.name,e]));return Yu.filter(e=>t.has(e.appName)||Zu.has(e.id)).map(e=>{let n=t.get(e.appName);return{...Qu(e),...e.id===`terminal`&&n?.appName&&n.label?{appName:n.appName,label:n.label}:{},iconDataUrl:n?.iconDataUrl??void 0}})},nd=()=>{if(typeof window>`u`)return Xu;let e=window.localStorage.getItem(`openInAppId`);return e&&$u(e)?e:Xu},rd=!1,id=!1,ad=!1,od=0,sd=null,cd=()=>{sd&&=(clearTimeout(sd),null)},ld=le()((e,t)=>({selectedAppId:nd(),availableApps:ed(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(rd||typeof window>`u`)return;rd=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:ed(),hasLoadedApps:n});return}e({availableApps:td(t),hasLoadedApps:!0})},r=async i=>{if(!y()||id||t().hasLoadedApps&&!i)return;let a=Yu.map(e=>e.appName);cd(),i&&e({hasLoadedApps:!1}),id=!0,ad=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await L(a,i),l=o&&!s&&t.length===0&&od<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][od]??3200;od+=1,ad=!0,sd=setTimeout(()=>{r()},e);return}od=0,ad=!1;return}if(od<3){let e=[1e3,3e3,7e3][od]??7e3;od+=1,ad=!0,sd=setTimeout(()=>{r()},e)}}finally{id=!1,ad||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&$u(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(od=3,ad=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(rd||t().initialize(),!y()||id||t().hasLoadedApps&&!n)return;let r=Yu.map(e=>e.appName);cd(),n&&e({hasLoadedApps:!1}),id=!0,ad=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await L(r,n),o=td(t);e({availableApps:o.length>0?o:ed(),hasLoadedApps:o.length>0,isCacheStale:i?a:!1})}finally{id=!1,ad||e({isScanning:!1})}},selectApp:async t=>{$u(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Me({openInAppId:t}))}})),ud=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:y()&&z()&&n!==null,queryFn:async({signal:e})=>{let t=await v(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},dd=()=>{let e=(0,Au.c)(3),t=(0,Q.useSyncExternalStore)(c,p,fd),n=(0,Q.useSyncExternalStore)(c,u,pd),r;return e[0]!==t||e[1]!==n?(r=ud(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],vt(r)};function fd(){return``}function pd(){return``}var md=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,hd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,gd=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?md:e.id===`terminal`&&e.label===`Terminal`?hd:void 0}),_d=e=>{let t=(0,Au.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Q.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},vd=({directory:e,className:t})=>{let{t:n}=Mr(),r=ld(e=>e.selectedAppId),i=ld(e=>e.availableApps),a=ld(e=>e.isCacheStale),o=ld(e=>e.isScanning),s=ld(e=>e.initialize),c=ld(e=>e.loadInstalledApps),l=ld(e=>e.selectApp),{data:u}=dd(),d=Q.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Q.useEffect(()=>{s()},[s]);let f=y()&&T(),p=Q.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?gd(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await b(e,t.id,t.appName,u?.hostId);!r&&!u?await k(e,t.appName):r||X.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){X.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await fr(e)};return(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:Y(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(_d,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(yi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(Z,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(xi,{}),d.map(e=>{let t=gd(e);return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(_d,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(Z,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(Z,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},yd=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],bd=[`dev`,`start`,`preview`,`serve`];async function xd(e,t,n,r){if(!e)return null;let i=wd(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Td(n);if(t){let n=await Ed(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await Sd(e,r)){let e=await Cd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function Sd(e,t){let n=await Dd(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function Cd(e){if(e){let t=await bt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function wd(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(bd.some(t=>e.includes(t)))return t}return null}function Td(e){for(let{pattern:t}of yd)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Ed(e,t){let n=await Dd(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Dd(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Dd(e,t,n){if(n){let r=bt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=H()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function Od(e,t){try{let n=await Dd(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var kd=e=>new Promise(t=>{window.setTimeout(t,e)}),Ad=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),jd=/https?:\/\/[^\s<>'"`]+/gi,Md=`__yuri_auto_discover_preview__`,Nd=15e3,Pd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Fd=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Id=e=>{let t=e.replace(Ad,``).match(jd);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Ld=e=>{let t=(0,Au.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Er(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):zd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Q.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(Rd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},Rd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Mr(),{terminal:s,runtime:c}=Ct(),l=Q.useRef(null),u=Q.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&bt(a).assertCurrent()},f=K(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Wt(a)}),p=Q.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=di(),h=Q.useMemo(()=>y(),[]),g=_u(e=>e.instances),_=_u(e=>e.load),v=q(e=>e.setBottomTerminalOpen),b=q(e=>e.setActiveMainTab),x=q(e=>e.setSettingsPage),S=q(e=>e.setSettingsDialogOpen),C=q(e=>e.setSettingsProjectsSelectedId),w=q(e=>e.openContextPreview),T=uc(e=>e.sessions),E=uc(e=>e.ensureDirectory),D=uc(e=>e.setTabLabel),O=uc(e=>e.setTabIconKey),k=uc(e=>e.setActiveTab),A=uc(e=>e.setConnecting),j=uc(e=>e.setTabSessionId),M=uc(e=>e.setTabPreviewUrl),N=uc(e=>e.projectActionRuns),P=uc(e=>e.setProjectActionRun),F=uc(e=>e.updateProjectActionRunStatus),I=uc(e=>e.removeProjectActionRun),[L,R]=Q.useState([]),[z,V]=Q.useState(null),[te,ne]=Q.useState(!1),re=Q.useRef({}),ie=Q.useRef({}),ae=Q.useRef({}),H=Q.useRef({}),U=Q.useRef(0),oe=Q.useRef(new Set),W=e?.id??null,se=e?.path??``,ce=Q.useMemo(()=>W?{id:W,path:se,hostId:e?.hostId,hubId:e?.hubId}:null,[W,se,e?.hostId,e?.hubId]);Q.useEffect(()=>{u.current=!0;let e=ae.current,t=H.current;return()=>{u.current=!1,U.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Q.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let le=K(async e=>{await Ht(e)}),ue=K(async()=>{if(!ce)return;let e=U.current+1;U.current=e,ne(!0);try{d();let t=await Yt(ce,a);if(U.current!==e)return;let n=t.actions;R(n),V(e=>e===Md||e&&n.some(t=>t.id===e)?e:null)}catch{if(U.current!==e)return}finally{U.current===e&&ne(!1)}}),de=t||ce?.path||``,fe=Q.useMemo(()=>a?B(ee({...a.location,directory:de})):ce?.hostId?ce.hubId?B(ee({hubId:ce.hubId,hostId:ce.hostId,directory:de})):``:Cu(de),[de,ce,a]),pe=Q.useMemo(()=>z?L.find(e=>e.id===z)??null:null,[L,z]),me=Q.useMemo(()=>({id:Md,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),he=!m,ge=Q.useMemo(()=>he?[me,...L]:L,[L,me,he]);Q.useEffect(()=>{ue()},[ue,ce,a]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;W&&(t?.projectId&&t.projectId!==W||ue())};return window.addEventListener(wu,e),()=>{window.removeEventListener(wu,e)}},[ue,W]),Q.useEffect(()=>{z&&(z===Md&&he||L.some(e=>e.id===z)||V(null))},[L,he,z]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[fe,N,I,T]),Q.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==fe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=ge.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Id(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(H.current[e]),delete H.current[e],w(t.directory,u))}else a||ce?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(le(u),X.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(H.current[e]),delete H.current[e])},[fe,a,ce?.hostId,ge,w,le,N,M,o,T,F]);let _e=K(async(e,t={})=>{if(!fe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=bu(fe,e.id);E(fe);let r=uc.getState(),i=r.getDirectoryState(fe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(fe),re.current[n]=a),D(fe,a,`Action: ${e.name}`),O(fe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(fe,a),v(!0),b(`terminal`));let c=uc.getState().getDirectoryState(fe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ve=K(async e=>{if(c.isVSCode||!i&&m)return;if(!fe){X.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=bu(fe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!oe.current.has(t)){oe.current.add(t);try{d();let t=e.id===Md?await(async()=>{let[e,t]=await Promise.all([Yt({...ce,id:ce?.id??``,path:de},a),Od(de,a)]),n=await xd(de,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Md,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await _e(t,{revealTerminal:!n&&e.id!==Md}),c=s,l=!1;if(!c){A(fe,i,!0);try{let e=await p.createSession({cwd:de});d(),c=e.sessionId,l=!0,j(fe,i,c)}finally{A(fe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await kd(350),d(),t.id===Md&&(ae.current[r]?.(),A(fe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Ut)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&uc.getState().appendToBuffer(fe,i,e.data),e.type===`exit`&&(uc.getState().setTabLifecycle(fe,i,`exited`),uc.getState().setConnecting(fe,i,!1),uc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(H.current[r]),delete H.current[r])}},()=>{u.current&&uc.getState().setConnecting(fe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Fd(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?xu(t.desktopOpenSshForward,g):null;P({key:r,directory:fe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Md&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(H.current[r]),delete H.current[r],t.id===Md&&!_&&(H.current[r]=window.setTimeout(()=>{uc.getState().updateProjectActionRunStatus(r,`running`),delete H.current[r]},Nd)),v?(M(fe,i,null,{locked:!0}),le(v),X.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(fe,i,_,{locked:!0,autoOpened:!0}),w(fe,_),X.success(o(`projectActions.toast.openedActionUrl`))):n?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(fe,i,null,{locked:!0}),X.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(fe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Md};let y=Pd(t.command.trim().replace(/\r\n|\r/g,`
3
+ `));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t],X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{oe.current.delete(t)}}}),ye=K(async e=>{let t=bu(fe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||ce?.hostId){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),uc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||ce?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),X.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t]}}),be=K(()=>{let e=pe??ge[0];if(!e)return;let t=bu(fe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){ye(e);return}ve(e)}}),xe=K((e,t=!1)=>{if(V(e.id),!t){ve(e);return}let n=bu(fe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){ye(e);return}ve(e)}}),Se=K(()=>{if(ce?.id){if(a||ce.hostId){X.info(o(`remoteProjects.configurationReadOnly`)),x(`remoteInstances`),S(!0);return}C(ce.id),x(`projects`),S(!0)}});if(c.isVSCode||!i&&m||!ce||!fe)return null;let Ce=pe??ge[0]??null;if(!Ce)return null;let we=Ce.icon||`play`,Te=Ce.id===Md?`search`:Su[we]||`play`,Ee=N[bu(fe,Ce.id)],De=Ee?.status===`stopping`,Oe=Ee?.status===`waiting-for-preview`,ke=Ee?T.get(Ee.directory)?.tabs.find(e=>e.id===Ee.tabId)?.previewUrl??null:null,Ae=!!(Ee&&ke),je=()=>{!Ee||!ke||w(Ee.directory,ke)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:te||De,className:Y(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:be,"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-5 w-5`})}),Ae?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:je,children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)($r,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(yi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(xi,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Md?`search`:Su[t]||`play`,r=bu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:Y(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:be,disabled:te||De,className:Y(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(Ee?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:Ce.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:De||Oe?(0,$.jsx)(Z,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):Ee?(0,$.jsx)(Z,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(Z,{name:Te,className:`h-4 w-4`})})}),Ae?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:je,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(Z,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)($r,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Si,{children:[(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(yi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:Se,children:[(0,$.jsx)(Z,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(xi,{}),ge.map(e=>{let t=e.icon||`play`,n=e.id===Md?`search`:Su[t]||`play`,r=bu(fe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>{xe(e,!0)},children:[(0,$.jsx)(Z,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(Z,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(Z,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function zd(){}function Bd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Vd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Hd=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Ud=Q.memo(function(e){let t=(0,Au.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??Vd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=Y(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(Z,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ti,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Wd=Q.memo(function(e){let t=(0,Au.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Mr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=Y(Vd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(vi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(xi,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(bi,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(Z,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(Z,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(yi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Si,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(Z,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Gd=Q.memo(function(e){let t=(0,Au.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Mr(),E=Q.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=K(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(_i,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Bs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Dl,{})]})}):null,(0,$.jsx)(Ha,{embedded:!0,open:i&&s===`instance`,onOpenChange:tf,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(Vc,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:qd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Bs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(Ds,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Ll(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:$s(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-tc(s.elapsedRatio):tc(s.elapsedRatio),l=Zs(i.valueLabel,o),u=Qs(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Q.Fragment,{children:[a?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ec(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(mu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(au,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(Ai,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(ki,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Oi,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=$s(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-tc(a.elapsedRatio):tc(a.elapsedRatio),s=Zs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Ws(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(mu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(au,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(yi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Si,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Kd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),qd=(e,t)=>{if(!e)return`-`;try{return Hs(e,t,{fallback:`-`})}catch{return`-`}},Jd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Yd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Xd=e=>{let t=(0,Au.c)(3),n=Qt(nf),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Zd,{...e,hostId:n}):(0,$.jsx)(ef,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Zd=e=>{let t=(0,Au.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=yt(),a=Er(!0),o=Dr(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(ef,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},Qd=Q.memo(e=>{let t=(0,Au.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:mt,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=vt(s,wt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),$d=Q.memo(e=>{let t=(0,Au.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Q.useSyncExternalStore(Ze,Xe,Xe),c;t[0]===o?c=t[1]:(c=Ye(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?nt(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):rf,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Q.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=hn(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=vt(b,wt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=dr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=st([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=qe(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(nc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),ef=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Mr(),l=q(e=>e.setSessionSwitcherOpen),d=q(e=>e.toggleSidebar),f=q(e=>e.isSidebarOpen),m=q(e=>e.toggleBottomTerminal),_=q(e=>e.toggleContextPanel),b=q(e=>e.openContextOverview),x=q(e=>e.openContextBrowser),S=q(e=>e.closeContextPanel),C=q(e=>e.activeMainTab),E=q(e=>e.setActiveMainTab),O=q(e=>e.shortcutOverrides),k=q(e=>e.timeFormatPreference),A=kn(e=>e.getCurrentModel),j=Ct(),M=Bn(e=>!!e.newSessionDraft?.open),N=Bn(e=>e.currentSessionId),P=Qt(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),F=!!P?.hostId,L=wn(e=>e.remoteSession),z=P?.hostId&&L?.projectId===P.id&&L.location.hostId===P.hostId&&(!P.hubId||L.location.hubId===P.hubId)?L:null,B=F?z?.sessionId??null:N,V=F?!z?.sessionId:M,te=Rn(F?``:B??``),ne=sn(F?null:B),re=Qt(e=>e.projects),ie=Q.useMemo(()=>{if(!F)return ne;let e=z?.location.directory??P?.path,t=P?.hubId??s?.hubId,n=P?.hostId;if(!(!e||!t||!n||Ft(re,t,n,e,a?.worktrees)?.id!==P?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===B&&t.directory===e)},[F,ne,z?.location.directory,P,s?.hubId,re,a,B]),ae=Q.useMemo(()=>{if(!P)return null;let e=P.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[P]),H=Ys(e=>e.results),W=Ys(e=>e.fetchAllQuotas),le=Ys(e=>e.isLoading),ue=Ys(e=>e.lastUpdated),de=Ys(e=>e.displayMode),fe=Ys(e=>e.showPredValues),pe=Ys(e=>e.dropdownProviderIds),me=Ys(e=>e.loadSettings),he=Ys(e=>e.setDisplayMode),{isMobile:ge}=di(),_e=Fs().data??null,ve=Ml(e=>e.setStatus),ye=Q.useRef(null),[be,xe]=Q.useState(()=>typeof window>`u`?!1:y()),Se=Q.useMemo(()=>I(),[]),Ce=be&&w()===`win32`,we=ui(),Te=Lu(),Ee=Q.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:De,side:Oe}=ac(),ke=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Q.useEffect)(()=>{typeof window>`u`||xe(y())},[]);let Ae=A(),je=Ae&&typeof Ae.limit==`object`&&Ae.limit!==null?Ae.limit:null,Ne=je&&typeof je.context==`number`?je.context:0,Pe=je&&typeof je.output==`number`?je.output:0,Fe=pr(F?``:B??``,Ne,Pe),G=V?null:Fe,[Ie,Le]=Q.useState(null),Re=!B||te;(0,Q.useEffect)(()=>{if(!B){Le(e=>e===null?e:null);return}if(G){Le(e=>Kd(e,G)?e:G);return}Re&&Le(e=>e===null?e:null)},[G,B,Re]);let ze=q(e=>e.isSessionSwitcherOpen),Be=_e?.connected?_e.user?.avatarUrl??null:null,Ve=_e?.connected?_e.user?.login??null:null,He=_e?.accounts??[],[Ue,We]=Q.useState(!1),[Ge,Ke]=Q.useState(!1),[qe,Je]=Q.useState(!1),[Ye,Xe]=Q.useState(!1),[Ze,Qe]=Q.useState(`Local`),[$e,et]=Q.useState(!1),[tt,nt]=Q.useState(be?`instance`:`usage`),[rt,it]=Q.useState(`usage`);(0,Q.useEffect)(()=>{!be&&tt===`instance`&&nt(`usage`)},[tt,be]);let at=Q.useMemo(()=>D(),[]),ot=!at&&C===`chat`&&!!Ie,st=Ie&&Ie.contextLimit>0?Math.min(999,Ie.totalTokens/Ie.contextLimit*100):0,ct=K(async()=>{if(!(typeof window>`u`||!be))try{if(T()){Qe(`Local`),et(!1);return}let e=u(),t=await se();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?oe(n,U(e)):!1);if(h()!==n)return;if(et(!!n),a?.label?.trim()){Qe(ce(a.label.trim()));return}Qe(`Instance`)}catch{Qe(`Local`),et(!1)}});(0,Q.useEffect)(()=>{ct()},[be]),qs();let lt=Ys(e=>e.selectedModels),ut=Ys(e=>e.expandedFamilies),dt=Ys(e=>e.toggleFamilyExpanded),ft=Q.useMemo(()=>{let e=[];for(let t of Xs(H)){if(!pe.includes(t.id))continue;let n=H.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Il(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=lt[t.id]??[],n=e.length>0,r=Js(i,t.id),a=Ks(t.id),s=Gs(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,H,lt,c]),pt=ft.length>0;Q.useEffect(()=>{me()},[me]);let mt=Q.useCallback(async e=>{he(e);try{await Me({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[he]),ht=Q.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([W(),e]).finally(()=>{Xe(!1)})},[W,Ye]),gt=Bn(e=>F||!B?``:e.worktreeMetadata.get(B)?.path??``),_t=Q.useMemo(()=>Jd(gt||``),[gt]),vt=Q.useMemo(()=>Jd((typeof ie?.directory==`string`?ie.directory:``)||``),[ie?.directory]),yt=Bn(e=>e.newSessionDraft?.open?Jd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),bt=Q.useMemo(()=>F?z?.location.directory??P?.path??``:_t||vt||yt,[F,z?.location.directory,P?.path,yt,vt,_t]),xt=Hi(),St=z?ee(z.location):P?.hostId&&P.hubId?ee({hubId:P.hubId,hostId:P.hostId,directory:xt??P.path}):``,wt=Q.useMemo(()=>F?St:Jd(xt||bt||P?.path||``),[F,St,P?.path,xt,bt]),Tt=q(e=>Vt(e,wt)),Et=!!Tt?.isOpen,Dt=K(()=>_(wt)),Ot=Q.useMemo(()=>{if(!B)return ae??`Yuri`;let e=ie?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ae,ie?.title,B]),kt=Q.useMemo(()=>F?bt:Jd(bt||P?.path||``),[F,P?.path,bt]),At=Q.useMemo(()=>P?{id:P.id,path:P.path,hostId:P.hostId,hubId:P.hubId}:null,[P]),jt=Q.useRef(null);Q.useEffect(()=>{!At||!kt||(jt.current={projectRef:At,directory:kt})},[kt,At]);let Mt=Q.useMemo(()=>At&&kt?{projectRef:At,directory:kt}:jt.current,[kt,At]),Nt=Q.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=j.github?await j.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ve(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,j.github,ve]),It=Q.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Lt=Q.useCallback(()=>{if(ge){It(),l(!ze);return}d()},[It,ge,ze,l,d]),Rt=Q.useCallback(()=>{F||v(`desktop_open_draft_mini_chat_window`,{directory:Jd(bt||P?.path||``),projectId:P?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[F,P?.id,P?.path,bt]),zt=Q.useCallback(()=>{if(!F){if(V){Rt();return}B&&v(`desktop_open_session_mini_chat_window`,{sessionId:B,directory:Jd(bt||P?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[F,P?.path,B,Rt,V,bt]),Bt=Q.useCallback(()=>{let e=wt;if(e){if(Yd(Tt)===`context`){S(e);return}b(e)}},[S,wt,Tt,b]),Ht=Q.useMemo(()=>wt?Yd(Tt)===`context`:!1,[wt,Tt]),Ut=Q.useCallback(()=>{let e=wt;if(e){if(Yd(Tt)===`browser`){S(e);return}x(e)}},[S,wt,Tt,x]),Wt=Q.useMemo(()=>wt?Yd(Tt)===`browser`:!1,[wt,Tt]),Gt=Vd,Kt=Hd,qt=Q.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:C,[C,Ge,r,i]),Jt=Q.useCallback(()=>{Ke(!1),r&&e&&e(),i&&t&&t(),!e&&ze&&l(!1)},[ze,r,e,t,i,l]),Yt=Q.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Xt=Q.useCallback(()=>{i||Ke(!1),t?.()},[t,i]),Zt=Q.useMemo(()=>be&&Ee&&!Te?`5.5rem`:we?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!be||De)&&!at?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[be,Te,Ee,we,at,De]);(0,Q.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Zt)},[Zt]);let $t=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,en=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,tn=Q.useMemo(()=>!be||!Ee||ke===null?``:ke>=26?`h-12`:ke<=15?`h-14`:``,[be,Ee,ke]),nn=Q.useMemo(()=>{if(!(be&&!De||at))return{paddingRight:Et?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[be,at,Et,De]),rn=K(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Pt(ye,([e])=>{e&&rn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Q.useLayoutEffect(()=>{rn(ye.current?.getBoundingClientRect().height)},[rn,ge,tn]);let an=Q.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&be&&await R()},[be]),on=Q.useMemo(()=>{if(ge){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[ge,c]),cn=Q.useCallback(e=>xa(wa(e,O)),[O]);(0,Q.useEffect)(()=>{!ge&&(C===`git`||C===`terminal`||C===`diff`||C===`files`)&&E(`chat`)},[C,ge,E]);let ln=Q.useMemo(()=>{let e=[];return be&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(Z,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}),e},[be,c]),un=Q.useMemo(()=>ln.map(e=>({id:e.value,label:e.label,icon:e.icon})),[ln]),dn=Q.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),fn=Q.useMemo(()=>dn.map(e=>({id:e.value,label:e.label})),[dn]),pn=Q.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}],[c]);(0,Q.useEffect)(()=>{let e=e=>{if(lr(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=on.length&&(e.preventDefault(),ge&&(It(),Jt()),E(on[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[It,Jt,ge,E,on]);let mn=K(e=>{nt(e),Je(!0),ct(),e===`usage`&&ue===null&&W()});(0,Q.useEffect)(()=>{let e=e=>{let t=wa(`toggle_services_menu`,O);if(Ca(e,t)){e.preventDefault();let t=Bd({isOpen:qe,activeTab:tt,targetTab:be?`instance`:`usage`});t.open?mn(t.tab):Je(!1);return}let n=wa(`cycle_services_tab`,O);if(Ca(e,n)){e.preventDefault();let t=ln.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(tt),r=t[n===-1?0:(n+1)%t.length];nt(r),Je(!0),ct(),r===`usage`&&ue===null&&W();return}let r=wa(`open_usage`,O);if(Ca(e,r)){e.preventDefault();let t=Bd({isOpen:qe,activeTab:tt,targetTab:`usage`});t.open?mn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O,be,qe,tt,ln,ue,W,ct,mn]);let hn=e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(ju,{size:e}):r?(0,$.jsx)(Z,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e.id),className:Y(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!ge&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[ge?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Q.Fragment,{children:o},e.id)},gn=!F&&Se&&(V||!!B),_n=Q.useCallback(e=>{window.setTimeout(e,0)},[]),vn=Q.useCallback(e=>{mn(e)},[mn]),yn=Q.useRef(null),bn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:yn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Si,{children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:Y(Gt,`text-muted-foreground`),children:(0,$.jsx)(Z,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(yi,{align:`start`,className:`min-w-[14rem]`,children:[gn?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(zt),children:[(0,$.jsx)(Z,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(V?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,be?(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`instance`)),children:[(0,$.jsx)(Z,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Ze})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`toggle_services_menu`)})]}):null,(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(()=>vn(`usage`)),children:[(0,$.jsx)(Z,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`open_usage`)})]}),(0,$.jsx)(xi,{}),(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(m),children:[(0,$.jsx)(Z,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:cn(`toggle_terminal`)})]}),(0,$.jsxs)(bi,{className:`flex items-center gap-2`,onClick:()=>_n(Ut),children:[(0,$.jsx)(Z,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Wt?(0,$.jsx)(Z,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Gd,{isDesktopApp:be,currentInstanceSupportsUpdate:$e,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:ct,desktopServicesTab:tt,setDesktopServicesTab:nt,fetchAllQuotas:W,servicesTabItems:un,quotaLastUpdated:ue,quotaDisplayMode:de,showPredValues:fe,quotaDisplayTabItems:fn,handleDisplayModeChange:mt,handleUsageRefresh:ht,isQuotaLoading:le,isUsageRefreshSpinning:Ye,hasRateLimits:pt,rateLimitGroups:ft,expandedFamilies:ut,toggleFamilyExpanded:dt,timeFormatPreference:k,anchorRef:yn})]}),xn=(0,$.jsxs)($.Fragment,{children:[!F&&!ge&&!at&&C===`chat`?(0,$.jsx)(Bu,{}):null,F?null:(0,$.jsx)(vd,{directory:kt}),be&&(0,$.jsx)(qu,{open:qe&&tt===`instance`,onClick:()=>mn(`instance`)}),(0,$.jsx)(Ud,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:cn(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Et,onClick:Dt,className:Y(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Et?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Wd,{isMobile:ge,githubAuthStatus:_e,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Nt})]}),Sn=()=>(0,$.jsxs)(`div`,{onMouseDown:an,className:Y(`app-region-drag relative flex h-12 select-none items-center pr-3`,tn),style:nn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ic,{scopeProjectId:F?P?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:V?c(`sessions.switcher.draftTitle`):F&&s&&z?.sessionId?(0,$.jsx)(Qd,{entry:s.resolve(z.location),sessionId:z.sessionId,fallback:Ot},ee(z.location)):Ot})})}),F?(0,$.jsxs)(`span`,{"data-remote-header-host":P?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&P?.hostId?(0,$.jsx)(Ro,{registry:s,hostId:P.hostId}):null]}):null]}),on.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:on.map(e=>hn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[bn,F&&!at&&C===`chat`&&s&&z?.sessionId?(0,$.jsx)($d,{entry:s.resolve(z.location),sessionId:z.sessionId,onClick:Bt,pressed:Ht},ee(z.location)):null,ot&&Ie?(0,$.jsx)(nc,{pending:Ie.pending,totalTokens:Ie.totalTokens,percentage:st,colorPercentage:Ie.percentage,contextLimit:Ie.contextLimit,outputLimit:Ie.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Bt,pressed:Ht}):null,xn,(0,$.jsx)(rc,{visible:De&&Oe===`right`&&!Et,position:`right`})]})]})]}),Cn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Yt,className:Y(Kt,qt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(Z,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Lt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(Z,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[F?(0,$.jsxs)(`span`,{"data-remote-header-host":P?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&P?.hostId?(0,$.jsx)(Ro,{registry:s,hostId:P.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:on.map(e=>{let t=C===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ge&&(It(),Jt()),E(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:Y(Kt,`relative rounded-lg`,qt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(ju,{className:`h-5 w-5`}):r?(0,$.jsx)(Z,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Tu,{mobile:!0}),Mt&&(0,$.jsx)(Ld,{projectRef:Mt.projectRef,directory:Mt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Si,{open:Ge,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),Ke(n),n&&ue===null&&W()},children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:Y(Kt,qt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(Z,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(yi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Bs,{items:pn,activeId:rt,onSelect:e=>{let t=e;it(t),t===`usage`&&ue===null&&W()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(Z,{name:`close`,className:`h-5 w-5`})})]})}),rt===`mcp`&&(0,$.jsx)(Vc,{active:Ge&&rt===`mcp`}),rt===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:qd(ue,k)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`usage`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>mt(`remaining`),className:Y(`typography-ui-label px-1 pb-0.5 transition-colors`,de===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:ht,disabled:le||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(Z,{name:`refresh`,className:Y(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!pt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:ft.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(Ds,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Ll(e.entries,r),a=de===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:$s(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:de===`remaining`?100-tc(o.elapsedRatio):tc(o.elapsedRatio),c=Zs(n.valueLabel,a),l=Qs(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,k);return(0,$.jsxs)(Q.Fragment,{children:[i?(0,$.jsx)(`div`,{className:Y(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:ec(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(mu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&fe?(0,$.jsx)(au,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(ut[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(Ai,{open:n,onOpenChange:()=>dt(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(ki,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Oi,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=de===`remaining`?n.remainingPercent:n.usedPercent,i=$s(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:de===`remaining`?100-tc(i.elapsedRatio):tc(i.elapsedRatio),o=Zs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Ws(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(mu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&fe?(0,$.jsx)(au,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:Y(Kt,`relative`,qt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(Z,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),Tn=Y(`header-safe-area relative z-10 bg-background`,Ce&&`bg-[var(--surface-background)] backdrop-blur-none`,ge&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:ye,className:Tn,style:{"--padding-scale":`1`},children:ge?Cn():Sn()})})};function tf(){}function nf(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function rf(){}var af=180,of=640,sf=110,cf=e=>{let t=(0,Au.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Mr(),o=q(lf),s=q(uf),c=q(df),l=q(ff),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),m=Q.useRef(null),h=Q.useRef(0),g=Q.useRef(o||300),_=Math.min(of,Math.max(af,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Q.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Q.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(of,Math.max(af,g.current+t));c(n)},t=()=>{p(!1),q.getState().bottomTerminalHeight<=sf&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Q.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=Y(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:Y(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=Y(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function lf(e){return e.bottomTerminalHeight}function uf(e){return e.isBottomTerminalExpanded}function df(e){return e.setBottomTerminalHeight}function ff(e){return e.setBottomTerminalOpen}var pf=260,mf=260,hf=500,gf=e=>Math.min(hf,Math.max(mf,e)),_f=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Mr(),o=q(e=>e.sidebarWidth),s=q(e=>e.setSidebarWidth),[c,l]=Q.useState(!1),u=Q.useRef(0),d=Q.useRef(o||pf),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g=K(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Q.useEffect(()=>{t&&c&&l(!1)},[t,c]),Q.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(hf,Math.max(mf,o||pf)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=gf(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=gf(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:Y(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:Y(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:Y(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Mo,{children:n})})]})]})},vf=()=>{let e=(0,Au.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},yf=e=>{let t=(0,Au.c)(26),{className:n}=e,{t:r}=Mr(),i=q(bf),a=gu(xf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(Sf);if(Q.useEffect(()=>{c&&io()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=Y(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=J,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=Y(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(Ao,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:Y(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Tl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function bf(e){return e.openSettingsAtItem}function xf(e){return e.sidebarBrandName}function Sf(e){return e!==`Yuri`}var Cf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,wf=()=>{let e=(0,Au.c)(50),{t}=Mr(),n=Qt(Tf),r=wn(Ef),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ee(i.location):n?.hostId&&n.hubId?ee({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=q(Df),c=q(Of),l=q(kf),u=q(Af),d=gu(jf),f=Q.useRef(null),p=xa(wa(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=ac(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=y(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!D()&&!_&&ie(),e[4]=b):b=e[4];let x=b,S=Nf,C,w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},w=[],e[5]=C,e[6]=w):(C=e[5],w=e[6]),Q.useEffect(C,w);let T=o||void 0,E=x&&s?`${c||260}px`:void 0,O;e[7]===E?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:E},e[7]=E,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=Y(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(yf,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(rc,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:Y(Cf,`shrink-0`),children:(0,$.jsx)(Z,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)($r,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(al,{}):null,e[19]=v,e[20]=P);let F=ti,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=Y(Cf,`group shrink-0`),R=(0,$.jsx)(Z,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let B=$r,V=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),te;e[28]===V?te=e[29]:(te=(0,$.jsx)(`p`,{children:V}),e[28]=V,e[29]=te);let ne;e[30]!==B||e[31]!==te?(ne=(0,$.jsx)(B,{children:te}),e[30]=B,e[31]=te,e[32]=ne):ne=e[32];let re;e[33]!==F||e[34]!==z||e[35]!==ne?(re=(0,$.jsxs)(F,{children:[z,ne]}),e[33]=F,e[34]=z,e[35]=ne,e[36]=re):re=e[36];let ae;e[37]!==P||e[38]!==re?(ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,re]}),e[37]=P,e[38]=re,e[39]=ae):ae=e[39];let H;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ae?(H=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ae]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ae,e[45]=H):H=e[45];let U;return e[46]!==H||e[47]!==T||e[48]!==O?(U=(0,$.jsx)(`div`,{"data-titlebar-location":T,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:H}),e[46]=H,e[47]=T,e[48]=O,e[49]=U):U=e[49],U};function Tf(e){return e.projects.find(t=>t.id===e.activeProjectId)}function Ef(e){return e.remoteSession}function Df(e){return e.isSidebarOpen}function Of(e){return e.sidebarWidth}function kf(e){return e.toggleSidebar}function Af(e){return e.shortcutOverrides}function jf(e){return e.sidebarBrandName.trim().length>0}function Mf(e){console.warn(`[titlebar] failed to open app menu`,e)}function Nf(e){let t=e.currentTarget.getBoundingClientRect();v(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Mf)}var Pf=(e,t)=>{let n=Mt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},Ff=(e,t,n=10)=>{let r=jt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=jt(t.path);if(!e||i.has(e))continue;let o=Pf(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},If=e=>e.some(e=>!!jt(e)),Lf=(e,t)=>{let n=new Set(t.map(e=>jt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},Rf=(e,t,n)=>t.length===0?e.length===0:Lf(e,t).length>0?!1:t.every(e=>n.has(jt(e))),zf=ya(()=>It(()=>import(`./ToolOutputDialog-Bk8GsZTN.js`).then(e=>e.n),__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]))),Bf=e=>{let t=Uf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},Vf=e=>{let t=(0,Au.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Q.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Hf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Uf=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},Wf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Gf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Kf=(e,t)=>{let n=Uf(t),r=Uf(e);if(!n||!r)return!1;let i=Gf(n),a=Gf(r);return a===i||a.startsWith(`${i}/`)},qf=(e,t)=>{let n=Uf(t),r=Uf(e);if(!Kf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Jf=(e,t)=>{if(!t)return``;let n=Uf(t);if(!e||!Kf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Yf=new Set([`node_modules`]),Xf=e=>{let t=(0,Au.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Zf=e=>{let t=(0,Au.c)(11),{name:n}=e,r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Q.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},Qf=e=>Yf.has(e),$f=e=>{let t=Uf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},ep=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},tp=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},np=2e5,rp=`yuri:files:auto-save-enabled`,ip=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
4
4
  `:`
5
5
  `},ap=e=>e.replace(/\r\n/g,`
6
6
  `).replace(/\r/g,`
@@ -166,4 +166,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p
166
166
  `+e}return r}function Pb(e,t){let n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function Fb(e,t){let n=await _(t,e);if(n)return n;if(!D())return null;try{let n=await H()?.vscode?.saveMarkdown?.({fileName:t,content:e});if(!n||n.saved!==!0)return null;let r=typeof n.path==`string`?n.path.trim():``;return r.length>0?r:null}catch{return null}}async function Ib(e){let t=H()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await E(e)?!0:k(e)}function Lb(){return tr()}function Rb(e){return`${(e?.trim()||`session`).normalize(`NFKC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`session`}-${new Date().toISOString().split(`T`)[0]}.md`}function zb(e){let t=(0,Au.c)(35),{session:n,title:r,projectLabel:i,project:a,branch:o,directory:s,time:c}=e,{t:l}=Mr(),d;t[0]===s?d=t[1]:(d=e=>s?e.directories.get(s)?.status?.current:void 0,t[0]=s,t[1]=d);let f=Zi(d),m;t[2]!==s||t[3]!==n.model?(m=e=>{let t=n.model;return t?e.directoryScoped[dn(s)]?.providers.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.id)?.name??t.id:null},t[2]=s,t[3]=n.model,t[4]=m):m=t[4];let g=kn(m),_;if(t[5]!==l){let e=wt.getQueryData([`desktop-host-inventory`,u()]),n=p(),r=h(),i=n.startsWith(`host:`)?n.slice(5):null,a=e?.hosts.find(e=>i?e.id===i:!!(r&&oe(r,U(e))));_=a?ce(a.label):T()?l(`desktopHostSwitcher.instance.local`):null,t[5]=l,t[6]=_}else _=t[6];let v=_,y=!!(o&&f&&f!==`HEAD`&&f!==o),b;t[7]===r?b=t[8]:(b=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:r}),t[7]=r,t[8]=b);let x;t[9]===c?x=t[10]:(x=(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:c}),t[9]=c,t[10]=x);let S;t[11]!==b||t[12]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[11]=b,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==a||t[15]!==i?(C=i?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(gl,{project:a}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:i})]}):null,t[14]=a,t[15]=i,t[16]=C):C=t[16];let w;t[17]===v?w=t[18]:(w=v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`computer`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:v})]}):null,t[17]=v,t[18]=w);let E;t[19]===o?E=t[20]:(E=o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:o})]}):null,t[19]=o,t[20]=E);let D;t[21]!==f||t[22]!==y||t[23]!==l?(D=y?(0,$.jsxs)(`div`,{className:`flex items-start gap-2 typography-meta text-status-warning`,children:[(0,$.jsx)(Z,{name:`error-warning`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:l(`sessions.sidebar.session.hover.differentBranch`,{branch:f??``})})]}):null,t[21]=f,t[22]=y,t[23]=l,t[24]=D):D=t[24];let O;t[25]===g?O=t[26]:(O=g?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:g})]}):null,t[25]=g,t[26]=O);let k;return t[27]!==n.id||t[28]!==D||t[29]!==O||t[30]!==S||t[31]!==C||t[32]!==w||t[33]!==E?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 text-left`,"data-session-hover-details":n.id,children:[S,C,w,E,D,O]}),t[27]=n.id,t[28]=D,t[29]=O,t[30]=S,t[31]=C,t[32]=w,t[33]=E,t[34]=k):k=t[34],k}var Bb=(e,t)=>{if(!t)return Array.from(e);let n=[],r=new Set;for(let i of e){r.has(i)||(r.add(i),n.push(i));let e=t.get(i);if(e)for(let t of e)r.has(t)||(r.add(t),n.push(t))}return n},Vb=le()((e,t)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{t().enabled||e({enabled:!0})},disable:()=>{e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{t().enabled?e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):e({enabled:!0})},toggleSelected:(n,r,i)=>{let a=t(),o=new Set(a.selectedIds),s=a.scopeKey,c=a.anchorId;r!==null&&a.scopeKey!==null&&r!==a.scopeKey?(o.clear(),s=r,c=null):s===null&&r!==null&&(s=r);let l=i&&i.length>0?[n,...i]:[n];if(o.has(n)){for(let e of l)o.delete(e);c===n&&(c=null)}else{for(let e of l)o.add(e);c=n}o.size===0?e({selectedIds:o,scopeKey:null,anchorId:null}):e({selectedIds:o,scopeKey:s,anchorId:c})},setRange:(n,r,i,a,o)=>{let s=t();if(i.length===0)return;let c=n&&i.includes(n)?n:i[0],l=i.indexOf(c),u=i.indexOf(r);if(l<0||u<0)return;let[d,f]=l<=u?[l,u]:[u,l],p=Bb(i.slice(d,f+1),o),m=a!==null&&s.scopeKey!==null&&a!==s.scopeKey?new Set:new Set(s.selectedIds);for(let e of p)m.add(e);e({selectedIds:m,scopeKey:a??s.scopeKey,anchorId:c})},replaceAll:(t,n)=>{if(t.length===0){e({selectedIds:new Set,scopeKey:null,anchorId:null});return}e({selectedIds:new Set(t),scopeKey:n,anchorId:t[0]??null})},clear:()=>{e({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{let r=t();if(r.selectedIds.size===0||n.length===0)return;let i=new Set(r.selectedIds);for(let e of n)i.delete(e);i.size!==r.selectedIds.size&&(i.size===0?e({selectedIds:i,scopeKey:null,anchorId:null}):e({selectedIds:i}))}})),Hb=!1,Ub=new Set,Wb=!1;function Gb(){for(let e of Ub)e()}function Kb(e){Hb!==e&&(Hb=e,Gb())}function qb(e){e.key===`Shift`&&Kb(!0)}function Jb(e){e.key===`Shift`&&Kb(!1)}function Yb(){Kb(!1)}function Xb(){Wb||typeof window>`u`||(Wb=!0,window.addEventListener(`keydown`,qb),window.addEventListener(`keyup`,Jb),window.addEventListener(`blur`,Yb))}function Zb(e){return Xb(),Ub.add(e),()=>{Ub.delete(e)}}function Qb(){return Hb}function $b(){return!1}function ex(){return(0,Q.useSyncExternalStore)(Zb,Qb,$b)}var tx=!1,nx=!1,rx=new Set;function ix(){rx.forEach(e=>e())}function ax(e){tx!==e&&(tx=e,ix())}function ox(e){return In()?e.key===`Meta`:e.key===`Control`}var sx=(({setVisible:e,schedule:t=(e,t)=>setTimeout(e,t),cancel:n=e=>clearTimeout(e)})=>{let r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{press(){r||(r=!0,a(),i=t(()=>{i=null,r&&e(!0)},500))},release(){r=!1,a(),e(!1)}}})({setVisible:ax});function cx(e){ox(e)&&sx.press()}function lx(){sx.release()}function ux(e){ox(e)&&lx()}function dx(){document.visibilityState!==`visible`&&lx()}function fx(){nx||typeof window>`u`||(nx=!0,window.addEventListener(`keydown`,cx),window.addEventListener(`keyup`,ux),window.addEventListener(`blur`,lx),document.addEventListener(`visibilitychange`,dx))}function px(e){return fx(),rx.add(e),()=>rx.delete(e)}function mx(){return tx}function hx(){return!1}function gx(){return(0,Q.useSyncExternalStore)(px,mx,hx)}var _x=(e,t,n)=>{let r=e.session.title?.trim()||e.session.id;return`\n\n--- RESULT ${n+1}: ${r} ---\n${t.trim()}\n--- END RESULT ${n+1} ---`},vx=(e,t)=>Bn.getState().getWorktreeMetadata(e)?.projectDirectory??t,yx=e=>e.type===`assistant`?Xo(e.content??[]).trim():``,bx=async e=>{let t=e.directory??void 0,n=et(e.session.id,t);if(n.length===0&&e.directory){let t=await tt.withDirectory(e.directory,()=>tt.getSdkClient().message.list({sessionID:e.session.id,limit:50})),n=Array.isArray(t.data)?t.data:[];for(let e=n.length-1;e>=0;--e){let t=yx(n[e]);if(t)return t}return``}for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.role===`assistant`)return Xo($e(r.id,t)).trim()}return``};function xx({session:e,open:t,onOpenChange:n}){let{t:r}=Mr(),i=yn(),a=an(e=>e.activeSessions),o=an(e=>e.archivedSessions),s=kn(e=>e.providers),c=kn(e=>e.currentProviderId),l=kn(e=>e.currentModelId),u=kn(e=>e.currentAgentName),[d,f]=Q.useState(c??``),[p,m]=Q.useState(l??``),[h,g]=Q.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:$l()}]:[]),[_,v]=Q.useState(``),[y,b]=Q.useState(u??``),[x,S]=Q.useState([]),[C,w]=Q.useState(!1),T=Q.useMemo(()=>tu(e.title),[e.title]),E=Q.useMemo(()=>{let t=new Map;for(let e of i)t.set(e.id,e);for(let e of a)t.set(e.id,e);for(let e of o)t.set(e.id,e);return e.id&&t.set(e.id,e),Array.from(t.values())},[a,o,i,e]);Q.useEffect(()=>{if(!t||!T)return;let n=Bn.getState().getDirectoryForSession(e.id),r=vx(e.id,n),i=E.map(e=>{let t=tu(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=Bn.getState().getDirectoryForSession(e.id)??mn(e),i=vx(e.id,n);return r&&i&&r!==i?null:{session:e,directory:n,projectDirectory:i}}).filter(e=>e!==null).sort((e,t)=>(e.session.time?.created??0)-(t.session.time?.created??0));S(i)},[E,t,T,e.id]);let D=s.find(e=>e.id===d)?.models.find(e=>e.id===p),O=D?.variants?Object.keys(D.variants):[],k=!!(T&&d&&p&&x.length>0&&!C),A=Q.useCallback(e=>{g([e]),f(e.providerID),m(e.modelID),v(``)},[]),j=h[0]?.displayName||h[0]?.modelID||r(`multirun.fusion.model.placeholder`);return(0,$.jsx)(Zr,{open:t,onOpenChange:n,children:(0,$.jsxs)(Jr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(Kr,{children:[(0,$.jsx)(Yr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(Xr,{children:r(`multirun.fusion.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`max-w-full`,children:(0,$.jsx)(nu,{selectedModels:h,onAdd:A,onUpdate:(e,t)=>A(t),onRemove:()=>{g([]),f(``),m(``),v(``)},maxModels:1,addButtonLabel:j,showChips:!1,addButtonClassName:`h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`,dropdownSide:`bottom`,dropdownClassName:`w-[min(28rem,calc(100vw-8rem))]`,triggerIcon:d||p?(0,$.jsx)(Bo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(Ps,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(Ns,{size:`lg`,className:`h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5`,children:[(0,$.jsx)(Z,{name:`brain-ai-3`,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(As,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(Ms,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(js,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(js,{value:e,children:e},e))]})]}):null,(0,$.jsx)(eu,{value:y,onChange:b,portalToBody:!0,className:`h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-foreground`,children:r(`multirun.fusion.sources.label`,{count:x.length})}),(0,$.jsx)(`div`,{className:`max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1`,children:x.map(e=>{let t=tu(e.session.title);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta`,children:[(0,$.jsx)(Bo,{modelId:t?.modelID,providerId:t?.providerID,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.session.title||e.session.id}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(t=>t.filter(t=>t.session.id!==e.session.id)),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})})]},e.session.id)})})]}),(0,$.jsxs)(qr,{children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>n(!1),children:r(`multirun.fusion.actions.cancel`)}),(0,$.jsx)(J,{onClick:async()=>{if(!(!T||!d||!p)){w(!0);try{let e=await Promise.all(x.map(e=>bx(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){X.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=Ql(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([Ki(`session.fusion.visible`),Ki(`session.fusion.instructions`)]),c=await Bn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);Bn.getState().setCurrentSession(c.id,i),n(!1),await tt.sendMessage({id:c.id,providerID:d,modelID:p,variant:_||void 0,agent:y||void 0,text:o,additionalParts:[{text:s,synthetic:!0},...t.map((e,t)=>({text:_x(e.source,e.text,t),synthetic:!0})),{text:`
167
167
 
168
168
  --- FUSION INPUTS END ---
169
- Now write the final fused answer.`,synthetic:!0}],directory:i??tt.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function Sx(e){let t=(0,Au.c)(13),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=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:Cr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var Cx=e(xe(),1),wx=null,Tx=!1,Ex=(e,t=lo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:Qa(e):e,Dx=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},Ox=()=>{wx&&=(Dx(wx),null)},kx=(e,t)=>{Ox(),rr(!0);let n=Ex(e);if(!n)return;Tx=!0;let r;try{r=Rt(n.sessionId)}finally{Tx=!1}wx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Cx.flushSync)(()=>{lo.getState().setFocus(n)}),typeof window<`u`&&(wx.fallbackTimer=window.setTimeout(()=>{Ax(n)},150))},Ax=e=>{let t=wx,n=Ex(e);if(!t||!Ka(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{wx===t&&Lt()===t.intent&&(wx=null,Hn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{wx===t&&Lt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},jx=e=>{if(wx)return;let t=lo.getState();t.setFocus(Ex(e,t.focus))};zt(e=>{if(Tx)return;let t=wx;if(t?.intent===e)return;t&&Ox();let n=lo.getState();n.setFocus(Ex(e.sessionId,n.focus))});var Mx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Nx=Q.memo(function(e){let t=(0,Au.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=Y(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=Y(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:Kx,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ti,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Px=Q.memo(function(e){let t=(0,Au.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=ex(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=Y(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(Z,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:qx,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ti,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),Fx=Q.memo(function(e){let t=(0,Au.c)(3),{number:n}=e;if(!gx())return null;let r=In()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Li,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function Ix(e){let{t}=Mr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:y,toggleParent:b,handleSessionSelect:x,togglePinnedSession:S,handleShareSession:C,copiedSessionId:w,handleCopyShareUrl:T,handleUnshareSession:E,setOpenSidebarMenuKey:O,renamingFolderId:k,getFoldersForScope:A,getSessionFolderId:j,removeSessionFromFolder:M,addSessionToFolder:N,createFolderAndStartRename:P,handleDeleteSession:F,mobileVariant:L,alwaysShowActions:R,renderSessionNode:z,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:ee,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:ie,shortcutNumber:ae=null,settledSessionIds:H,setSessionSettled:U}=e,oe=!!B?.projectLabel,W=!!B?.branchLabel,se=en(e=>e.displayMode),ce=Q.useMemo(()=>D(),[]),le=se===`minimal`||ce,ue=Q.useMemo(()=>I(),[]),de=Q.useContext(At),me=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,ve=ce,be=V===`pinned`&&c.has(r.session.id),xe=!be&&!s&&!L&&!B?.slim,we=`h-5 w-5`,Te=`h-3.5 w-3.5`,Ee=(xe||be?1:0)+ +!!ve+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=R?ce?De:Ee>=2?`pr-12`:`pr-8`:De,Ae=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(f);Pe.current=f;let Fe=Q.useRef(null),[G,Ie]=Q.useState(m),[Le,Re]=Q.useState(f===r.session.id),ze=Q.useRef(null),Be=Q.useRef(null),Ve=Q.useRef(null),He=r.session,Ue=ie.get(He.id)??He,We=!!Ue.metadata?.yuri?.assistant,Ge=dt(He.directory??null)??dt(a??null),Ke=Cn(Ge??void 0,{bootstrap:!1}),qe=fs(),Xe=Vb(e=>e.enabled),Ze=Vb(Q.useMemo(()=>e=>e.selectedIds.has(He.id),[He.id])),Qe=Vb(e=>e.toggleSelected),$e=Vb(e=>e.setRange),[et,tt]=Q.useState(!1),[rt,at]=Q.useState(!0),[ot,st]=Q.useState(!1),[ct,lt]=Q.useState(!1),ut=`${V}:${s?`archived`:`active`}:${He.id}`,ft=_r(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(bn(He.id))?.isZombie,[He.id])),pt=zn(He.id),mt=ar(He.id,Ge??void 0,{bootstrap:!1}),ht=$n(He.id,Ge??void 0,{bootstrap:!1}),gt=Q.useMemo(()=>({scope:V,sessionId:He.id,projectId:o??null}),[o,V,He.id]),_t=Q.useMemo(()=>Za(gt)??``,[gt]),vt=Q.useRef(null),yt=lo(Q.useMemo(()=>e=>Ka(e.focus,gt),[gt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=vt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):gb(e)),Ax(gt)},[yt,L,gt]);let bt=Ue.title||t(`sessions.sidebar.session.untitled`),xt=sc(oc(Ue)),St=Ue.metadata?.yuri?.titleRefresh,Ct=typeof St?.lastError==`string`?St.lastError:null,wt=typeof St?.failedAt==`number`?St.failedAt:null;Q.useEffect(()=>{!Ct||wt===null||console.warn(`[session-title] generation failed for ${He.id}: ${Ct}`)},[He.id,Ct,wt]);let Tt=typeof St?.generationExpiresAt==`number`&&Number.isFinite(St.generationExpiresAt)?St.generationExpiresAt:0,[Et,Dt]=Q.useState(0),Ot=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,kt,jt]=Nt(()=>Dt(Tt),Ot,{immediate:!1}),Mt=St?.isGenerating===!0;Q.useEffect(()=>(Mt&&Tt>Date.now()&&kt(),jt),[Mt,Tt,kt,jt]);let Pt=r.children.length>0||!!(Ue.hasChildren??He.hasChildren),Ft=c.has(He.id),It=!!H?.has(He.id),Lt=ut,Rt=u?!0:l.has(Lt),zt=!!Ue.parentID,q=V===`pinned`,Bt=on(He.id),Vt=Bt>0&&!zt,Ht=or(Ue)||Date.now(),Ut=bo(Ht),Wt=ko(Ht),[Gt,Kt]=Q.useState(!1),[qt,Jt]=Q.useState(!1),Yt=Gt,Zt=Q.useMemo(()=>tu(Ue.title)!==null,[Ue.title]),[Qt,$t]=Q.useState(!1),tn=Q.useMemo(()=>Mx(r).length,[r]),nn=K(e=>{let t=Ge??``,n=(Ye()??it(t,Ke)).getTranscript(nt(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return Xt({sessionID:e,messages:Je(n),parts:n.partsByMessageID,revertMessageID:r}).list}),rn=K(async e=>{let n=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=nn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await rn(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Mx(i).length+1}return{children:n,skipped:r}}),an=K(e=>{e<=0||X.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),sn=K(async e=>{if(!Ge){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(He.id);let n=nn(He.id);if(n.length===0){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await rn(r.children);i=e.children,a=e.skipped}let o=Nb(n,Ue.title??null,i),s=Rb(Ue.title??null),c=await Fb(o,s);if(c){X.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Lb()),onClick:()=>{Ib(c).then(e=>{e||X.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),an(a);return}Pb(o,s),X.success(t(`sessions.sidebar.session.export.success`)),an(a)}),cn=K(async()=>{if(r.children.length>0){at(!0),tt(!0);return}await sn(!1)}),un=K(()=>{Ge&&v(`desktop_open_session_mini_chat_window`,{sessionId:He.id,directory:Ge,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==He.id){Le&&Re(!1),ze.current===He.id&&(ze.current=null);return}!Le||ze.current===He.id||(ze.current=He.id,Ie(m),queueMicrotask(()=>Ve.current?.select()))},[f,m,He.id,Le]);let dn=K(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,Re(!0),p(e),g(t)}}),fn=K(e=>{Kt(e)}),pn=K(e=>{e.preventDefault(),e.stopPropagation()}),mn=K(e=>{e.preventDefault(),e.stopPropagation()}),hn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(He.id)}),gn=!!U&&!!(B?.card||B?.slim)&&!s&&!zt,_n=K(e=>{if(e.preventDefault(),e.stopPropagation(),O(null),gn&&U){U(He.id,!It);return}F(He,{archivedBucket:s})}),vn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),F(He,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),yn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(He.id)}),xn=K(()=>{!Ge||ot||(st(!0),(async()=>{try{await qe.refreshSessionTranscript(He.id,{directory:Ge}),X.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{st(!1)}})())}),Sn=K(e=>{e.preventDefault(),e.stopPropagation()}),wn=K(e=>{e.preventDefault(),e.stopPropagation()}),En=K(e=>{e.preventDefault(),e.stopPropagation(),de?.vscode?.executeCommand(`yuri.openSessionInEditor`,He.id,bt)}),Dn=K(e=>{if(Ae.current){Ae.current=!1;return}if(Xe){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Vb.getState().anchorId,n=new Map;n.set(He.id,Mx(r)),$e(t,He.id,e,Ge??null,n);return}Qe(He.id,Ge??null,Mx(r));return}x(He.id,Ge,o,V)}),On=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;Dn(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!L&&(t.focus({preventScroll:!0}),je.current=!0)}),kn=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Xe)&&(Ae.current=!0)}),An=K(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Ne(!0)}),jn=K(e=>{L&&e.pointerType===`touch`&&Ne(!1)}),Mn=K(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(He.id),g(bt))}),Nn=K(e=>{if(Dn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Pn=K(()=>{je.current=!1}),Fn=K(()=>{!Rt&&!ct&&(lt(!0),qe.loadChildren(He.id,Ge).catch(()=>X.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>lt(!1))),b(Lt)});if(f===He.id&&Le){let e=async()=>{y();try{await Wn(He.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:vo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:Be,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(G)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||y()},children:[(0,$.jsx)(`input`,{ref:Ve,value:G,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){y();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),le?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Pt&&!q&&!zt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Ut}),oe?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,W?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})},He.id)}let In=pt,Ln=Mt&&Tt>Date.now()&&Et!==Tt,Rn=mt.length,Bn=ht.length>0,Hn=!Bn&&!In&&Vt,Un=!!B?.card,Gn=!!B?.slim,Kn=Bn||Rn>0,qn=!Kn&&In,Jn=yt||Ze,Yn=Un&&Hn,Xn=!Un&&(Bn||In||Hn),Zn=t(Bn?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),Qn=B?.runStartedAt??null,er=Kn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":Zn,title:Zn,children:[(0,$.jsx)(Z,{name:Bn?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:Zn})]}):qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)(Qc,{size:10,arcColor:`var(--status-info)`}),Qn===null?null:(0,$.jsx)(xl,{startedAt:Qn})]}):(0,$.jsx)(`span`,{className:Y(`text-[10px] leading-none tabular-nums`,Jn?`text-foreground/70`:`text-muted-foreground/70`),children:Wt}),tr=!R||ce,nr=tr?Y(`group-hover:invisible group-focus-within:invisible`,Yt&&`invisible`):Yt?`invisible`:``,rr=Bn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):In?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Qc,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),ir=!q&&!zt&&Pt,sr=ir&&!R&&!ct,cr=vo(Math.max(0,i-1)),lr=ir?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Rt,"aria-busy":ct,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Fn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Fn())},style:{minWidth:14,minHeight:14,left:cr},className:Y(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,le?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,sr?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(Rt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:ct?(0,$.jsx)(Qc,{size:12}):Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,ur=ft?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,dr=(0,$.jsx)(pe,{children:(0,$.jsx)(ke,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(k||Pe.current),style:{color:`var(--surface-elevated-foreground)`},className:Y(mi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>S(He.id),className:`[&>svg]:mr-1`,children:[Ft?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),zt?null:(0,$.jsxs)(e,{onClick:()=>{Bt>0?ln(He.id):Tn(He.id,Ge||void 0).catch(()=>X.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:Bt>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(Bt>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Fe.current={id:He.id,title:bt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Vn()&&!Ue.share?(0,$.jsxs)(e,{onClick:()=>C(Ue),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Vn()&&Ue.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ue.share?.url&&T(Ue.share.url,He.id)},className:`[&>svg]:mr-1`,children:w===He.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(He.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{cn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||ot,onClick:()=>{xn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:Y(`mr-1 h-4 w-4`,ot&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Zt?(0,$.jsxs)(e,{onClick:()=>$t(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Sx,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=A(Ge),s=j(Ge,He.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?M(Ge,He.id):N(Ge,t.id,He.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=P(Ge);e&&N(Ge,e.id,He.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{M(Ge,He.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,ue?(0,$.jsxs)(e,{disabled:!Ge,onClick:un,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:gn&&It?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>U?.(He.id,!1),children:[(0,$.jsx)(Z,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>gn&&U?U(He.id,!0):F(He,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>F(He,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(he,{className:Y(gi,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(ge,{className:Y(hi,e),...t}),Sub:_e,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(Se,{className:Y(pi,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(pe,{children:(0,$.jsx)(ke,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:Y(mi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Jc,{sessionId:He.id,sessionDirectory:Ge??null,sessionTitle:bt,children:(0,$.jsxs)(fe,{open:Gt,onOpenChange:fn,onOpenChangeComplete:dn,children:[(0,$.jsxs)(Ce,{render:(0,$.jsx)(Kc,{ref:vt,active:yt,selected:Ze,"data-session-row":He.id,"data-session-scope":Ge??``,"data-session-focus-scope":V,"data-session-focus-key":_t,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:On,className:Y(yt&&!Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!yt&&!Ze&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Gn&&`py-1`)}),children:[lr,(0,$.jsx)(Wc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ti,{onOpenChange:Jt,children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsxs)(Sc,{type:`button`,"data-session-title":!0,onPointerDown:An,onPointerUp:jn,onPointerCancel:jn,onMouseDown:kn,onKeyDown:Mn,onBlur:Pn,onClick:Nn,onDoubleClick:e=>{e.stopPropagation(),!L&&I()&&un()},className:Y(Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Un&&`gap-0.5`,!Un&&Oe),children:[Un?(0,$.jsxs)(`div`,{className:Y(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,Oe),children:[(0,$.jsx)(gl,{project:B?.project}),Yn&&!Kn?(0,$.jsx)(Zc,{}):null,(0,$.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate typography-micro leading-4`,Jn?`text-foreground/80`:`text-muted-foreground`),children:B?.projectLabel}),(0,$.jsx)(`span`,{className:Y(`shrink-0`,nr),children:er})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Gn?(0,$.jsx)(gl,{project:B?.project}):null,(0,$.jsx)(`div`,{className:Y(`block min-w-0 flex-1 truncate text-foreground`,Gn?`typography-meta`:`typography-ui-label`,Gn&&!Jn&&`text-muted-foreground`,Yn?`font-medium`:`font-normal`,Ln&&`animate-text-shimmer`),"aria-busy":Ln||void 0,children:go(bt,d)}),xt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:xt}):null,Gn?(0,$.jsx)(`span`,{className:Y(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,nr),children:Wt}):null,We?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Rn>0&&!Un?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Rn})]}):null,Xn?(0,$.jsx)(`span`,{className:Y(`inline-flex shrink-0 items-center justify-center transition-none`,tr?Y(`group-hover:hidden group-focus-within:hidden`,Yt?`hidden`:``):Yt?`invisible`:``),children:rr}):null,ae?(0,$.jsx)(Fx,{number:ae}):null]}),Un?(0,$.jsxs)(`div`,{className:Y(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Jn?`text-foreground/60`:`text-muted-foreground/60`),children:[W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B?.branchLabel})]}):B?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):B?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),Ft?(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),ce?null:(0,$.jsx)($r,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:qt?(0,$.jsx)(zb,{session:Ue,title:bt,time:Wt,projectLabel:B?.projectLabel,project:B?.project,branch:r.worktree?.branch??B?.branchLabel,directory:Ge}):null})]})})}),ur&&!L?(0,$.jsx)(`div`,{className:Y(`absolute top-1/2 -translate-y-1/2 z-10`,le?`right-0`:`right-[30px]`),children:ur}):null,(0,$.jsxs)(Cc,{visible:Yt||R&&!ce,className:Y(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Yt||R&&!ce?`opacity-100`:Y(`opacity-0`,me),Un&&`top-1.5 translate-y-0`),children:[xe?(0,$.jsx)(Nx,{pinned:Ft,pinLabel:t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:we,iconSizeClass:Te,onPointerDown:pn,onMouseDown:mn,onPin:hn}):null,be?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,we),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:pn,onMouseDown:mn,onClick:yn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,ve?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,we),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:Sn,onMouseDown:wn,onClick:En,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(Px,{archiveLabel:t(gn&&It?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:gn&&It,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:we,iconSizeClass:Te,revealClassName:le&&!R&&!Yt?Y(`opacity-0`,me):`opacity-100`,onPointerDown:pn,onMouseDown:mn,onArchive:_n,onDelete:vn})]})]}),dr]})}),!q&&Pt&&Rt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:ee,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return z(e,i+1,Ge??a,o,s,void 0,V,t)}):null,(0,$.jsx)(Zr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Kr,{children:[(0,$.jsx)(Yr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Xr,{children:t(tn===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:tn})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:rt,onChange:e=>at(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(qr,{children:[(0,$.jsx)(J,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,onClick:()=>{tt(!1),sn(rt)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Zt?(0,$.jsx)(xx,{session:Ue,open:Qt,onOpenChange:$t}):null]},He.id)}var Lx=e=>dt(e.session.directory??null),Rx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),zx=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},Bx=e=>e.menuOpenSessionId??zx(e),Vx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Nc(e.node,t):!1,Hx=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(Hx(e.children[a],t.children[a],n,r,i))return!0;return!1},Ux=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&bc(a)!==bc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Ux(e.children[i],t.children[i],n,r))return!0;return!1},Wx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Hx(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Hx(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},Gx=Q.memo(Ix,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||Lx(e.node)!==Lx(t.node)||!Rx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Ux(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Hx(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&Wx(e,t)||e.currentSessionId!==t.currentSessionId&&(Vx(e,e.currentSessionId,e.subtreeContainsActive)||Vx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Vx(e,e.editingId,e.subtreeContainsEditing)||Vx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Vx(e,e.editingId,e.subtreeContainsEditing)||Vx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Nc(e.node,e.copiedSessionId)||Nc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Bx(e),r=Bx(t);if(Nc(e.node,n)||Nc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Bx(e),r=Bx(t);if(Nc(e.node,n)||Nc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function Kx(e){return e.stopPropagation()}function qx(e){return e.stopPropagation()}function Jx(e){let t=(0,Au.c)(71),{t:n}=Mr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Zr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Jr,m=!1,h=`max-w-sm gap-5`,l=Kr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Yr,{children:a}),t[18]=a,t[19]=p),c=Xr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(qr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function Yx(e){let t=(0,Au.c)(57),{t:n}=Mr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Yr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Xr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Kr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(qr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Zr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Xx(e){let t=(0,Au.c)(36),{t:n}=Mr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Yr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Xr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Kr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(qr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Zr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Zx=e=>{let t=(0,Au.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Mr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Si,{children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(yi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(bi,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(bi,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(xi,{}),(0,$.jsxs)(bi,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(bi,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ti,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ti,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},Qx=e=>{let{t}=Mr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Vb(e=>e.enabled),d=Vb(e=>e.selectedIds.size),f=d>0,p=Vb(e=>e.selectedIds),m=Vb(e=>e.scopeKey),h=Q.useCallback(()=>{Vb.getState().toggleMode()},[]),g=Q.useCallback(()=>{Vb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)_l({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&Sl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Vb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Vb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Vb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Vb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},$x=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],eS=Q.memo(function(e){let t=(0,Au.c)(9),{value:n,onChange:r}=e,{t:i}=Mr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=$x.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:Y(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:Y(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),tS=e=>{let t=(0,Au.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`mr-3 typography-micro tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function nS(e){let t=(0,Au.c)(20),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Mr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(iS),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map(rS)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hc,{className:`size-20`}),t[4]=e):e=t[4];let n;t[5]===a?n=t[6]:(n=a(`sessions.sidebar.task.empty`),t[5]=a,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 pt-6 pb-2`,children:[e,(0,$.jsx)(`div`,{className:`${To} !text-center`,children:n})]}),t[7]=n,t[8]=r),r}let u;t[9]!==n.active||t[10]!==r?(u=n.active.map(r),t[9]=n.active,t[10]=r,t[11]=u):u=t[11];let d=u,f;t[12]!==l||t[13]!==n.active.length||t[14]!==i||t[15]!==d||t[16]!==s?(f=i&&n.active.length>1?(0,$.jsx)(zc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:aS,onSessionsReordered:i,children:d}):d,t[12]=l,t[13]=n.active.length,t[14]=i,t[15]=d,t[16]=s,t[17]=f):f=t[17];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`div`,{className:`-ml-1 -mr-1 space-y-0.5`,children:f}),t[18]=f,t[19]=p),p}function rS(e){return[e,null]}function iS(e){return e.node.session.id}var aS=()=>{};function oS(e){let t=(0,Au.c)(21),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Mr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Z,{name:`archive`,className:`-ml-1 mr-0.5 size-3.5 shrink-0 text-foreground/55`}),t[2]=d):d=t[2];let f;t[3]===n.settledTotal?f=t[4]:(f=(0,$.jsx)(tS,{count:n.settledTotal}),t[3]=n.settledTotal,t[4]=f);let p;t[5]!==i||t[6]!==r||t[7]!==u||t[8]!==f?(p=(0,$.jsx)(yy,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,leadingIcon:d,accessory:f}),t[5]=i,t[6]=r,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==n.settled||t[11]!==l||t[12]!==a||t[13]!==r||t[14]!==c||t[15]!==o||t[16]!==s?(m=r?(0,$.jsxs)(`div`,{className:`-ml-1 -mr-2 max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`box-border flex w-full items-center gap-[3px] rounded-md px-2 py-1.5 text-left typography-meta text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`-ml-0.5 size-4 shrink-0`}),s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})]}):null]}):null,t[10]=n.settled,t[11]=l,t[12]=a,t[13]=r,t[14]=c,t[15]=o,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}var sS={ids:[],baseline:{}},cS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,lS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!cS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},uS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},dS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=dt(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},fS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},pS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=fS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:fS(n,e,o,i)??s};function mS(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var hS=`yuri.sessions.sidebarView`,gS=`yuri.sessions.projectCollapse`,_S=`yuri.sessions.groupOrder`,vS=`yuri.sessions.groupCollapse`,yS=`yuri.sessions.activeSessionByProject`,bS=`yuri.sessions.expandedParents.v2`,xS=`yuri.sessions.expandedParents`,SS=ot(Ve()),CS=e=>{try{let t=SS.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},wS=e=>{try{let t=SS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},TS=e=>{try{let t=SS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},ES=(e,t,n)=>{let r=new Set;for(let t of e){let e=dt(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=dt(t.path)?.toLowerCase();e&&r.add(e)}return r},DS=(e,t,n)=>{if(e.time?.archived)return!0;let r=dt(mn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},OS=new Set,kS=[],AS={},jS=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},MS=Q.memo(function(e){let t=(0,Au.c)(3),{onOpenChange:n}=e,r=El(de(PS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(jl,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),NS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Mr(),[s,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[w,T]=Q.useState(new Set),E=Q.useMemo(()=>SS,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[M,N]=Q.useState(new Map),P=q(e=>e.isNewWorktreeDialogOpen),F=q(e=>e.setNewWorktreeDialogOpen),[I,L]=Q.useState(null),[R,z]=Q.useState(null),[B,V]=Q.useState(``),[ee,te]=Q.useState(null),[ne,re]=Q.useState(null),[ie,ae]=Q.useState(null),H=Sr(),U=$t(),oe=tl(),W=Yc(),se=fl(),ce=Kn(),le=q(e=>e.sidebarView),ue=q(e=>e.setSidebarView);Q.useEffect(()=>{let e=Ve().getItem(hS);e!==null&&(Ve().removeItem(hS),q.getState().sidebarView===`projects`&&_c(e)!==`projects`&&ue(_c(e)))},[ue]);let[de,fe]=Q.useState({settledOpen:!1,settledLimit:30}),pe=Q.useRef(new Map),me=Q.useRef(new Map),he=K(e=>{ue(e),Me({sidebarView:e})}),[ge,_e]=Q.useState(()=>CS(vS)),[ve,ye]=Q.useState(()=>TS(_S)),[be,xe]=Q.useState(()=>wS(yS)),Se=Q.useRef(null);Q.useEffect(()=>c(e=>{m(e)&&(Se.current=null,_e(CS(vS)),ye(TS(_S)),xe(wS(yS)),k(CS(gS)),T(CS(bS)))}),[]);let[Ce,we]=Q.useState(new Map),Te=Q.useRef(0),Ee=Fe(e=>e.homeDirectory),De=Fe(e=>e.currentDirectory),Oe=Fe(e=>e.setDirectory),ke=Qt(e=>e.projects),Ae=Q.useMemo(()=>ke.filter(e=>!e.hostId),[ke]),je=Q.useMemo(()=>ke.filter(e=>e.hostId).map(Tr),[ke]),[Ne,Pe]=Q.useState(()=>new Map),G=K((e,t)=>{Pe(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Ie=qc(a),[Le,Re]=Q.useState(new Map),ze=K((e,t)=>{Re(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),Be=Qt(e=>e.activeProjectId),He=Qt(e=>e.removeProject),Ue=Qt(e=>e.setActiveProjectIdOnly),We=Qt(e=>e.updateProjectMeta),Ge=Qt(e=>e.reorderProjectsById),Ke=q(e=>e.setActiveMainTab),qe=q(e=>e.activeMainTab),Je=Aa(),Ye=q(e=>e.setSettingsDialogOpen),Xe=q(e=>e.toggleHelpDialog),Ze=q(e=>e.setSessionSwitcherOpen),Qe=q(e=>e.setScheduledTasksDialogOpen),$e=q(e=>e.notifyOnSubtasks),et=q(e=>e.showDeletionDialog),tt=q(e=>e.setShowDeletionDialog),nt=ka(f,120),rt=Q.useMemo(()=>nt.trim().toLowerCase(),[nt]),it=rt.length>0,at=El(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ot=xn(e=>e.collapsedFolderIds),st=xn(e=>e.foldersMap),ct=xn(e=>e.sessionOrderByScope),lt=xn(e=>e.sessionOrderActivityByScope),ut=xn(e=>e.getFoldersForScope),ft=xn(e=>e.createFolder),pt=xn(e=>e.renameFolder),mt=xn(e=>e.deleteFolder),ht=xn(e=>e.addSessionToFolder),gt=xn(e=>e.addSessionsToFolder),_t=xn(e=>e.removeSessionFromFolder),vt=xn(e=>e.removeSessionsFromFolders),yt=xn(e=>e.toggleFolderCollapse),bt=xn(e=>e.getSessionFolderId),xt=xn(e=>e.reorderSessions);oy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let Ct=Q.useMemo(()=>new Map,[]),wt=yn({enabled:a,includeChildren:!0}),Tt=vc({enabled:a}),Et=Ic({enabled:a}),Dt=Dn(e=>a?e.index.session.unseenCount:AS),Ot=Q.useMemo(()=>D(),[]),kt=an(e=>e.status),At=an(e=>e.activeSessions),jt=an(e=>e.archivedSessions),Mt=an(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Nt=an(e=>e.archivedLoadingDirectories),Pt=Q.useDeferredValue(At),Ft=Q.useDeferredValue(jt),It=Bn(e=>e.currentSessionId),Bt=wn(e=>e.remoteSession!==null)?null:It,Vt=lo(e=>e.focus),Ht=Q.useSyncExternalStore(zt,Lt,Lt),Ut=Bn(e=>!!e.newSessionDraft?.open),Wt=Bn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),Gt=Q.useMemo(()=>!e&&qe===`chat`&&Wt&&Ht.sessionId===null?{projectId:Wt,revision:Ht.revision}:null,[e,qe,Wt,Ht]),Kt=Bn(e=>e.setCurrentSession),qt=Bn(e=>e.updateSessionTitle),Jt=Bn(e=>e.shareSession),Yt=Bn(e=>e.unshareSession),Xt=Bn(e=>e.worktreeMetadata),tn=Bn(e=>e.availableWorktreesByProject),rn=Bn(e=>e.openNewSessionDraft),on=K(t=>{let n=je.find(e=>e.id===(t?.selectedProjectId??Qt.getState().activeProjectId));if(n){lc(n,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),rn(t),Ot&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),sn=Q.useMemo(()=>ES(Ae,tn,{includeWorktrees:!Ot}),[tn,Ot,Ae]),cn=Q.useMemo(()=>{let e=new Map(wt.map(e=>[e.id,e])),t=Pt.map(t=>{let n=e.get(t.id);return n?Yn(n,t):t}),n=new Set(t.map(e=>e.id));return wt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>DS(e,sn,{allowUnknownDirectory:!Ot,allowEmptyDirectorySet:!Ot}))},[Pt,Ot,sn,wt]),ln=Q.useMemo(()=>wt.map(e=>{let t=dt(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[wt]),un=Q.useRef(wt);Q.useEffect(()=>{un.current=wt},[ln,wt]);let dn=Q.useMemo(()=>new Map(wt.map(e=>[e.id,e])),[wt]);Q.useEffect(()=>{let e=null,t=St(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=Qt.getState().projects.find(e=>e.id===t.projectId),n=dt(e?.path??null);if(!n)return;let r=[n];(Bn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),qn(r,un.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let fn=Q.useMemo(()=>y(),[]),pn=gu(e=>e.sidebarBrandName.trim().length>0),{isTablet:hn,isDesktop:_n}=di(),vn=e||hn,{buildGroupSearchText:bn,filterSessionNodesForSearch:Sn,buildGroupedSessions:Cn}=Dc({homeDirectory:Ee,worktreeMetadata:Xt,pinnedSessionIds:H,gitBranches:Ct,isVSCode:Ot}),{scheduleCollapsedProjectsPersist:Tn,hasRestoredProjectCollapse:En}=py({isVSCode:Ot,safeStorage:E,keys:{sessionExpanded:bS,sessionExpandedLegacy:xS,projectCollapse:gS,groupOrder:_S,projectActiveSession:yS,groupCollapse:vS},groupOrderByProject:ve,activeSessionByProject:be,collapsedGroups:ge,setExpandedParents:T,setCollapsedProjects:k}),On=Q.useMemo(()=>[...cn].sort((e,t)=>yo(e,t,H)),[cn,H]),kn=Q.useMemo(()=>{let e=new Map;return On.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>yo(e,t,H))),e},[On,H]),An=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),jn=Q.useMemo(()=>Ae.find(e=>e.id===S)??null,[Ae,S]),Nn=Q.useCallback(e=>{S&&We(S,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[S,We]),Pn=Q.useCallback(()=>{F(!0)},[F]),Fn=Q.useCallback((t,n)=>{if(Ke(`chat`),e&&Ze(!1),!n?.remote){if(n?.sessionId){Kt(n.sessionId,t);return}rn({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,rn,Ke,Kt,Ze]),In=K(()=>{let e=El.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=El.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Ln=Q.useCallback(()=>{e&&Ze(!1),Ye(!0)},[e,Ze,Ye]),Rn=K(()=>{let t=je.find(e=>e.id===Qt.getState().activeProjectId);if(t){lc(t,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),Ke(`chat`),rn(),e&&Ze(!1)}),zn=Q.useCallback(()=>{if(!e){Ke(`schedule`);return}Qe(!0),Ze(!1)},[e,Ke,Qe,Ze]),Vn=Q.useCallback(()=>{Vr(),e&&Ze(!1)},[e,Ze]),Hn=Bn(e=>e.archiveSession),Un=Bn(e=>e.archiveSessions),{copiedSessionId:Wn,handleSessionSelect:Jn,handleSessionDoubleClick:Xn,handleSaveEdit:Zn,handleCancelEdit:Qn,handleShareSession:$n,handleCopyShareUrl:er,handleUnshareSession:tr,handleDeleteSession:nr,confirmDeleteSession:rr}=sy({activeProjectId:Be,currentDirectory:De,currentSessionId:Bt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ue,setDirectory:Oe,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,setCurrentSession:Kt,updateSessionTitle:qt,shareSession:Jt,unshareSession:Yt,archiveSession:Hn,archiveSessions:Un,childrenMap:kn,showDeletionDialog:et,setDeleteSessionConfirm:te,deleteSessionConfirm:ee,setEditingId:v,setEditTitle:x,editingId:_,editTitle:b}),ir=Q.useCallback((e,t,n,r=`project`)=>{wn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===Bt){Rt(e),jx(i),Jn(e,t,n);return}kx(i,()=>Jn(e,t,n))},[Jn,Bt]);Q.useEffect(()=>()=>{Ox()},[]);let ar=Q.useCallback(()=>{if(!ne)return;let{scopeKey:e,folderId:t}=ne;re(null),mt(e,t)},[ne,mt]);Q.useEffect(()=>{if(!Bt)return;let e=cn.find(e=>e.id===Bt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{E.setItem(bS,JSON.stringify(Array.from(n)))}catch{}return n})},[Bt,cn,E]);let cr=Q.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{E.setItem(bS,JSON.stringify(Array.from(n)))}catch{}return n})},[E]),lr=Q.useCallback((e,t)=>{if(!e)return null;t&&ot.has(t)&&yt(t);let n=ft(e,o(`sessions.sidebar.folder.newFolderName`),t);return z(n.id),V(n.name),n},[ot,yt,ft,o]),ur=K(ir),dr=K(Xn),fr=K(Zn),pr=K(Qn),hr=K($n),gr=K(er),_r=K(tr),vr=K(nr),yr=K(lr),br=K((e,t,n,r)=>{let i=gc(),a=Math.max(i,n)+7;if(N(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=dt(e.directory??null);if(!o)return;let s=an.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&nn(o)}),xr=K(e=>{N(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Cr=K(e=>{N(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),wr=Q.useMemo(()=>e=>{let t=Ae.find(t=>t.id===e),n=dt(t?.path??null);if(!n)return[];let r=[n];return Ot||(tn.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),r},[tn,Ot,Ae]),Er=K(e=>{let t=wr(e);if(t.length===0)return;let n=an.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&qn(r,un.current)}),Dr=K(e=>{let t=Ae.find(t=>t.id===e);t&&(async()=>{let e=[];if(!Ot)try{e=(await Rs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=dt(t.path);e=r?Bn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=dS(t.path,e,{currentDirectory:De,workspaceRoot:t.path,includeWorktrees:!Ot});n.length!==0&&await gn(n,un.current)})()});Q.useEffect(()=>{if(!En)return;let e=an.getState(),t=Ae.flatMap(t=>O.has(t.id)?[]:wr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&qn(t,un.current)},[O,wr,En,Ae]);let Or=K(()=>{Te.current=Date.now()+150,N(new Map),k(()=>{let e=new Set(Ae.map(e=>e.id));try{E.setItem(gS,JSON.stringify(Array.from(e)))}catch{}return Ot||Tn(e),e})}),kr=K(()=>{Te.current=Date.now()+150,N(new Map),k(()=>{let e=new Set;try{E.setItem(gS,JSON.stringify([]))}catch{}return Ot||Tn(e),e});let e=an.getState().loadedDirectories,t=Ae.flatMap(t=>wr(t.id).filter(t=>!e.has(t)));t.length>0&&qn(t,un.current)}),Ar=K(e=>{Te.current=Date.now()+150,Cr(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Er(e))):n.add(e);try{E.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return Ot||Tn(n),n})}),jr=K(e=>{Te.current=Date.now()+150,Er(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{E.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return Ot||Tn(n),n})}),Nr=Q.useMemo(()=>Ae.map(e=>({...e,normalizedPath:dt(e.path)})).filter(e=>!!e.normalizedPath),[Ae]),Pr=Q.useMemo(()=>new Map(Nr.map(e=>[e.id,sr(e.normalizedPath)||e.normalizedPath])),[Nr]),Fr=Q.useMemo(()=>Nr.map(e=>e.normalizedPath),[Nr]),Ir=Q.useMemo(()=>{let e=new Set(Nr.map(e=>e.normalizedPath));if(!Ot)for(let t of tn.values())for(let n of t){let t=dt(n.path);t&&e.add(t)}return[...e].sort()},[tn,Ot,Nr]),Lr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(Ir),t=Lr.current;if(Lr.current=e,!t)return;let n=Ir.filter(e=>!t.has(e));if(n.length===0)return;let r=an.getState().loadedDirectories,i=dt(De),a=Nr.find(e=>e.id===Be)??Nr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),Ot||(tn.get(a.normalizedPath)??[]).forEach(e=>{let t=dt(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&qn(s,un.current)},[Be,tn,De,Ot,Nr,Ir]);let Rr=Yi(a?Fr:kS);hy({normalizedProjects:Nr,activeProjectId:Be,gitRepoStatus:Rr,setProjectRepoStatus:j,setProjectRootBranches:we,enabled:a});let zr=Q.useMemo(()=>Nl(cn,Nr,tn,Ot,Ft),[Ft,tn,Ot,Nr,cn]),{getSessionsForProject:Br,getArchivedSessionsForProject:Hr}=gy({ownership:zr}),Ur=Mt||kt===`idle`||kt===`loading`,Wr=Q.useRef(!1);Be&&A.has(Be)&&(Wr.current=!!A.get(Be));let Gr=en(e=>e.projectSortOrder),Kr=Q.useMemo(()=>el(Nr,Gr),[Nr,Gr]),{projectSections:qr,groupSearchDataByGroup:Jr,sectionsForRender:Yr,searchMatchCount:Xr}=ry({normalizedProjects:Kr,getSessionsForProject:Br,getArchivedSessionsForProject:Hr,availableWorktreesByProject:tn,projectRepoStatus:A,projectRootBranches:Ce,lastRepoStatus:Wr.current,buildGroupedSessions:Cn,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,filterSessionNodesForSearch:Sn,buildGroupSearchText:bn,foldersMap:st}),Zr=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});iy({projectSections:qr,activeProjectId:Be,activeSessionByProject:be,setActiveSessionByProject:xe,currentSessionId:Bt,handleSessionSelect:Jn,newSessionDraftOpen:Ut,mobileVariant:e,openNewSessionDraft:rn,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze});let{getOrderedGroups:Qr}=ay(ve),$r=Q.useRef(!1);Q.useEffect(()=>{if($r.current||qr.length===0)return;let e=qr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&_e(t=>new Set([...t,...e])),$r.current=!0},[qr]);let ei=Q.useMemo(()=>{let e=new Map,t=new Map;return qr.forEach(n=>{let r=sr(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[qr]);Q.useLayoutEffect(()=>{if(!Bt){jx(null);return}let e=lo.getState().focus;if(e?.sessionId===Bt){e.scope===`project`&&!e.projectId&&jx({...e,projectId:ei.get(Bt)?.projectId??null});return}jx({scope:`project`,sessionId:Bt,projectId:ei.get(Bt)?.projectId??null})},[Bt,ei]);let ti=Q.useMemo(()=>Ot?[]:kc(cn,H,ct[Tc]),[Ot,H,cn,ct]),ni=K((e,t)=>{_||xt(Tc,si.map(e=>e.node.session.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),ri=Q.useMemo(()=>it?[]:Bc(cn,H,Et,Dt),[it,H,Et,cn,Dt]),{pinnedItems:ii,inProgressItems:ai}=Q.useMemo(()=>{let e=e=>{let t=ei.get(e.id),n=dt(e.directory??null),r={session:e,children:[],worktree:Xt.get(e.id)??null};if(it&&Sn([r],rt).length===0)return null;let i=zr.bySessionId.get(e.id),a=i?Kr.find(e=>e.id===i.projectId):void 0,o=a?sr(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=mc({projectLabel:o,owner:i,sessionWorktree:Xt.get(e.id)??null,worktrees:a?tn.get(a.normalizedPath)??[]:[],projectRootBranch:i?Ce.get(i.projectId)??(a?Rr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:Ot})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:Ot?[]:t(ti),inProgressItems:t(ri)}},[tn,Sn,Rr,it,ri,Ot,rt,ti,Ce,zr,ei,Kr,Xt]),oi=Q.useMemo(()=>je.flatMap(e=>Ne.get(e.id)??[]),[je,Ne]),si=Q.useMemo(()=>Cl([...ii,...oi.filter(e=>e.pinned)],e=>e.node.session.id,ct[Tc]),[ii,oi,ct]),ci=Q.useMemo(()=>[...ai,...oi.filter(e=>!e.pinned)].sort((e,t)=>or(t.node.session)-or(e.node.session)),[ai,oi]),li=!e&&!Ot&&!r&&!i,ui=li&&le===`tasks`&&!it,fi=yl(Et,a&&li),[pi,mi]=Q.useState(sS),hi=Q.useMemo(()=>ui?vl({sessions:cn,pinnedSessionIds:H,settledSessionIds:oe,indexedSessionIds:W?.indexedIds??null,settledAtBySessionId:W?.settledAtById,runningSessionIds:Et,pendingRequestSessionIds:ce,unseenBySession:Dt}):null,[ce,H,Et,cn,oe,W,ui,Dt]),gi=Q.useMemo(()=>{let e=hi?.settled.filter(e=>!oe.has(e.id));return e?.length?new Set([...oe,...e.map(e=>e.id)]):oe},[hi,oe]),_i=K(e=>({activityAt:or(e),running:Et.has(e.id),attention:Fc(e.id,ce,Dt)})),vi=Q.useMemo(()=>{if(!hi)return null;let e=lS(hi.active,e=>e.id,_i,pi);return e===hi.active?hi:{...hi,active:e}},[hi,_i,pi]),yi=K((e,t)=>{if(_||!vi)return;let n=new Map(vi.active.map(e=>[e.id,e])),r=uS(vi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?_i(t):void 0});r&&mi(r)}),bi=K((e,t,n)=>{if(!ui||qe!==`chat`||Bt!==e||Lt()!==n)return;let r=[...ti,...vi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){Ox(),jx(null),rn();return}let a=zr.bySessionId.get(i.id);ir(i.id,a?.scopeDirectory??dt(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),xi=K((e,t)=>{if(!t&&hi?.settled.some(t=>t.id===e&&t.time?.archived)){mr(e);return}if(!t||!ui||Bt!==e){se(e,t);return}let n=[...ti,...vi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Lt();se(e,!0,{onSuccess:()=>bi(e,i?.id??null,a)})}),Si=li?xi:void 0,Ci=Q.useMemo(()=>{if(!vi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(Kr.map(e=>[e.id,sr(e.normalizedPath)||e.normalizedPath])),n=me.current,r=new Map(Kr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of Kr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=pe.current,s=new Map,c=n=>o=>{let c=zr.bySessionId.get(o.id),l=ei.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??dt(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?Rr.get(m):void 0,g=Xt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?Ce.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?Gn(m,Ee):null,x=g,S=n?fi.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=de.settledOpen?vi.settled.slice(0,de.settledLimit):[],u={pinned:ti.map(c(!0)),active:vi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:vi.settled.length};return pe.current=s,u},[Rr,Ee,ti,Ce,fi,zr,ei,Kr,o,vi,de.settledLimit,de.settledOpen,Xt]),wi=Q.useMemo(()=>{if(!Ci)return si;let e=new Map(Ci.pinned.map(e=>[e.node.session.id,e]));return si.map(t=>e.get(t.node.session.id)??t)},[si,Ci]),Ti=Q.useMemo(()=>{if(!vi||!Ci)return[];let e=new Map([...Ci.active,...Ci.settled].map(e=>[e.node.session.id,e]));return yc(vi,de).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:dt(mn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[vi,Ci,de]),Ei=Q.useMemo(()=>Yr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Yr]),Di=Q.useMemo(()=>{let e=it?Ei.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Jr.get(e)?.filteredNodes??[]}))})):Ei;if(!i)return e;let t=e.find(e=>e.project.id===Be)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[Be,Jr,it,Ei,i]),Oi=Q.useMemo(()=>bl({sections:Di,foldersMap:st,getOrderedGroups:Qr,pinnedSessionIds:H,sessionOrderByScope:ct,sessionOrderActivityByScope:lt}),[st,Qr,Di,H,lt,ct]),ki=Q.useMemo(()=>Uc({targets:Oi,collapsedProjectIds:O,collapsedGroupKeys:ge,collapsedFolderIds:ot,visibleSessionCountByGroup:M,defaultVisibleSessionCount:gc(),hasSessionSearchQuery:it,alwaysVisibleSessionIds:Tt}),[Tt,ot,ge,O,it,Oi,M]),Ai=Q.useMemo(()=>it?[]:(ui?si:[...si,...ci]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:dt(mn(n))??e.groupDirectory??null,visibleIndex:t}}),[it,ci,si,ui]),[ji,Mi]=Q.useState(null),Ni=Q.useCallback(e=>{Mi(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Pi=Q.useMemo(()=>{if(!ji)return Ai;let e=new Set(ji);return Ai.filter(t=>e.has(t.sessionId))},[Ai,ji]),Fi=Q.useMemo(()=>!a&&Se.current?Se.current:{pinned:Pi,project:ui?Ti:ki},[a,Ti,ui,Pi,ki]);Q.useLayoutEffect(()=>{a&&(Se.current=Fi)},[a,Fi]);let Ii=Q.useMemo(()=>e?[]:oo({pinnedTargets:Fi.pinned,projectTargets:ui?Fi.project:ke.flatMap(e=>e.hostId?Le.get(e.id)??[]:Fi.project.filter(t=>t.projectId===e.id))}),[e,ui,Fi,ke,Le]),Li=Q.useCallback(t=>{let n=je.find(e=>e.id===t.projectId);if(n&&Ie.registry){let r=Ne.get(n.id)?.find(e=>e.identity===t.sessionId);cc(n,Ie.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Ke(`chat`),Ze(!1),t.scope===`project`&&t.projectId&&Ue(t.projectId),ir(t.sessionId,t.directory,t.projectId,t.scope)},[ir,Ke,Ue,Ze,je,Ie.registry,Ne,e]);Q.useLayoutEffect(()=>no({targets:Ii,activate:Li}),[Li,Ii]);let Ri=Q.useMemo(()=>{let e=new Map;return Ii.forEach(t=>{let n=Za({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Ja(Ii,t)??0)}),e},[Ii]),zi=Q.useMemo(()=>{if(!Bt||it)return[];let e=[],t=(n,r)=>{if(n.session.id===Bt){e.push({scope:`pinned`,sessionId:Bt,projectId:r});return}n.children.forEach(e=>t(e,r))};return si.forEach(e=>t(e.node,e.projectId)),ai.forEach(e=>t(e.node,e.projectId)),e},[Bt,it,ai,si]),Bi=Q.useMemo(()=>{if(!Bt)return[];let e=[],t=(n,r)=>{if(n.session.id===Bt){e.push({scope:`project`,sessionId:Bt,projectId:r});return}n.children.forEach(e=>t(e,r))};return qr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[Bt,qr]);Q.useLayoutEffect(()=>ro({pinned:Fi.pinned,project:Fi.project}),[Fi]),Q.useLayoutEffect(()=>{!a||Ur||jx(pS({currentSessionId:Bt,focus:Vt,pinnedFocuses:zi,projectFocuses:Bi,fallbackProjectId:Bt?ei.get(Bt)?.projectId??null:null}))},[Bt,a,Ur,Bi,zi,Vt,ei]);let Vi=Q.useMemo(()=>{let e=Vt?.sessionId?ei.get(Vt.sessionId)?.projectId??null:null;return mS(Vt,Oi,e)},[Oi,Vt,ei]),Hi=Q.useRef(null),Ui=Q.useRef(null);Q.useEffect(()=>{Ui.current&&Ui.current!==Bt&&(Ui.current=null)},[Bt]),Q.useLayoutEffect(()=>{if(!Vi?.projectId)return;let e=Vi.sessionId,t=Ht.sessionId===e;if(!(!t&&Bt!==e)){if(t){if(Hi.current===Ht.revision)return;Hi.current=Ht.revision,Ui.current=e}else{if(Ui.current===e)return;Ui.current=e}if(jr(Vi.projectId),Vi.groupKey&&_e(e=>{if(!e.has(Vi.groupKey))return e;let t=new Set(e);return t.delete(Vi.groupKey),t}),Vi.folderAncestorIds?.forEach(e=>{let t=xn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Vi.groupKey&&Vi.visibleIndex!==void 0){let e=Vi.visibleIndex+1;N(t=>{if((t.get(Vi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Vi.groupKey,e),n})}}},[Bt,Vi,Ht]);let Wi=jS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(Gx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:Bt,pinnedSessionIds:H,settledSessionIds:gi,setSessionSettled:Si,expandedParents:w,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,notifyOnSubtasks:$e,editingId:_,setEditingId:v,editTitle:b,setEditTitle:x,handleSaveEdit:fr,handleCancelEdit:pr,toggleParent:cr,handleSessionSelect:ur,handleSessionDoubleClick:dr,togglePinnedSession:U,handleShareSession:hr,copiedSessionId:Wn,handleCopyShareUrl:gr,handleUnshareSession:_r,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,renamingFolderId:R,getFoldersForScope:ut,getSessionFolderId:bt,removeSessionFromFolder:_t,addSessionToFolder:ht,createFolderAndStartRename:yr,handleDeleteSession:vr,mobileVariant:e,alwaysShowActions:vn,renderSessionNode:Wi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??OS,subtreeContainsEditing:c?.subtreeContainsEditing??OS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:dn,shortcutNumber:Ri.get(Za({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...Ri])),Gi=Q.useCallback(e=>{xr(e),_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[xr]),Ki=Q.useCallback(e=>{let t=wr(e);if(t.length===0)return;let n=an.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&Zt(r)},[wr]),qi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??dt(e.directory??null);a&&xt(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Ji=K((e,t,n)=>{e.isArchivedBucket&&ge.has(t)&&n&&Ki(n),Gi(t)}),Xi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(fc,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&wr(r).some(e=>Nt.has(e))),projectId:r,projectLabel:r?Pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,groupSearchDataByGroup:Jr,visibleSessionCount:M.get(n),collapsedGroups:ge,collapsedFolderIds:ot,toggleFolderCollapse:yt,renameFolder:pt,deleteFolder:mt,showDeletionDialog:et,setDeleteFolderConfirm:re,renderSessionNode:Wi,projectRepoStatus:A,lastRepoStatus:Wr.current,showMoreGroupSessions:br,resetGroupSessionLimit:xr,mobileVariant:e,alwaysShowActions:vn,activeProjectId:Be,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:on,addSessionToFolder:ht,createFolderAndStartRename:yr,renamingFolderId:R,renameFolderDraft:B,setRenameFolderDraft:V,setRenamingFolderId:z,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:ct,sessionOrderActivityByScope:lt,onReorderSessions:qi,currentSessionId:Bt,shortcutTargetSessionId:Vi?.groupKey===n?Vi.sessionId:null,shortcutTargetVisibleIndex:Vi?.groupKey===n?Vi.visibleIndex??null:null,editingId:_,editTitle:b,openSidebarMenuKey:I,liveSessionById:dn,alwaysVisibleSessionIds:Tt,onToggleCollapsedGroup:Ji,dragHandleProps:a,scrollContainerRef:s}),[it,rt,Jr,Pr,Nt,wr,M,ge,ot,yt,pt,mt,et,Wi,A,br,xr,e,vn,Be,Ue,Ke,Ze,on,ht,yr,R,B,H,w,ct,lt,qi,Bt,Vi,_,b,I,dn,Tt,Ji]),Zi=ui?(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Mn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})}):null,Qi=li?(0,$.jsx)(eS,{value:le,onChange:he}):void 0,$i=e=>Wi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),ea=ui&&Ci?(0,$.jsx)(nS,{items:Ci,renderTaskRow:$i,onSessionsReordered:yi}):void 0,ta=ui&&Ci?(0,$.jsx)(oS,{items:Ci,open:de.settledOpen,onToggle:()=>fe(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>fe(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:$i}):void 0,na=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ky,{collapseAllProjects:Or,expandAllProjects:kr}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Mn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),ra=fn&&pn&&!Ot&&!it?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(yf,{className:`min-w-0 flex-1`}),(0,$.jsx)(al,{className:`ml-auto shrink-0`})]})}):null,ia=!Ot&&!it,aa=ia&&_n&&!e,oa=ui?[]:ci,sa=!it&&(si.length>0||oa.length>0),ca=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:Rn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:zn,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Hv,{}):null]}),Je.data?.supported&&Je.data?.enabled?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Vn,children:[(0,$.jsx)(ll,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Bl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Uv,{}):null]})]}):null,(0,$.jsx)(Tu,{sidebar:!0,mobile:e})]}),la=li&&!it,ua=sa?(0,$.jsx)(by,{isFirst:la,hideHeader:ui,items:wi,reorderEnabled:!0,onSessionsReordered:ni,inProgressItems:oa,renderSessionNode:Wi,currentSessionId:Bt,editingId:_,openSidebarMenuKey:I,onVisibleSessionIdsChange:Ni}):null,da=ia&&!aa||sa&&!la?(0,$.jsxs)($.Fragment,{children:[ia&&!aa?(0,$.jsxs)($.Fragment,{children:[e&&pn?(0,$.jsx)(yf,{}):null,ca]}):null,la?null:ua]}):null,fa=!!(R||_||S),{selectionModeEnabled:pa,hasSelection:ma,selectedIdsSize:ha,bulkScopeIsArchived:ga,derivedSelectionScope:_a,bulkScopeFolders:va,bulkCanRemoveFromFolder:ya,handleExitSelectionMode:ba,handleBulkMoveToFolder:xa,handleBulkCreateFolderAndMove:Sa,handleBulkRemoveFromFolder:Ca,handleBulkDelete:wa,confirmBulkDelete:Ta}=Qx({isInlineEditing:fa,showDeletionDialog:et,foldersMap:st,addSessionsToFolder:gt,removeSessionsFromFolders:vt,createFolderAndStartRename:lr,archiveSessions:Un,setBulkDeleteConfirm:ae});return(0,$.jsxs)(`div`,{ref:h,className:Y(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(vy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:it,searchMatchCount:Xr}),ra,aa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ca}):null,a?(0,$.jsx)(bb,{remoteProjects:je,hostRegistry:Ie.registry,projectOrderIds:el(ke,Gr).map(e=>e.id),onRemoteActivityItems:G,remoteSearch:f,remoteError:Ie.catalog.error?.message,onRemoteNavigationTargets:ze,topContent:da,tabLeadingContent:la?ua:void 0,hasLeadingSection:da!==null&&!la&&(si.length>0||ai.length>0),headerAccessory:ui?Zi:na,headerSwitch:Qi,taskContent:ea,taskFooter:ta,sectionsForRender:Ei,projectSections:qr,activeProjectId:Be,projectRevealTarget:Gt,showOnlyMainWorkspace:i,hasSessionSearchQuery:it,emptyState:An,searchEmptyState:Zr,renderGroupSessions:Xi,homeDirectory:Ee,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:vn,toggleProject:Ar,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:on,openNewWorktreeDialog:Pn,syncProjectSessions:Dr,openProjectEditDialog:C,removeProject:He,projectReorderEnabled:Gr===`manual`,reorderProjects:Ge,projectSortOrder:Gr,getOrderedGroups:Qr,setGroupOrderByProject:ye,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,isInlineEditing:fa}):null,pa&&ma?(0,$.jsx)(Zx,{selectedCount:ha,scopeKey:_a,scopeFolders:va,archivedBucket:ga,onMoveToFolder:xa,onCreateFolderAndMove:Sa,onRemoveFromFolder:Ca,canRemoveFromFolder:ya,onDelete:wa,onDone:ba}):null,(0,$.jsx)(Jv,{normalizedProjects:Nr,ownership:zr,enabled:a}),(0,$.jsx)(ub,{onOpenSettings:Ln,onOpenShortcuts:Xe,onOpenUpdate:In,showRuntimeButtons:!Ot,showUpdateButton:at}),s?(0,$.jsx)(MS,{onOpenChange:l}):null,jn?(0,$.jsx)(_y,{open:!0,onOpenChange:e=>{e||C(null)},project:jn,onSave:Nn}):null,P?(0,$.jsx)(ds,{open:!0,onOpenChange:F,onWorktreeCreated:Fn}):null,(0,$.jsx)(cl,{}),(0,$.jsx)(vu,{}),(0,$.jsx)(Jx,{value:ee,setValue:te,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:rr}),(0,$.jsx)(Xx,{value:ne,setValue:re,onConfirm:ar}),(0,$.jsx)(Yx,{value:ie,setValue:ae,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:Ta})]})});function PS(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var FS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,IS=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},LS=()=>{let{t:e}=Mr(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=Bn(e=>e.getWorktreeMetadata),b=Bn(e=>e.newSessionDraft),x=Bn(e=>e.setNewSessionDraftTarget),S=Bn(e=>e.setDraftBootstrapPendingDirectory),C=pn,w=Bn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Fe(e=>e.currentDirectory),O=Fe(e=>e.homeDirectory),k=Qt(e=>e.projects),A=Qt(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=di(),P=j||M||N,F=Q.useMemo(()=>IS((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=IS(e.projectDirectory)||F;return{id:(k.find(e=>IS(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,B=z,V=p||!z||!R,ee=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);_l({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>Mn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>Mn.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(IS(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(IS(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Is(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=IS(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=IS(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=IS(t.path),o=IS(i.path);try{await Ls(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=IS(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),IS(D)===a&&o&&Fe.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:FS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:FS(i)})})()},[R,l,ie,e]),H=Q.useCallback(async()=>{if(a){m(!0);try{let t=B&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}Sl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else _l({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else _l({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&Sl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:FS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,B,z,ae,e]),U=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,W=a?(0,$.jsxs)(`div`,{className:Y(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:Y(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:Y(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:Y(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:Y(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:Y(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?Gn(U.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||u(e=>!e)},disabled:V,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ee||f(e=>!e)},disabled:ee,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,ee?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Es,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),W]})}):(0,$.jsx)(Zr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Jr,{className:Y(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(Kr,{children:[(0,$.jsxs)(Yr,{className:Y(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(Xr,{children:oe})]}),(0,$.jsx)(`div`,{className:Y(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:W}),(0,$.jsx)(qr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)($c,{open:t,onOpenChange:n,origin:r})]})},RS=Q.createContext(null),zS=e=>{let t=(0,Au.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(RS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},BS=ya(()=>It(()=>import(`./TerminalView-DUwwOkqI.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([84,1,4,2,5,3,6,7,8,9,10,23,24,25,22,26,27,20,85,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,86,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,87,67,88,70,89,90,91,92,93,94,95,96,97]))),VS=ya(()=>It(()=>import(`./DiagramView-CzXoWMbU.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([98,1,3,2,10,12,13,14,4,5,6,7,8,9,11,15,16,17,18,19,20,21,22,23,24,25,26,27,46,60,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,70,89,85,99,100]))),HS=ya(()=>It(()=>import(`./SettingsView-Q23asKrK.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([101,1,2,3,4,5,6,7,8,9,102,103,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,104,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,105,87,64,65,106,67,107,88,108,109,110,111,112,68,29,30,31,32,33,34,35,36,37,38,113,71,72,73,114,115,116,76,70,77,78,117,118,119,120,121,122,123,124,125,126,127,61,62,128,129,90,91,92,93,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,63,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,81,178,179,180,181,182]))),US=ya(()=>It(()=>import(`./SettingsWindow-C5quZoiL.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([183,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,101,102,103,104,60,105,87,64,65,106,67,107,88,108,109,110,111,112,68,29,30,31,32,33,34,35,36,37,38,113,71,72,73,114,115,116,76,70,77,78,117,118,119,120,121,122,123,124,125,126,127,61,62,128,129,90,91,92,93,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,63,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,81,178,179,180,181,182]))),WS=ya(()=>It(()=>import(`./MultiRunWindow-BbYMumwu.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([184,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,185,105,87,106,88,111,112,113,186,116,138,187,188,189,190,160,61,67,72,78,161,162,191,192,193,150,125,157,63,91,92,93,124,126,127,62,177,194,129]))),GS=ya(()=>It(()=>import(`./AssistantView-hrY8xNCO.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([195,1,3,2,10,11,16,17,18,23,5,6,7,8,9,24,25,22,26,27,20,39,4,40,41,42,43,44,14,13,12,15,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,196,88,118,166,119,197,105,87,61,74,75,198,76,70,77,78,79,164,64,65,73,165,160,67,72,161,162,199,127,62,112,191,192,193,188,189,200,69,151,152,201,202,203,204,205,206,207,167,134,135,208,209,210,211,110,109]))),KS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),[f,p]=Q.useState(c),[m,h]=Q.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=di(),v=Q.useRef(!1),y=Q.useRef(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),O=Q.useCallback(e=>{x(e),q.getState().setSessionSwitcherOpen(e)},[]),k=Q.useRef(!1),A=Q.useRef(typeof window>`u`?0:window.innerWidth),j=Wr(-A.current),M=(0,Q.useRef)(0),N=Wr(A.current),P=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Q.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),Gr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Q.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),Gr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Q.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Q.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Q.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Q.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),q.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Q.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Bn.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Q.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Q.useEffect(()=>{q.getState().isMobile!==g&&o(g)},[g,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Q.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(kh,{isActive:!S})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zl,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(BS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(mp,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,B=L||R||z,V=a===`chat`,ee=!B&&!c;return(0,$.jsx)(Ri,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:Y(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(il,{}),(0,$.jsx)(Pv,{}),(0,$.jsx)(Rv,{}),(0,$.jsx)(LS,{}),(0,$.jsx)(wl,{}),g?(0,$.jsxs)(zS,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!B&&(0,$.jsx)(Xd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:Y(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Jl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(GS,{})})})}),ee&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!V&&`invisible`),children:(0,$.jsx)(pc,{children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Yl,{})})})}),ee&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(pc,{children:(0,$.jsx)(Mo,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(ru,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ks.div,{className:Y(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(NS,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(ks.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(pc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(kh,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(HS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Mo,{children:(0,$.jsx)(ul,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(_f,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(vf,{}),children:(0,$.jsx)(NS,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:B?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:z?(0,$.jsx)(Hl,{}):R?(0,$.jsx)(GS,{}):(0,$.jsx)(Jl,{})})})}):(0,$.jsx)(pc,{children:(0,$.jsxs)(Mv,{header:(0,$.jsx)(Xd,{}),footer:(0,$.jsx)(cf,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(BS,{})})}):null}),children:[ee&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!V&&`invisible`),children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Yl,{})})}),ee&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:I})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:f&&(0,$.jsx)(US,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:m&&(0,$.jsx)(WS,{open:u,onOpenChange:d})})]})]})})},qS=9e4,JS=15e3,YS=3e5,XS=[2e3,5e3],ZS=6e4,QS=12e4,$S=3e5,eC=4,tC=432e5,nC=`yuri.github-pr-status`,rC=e=>e===`closed`||e===`merged`,iC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},aC=(e,t,n)=>`${e}::${t}`,oC=new Map,sC=new Map,cC=new Set,lC=new Map,uC=2,dC=0,fC=[],pC=()=>dC<uC?(dC+=1,Promise.resolve()):new Promise(e=>{fC.push(e)}),mC=()=>{let e=fC.shift();if(e){e();return}dC=Math.max(0,dC-1)},hC=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),gC=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,_C=e=>{let t=gC(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},vC=(e,t)=>Object.entries(e).filter(([,e])=>_C(e)===t).map(([e])=>e),yC=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},bC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},xC=(e,t,n)=>{let r=vC(e,t),i=r.map(t=>bC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=bC(e[n]);if(a&&_C(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&bC(e)));return o?bC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},SC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:gC(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),CC=e=>({...hC(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),wC=le()(ue((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:hC()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??hC();return{entries:{...e.entries,[t]:yC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??hC();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),oC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=sC.get(n)??[];i.push(r),sC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),XS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<YS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}rC(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(iC(r.status)?ZS:r.status?.checks&&r.status.checks.state!==`pending`?$S:QS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},JS);oC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=oC.get(n);typeof i==`number`&&window.clearInterval(i),oC.delete(n);let a=sC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),sC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=_C(a);if(!a||!o)return;let s=vC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=lC.get(o)??0;if(!r?.force&&Date.now()-l<qS||cC.has(o))return;let u=xC(i.entries,o,n);if(u){if(cC.add(o),lC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),cC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),cC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await pC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{mC()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=gC(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{cC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await my(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:aC(t,n,e.remoteName??null)}).filter(e=>!!e))),eC,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??hC();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:nC,storage:Ue(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=gC(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<tC}).map(([e,t])=>[e,SC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,CC(t)]))}}})),TC=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},EC=e=>{let t=(0,Au.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},DC=e=>{let t=(0,Au.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Mr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(kC,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?TC(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(EC,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(EC,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(EC,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Ur,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},OC=e=>{let t=(0,Au.c)(104),{onClose:n}=e,{t:r}=Mr(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Bn(AC),l=_r(jC),u=Fn(),d=vr(),[f,p]=Q.useState(MC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Ze(()=>{p(Xe())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Ye(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(NC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(nt(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(PC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=wC(FC),[y,b]=Q.useState(IC),[x,S]=Q.useState(LC),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(Ae()),S(ze())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let B=z,V;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],V=u.map(e).sort(RC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=V}else V=t[40];let ee=V,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Ae(),vscode:ze()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let H;t[50]===i?H=t[51]:(H=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=H);let U;t[52]===r?U=t[53]:(U=r(`memoryDebugPanel.title`),t[52]=r,t[53]=U);let oe;t[54]===U?oe=t[55]:(oe=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:U}),t[54]=U,t[55]=oe);let W;t[56]!==H||t[57]!==oe?(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,oe]}),t[56]=H,t[57]=oe,t[58]=W):W=t[58];let se;t[59]===i?se=t[60]:(se=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:()=>{G(),b(Ae()),S(ze())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=se);let ce;t[61]===n?ce=t[62]:(ce=n?(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=ce);let le;t[63]!==se||t[64]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[se,ce]}),t[63]=se,t[64]=ce,t[65]=le):le=t[65];let ue;t[66]!==W||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[W,le]}),t[66]=W,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(J,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(J,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==B||t[91]!==l||t[92]!==ee||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:B.total}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${Ho.MAX_SESSIONS}`}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.userMessages`),value:B.user}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:B.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Yo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Ho.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Ur,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:ee.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(zC),Object.keys(_),ee.map(BC),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)($r,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(J,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(DC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(DC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=B,t[91]=l,t[92]=ee,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(jo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function kC(e,t){return e+t.count}function AC(e){return e.currentSessionId}function jC(e){return e.sessionMemoryState}function MC(){return Xe()}function NC(e){return e.scope}function PC(e){return!!e}function FC(e){return e.totalRequestCount}function IC(){return Ae()}function LC(){return ze()}function RC(e,t){return t.lastAccessed-e.lastAccessed}function zC(e){return{id:e.id,title:e.title}}function BC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var VC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Ui();n&&t(n)||I()&&v(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},HC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},UC=async()=>{let e=HC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},WC=`yuri:menu-action`,GC=`yuri:check-for-updates`,KC=e=>typeof e?.listen==`function`?`bridge`:`dom`,qC=e=>{let t=Bn(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=El(e=>e.checkForUpdates),{setThemeMode:_}=ii(),{t:v}=Mr(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=KC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=El.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{Mn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{ao(e,Bn.getState().currentSessionId,e=>{s(`chat`),o(!1),Bn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=Qt.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),us();break;case`change-workspace`:C();break;case`close-tab-or-window`:VC();break;case`toggle-right-sidebar`:{let e=Ui();e&&d(e);break}case`open-right-sidebar-git`:{let e=Ui();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Ui();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&UC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Ya();break;case`zoom-out`:Xa();break;case`zoom-reset`:co();break;case`go-back`:Fe.getState().goBack();break;case`go-forward`:Fe.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:po().catch(()=>{X.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(WC,e),window.addEventListener(GC,t),()=>{window.removeEventListener(WC,e),window.removeEventListener(GC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},JC=(e,t)=>e<t?-1:+(e>t),YC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(JC)]).sort(([e],[t])=>JC(e,t)));async function XC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var ZC=`yuri:tray-action`,QC=3e4,$C=120,ew=20,tw=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},nw=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},rw=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},iw=e=>or(e),aw=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},ow=(e,t,n,r)=>{if(!e)return``;let i=vn(t,n,e),a=aw(i?i.path:e),o=On(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Zi.getState().directories)if(On(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>On(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},sw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Ys.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Xs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:ec(n.label??t),value:Zs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},cw=async()=>{try{if(T())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&oe(t,e))return`Local Yuri`;let n=(await se()).hosts.find(e=>t?oe(t,U(e)):!1);return n?.label?.trim()?ce(n.label.trim()):`Instance`}catch{return``}},lw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Qe()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(On(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:nw(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:rw(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},uw=()=>{let e=an.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>iw(t)-iw(e)).slice(0,ew).forEach(e=>{let n=mn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=mn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},dw=e=>{let t=lw(),n=Dn.getState().index.session,r=an.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Pn.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=Qt.getState().projects,d=Bn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>iw(t)-iw(e)).slice(0,ew).map(e=>{let r=[e.id,...o(e.id)],i=mn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:ow(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:sw(),dockBadgeCount:h}},fw=()=>{Q.useEffect(()=>{if(!tw()||!I())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=dw(r),i=JSON.stringify(n);i!==t&&(t=i,v(`desktop_tray_update`,n))};cw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=kn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=uw();return o=YC(t),a=XC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await tt.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{br(e,t,[...n])}}).finally(()=>{a=null;let t=uw();!e&&s()&&YC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},$C))},u=new Map,d=()=>{if(e)return;let t;try{t=Qe()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=Qe().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=Dn.subscribe(()=>l()),m=an.subscribe(()=>{l(),s()&&YC(uw())!==o&&c()}),h=Qt.subscribe(()=>l()),g=Bn.subscribe(()=>l()),_=Zi.subscribe(()=>l()),y=q.subscribe(()=>l()),b=Pn.subscribe(()=>l()),x=s(),S=kn.subscribe(()=>{let e=s();e&&!x&&c(),x=e});x&&c();let C=Ys.subscribe(()=>l());Ys.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Ys.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Ys.getState().fetchAllQuotas()});let w=window.setInterval(()=>{let e=Ys.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Ys.getState().refreshIntervalMs||6e4)),T=window.setInterval(()=>{d(),i()},QC);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(T),window.clearInterval(w),p(),m(),h(),g(),_(),y(),b(),S(),C(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!tw()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&An(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(ZC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},pw=`/api/notifications/stream`,mw=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),hw=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},gw=e=>{let t=(0,Au.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||y()||!ie()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(pw));return e.onmessage=_w,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function _w(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=hw(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&mw()||H()?.notifications?.notifyAgentCompletion(r))}var vw=`pwa-install-toast-shown`,yw=`pwa-install-toast-dismissed`,bw=()=>{let e=(0,Au.c)(6),{browserTab:t}=du(),{t:n}=Mr(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!ie()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Ve(),c=He();Ac({dismissed:s.getItem(yw),sessionShown:c.getItem(vw),hasActiveToast:n!==null})&&(c.setItem(vw,`true`),n=X.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{Ve().setItem(yw,`true`),i()}}}))},s=()=>{e=null,i(),X.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},xw=0;function Sw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++xw,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;It(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-DRRQnuzD.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([212,1,3,2,19,8,9,20,39,5,4,6,7,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59])).then(({applyRemoteProjectRoute:i})=>{if(n===xw)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===xw)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Bn.getState().setCurrentSession(t,r)}var Cw=({open:e,onOpenChange:t})=>{let{t:n}=Mr(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await kr())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Zr,{open:e,onOpenChange:t,children:(0,$.jsx)(Jr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Ao,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},ww=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},Tw=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},Ew=()=>{let e=Pl(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=ww(t,`code`),a=lu(t),o=iu(t),s=ww(t,`error`),c=ww(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(Tw(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(J,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},Dw=()=>{let e=an(e=>e.startupSyncProgress.active),t=an(e=>e.startupSyncProgress.phase),n=an(e=>e.startupSyncProgress.completed),r=an(e=>e.startupSyncProgress.total),{locale:i,t:a}=Mr(),[o,s]=Q.useState(!0),c=Kt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},Ow=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function kw(e){let t=(0,Au.c)(21),{transition:n,ready:r}=e,{t:i}=Mr(),a=wo(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=Ow(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(Ao,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var Aw=ya(()=>It(()=>import(`./OnboardingScreen-DMLpMUuF.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([213,1,4,2,5,3,6,7,8,9,102,10,40,24,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,116,145,67]))),jw=36e5,Mw=12e5,Nw=()=>{let e=(0,Au.c)(3),t=q(Bw),n=q(Vw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(Cw,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},Pw=e=>{let t=(0,Au.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Mr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(J,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},Fw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,Iw=()=>{if(typeof window>`u`||!Fo())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},Lw=()=>typeof window>`u`?!1:window.location.pathname===uu,Rw=e=>{let t=(0,Au.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Fe(Hw),o=Bn(Uw),s=Bn(Ww),c=fs(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=Fw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=Fw(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)($a,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Yl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Pa,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function zw({apis:e}){Q.useEffect(()=>{We(`App:mounted`),Ge()},[]),Q.useEffect(()=>er(),[]);let t=kn(e=>e.initializeApp),n=kn(e=>e.isInitialized),r=kn(e=>e.isConnected),i=Bn(e=>e.error),a=Bn(e=>e.clearError),o=Bn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=Fe(e=>e.currentDirectory),l=Fe(e=>e.setDirectory),u=Fe(e=>e.isSwitchingDirectory),[d,p]=Q.useState(!1),m=Ml(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,b]=Q.useState(!1),[S,w]=Q.useState(!1),[E,D]=Q.useState(0),[O,k]=Q.useState(0),[j,M]=Q.useState({epoch:0,startedAt:0}),[P,I]=Q.useState(!1),L=Q.useRef(!1),R=q(e=>e.wideChatLayoutEnabled),z=q(e=>e.mobileKeyboardMode),B=Q.useMemo(()=>y(),[]),ee=an(e=>e.hasCachedSessionIndex),ne=an(e=>e.hasHydratedSessionIndex),[ie,H]=Q.useState(()=>N()),[U,oe]=Q.useState(()=>{let e=V();return e===null?null:re({isDesktopShell:!0,bootOutcome:e})}),W=Q.useRef(!1),se=Q.useMemo(()=>Iw(),[]),ce=!se||_,le=Q.useMemo(()=>Lw(),[]);Q.useEffect(()=>(je(d),()=>{je(!1)}),[d]),Q.useEffect(()=>{Bt(z)},[z]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Ra(e=>{f(e)&&(B&&M(e=>({epoch:e.epoch+1,startedAt:Date.now()})),sl(e),k(e=>e+1),w(!1),D(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[B]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,R),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[R]),Q.useEffect(()=>(ae(e),()=>ae(null)),[e]),Q.useEffect(()=>{if(se)return;let t=!1;return Sn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,se,m]),so();let ue=ie===`valid`,de=U?.screen===`main`,[fe,pe]=Q.useState(!1);Q.useEffect(()=>{if(!ce||!te({isDesktopShell:B,isInitialized:B&&de?ee||n&&ne:n,bootOutcomeKnown:ue,bootViewIsMain:de}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),pe(!0)},300)):pe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[ce,B,n,ue,de,ee,ne]),Q.useEffect(()=>{if(!B||ie!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[B,ie]),Q.useEffect(()=>{if(!ce||B)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[ce,B,n]),Q.useEffect(()=>{if(!ce||h)return;let e=!1;return Sn().then(()=>{if(!e)return t()}),()=>{e=!0}},[ce,t,h]),Q.useEffect(()=>{if(!ce||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){w(!0);return}let n=kn.getState();if(n.isInitialized){w(!1);return}if(r+=1,await Sn(),!e)return;await n.initializeApp();let o=kn.getState();if(!e)return;if(o.isInitialized){w(!1);return}if(r>=10){w(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[ce,E,n,h]),Q.useEffect(()=>{ce&&n&&w(!1)},[ce,n]),Q.useEffect(()=>{if(!ce||!S)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[ce,S]),Ga({enabled:ce&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&tt.setDirectory(s)},[s,u,r,h]),Q.useEffect(()=>{if(!se||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;b(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Io},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[se]),Q.useEffect(()=>{!se?.directory||h||s!==se.directory&&l(se.directory,{showOverlay:!1})},[s,se,h,l]),Q.useEffect(()=>{if(!se||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[se]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;Sw(t??{})},t=e=>{let t=e.detail;It(async()=>{let{openSessionFromDeepLink:e}=await import(`./openSessionFromDeepLink-DnoNsjzY.js`);return{openSessionFromDeepLink:e}},__vite__mapDeps([214,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,207])).then(({openSessionFromDeepLink:e})=>e(t??{}))},n=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Vr(t.trim())},r=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&It(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-DpfZSGu8.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([167,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,20,134,135])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-session-link`,t),window.addEventListener(`yuri:open-assistant`,n),window.addEventListener(`yuri:open-scheduled-task`,r),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-session-link`,t),window.removeEventListener(`yuri:open-assistant`,n),window.removeEventListener(`yuri:open-scheduled-task`,r)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=Fe.getState().currentDirectory,{activeProjectId:t,projects:n}=Qt.getState(),r=n.find(e=>e.id===t)??null;v(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(wn.getState().remoteSession)return;let e=Bn.getState().currentSessionId;e&&ln(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=Qt.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=wn.getState().remoteSession,c=s.activeProjectId;zl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&wn.getState().remoteSession===t&&Qt.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=wn.getState().remoteSession;o&&t&&await Rl(t.location,o)}).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),wn.getState().openRemoteSession(c,e,null),o&&Rl(e,o).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),Bn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=Qt.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!ce||!n||u||W.current||(W.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[ce,n,u]),Wa({enabled:ce}),gw({enabled:ce}),bw(),fo(),nl(),qC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{C()&&Gt().then(async e=>{e&&await x(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!C()||L.current)return;L.current=!0;let e=!1,t=null,r=null;El.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=El.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(jw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=El.getState().lastChecked;t!=null&&Date.now()-t<Mw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),fw(),Q.useEffect(()=>{if(se)return;let e=e=>{lr(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[se]),Q.useEffect(()=>{se||i&&setTimeout(()=>a(),5e3)},[a,se,i]),Q.useEffect(()=>{if(!B||ie!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=N();if(r!==`not-injected`){if(e=!0,H(r),r===`valid`){let e=V();e&&oe(re({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[B,ie]);let me=K(async()=>{if(F({isDesktopShell:y(),isDesktopLocalOriginActive:T()})){await A();return}window.location.reload()}),he=K(async()=>{if(!P){w(!1),I(!0);try{await Sn(),await kn.getState().initializeApp()}finally{I(!1)}kn.getState().isInitialized||D(e=>e+1)}}),ge=e=>{if(e.screen===`recovery`)return e.variant};if(B&&U&&U.screen!==`main`){if(U.screen===`chooser`)return(0,$.jsx)(Mo,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Aw,{mode:`first-launch`,onCliAvailable:me,onChooseRemote:()=>{}})})})});let e=ge(U),t=U.screen===`recovery`&&`url`in U?U.url:void 0;return(0,$.jsx)(Mo,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Aw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:me})})})})}if(se)return gr(),(0,$.jsx)(Mo,{children:(0,$.jsx)(Jn,{sdk:tt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(uo,{apis:e,children:(0,$.jsx)(ei,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(Rw,{embeddedSessionChat:se,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:ce})})})})},O)});if(le)return(0,$.jsx)(Mo,{children:(0,$.jsx)(Ew,{})});if(S&&!n&&!h&&!se)return(0,$.jsx)(Mo,{children:(0,$.jsx)(Pw,{onRetry:()=>{he()},isRetrying:P})});let _e=!n&&!B;return(0,$.jsx)(Mo,{children:(0,$.jsx)(Jn,{sdk:tt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(uo,{apis:e,children:(0,$.jsx)(Xc,{ready:fe&&n&&ce,children:(0,$.jsx)(ym,{children:(0,$.jsx)(ei,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:B?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)($a,{embeddedBackgroundWorkEnabled:ce}),(0,$.jsx)(pl,{}),(0,$.jsx)(ol,{}),(0,$.jsx)(Ec,{}),(0,$.jsx)(KS,{}),B&&(0,$.jsx)(kw,{transition:j,ready:n&&r}),(0,$.jsx)(Dw,{}),(0,$.jsx)(Pa,{}),!_e&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rc,{}),(0,$.jsx)(xc,{}),(0,$.jsx)(hc,{}),(0,$.jsx)(Nw,{}),d&&(0,$.jsx)(OC,{onClose:()=>p(!1)})]})]})})})})})},O)})}function Bw(e){return e.isAboutDialogOpen}function Vw(e){return e.setAboutDialogOpen}function Hw(e){return e.currentDirectory}function Uw(e){return e.currentSessionId}function Ww(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var Gw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Nr(),y()&&tn(),Ua({runtimeKey:p(),initializeAppearance:Ne,syncSettings:Pe,applyDirectory:mo,startWatchers:()=>{to(),Va(),Fa()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var Kw=document.getElementById(`root`);if(!Kw)throw Error(`Root element not found`);(0,ku.createRoot)(Kw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ia,{children:(0,$.jsx)(jr,{children:(0,$.jsx)(Na,{children:(0,$.jsx)(eo,{children:(0,$.jsx)(za,{children:(0,$.jsx)(Ba,{children:(0,$.jsx)(zw,{apis:Gw})})})})})})})}));
169
+ Now write the final fused answer.`,synthetic:!0}],directory:i??tt.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),X.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function Sx(e){let t=(0,Au.c)(13),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=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:Cr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var Cx=e(xe(),1),wx=null,Tx=!1,Ex=(e,t=lo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:Qa(e):e,Dx=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},Ox=()=>{wx&&=(Dx(wx),null)},kx=(e,t)=>{Ox(),rr(!0);let n=Ex(e);if(!n)return;Tx=!0;let r;try{r=Rt(n.sessionId)}finally{Tx=!1}wx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,Cx.flushSync)(()=>{lo.getState().setFocus(n)}),typeof window<`u`&&(wx.fallbackTimer=window.setTimeout(()=>{Ax(n)},150))},Ax=e=>{let t=wx,n=Ex(e);if(!t||!Ka(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{wx===t&&Lt()===t.intent&&(wx=null,Hn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{wx===t&&Lt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},jx=e=>{if(wx)return;let t=lo.getState();t.setFocus(Ex(e,t.focus))};zt(e=>{if(Tx)return;let t=wx;if(t?.intent===e)return;t&&Ox();let n=lo.getState();n.setFocus(Ex(e.sessionId,n.focus))});var Mx=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},Nx=Q.memo(function(e){let t=(0,Au.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=Y(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=Y(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(Z,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:Kx,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ti,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Px=Q.memo(function(e){let t=(0,Au.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=ex(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=Y(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(Z,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:qx,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ti,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),Fx=Q.memo(function(e){let t=(0,Au.c)(3),{number:n}=e;if(!gx())return null;let r=In()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Li,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function Ix(e){let{t}=Mr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:y,toggleParent:b,handleSessionSelect:x,togglePinnedSession:S,handleShareSession:C,copiedSessionId:w,handleCopyShareUrl:T,handleUnshareSession:E,setOpenSidebarMenuKey:O,renamingFolderId:k,getFoldersForScope:A,getSessionFolderId:j,removeSessionFromFolder:M,addSessionToFolder:N,createFolderAndStartRename:P,handleDeleteSession:F,mobileVariant:L,alwaysShowActions:R,renderSessionNode:z,secondaryMeta:B,renderContext:V=`project`,subtreeContainsActive:ee,subtreeContainsEditing:te,menuOpenSessionId:ne,childRenderExtrasFor:re,liveSessionById:ie,shortcutNumber:ae=null,settledSessionIds:H,setSessionSettled:U}=e,oe=!!B?.projectLabel,W=!!B?.branchLabel,se=en(e=>e.displayMode),ce=Q.useMemo(()=>D(),[]),le=se===`minimal`||ce,ue=Q.useMemo(()=>I(),[]),de=Q.useContext(At),me=ce?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,ve=ce,be=V===`pinned`&&c.has(r.session.id),xe=!be&&!s&&!L&&!B?.slim,we=`h-5 w-5`,Te=`h-3.5 w-3.5`,Ee=(xe||be?1:0)+ +!!ve+1,De=Ee>=3?`group-hover:pr-18 group-focus-within:pr-18`:Ee>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Oe=R?ce?De:Ee>=2?`pr-12`:`pr-8`:De,Ae=Q.useRef(!1),je=Q.useRef(!1),[Me,Ne]=Q.useState(!1),Pe=Q.useRef(f);Pe.current=f;let Fe=Q.useRef(null),[G,Ie]=Q.useState(m),[Le,Re]=Q.useState(f===r.session.id),ze=Q.useRef(null),Be=Q.useRef(null),Ve=Q.useRef(null),He=r.session,Ue=ie.get(He.id)??He,We=!!Ue.metadata?.yuri?.assistant,Ge=dt(He.directory??null)??dt(a??null),Ke=Cn(Ge??void 0,{bootstrap:!1}),qe=fs(),Xe=Vb(e=>e.enabled),Ze=Vb(Q.useMemo(()=>e=>e.selectedIds.has(He.id),[He.id])),Qe=Vb(e=>e.toggleSelected),$e=Vb(e=>e.setRange),[et,tt]=Q.useState(!1),[rt,at]=Q.useState(!0),[ot,st]=Q.useState(!1),[ct,lt]=Q.useState(!1),ut=`${V}:${s?`archived`:`active`}:${He.id}`,ft=_r(Q.useMemo(()=>e=>!!e.sessionMemoryState.get(bn(He.id))?.isZombie,[He.id])),pt=zn(He.id),mt=ar(He.id,Ge??void 0,{bootstrap:!1}),ht=$n(He.id,Ge??void 0,{bootstrap:!1}),gt=Q.useMemo(()=>({scope:V,sessionId:He.id,projectId:o??null}),[o,V,He.id]),_t=Q.useMemo(()=>Za(gt)??``,[gt]),vt=Q.useRef(null),yt=lo(Q.useMemo(()=>e=>Ka(e.focus,gt),[gt]));Q.useLayoutEffect(()=>{if(!yt)return;let e=vt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):gb(e)),Ax(gt)},[yt,L,gt]);let bt=Ue.title||t(`sessions.sidebar.session.untitled`),xt=sc(oc(Ue)),St=Ue.metadata?.yuri?.titleRefresh,Ct=typeof St?.lastError==`string`?St.lastError:null,wt=typeof St?.failedAt==`number`?St.failedAt:null;Q.useEffect(()=>{!Ct||wt===null||console.warn(`[session-title] generation failed for ${He.id}: ${Ct}`)},[He.id,Ct,wt]);let Tt=typeof St?.generationExpiresAt==`number`&&Number.isFinite(St.generationExpiresAt)?St.generationExpiresAt:0,[Et,Dt]=Q.useState(0),Ot=Q.useMemo(()=>Math.max(0,Tt-Date.now()),[Tt]),[,kt,jt]=Nt(()=>Dt(Tt),Ot,{immediate:!1}),Mt=St?.isGenerating===!0;Q.useEffect(()=>(Mt&&Tt>Date.now()&&kt(),jt),[Mt,Tt,kt,jt]);let Pt=r.children.length>0||!!(Ue.hasChildren??He.hasChildren),Ft=c.has(He.id),It=!!H?.has(He.id),Lt=ut,Rt=u?!0:l.has(Lt),zt=!!Ue.parentID,q=V===`pinned`,Bt=on(He.id),Vt=Bt>0&&!zt,Ht=or(Ue)||Date.now(),Ut=bo(Ht),Wt=ko(Ht),[Gt,Kt]=Q.useState(!1),[qt,Jt]=Q.useState(!1),Yt=Gt,Zt=Q.useMemo(()=>tu(Ue.title)!==null,[Ue.title]),[Qt,$t]=Q.useState(!1),tn=Q.useMemo(()=>Mx(r).length,[r]),nn=K(e=>{let t=Ge??``,n=(Ye()??it(t,Ke)).getTranscript(nt(t,e)),r=Ke.getState().session.find(t=>t.id===e)?.revert?.messageID;return Xt({sessionID:e,messages:Je(n),parts:n.partsByMessageID,revertMessageID:r}).list}),rn=K(async e=>{let n=[],r=0;for(let i of e)try{await qe.ensureSessionRenderable(i.session.id);let e=nn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await rn(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Mx(i).length+1}return{children:n,skipped:r}}),an=K(e=>{e<=0||X.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),sn=K(async e=>{if(!Ge){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await qe.ensureSessionRenderable(He.id);let n=nn(He.id);if(n.length===0){X.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await rn(r.children);i=e.children,a=e.skipped}let o=Nb(n,Ue.title??null,i),s=Rb(Ue.title??null),c=await Fb(o,s);if(c){X.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Lb()),onClick:()=>{Ib(c).then(e=>{e||X.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),an(a);return}Pb(o,s),X.success(t(`sessions.sidebar.session.export.success`)),an(a)}),cn=K(async()=>{if(r.children.length>0){at(!0),tt(!0);return}await sn(!1)}),un=K(()=>{Ge&&v(`desktop_open_session_mini_chat_window`,{sessionId:He.id,directory:Ge,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Q.useLayoutEffect(()=>{if(f!==He.id){Le&&Re(!1),ze.current===He.id&&(ze.current=null);return}!Le||ze.current===He.id||(ze.current=He.id,Ie(m),queueMicrotask(()=>Ve.current?.select()))},[f,m,He.id,Le]);let dn=K(e=>{if(!e&&Fe.current){let{id:e,title:t}=Fe.current;Fe.current=null,Re(!0),p(e),g(t)}}),fn=K(e=>{Kt(e)}),pn=K(e=>{e.preventDefault(),e.stopPropagation()}),mn=K(e=>{e.preventDefault(),e.stopPropagation()}),hn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(He.id)}),gn=!!U&&!!(B?.card||B?.slim)&&!s&&!zt,_n=K(e=>{if(e.preventDefault(),e.stopPropagation(),O(null),gn&&U){U(He.id,!It);return}F(He,{archivedBucket:s})}),vn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),F(He,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),yn=K(e=>{e.preventDefault(),e.stopPropagation(),O(null),S(He.id)}),xn=K(()=>{!Ge||ot||(st(!0),(async()=>{try{await qe.refreshSessionTranscript(He.id,{directory:Ge}),X.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{X.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{st(!1)}})())}),Sn=K(e=>{e.preventDefault(),e.stopPropagation()}),wn=K(e=>{e.preventDefault(),e.stopPropagation()}),En=K(e=>{e.preventDefault(),e.stopPropagation(),de?.vscode?.executeCommand(`yuri.openSessionInEditor`,He.id,bt)}),Dn=K(e=>{if(Ae.current){Ae.current=!1;return}if(Xe){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Vb.getState().anchorId,n=new Map;n.set(He.id,Mx(r)),$e(t,He.id,e,Ge??null,n);return}Qe(He.id,Ge??null,Mx(r));return}x(He.id,Ge,o,V)}),On=K(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;Dn(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!L&&(t.focus({preventScroll:!0}),je.current=!0)}),kn=K(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Xe)&&(Ae.current=!0)}),An=K(e=>{je.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Ne(!0)}),jn=K(e=>{L&&e.pointerType===`touch`&&Ne(!1)}),Mn=K(e=>{e.key!==`Enter`||!je.current||(e.preventDefault(),e.stopPropagation(),Re(!0),p(He.id),g(bt))}),Nn=K(e=>{if(Dn(e),!je.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{je.current=!0,t.focus({preventScroll:!0})})}),Pn=K(()=>{je.current=!1}),Fn=K(()=>{!Rt&&!ct&&(lt(!0),qe.loadChildren(He.id,Ge).catch(()=>X.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>lt(!1))),b(Lt)});if(f===He.id&&Le){let e=async()=>{y();try{await Wn(He.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:vo(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:Be,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(G)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||y()},children:[(0,$.jsx)(`input`,{ref:Ve,value:G,onChange:e=>Ie(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){y();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Z,{name:`check`,className:`size-3.5`})})]}),le?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Pt&&!q&&!zt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Ut}),oe?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,W?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})},He.id)}let In=pt,Ln=Mt&&Tt>Date.now()&&Et!==Tt,Rn=mt.length,Bn=ht.length>0,Hn=!Bn&&!In&&Vt,Un=!!B?.card,Gn=!!B?.slim,Kn=Bn||Rn>0,qn=!Kn&&In,Jn=yt||Ze,Yn=Un&&Hn,Xn=!Un&&(Bn||In||Hn),Zn=t(Bn?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),Qn=B?.runStartedAt??null,er=Kn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":Zn,title:Zn,children:[(0,$.jsx)(Z,{name:Bn?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:Zn})]}):qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)(Qc,{size:10,arcColor:`var(--status-info)`}),Qn===null?null:(0,$.jsx)(xl,{startedAt:Qn})]}):(0,$.jsx)(`span`,{className:Y(`text-[10px] leading-none tabular-nums`,Jn?`text-foreground/70`:`text-muted-foreground/70`),children:Wt}),tr=!R||ce,nr=tr?Y(`group-hover:invisible group-focus-within:invisible`,Yt&&`invisible`):Yt?`invisible`:``,rr=Bn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(Z,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):In?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Qc,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),ir=!q&&!zt&&Pt,sr=ir&&!R&&!ct,cr=vo(Math.max(0,i-1)),lr=ir?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":Rt,"aria-busy":ct,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),Fn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),Fn())},style:{minWidth:14,minHeight:14,left:cr},className:Y(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,le?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,sr?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(Rt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:ct?(0,$.jsx)(Qc,{size:12}):Rt?(0,$.jsx)(Z,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(Z,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,ur=ft?(0,$.jsx)(Z,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,dr=(0,$.jsx)(pe,{children:(0,$.jsx)(ke,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(k||Pe.current),style:{color:`var(--surface-elevated-foreground)`},className:Y(mi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>S(He.id),className:`[&>svg]:mr-1`,children:[Ft?(0,$.jsx)(Z,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(Z,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),zt?null:(0,$.jsxs)(e,{onClick:()=>{Bt>0?ln(He.id):Tn(He.id,Ge||void 0).catch(()=>X.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:Bt>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(Bt>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{Fe.current={id:He.id,title:bt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Vn()&&!Ue.share?(0,$.jsxs)(e,{onClick:()=>C(Ue),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Vn()&&Ue.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ue.share?.url&&T(Ue.share.url,He.id)},className:`[&>svg]:mr-1`,children:w===He.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>E(He.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{cn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Ge||ot,onClick:()=>{xn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`refresh`,className:Y(`mr-1 h-4 w-4`,ot&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Zt?(0,$.jsxs)(e,{onClick:()=>$t(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Sx,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,Ge&&!s?(()=>{let o=A(Ge),s=j(Ge,He.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?M(Ge,He.id):N(Ge,t.id,He.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(Z,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=P(Ge);e&&N(Ge,e.id,He.id)},children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{M(Ge,He.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,ue?(0,$.jsxs)(e,{disabled:!Ge,onClick:un,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(Z,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:gn&&It?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>U?.(He.id,!1),children:[(0,$.jsx)(Z,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>gn&&U?U(He.id,!0):F(He,{archivedBucket:s}),children:[(0,$.jsx)(Z,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>F(He,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(Z,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(he,{className:Y(gi,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(ge,{className:Y(hi,e),...t}),Sub:_e,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(Se,{className:Y(pi,e),...n,children:[t,(0,$.jsx)(Z,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(pe,{children:(0,$.jsx)(ke,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(ye,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:Y(mi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(Jc,{sessionId:He.id,sessionDirectory:Ge??null,sessionTitle:bt,children:(0,$.jsxs)(fe,{open:Gt,onOpenChange:fn,onOpenChangeComplete:dn,children:[(0,$.jsxs)(Ce,{render:(0,$.jsx)(Kc,{ref:vt,active:yt,selected:Ze,"data-session-row":He.id,"data-session-scope":Ge??``,"data-session-focus-scope":V,"data-session-focus-key":_t,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:On,className:Y(yt&&!Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,Ze&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!yt&&!Ze&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Gn&&`py-1`)}),children:[lr,(0,$.jsx)(Wc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ti,{onOpenChange:Jt,children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsxs)(Sc,{type:`button`,"data-session-title":!0,onPointerDown:An,onPointerUp:jn,onPointerCancel:jn,onMouseDown:kn,onKeyDown:Mn,onBlur:Pn,onClick:Nn,onDoubleClick:e=>{e.stopPropagation(),!L&&I()&&un()},className:Y(Me&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Un&&`gap-0.5`,!Un&&Oe),children:[Un?(0,$.jsxs)(`div`,{className:Y(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,Oe),children:[(0,$.jsx)(gl,{project:B?.project}),Yn&&!Kn?(0,$.jsx)(Zc,{}):null,(0,$.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate typography-micro leading-4`,Jn?`text-foreground/80`:`text-muted-foreground`),children:B?.projectLabel}),(0,$.jsx)(`span`,{className:Y(`shrink-0`,nr),children:er})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Gn?(0,$.jsx)(gl,{project:B?.project}):null,(0,$.jsx)(`div`,{className:Y(`block min-w-0 flex-1 truncate text-foreground`,Gn?`typography-meta`:`typography-ui-label`,Gn&&!Jn&&`text-muted-foreground`,Yn?`font-medium`:`font-normal`,Ln&&`animate-text-shimmer`),"aria-busy":Ln||void 0,children:go(bt,d)}),xt?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:xt}):null,Gn?(0,$.jsx)(`span`,{className:Y(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,nr),children:Wt}):null,We?(0,$.jsx)(Z,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Rn>0&&!Un?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(Z,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Rn})]}):null,Xn?(0,$.jsx)(`span`,{className:Y(`inline-flex shrink-0 items-center justify-center transition-none`,tr?Y(`group-hover:hidden group-focus-within:hidden`,Yt?`hidden`:``):Yt?`invisible`:``),children:rr}):null,ae?(0,$.jsx)(Fx,{number:ae}):null]}),Un?(0,$.jsxs)(`div`,{className:Y(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Jn?`text-foreground/60`:`text-muted-foreground/60`),children:[W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B?.branchLabel})]}):B?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):B?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(Z,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),Ft?(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),ce?null:(0,$.jsx)($r,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:qt?(0,$.jsx)(zb,{session:Ue,title:bt,time:Wt,projectLabel:B?.projectLabel,project:B?.project,branch:r.worktree?.branch??B?.branchLabel,directory:Ge}):null})]})})}),ur&&!L?(0,$.jsx)(`div`,{className:Y(`absolute top-1/2 -translate-y-1/2 z-10`,le?`right-0`:`right-[30px]`),children:ur}):null,(0,$.jsxs)(Cc,{visible:Yt||R&&!ce,className:Y(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Yt||R&&!ce?`opacity-100`:Y(`opacity-0`,me),Un&&`top-1.5 translate-y-0`),children:[xe?(0,$.jsx)(Nx,{pinned:Ft,pinLabel:t(Ft?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:we,iconSizeClass:Te,onPointerDown:pn,onMouseDown:mn,onPin:hn}):null,be?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,we),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:pn,onMouseDown:mn,onClick:yn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`pushpin-2-fill`,className:Te})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,ve?(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,we),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:Sn,onMouseDown:wn,onClick:En,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(Z,{name:`external-link`,className:Te})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(Px,{archiveLabel:t(gn&&It?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:gn&&It,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:we,iconSizeClass:Te,revealClassName:le&&!R&&!Yt?Y(`opacity-0`,me):`opacity-100`,onPointerDown:pn,onMouseDown:mn,onArchive:_n,onDelete:vn})]})]}),dr]})}),!q&&Pt&&Rt?r.children.map(e=>{let t=re?re(e):{subtreeContainsActive:ee,subtreeContainsEditing:te,menuOpenSessionId:ne,nodeStructureKey:``};return z(e,i+1,Ge??a,o,s,void 0,V,t)}):null,(0,$.jsx)(Zr,{open:et,onOpenChange:tt,children:(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Kr,{children:[(0,$.jsx)(Yr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Xr,{children:t(tn===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:tn})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:rt,onChange:e=>at(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(qr,{children:[(0,$.jsx)(J,{type:`button`,onClick:()=>tt(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{type:`button`,onClick:()=>{tt(!1),sn(rt)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Zt?(0,$.jsx)(xx,{session:Ue,open:Qt,onOpenChange:$t}):null]},He.id)}var Lx=e=>dt(e.session.directory??null),Rx=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),zx=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},Bx=e=>e.menuOpenSessionId??zx(e),Vx=(e,t,n)=>t?n.has(e.node.session.id)?!0:Nc(e.node,t):!1,Hx=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(Hx(e.children[a],t.children[a],n,r,i))return!0;return!1},Ux=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&bc(a)!==bc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(Ux(e.children[i],t.children[i],n,r))return!0;return!1},Wx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Hx(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Hx(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},Gx=Q.memo(Ix,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||Lx(e.node)!==Lx(t.node)||!Rx(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&Ux(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Hx(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&Wx(e,t)||e.currentSessionId!==t.currentSessionId&&(Vx(e,e.currentSessionId,e.subtreeContainsActive)||Vx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Vx(e,e.editingId,e.subtreeContainsEditing)||Vx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Vx(e,e.editingId,e.subtreeContainsEditing)||Vx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Nc(e.node,e.copiedSessionId)||Nc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Bx(e),r=Bx(t);if(Nc(e.node,n)||Nc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Bx(e),r=Bx(t);if(Nc(e.node,n)||Nc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function Kx(e){return e.stopPropagation()}function qx(e){return e.stopPropagation()}function Jx(e){let t=(0,Au.c)(71),{t:n}=Mr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Zr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Jr,m=!1,h=`max-w-sm gap-5`,l=Kr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Yr,{children:a}),t[18]=a,t[19]=p),c=Xr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(qr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function Yx(e){let t=(0,Au.c)(57),{t:n}=Mr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Yr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Xr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Kr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(qr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Zr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Xx(e){let t=(0,Au.c)(36),{t:n}=Mr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Yr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Xr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Kr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(qr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Jr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Zr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var Zx=e=>{let t=(0,Au.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Mr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Si,{children:[(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(_i,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(Z,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(yi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(bi,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(bi,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(xi,{}),(0,$.jsxs)(bi,{onClick:s,children:[(0,$.jsx)(Z,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(bi,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Z,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Z,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ti,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)($r,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ti,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},Qx=e=>{let{t}=Mr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Vb(e=>e.enabled),d=Vb(e=>e.selectedIds.size),f=d>0,p=Vb(e=>e.selectedIds),m=Vb(e=>e.scopeKey),h=Q.useCallback(()=>{Vb.getState().toggleMode()},[]),g=Q.useCallback(()=>{Vb.getState().disable()},[]),_=Q.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Q.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Q.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Q.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Q.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Q.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Q.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Q.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)_l({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&Sl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&X.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Vb.getState().clear()}},[c,_,p,t]),T=Q.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Q.useCallback(async()=>{l(null),await w()},[w]);return Q.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Vb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Vb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Vb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},$x=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],eS=Q.memo(function(e){let t=(0,Au.c)(9),{value:n,onChange:r}=e,{t:i}=Mr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=$x.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:Y(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(Z,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:Y(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),tS=e=>{let t=(0,Au.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`mr-3 typography-micro tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function nS(e){let t=(0,Au.c)(20),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Mr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(iS),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map(rS)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Hc,{className:`size-20`}),t[4]=e):e=t[4];let n;t[5]===a?n=t[6]:(n=a(`sessions.sidebar.task.empty`),t[5]=a,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 pt-6 pb-2`,children:[e,(0,$.jsx)(`div`,{className:`${To} !text-center`,children:n})]}),t[7]=n,t[8]=r),r}let u;t[9]!==n.active||t[10]!==r?(u=n.active.map(r),t[9]=n.active,t[10]=r,t[11]=u):u=t[11];let d=u,f;t[12]!==l||t[13]!==n.active.length||t[14]!==i||t[15]!==d||t[16]!==s?(f=i&&n.active.length>1?(0,$.jsx)(zc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:aS,onSessionsReordered:i,children:d}):d,t[12]=l,t[13]=n.active.length,t[14]=i,t[15]=d,t[16]=s,t[17]=f):f=t[17];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`div`,{className:`-ml-1 -mr-1 space-y-0.5`,children:f}),t[18]=f,t[19]=p),p}function rS(e){return[e,null]}function iS(e){return e.node.session.id}var aS=()=>{};function oS(e){let t=(0,Au.c)(21),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Mr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Z,{name:`archive`,className:`-ml-1 mr-0.5 size-3.5 shrink-0 text-foreground/55`}),t[2]=d):d=t[2];let f;t[3]===n.settledTotal?f=t[4]:(f=(0,$.jsx)(tS,{count:n.settledTotal}),t[3]=n.settledTotal,t[4]=f);let p;t[5]!==i||t[6]!==r||t[7]!==u||t[8]!==f?(p=(0,$.jsx)(yy,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,leadingIcon:d,accessory:f}),t[5]=i,t[6]=r,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==n.settled||t[11]!==l||t[12]!==a||t[13]!==r||t[14]!==c||t[15]!==o||t[16]!==s?(m=r?(0,$.jsxs)(`div`,{className:`-ml-1 -mr-2 max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`box-border flex w-full items-center gap-[3px] rounded-md px-2 py-1.5 text-left typography-meta text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(Z,{name:`arrow-down-s`,className:`-ml-0.5 size-4 shrink-0`}),s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})]}):null]}):null,t[10]=n.settled,t[11]=l,t[12]=a,t[13]=r,t[14]=c,t[15]=o,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}var sS={ids:[],baseline:{}},cS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,lS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!cS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},uS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},dS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=dt(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},fS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},pS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=fS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:fS(n,e,o,i)??s};function mS(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var hS=`yuri.sessions.sidebarView`,gS=`yuri.sessions.projectCollapse`,_S=`yuri.sessions.groupOrder`,vS=`yuri.sessions.groupCollapse`,yS=`yuri.sessions.activeSessionByProject`,bS=`yuri.sessions.expandedParents.v2`,xS=`yuri.sessions.expandedParents`,SS=ot(Ve()),CS=e=>{try{let t=SS.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},wS=e=>{try{let t=SS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},TS=e=>{try{let t=SS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},ES=(e,t,n)=>{let r=new Set;for(let t of e){let e=dt(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=dt(t.path)?.toLowerCase();e&&r.add(e)}return r},DS=(e,t,n)=>{if(e.time?.archived)return!0;let r=dt(mn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},OS=new Set,kS=[],AS={},jS=(e,t)=>{let n=Q.useRef(e);return n.current=e,Q.useMemo(()=>(...e)=>n.current(...e),[t])},MS=Q.memo(function(e){let t=(0,Au.c)(3),{onOpenChange:n}=e,r=El(de(PS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(jl,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),NS=Q.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Mr(),[s,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(``),h=Q.useRef(null),g=Q.useRef(null),[_,v]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[w,T]=Q.useState(new Set),E=Q.useMemo(()=>SS,[]),[O,k]=Q.useState(new Set),[A,j]=Q.useState(new Map),[M,N]=Q.useState(new Map),P=q(e=>e.isNewWorktreeDialogOpen),F=q(e=>e.setNewWorktreeDialogOpen),[I,L]=Q.useState(null),[R,z]=Q.useState(null),[B,V]=Q.useState(``),[ee,te]=Q.useState(null),[ne,re]=Q.useState(null),[ie,ae]=Q.useState(null),H=Sr(),U=$t(),oe=tl(),W=Yc(),se=fl(),ce=Kn(),le=q(e=>e.sidebarView),ue=q(e=>e.setSidebarView);Q.useEffect(()=>{let e=Ve().getItem(hS);e!==null&&(Ve().removeItem(hS),q.getState().sidebarView===`projects`&&_c(e)!==`projects`&&ue(_c(e)))},[ue]);let[de,fe]=Q.useState({settledOpen:!1,settledLimit:30}),pe=Q.useRef(new Map),me=Q.useRef(new Map),he=K(e=>{ue(e),Me({sidebarView:e})}),[ge,_e]=Q.useState(()=>CS(vS)),[ve,ye]=Q.useState(()=>TS(_S)),[be,xe]=Q.useState(()=>wS(yS)),Se=Q.useRef(null);Q.useEffect(()=>c(e=>{m(e)&&(Se.current=null,_e(CS(vS)),ye(TS(_S)),xe(wS(yS)),k(CS(gS)),T(CS(bS)))}),[]);let[Ce,we]=Q.useState(new Map),Te=Q.useRef(0),Ee=Fe(e=>e.homeDirectory),De=Fe(e=>e.currentDirectory),Oe=Fe(e=>e.setDirectory),ke=Qt(e=>e.projects),Ae=Q.useMemo(()=>ke.filter(e=>!e.hostId),[ke]),je=Q.useMemo(()=>ke.filter(e=>e.hostId).map(Tr),[ke]),[Ne,Pe]=Q.useState(()=>new Map),G=K((e,t)=>{Pe(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Ie=qc(a),[Le,Re]=Q.useState(new Map),ze=K((e,t)=>{Re(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),Be=Qt(e=>e.activeProjectId),He=Qt(e=>e.removeProject),Ue=Qt(e=>e.setActiveProjectIdOnly),We=Qt(e=>e.updateProjectMeta),Ge=Qt(e=>e.reorderProjectsById),Ke=q(e=>e.setActiveMainTab),qe=q(e=>e.activeMainTab),Je=Aa(),Ye=q(e=>e.setSettingsDialogOpen),Xe=q(e=>e.toggleHelpDialog),Ze=q(e=>e.setSessionSwitcherOpen),Qe=q(e=>e.setScheduledTasksDialogOpen),$e=q(e=>e.notifyOnSubtasks),et=q(e=>e.showDeletionDialog),tt=q(e=>e.setShowDeletionDialog),nt=ka(f,120),rt=Q.useMemo(()=>nt.trim().toLowerCase(),[nt]),it=rt.length>0,at=El(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ot=xn(e=>e.collapsedFolderIds),st=xn(e=>e.foldersMap),ct=xn(e=>e.sessionOrderByScope),lt=xn(e=>e.sessionOrderActivityByScope),ut=xn(e=>e.getFoldersForScope),ft=xn(e=>e.createFolder),pt=xn(e=>e.renameFolder),mt=xn(e=>e.deleteFolder),ht=xn(e=>e.addSessionToFolder),gt=xn(e=>e.addSessionsToFolder),_t=xn(e=>e.removeSessionFromFolder),vt=xn(e=>e.removeSessionsFromFolders),yt=xn(e=>e.toggleFolderCollapse),bt=xn(e=>e.getSessionFolderId),xt=xn(e=>e.reorderSessions);oy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let Ct=Q.useMemo(()=>new Map,[]),wt=yn({enabled:a,includeChildren:!0}),Tt=vc({enabled:a}),Et=Ic({enabled:a}),Dt=Dn(e=>a?e.index.session.unseenCount:AS),Ot=Q.useMemo(()=>D(),[]),kt=an(e=>e.status),At=an(e=>e.activeSessions),jt=an(e=>e.archivedSessions),Mt=an(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Nt=an(e=>e.archivedLoadingDirectories),Pt=Q.useDeferredValue(At),Ft=Q.useDeferredValue(jt),It=Bn(e=>e.currentSessionId),Bt=wn(e=>e.remoteSession!==null)?null:It,Vt=lo(e=>e.focus),Ht=Q.useSyncExternalStore(zt,Lt,Lt),Ut=Bn(e=>!!e.newSessionDraft?.open),Wt=Bn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),Gt=Q.useMemo(()=>!e&&qe===`chat`&&Wt&&Ht.sessionId===null?{projectId:Wt,revision:Ht.revision}:null,[e,qe,Wt,Ht]),Kt=Bn(e=>e.setCurrentSession),qt=Bn(e=>e.updateSessionTitle),Jt=Bn(e=>e.shareSession),Yt=Bn(e=>e.unshareSession),Xt=Bn(e=>e.worktreeMetadata),tn=Bn(e=>e.availableWorktreesByProject),rn=Bn(e=>e.openNewSessionDraft),on=K(t=>{let n=je.find(e=>e.id===(t?.selectedProjectId??Qt.getState().activeProjectId));if(n){lc(n,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),rn(t),Ot&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),sn=Q.useMemo(()=>ES(Ae,tn,{includeWorktrees:!Ot}),[tn,Ot,Ae]),cn=Q.useMemo(()=>{let e=new Map(wt.map(e=>[e.id,e])),t=Pt.map(t=>{let n=e.get(t.id);return n?Yn(n,t):t}),n=new Set(t.map(e=>e.id));return wt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>DS(e,sn,{allowUnknownDirectory:!Ot,allowEmptyDirectorySet:!Ot}))},[Pt,Ot,sn,wt]),ln=Q.useMemo(()=>wt.map(e=>{let t=dt(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[wt]),un=Q.useRef(wt);Q.useEffect(()=>{un.current=wt},[ln,wt]);let dn=Q.useMemo(()=>new Map(wt.map(e=>[e.id,e])),[wt]);Q.useEffect(()=>{let e=null,t=St(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=Qt.getState().projects.find(e=>e.id===t.projectId),n=dt(e?.path??null);if(!n)return;let r=[n];(Bn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),qn(r,un.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let fn=Q.useMemo(()=>y(),[]),pn=gu(e=>e.sidebarBrandName.trim().length>0),{isTablet:hn,isDesktop:_n}=di(),vn=e||hn,{buildGroupSearchText:bn,filterSessionNodesForSearch:Sn,buildGroupedSessions:Cn}=Dc({homeDirectory:Ee,worktreeMetadata:Xt,pinnedSessionIds:H,gitBranches:Ct,isVSCode:Ot}),{scheduleCollapsedProjectsPersist:Tn,hasRestoredProjectCollapse:En}=py({isVSCode:Ot,safeStorage:E,keys:{sessionExpanded:bS,sessionExpandedLegacy:xS,projectCollapse:gS,groupOrder:_S,projectActiveSession:yS,groupCollapse:vS},groupOrderByProject:ve,activeSessionByProject:be,collapsedGroups:ge,setExpandedParents:T,setCollapsedProjects:k}),On=Q.useMemo(()=>[...cn].sort((e,t)=>yo(e,t,H)),[cn,H]),kn=Q.useMemo(()=>{let e=new Map;return On.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>yo(e,t,H))),e},[On,H]),An=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),jn=Q.useMemo(()=>Ae.find(e=>e.id===S)??null,[Ae,S]),Nn=Q.useCallback(e=>{S&&We(S,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[S,We]),Pn=Q.useCallback(()=>{F(!0)},[F]),Fn=Q.useCallback((t,n)=>{if(Ke(`chat`),e&&Ze(!1),!n?.remote){if(n?.sessionId){Kt(n.sessionId,t);return}rn({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,rn,Ke,Kt,Ze]),In=K(()=>{let e=El.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=El.getState();if(t){X.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){X.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Ln=Q.useCallback(()=>{e&&Ze(!1),Ye(!0)},[e,Ze,Ye]),Rn=K(()=>{let t=je.find(e=>e.id===Qt.getState().activeProjectId);if(t){lc(t,e).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),Ke(`chat`),rn(),e&&Ze(!1)}),zn=Q.useCallback(()=>{if(!e){Ke(`schedule`);return}Qe(!0),Ze(!1)},[e,Ke,Qe,Ze]),Vn=Q.useCallback(()=>{Vr(),e&&Ze(!1)},[e,Ze]),Hn=Bn(e=>e.archiveSession),Un=Bn(e=>e.archiveSessions),{copiedSessionId:Wn,handleSessionSelect:Jn,handleSessionDoubleClick:Xn,handleSaveEdit:Zn,handleCancelEdit:Qn,handleShareSession:$n,handleCopyShareUrl:er,handleUnshareSession:tr,handleDeleteSession:nr,confirmDeleteSession:rr}=sy({activeProjectId:Be,currentDirectory:De,currentSessionId:Bt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ue,setDirectory:Oe,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,setCurrentSession:Kt,updateSessionTitle:qt,shareSession:Jt,unshareSession:Yt,archiveSession:Hn,archiveSessions:Un,childrenMap:kn,showDeletionDialog:et,setDeleteSessionConfirm:te,deleteSessionConfirm:ee,setEditingId:v,setEditTitle:x,editingId:_,editTitle:b}),ir=Q.useCallback((e,t,n,r=`project`)=>{wn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===Bt){Rt(e),jx(i),Jn(e,t,n);return}kx(i,()=>Jn(e,t,n))},[Jn,Bt]);Q.useEffect(()=>()=>{Ox()},[]);let ar=Q.useCallback(()=>{if(!ne)return;let{scopeKey:e,folderId:t}=ne;re(null),mt(e,t)},[ne,mt]);Q.useEffect(()=>{if(!Bt)return;let e=cn.find(e=>e.id===Bt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{E.setItem(bS,JSON.stringify(Array.from(n)))}catch{}return n})},[Bt,cn,E]);let cr=Q.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{E.setItem(bS,JSON.stringify(Array.from(n)))}catch{}return n})},[E]),lr=Q.useCallback((e,t)=>{if(!e)return null;t&&ot.has(t)&&yt(t);let n=ft(e,o(`sessions.sidebar.folder.newFolderName`),t);return z(n.id),V(n.name),n},[ot,yt,ft,o]),ur=K(ir),dr=K(Xn),fr=K(Zn),pr=K(Qn),hr=K($n),gr=K(er),_r=K(tr),vr=K(nr),yr=K(lr),br=K((e,t,n,r)=>{let i=gc(),a=Math.max(i,n)+7;if(N(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=dt(e.directory??null);if(!o)return;let s=an.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&nn(o)}),xr=K(e=>{N(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Cr=K(e=>{N(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),wr=Q.useMemo(()=>e=>{let t=Ae.find(t=>t.id===e),n=dt(t?.path??null);if(!n)return[];let r=[n];return Ot||(tn.get(n)??[]).forEach(e=>{let t=dt(e.path);t&&r.push(t)}),r},[tn,Ot,Ae]),Er=K(e=>{let t=wr(e);if(t.length===0)return;let n=an.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&qn(r,un.current)}),Dr=K(e=>{let t=Ae.find(t=>t.id===e);t&&(async()=>{let e=[];if(!Ot)try{e=(await Rs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=dt(t.path);e=r?Bn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=dS(t.path,e,{currentDirectory:De,workspaceRoot:t.path,includeWorktrees:!Ot});n.length!==0&&await gn(n,un.current)})()});Q.useEffect(()=>{if(!En)return;let e=an.getState(),t=Ae.flatMap(t=>O.has(t.id)?[]:wr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&qn(t,un.current)},[O,wr,En,Ae]);let Or=K(()=>{Te.current=Date.now()+150,N(new Map),k(()=>{let e=new Set(Ae.map(e=>e.id));try{E.setItem(gS,JSON.stringify(Array.from(e)))}catch{}return Ot||Tn(e),e})}),kr=K(()=>{Te.current=Date.now()+150,N(new Map),k(()=>{let e=new Set;try{E.setItem(gS,JSON.stringify([]))}catch{}return Ot||Tn(e),e});let e=an.getState().loadedDirectories,t=Ae.flatMap(t=>wr(t.id).filter(t=>!e.has(t)));t.length>0&&qn(t,un.current)}),Ar=K(e=>{Te.current=Date.now()+150,Cr(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Er(e))):n.add(e);try{E.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return Ot||Tn(n),n})}),jr=K(e=>{Te.current=Date.now()+150,Er(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{E.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return Ot||Tn(n),n})}),Nr=Q.useMemo(()=>Ae.map(e=>({...e,normalizedPath:dt(e.path)})).filter(e=>!!e.normalizedPath),[Ae]),Pr=Q.useMemo(()=>new Map(Nr.map(e=>[e.id,sr(e.normalizedPath)||e.normalizedPath])),[Nr]),Fr=Q.useMemo(()=>Nr.map(e=>e.normalizedPath),[Nr]),Ir=Q.useMemo(()=>{let e=new Set(Nr.map(e=>e.normalizedPath));if(!Ot)for(let t of tn.values())for(let n of t){let t=dt(n.path);t&&e.add(t)}return[...e].sort()},[tn,Ot,Nr]),Lr=Q.useRef(null);Q.useEffect(()=>{let e=new Set(Ir),t=Lr.current;if(Lr.current=e,!t)return;let n=Ir.filter(e=>!t.has(e));if(n.length===0)return;let r=an.getState().loadedDirectories,i=dt(De),a=Nr.find(e=>e.id===Be)??Nr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),Ot||(tn.get(a.normalizedPath)??[]).forEach(e=>{let t=dt(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&qn(s,un.current)},[Be,tn,De,Ot,Nr,Ir]);let Rr=Yi(a?Fr:kS);hy({normalizedProjects:Nr,activeProjectId:Be,gitRepoStatus:Rr,setProjectRepoStatus:j,setProjectRootBranches:we,enabled:a});let zr=Q.useMemo(()=>Nl(cn,Nr,tn,Ot,Ft),[Ft,tn,Ot,Nr,cn]),{getSessionsForProject:Br,getArchivedSessionsForProject:Hr}=gy({ownership:zr}),Ur=Mt||kt===`idle`||kt===`loading`,Wr=Q.useRef(!1);Be&&A.has(Be)&&(Wr.current=!!A.get(Be));let Gr=en(e=>e.projectSortOrder),Kr=Q.useMemo(()=>el(Nr,Gr),[Nr,Gr]),{projectSections:qr,groupSearchDataByGroup:Jr,sectionsForRender:Yr,searchMatchCount:Xr}=ry({normalizedProjects:Kr,getSessionsForProject:Br,getArchivedSessionsForProject:Hr,availableWorktreesByProject:tn,projectRepoStatus:A,projectRootBranches:Ce,lastRepoStatus:Wr.current,buildGroupedSessions:Cn,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,filterSessionNodesForSearch:Sn,buildGroupSearchText:bn,foldersMap:st}),Zr=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});iy({projectSections:qr,activeProjectId:Be,activeSessionByProject:be,setActiveSessionByProject:xe,currentSessionId:Bt,handleSessionSelect:Jn,newSessionDraftOpen:Ut,mobileVariant:e,openNewSessionDraft:rn,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze});let{getOrderedGroups:Qr}=ay(ve),$r=Q.useRef(!1);Q.useEffect(()=>{if($r.current||qr.length===0)return;let e=qr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&_e(t=>new Set([...t,...e])),$r.current=!0},[qr]);let ei=Q.useMemo(()=>{let e=new Map,t=new Map;return qr.forEach(n=>{let r=sr(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[qr]);Q.useLayoutEffect(()=>{if(!Bt){jx(null);return}let e=lo.getState().focus;if(e?.sessionId===Bt){e.scope===`project`&&!e.projectId&&jx({...e,projectId:ei.get(Bt)?.projectId??null});return}jx({scope:`project`,sessionId:Bt,projectId:ei.get(Bt)?.projectId??null})},[Bt,ei]);let ti=Q.useMemo(()=>Ot?[]:kc(cn,H,ct[Tc]),[Ot,H,cn,ct]),ni=K((e,t)=>{_||xt(Tc,si.map(e=>e.node.session.id),e,t,{}).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),ri=Q.useMemo(()=>it?[]:Bc(cn,H,Et,Dt),[it,H,Et,cn,Dt]),{pinnedItems:ii,inProgressItems:ai}=Q.useMemo(()=>{let e=e=>{let t=ei.get(e.id),n=dt(e.directory??null),r={session:e,children:[],worktree:Xt.get(e.id)??null};if(it&&Sn([r],rt).length===0)return null;let i=zr.bySessionId.get(e.id),a=i?Kr.find(e=>e.id===i.projectId):void 0,o=a?sr(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=mc({projectLabel:o,owner:i,sessionWorktree:Xt.get(e.id)??null,worktrees:a?tn.get(a.normalizedPath)??[]:[],projectRootBranch:i?Ce.get(i.projectId)??(a?Rr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:Ot})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:Ot?[]:t(ti),inProgressItems:t(ri)}},[tn,Sn,Rr,it,ri,Ot,rt,ti,Ce,zr,ei,Kr,Xt]),oi=Q.useMemo(()=>je.flatMap(e=>Ne.get(e.id)??[]),[je,Ne]),si=Q.useMemo(()=>Cl([...ii,...oi.filter(e=>e.pinned)],e=>e.node.session.id,ct[Tc]),[ii,oi,ct]),ci=Q.useMemo(()=>[...ai,...oi.filter(e=>!e.pinned)].sort((e,t)=>or(t.node.session)-or(e.node.session)),[ai,oi]),li=!e&&!Ot&&!r&&!i,ui=li&&le===`tasks`&&!it,fi=yl(Et,a&&li),[pi,mi]=Q.useState(sS),hi=Q.useMemo(()=>ui?vl({sessions:cn,pinnedSessionIds:H,settledSessionIds:oe,indexedSessionIds:W?.indexedIds??null,settledAtBySessionId:W?.settledAtById,runningSessionIds:Et,pendingRequestSessionIds:ce,unseenBySession:Dt}):null,[ce,H,Et,cn,oe,W,ui,Dt]),gi=Q.useMemo(()=>{let e=hi?.settled.filter(e=>!oe.has(e.id));return e?.length?new Set([...oe,...e.map(e=>e.id)]):oe},[hi,oe]),_i=K(e=>({activityAt:or(e),running:Et.has(e.id),attention:Fc(e.id,ce,Dt)})),vi=Q.useMemo(()=>{if(!hi)return null;let e=lS(hi.active,e=>e.id,_i,pi);return e===hi.active?hi:{...hi,active:e}},[hi,_i,pi]),yi=K((e,t)=>{if(_||!vi)return;let n=new Map(vi.active.map(e=>[e.id,e])),r=uS(vi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?_i(t):void 0});r&&mi(r)}),bi=K((e,t,n)=>{if(!ui||qe!==`chat`||Bt!==e||Lt()!==n)return;let r=[...ti,...vi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){Ox(),jx(null),rn();return}let a=zr.bySessionId.get(i.id);ir(i.id,a?.scopeDirectory??dt(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),xi=K((e,t)=>{if(!t&&hi?.settled.some(t=>t.id===e&&t.time?.archived)){mr(e);return}if(!t||!ui||Bt!==e){se(e,t);return}let n=[...ti,...vi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Lt();se(e,!0,{onSuccess:()=>bi(e,i?.id??null,a)})}),Si=li?xi:void 0,Ci=Q.useMemo(()=>{if(!vi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(Kr.map(e=>[e.id,sr(e.normalizedPath)||e.normalizedPath])),n=me.current,r=new Map(Kr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of Kr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=pe.current,s=new Map,c=n=>o=>{let c=zr.bySessionId.get(o.id),l=ei.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??dt(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?Rr.get(m):void 0,g=Xt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?Ce.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?Gn(m,Ee):null,x=g,S=n?fi.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=de.settledOpen?vi.settled.slice(0,de.settledLimit):[],u={pinned:ti.map(c(!0)),active:vi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:vi.settled.length};return pe.current=s,u},[Rr,Ee,ti,Ce,fi,zr,ei,Kr,o,vi,de.settledLimit,de.settledOpen,Xt]),wi=Q.useMemo(()=>{if(!Ci)return si;let e=new Map(Ci.pinned.map(e=>[e.node.session.id,e]));return si.map(t=>e.get(t.node.session.id)??t)},[si,Ci]),Ti=Q.useMemo(()=>{if(!vi||!Ci)return[];let e=new Map([...Ci.active,...Ci.settled].map(e=>[e.node.session.id,e]));return yc(vi,de).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:dt(mn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[vi,Ci,de]),Ei=Q.useMemo(()=>Yr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Yr]),Di=Q.useMemo(()=>{let e=it?Ei.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Jr.get(e)?.filteredNodes??[]}))})):Ei;if(!i)return e;let t=e.find(e=>e.project.id===Be)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[Be,Jr,it,Ei,i]),Oi=Q.useMemo(()=>bl({sections:Di,foldersMap:st,getOrderedGroups:Qr,pinnedSessionIds:H,sessionOrderByScope:ct,sessionOrderActivityByScope:lt}),[st,Qr,Di,H,lt,ct]),ki=Q.useMemo(()=>Uc({targets:Oi,collapsedProjectIds:O,collapsedGroupKeys:ge,collapsedFolderIds:ot,visibleSessionCountByGroup:M,defaultVisibleSessionCount:gc(),hasSessionSearchQuery:it,alwaysVisibleSessionIds:Tt}),[Tt,ot,ge,O,it,Oi,M]),Ai=Q.useMemo(()=>it?[]:(ui?si:[...si,...ci]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:dt(mn(n))??e.groupDirectory??null,visibleIndex:t}}),[it,ci,si,ui]),[ji,Mi]=Q.useState(null),Ni=Q.useCallback(e=>{Mi(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Pi=Q.useMemo(()=>{if(!ji)return Ai;let e=new Set(ji);return Ai.filter(t=>e.has(t.sessionId))},[Ai,ji]),Fi=Q.useMemo(()=>!a&&Se.current?Se.current:{pinned:Pi,project:ui?Ti:ki},[a,Ti,ui,Pi,ki]);Q.useLayoutEffect(()=>{a&&(Se.current=Fi)},[a,Fi]);let Ii=Q.useMemo(()=>e?[]:oo({pinnedTargets:Fi.pinned,projectTargets:ui?Fi.project:ke.flatMap(e=>e.hostId?Le.get(e.id)??[]:Fi.project.filter(t=>t.projectId===e.id))}),[e,ui,Fi,ke,Le]),Li=Q.useCallback(t=>{let n=je.find(e=>e.id===t.projectId);if(n&&Ie.registry){let r=Ne.get(n.id)?.find(e=>e.identity===t.sessionId);cc(n,Ie.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Ke(`chat`),Ze(!1),t.scope===`project`&&t.projectId&&Ue(t.projectId),ir(t.sessionId,t.directory,t.projectId,t.scope)},[ir,Ke,Ue,Ze,je,Ie.registry,Ne,e]);Q.useLayoutEffect(()=>no({targets:Ii,activate:Li}),[Li,Ii]);let Ri=Q.useMemo(()=>{let e=new Map;return Ii.forEach(t=>{let n=Za({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Ja(Ii,t)??0)}),e},[Ii]),zi=Q.useMemo(()=>{if(!Bt||it)return[];let e=[],t=(n,r)=>{if(n.session.id===Bt){e.push({scope:`pinned`,sessionId:Bt,projectId:r});return}n.children.forEach(e=>t(e,r))};return si.forEach(e=>t(e.node,e.projectId)),ai.forEach(e=>t(e.node,e.projectId)),e},[Bt,it,ai,si]),Bi=Q.useMemo(()=>{if(!Bt)return[];let e=[],t=(n,r)=>{if(n.session.id===Bt){e.push({scope:`project`,sessionId:Bt,projectId:r});return}n.children.forEach(e=>t(e,r))};return qr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[Bt,qr]);Q.useLayoutEffect(()=>ro({pinned:Fi.pinned,project:Fi.project}),[Fi]),Q.useLayoutEffect(()=>{!a||Ur||jx(pS({currentSessionId:Bt,focus:Vt,pinnedFocuses:zi,projectFocuses:Bi,fallbackProjectId:Bt?ei.get(Bt)?.projectId??null:null}))},[Bt,a,Ur,Bi,zi,Vt,ei]);let Vi=Q.useMemo(()=>{let e=Vt?.sessionId?ei.get(Vt.sessionId)?.projectId??null:null;return mS(Vt,Oi,e)},[Oi,Vt,ei]),Hi=Q.useRef(null),Ui=Q.useRef(null);Q.useEffect(()=>{Ui.current&&Ui.current!==Bt&&(Ui.current=null)},[Bt]),Q.useLayoutEffect(()=>{if(!Vi?.projectId)return;let e=Vi.sessionId,t=Ht.sessionId===e;if(!(!t&&Bt!==e)){if(t){if(Hi.current===Ht.revision)return;Hi.current=Ht.revision,Ui.current=e}else{if(Ui.current===e)return;Ui.current=e}if(jr(Vi.projectId),Vi.groupKey&&_e(e=>{if(!e.has(Vi.groupKey))return e;let t=new Set(e);return t.delete(Vi.groupKey),t}),Vi.folderAncestorIds?.forEach(e=>{let t=xn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Vi.groupKey&&Vi.visibleIndex!==void 0){let e=Vi.visibleIndex+1;N(t=>{if((t.get(Vi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Vi.groupKey,e),n})}}},[Bt,Vi,Ht]);let Wi=jS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(Gx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:Bt,pinnedSessionIds:H,settledSessionIds:gi,setSessionSettled:Si,expandedParents:w,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,notifyOnSubtasks:$e,editingId:_,setEditingId:v,editTitle:b,setEditTitle:x,handleSaveEdit:fr,handleCancelEdit:pr,toggleParent:cr,handleSessionSelect:ur,handleSessionDoubleClick:dr,togglePinnedSession:U,handleShareSession:hr,copiedSessionId:Wn,handleCopyShareUrl:gr,handleUnshareSession:_r,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,renamingFolderId:R,getFoldersForScope:ut,getSessionFolderId:bt,removeSessionFromFolder:_t,addSessionToFolder:ht,createFolderAndStartRename:yr,handleDeleteSession:vr,mobileVariant:e,alwaysShowActions:vn,renderSessionNode:Wi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??OS,subtreeContainsEditing:c?.subtreeContainsEditing??OS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:dn,shortcutNumber:Ri.get(Za({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...Ri])),Gi=Q.useCallback(e=>{xr(e),_e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[xr]),Ki=Q.useCallback(e=>{let t=wr(e);if(t.length===0)return;let n=an.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&Zt(r)},[wr]),qi=K((e,t,n,r,i)=>{let a=e.folderScopeKey??dt(e.directory??null);a&&xt(a,t,n,r,i).catch(()=>X.error(o(`sessions.order.saveFailed`)))}),Ji=K((e,t,n)=>{e.isArchivedBucket&&ge.has(t)&&n&&Ki(n),Gi(t)}),Xi=Q.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(fc,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&wr(r).some(e=>Nt.has(e))),projectId:r,projectLabel:r?Pr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,groupSearchDataByGroup:Jr,visibleSessionCount:M.get(n),collapsedGroups:ge,collapsedFolderIds:ot,toggleFolderCollapse:yt,renameFolder:pt,deleteFolder:mt,showDeletionDialog:et,setDeleteFolderConfirm:re,renderSessionNode:Wi,projectRepoStatus:A,lastRepoStatus:Wr.current,showMoreGroupSessions:br,resetGroupSessionLimit:xr,mobileVariant:e,alwaysShowActions:vn,activeProjectId:Be,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:on,addSessionToFolder:ht,createFolderAndStartRename:yr,renamingFolderId:R,renameFolderDraft:B,setRenameFolderDraft:V,setRenamingFolderId:z,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:ct,sessionOrderActivityByScope:lt,onReorderSessions:qi,currentSessionId:Bt,shortcutTargetSessionId:Vi?.groupKey===n?Vi.sessionId:null,shortcutTargetVisibleIndex:Vi?.groupKey===n?Vi.visibleIndex??null:null,editingId:_,editTitle:b,openSidebarMenuKey:I,liveSessionById:dn,alwaysVisibleSessionIds:Tt,onToggleCollapsedGroup:Ji,dragHandleProps:a,scrollContainerRef:s}),[it,rt,Jr,Pr,Nt,wr,M,ge,ot,yt,pt,mt,et,Wi,A,br,xr,e,vn,Be,Ue,Ke,Ze,on,ht,yr,R,B,H,w,ct,lt,qi,Bt,Vi,_,b,I,dn,Tt,Ji]),Zi=ui?(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Mn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})}):null,Qi=li?(0,$.jsx)(eS,{value:le,onChange:he}):void 0,$i=e=>Wi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),ea=ui&&Ci?(0,$.jsx)(nS,{items:Ci,renderTaskRow:$i,onSessionsReordered:yi}):void 0,ta=ui&&Ci?(0,$.jsx)(oS,{items:Ci,open:de.settledOpen,onToggle:()=>fe(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>fe(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:$i}):void 0,na=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ky,{collapseAllProjects:Or,expandAllProjects:kr}),(0,$.jsx)(J,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Mn.requestDirectoryDialog,children:(0,$.jsx)(Z,{name:`add`,className:`size-4`})})]}),ra=fn&&pn&&!Ot&&!it?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(yf,{className:`min-w-0 flex-1`}),(0,$.jsx)(al,{className:`ml-auto shrink-0`})]})}):null,ia=!Ot&&!it,aa=ia&&_n&&!e,oa=ui?[]:ci,sa=!it&&(si.length>0||oa.length>0),ca=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:Rn,children:[(0,$.jsx)(Z,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:zn,children:[(0,$.jsx)(Z,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Hv,{}):null]}),Je.data?.supported&&Je.data?.enabled?(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`w-full justify-start px-2 font-normal`,qe===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Vn,children:[(0,$.jsx)(ll,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Bl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Uv,{}):null]})]}):null,(0,$.jsx)(Tu,{sidebar:!0,mobile:e})]}),la=li&&!it,ua=sa?(0,$.jsx)(by,{isFirst:la,hideHeader:ui,items:wi,reorderEnabled:!0,onSessionsReordered:ni,inProgressItems:oa,renderSessionNode:Wi,currentSessionId:Bt,editingId:_,openSidebarMenuKey:I,onVisibleSessionIdsChange:Ni}):null,da=ia&&!aa||sa&&!la?(0,$.jsxs)($.Fragment,{children:[ia&&!aa?(0,$.jsxs)($.Fragment,{children:[e&&pn?(0,$.jsx)(yf,{}):null,ca]}):null,la?null:ua]}):null,fa=!!(R||_||S),{selectionModeEnabled:pa,hasSelection:ma,selectedIdsSize:ha,bulkScopeIsArchived:ga,derivedSelectionScope:_a,bulkScopeFolders:va,bulkCanRemoveFromFolder:ya,handleExitSelectionMode:ba,handleBulkMoveToFolder:xa,handleBulkCreateFolderAndMove:Sa,handleBulkRemoveFromFolder:Ca,handleBulkDelete:wa,confirmBulkDelete:Ta}=Qx({isInlineEditing:fa,showDeletionDialog:et,foldersMap:st,addSessionsToFolder:gt,removeSessionsFromFolders:vt,createFolderAndStartRename:lr,archiveSessions:Un,setBulkDeleteConfirm:ae});return(0,$.jsxs)(`div`,{ref:h,className:Y(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(vy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:it,searchMatchCount:Xr}),ra,aa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ca}):null,a?(0,$.jsx)(bb,{remoteProjects:je,hostRegistry:Ie.registry,projectOrderIds:el(ke,Gr).map(e=>e.id),onRemoteActivityItems:G,remoteSearch:f,remoteError:Ie.catalog.error?.message,onRemoteNavigationTargets:ze,topContent:da,tabLeadingContent:la?ua:void 0,hasLeadingSection:da!==null&&!la&&(si.length>0||ai.length>0),headerAccessory:ui?Zi:na,headerSwitch:Qi,taskContent:ea,taskFooter:ta,sectionsForRender:Ei,projectSections:qr,activeProjectId:Be,projectRevealTarget:Gt,showOnlyMainWorkspace:i,hasSessionSearchQuery:it,emptyState:An,searchEmptyState:Zr,renderGroupSessions:Xi,homeDirectory:Ee,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:vn,toggleProject:Ar,setActiveProjectIdOnly:Ue,setActiveMainTab:Ke,setSessionSwitcherOpen:Ze,openNewSessionDraft:on,openNewWorktreeDialog:Pn,syncProjectSessions:Dr,openProjectEditDialog:C,removeProject:He,projectReorderEnabled:Gr===`manual`,reorderProjects:Ge,projectSortOrder:Gr,getOrderedGroups:Qr,setGroupOrderByProject:ye,openSidebarMenuKey:I,setOpenSidebarMenuKey:L,isInlineEditing:fa}):null,pa&&ma?(0,$.jsx)(Zx,{selectedCount:ha,scopeKey:_a,scopeFolders:va,archivedBucket:ga,onMoveToFolder:xa,onCreateFolderAndMove:Sa,onRemoveFromFolder:Ca,canRemoveFromFolder:ya,onDelete:wa,onDone:ba}):null,(0,$.jsx)(Jv,{normalizedProjects:Nr,ownership:zr,enabled:a}),(0,$.jsx)(ub,{onOpenSettings:Ln,onOpenShortcuts:Xe,onOpenUpdate:In,showRuntimeButtons:!Ot,showUpdateButton:at}),s?(0,$.jsx)(MS,{onOpenChange:l}):null,jn?(0,$.jsx)(_y,{open:!0,onOpenChange:e=>{e||C(null)},project:jn,onSave:Nn}):null,P?(0,$.jsx)(ds,{open:!0,onOpenChange:F,onWorktreeCreated:Fn}):null,(0,$.jsx)(cl,{}),(0,$.jsx)(vu,{}),(0,$.jsx)(Jx,{value:ee,setValue:te,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:rr}),(0,$.jsx)(Xx,{value:ne,setValue:re,onConfirm:ar}),(0,$.jsx)(Yx,{value:ie,setValue:ae,showDeletionDialog:et,setShowDeletionDialog:tt,onConfirm:Ta})]})});function PS(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var FS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,IS=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},LS=()=>{let{t:e}=Mr(),[t,n]=Q.useState(!1),[r,i]=Q.useState(),[a,o]=Q.useState(null),[s,c]=Q.useState([]),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(new Set),y=Bn(e=>e.getWorktreeMetadata),b=Bn(e=>e.newSessionDraft),x=Bn(e=>e.setNewSessionDraftTarget),S=Bn(e=>e.setDraftBootstrapPendingDirectory),C=pn,w=Bn(e=>e.archiveSessions),T=q(e=>e.showDeletionDialog),E=q(e=>e.setShowDeletionDialog),D=Fe(e=>e.currentDirectory),O=Fe(e=>e.homeDirectory),k=Qt(e=>e.projects),A=Qt(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=di(),P=j||M||N,F=Q.useMemo(()=>IS((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Q.useCallback(e=>{let t=IS(e.projectDirectory)||F;return{id:(k.find(e=>IS(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Q.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,B=z,V=p||!z||!R,ee=p||!z,te=Q.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Q.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Q.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);_l({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Q.useEffect(()=>Mn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Q.useEffect(()=>Mn.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Q.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(IS(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(IS(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Is(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=IS(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=IS(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Q.useEffect(()=>{R||u(!1)},[R]);let ie=Q.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=IS(t.path),o=IS(i.path);try{await Ls(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=IS(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),IS(D)===a&&o&&Fe.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return X.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:FS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Q.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);X.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:FS(i)})})()},[R,l,ie,e]),H=Q.useCallback(async()=>{if(a){m(!0);try{let t=B&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){X.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}Sl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else _l({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else _l({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&Sl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(X.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:FS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,B,z,ae,e]),U=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,W=a?(0,$.jsxs)(`div`,{className:Y(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:Y(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:Y(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:Y(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:Y(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:Y(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Z,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?Gn(U.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,se=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||u(e=>!e)},disabled:V,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,ce=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ee||f(e=>!e)},disabled:ee,className:Y(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,ee?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,le=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[ce,se]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(Z,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(Z,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(J,{variant:`destructive`,onClick:H,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),ue=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Es,{open:!!a,onClose:()=>{p||ne()},title:ue,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:le}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),W]})}):(0,$.jsx)(Zr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Jr,{className:Y(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(Kr,{children:[(0,$.jsxs)(Yr,{className:Y(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(Z,{name:`delete-bin`,className:`h-5 w-5`}),ue]}),oe&&(0,$.jsx)(Xr,{children:oe})]}),(0,$.jsx)(`div`,{className:Y(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:W}),(0,$.jsx)(qr,{className:`mt-2 gap-2 pt-1 pb-1`,children:le})]})}),(0,$.jsx)($c,{open:t,onOpenChange:n,origin:r})]})},RS=Q.createContext(null),zS=e=>{let t=(0,Au.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(RS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},BS=ya(()=>It(()=>import(`./TerminalView-CvTlu81P.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([84,1,4,2,5,3,6,7,8,9,10,23,24,25,22,26,27,20,85,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,86,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,87,67,88,70,89,90,91,92,93,94,95,96,97]))),VS=ya(()=>It(()=>import(`./DiagramView-CUCcpmvd.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([98,1,3,2,10,12,13,14,4,5,6,7,8,9,11,15,16,17,18,19,20,21,22,23,24,25,26,27,46,60,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,70,89,85,99,100]))),HS=ya(()=>It(()=>import(`./SettingsView-RULyRRQP.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([101,1,2,3,4,5,6,7,8,9,102,103,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,104,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,105,87,64,65,106,67,107,88,108,109,110,111,112,68,29,30,31,32,33,34,35,36,37,38,113,71,72,73,114,115,116,76,70,77,78,117,118,119,120,121,122,123,124,125,126,127,61,62,128,129,90,91,92,93,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,63,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,81,178,179,180,181,182]))),US=ya(()=>It(()=>import(`./SettingsWindow-DPPmIElK.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([183,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,101,102,103,104,60,105,87,64,65,106,67,107,88,108,109,110,111,112,68,29,30,31,32,33,34,35,36,37,38,113,71,72,73,114,115,116,76,70,77,78,117,118,119,120,121,122,123,124,125,126,127,61,62,128,129,90,91,92,93,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,63,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,81,178,179,180,181,182]))),WS=ya(()=>It(()=>import(`./MultiRunWindow-CyGYoQ6V.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([184,1,10,11,39,2,5,3,4,6,7,8,9,24,40,25,22,26,41,42,43,44,14,13,12,15,16,17,18,19,20,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,185,105,87,106,88,111,112,113,186,116,138,187,188,189,190,160,61,67,72,78,161,162,191,192,193,150,125,157,63,91,92,93,124,126,127,62,177,194,129]))),GS=ya(()=>It(()=>import(`./AssistantView-D91RZ13W.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([195,1,3,2,10,11,16,17,18,23,5,6,7,8,9,24,25,22,26,27,20,39,4,40,41,42,43,44,14,13,12,15,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,196,88,118,166,119,197,105,87,61,74,75,198,76,70,77,78,79,164,64,65,73,165,160,67,72,161,162,199,127,62,112,191,192,193,188,189,200,69,151,152,201,202,203,204,205,206,207,167,134,135,208,209,210,211,110,109]))),KS=()=>{let e=q(e=>e.isSidebarOpen),t=q(e=>e.isRightSidebarOpen),n=q(e=>e.isBottomTerminalOpen),r=q(e=>e.setRightSidebarOpen),i=q(e=>e.setBottomTerminalOpen),a=q(e=>e.activeMainTab),o=q(e=>e.setIsMobile),s=q(e=>e.isSessionSwitcherOpen),c=q(e=>e.isSettingsDialogOpen),l=q(e=>e.setSettingsDialogOpen),u=q(e=>e.isMultiRunLauncherOpen),d=q(e=>e.setMultiRunLauncherOpen),[f,p]=Q.useState(c),[m,h]=Q.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=di(),v=Q.useRef(!1),y=Q.useRef(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),O=Q.useCallback(e=>{x(e),q.getState().setSessionSwitcherOpen(e)},[]),k=Q.useRef(!1),A=Q.useRef(typeof window>`u`?0:window.innerWidth),j=Wr(-A.current),M=(0,Q.useRef)(0),N=Wr(A.current),P=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Q.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),Gr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Q.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),Gr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Q.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Q.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Q.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Q.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),q.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Q.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Bn.getState(),r=q.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Q.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Q.useEffect(()=>{q.getState().isMobile!==g&&o(g)},[g,o]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,q.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=q.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=q.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Q.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Q.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(kh,{isActive:!S})});case`diff`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Zl,{})});case`terminal`:return n?null:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(BS,{})});case`files`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(mp,{})});case`diagram`:return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,B=L||R||z,V=a===`chat`,ee=!B&&!c;return(0,$.jsx)(Ri,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:Y(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(il,{}),(0,$.jsx)(Pv,{}),(0,$.jsx)(Rv,{}),(0,$.jsx)(LS,{}),(0,$.jsx)(wl,{}),g?(0,$.jsxs)(zS,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!B&&(0,$.jsx)(Xd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:Y(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Jl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(GS,{})})})}),ee&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!V&&`invisible`),children:(0,$.jsx)(pc,{children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Yl,{})})})}),ee&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(pc,{children:(0,$.jsx)(Mo,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(ru,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(ks.div,{className:Y(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(NS,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(ks.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(pc,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(kh,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(HS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Mo,{children:(0,$.jsx)(ul,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(_f,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(vf,{}),children:(0,$.jsx)(NS,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:B?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:z?(0,$.jsx)(Hl,{}):R?(0,$.jsx)(GS,{}):(0,$.jsx)(Jl,{})})})}):(0,$.jsx)(pc,{children:(0,$.jsxs)(Mv,{header:(0,$.jsx)(Xd,{}),footer:(0,$.jsx)(cf,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(Mo,{children:(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(BS,{})})}):null}),children:[ee&&(0,$.jsx)(`div`,{className:Y(`absolute inset-0`,!V&&`invisible`),children:(0,$.jsx)(Mo,{children:(0,$.jsx)(Yl,{})})}),ee&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Mo,{children:I})})]})})})]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:f&&(0,$.jsx)(US,{open:c,onOpenChange:l})}),(0,$.jsx)(Q.Suspense,{fallback:null,children:m&&(0,$.jsx)(WS,{open:u,onOpenChange:d})})]})]})})},qS=9e4,JS=15e3,YS=3e5,XS=[2e3,5e3],ZS=6e4,QS=12e4,$S=3e5,eC=4,tC=432e5,nC=`yuri.github-pr-status`,rC=e=>e===`closed`||e===`merged`,iC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},aC=(e,t,n)=>`${e}::${t}`,oC=new Map,sC=new Map,cC=new Set,lC=new Map,uC=2,dC=0,fC=[],pC=()=>dC<uC?(dC+=1,Promise.resolve()):new Promise(e=>{fC.push(e)}),mC=()=>{let e=fC.shift();if(e){e();return}dC=Math.max(0,dC-1)},hC=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),gC=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,_C=e=>{let t=gC(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},vC=(e,t)=>Object.entries(e).filter(([,e])=>_C(e)===t).map(([e])=>e),yC=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},bC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},xC=(e,t,n)=>{let r=vC(e,t),i=r.map(t=>bC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=bC(e[n]);if(a&&_C(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&bC(e)));return o?bC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},SC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:gC(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),CC=e=>({...hC(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),wC=le()(ue((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:hC()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??hC();return{entries:{...e.entries,[t]:yC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??hC();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),oC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=sC.get(n)??[];i.push(r),sC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),XS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<YS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}rC(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(iC(r.status)?ZS:r.status?.checks&&r.status.checks.state!==`pending`?$S:QS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},JS);oC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=oC.get(n);typeof i==`number`&&window.clearInterval(i),oC.delete(n);let a=sC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),sC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=_C(a);if(!a||!o)return;let s=vC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=lC.get(o)??0;if(!r?.force&&Date.now()-l<qS||cC.has(o))return;let u=xC(i.entries,o,n);if(u){if(cC.add(o),lC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),cC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),cC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await pC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{mC()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=gC(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{cC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await my(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:aC(t,n,e.remoteName??null)}).filter(e=>!!e))),eC,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??hC();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:nC,storage:Ue(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=gC(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<tC}).map(([e,t])=>[e,SC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,CC(t)]))}}})),TC=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},EC=e=>{let t=(0,Au.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},DC=e=>{let t=(0,Au.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Mr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(kC,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?TC(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(EC,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(EC,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(EC,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Ur,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},OC=e=>{let t=(0,Au.c)(104),{onClose:n}=e,{t:r}=Mr(),[i,a]=Q.useState(`memory`),[o,s]=Q.useState(`idle`),c=Bn(AC),l=_r(jC),u=Fn(),d=vr(),[f,p]=Q.useState(MC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>Ze(()=>{p(Xe())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Q.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Ye(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(NC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(nt(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(PC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=wC(FC),[y,b]=Q.useState(IC),[x,S]=Q.useState(LC),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(Ae()),S(ze())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Q.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Q.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let B=z,V;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],V=u.map(e).sort(RC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=V}else V=t[40];let ee=V,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Ae(),vscode:ze()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let H;t[50]===i?H=t[51]:(H=i===`memory`?(0,$.jsx)(Z,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(Z,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=H);let U;t[52]===r?U=t[53]:(U=r(`memoryDebugPanel.title`),t[52]=r,t[53]=U);let oe;t[54]===U?oe=t[55]:(oe=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:U}),t[54]=U,t[55]=oe);let W;t[56]!==H||t[57]!==oe?(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,oe]}),t[56]=H,t[57]=oe,t[58]=W):W=t[58];let se;t[59]===i?se=t[60]:(se=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(Z,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(J,{size:`xs`,variant:`ghost`,onClick:()=>{G(),b(Ae()),S(ze())},children:(0,$.jsx)(Z,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=se);let ce;t[61]===n?ce=t[62]:(ce=n?(0,$.jsx)(J,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(Z,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=ce);let le;t[63]!==se||t[64]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[se,ce]}),t[63]=se,t[64]=ce,t[65]=le):le=t[65];let ue;t[66]!==W||t[67]!==le?(ue=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[W,le]}),t[66]=W,t[67]=le,t[68]=ue):ue=t[68];let de;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(de={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=de):de=t[69];let fe=i===`memory`?`secondary`:`ghost`,pe;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>a(`memory`),t[70]=pe):pe=t[70];let me;t[71]===r?me=t[72]:(me=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=me);let he;t[73]!==fe||t[74]!==me?(he=(0,$.jsx)(J,{size:`sm`,variant:fe,className:`flex-1`,onClick:pe,children:me}),t[73]=fe,t[74]=me,t[75]=he):he=t[75];let ge=i===`streaming`?`secondary`:`ghost`,_e;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(_e=()=>a(`streaming`),t[76]=_e):_e=t[76];let ve;t[77]===r?ve=t[78]:(ve=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ve);let ye;t[79]!==ge||t[80]!==ve?(ye=(0,$.jsx)(J,{size:`sm`,variant:ge,className:`flex-1`,onClick:_e,children:ve}),t[79]=ge,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]!==he||t[83]!==ye?(be=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:de,children:[he,ye]}),t[82]=he,t[83]=ye,t[84]=be):be=t[84];let xe;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==B||t[91]!==l||t[92]!==ee||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(xe=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:B.total}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${Ho.MAX_SESSIONS}`}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.userMessages`),value:B.user}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:B.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Yo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Ho.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Ur,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:ee.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(Z,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ti,{children:[(0,$.jsx)(Qr,{asChild:!0,children:(0,$.jsx)(J,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(zC),Object.keys(_),ee.map(BC),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)($r,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(J,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(EC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(DC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(DC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=B,t[91]=l,t[92]=ee,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=xe):xe=t[99];let Se;return t[100]!==ue||t[101]!==be||t[102]!==xe?(Se=(0,$.jsxs)(jo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[ue,be,xe]}),t[100]=ue,t[101]=be,t[102]=xe,t[103]=Se):Se=t[103],Se};function kC(e,t){return e+t.count}function AC(e){return e.currentSessionId}function jC(e){return e.sessionMemoryState}function MC(){return Xe()}function NC(e){return e.scope}function PC(e){return!!e}function FC(e){return e.totalRequestCount}function IC(){return Ae()}function LC(){return ze()}function RC(e,t){return t.lastAccessed-e.lastAccessed}function zC(e){return{id:e.id,title:e.title}}function BC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var VC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=q.getState();if(e)return;let n=Ui();n&&t(n)||I()&&v(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},HC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},UC=async()=>{let e=HC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},WC=`yuri:menu-action`,GC=`yuri:check-for-updates`,KC=e=>typeof e?.listen==`function`?`bridge`:`dom`,qC=e=>{let t=Bn(e=>e.openNewSessionDraft),n=q(e=>e.toggleCommandPalette),r=q(e=>e.setCommandPaletteOpen),i=q(e=>e.toggleHelpDialog),a=q(e=>e.toggleSidebar),o=q(e=>e.setSessionSwitcherOpen),s=q(e=>e.setActiveMainTab),c=q(e=>e.setSettingsDialogOpen),l=q(e=>e.setSettingsPage),u=q(e=>e.setAboutDialogOpen),d=q(e=>e.toggleContextPanel),f=q(e=>e.setRightSidebarOpen),p=q(e=>e.setRightSidebarTab),m=q(e=>e.toggleBottomTerminal),h=q(e=>e.setBottomTerminalExpanded),g=El(e=>e.checkForUpdates),{setThemeMode:_}=ii(),{t:v}=Mr(),y=Q.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=KC(b),S=Q.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=El.getState();if(t){X.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||X.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Q.useCallback(()=>{Mn.requestDirectoryDialog()},[]),w=Q.useCallback(e=>{ao(e,Bn.getState().currentSessionId,e=>{s(`chat`),o(!1),Bn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Q.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=Qt.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Q.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),us();break;case`change-workspace`:C();break;case`close-tab-or-window`:VC();break;case`toggle-right-sidebar`:{let e=Ui();e&&d(e);break}case`open-right-sidebar-git`:{let e=Ui();e&&q.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Ui();e&&q.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!q.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&UC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Ya();break;case`zoom-out`:Xa();break;case`zoom-reset`:co();break;case`go-back`:Fe.getState().goBack();break;case`go-forward`:Fe.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:po().catch(()=>{X.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Q.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(WC,e),window.addEventListener(GC,t),()=>{window.removeEventListener(WC,e),window.removeEventListener(GC,t)}},[E,S,x]),Q.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},JC=(e,t)=>e<t?-1:+(e>t),YC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(JC)]).sort(([e],[t])=>JC(e,t)));async function XC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var ZC=`yuri:tray-action`,QC=3e4,$C=120,ew=20,tw=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},nw=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},rw=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},iw=e=>or(e),aw=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},ow=(e,t,n,r)=>{if(!e)return``;let i=vn(t,n,e),a=aw(i?i.path:e),o=On(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Zi.getState().directories)if(On(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>On(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},sw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Ys.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Xs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:ec(n.label??t),value:Zs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},cw=async()=>{try{if(T())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&oe(t,e))return`Local Yuri`;let n=(await se()).hosts.find(e=>t?oe(t,U(e)):!1);return n?.label?.trim()?ce(n.label.trim()):`Instance`}catch{return``}},lw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=Qe()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(On(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:nw(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:rw(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},uw=()=>{let e=an.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>iw(t)-iw(e)).slice(0,ew).forEach(e=>{let n=mn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=mn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},dw=e=>{let t=lw(),n=Dn.getState().index.session,r=an.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Pn.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=Qt.getState().projects,d=Bn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>iw(t)-iw(e)).slice(0,ew).map(e=>{let r=[e.id,...o(e.id)],i=mn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:ow(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=q.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:sw(),dockBadgeCount:h}},fw=()=>{Q.useEffect(()=>{if(!tw()||!I())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=dw(r),i=JSON.stringify(n);i!==t&&(t=i,v(`desktop_tray_update`,n))};cw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=kn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=uw();return o=YC(t),a=XC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await tt.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{br(e,t,[...n])}}).finally(()=>{a=null;let t=uw();!e&&s()&&YC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},$C))},u=new Map,d=()=>{if(e)return;let t;try{t=Qe()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=Qe().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=Dn.subscribe(()=>l()),m=an.subscribe(()=>{l(),s()&&YC(uw())!==o&&c()}),h=Qt.subscribe(()=>l()),g=Bn.subscribe(()=>l()),_=Zi.subscribe(()=>l()),y=q.subscribe(()=>l()),b=Pn.subscribe(()=>l()),x=s(),S=kn.subscribe(()=>{let e=s();e&&!x&&c(),x=e});x&&c();let C=Ys.subscribe(()=>l());Ys.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Ys.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Ys.getState().fetchAllQuotas()});let w=window.setInterval(()=>{let e=Ys.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Ys.getState().refreshIntervalMs||6e4)),T=window.setInterval(()=>{d(),i()},QC);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(T),window.clearInterval(w),p(),m(),h(),g(),_(),y(),b(),S(),C(),f?.();for(let e of u.values())e();u.clear()}},[]),Q.useEffect(()=>{if(!tw()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&An(e.sessionId,e.id,e.response).catch(()=>{X.error(`Failed to respond to permission request`)})},n=null;return e(ZC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},pw=`/api/notifications/stream`,mw=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),hw=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},gw=e=>{let t=(0,Au.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||y()||!ie()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(pw));return e.onmessage=_w,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Q.useEffect(r,i)};function _w(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=q.getState();if(!n.nativeNotificationsEnabled)return;let r=hw(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&mw()||H()?.notifications?.notifyAgentCompletion(r))}var vw=`pwa-install-toast-shown`,yw=`pwa-install-toast-dismissed`,bw=()=>{let e=(0,Au.c)(6),{browserTab:t}=du(),{t:n}=Mr(),r=Q.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Q.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!ie()||!t)return;let e=null,n=null,i=()=>{n!==null&&(X.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&X.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Ve(),c=He();Ac({dismissed:s.getItem(yw),sessionShown:c.getItem(vw),hasActiveToast:n!==null})&&(c.setItem(vw,`true`),n=X.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{Ve().setItem(yw,`true`),i()}}}))},s=()=>{e=null,i(),X.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Q.useEffect(o,s)},xw=0;function Sw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++xw,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(q.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;It(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-BFoRE4u8.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([212,1,3,2,19,8,9,20,39,5,4,6,7,24,10,40,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,21,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59])).then(({applyRemoteProjectRoute:i})=>{if(n===xw)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===xw)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Bn.getState().setCurrentSession(t,r)}var Cw=({open:e,onOpenChange:t})=>{let{t:n}=Mr(),[r,i]=Q.useState(null),[a,o]=Q.useState(null);Q.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await kr())})()},[e]),Q.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Zr,{open:e,onOpenChange:t,children:(0,$.jsx)(Jr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Ao,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(Z,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},ww=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},Tw=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},Ew=()=>{let e=Pl(e=>e.completeAuth),[t,n]=Q.useState(`working`),[r,i]=Q.useState(`Completing MCP authorization...`);return Q.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=ww(t,`code`),a=lu(t),o=iu(t),s=ww(t,`error`),c=ww(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(Tw(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(J,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},Dw=()=>{let e=an(e=>e.startupSyncProgress.active),t=an(e=>e.startupSyncProgress.phase),n=an(e=>e.startupSyncProgress.completed),r=an(e=>e.startupSyncProgress.total),{locale:i,t:a}=Mr(),[o,s]=Q.useState(!0),c=Kt(i).startingApi;Q.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Q.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},Ow=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function kw(e){let t=(0,Au.c)(21),{transition:n,ready:r}=e,{t:i}=Mr(),a=wo(!0),[o,s]=Q.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=Ow(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Q.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(Ao,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var Aw=ya(()=>It(()=>import(`./OnboardingScreen-Bctdl4oS.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([213,1,4,2,5,3,6,7,8,9,102,10,40,24,25,22,26,41,42,43,44,14,11,13,12,15,16,17,18,19,20,21,23,27,45,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,116,145,67]))),jw=36e5,Mw=12e5,Nw=()=>{let e=(0,Au.c)(3),t=q(Bw),n=q(Vw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(Cw,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},Pw=e=>{let t=(0,Au.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Mr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(J,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},Fw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,Iw=()=>{if(typeof window>`u`||!Fo())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},Lw=()=>typeof window>`u`?!1:window.location.pathname===uu,Rw=e=>{let t=(0,Au.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=Fe(Hw),o=Bn(Uw),s=Bn(Ww),c=fs(),l=Q.useRef(null),u;t[0]===n.directory?u=t[1]:(u=Fw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=Fw(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Q.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)($a,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Yl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Pa,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function zw({apis:e}){Q.useEffect(()=>{We(`App:mounted`),Ge()},[]),Q.useEffect(()=>er(),[]);let t=kn(e=>e.initializeApp),n=kn(e=>e.isInitialized),r=kn(e=>e.isConnected),i=Bn(e=>e.error),a=Bn(e=>e.clearError),o=Bn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=Fe(e=>e.currentDirectory),l=Fe(e=>e.setDirectory),u=Fe(e=>e.isSwitchingDirectory),[d,p]=Q.useState(!1),m=Ml(e=>e.refreshStatus),[h,g]=Q.useState(()=>e.runtime.isVSCode),[_,b]=Q.useState(!1),[S,w]=Q.useState(!1),[E,D]=Q.useState(0),[O,k]=Q.useState(0),[j,M]=Q.useState({epoch:0,startedAt:0}),[P,I]=Q.useState(!1),L=Q.useRef(!1),R=q(e=>e.wideChatLayoutEnabled),z=q(e=>e.mobileKeyboardMode),B=Q.useMemo(()=>y(),[]),ee=an(e=>e.hasCachedSessionIndex),ne=an(e=>e.hasHydratedSessionIndex),[ie,H]=Q.useState(()=>N()),[U,oe]=Q.useState(()=>{let e=V();return e===null?null:re({isDesktopShell:!0,bootOutcome:e})}),W=Q.useRef(!1),se=Q.useMemo(()=>Iw(),[]),ce=!se||_,le=Q.useMemo(()=>Lw(),[]);Q.useEffect(()=>(je(d),()=>{je(!1)}),[d]),Q.useEffect(()=>{Bt(z)},[z]),Q.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Q.useEffect(()=>{let e=Ra(e=>{f(e)&&(B&&M(e=>({epoch:e.epoch+1,startedAt:Date.now()})),sl(e),k(e=>e+1),w(!1),D(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[B]),Q.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,R),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[R]),Q.useEffect(()=>(ae(e),()=>ae(null)),[e]),Q.useEffect(()=>{if(se)return;let t=!1;return Sn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,se,m]),so();let ue=ie===`valid`,de=U?.screen===`main`,[fe,pe]=Q.useState(!1);Q.useEffect(()=>{if(!ce||!te({isDesktopShell:B,isInitialized:B&&de?ee||n&&ne:n,bootOutcomeKnown:ue,bootViewIsMain:de}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),pe(!0)},300)):pe(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[ce,B,n,ue,de,ee,ne]),Q.useEffect(()=>{if(!B||ie!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[B,ie]),Q.useEffect(()=>{if(!ce||B)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[ce,B,n]),Q.useEffect(()=>{if(!ce||h)return;let e=!1;return Sn().then(()=>{if(!e)return t()}),()=>{e=!0}},[ce,t,h]),Q.useEffect(()=>{if(!ce||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){w(!0);return}let n=kn.getState();if(n.isInitialized){w(!1);return}if(r+=1,await Sn(),!e)return;await n.initializeApp();let o=kn.getState();if(!e)return;if(o.isInitialized){w(!1);return}if(r>=10){w(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[ce,E,n,h]),Q.useEffect(()=>{ce&&n&&w(!1)},[ce,n]),Q.useEffect(()=>{if(!ce||!S)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[ce,S]),Ga({enabled:ce&&!h,source:`startupRecovery`}),Q.useEffect(()=>{u||h||r&&tt.setDirectory(s)},[s,u,r,h]),Q.useEffect(()=>{if(!se||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;b(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Io},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[se]),Q.useEffect(()=>{!se?.directory||h||s!==se.directory&&l(se.directory,{showOverlay:!1})},[s,se,h,l]),Q.useEffect(()=>{if(!se||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&q.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[se]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;Sw(t??{})},t=e=>{let t=e.detail;It(async()=>{let{openSessionFromDeepLink:e}=await import(`./openSessionFromDeepLink-DMS6SIo7.js`);return{openSessionFromDeepLink:e}},__vite__mapDeps([214,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,44,14,11,13,12,15,16,17,18,19,21,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,207])).then(({openSessionFromDeepLink:e})=>e(t??{}))},n=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Vr(t.trim())},r=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&It(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-DpfZSGu8.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([167,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,20,134,135])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-session-link`,t),window.addEventListener(`yuri:open-assistant`,n),window.addEventListener(`yuri:open-scheduled-task`,r),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-session-link`,t),window.removeEventListener(`yuri:open-assistant`,n),window.removeEventListener(`yuri:open-scheduled-task`,r)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=Fe.getState().currentDirectory,{activeProjectId:t,projects:n}=Qt.getState(),r=n.find(e=>e.id===t)??null;v(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(wn.getState().remoteSession)return;let e=Bn.getState().currentSessionId;e&&ln(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;q.getState().setActiveMainTab(`chat`),q.getState().setSessionSwitcherOpen(!1);let s=Qt.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=wn.getState().remoteSession,c=s.activeProjectId;zl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&wn.getState().remoteSession===t&&Qt.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=wn.getState().remoteSession;o&&t&&await Rl(t.location,o)}).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),wn.getState().openRemoteSession(c,e,null),o&&Rl(e,o).catch(e=>X.error(e instanceof Error?e.message:String(e)));return}wn.getState().clearRemoteSession(),Bn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Q.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=Qt.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Q.useEffect(()=>{typeof window>`u`||!ce||!n||u||W.current||(W.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[ce,n,u]),Wa({enabled:ce}),gw({enabled:ce}),bw(),fo(),nl(),qC(K(()=>{p(e=>!e)})),Q.useEffect(()=>{C()&&Gt().then(async e=>{e&&await x(e)}).catch(console.warn)},[]),Q.useEffect(()=>{if(!n||!C()||L.current)return;L.current=!0;let e=!1,t=null,r=null;El.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=El.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(jw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=El.getState().lastChecked;t!=null&&Date.now()-t<Mw||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),fw(),Q.useEffect(()=>{if(se)return;let e=e=>{lr(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[se]),Q.useEffect(()=>{se||i&&setTimeout(()=>a(),5e3)},[a,se,i]),Q.useEffect(()=>{if(!B||ie!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=N();if(r!==`not-injected`){if(e=!0,H(r),r===`valid`){let e=V();e&&oe(re({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[B,ie]);let me=K(async()=>{if(F({isDesktopShell:y(),isDesktopLocalOriginActive:T()})){await A();return}window.location.reload()}),he=K(async()=>{if(!P){w(!1),I(!0);try{await Sn(),await kn.getState().initializeApp()}finally{I(!1)}kn.getState().isInitialized||D(e=>e+1)}}),ge=e=>{if(e.screen===`recovery`)return e.variant};if(B&&U&&U.screen!==`main`){if(U.screen===`chooser`)return(0,$.jsx)(Mo,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Aw,{mode:`first-launch`,onCliAvailable:me,onChooseRemote:()=>{}})})})});let e=ge(U),t=U.screen===`recovery`&&`url`in U?U.url:void 0;return(0,$.jsx)(Mo,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Aw,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:me})})})})}if(se)return gr(),(0,$.jsx)(Mo,{children:(0,$.jsx)(Jn,{sdk:tt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(uo,{apis:e,children:(0,$.jsx)(ei,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(Rw,{embeddedSessionChat:se,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:ce})})})})},O)});if(le)return(0,$.jsx)(Mo,{children:(0,$.jsx)(Ew,{})});if(S&&!n&&!h&&!se)return(0,$.jsx)(Mo,{children:(0,$.jsx)(Pw,{onRetry:()=>{he()},isRetrying:P})});let _e=!n&&!B;return(0,$.jsx)(Mo,{children:(0,$.jsx)(Jn,{sdk:tt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(uo,{apis:e,children:(0,$.jsx)(Xc,{ready:fe&&n&&ce,children:(0,$.jsx)(ym,{children:(0,$.jsx)(ei,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:B?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)($a,{embeddedBackgroundWorkEnabled:ce}),(0,$.jsx)(pl,{}),(0,$.jsx)(ol,{}),(0,$.jsx)(Ec,{}),(0,$.jsx)(KS,{}),B&&(0,$.jsx)(kw,{transition:j,ready:n&&r}),(0,$.jsx)(Dw,{}),(0,$.jsx)(Pa,{}),!_e&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rc,{}),(0,$.jsx)(xc,{}),(0,$.jsx)(hc,{}),(0,$.jsx)(Nw,{}),d&&(0,$.jsx)(OC,{onClose:()=>p(!1)})]})]})})})})})},O)})}function Bw(e){return e.isAboutDialogOpen}function Vw(e){return e.setAboutDialogOpen}function Hw(e){return e.currentDirectory}function Uw(e){return e.currentSessionId}function Ww(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var Gw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Nr(),y()&&tn(),Ua({runtimeKey:p(),initializeAppearance:Ne,syncSettings:Pe,applyDirectory:mo,startWatchers:()=>{to(),Va(),Fa()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var Kw=document.getElementById(`root`);if(!Kw)throw Error(`Root element not found`);(0,ku.createRoot)(Kw).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Ia,{children:(0,$.jsx)(jr,{children:(0,$.jsx)(Na,{children:(0,$.jsx)(eo,{children:(0,$.jsx)(za,{children:(0,$.jsx)(Ba,{children:(0,$.jsx)(zw,{apis:Gw})})})})})})})}));