@yuriai/web 0.3.7 → 0.3.8-beta.11

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 (216) hide show
  1. package/README.md +5 -3
  2. package/dist/assets/{AgentAvatar-4HfTeQK1.js → AgentAvatar-DUosbplP.js} +1 -1
  3. package/dist/assets/{AgentSelector-Db0C7nfY.js → AgentSelector-CATfrz9H.js} +1 -1
  4. package/dist/assets/ArchivedSessionsDialog-4LsjJMwq.js +1 -0
  5. package/dist/assets/{AssistantConversationSurface-Cg0Z0laN.js → AssistantConversationSurface-C1aqkQB8.js} +3 -3
  6. package/dist/assets/{AssistantSessionCard-CRaYbAwR.js → AssistantSessionCard-BiJz_g-2.js} +2 -2
  7. package/dist/assets/{AssistantUnreadBadge-B0XaBtKU.js → AssistantUnreadBadge-BscM_1to.js} +1 -1
  8. package/dist/assets/AssistantView-DyWyt6pE.js +1 -0
  9. package/dist/assets/{AssistantWorkingAvatar-QmEGmd3p.js → AssistantWorkingAvatar-BU52rN5b.js} +1 -1
  10. package/dist/assets/{AssistantsSettingsPage-SynpDBbu.js → AssistantsSettingsPage-q8ytJWE1.js} +1 -1
  11. package/dist/assets/{BinaryFileFallback-CLr78pii.js → BinaryFileFallback-Cyt-95DW.js} +1 -1
  12. package/dist/assets/{BtwPanel-eNUn2HxV.js → BtwPanel-ryEWiuLR.js} +2 -2
  13. package/dist/assets/{BusyDots-CGTf_jqS.js → BusyDots-UZgAtz3O.js} +2 -2
  14. package/dist/assets/ChatContainer-ByJtQVK6.js +65 -0
  15. package/dist/assets/{ChatView-DJnxvyiB.js → ChatView-DLmKqX9f.js} +3 -3
  16. package/dist/assets/{DiagramView-BQ_5mLmc.js → DiagramView-Bn8Pblt5.js} +1 -1
  17. package/dist/assets/{DiffView-KE3aMklA.js → DiffView-BBQ_CqkV.js} +2 -2
  18. package/dist/assets/{DiffViewToggle-B-fDu13M.js → DiffViewToggle-BiHt1Lnh.js} +1 -1
  19. package/dist/assets/{ErrorBoundary-BMkurwx0.js → ErrorBoundary-DMqsgJ2Z.js} +1 -1
  20. package/dist/assets/{FadeInOnReveal-BNxn8bBO.js → FadeInOnReveal-BfL8sBKI.js} +1 -1
  21. package/dist/assets/{GuiPluginMount-CcxWjZGn.js → GuiPluginMount-CcRofngt.js} +1 -1
  22. package/dist/assets/{GuiPluginPage-B6DZGRf5.js → GuiPluginPage-BlrZRGuS.js} +1 -1
  23. package/dist/assets/{GuiPluginSurface-CZ-rTgd0.js → GuiPluginSurface-DEvwkiVX.js} +1 -1
  24. package/dist/assets/{GuiPluginTitlebarItems-ByapzQyJ.js → GuiPluginTitlebarItems-DWCgE7ET.js} +1 -1
  25. package/dist/assets/{GuiPluginWindow-DtZqX_qS.js → GuiPluginWindow-Bo7XbYA1.js} +1 -1
  26. package/dist/assets/{Icon-CUOVBCQn.js → Icon-EsiJulCS.js} +1 -1
  27. package/dist/assets/{ImageLoadingPlaceholder-ON75MLXx.js → ImageLoadingPlaceholder-C3jBr-ZF.js} +1 -1
  28. package/dist/assets/{LoadingImage-CE1QZoPZ.js → LoadingImage-fEm8pr_o.js} +1 -1
  29. package/dist/assets/MarkdownRenderer-CHeSsPIE.js +2 -0
  30. package/dist/assets/{MarkdownRendererImpl-SH7kLqNr.js → MarkdownRendererImpl-Bz8KtAbA.js} +1 -1
  31. package/dist/assets/{MarkstreamRendererImpl-kWCEeJ84.js → MarkstreamRendererImpl-DjJQlxGp.js} +1 -1
  32. package/dist/assets/{MobileAssistantSettingsPage-DkSgJLH5.js → MobileAssistantSettingsPage-Cck3j35v.js} +1 -1
  33. package/dist/assets/{MobileAssistantTab-DlreBfpD.js → MobileAssistantTab-DTJNwwEb.js} +1 -1
  34. package/dist/assets/{MobileBtwPage-DUOHjbOb.js → MobileBtwPage-xeCPKgyS.js} +1 -1
  35. package/dist/assets/{MobileChangesSurface-s-IkQzDj.js → MobileChangesSurface-BSa70G-M.js} +1 -1
  36. package/dist/assets/{MobileChatScreen-RJicegCg.js → MobileChatScreen-DwiIXUTa.js} +1 -1
  37. package/dist/assets/{MobileDetailNavigation-B0Xb37E5.js → MobileDetailNavigation-B890bmvA.js} +1 -1
  38. package/dist/assets/{MobileFilesSurface-CR7C7ern.js → MobileFilesSurface-DSuHpwIN.js} +2 -2
  39. package/dist/assets/{MobileHtmlNetworkBoundary-CG4kdWvo.js → MobileHtmlNetworkBoundary-Dbmb0woF.js} +2 -2
  40. package/dist/assets/{MobileOverlayPanel-DLDL_a6S.js → MobileOverlayPanel-BSoJXidn.js} +1 -1
  41. package/dist/assets/{MobileResizableSheet-BTsMGacb.js → MobileResizableSheet-Cqp-f6Oh.js} +1 -1
  42. package/dist/assets/{MobileSettingsTab-DIqufnwp.js → MobileSettingsTab-C7Hix5yH.js} +1 -1
  43. package/dist/assets/{MobileShareBridge-BgAD2FqK.js → MobileShareBridge-CthZXZjk.js} +2 -2
  44. package/dist/assets/{MobileSurface-D_9tJDu_.js → MobileSurface-BjCCDoF_.js} +1 -1
  45. package/dist/assets/{MobileTabPageHeader-CPEY1sVL.js → MobileTabPageHeader-ClOtB91R.js} +1 -1
  46. package/dist/assets/{ModelLogo-CoEkCK6k.js → ModelLogo-CNbb6tTt.js} +1 -1
  47. package/dist/assets/{ModelSelector-CdSx-1l3.js → ModelSelector-jh1lc6Ir.js} +1 -1
  48. package/dist/assets/{MultiRunWindow-08NX-bpU.js → MultiRunWindow-CkQnlNg7.js} +1 -1
  49. package/dist/assets/{OnboardingScreen-DW4PQZ48.js → OnboardingScreen-sILjaIGV.js} +1 -1
  50. package/dist/assets/{OverlayScrollbar-D4U670-p.js → OverlayScrollbar-D7457mMt.js} +1 -1
  51. package/dist/assets/{PierreDiffViewer-CU2O_Gqy.js → PierreDiffViewer-Ccn-WFDS.js} +1 -1
  52. package/dist/assets/ProviderLogo-C_0JyXvj.js +1 -0
  53. package/dist/assets/{RemoteAssistantSessionCard-44WC5u9f.js → RemoteAssistantSessionCard-CYnS-jZj.js} +1 -1
  54. package/dist/assets/{RemoteDesktopPanel-BfdjP2Ug.js → RemoteDesktopPanel-DyBKtlM9.js} +1 -1
  55. package/dist/assets/{ScheduledTasksDialog-p2z6x4k7.js → ScheduledTasksDialog-z6Dv9y64.js} +1 -1
  56. package/dist/assets/{ScrollableOverlay-B5Mx_IrY.js → ScrollableOverlay-C2U_lDD9.js} +1 -1
  57. package/dist/assets/{SettingsGroup-Bd0hGXKp.js → SettingsGroup-Dvwqxwl4.js} +1 -1
  58. package/dist/assets/SettingsView-B9XQGrzH.js +29 -0
  59. package/dist/assets/{SettingsWindow-DO2ySMZ8.js → SettingsWindow-BvjAJLEF.js} +1 -1
  60. package/dist/assets/{SetupTourDialog-Bm0scCiD.js → SetupTourDialog-DjODwX_8.js} +1 -1
  61. package/dist/assets/{SyncActions-ktq_QbjA.js → SyncActions-DQf7zh2C.js} +1 -1
  62. package/dist/assets/{TerminalView-tXyVGRwg.js → TerminalView-gKe5t6-4.js} +2 -2
  63. package/dist/assets/{TextSelectionMenu-CCsFVQha.js → TextSelectionMenu-DxIfqr_a.js} +1 -1
  64. package/dist/assets/{ToolOutputDialog-BX3Vi-k5.js → ToolOutputDialog-CcgWwheU.js} +1 -1
  65. package/dist/assets/{YuriLogo-1yVZFnVN.js → YuriLogo-lpk1hpWI.js} +1 -1
  66. package/dist/assets/YuriWordmark-CqWOXOaU.js +1 -0
  67. package/dist/assets/{assistantMessagePreview-Bh2bPUPh.js → assistantMessagePreview-DGkM0JMu.js} +1 -1
  68. package/dist/assets/{assistantQueries-9sjQcHoO.js → assistantQueries-DqCSkgsu.js} +1 -1
  69. package/dist/assets/{auto-read-context-JBvQYPyM.js → auto-read-context-Cc4uzTzL.js} +1 -1
  70. package/dist/assets/{capgoAdapter-llXcw7v2.js → capgoAdapter-BsHuRsys.js} +1 -1
  71. package/dist/assets/{card-YOYJB2Bf.js → card-v4kRRyeV.js} +1 -1
  72. package/dist/assets/{chatUpwardIntent-Z6bMNkax.js → chatUpwardIntent-C45h0M5M.js} +1 -1
  73. package/dist/assets/{checkbox-ByuwPnuS.js → checkbox-8Dmjv-Nw.js} +1 -1
  74. package/dist/assets/client-A12QacVZ.js +7 -0
  75. package/dist/assets/{collapsible-ByaFR6Oc.js → collapsible-CIRN8x_z.js} +1 -1
  76. package/dist/assets/connection-hint-Dc3xE6Tv.js +2 -0
  77. package/dist/assets/{context-menu-DKL8DaT6.js → context-menu-DmvtUZ1N.js} +1 -1
  78. package/dist/assets/desktopRelayRestore-DtGRUKC-.js +1 -0
  79. package/dist/assets/{diagram-DkVURCJZ.js → diagram-NiXWMnMe.js} +1 -1
  80. package/dist/assets/{dialog-CQbyU8pU.js → dialog-BuB7G_sj.js} +1 -1
  81. package/dist/assets/{dropdown-menu-W3Ii298F.js → dropdown-menu-DYZL6MMz.js} +1 -1
  82. package/dist/assets/es-Dl_f-VoR.js +15 -0
  83. package/dist/assets/{fileMentionTouchSelection-CwTAmgan.js → fileMentionTouchSelection-BTE8qVPm.js} +1 -1
  84. package/dist/assets/fr-BoFSg4oh.js +13 -0
  85. package/dist/assets/{gitApi-droqYZ9A.js → gitApi-DkL1o8lv.js} +4 -4
  86. package/dist/assets/gitApiHttp-DyA_XRfG.js +3 -0
  87. package/dist/assets/{i18n-Sh2Qk9nD.js → i18n-G4mBbEvx.js} +1 -1
  88. package/dist/assets/icons-DpMi4Nu2.js +2 -0
  89. package/dist/assets/{input-DSdEvspA.js → input-BGaLdSO2.js} +1 -1
  90. package/dist/assets/{insertionBoundaries-Bf3EMWj8.js → insertionBoundaries-BWalaUBf.js} +1 -1
  91. package/dist/assets/ja-DmxgfcWg.js +15 -0
  92. package/dist/assets/{kbd-hp3-RDSe.js → kbd-CHXZIYGx.js} +1 -1
  93. package/dist/assets/ko-DH3El5QZ.js +15 -0
  94. package/dist/assets/main-C5ruSn_v.css +1 -0
  95. package/dist/assets/main-CMGZ9WKY.js +2 -0
  96. package/dist/assets/main-Ct-eT9V1.js +169 -0
  97. package/dist/assets/{markdownHeightCache-qX2f-vgi.js → markdownHeightCache-DL0I2tk1.js} +1 -1
  98. package/dist/assets/{mcpQueries-DKxn0-Iq.js → mcpQueries-DnUCiven.js} +1 -1
  99. package/dist/assets/miniChat-61JnQCjp.js +2 -0
  100. package/dist/assets/mobile-PAf_lmhs.js +2 -0
  101. package/dist/assets/{mobileBackNavigation-Ce-CFzRu.js → mobileBackNavigation-DmqlauAT.js} +1 -1
  102. package/dist/assets/{mobileConnections-BWToBinV.js → mobileConnections-DabSpi6d.js} +2 -2
  103. package/dist/assets/{multirun-ByBZh9To.js → multirun-BpIWMSVl.js} +1 -1
  104. package/dist/assets/{native-config-BDAV-Sn-.js → native-config-BU3APHGL.js} +1 -1
  105. package/dist/assets/{nativeComposerCover-DcWXqfZa.js → nativeComposerCover-B7Cbs_PM.js} +1 -1
  106. package/dist/assets/{navigation-DiqbYNCD.js → navigation-CAHzFx17.js} +1 -1
  107. package/dist/assets/{openRemoteProjectSession-DPb8H79n.js → openRemoteProjectSession-BWUT1ORe.js} +1 -1
  108. package/dist/assets/{openSessionFromDeepLink-gJWOkm8w.js → openSessionFromDeepLink-Bbkfy3UJ.js} +2 -2
  109. package/dist/assets/pl-CD38psJG.js +15 -0
  110. package/dist/assets/{pluginPresentation-C8XRIFn5.js → pluginPresentation-BNIduz5y.js} +1 -1
  111. package/dist/assets/pt-BR-DBB59YTx.js +15 -0
  112. package/dist/assets/pwa-BJKKdnmb.js +2 -0
  113. package/dist/assets/queue-abort-optimistic-J0B7Rxan.js +1 -0
  114. package/dist/assets/quota-kI30nh9N.js +1 -0
  115. package/dist/assets/{reference-history-BAPLZtrN.js → reference-history-Dq1wAOCJ.js} +1 -1
  116. package/dist/assets/remoteProjectQueries-Dq2vrCZs.js +1 -0
  117. package/dist/assets/{remoteSessionReference-B-5Nd45t.js → remoteSessionReference-CQ6-AG6n.js} +1 -1
  118. package/dist/assets/{renderElectronMiniChatApp-DudyNNIU.js → renderElectronMiniChatApp-DeaRwryA.js} +2 -2
  119. package/dist/assets/renderMobileApp-dcdcE-k9.js +17 -0
  120. package/dist/assets/{runtimeConfig-CUiokUFx.js → runtimeConfig-BltRTBn6.js} +1 -1
  121. package/dist/assets/runtimeEndpointReset-BO-UTHDI.js +4 -0
  122. package/dist/assets/{select--wmAuAOB.js → select-DmDy5Nhb.js} +1 -1
  123. package/dist/assets/{sessionLookup-on217pcK.js → sessionLookup-CfB67XO0.js} +1 -1
  124. package/dist/assets/{sessionOwnership-BoiTRI2O.js → sessionOwnership-tRpXQ2bX.js} +1 -1
  125. package/dist/assets/shortcuts-CPoJSIo2.js +1 -0
  126. package/dist/assets/{sortable-tabs-strip-DvvltU2l.js → sortable-tabs-strip-eyDVY37z.js} +1 -1
  127. package/dist/assets/{speechSettingsQueries-Cqj3BM7O.js → speechSettingsQueries-C2FXBLpd.js} +1 -1
  128. package/dist/assets/src-hWgdOgID.css +2 -0
  129. package/dist/assets/store-1zpYqZEm.js +17 -0
  130. package/dist/assets/{switch-ClpM-4qX.js → switch-jRAluPds.js} +1 -1
  131. package/dist/assets/{terminalApi-wdwb9MVG.js → terminalApi-BMwgGgnC.js} +1 -1
  132. package/dist/assets/{textarea-Cpcy0ejH.js → textarea-B2CAde2L.js} +1 -1
  133. package/dist/assets/{timeFormat-BaiPCZgf.js → timeFormat-DUXj9SWS.js} +1 -1
  134. package/dist/assets/{tooltip-B9I9lmf0.js → tooltip-C3xkMhqj.js} +1 -1
  135. package/dist/assets/{truncated-path-BPcF8ywI.js → truncated-path-BnSVKueG.js} +1 -1
  136. package/dist/assets/types-kEJAYUcf.js +2 -0
  137. package/dist/assets/ui-l6IO9PTO.js +13 -0
  138. package/dist/assets/uk-Cvg8_R2n.js +15 -0
  139. package/dist/assets/useAppFontEffects-UrrEtsUl.js +7 -0
  140. package/dist/assets/{useDesktopWindowControlsLayout-BA4DI_W1.js → useDesktopWindowControlsLayout-BXISWBu3.js} +1 -1
  141. package/dist/assets/{useDictation-83-qDgkn.js → useDictation-SKA19H8P.js} +1 -1
  142. package/dist/assets/{useEffectiveDirectory-DQMEyl5O.js → useEffectiveDirectory-oCbxzmAs.js} +1 -1
  143. package/dist/assets/{useGitStore-Dvd_1jyD.js → useGitStore-n7r0qj_Y.js} +1 -1
  144. package/dist/assets/{useInlineCommentDraftStore-DWSuMEHF.js → useInlineCommentDraftStore-CJ4SnS1O.js} +1 -1
  145. package/dist/assets/{useMcpConfigStore-7NoTGiyv.js → useMcpConfigStore-Dpy8jok0.js} +1 -1
  146. package/dist/assets/{useMobileSwipeActions-7iuGbwWj.js → useMobileSwipeActions-Bd7qL7eT.js} +1 -1
  147. package/dist/assets/useMobileTranscriptSyncHint-ziZduwzN.js +10 -0
  148. package/dist/assets/{useModelLists-C5fB7vLV.js → useModelLists-B1xrZ7Pe.js} +1 -1
  149. package/dist/assets/{useOpenCodeReadiness-B4IGjODK.js → useOpenCodeReadiness-B5xaaV1D.js} +1 -1
  150. package/dist/assets/usePluginsStore-Dff5sK3j.js +1 -0
  151. package/dist/assets/{useProjectGitActions-CiL6W09h.js → useProjectGitActions-CZd8McCZ.js} +1 -1
  152. package/dist/assets/{useProjectGitStore-Bv65Bj_P.js → useProjectGitStore-6H4jREwp.js} +1 -1
  153. package/dist/assets/{useProjectRuntimeAPIs-CYT-3dZd.js → useProjectRuntimeAPIs-B4gN7GV3.js} +1 -1
  154. package/dist/assets/useQuotaStore-QZ66qdMQ.js +1 -0
  155. package/dist/assets/{useSessionBtwStore-H4R5jYT2.js → useSessionBtwStore-rmnV1v0Y.js} +2 -2
  156. package/dist/assets/{useStreamingTextThrottle-D9STYrQw.js → useStreamingTextThrottle-h-BCiqXc.js} +1 -1
  157. package/dist/assets/{useTerminalStore-C_QzSEgP.js → useTerminalStore-ZDylJPQJ.js} +1 -1
  158. package/dist/assets/{worktreeManager-33ddwAq1.js → worktreeManager-EPxXxMzC.js} +1 -1
  159. package/dist/assets/{worktreeSourceBranchPreference-Cp5jF1M9.js → worktreeSourceBranchPreference-CYCs9_g2.js} +1 -1
  160. package/dist/assets/zh-CN-B6Gc3wZh.js +15 -0
  161. package/dist/assets/zh-TW-C2bT0lOZ.js +15 -0
  162. package/dist/index.html +12 -13
  163. package/dist/mini-chat.html +12 -13
  164. package/dist/mobile.html +2 -2
  165. package/package.json +1 -1
  166. package/server/lib/host-update/DOCUMENTATION.md +28 -16
  167. package/server/lib/host-update/cli-worker.js +71 -24
  168. package/server/lib/host-update/cli.js +9 -6
  169. package/server/lib/host-update/cli.test.js +28 -5
  170. package/server/lib/host-update/releases.js +33 -2
  171. package/server/lib/host-update/runtime.test.js +16 -1
  172. package/server/lib/opencode/settings-helpers.js +3 -0
  173. package/server/lib/quota/magpie.js +6 -2
  174. package/server/lib/quota/magpie.test.js +14 -0
  175. package/dist/assets/ArchivedSessionsDialog-Cja7TIg6.js +0 -1
  176. package/dist/assets/AssistantView-D7Ec_wbs.js +0 -1
  177. package/dist/assets/ChatContainer-DUJRc6kx.js +0 -65
  178. package/dist/assets/MarkdownRenderer-DL1l4dgn.js +0 -2
  179. package/dist/assets/ProviderLogo-C9ON1xS-.js +0 -1
  180. package/dist/assets/SettingsView-BbEPSEy3.js +0 -29
  181. package/dist/assets/YuriWordmark-CqkcfAJl.js +0 -1
  182. package/dist/assets/client-CmtAKi5B.js +0 -7
  183. package/dist/assets/connection-hint-DugoAaao.js +0 -2
  184. package/dist/assets/desktopHosts-COI-czjF.js +0 -1
  185. package/dist/assets/desktopRelayRestore-BEPNc7qb.js +0 -1
  186. package/dist/assets/es-C1spVk4O.js +0 -15
  187. package/dist/assets/fr-yyP7Hlty.js +0 -13
  188. package/dist/assets/gitApiHttp-ZjM4HkSo.js +0 -3
  189. package/dist/assets/icons-CLvvQeAy.js +0 -1
  190. package/dist/assets/ja-ChftrfCh.js +0 -15
  191. package/dist/assets/ko-BrLgX_6B.js +0 -15
  192. package/dist/assets/main-ClNDsxXD.js +0 -2
  193. package/dist/assets/main-D71N_bhn.js +0 -169
  194. package/dist/assets/main-qSeeJRW1.css +0 -1
  195. package/dist/assets/miniChat-DuWGMHPI.js +0 -2
  196. package/dist/assets/mobile-CjbFG_ps.js +0 -2
  197. package/dist/assets/pl-DlKDQDhl.js +0 -15
  198. package/dist/assets/pt-BR-BldJPFQ5.js +0 -15
  199. package/dist/assets/pwa-CLwERclR.js +0 -2
  200. package/dist/assets/queue-abort-optimistic-BET9wo1a.js +0 -1
  201. package/dist/assets/quota-jMPnmJTS.js +0 -1
  202. package/dist/assets/remoteProjectQueries-BQzoY_Y9.js +0 -1
  203. package/dist/assets/renderMobileApp-GIRJpszx.js +0 -17
  204. package/dist/assets/runtimeEndpointReset-DXfdUC1r.js +0 -4
  205. package/dist/assets/shortcuts-D3O9f1E5.js +0 -1
  206. package/dist/assets/src-B7qham90.css +0 -2
  207. package/dist/assets/store-BGuutgkJ.js +0 -17
  208. package/dist/assets/types-DjBXLnbS.js +0 -2
  209. package/dist/assets/ui-BqoDhEiW.js +0 -13
  210. package/dist/assets/uk-Cw2L_unr.js +0 -15
  211. package/dist/assets/useAppFontEffects-CaZbgo4R.js +0 -7
  212. package/dist/assets/useMobileTranscriptSyncHint-B3NigAUx.js +0 -10
  213. package/dist/assets/usePluginsStore-D2P-bQeH.js +0 -1
  214. package/dist/assets/useQuotaStore-CHxR2ZkD.js +0 -1
  215. package/dist/assets/zh-CN-BQXjCmNe.js +0 -15
  216. package/dist/assets/zh-TW-Y0lErpEY.js +0 -15
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,S as n,c as r,l as i,s as a,x as o,y as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,l as d,n as f,o as p,r as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{B as _,F as v,I as y,L as b,d as x,f as S,j as C,n as w,s as T,t as E,ut as D,w as ee,z as te}from"./platform-B2ylz14u.js";import{t as O}from"./runtimeAPIRegistry-C2VogTny.js";import{Ar as k,Br as ne,Dr as A,Er as j,Fr as M,Lr as re,Mr as ie,Pr as N,Rr as P,Tr as ae,Ur as oe,Vr as F,gt as I,ht as L,jr as se,kr as ce,mt as le,n as ue,o as R,ut as de,xr as fe,zr as z}from"./client-A12QacVZ.js";import{r as B}from"./desktopRelayRestore-DtGRUKC-.js";import{a as V}from"./vendor-zustand-CTekDqaS.js";import{it as pe,ot as H,st as me}from"./vendor-base-ui-wXsskyKm.js";import{Dt as he,Ft as ge,Jt as _e,Kt as ve,Mt as ye,Pt as be,St as xe,Wt as Se}from"./gitApiHttp-DyA_XRfG.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Ce}from"./vendor-react-BkccXcWz.js";import{a as we}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{l as Te,o as Ee,s as De}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{P as Oe,V as ke,W as Ae,z as je}from"./runtime-file-resource-BGZ4tGr5.js";import{i as Me,o as Ne,r as U}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as Pe}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{C as Fe,b as Ie,f as Le,g as Re,r as W,y as ze}from"./useUIStore-68ZPpgYA.js";import{t as Be}from"./vendor-sonner-DX3nfJx4.js";import{Fi as Ve,Fn as He,Ga as Ue,Ha as We,I as Ge,Ii as Ke,Jr as qe,Kt as Je,Qa as Ye,Ur as Xe,Xn as Ze,Yr as Qe,Zi as G,f as K,io as $e,oa as et,pn as tt,ra as nt,ro as rt,t as q,un as it,xt as at}from"./ui-l6IO9PTO.js";import{n as J}from"./Icon-EsiJulCS.js";import{o as ot,s as st,t as ct}from"./i18n-G4mBbEvx.js";import{a as lt,n as ut,o as dt,r as ft,t as pt}from"./dialog-BuB7G_sj.js";import{i as mt,n as ht,t as gt}from"./tooltip-C3xkMhqj.js";import{n as _t,r as vt}from"./useThemeSystem-BIXghnHj.js";import{n as yt}from"./react-CPBNl-S9.js";import{r as bt}from"./device-TCHW5U2y.js";import{a as xt,i as St,n as Ct,r as wt,t as Tt}from"./themes-BgDJcxRc.js";import{t as Et}from"./useEffectiveDirectory-oCbxzmAs.js";import{m as Dt,t as Ot}from"./gitApi-DkL1o8lv.js";import{t as kt}from"./input-BGaLdSO2.js";import{_ as At,c as jt,f as Mt,n as Y,r as Nt,s as Pt}from"./shortcuts-CPoJSIo2.js";import{a as Ft}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{t as It}from"./checkbox-8Dmjv-Nw.js";import{$ as Lt,A as Rt,B as zt,F as Bt,H as Vt,I as Ht,K as Ut,M as Wt,U as Gt,V as Kt,Y as qt,a as Jt,at as Yt,c as Xt,it as Zt,j as Qt,k as $t,ot as en,p as tn,q as nn,r as rn,rt as an,s as on,t as sn,z as cn}from"./pwa-BJKKdnmb.js";import{t as ln}from"./YuriLogo-lpk1hpWI.js";import{t as un}from"./ErrorBoundary-DMqsgJ2Z.js";import{o as dn,s as fn,t as pn}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{t as mn}from"./theme-validation-BGYdrOu7.js";import{C as hn,P as gn,Q as _n,S as vn,X as yn,Z as bn,c as xn,y as Sn}from"./BusyDots-UZgAtz3O.js";import{F as Cn,I as wn,L as Tn,M as En,N as Dn,O as On,f as kn,j as An,k as jn,l as Mn,o as Nn,r as Pn,s as Fn,u as In}from"./queue-abort-optimistic-J0B7Rxan.js";import{n as Ln}from"./worktreeManager-EPxXxMzC.js";import{t as Rn}from"./useTerminalStore-ZDylJPQJ.js";import{n as zn}from"./speechSettingsQueries-C2FXBLpd.js";import{t as Bn}from"./useFontPreferences-C4dQT72k.js";var Vn=e=>{if(typeof e!=`string`)return;let t=e.trim();if(t)return{location:{directory:t}}};typeof window<`u`&&(window.__opencodeDebug={getLastAssistantMessage(){let e=K.getState().currentSessionId;if(!e)return null;let t=le(e);if(!t||t.length===0)return null;for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.role===`assistant`){let e=(L(n.id)||[]).map(e=>{let t={id:e.id,type:e.type};return e.type===`text`?(t.text=e.text,t.textLength=e.text?.length||0):e.type===`tool`?(t.tool=e.tool,t.state=e.state?.status):(e.type===`step-start`||e.type===`step-finish`)&&(t.isStepMarker=!0),t}),t=e.some(e=>e.type===`text`&&e.text&&e.text.trim().length>0),r=e.some(e=>e.type===`tool`),i=e.some(e=>e.type===`step-start`||e.type===`step-finish`),a=e.length===0,o=!t&&!r&&(!a||i),s={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:e.length,parts:e,isEmpty:a,isEmptyResponse:o,raw:n};return s.messageId,s.partsCount,s.isEmpty,s.isEmptyResponse,s.isEmpty&&console.warn(`[WARNING] Message has NO parts!`),s.isEmptyResponse&&(console.warn(`[WARNING] Message has parts but NO meaningful content (empty text, no tools)!`),i&&!t&&!r&&console.warn(`[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!`)),s}}return null},truncateString(e,t=80){return!e||typeof e!=`string`||e.length<=t?e:e.substring(0,t)+`…`},truncateMessages(e){return e.map(e=>({...e,parts:(L(e.id)||[]).map(e=>{let t={...e};return`text`in e&&(t.text=this.truncateString(e.text)),`textPreview`in e&&(t.textPreview=this.truncateString(e.textPreview)),e.state&&(t.state={...e.state},`output`in e.state&&(t.state.output=this.truncateString(e.state.output)),`error`in e.state&&(t.state.error=this.truncateString(e.state.error)),e.state.metadata&&`preview`in e.state.metadata&&(t.state.metadata={...e.state.metadata,preview:this.truncateString(e.state.metadata.preview)})),t})}))},getAllMessages(e=!1){let t=K.getState().currentSessionId;if(!t)return[];let n=le(t);return`${n.length}`,n.forEach((e,t)=>{let n=L(e.id)||[];`${t}${e.role}${e.id}${n.length}`}),e?this.truncateMessages(n):n},async getAppStatus(){let e=xe.getState(),t=K.getState(),n=We.getState(),r=e.currentDirectory||null,i=ue.getDirectory()??null,a=I(),o=new Set,s={};a.forEach(e=>{let t=e.directory;typeof t==`string`&&t.trim().length>0?(o.add(t),s[t]=(s[t]??0)+1):s[`(none)`]=(s[`(none)`]??0)+1});let c=(()=>{if(typeof window>`u`)return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem(`lastDirectory`),homeDirectory:window.localStorage.getItem(`homeDirectory`)}}catch(e){return{available:!1,error:e instanceof Error?e.message:String(e)}}})(),l=O(),u=typeof window<`u`&&!!window.__YURI_ELECTRON__,d=async e=>{try{return await e.json()}catch{return null}},f=async e=>{try{return await e.text()}catch{return null}},p=async e=>{try{let t=await g(e);return t.ok?await d(t):{status:t.status}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},m=null,h=null,_=null,v=null;try{let e=await ue.getSdkClient().location.get(Vn(r));m=R(e)}catch(e){m={error:e instanceof Error?e.message:String(e)}}try{h=(await ue.getSdkClient().location.get(Vn(r)))?.project??null}catch(e){h={error:e instanceof Error?e.message:String(e)}}_=await p(`/api/config/settings`);try{let e=await g(`/api/health`),t=e.headers.get(`content-type`)||``,n=await f(e),r=t.toLowerCase().includes(`application/json`),i=null;if(r&&n)try{let e=JSON.parse(n);e&&typeof e==`object`&&!Array.isArray(e)&&(i=e)}catch{i=null}v={status:e.status,ok:e.ok,contentType:t,type:r?`json`:`html`,openCodePort:i?.openCodePort??null,openCodeRunning:i?.openCodeRunning??null,openCodeSecureConnection:i?.openCodeSecureConnection??null,openCodeAuthSource:i?.openCodeAuthSource??null,isOpenCodeReady:i?.isOpenCodeReady??null,lastOpenCodeError:i?.lastOpenCodeError??null,preview:n?n.slice(0,120):null}}catch(e){v={error:e instanceof Error?e.message:String(e)}}let y={isGitRepo:null};if(r)try{y.isGitRepo=await Ot(r)}catch(e){y={isGitRepo:null,error:e instanceof Error?e.message:String(e)}}let b=n.projects.map(e=>({id:e.id,path:e.path,label:e.label}));return{runtime:{platform:l?.runtime?.platform??null,isDesktop:u,isVSCode:!!l?.runtime?.isVSCode,hasRuntimeApis:!!l,desktopServerOrigin:null},location:typeof window<`u`?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:r,opencodeDirectory:m?.directory||m?.worktree||i,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:n.projects.length,activeProjectId:n.activeProjectId,samples:b},sessions:{total:a.length,currentSessionId:t.currentSessionId,lastLoadedDirectory:t.lastLoadedDirectory,uniqueDirectories:o.size,directorySamples:Array.from(o).slice(0,5),directoryCounts:s},worktrees:{available:t.availableWorktrees.length,metadataEntries:t.worktreeMetadata.size},git:y,localStorage:c,opencode:{pathInfo:m,projectInfo:h,health:v},yuri:{settingsInfo:_}}},async buildDiagnosticsReport(){let e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return rt(e)},async copyDiagnosticsReport(){let e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){let e=this.getLastAssistantMessage();if(!e)return!1;let t=e.isEmpty||e.isEmptyResponse;return t&&(console.error(`[ALERT] PROBLEMATIC MESSAGE DETECTED!`),e.messageId,e.isEmpty,e.isEmptyResponse,e.partsCount,e.parts.length>0&&e.parts),t},getStreamingState(){let e=K.getState(),t=He.getState(),n=e.currentSessionId?t.streamingMessageIds.get(e.currentSessionId)??null:null;return Array.from(t.streamingMessageIds.entries()),Array.from(t.messageStreamStates.entries()),{streamingMessageId:n,streamingMessageIds:t.streamingMessageIds,streamStates:t.messageStreamStates}},findEmptyMessages(){let e=K.getState().currentSessionId;if(!e)return[];let t=le(e).filter(e=>e.role===`assistant`).filter(e=>{let t=L(e.id)||[],n=t.some(e=>e.type===`text`&&e.text&&e.text.trim().length>0),r=t.some(e=>e.type===`tool`);return t.length===0||!n&&!r});return`${t.length}`,t.forEach((e,t)=>{let n=L(e.id)||[];`${t}`,e.id,n.length,e.providerID,e.modelID,e.time?.created}),t},showRetryHelp(){},analyzeMessageCompletionConsistency(e={}){let{includeNonAssistant:t=!1,verbose:n=!0,maxTableRows:r=25}=e,i=K.getState().currentSessionId;if(!i)return{summary:null,rows:[]};let a=le(i),o=t?a:a.filter(e=>e.role===`assistant`),s={totalMessages:a.length,analyzedMessages:o.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},c=e=>typeof e==`number`&&Number.isFinite(e)?e:null,l=e=>{let t=e.filter(e=>typeof e==`number`);return t.length>0?Math.max(...t):null},u=o.map((e,t)=>{let n=e,r=L(e.id)||[],i=n.time??{},a=c(i.completed),o=a!==null,u=r.filter(e=>e.type===`tool`),d=r.filter(e=>e.type===`reasoning`),f=l(u.map(e=>c(e.state?.time?.end??e.state?.time?.start))),p=l(d.map(e=>c(e.time?.end??e.time?.start))),m=l([f,p].filter(e=>e!==null)),h=u.some(e=>[`pending`,`running`,`started`].includes(e.state?.status)),g=d.some(e=>typeof e.time?.end!=`number`);u.length>0&&(s.withTools+=1),d.length>0&&(s.withReasoning+=1),o||(s.completedMissing+=1);let _=!!(o&&typeof f==`number`&&a<f);_&&(s.completedBeforeTool+=1);let v=!!(o&&typeof p==`number`&&a<p);return v&&(s.completedBeforeReasoning+=1),o&&h&&(s.runningToolsWhenCompleted+=1),o&&g&&(s.reasoningOpenWhenCompleted+=1),{index:t,messageId:n.id,role:n.role,completedAt:a,latestToolTimestamp:f,latestReasoningTimestamp:p,latestPartTimestamp:m,completed_missing:!o,completed_before_tool:_,completed_before_reasoning:v,running_tools_when_completed:!!(o&&h),reasoning_open_when_completed:!!(o&&g),has_tools:u.length>0,has_reasoning:d.length>0}});return n&&(console.table(u.slice(0,r)),u.length>r&&`${r}${u.length}`),{summary:s,rows:u}},checkCompletionStatus(){let e=K.getState().currentSessionId;if(!e)return null;let t=le(e).filter(e=>e.role===`assistant`);if(t.length===0)return null;let n=t[t.length-1],r=(L(n.id)||[]).filter(e=>e.type===`step-finish`),i=n.finish===`stop`,a=n.time?.completed,o=n.status,s=typeof a==`number`&&a>0||o===`completed`,c=!!(s&&i),l=He.getState();n.sessionID&&l.streamingMessageIds.get(n.sessionID);let u=l.messageStreamStates.get(n.id);return n.id,n.id,u?.phase,{messageId:n.id,completed:a,status:o,hasCompletedFlag:s,hasStopReason:i,messageIsComplete:c,stepFinishParts:r,raw:n}}},he(),window.addEventListener(`error`,e=>{try{let t=e.message||``,n=e.filename||``;typeof t==`string`&&t.includes(`this._renderer.value.dimensions`)&&/xterm/i.test(String(n))&&e.preventDefault()}catch{}}));var X=e(me(),1),Z=Ce(),Hn=async()=>{if(typeof window>`u`)return;let e=null;try{e=fe(`lastDirectory`)}catch(e){console.warn(`Failed to read saved directory preferences:`,e)}e&&!te()&&xe.getState().setDirectory(e,{showOverlay:!1})},Un=new Map,Wn=e=>Un.get(e)??null,Gn=({runtimeKey:e,initializeAppearance:t,syncSettings:n,applyDirectory:r,onError:i},a={})=>{let o=Un.get(e);if(o&&!a.force)return o;let s=(async()=>{o&&await o;try{await t()}catch(e){return i(`appearance`,e),!1}try{await Promise.all([n(),r()])}catch(e){i(`secondary`,e)}return!0})();return Un.set(e,s),s},Kn=async({runtimeKey:e,initializeAppearance:t,syncSettings:n,applyDirectory:r,startWatchers:i,onError:a})=>{await Gn({runtimeKey:e,initializeAppearance:t,syncSettings:n,applyDirectory:r,onError:a})&&i()},qn=(e,t=50)=>{let n=null,r;return{schedule:i=>{r=i,n&&clearTimeout(n),n=setTimeout(()=>{n=null;let t=r;r=void 0,t!==void 0&&e(t)},t)},cancel:()=>{n&&clearTimeout(n),n=null,r=void 0}}};function Jn(e){return!e||e===`idle`?null:e===`ready`?`ok`:e===`error`?`unreachable`:`auth`}function Yn(e,t){let n=e.via===`relay`;return t?n:!n}function Xn(e){let{isActive:t,isSsh:n,runtimeIsConnected:r,runtimeConnectionPhase:i,currentTransportIsRelay:a,probe:o,sshPhase:s}=e,c;c=t?r&&i===`connected`?`ok`:`checking`:n?Jn(s):o?.status??`checking`;let l=t?a:o?.via===`relay`,u=null;return!n&&c===`ok`&&o?.status===`ok`&&typeof o.latencyMs==`number`&&(!t||Yn(o,a))&&(u=Math.max(0,Math.round(o.latencyMs))),{statusKind:c,showViaRelay:l,latencyMs:u}}function Zn({isLocal:e,isSsh:t,isRelay:n}){return e?`connection-local`:n?`connection-relay`:t?`connection-ssh`:`connection-lan`}var Q=H(),$=`local`,Qn=9e4,$n=`SSH connection cancelled`,er=e=>B(e),tr={},nr=e=>{let t=z(e);if(!t)return e.trim();try{let e=new URL(t);return e.pathname.endsWith(`/`)||(e.pathname=`${e.pathname}/`),e.toString()}catch{return t}},rr=()=>typeof window>`u`?``:window.__YURI_LOCAL_ORIGIN__||window.location.origin,ir=async()=>!b()||!x()?``:ce().catch(()=>``),ar=e=>e===`ok`?`bg-status-success`:e===`auth`||e===`update-recommended`?`bg-status-warning`:e===`incompatible`||e===`wrong-service`||e===`unreachable`?`bg-status-error`:e===`checking`?`bg-status-info`:`bg-muted-foreground/40`,or=e=>e===`ok`?`text-[var(--status-success)]`:e===`auth`||e===`update-recommended`?`text-[var(--status-warning)]`:e===`incompatible`||e===`wrong-service`||e===`unreachable`?`text-[var(--status-error)]`:`text-muted-foreground`,sr=e=>e===`unreachable`||e===`wrong-service`||e===`incompatible`,cr=e=>e===`unreachable`||e===`wrong-service`||e===`incompatible`,lr=e=>e===`ok`?`desktopHostSwitcher.status.connected`:e===`auth`?`desktopHostSwitcher.status.authRequired`:e===`checking`?`desktopHostSwitcher.status.checking`:e===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:e===`incompatible`?`desktopHostSwitcher.status.incompatible`:e===`wrong-service`?`desktopHostSwitcher.status.wrongService`:e===`unreachable`?`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.unknown`,ur=e=>new Promise(t=>window.setTimeout(t,e)),dr=e=>{switch(e){case`ready`:return`desktopHostSwitcher.sshPhase.ready`;case`error`:return`desktopHostSwitcher.sshPhase.error`;case`degraded`:return`desktopHostSwitcher.sshPhase.reconnecting`;case`config_resolved`:return`desktopHostSwitcher.sshPhase.resolvingConfig`;case`auth_check`:return`desktopHostSwitcher.sshPhase.checkingAuth`;case`master_connecting`:return`desktopHostSwitcher.sshPhase.connectingSsh`;case`remote_probe`:return`desktopHostSwitcher.sshPhase.probingRemote`;case`installing`:return`desktopHostSwitcher.sshPhase.installing`;case`updating`:return`desktopHostSwitcher.sshPhase.updating`;case`server_detecting`:return`desktopHostSwitcher.sshPhase.detectingServer`;case`server_starting`:return`desktopHostSwitcher.sshPhase.startingServer`;case`forwarding`:return`desktopHostSwitcher.sshPhase.forwardingPorts`;default:return`desktopHostSwitcher.sshPhase.idle`}},fr=async()=>{let e=await Lt().catch(()=>[]),t={};for(let n of e)t[n.id]=n;return t},pr=async(e,t,n,r)=>{let i=Date.now()+t;for(;Date.now()<i;){if(r?.())throw Error($n);let t=(await Lt(e).catch(()=>[])).find(t=>t.id===e);if(t){if(n(t),t.phase===`ready`)return t;if(t.phase===`error`)throw Error(t.detail||`SSH connection failed`)}await ur(700)}throw r?.()?Error($n):Error(`Timed out waiting for SSH connection`)},mr=e=>({id:$,label:`Local`,url:e||rr()}),hr=e=>{let t=typeof window>`u`?``:window.location.href,n=e.find(e=>e.id===$)?.url||rr(),r=h(),i=z(n)||n,a=z(t)||t,o=m(),s=e.find(e=>er(e)===o);if(s)return{id:s.id,label:s.label,url:s.url};if(r&&P(r,n))return{id:$,label:`Local`,url:i};let c=e.find(e=>r?P(r,N(e)):!1);if(c)return{id:c.id,label:c.label,url:z(N(c))||N(c)};if(t&&P(t,n))return{id:$,label:`Local`,url:i};let l=e.find(e=>t?P(t,e.url):!1);return l?{id:l.id,label:l.label,url:z(l.url)||l.url}:t.startsWith(`yuri-ui://`)?{id:$,label:`Local`,url:i}:{id:`custom`,label:F(a||`Instance`),url:a}};function gr({open:e,onOpenChange:t,embedded:n=!1,onHostSwitched:r,onBusyChange:i}){let{t:a}=ct(),o=W(e=>e.setSettingsDialogOpen),s=W(e=>e.setSettingsPage),l=G(e=>e.isConnected),d=G(e=>e.connectionPhase),[f,p]=X.useState([]),[m,h]=X.useState(null),[g,_]=X.useState(()=>({...tr}));X.useEffect(()=>{Object.assign(tr,g)},[g]);let[v,S]=X.useState(!1),[C,w]=X.useState(!1),[T,E]=X.useState(!1),D=Yt(),ee=en(),[te,O]=X.useState(null),M=te||ee,P=X.useRef(!1),I=U(e=>{P.current=e!==null,O(e),i?.(e!==null)}),[L,ce]=X.useState({}),[le,ue]=X.useState({}),[R,de]=X.useState({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),[fe,B]=X.useState(``),[V,pe]=X.useState(()=>rr()),[H,me]=X.useState(null),[he,ge]=X.useState(``),[_e,ve]=X.useState(``),[ye,be]=X.useState(0),xe=X.useRef(0),Se=X.useMemo(()=>[mr(V),...f.map(e=>({...e,url:z(e.url)||e.url}))],[f,V]),Ce=X.useMemo(()=>new Set(Object.keys(L)),[L]),we=X.useMemo(()=>{let e=hr(Se).id;return Se.filter(t=>t.id===$||re(t,Ce)||t.id===e)},[Se,Ce,ye]);X.useEffect(()=>c(()=>be(e=>e+1)),[]);let Te=X.useMemo(()=>hr(Se),[Se,ye]),Ee=X.useMemo(()=>u().startsWith(`relay:`),[ye]),De=X.useMemo(()=>{let e=m||$;return Se.find(t=>t.id===e)?.label||a(`desktopHostSwitcher.instance.local`)},[Se,m,a]),Oe=U(async(e,t)=>{if(y()){E(!0),B(``);try{if(b()&&!x()){await k();return}let n=e.filter(e=>e.id!==$);await A({hosts:n,defaultHostId:t}),p(n),h(t)}catch(e){B(e instanceof Error?e.message:a(`desktopHostSwitcher.error.failedToSave`))}finally{E(!1)}}}),ke=U(()=>{if(b()&&!x()){k().catch(e=>q.error(String(e))),t(!1);return}s(`remote-instances`),o(!0),t(!1)}),Ae=X.useCallback(async()=>{if(y()){S(!0),B(``);try{let[e,t,n]=await Promise.all([j(),x()?qt().catch(()=>({instances:[]})):Promise.resolve({instances:[]}),x()?fr():Promise.resolve({})]);e.localOrigin&&pe(e.localOrigin);let r={};for(let t of e.sshHostIds??[])r[t]=!0;for(let e of t.instances)r[e.id]=!0;p(e.hosts||[]),h(e.defaultHostId??null),ce(r),ue(n)}catch(e){B(e instanceof Error?e.message:a(`desktopHostSwitcher.error.failedToLoad`)),p([]),h(null),ce({}),ue({})}finally{S(!1)}}},[a]),je=X.useCallback(async e=>{if(y()){w(!0);try{let t=await ir(),n=await Promise.all(e.map(async e=>{let n=async()=>{let t=await ne(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return{status:t.status,latencyMs:t.latencyMs,...t.status===`ok`?{via:`relay`}:{}}};if(e.relay&&!e.apiUrl)return[e.id,await n()];let r=z(b()?N(e):e.url);if(!r)return[e.id,{status:`unreachable`,latencyMs:0}];let i=e.id===$?t:e.clientToken||``,a=await ae(r,{clientToken:i||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(sr(a.status)&&e.relay){let t=await n();if(t.status===`ok`)return[e.id,t]}return[e.id,{status:a.status,latencyMs:a.latencyMs}]})),r={};for(let[e,t]of n)r[e]=t;_(r)}finally{w(!1)}}},[]);X.useEffect(()=>{if(!e){me(null),ge(``),ve(``),O(null),de({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),B(``);return}Ae()},[e,Ae]),X.useEffect(()=>{e&&je(we)},[e,we,je]),X.useEffect(()=>{if(!e||!y()||!x())return;let t=!1,n=async()=>{let e=await fr();t||ue(e)};n();let r=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||n()},1500);return()=>{t=!0,window.clearInterval(r)}},[e]);let Me=U(async e=>{if(P.current||D)return;let t=e.id===$?V:z(e.url)||``,n=e.id===$?V:z(N(e))||``,i=!!e.relay&&!e.apiUrl&&e.id!==$;if(!t&&!i)return;if(b()){if(!n&&!e.relay||D)return;I(e.id);try{let t=e.id===$?await ir():null,i=await Zt({host:e,inlineProgress:!0,cachedProbe:g[e.id]||null,...e.id===$?{localApiOrigin:n,localClientToken:t}:{}});_(t=>({...t,[e.id]:i.status})),i.ok&&r?.()}finally{I(null)}return}let o=!!L[e.id];if(e.id!==$&&o&&y()){let n=le[e.id],i=await Lt(e.id).then(t=>t.find(t=>t.id===e.id)||null).catch(()=>null);i&&(n=i,ue(t=>({...t,[e.id]:i})));let o=z(n?.localUrl||e.url||``);if(n?.phase===`ready`&&o){let e=nr(o);r?.(),window.location.assign(e);return}O(e.id);let s=xe.current+1;xe.current=s,de({open:!0,hostId:e.id,hostLabel:F(e.label),phase:`master_connecting`,detail:null,error:null,errorCode:null});try{if(await Ut(e.id),s!==xe.current)return;let n=await pr(e.id,Qn,e=>{ue(t=>({...t,[e.id]:e})),de(t=>({...t,phase:e.phase,detail:e.detail||null,errorCode:e.errorCode||null}))},()=>s!==xe.current);if(s!==xe.current)return;let i=nr(z(n.localUrl||``)||t);r?.(),window.location.assign(i);return}catch(t){if(s!==xe.current)return;let n=t instanceof Error?t.message:String(t);if(n===$n)return;let r=Kt(R.errorCode,n);de(e=>({...e,error:n,errorCode:r})),q.error(a(`desktopHostSwitcher.toast.sshFailedToConnect`,{host:F(e.label)}),{description:zt(a(Vt(r)),r,n)});return}finally{s===xe.current&&O(null)}}if(e.id!==$&&y()){O(e.id);let n=await ae(t,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(_(t=>({...t,[e.id]:{status:n.status,latencyMs:n.latencyMs}})),sr(n.status)){q.error(a(`desktopHostSwitcher.toast.instanceUnreachable`,{host:F(e.label)})),O(null);return}}let s=nr(t);r?.();try{window.location.assign(s)}catch{window.location.href=s}}),Ne=X.useCallback(()=>{me(null),ge(``),ve(``)},[]),Pe=X.useCallback(e=>{e.stopPropagation()},[]),Fe=X.useCallback(async()=>{if(!H)return;if(H===$){Ne();return}let e=oe(_e);if(!e){B(a(`desktopHostSwitcher.error.invalidUrl`));return}let t=e.persistedUrl,n=(he||F(t)).trim(),r=f.map(e=>e.id===H?{...e,label:n,url:t,apiUrl:t}:e);await Oe(r,m),Ne(),e.redeemUrl&&window.location.assign(e.redeemUrl)},[Ne,f,m,he,_e,H,Oe,a]),Ie=X.useCallback(async e=>{await Oe(f,e===$?$:e)},[f,Oe]),Le=U(async e=>{if(P.current||D)return;I(e.id);let t=e=>{q.error(a(`desktopHostSwitcher.error.failedToOpenNewWindow`),{description:e instanceof Error?e.message:String(e)})};try{if(e.relay&&e.id!==$)await ie(e.id);else{let t=e.id===$?V:N(e);if(!t)return;let n=nr(t);await se(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null})}r?.()}catch(e){t(e)}finally{I(null)}}),Re=U(async()=>{xe.current+=1,O(null),de(e=>({...e,open:!1,hostId:null,error:null,errorCode:null,detail:null,phase:`idle`}));let e=nr(V);if(b()){if(D)return;let e=await ir();(await Zt({host:mr(V),localApiOrigin:V,localClientToken:e})).ok&&r?.();return}r?.(),window.location.assign(e)}),ze=X.useCallback(async()=>{let e=R.hostId||M;xe.current+=1,O(null),de({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),!(!e||e===$||!y())&&await nn(e).catch(()=>{})},[R.hostId,M]),Be=X.useCallback(()=>{let e=R.hostId;if(!e)return;let t=Se.find(t=>t.id===e);t&&Me(t)},[Se,Me,R.hostId]),Ve=U(async e=>{if(!(!y()||P.current||D)){I(e.id);try{await Ut(e.id),(await pr(e.id,Qn,e=>{ue(t=>({...t,[e.id]:e}))})).phase===`ready`&&q.success(a(`desktopHostSwitcher.toast.sshConnected`,{host:F(e.label)}))}catch(t){let n=t instanceof Error?t.message:String(t);if(n!==$n){let t=Kt(null,n);q.error(a(`desktopHostSwitcher.toast.sshFailedToConnect`,{host:F(e.label)}),{description:zt(a(Vt(t)),t,n)})}}finally{I(null)}}});if(!y())return null;let He=y(),Ue=(0,Q.jsxs)(Q.Fragment,{children:[!n&&(0,Q.jsxs)(lt,{className:`flex-shrink-0`,children:[(0,Q.jsxs)(dt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{name:`connection-local`,className:`h-5 w-5`}),a(`desktopHostSwitcher.title`)]}),(0,Q.jsx)(ft,{children:a(`desktopHostSwitcher.description`)})]}),!n&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`desktopHostSwitcher.header.currentColon`)}),(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:F(Te.label)}),(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`desktopHostSwitcher.header.currentDefaultColon`)}),(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:F(De)})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,Q.jsxs)(Ze,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void je(we),disabled:!He||v||C,children:[(0,Q.jsx)(J,{name:`refresh`,className:$e(`h-4 w-4`,C&&`animate-spin`)}),a(`desktopHostSwitcher.actions.refresh`)]})})]}),!He&&(0,Q.jsx)(`div`,{className:`flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3`,children:(0,Q.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`desktopHostSwitcher.state.limitedOnPage`)})}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,Q.jsx)(`div`,{className:$e(`space-y-1`,n&&`space-y-1.5 px-3 py-1`),children:v?(0,Q.jsx)(`div`,{className:`px-2 py-2 text-muted-foreground text-sm`,children:a(`desktopHostSwitcher.state.loading`)}):we.map(e=>{let t=e.id===$,r=!!L[e.id],i=r&&x(),o=e.id===Te.id,s=(m||$)===e.id,c=g[e.id]||null,u=le[e.id]||null,f=Xn({isActive:o,isSsh:i,runtimeIsConnected:l,runtimeConnectionPhase:d,currentTransportIsRelay:Ee,probe:c,sshPhase:u?.phase}),p=f.statusKind,h=f.showViaRelay,_=Zn({isLocal:t,isSsh:r,isRelay:o?Ee:h||!!(e.relay&&!e.apiUrl)}),v=_===`connection-local`?a(`desktopHostSwitcher.instance.local`):_===`connection-relay`?`Relay`:_===`connection-ssh`?`SSH`:`LAN`,y=H===e.id,b=t?V:z(e.url)||e.url,S=e.id===$?a(`desktopHostSwitcher.instance.local`):F(e.label),C=e.relay&&!e.apiUrl?a(`mobile.connect.relay.badge`):F(b);return(0,Q.jsxs)(`div`,{className:$e(`app-region-no-drag group flex items-center gap-2 px-2.5 py-2 rounded-md overflow-hidden`,n&&`rounded-xl px-3 py-3`,n&&o&&`bg-[var(--interactive-selection)]/25`,y?`bg-interactive-hover/20`:`hover:bg-interactive-hover/30`),children:[(0,Q.jsxs)(`button`,{type:`button`,className:$e(`flex items-center gap-2 flex-1 min-w-0 text-left`,y&&`pointer-events-none opacity-70`),onClick:()=>void Me(e),disabled:M===e.id,"aria-busy":M===e.id,"aria-current":o?`true`:void 0,"aria-label":a(`desktopHostSwitcher.actions.switchToAria`,{instance:S}),children:[(0,Q.jsx)(J,{name:M===e.id?`loader-4`:_,className:$e(`size-8 shrink-0 text-muted-foreground`,M===e.id&&`animate-spin`)}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label font-medium truncate text-foreground`,children:S}),o&&!n&&(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 text-muted-foreground bg-muted px-1 rounded leading-none pb-px border border-border/50`,children:a(`desktopHostSwitcher.header.current`)}),r&&!n&&(0,Q.jsx)(`span`,{className:`typography-micro flex-shrink-0 px-1 rounded leading-none pb-px text-[var(--status-info)] bg-[var(--status-info)]/10`,children:`SSH`})]}),n?(0,Q.jsxs)(`div`,{className:`typography-micro flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:v}),f.latencyMs!=null&&(0,Q.jsxs)(`span`,{children:[f.latencyMs,` ms`]}),p!==`ok`&&(0,Q.jsx)(`span`,{className:$e(`truncate`,or(p)),children:i&&(!o||M===e.id)?a(dr(u?.phase)):a(lr(p))})]}):(0,Q.jsxs)(`div`,{className:$e(`typography-micro truncate`,or(p)),children:[(0,Q.jsx)(`span`,{className:$e(`mr-1 inline-block h-1.5 w-1.5 rounded-full`,ar(p))}),i&&(!o||M===e.id)?a(dr(u?.phase)):a(lr(p)),f.latencyMs==null?``:a(`desktopHostSwitcher.status.ping`,{ms:f.latencyMs}),h?` · ${a(`settings.remoteInstances.clientAuth.state.viaRelay`)}`:``]}),!n&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 truncate font-mono`,children:C})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[n&&o&&(0,Q.jsx)(J,{name:`check`,className:`size-4 text-foreground`,"aria-label":a(`desktopHostSwitcher.header.current`)}),i&&!t&&(u?.phase===`idle`||!u?.phase?(0,Q.jsxs)(Ze,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 px-2.5`,disabled:M===e.id,onClick:t=>{t.stopPropagation(),Ve(e)},children:[M===e.id?(0,Q.jsx)(J,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(J,{name:`plug-2`,className:`h-3.5 w-3.5`}),a(`desktopHostSwitcher.actions.connect`)]}):null),(0,Q.jsxs)(gt,{delayDuration:600,children:[(0,Q.jsx)(mt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:$e(`app-region-no-drag h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors`,s?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/60 hover:text-foreground`),onClick:()=>void Ie(e.id),"aria-pressed":s,"aria-label":a(s?`desktopHostSwitcher.actions.defaultInstanceAria`:`desktopHostSwitcher.actions.setAsDefaultAria`),disabled:T||!s&&cr(p),children:(0,Q.jsx)(J,{name:s?`home-fill`:`home`,className:`h-4 w-4`})})}),(0,Q.jsx)(ht,{sideOffset:6,children:a(s?`desktopHostSwitcher.header.default`:`desktopHostSwitcher.actions.setAsDefault`)})]}),(0,Q.jsxs)(gt,{delayDuration:600,children:[(0,Q.jsx)(mt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:$e(`app-region-no-drag h-8 w-8 rounded-md inline-flex items-center justify-center hover:bg-interactive-hover transition-colors`,cr(p)?`text-muted-foreground/30 cursor-not-allowed`:`text-muted-foreground/60 hover:text-foreground`),onClick:t=>{t.stopPropagation(),Le(e)},disabled:M===e.id||cr(p),"aria-busy":M===e.id,"aria-label":a(`desktopHostSwitcher.actions.openInNewWindowAria`),children:(0,Q.jsx)(J,{name:M===e.id?`loader-4`:`window`,className:$e(`h-4 w-4`,M===e.id&&`animate-spin`)})})}),(0,Q.jsx)(ht,{sideOffset:6,children:cr(p)?a(`desktopHostSwitcher.state.instanceUnreachable`):a(`desktopHostSwitcher.actions.openInNewWindow`)})]})]})]},e.id)})})}),He&&H&&H!==$&&(0,Q.jsxs)(`div`,{className:`flex-shrink-0 rounded-lg border border-border/50 bg-muted/20 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:a(`desktopHostSwitcher.edit.title`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ze,{type:`button`,variant:`outline`,size:`sm`,onClick:Ne,disabled:T,children:a(`desktopHostSwitcher.actions.cancel`)}),(0,Q.jsxs)(Ze,{type:`button`,size:`sm`,onClick:()=>void Fe(),disabled:T,children:[T?(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}):null,a(`desktopHostSwitcher.actions.save`)]})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,Q.jsx)(kt,{value:he,onChange:e=>ge(e.target.value),onKeyDown:Pe,placeholder:a(`desktopHostSwitcher.field.labelPlaceholder`),disabled:T}),(0,Q.jsx)(kt,{value:_e,onChange:e=>ve(e.target.value),onKeyDown:Pe,placeholder:a(`desktopHostSwitcher.field.urlPlaceholder`),disabled:T})]})]}),(0,Q.jsx)(`div`,{className:$e(`flex-shrink-0 border-t border-[var(--interactive-border)]`,n&&`px-3 py-1`),children:(0,Q.jsxs)(`button`,{type:`button`,className:$e(`w-full flex items-center gap-2 px-2 py-2 text-left text-muted-foreground hover:text-foreground hover:bg-interactive-hover/30 transition-colors`,n&&`rounded-xl px-3 py-3`),onClick:ke,children:[(0,Q.jsx)(J,{name:`add`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-ui-label`,children:a(`desktopHostSwitcher.actions.addInstance`)})]})}),fe&&(0,Q.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-status-error`,children:fe})]}),We=(0,Q.jsx)(pt,{open:R.open,onOpenChange:e=>{if(!e&&M){ze();return}de(t=>({...t,open:e,...e?{}:{hostId:null,error:null,errorCode:null,detail:null,phase:`idle`}}))},children:(0,Q.jsxs)(ut,{className:`w-[min(28rem,calc(100vw-2rem))] max-w-none`,children:[(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(dt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J,{name:`loader-4`,className:$e(`h-4 w-4`,!R.error&&`animate-spin`)}),a(`desktopHostSwitcher.ssh.connectingTo`,{host:R.hostLabel||a(`desktopHostSwitcher.ssh.instanceFallback`)})]}),R.error?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ft,{className:`sr-only`,children:a(Gt(Kt(R.errorCode,R.error)))}),(0,Q.jsx)(cn,{errorCode:R.errorCode,detail:R.error})]}):(0,Q.jsx)(ft,{children:R.detail||a(dr(R.phase))})]}),R.error?(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(Ze,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{ke(),ze()},children:a(`desktopHostSwitcher.sshError.openRemoteSettings`)}),(0,Q.jsx)(Ze,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Re(),children:a(`desktopHostSwitcher.actions.switchToLocal`)}),(0,Q.jsx)(Ze,{type:`button`,size:`sm`,onClick:Be,disabled:!R.hostId,children:a(`desktopHostSwitcher.actions.retry`)})]}):null]})});return n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-full max-h-[70vh] flex flex-col overflow-hidden gap-2`,children:Ue}),We]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pt,{open:e,onOpenChange:e=>{!e&&P.current||t(e)},children:(0,Q.jsx)(ut,{className:`w-[min(42rem,calc(100vw-2rem))] max-w-none max-h-[70vh] flex flex-col overflow-hidden gap-3`,children:Ue})}),We]})}function _r(){let e=(0,Z.c)(11),[t,n]=X.useState(!1),{t:r}=ct();if(!y())return null;let i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>n(!0),a=(0,Q.jsx)(J,{name:`server`,className:`h-4 w-4`}),e[0]=i,e[1]=a):(i=e[0],a=e[1]);let o;e[2]===r?o=e[3]:(o=r(`desktopHostSwitcher.actions.switchInstance`),e[2]=r,e[3]=o);let s;e[4]===o?s=e[5]:(s=(0,Q.jsxs)(Ze,{type:`button`,variant:`ghost`,size:`sm`,"data-yuri-host-switcher":!0,className:`w-full justify-center`,onClick:i,children:[a,o]}),e[4]=o,e[5]=s);let c;e[6]===t?c=e[7]:(c=(0,Q.jsx)(gr,{open:t,onOpenChange:n}),e[6]=t,e[7]=c);let l;return e[8]!==s||e[9]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[s,c]}),e[8]=s,e[9]=c,e[10]=l):l=e[10],l}var vr=(e,{desktop:n=!1}={})=>{let r=!1,i=null,o,s=()=>{if(o?.(),!n)return;let i=t();if(!i)return;let a=()=>{!r&&t()===i&&i.getStatus().failureCode===`relay_authentication_rejected`&&e({kind:`relay-authentication`})};o=i.subscribeStatus(a),a()},l=()=>{if(i||r)return;let o=t();if(n&&o?.getStatus().failureCode===`relay_authentication_rejected`){e({kind:`relay-authentication`});return}let s=m(),c=f(),l=a(),u=new AbortController;i=u;let d=setTimeout(()=>u.abort(),1e4);g(`/auth/session`,{credentials:`include`,signal:u.signal}).then(i=>{r||u.signal.aborted||s!==m()||c!==f()||l!==a()||o!==t()||(i.status===401||n&&o&&i.status===403)&&e({kind:`session`,response:i,relay:!!o})}).catch(()=>{}).finally(()=>{clearTimeout(d),i===u&&(i=null)})},u=c(()=>{i?.abort(),i=null,s()});return window.addEventListener(`yuri:runtime-auth-rejected`,l),n&&window.addEventListener(`focus`,l),s(),()=>{r=!0,i?.abort(),o?.(),u(),window.removeEventListener(`yuri:runtime-auth-rejected`,l),window.removeEventListener(`focus`,l)}},yr=(e,t)=>{let n=z(e),r=z(t);if(!n||!r)return!1;try{return new URL(n).origin===new URL(r).origin}catch{return!1}},br=()=>{let e=m();if(e.startsWith(`host:`))return e.slice(5);let t=D();return t?.target===`remote`&&t.status===`ok`&&yr(t.url,h())?t.hostId:null},xr=e=>{let t=e.sshHostIds??[],n=br();if(n)return t.includes(n)?n:null;let r=h();return e.hosts.find(e=>t.includes(e.id)&&!e.relay&&yr(N(e),r))?.id??null},Sr=async()=>{if(!b()||t())return null;let e=await j().catch(()=>null);if(!e)return null;let n=xr(e);return n?{id:n,label:e.hosts.find(e=>e.id===n)?.label?.trim()||``}:null},Cr=async(e={})=>{if(!b()||t())return`not-ssh`;let n=m(),i=f(),o=a(),s=()=>n===m()&&i===f()&&o===a(),c=await j().catch(()=>null);if(!c||!s())return`unchanged`;let l=xr(c);if(!l||e.hostId&&e.hostId!==l)return`not-ssh`;if(e.refresh){try{await C(`desktop_ssh_host_token_refresh`,{hostId:l})}catch{return`failed`}if(c=await j().catch(()=>null),!c||!s())return`unchanged`}let u=c.hosts.find(e=>e.id===l),p=u?z(N(u)):null;return!u||u.relay||!p||!u.clientToken||u.clientToken===r()&&z(h())===p?`unchanged`:(d({apiBaseUrl:p,clientToken:u.clientToken,requestHeaders:u.requestHeaders||null,runtimeKey:B(u)}),`switched`)},wr=e=>e.shouldUseDesktopShellPasswordLogin?`locked`:`error`,Tr=`/auth/session`,Er=4,Dr=1500,Or=2,kr=`yuri.uiAuth.trustDevice`,Ar=`desktop-local`,jr=`desktop-local`,Mr=()=>{if(typeof window>`u`)return``;let e=window.__YURI_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},Nr=(e,t)=>{let n=z(e),r=z(t);if(!n||!r)return!1;try{return new URL(n).origin===new URL(r).origin}catch{return!1}},Pr=()=>y(),Fr=e=>{let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`127.0.0.1`||t===`::1`},Ir=()=>{if(!y())return!1;let e=Mr();if(!e)return!1;let t=h()||(typeof window<`u`?window.location.origin:``);if(Nr(e,t))return!0;try{let e=z(t);return!!(e&&Fr(new URL(e).hostname))}catch{return!1}},Lr=()=>Ir()?{clientKind:Ar,dedupeKey:jr}:{},Rr=async()=>await g(Tr,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}}),zr=()=>typeof window>`u`?!1:window.localStorage.getItem(kr)===`true`,Br=async(e,t)=>{let n=Pr();return await g(Tr,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({password:e,trustDevice:t,issueClientToken:n,clientLabel:`Yuri Desktop`,...Lr()})})},Vr=async()=>{if(!y())return``;let e=await g(`/api/client-auth/clients`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({label:`Yuri Desktop`,...Lr()})}).catch(()=>null);if(!e?.ok)return``;let t=await e.json().catch(()=>null);return typeof t?.token==`string`?t.token.trim():``},Hr=()=>y()&&!Ir(),Ur=async()=>{if(!y())return null;let e=m(),t=br();if(!t)return null;let n=await j().catch(()=>null);if(m()!==e||!n)return;let r=n?.hosts.find(e=>e.id===t);if(r)return r&&M(r)?r:null},Wr=async(e,t)=>{if(!y()||typeof window>`u`)return null;let n=await C(`desktop_remote_password_login`,{url:h(),password:e,trustDevice:t,requestHeaders:i()}).catch(()=>null);if(!n||typeof n!=`object`)return null;let r=n.token,a=n.status;return{token:typeof r==`string`?r.trim():``,...typeof a==`number`?{status:a}:{}}},Gr=async(e,t)=>{if(!y()||!t)return;let n=await j().catch(()=>null);if(!n)return;if(n.localOrigin&&Nr(n.localOrigin,e)){await A({hosts:n.hosts,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted,localClientToken:t}).catch(()=>void 0);return}let r=!1,i=n.hosts.map(n=>!Nr(N(n),e)||n.clientToken===t?n:(r=!0,{...n,clientToken:t}));r&&await A({hosts:i,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>void 0)},Kr=async e=>{if(!e)return;let t=h(),r=i();await Gr(t,e),d({apiBaseUrl:t,clientToken:e,requestHeaders:Object.keys(r).length>0?r:null,relay:n()})},qr=e=>{let t=(0,Z.c)(7),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={height:`var(--yuri-wco-titlebar-height, 0px)`,right:`var(--yuri-wco-right-inset, 0px)`},t[0]=r):r=t[0];let i=r,a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a={fontFamily:`"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif`},o=(0,Q.jsx)(`div`,{className:`app-region-drag fixed left-0 top-0 z-20`,style:i,"aria-hidden":!0}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-55`,style:{background:`radial-gradient(120% 140% at 50% -20%, var(--surface-overlay) 0%, transparent 68%)`}}),t[3]=s):s=t[3];let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{backgroundColor:`var(--surface-subtle)`,opacity:.22}}),t[4]=c):c=t[4];let l;return t[5]===n?l=t[6]:(l=(0,Q.jsxs)(`div`,{className:`relative flex min-h-screen items-center justify-center overflow-hidden bg-background text-foreground`,style:a,children:[o,s,c,(0,Q.jsx)(`div`,{className:`app-region-no-drag relative z-10 flex w-full justify-center px-4 py-12 sm:px-6`,children:n})]}),t[5]=n,t[6]=l),l},Jr=()=>{let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background text-foreground`,children:(0,Q.jsx)(ln,{width:120,height:120})}),e[0]=t):t=e[0],t},Yr=e=>{let t=(0,Z.c)(25),{onRetry:n,errorType:r,retryAfter:i,children:a}=e,o=r===void 0?`network`:r,{t:s}=ct(),c=o===`rate-limit`,l=i?Math.ceil(i/60):1,u;t[0]!==o||t[1]!==c||t[2]!==s?(u=s(c?`sessionAuth.error.rateLimitTitle`:o===`relay-auth`?`sessionAuth.error.relayAuthTitle`:`sessionAuth.error.networkTitle`),t[0]=o,t[1]=c,t[2]=s,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,Q.jsx)(`h1`,{className:`typography-ui-header font-semibold text-destructive`,children:u}),t[4]=u,t[5]=d);let f;t[6]!==o||t[7]!==c||t[8]!==l||t[9]!==s?(f=c?s(l>1?`sessionAuth.error.rateLimitDescriptionPlural`:`sessionAuth.error.rateLimitDescriptionSingle`,{minutes:l}):s(o===`relay-auth`?`sessionAuth.error.relayAuthDescription`:`sessionAuth.error.networkDescription`),t[6]=o,t[7]=c,t[8]=l,t[9]=s,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground max-w-xs`,children:f}),t[11]=f,t[12]=p);let m;t[13]!==d||t[14]!==p?(m=(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[d,p]}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]===s?h=t[17]:(h=s(`sessionAuth.error.retry`),t[16]=s,t[17]=h);let g;t[18]!==n||t[19]!==h?(g=(0,Q.jsx)(Ze,{type:`button`,onClick:n,className:`w-full max-w-xs`,children:h}),t[18]=n,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==a||t[22]!==m||t[23]!==g?(_=(0,Q.jsx)(qr,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-6 text-center`,children:[m,g,a]})}),t[21]=a,t[22]=m,t[23]=g,t[24]=_):_=t[24],_},Xr=({children:e})=>{let{t:r}=ct(),i=X.useMemo(()=>te(),[]),l=i,u=X.useMemo(()=>y()&&!i,[i]),[d,h]=X.useState(()=>l?`authenticated`:`pending`),[g,_]=X.useState(``),[v,b]=X.useState(!1),[x,S]=X.useState(``),[C,w]=X.useState(void 0),[T,E]=X.useState(!1),[D,ee]=X.useState(Qt),[O,ne]=X.useState(!1),[A,j]=X.useState(!1),[M,re]=X.useState(()=>zr()),[ie,N]=X.useState(null),[P,ae]=X.useState(l),oe=X.useRef(null),F=X.useRef(l),I=X.useRef(0);X.useEffect(()=>()=>{I.current+=1},[]),X.useEffect(()=>{typeof window>`u`||window.localStorage.setItem(kr,M?`true`:`false`)},[M]);let L=X.useCallback(async()=>{if(l)return Qt;let e=m(),t=f(),n=a(),r=()=>e===m()&&t===f()&&n===a();try{let e=await Wt();return r()&&ee(e),e}catch{return r()&&ee(Qt),Qt}},[l]);X.useEffect(()=>{let e=!1;if(!l)return(async()=>{try{if(!window.isSecureContext||!Ft()){e||ne(!1);return}e||ne(!0)}catch{e||ne(!1)}})(),()=>{e=!0}},[l]);let se=X.useRef(0),ce=X.useRef(null),le=X.useRef(null),ue=X.useRef(0),[R,de]=X.useState(``),[fe,z]=X.useState(`idle`),B=X.useCallback(()=>{ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null)},[]),V=X.useCallback(()=>{se.current=0,B()},[B]),pe=X.useCallback(()=>se.current>=Er?!1:(se.current+=1,B(),ce.current=window.setTimeout(()=>{ce.current=null,le.current?.()},Dr*se.current),!0),[B]);X.useEffect(()=>B,[B]);let H=X.useCallback(async e=>{if(l){h(`authenticated`);return}let n=++I.current,r=m(),i=f(),o=a(),s=()=>n===I.current&&r===m()&&i===f()&&o===a(),c=y()?t():null;if(c?.getStatus().failureCode===`relay_authentication_rejected`){V(),h(`relay-auth-error`);return}h(e=>e===`authenticated`||e===`ssh-expired`?e:`pending`);try{let[t,n]=await Promise.all([e??Rr(),e?Qt:L()]),r=await t.text();if(!s())return;if(t.ok){V(),ue.current=0,h(`authenticated`),E(!1),S(``),w(void 0);return}if(t.status===401||t.status===403&&(c||y())){if(!c&&y()){let e=ue.current<Or;e&&(ue.current+=1);let t=await Cr({refresh:e}).catch(()=>`not-ssh`);if(t===`switched`){await le.current?.();return}if(t!==`not-ssh`){if(!s())return;V(),E(!1),w(void 0),h(`ssh-expired`);return}}let i=c?!0:await Ur();if(!s())return;if(i===void 0){V(),h(`error`);return}if(i){V(),E(!1),h(`pairing-expired`),w(void 0);return}if(t.status===403){if(pe())return;h(`error`);return}let a={};try{a=JSON.parse(r)}catch{a={}}V(),E(a.tunnelLocked===!0),e||ee(n),h(`locked`),w(void 0);return}if(t.status===429){let e={};try{e=JSON.parse(r)}catch{e={}}V(),w(e.retryAfter),E(!1),h(`rate-limited`);return}if(pe())return;h(`error`),E(!1)}catch(e){if(!s())return;if(console.warn(`Failed to check session status:`,e),c?.getStatus().failureCode===`relay_authentication_rejected`){V(),h(`relay-auth-error`);return}let t=c?!0:await Ur();if(!s())return;if(t||t===void 0){if(pe())return;h(`error`),E(!1);return}if(wr({shouldUseDesktopShellPasswordLogin:Hr()})===`locked`){h(`locked`),w(void 0),E(!1);return}if(pe())return;h(`error`),E(!1)}},[L,V,pe,l]);X.useEffect(()=>{le.current=H},[H]),X.useEffect(()=>{l||H()},[H,l]),X.useEffect(()=>{if(!(l||d!==`authenticated`))return vr(e=>{e.kind===`relay-authentication`?(I.current+=1,V(),h(`relay-auth-error`)):H(e.response)},{desktop:y()})},[H,V,l,d]),X.useEffect(()=>{if(l||!y())return;let e=!1,t=null;return an(t=>{t.phase===`ready`&&Cr({hostId:t.id}).then(t=>{!e&&t===`switched`&&le.current?.()}).catch(()=>void 0)}).then(n=>{e?n():t=n}).catch(()=>void 0),()=>{e=!0,t?.()}},[l]),X.useEffect(()=>{if(d!==`ssh-expired`){z(`idle`);return}let e=!1;return Sr().then(t=>{e||de(t?.label??``)}).catch(()=>void 0),()=>{e=!0}},[d]),X.useEffect(()=>{if(d===`pending`||d===`authenticated`||typeof document>`u`)return;let e=document.getElementById(`initial-loading`);if(!e)return;e.classList.add(`fade-out`);let t=window.setTimeout(()=>{e.remove()},300);return()=>{window.clearTimeout(t)}},[d]),X.useEffect(()=>{if(l)return;let e=qn(e=>{p(e)&&(_(``),S(``),w(void 0),E(!1),V(),ae(!1),F.current=!1,h(`pending`),H())}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[H,V,l]),X.useEffect(()=>{!l&&(d===`locked`||d===`pairing-expired`||d===`ssh-expired`)&&(F.current=!1,ae(!1))},[l,d]),X.useEffect(()=>{d===`locked`&&oe.current&&(oe.current.focus(),oe.current.select())},[d]),X.useEffect(()=>{if(!l&&d===`authenticated`&&!F.current){F.current=!0;let e=!1;return Gn({runtimeKey:m(),initializeAppearance:ye,syncSettings:be,applyDirectory:Hn,onError:(e,t)=>{console.error(`[SessionAuthGate] ${e} settings hydration failed:`,t)}},{force:!0}).then(()=>{e||ae(!0)}),()=>{e=!0}}},[l,d]);let me=async e=>{e.preventDefault(),await _e(!1)},he=X.useCallback(async()=>{N(`register`),j(!0);try{await Ht()}finally{N(null),j(!1)}await L()},[L]),ge=X.useCallback(()=>{Rt(),N(null),j(!1)},[]),_e=X.useCallback(async e=>{if(!T&&!(!g||v)){A&&ge(),b(!0),S(``);try{if(Hr()){let e=await Wr(g,M);if(e?.token){_(``),E(!1),await Kr(e.token),h(`authenticated`);return}if(e?.status===401){S(r(`sessionAuth.error.incorrectPassword`)),E(!1),h(`locked`);return}if(e?.status===429){w(void 0),E(!1),h(`rate-limited`);return}}let t=await Br(g,M);if(t.ok){let n=await t.json().catch(()=>null),i=Pr(),a=``;if(i&&(a=typeof n?.clientToken==`string`&&n.clientToken.trim()?n.clientToken.trim():``,a||=(await Wr(g,M))?.token||await Vr()),_(``),E(!1),a&&await Kr(a),e&&O)try{await he(),q.success(r(`sessionAuth.toast.passkeyAdded`)),h(`authenticated`);return}catch(e){if(Bt(e))q.message(r(`sessionAuth.toast.passkeySetupCanceled`));else{let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySetupFailed`);q.error(t)}h(`authenticated`);return}h(`authenticated`);return}if(t.status===401){S(r(`sessionAuth.error.incorrectPassword`)),E(!1),h(`locked`);return}if(t.status===429){let e=await t.json().catch(()=>({}));w(e.retryAfter),E(!1),h(`rate-limited`);return}S(r(`sessionAuth.error.unexpectedResponse`)),E(!1),h(`error`)}catch(e){console.warn(`Failed to submit UI password:`,e);let t=Hr()?await Wr(g,M):null;if(t?.token){_(``),E(!1),await Kr(t.token),h(`authenticated`);return}if(t?.status===401){S(r(`sessionAuth.error.incorrectPassword`)),E(!1),h(`locked`);return}if(t?.status===429){w(void 0),E(!1),h(`rate-limited`);return}S(r(`sessionAuth.error.networkRetry`)),E(!1),h(`error`)}finally{b(!1)}}},[ge,A,v,T,g,he,O,r,M]),ve=X.useCallback(async()=>{if(!(v||!O)){if(A){ge();return}j(!0),N(`auth`),S(``);try{let e=await $t(M,{issueClientToken:Pr(),clientLabel:`Yuri Desktop`,...Lr()}),t=Pr()&&typeof e?.clientToken==`string`&&e.clientToken.trim()?e.clientToken.trim():``;t&&await Kr(t),_(``),h(`authenticated`)}catch(e){if(Bt(e))S(``);else{let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySignInCanceled`);S(t)}}finally{N(null),j(!1)}}},[ge,A,v,O,r,M]),xe=X.useCallback(async()=>{if(!(v||T||!O)){if(A){ge();return}if(d!==`authenticated`){if(!g){S(r(`sessionAuth.error.enterPasswordForPasskey`));return}await _e(!0);return}S(``);try{await he(),q.success(r(`sessionAuth.toast.passkeyAdded`))}catch(e){if(Bt(e)){q.message(r(`sessionAuth.toast.passkeySetupCanceled`));return}let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySetupFailed`);q.error(t)}}},[ge,_e,A,v,T,g,he,d,O,r]),Se=O&&D.enabled,Ce=Se&&D.hasPasskeys;if(d===`pending`||d===`authenticated`&&!P)return(0,Q.jsx)(Jr,{});if(d===`error`)return(0,Q.jsx)(Yr,{onRetry:()=>{V(),H()},errorType:`network`,children:u&&(0,Q.jsxs)(`div`,{className:`w-full max-w-xs`,children:[(0,Q.jsx)(_r,{}),(0,Q.jsx)(`p`,{className:`mt-1 text-center typography-micro text-muted-foreground`,children:r(`sessionAuth.locked.hostSwitcherHint`)})]})});if(d===`rate-limited`)return(0,Q.jsx)(Yr,{onRetry:()=>void H(),errorType:`rate-limit`,retryAfter:C});if(d===`pairing-expired`)return(0,Q.jsx)(qr,{children:(0,Q.jsxs)(`div`,{className:`flex w-full max-w-xs flex-col items-center gap-6 text-center`,children:[(0,Q.jsx)(J,{name:`computer`,className:`size-8 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h1`,{className:`text-xl font-semibold`,children:r(`mobile.connect.pairing.expired`)}),(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`desktopHostSwitcher.pairing.reconnectHint`)})]}),(0,Q.jsx)(Ze,{type:`button`,className:`w-full`,onClick:()=>{k().catch(()=>q.error(r(`sessionAuth.error.networkTitle`)))},children:r(`settings.remoteInstances.openLocalManager`)}),(0,Q.jsx)(_r,{})]})});if(d===`ssh-expired`){let e=fe===`reconnecting`;return(0,Q.jsx)(qr,{children:(0,Q.jsxs)(`div`,{className:`flex w-full max-w-xs flex-col items-center gap-6 text-center`,children:[(0,Q.jsx)(J,{name:`computer`,className:`size-8 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h1`,{className:`text-xl font-semibold`,children:R?r(`sessionAuth.sshExpired.titleWithHost`,{name:R}):r(`sessionAuth.sshExpired.title`)}),(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`sessionAuth.sshExpired.description`)})]}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,children:[(0,Q.jsxs)(Ze,{type:`button`,className:`w-full`,disabled:e,onClick:()=>{ue.current=0,V(),z(`reconnecting`),H().finally(()=>{z(e=>e===`reconnecting`?`failed`:e)})},children:[e&&(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),r(e?`sessionAuth.sshExpired.reconnecting`:`sessionAuth.sshExpired.reconnect`)]}),fe===`failed`&&(0,Q.jsx)(`p`,{role:`alert`,className:`typography-meta text-destructive`,children:r(`sessionAuth.sshExpired.failed`)}),(0,Q.jsx)(Ze,{type:`button`,variant:`outline`,className:`w-full`,disabled:e,onClick:()=>{k().catch(()=>q.error(r(`sessionAuth.error.networkTitle`)))},children:r(`settings.remoteInstances.openLocalManager`)})]}),(0,Q.jsx)(_r,{})]})})}return d===`relay-auth-error`?(0,Q.jsx)(Yr,{errorType:`relay-auth`,onRetry:()=>{let e=n();e&&(o(),s(e)),V(),H()},children:u&&(0,Q.jsx)(_r,{})}):d===`locked`?(0,Q.jsx)(qr,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-6 w-full max-w-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:r(T?`sessionAuth.locked.tunnelTitle`:`sessionAuth.locked.unlockTitle`)}),(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(T?`sessionAuth.locked.tunnelDescription`:`sessionAuth.locked.passwordDescription`)})]}),!T&&(0,Q.jsxs)(`form`,{onSubmit:me,className:`w-full space-y-2`,children:[Ce&&(0,Q.jsxs)(Ze,{type:`button`,variant:`outline`,className:`w-full`,onClick:()=>void ve(),disabled:v||A&&ie!==`auth`,children:[A?(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(J,{name:`lock-unlock`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:r(A&&ie===`auth`?`sessionAuth.actions.cancelPasskey`:`sessionAuth.actions.usePasskey`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(J,{name:`lock`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/60`}),(0,Q.jsx)(kt,{id:`yuri-ui-password`,ref:oe,type:`password`,autoComplete:`current-password`,placeholder:r(`sessionAuth.password.placeholder`),value:g,onChange:e=>{_(e.target.value),x&&S(``)},className:`pl-10`,"aria-invalid":!!x||void 0,"aria-describedby":x?`yuri-ui-auth-error`:void 0,disabled:v})]}),(0,Q.jsx)(Ze,{type:`submit`,size:`icon`,disabled:!g||v,"aria-label":r(v?`sessionAuth.actions.unlockingAria`:`sessionAuth.actions.unlockAria`),children:v?(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(J,{name:`lock-unlock`,className:`h-4 w-4`})})]}),Se?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-center typography-micro text-muted-foreground`,children:[(0,Q.jsx)(It,{checked:M,onChange:re,disabled:v,ariaLabel:r(`sessionAuth.actions.trustDeviceAria`),className:`size-4`,iconClassName:`size-4`}),(0,Q.jsx)(`span`,{children:r(`sessionAuth.actions.trustDevice`)})]}),(0,Q.jsx)(Ze,{type:`button`,variant:`ghost`,size:`sm`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>void xe(),disabled:v,children:r(A&&ie===`register`?`sessionAuth.actions.cancelPasskeySetup`:`sessionAuth.actions.addPasskey`)})]}):(0,Q.jsxs)(`label`,{className:`flex items-center justify-center gap-2 pt-1 text-center typography-micro text-muted-foreground`,children:[(0,Q.jsx)(It,{checked:M,onChange:re,disabled:v,ariaLabel:r(`sessionAuth.actions.trustDeviceAria`),className:`size-4`,iconClassName:`size-4`}),(0,Q.jsx)(`span`,{children:r(`sessionAuth.actions.trustDevice`)})]}),x&&(0,Q.jsx)(`p`,{id:`yuri-ui-auth-error`,className:`typography-meta text-destructive`,children:x})]}),u&&(0,Q.jsxs)(`div`,{className:`w-full`,children:[(0,Q.jsx)(_r,{}),(0,Q.jsx)(`p`,{className:`mt-1 text-center typography-micro text-muted-foreground`,children:r(`sessionAuth.locked.hostSwitcherHint`)})]})]})}):(0,Q.jsx)(Q.Fragment,{children:e})},Zr=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Qr=e=>typeof e==`string`&&e.trim()?e.trim():null,$r=e=>{if(!Zr(e))throw Error(`Could not check OpenCode compatibility`);let t=e.state,n=e.installation;if(t!==`compatible`&&t!==`incompatible`&&t!==`unavailable`||n!==`managed`&&n!==`external`&&n!==`bundled`)throw Error(`Could not check OpenCode compatibility`);let r=Qr(e.minimumVersion),i=Qr(e.targetVersion);if(!r||!i||typeof e.canInstall!=`boolean`)throw Error(`Could not check OpenCode compatibility`);return{state:t,version:Qr(e.version),installation:n,minimumVersion:r,targetVersion:i,canInstall:e.canInstall,guidance:Qr(e.guidance)}},ei=async()=>{let e=await g(`/api/opencode/compatibility`,{signal:AbortSignal.timeout(2e4)});if(!e.ok)throw Error(`Could not check OpenCode compatibility`);return $r(await e.json())},ti=async()=>{let e=await g(`/api/opencode/install-required`,{method:`POST`}),t=await e.json().catch(()=>null),n=Zr(t)?t:null,r=Qr(n?.error);if(!e.ok||n?.success!==!0||n?.upgraded!==!0)throw Error(r||`OpenCode installation failed`);let i=Qr(n.version);if(!i)throw Error(r||`OpenCode installation did not report a verified version`);return{version:i}},ni=(e,t)=>e instanceof Error&&e.message.trim()?e.message.trim():t,ri=({children:e})=>{let{t}=ct(),[n,r]=X.useState(null),[i,a]=X.useState(!1),[o,s]=X.useState(null),[l,u]=X.useState(null),d=X.useId(),f=X.useRef(null),p=X.useRef(0);X.useEffect(()=>{let e=!0,t=async()=>{let t=++p.current;try{let n=await ei();if(!e||t!==p.current)return;r(n),n.state!==`incompatible`&&u(null)}catch{}finally{e&&t===p.current&&a(!0)}};t();let n=c(()=>{e&&(r(null),a(!1),s(null),u(null),t())});return()=>{e=!1,p.current+=1,n()}},[]);let m=n?.state===`incompatible`;X.useEffect(()=>{m&&(document.getElementById(`initial-loading`)?.remove(),f.current?.focus())},[m]);let h=U(async e=>{if(o)return;let n=++p.current;s(e),u(null);try{if(e===`install`){let e=await ti();if(n!==p.current)return;if(!e.version)throw Error(t(`opencodeUpgrade.screen.failedGeneric`));window.location.reload();return}let i=await ei();if(n!==p.current)return;if(i.state===`incompatible`){r(i);return}if(i.state!==`compatible`)throw Error(t(`opencodeUpgrade.screen.failedGeneric`));window.location.reload()}catch(e){if(n!==p.current)return;u(ni(e,t(`opencodeUpgrade.screen.failedGeneric`)))}finally{n===p.current&&s(null)}}),g=(0,Q.jsx)(`main`,{"data-startup-logo":!0,className:`flex min-h-dvh items-center justify-center bg-background text-foreground`,children:(0,Q.jsx)(ln,{width:120,height:120,isAnimated:!0})});if(!i)return g;if(!m||!n)return(0,Q.jsx)(un,{children:(0,Q.jsx)(X.Suspense,{fallback:g,children:e})});let _=!!n.version?.startsWith(`2.`),v=n.installation===`bundled`?`opencodeUpgrade.screen.bundled`:n.installation===`external`?_?`opencodeUpgrade.screen.outdatedExternal`:`opencodeUpgrade.screen.external`:_?`opencodeUpgrade.screen.outdatedLocal`:`opencodeUpgrade.screen.local`,y=n.minimumVersion,b=o!==null;return(0,Q.jsx)(`section`,{className:`app-region-drag flex h-full min-h-dvh min-h-0 items-center justify-center overflow-y-auto bg-background px-4 py-10 text-foreground select-none sm:px-6`,"aria-labelledby":d,"aria-busy":b,"data-opencode-upgrade-screen":`true`,children:(0,Q.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center text-center`,children:[(0,Q.jsx)(ln,{width:48,height:48}),(0,Q.jsx)(`h1`,{id:d,ref:f,tabIndex:-1,className:`mt-6 text-xl font-semibold tracking-tight text-balance outline-none`,children:t(_?`opencodeUpgrade.screen.outdatedTitle`:`opencodeUpgrade.screen.title`)}),(0,Q.jsxs)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground text-balance`,children:[t(v,{version:n.version??``,minimum:y}),n.canInstall?(0,Q.jsxs)(Q.Fragment,{children:[` `,t(`opencodeUpgrade.screen.installDescription`,{minimum:y})]}):null]}),n.canInstall?null:(0,Q.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-muted-foreground text-balance`,children:t(`opencodeUpgrade.screen.manualGuidance`)}),n.version?(0,Q.jsxs)(`div`,{className:`mt-5 inline-flex max-w-full items-center gap-2 rounded-md border border-border px-2.5 py-1 font-mono text-xs`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`truncate text-muted-foreground`,children:n.version}),(0,Q.jsx)(J,{name:`arrow-right`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`text-foreground`,children:[y,`+`]})]}):null,l?(0,Q.jsxs)(`p`,{role:`alert`,className:`mt-5 w-full break-words rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] px-3 py-2 text-left text-sm text-[var(--status-error-text)]`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t(`opencodeUpgrade.screen.failedTitle`)}),` `,l]}):null,(0,Q.jsxs)(`div`,{className:`app-region-no-drag mt-7 flex w-full flex-wrap items-center justify-center gap-2`,children:[n.canInstall?(0,Q.jsxs)(Ze,{type:`button`,disabled:b,onClick:()=>void h(`install`),children:[(0,Q.jsx)(J,{name:o===`install`?`refresh`:`download`,className:o===`install`?`size-4 motion-safe:animate-spin`:`size-4`}),(0,Q.jsx)(`span`,{role:o===`install`?`status`:void 0,children:o===`install`?t(_?`opencodeUpgrade.screen.updating`:`opencodeUpgrade.screen.installing`):t(_?`opencodeUpgrade.screen.update`:`opencodeUpgrade.screen.install`,{minimum:y})})]}):null,(0,Q.jsxs)(Ze,{type:`button`,variant:n.canInstall?`ghost`:`default`,disabled:b,onClick:()=>void h(`reconnect`),children:[(0,Q.jsx)(J,{name:`refresh`,className:o===`reconnect`?`size-4 motion-safe:animate-spin`:`size-4`}),(0,Q.jsx)(`span`,{role:o===`reconnect`?`status`:void 0,children:t(o===`reconnect`?`opencodeUpgrade.screen.reconnecting`:`opencodeUpgrade.screen.reconnect`)})]})]}),(0,Q.jsxs)(`a`,{className:`app-region-no-drag mt-6 inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,href:`https://opencode.ai/download`,target:`_blank`,rel:`noopener noreferrer`,children:[t(`opencodeUpgrade.screen.guide`),(0,Q.jsx)(J,{name:`external-link`,className:`size-3`})]}),(0,Q.jsx)(`div`,{className:`app-region-no-drag mt-3 w-full`,children:(0,Q.jsx)(_r,{})})]})})},ii=e=>{let t=(0,Z.c)(14),{children:n}=e,r=W(ai),i=W(oi),a=W(si),o=W(ci),s=W(li),{deviceType:c,hasTouchInput:l}=bt(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=typeof document<`u`&&Fe(),t[0]=u):u=t[0];let d=u,f;t[1]!==s||t[2]!==a?(f=()=>{a(),s()},t[1]=s,t[2]=a,t[3]=f):f=t[3];let p;t[4]!==s||t[5]!==a||t[6]!==i||t[7]!==c||t[8]!==r||t[9]!==l||t[10]!==o?(p=[r,i,a,o,s,c,l,d],t[4]=s,t[5]=a,t[6]=i,t[7]=c,t[8]=r,t[9]=l,t[10]=o,t[11]=p):p=t[11],X.useLayoutEffect(f,p);let m;return t[12]===n?m=t[13]:(m=(0,Q.jsx)(Q.Fragment,{children:n}),t[12]=n,t[13]=m),m};function ai(e){return e.fontSize}function oi(e){return e.codeFontSize}function si(e){return e.applyTypography}function ci(e){return e.padding}function li(e){return e.applyPadding}var ui=e(pe(),1),di={light:`#212121`,dark:`#DEDEDE`},fi=e=>{let t=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.exec(e);if(!t)return null;let n=t[1].length<5?[...t[1]].map(e=>e+e).join(``):t[1];return[0,2,4].map(e=>Number.parseInt(n.slice(e,e+2),16)).concat(n.length===8?Number.parseInt(n.slice(6),16)/255:1)},pi=e=>{let t=e.slice(0,3).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return t[0]*.2126+t[1]*.7152+t[2]*.0722},mi=e=>{let t=di[e.metadata.variant],n=pi(fi(t)),r=e.colors,i=!1,a=(e,r)=>{let a=fi(e);if(!a)return e;let o=fi(r);return pi(a[3]===1||!o?a:a.slice(0,3).map((e,t)=>e*a[3]+o[t]*(1-a[3])))+1e-9>=n?e:(i=!0,t)},o={...r.surface,foreground:a(r.surface.foreground,r.surface.background),elevatedForeground:a(r.surface.elevatedForeground,r.surface.elevated)},s=r.chat?{...r.chat}:void 0;s?.userMessage&&(s.userMessage=a(s.userMessage,s.userMessageBackground||r.surface.elevated)),s?.assistantMessage&&(s.assistantMessage=a(s.assistantMessage,s.assistantMessageBackground||r.surface.muted));let c=r.tools?{...r.tools}:void 0;c?.title&&(c.title=a(c.title,r.surface.muted));let l=r.markdown?{...r.markdown}:void 0;if(l)for(let e of[`bold`,`italic`,`heading1`,`heading2`,`heading3`,`heading4`]){let t=l[e];if(!t)continue;let n=fi(t),i=n&&n[0]===n[1]&&n[1]===n[2],o=[r.surface.foreground,r.surface.elevatedForeground].some(e=>e.toLowerCase()===t.toLowerCase());(!e.startsWith(`heading`)||i||o)&&(l[e]=a(t,s?.background||r.surface.background))}return i?{...e,colors:{...r,surface:o,...s&&{chat:s},...c&&{tools:c},...l&&{markdown:l}}}:e},hi=e=>{if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`#`))return null;let n=t.slice(1);if((n.length===3||n.length===4)&&(n=n.split(``).map(e=>e+e).join(``)),n.length===8&&(n=n.slice(0,6)),n.length!==6)return null;let r=Number.parseInt(n,16);return Number.isNaN(r)?null:`${r>>16&255} ${r>>8&255} ${r&255}`},gi=class{inheritanceMap=new Map;constructor(){this.initializeInheritanceMap()}generate(e){e=mi(e);let t=[];return t.push(...this.generateTailwindVariables(e)),t.push(...this.generatePrimaryColors(e.colors.primary)),t.push(...this.generateSurfaceColors(e.colors.surface)),t.push(...this.generateInteractiveColors(e)),t.push(...this.generateStatusColors(e.colors.status)),t.push(...this.generatePullRequestColors(e)),t.push(...this.generateSyntaxColors(e.colors.syntax)),t.push(...this.generateComponentColors(e.colors,e)),t.push(...this.generateTypographyVariables()),e.config&&t.push(...this.generateConfigVariables(e.config)),t.join(`
3
+ `)}generateTailwindVariables(e){let t=[];t.push(` --background: ${e.colors.surface.background} !important;`),t.push(` --foreground: ${e.colors.surface.foreground} !important;`),t.push(` --muted: ${e.colors.surface.muted} !important;`),t.push(` --muted-foreground: ${e.colors.surface.mutedForeground} !important;`),t.push(` --card: ${e.colors.surface.elevated} !important;`),t.push(` --card-foreground: ${e.colors.surface.elevatedForeground} !important;`),t.push(` --popover: ${e.colors.surface.elevated} !important;`),t.push(` --popover-foreground: ${e.colors.surface.elevatedForeground} !important;`),t.push(` --border: ${e.colors.interactive.border} !important;`),t.push(` --input: ${e.colors.interactive.border} !important;`),t.push(` --primary: ${e.colors.primary.base} !important;`),t.push(` --primary-foreground: ${e.colors.primary.foreground} !important;`),t.push(` --secondary: ${e.colors.surface.muted} !important;`),t.push(` --secondary-foreground: ${e.colors.surface.mutedForeground} !important;`),t.push(` --accent: ${e.colors.surface.subtle} !important;`),t.push(` --accent-foreground: ${e.colors.surface.foreground} !important;`),t.push(` --destructive: ${e.colors.status.error} !important;`),t.push(` --destructive-foreground: ${e.colors.status.errorForeground} !important;`),t.push(` --ring: ${e.colors.interactive.focusRing} !important;`);let n=hi(e.colors.surface.muted),r=hi(e.colors.surface.subtle),i=hi(e.colors.interactive.border);t.push(` --sidebar-base: ${e.colors.surface.muted} !important;`),n&&t.push(` --sidebar-base-rgb: ${n} !important;`),t.push(` --sidebar: var(--sidebar-base) !important;`),t.push(` --sidebar-foreground: ${e.colors.surface.mutedForeground} !important;`),t.push(` --sidebar-primary: ${e.colors.primary.base} !important;`),t.push(` --sidebar-primary-foreground: ${e.colors.primary.foreground} !important;`),t.push(` --sidebar-accent-base: ${e.colors.surface.subtle} !important;`),r&&t.push(` --sidebar-accent-base-rgb: ${r} !important;`),t.push(` --sidebar-accent: var(--sidebar-accent-base) !important;`),t.push(` --sidebar-accent-foreground: ${e.colors.surface.foreground} !important;`),t.push(` --sidebar-border: ${e.colors.interactive.border} !important;`),i&&t.push(` --sidebar-border-rgb: ${i} !important;`),t.push(` --sidebar-ring: ${e.colors.interactive.focusRing} !important;`);let a=e.metadata.variant===`dark`,o=a?.15:.5,s=a?.1:.3,c=a?.42:.52;if(n)t.push(` --sidebar-overlay-strong: rgb(${n} / ${o}) !important;`),t.push(` --sidebar-overlay-soft: rgb(${n} / ${s}) !important;`),t.push(` --sidebar-vibrancy-overlay: rgb(${n} / ${c}) !important;`);else{let n=e.colors.surface.muted;t.push(` --sidebar-overlay-strong: ${this.opacity(n,o)} !important;`),t.push(` --sidebar-overlay-soft: ${this.opacity(n,s)} !important;`),t.push(` --sidebar-vibrancy-overlay: ${this.opacity(n,c)} !important;`)}return e.colors.charts?.series&&Array.isArray(e.colors.charts.series)&&e.colors.charts.series.forEach((e,n)=>{t.push(` --chart-${n+1}: ${e};`)}),e.colors.loading?(t.push(` --loading-spinner: ${e.colors.loading.spinner||e.colors.primary.base};`),t.push(` --loading-spinner-track: ${e.colors.loading.spinnerTrack||e.colors.surface.muted};`)):(t.push(` --loading-spinner: ${e.colors.primary.base};`),t.push(` --loading-spinner-track: ${e.colors.surface.muted};`)),t}apply(e){let t=this.generate(e),n=document.createElement(`style`);n.id=`opencode-theme-variables`;let r=``;e.metadata.variant===`dark`?(r=`:root {\n${t}\n}\n\n.dark {\n${t}\n}`,document.documentElement.classList.add(`dark`),document.documentElement.classList.remove(`light`)):(r=`:root {\n${t}\n}\n\n:root:not(.dark) {\n${t}\n}`,document.documentElement.classList.remove(`dark`),document.documentElement.classList.add(`light`)),n.textContent=r;let i=document.getElementById(`opencode-theme-variables`);i&&i.remove(),document.head.insertBefore(n,document.head.querySelector(`[data-yuri-plugin-style]`)),document.documentElement.setAttribute(`data-theme`,e.metadata.variant);let a=typeof window<`u`&&window.__YURI_ELECTRON__?.runtime===`electron`&&window.__YURI_ELECTRON__?.macVibrancy===!0;document.documentElement.toggleAttribute(`data-yuri-vibrancy`,a),a&&document.documentElement.toggleAttribute(`data-yuri-vibrancy-ready`,!0)}generatePrimaryColors(e){let t=[];return t.push(` --primary-base: ${e.base};`),t.push(` --primary-hover: ${e.hover||this.darken(e.base,10)};`),t.push(` --primary-active: ${e.active||this.darken(e.base,20)};`),t.push(` --primary-foreground: ${e.foreground||`#ffffff`};`),t.push(` --primary-muted: ${e.muted||this.opacity(e.base,.5)};`),t.push(` --primary-emphasis: ${e.emphasis||this.lighten(e.base,10)};`),t}generateSurfaceColors(e){let t=[];return t.push(` --surface-background: ${e.background};`),t.push(` --surface-foreground: ${e.foreground};`),t.push(` --surface-muted: ${e.muted};`),t.push(` --surface-muted-foreground: ${e.mutedForeground};`),t.push(` --surface-elevated: ${e.elevated};`),t.push(` --surface-elevated-foreground: ${e.elevatedForeground};`),t.push(` --surface-overlay: ${e.overlay};`),t.push(` --surface-subtle: ${e.subtle};`),t}generateInteractiveColors(e){let{interactive:t}=e.colors,n=e.metadata.variant===`light`,r=[];return r.push(` --interactive-border: ${t.border};`),r.push(` --interactive-border-hover: ${t.borderHover};`),r.push(` --interactive-border-focus: ${t.borderFocus};`),r.push(` --interactive-selection: ${n?`color-mix(in srgb, var(--surface-foreground) 7%, var(--background))`:t.selection};`),r.push(` --interactive-selection-foreground: ${n?`var(--surface-foreground)`:t.selectionForeground};`),r.push(` --interactive-focus: ${t.focus};`),r.push(` --interactive-focus-ring: ${t.focusRing};`),r.push(` --interactive-cursor: ${t.cursor};`),r.push(` --interactive-hover: ${t.hover};`),r.push(` --interactive-active: ${t.active};`),r}generateStatusColors(e){let t=[];return t.push(` --status-error: ${e.error};`),t.push(` --status-error-foreground: ${e.errorForeground};`),t.push(` --status-error-background: ${e.errorBackground};`),t.push(` --status-error-border: ${e.errorBorder};`),t.push(` --status-warning: ${e.warning};`),t.push(` --status-warning-foreground: ${e.warningForeground};`),t.push(` --status-warning-background: ${e.warningBackground};`),t.push(` --status-warning-border: ${e.warningBorder};`),t.push(` --status-success: ${e.success};`),t.push(` --status-success-foreground: ${e.successForeground};`),t.push(` --status-success-background: ${e.successBackground};`),t.push(` --status-success-border: ${e.successBorder};`),t.push(` --status-info: ${e.info};`),t.push(` --status-info-foreground: ${e.infoForeground};`),t.push(` --status-info-background: ${e.infoBackground};`),t.push(` --status-info-border: ${e.infoBorder};`),t}generatePullRequestColors(e){let t=[],n=e.colors.pr;return t.push(` --pr-open: ${n?.open||e.colors.status.success};`),t.push(` --pr-draft: ${n?.draft||e.colors.surface.mutedForeground};`),t.push(` --pr-blocked: ${n?.blocked||e.colors.status.warning};`),t.push(` --pr-merged: ${n?.merged||(e.metadata.variant===`dark`?`#8957e5`:`#8250df`)};`),t.push(` --pr-closed: ${n?.closed||e.colors.status.error};`),t}generateSyntaxColors(e){let t=[];t.push(` --syntax-background: ${e.base.background};`),t.push(` --syntax-foreground: ${e.base.foreground};`),t.push(` --syntax-comment: ${e.base.comment};`),t.push(` --syntax-keyword: ${e.base.keyword};`),t.push(` --syntax-string: ${e.base.string};`),t.push(` --syntax-number: ${e.base.number};`),t.push(` --syntax-function: ${e.base.function};`),t.push(` --syntax-variable: ${e.base.variable};`),t.push(` --syntax-type: ${e.base.type};`),t.push(` --syntax-operator: ${e.base.operator};`);let n=this.generateSyntaxTokens(e);for(let[e,r]of Object.entries(n))t.push(` --syntax-${this.kebabCase(e)}: ${r};`);return t}generateSyntaxTokens(e){let t=e.base,n=e.tokens||{};return{commentDoc:n.commentDoc||this.lighten(t.comment,10),stringEscape:n.stringEscape||this.darken(t.string,20),stringInterpolation:n.stringInterpolation||t.variable,stringRegex:n.stringRegex||this.adjustHue(t.string,15),keywordControl:n.keywordControl||t.keyword,keywordOperator:n.keywordOperator||t.operator,keywordImport:n.keywordImport||this.lighten(t.keyword,10),keywordReturn:n.keywordReturn||this.emphasize(t.keyword),functionCall:n.functionCall||this.lighten(t.function,5),functionBuiltin:n.functionBuiltin||this.darken(t.function,10),method:n.method||t.function,methodCall:n.methodCall||this.lighten(t.function,5),variableBuiltin:n.variableBuiltin||this.emphasize(t.variable),variableProperty:n.variableProperty||this.lighten(t.variable,10),variableReadonly:n.variableReadonly||t.number,parameter:n.parameter||t.variable,typePrimitive:n.typePrimitive||this.darken(t.type,10),typeInterface:n.typeInterface||t.type,className:n.className||this.emphasize(t.type),enum:n.enum||t.type,boolean:n.boolean||t.number,null:n.null||this.opacity(t.number,.7),constant:n.constant||t.number,punctuation:n.punctuation||this.opacity(t.foreground,.7),delimiter:n.delimiter||this.opacity(t.foreground,.8),bracket:n.bracket||t.foreground,tag:n.tag||t.keyword,tagAttribute:n.tagAttribute||t.variable,tagAttributeValue:n.tagAttributeValue||t.string,tagBracket:n.tagBracket||this.opacity(t.foreground,.8),decorator:n.decorator||t.function,annotation:n.annotation||t.function,namespace:n.namespace||this.opacity(t.type,.8),module:n.module||this.opacity(t.type,.8),...n}}generateComponentColors(e,t){let n=[];return e.markdown?n.push(...this.generateMarkdownColors(e.markdown,t)):n.push(...this.generateDefaultMarkdownColors(t)),e.chat?n.push(...this.generateChatColors(e.chat,t)):n.push(...this.generateDefaultChatColors(t)),e.tools?n.push(...this.generateToolColors(e.tools,t)):n.push(...this.generateDefaultToolColors(t)),n}generateMarkdownColors(e,t){let n=[],r=t.colors.primary.base,i=t.colors.chat?.background||t.colors.surface.background;return n.push(` --markdown-heading1: ${e.heading1||r};`),n.push(` --markdown-heading2: ${e.heading2||this.opacity(r,.9)};`),n.push(` --markdown-heading3: ${e.heading3||this.opacity(r,.8)};`),n.push(` --markdown-heading4: ${e.heading4||t.colors.surface.foreground};`),n.push(` --markdown-link: ${e.link||r};`),n.push(` --markdown-link-hover: ${e.linkHover||t.colors.primary.hover||this.darken(r,10)};`),n.push(` --markdown-inline-code: ${e.inlineCode||t.colors.syntax.base.string};`),n.push(` --markdown-inline-code-bg: ${e.inlineCodeBackground||i};`),n.push(` --markdown-blockquote: ${e.blockquote||t.colors.surface.mutedForeground};`),n.push(` --markdown-blockquote-border: ${e.blockquoteBorder||t.colors.interactive.border};`),n.push(` --markdown-list-marker: ${r};`),n.push(` --markdown-bold: ${e.bold||t.colors.surface.foreground};`),n.push(` --markdown-italic: ${e.italic||this.opacity(t.colors.surface.foreground,.9)};`),n.push(` --markdown-strikethrough: ${e.strikethrough||t.colors.surface.mutedForeground};`),n.push(` --markdown-hr: ${e.hr||t.colors.interactive.border};`),n}generateDefaultMarkdownColors(e){let t=[],n=e.colors.primary.base,r=e.colors.chat?.background||e.colors.surface.background;return t.push(` --markdown-heading1: ${n};`),t.push(` --markdown-heading2: ${this.opacity(n,.9)};`),t.push(` --markdown-heading3: ${this.opacity(n,.8)};`),t.push(` --markdown-heading4: ${e.colors.surface.foreground};`),t.push(` --markdown-link: ${n};`),t.push(` --markdown-link-hover: ${e.colors.primary.hover||this.darken(n,10)};`),t.push(` --markdown-inline-code: ${e.colors.syntax.base.string};`),t.push(` --markdown-inline-code-bg: ${r};`),t.push(` --markdown-blockquote: ${e.colors.surface.mutedForeground};`),t.push(` --markdown-blockquote-border: ${e.colors.interactive.border};`),t.push(` --markdown-list-marker: ${n};`),t.push(` --markdown-bold: ${e.colors.surface.foreground};`),t.push(` --markdown-italic: ${this.opacity(e.colors.surface.foreground,.9)};`),t.push(` --markdown-strikethrough: ${e.colors.surface.mutedForeground};`),t.push(` --markdown-hr: ${e.colors.interactive.border};`),t}generateChatColors(e,t){let n=[],r=e.background||t.colors.surface.background,i=e.composerSkill||this.getDefaultComposerSkillColor(t);return n.push(` --chat-background: ${r};`),n.push(` --chat-user-message: ${e.userMessage||t.colors.surface.foreground};`),n.push(` --chat-user-message-bg: ${e.userMessageBackground||t.colors.surface.elevated};`),n.push(` --chat-assistant-message: ${e.assistantMessage||t.colors.surface.foreground};`),n.push(` --chat-assistant-message-bg: ${e.assistantMessageBackground||t.colors.surface.muted};`),n.push(` --chat-timestamp: ${e.timestamp||t.colors.surface.mutedForeground};`),n.push(` --chat-divider: ${e.divider||t.colors.interactive.border};`),n.push(` --chat-typing: ${e.typing||t.colors.surface.mutedForeground};`),n.push(` --chat-composer-skill: ${i};`),n}generateDefaultChatColors(e){let t=[];return t.push(` --chat-background: ${e.colors.surface.background};`),t.push(` --chat-user-message: ${e.colors.surface.foreground};`),t.push(` --chat-user-message-bg: ${e.colors.surface.elevated};`),t.push(` --chat-assistant-message: ${e.colors.surface.foreground};`),t.push(` --chat-assistant-message-bg: ${e.colors.surface.muted};`),t.push(` --chat-timestamp: ${e.colors.surface.mutedForeground};`),t.push(` --chat-divider: ${e.colors.interactive.border};`),t.push(` --chat-typing: ${e.colors.surface.mutedForeground};`),t.push(` --chat-composer-skill: ${this.getDefaultComposerSkillColor(e)};`),t}getDefaultComposerSkillColor(e){return e.metadata.variant===`dark`?this.lighten(e.colors.status.warning,25):e.colors.status.warning}generateToolColors(e,t){let n=[];return n.push(` --tools-background: ${e?.background||this.opacity(t.colors.surface.muted,.2)};`),n.push(` --tools-border: ${e?.border||this.opacity(t.colors.interactive.border,.3)};`),n.push(` --tools-header-hover: ${e?.headerHover||this.opacity(t.colors.surface.muted,.3)};`),n.push(` --tools-icon: ${e?.icon||t.colors.surface.mutedForeground};`),n.push(` --tools-title: color-mix(in srgb, ${e?.title||t.colors.surface.foreground} 50%, ${t.colors.surface.mutedForeground});`),n.push(` --tools-description: ${e?.description||this.opacity(t.colors.surface.mutedForeground,.6)};`),e?.edit?(n.push(` --tools-edit-added: ${e.edit.added||t.colors.status.success};`),n.push(` --tools-edit-added-bg: ${e.edit.addedBackground||t.colors.status.successBackground};`),n.push(` --tools-edit-removed: ${e.edit.removed||t.colors.status.error};`),n.push(` --tools-edit-removed-bg: ${e.edit.removedBackground||t.colors.status.errorBackground};`),n.push(` --tools-edit-modified: ${e.edit.modified||t.colors.status.info};`),n.push(` --tools-edit-modified-bg: ${e.edit.modifiedBackground||t.colors.status.infoBackground};`),n.push(` --tools-edit-line-number: ${e.edit.lineNumber||this.opacity(t.colors.surface.mutedForeground,.6)};`)):(n.push(` --tools-edit-added: ${t.colors.status.success};`),n.push(` --tools-edit-added-bg: ${t.colors.status.successBackground};`),n.push(` --tools-edit-removed: ${t.colors.status.error};`),n.push(` --tools-edit-removed-bg: ${t.colors.status.errorBackground};`),n.push(` --tools-edit-modified: ${t.colors.status.info};`),n.push(` --tools-edit-modified-bg: ${t.colors.status.infoBackground};`),n.push(` --tools-edit-line-number: ${this.opacity(t.colors.surface.mutedForeground,.6)};`)),n}generateDefaultToolColors(e){let t=[];return t.push(` --tools-background: ${this.opacity(e.colors.surface.muted,.2)};`),t.push(` --tools-border: ${this.opacity(e.colors.interactive.border,.3)};`),t.push(` --tools-header-hover: ${this.opacity(e.colors.surface.muted,.3)};`),t.push(` --tools-icon: ${e.colors.surface.mutedForeground};`),t.push(` --tools-title: color-mix(in srgb, ${e.colors.surface.foreground} 50%, ${e.colors.surface.mutedForeground});`),t.push(` --tools-description: ${this.opacity(e.colors.surface.mutedForeground,.6)};`),t.push(` --tools-edit-added: ${e.colors.status.success};`),t.push(` --tools-edit-added-bg: ${this.addTransparency(this.removeTransparency(e.colors.status.successBackground),.15)};`),t.push(` --tools-edit-removed: ${e.colors.status.error};`),t.push(` --tools-edit-removed-bg: ${this.addTransparency(this.removeTransparency(e.colors.status.errorBackground),.15)};`),t.push(` --tools-edit-modified: ${e.colors.status.info};`),t.push(` --tools-edit-modified-bg: ${this.addTransparency(this.removeTransparency(e.colors.status.infoBackground),.15)};`),t.push(` --tools-edit-line-number: ${this.opacity(e.colors.surface.mutedForeground,.6)};`),t}generateConfigVariables(e){let t=[];return e?(e.fonts&&(e.fonts.sans&&(t.push(` --font-sans: ${e.fonts.sans};`),t.push(` --font-family-sans: ${e.fonts.sans};`)),e.fonts.mono&&(t.push(` --font-mono: ${e.fonts.mono};`),t.push(` --font-family-mono: ${e.fonts.mono};`)),e.fonts.heading&&t.push(` --font-heading: ${e.fonts.heading};`)),e.transitions&&(e.transitions.fast&&t.push(` --transition-fast: ${e.transitions.fast};`),e.transitions.normal&&t.push(` --transition-normal: ${e.transitions.normal};`),e.transitions.slow&&t.push(` --transition-slow: ${e.transitions.slow};`)),t):t}generateTypographyVariables(){let e=[],t=te()?Ie:ze;return e.push(` /* Semantic Typography Variables */`),e.push(` --ui-regular-font-weight: 400;`),e.push(` /* Markdown content - all markdown elements use same size */`),e.push(` --text-markdown: ${t.markdown};`),e.push(` /* Code content - all code elements use same size */`),e.push(` --text-code: ${t.code};`),e.push(` /* UI headers - dialog titles, panel headers */`),e.push(` --text-ui-header: ${t.uiHeader};`),e.push(` /* UI labels - buttons, menus, navigation */`),e.push(` --text-ui-label: ${t.uiLabel};`),e.push(` /* Metadata - timestamps, status, helper text */`),e.push(` --text-meta: ${t.meta};`),e.push(` /* Micro text - badges, shortcuts, indicators */`),e.push(` --text-micro: ${t.micro};`),e.push(` /* Heading line height and letter spacing */`),e.push(` --h1-line-height: 1.25rem;`),e.push(` --h2-line-height: 1.25rem;`),e.push(` --h3-line-height: 1.5rem;`),e.push(` --h4-line-height: 1.5rem;`),e.push(` --h5-line-height: 1.5rem;`),e.push(` --h6-line-height: 1.5rem;`),e.push(` --h1-letter-spacing: -0.025em;`),e.push(` --h2-letter-spacing: -0.02em;`),e.push(` --h3-letter-spacing: -0.015em;`),e.push(` --h4-letter-spacing: -0.01em;`),e.push(` --h5-letter-spacing: 0;`),e.push(` --h6-letter-spacing: 0.01em;`),e.push(` /* UI element line height and letter spacing */`),e.push(` --ui-button-line-height: 1.375rem;`),e.push(` --ui-button-letter-spacing: 0.02em;`),e.push(` --ui-button-font-weight: 500;`),e.push(` --ui-label-line-height: 1rem;`),e.push(` --ui-label-letter-spacing: 0.03em;`),e.push(` --ui-label-font-weight: 500;`),e.push(` --ui-caption-line-height: 1rem;`),e.push(` --ui-caption-letter-spacing: 0.025em;`),e.push(` --ui-caption-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` /* Markdown line height and letter spacing */`),e.push(` --markdown-body-line-height: 1.625;`),e.push(` --markdown-body-letter-spacing: 0;`),e.push(` --markdown-body-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --markdown-h1-line-height: 1.25rem;`),e.push(` --markdown-h1-letter-spacing: -0.025em;`),e.push(` --markdown-h2-line-height: 1.25rem;`),e.push(` --markdown-h2-letter-spacing: -0.02em;`),e.push(` --markdown-h3-line-height: 1.5rem;`),e.push(` --markdown-h3-letter-spacing: -0.015em;`),e.push(` --markdown-h4-line-height: 1.5rem;`),e.push(` --markdown-h4-letter-spacing: -0.01em;`),e.push(` --markdown-h5-line-height: 1.5rem;`),e.push(` --markdown-h5-letter-spacing: 0;`),e.push(` --markdown-h6-line-height: 1.5rem;`),e.push(` --markdown-h6-letter-spacing: 0.01em;`),e.push(` --markdown-list-line-height: 1.625;`),e.push(` --markdown-code-block-line-height: 1rem;`),e.push(` --ui-button-small-line-height: 1.25rem;`),e.push(` --ui-button-small-letter-spacing: 0.02em;`),e.push(` --ui-button-small-font-weight: 500;`),e.push(` --markdown-body-small-line-height: 1.5;`),e.push(` --markdown-body-small-letter-spacing: 0;`),e.push(` --markdown-body-small-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --ui-button-large-line-height: 1.5rem;`),e.push(` --ui-button-large-letter-spacing: 0.02em;`),e.push(` --ui-button-large-font-weight: 500;`),e.push(` --markdown-body-large-line-height: 1.625;`),e.push(` --markdown-body-large-letter-spacing: 0;`),e.push(` --markdown-body-large-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` /* Code line height and letter spacing */`),e.push(` --code-inline-line-height: 1rem;`),e.push(` --code-inline-letter-spacing: 0;`),e.push(` --code-inline-font-weight: 400;`),e.push(` --code-block-line-height: 1.4rem;`),e.push(` --code-block-letter-spacing: 0;`),e.push(` --code-block-font-weight: 400;`),e.push(` --code-line-numbers-line-height: 1.25rem;`),e.push(` --code-line-numbers-letter-spacing: 0;`),e.push(` --code-line-numbers-font-weight: 400;`),e.push(` /* Additional UI element line height and letter spacing */`),e.push(` --ui-badge-line-height: 1rem;`),e.push(` --ui-badge-letter-spacing: 0.025em;`),e.push(` --ui-badge-font-weight: 500;`),e.push(` --ui-tooltip-line-height: 1rem;`),e.push(` --ui-tooltip-letter-spacing: 0.025em;`),e.push(` --ui-tooltip-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --ui-input-line-height: 1.375rem;`),e.push(` --ui-input-letter-spacing: 0.02em;`),e.push(` --ui-input-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --ui-helper-text-line-height: 1rem;`),e.push(` --ui-helper-text-letter-spacing: 0.025em;`),e.push(` --ui-helper-text-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` /* Additional markdown line height and letter spacing */`),e.push(` --markdown-blockquote-line-height: 1.625;`),e.push(` --markdown-blockquote-letter-spacing: 0;`),e.push(` --markdown-blockquote-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --markdown-list-letter-spacing: 0;`),e.push(` --markdown-list-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --markdown-link-line-height: 1.625;`),e.push(` --markdown-link-letter-spacing: 0;`),e.push(` --markdown-link-font-weight: var(--ui-regular-font-weight, 400);`),e.push(` --markdown-code-line-height: 1.35;`),e.push(` --markdown-code-letter-spacing: 0;`),e.push(` --markdown-code-font-weight: 400;`),e.push(` --markdown-code-block-letter-spacing: 0;`),e.push(` --markdown-code-block-font-weight: 400;`),e}initializeInheritanceMap(){this.inheritanceMap.set(`header.background`,`surface.background`),this.inheritanceMap.set(`header.foreground`,`surface.foreground`),this.inheritanceMap.set(`header.logoTint`,`primary.base`),this.inheritanceMap.set(`header.divider`,`interactive.border`),this.inheritanceMap.set(`sidebar.background`,`surface.muted`),this.inheritanceMap.set(`sidebar.foreground`,`surface.mutedForeground`),this.inheritanceMap.set(`sidebar.hover`,`interactive.hover`),this.inheritanceMap.set(`sidebar.active`,`primary.base`),this.inheritanceMap.set(`sidebar.activeForeground`,`primary.foreground`)}opacity(e,t){return e.startsWith(`#`)?`${e}${Math.round(t*255).toString(16).padStart(2,`0`)}`:e.startsWith(`rgb`)?e.replace(`rgb`,`rgba`).replace(`)`,`, ${t})`):e}removeTransparency(e){return e.startsWith(`#`)?e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e:e.startsWith(`rgba`)?e.replace(`rgba`,`rgb`).replace(/,\s*[\d.]+\)$/,`)`):e}addTransparency(e,t){if(e.startsWith(`#`)){let n=e.slice(1);if(n.length===3)return`rgba(${parseInt(n[0]+n[0],16)}, ${parseInt(n[1]+n[1],16)}, ${parseInt(n[2]+n[2],16)}, ${t})`;if(n.length===6)return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${t})`}return e.startsWith(`rgb`)?e.replace(`rgb`,`rgba`).replace(`)`,`, ${t})`):e}darken(e,t){if(e.startsWith(`#`)){let n=parseInt(e.slice(1),16),r=Math.round(2.55*t),i=(n>>16)-r,a=(n>>8&255)-r,o=(n&255)-r;return`#`+(16777216+(i<255?i<0?0:i:255)*65536+(a<255?a<0?0:a:255)*256+(o<255?o<0?0:o:255)).toString(16).slice(1)}return e}lighten(e,t){if(e.startsWith(`#`)){let n=parseInt(e.slice(1),16),r=Math.round(2.55*t),i=(n>>16)+r,a=(n>>8&255)+r,o=(n&255)+r;return`#`+(16777216+(i<255?i<0?0:i:255)*65536+(a<255?a<0?0:a:255)*256+(o<255?o<0?0:o:255)).toString(16).slice(1)}return e}adjustHue(e,t){return this.lighten(e,t/10)}emphasize(e){return this.lighten(e,15)}kebabCase(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}},_i=()=>dn()?new URLSearchParams(window.location.search):null,vi=()=>typeof window>`u`||window.matchMedia(`(prefers-color-scheme: dark)`).matches,yi=()=>{let e=_i()?.get(`themeVariant`);return e===`dark`||e===`light`?e===`dark`:vi()},bi=e=>mn(e.currentTheme)?e.currentTheme:null,xi=e=>bi(e)?.metadata.variant??null,Si=Ct,Ci=Tt,wi=()=>{let e=_i()?.get(`currentTheme`);if(!e)return null;try{let t=JSON.parse(e);return mn(t)?t:null}catch{return null}},Ti=e=>wt(e===`dark`),Ei=typeof window<`u`?X.useLayoutEffect:X.useEffect,Di=()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.add(`yuri-theme-switching`);let t=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{e.classList.remove(`yuri-theme-switching`)})});return()=>{window.cancelAnimationFrame(t),e.classList.remove(`yuri-theme-switching`)}},Oi=e=>{let t=Si,n=Ci,r=`system`;if(typeof window<`u`){let e=_i(),i=e?.get(`themeMode`),a=e?.get(`lightThemeId`),o=e?.get(`darkThemeId`),s=ve(`themeMode`),c=ve(`lightThemeId`),l=ve(`darkThemeId`),u=ve(`useSystemTheme`),d=ve(`selectedThemeId`),f=ve(`selectedThemeVariant`);if(i===`light`||i===`dark`||i===`system`)r=i;else if(s===`light`||s===`dark`||s===`system`)r=s;else if(u!==null){if(u===`true`)r=`system`;else if(d){let e=St(d);e&&(r=e.metadata.variant===`dark`?`dark`:`light`,e.metadata.variant===`dark`?n=e.metadata.id:t=e.metadata.id)}}else(f===`light`||f===`dark`)&&(r=f);typeof a==`string`&&a.trim().length>0?t=a.trim():typeof c==`string`&&c.trim().length>0&&(t=c.trim()),typeof o==`string`&&o.trim().length>0?n=o.trim():typeof l==`string`&&l.trim().length>0&&(n=l.trim())}if(e){let r=St(e);r&&(r.metadata.variant===`light`?t=r.metadata.id:n=r.metadata.id)}return{themeMode:r,lightThemeId:t,darkThemeId:n}};function ki({children:e,defaultThemeId:t}){let n=(0,X.useMemo)(()=>new gi,[]),[r,i]=(0,X.useState)(()=>Oi(t)),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(()=>yi()),[u,d]=(0,X.useState)([]),[f,m]=(0,X.useState)([]),h=U(e=>(m(e),()=>{m(t=>t===e?[]:t)})),[_]=(0,X.useState)(()=>wi()),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(()=>typeof window>`u`||!te()?null:window.__YURI_VSCODE_THEME__||null),E=(0,X.useMemo)(()=>te(),[]),D=(0,X.useMemo)(()=>v(),[]),ee=(0,X.useMemo)(()=>y(),[]),O=(0,X.useMemo)(()=>typeof window>`u`?!1:_i()!==null,[]),k=(0,X.useMemo)(()=>{let e=[],t=new Set,n=n=>{let r=n.metadata.id;t.has(r)||(t.add(r),e.push(mi(n)))};return E&&w&&n(w),b&&n(b),_&&n(_),u.forEach(n),xt.forEach(n),e},[u,_,b,E,w]),ne=(0,X.useMemo)(()=>e=>k.find(t=>t.metadata.id===e),[k]),A=(0,X.useMemo)(()=>(e,t)=>{let n=ne(e);return n&&n.metadata.variant===t?n:k.find(e=>e.metadata.variant===t)??Ti(t)},[k,ne]),j=(0,X.useMemo)(()=>E&&w?ne(w.metadata.id)??mi(w):r.themeMode===`light`?A(r.lightThemeId,`light`):r.themeMode===`dark`||s?A(r.darkThemeId,`dark`):A(r.lightThemeId,`light`),[A,ne,E,r,s,w]),M=(0,X.useMemo)(()=>{if(E||O)return j;let e=f.find(e=>e.metadata.variant===j.metadata.variant);return e?mi(e):j},[E,O,f,j]),re=U(async()=>{if(!(typeof window>`u`||E)){C(!0);try{let e=await g(`/api/config/themes`,{method:`GET`,credentials:D?`omit`:`include`,headers:{Accept:`application/json`}});if(e.status===401||!e.ok)return;let t=await e.json(),n=(Array.isArray(t?.themes)?t.themes:[]).filter(mn);d(n)}catch{}finally{C(!1)}}});(0,X.useEffect)(()=>{re()},[re]),(0,X.useEffect)(()=>{if(!E)return;let e=e=>{T(e)},t=t=>{let n=t.detail;n?.theme&&e(n.theme)},n=window.__YURI_VSCODE_THEME__;return n&&e(n),window.addEventListener(`yuri:vscode-theme`,t),()=>window.removeEventListener(`yuri:vscode-theme`,t)},[E]);let ie=U(e=>{if(typeof document>`u`)return;let t=document.documentElement.hasAttribute(`data-yuri-vibrancy`)||window.__YURI_ELECTRON__?.macVibrancy===!0?`transparent`:e.colors.surface.background;document.body.style.backgroundColor=t;let n=document.querySelector(`meta[name="theme-color"]`);n||(n=document.createElement(`meta`),n.setAttribute(`name`,`theme-color`),document.head.appendChild(n)),n.setAttribute(`content`,t);let r=e.metadata.variant===`dark`?`(prefers-color-scheme: dark)`:`(prefers-color-scheme: light)`,i=document.querySelector(`meta[name="theme-color"][media="${r}"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`media`,r),document.head.appendChild(i)),i.setAttribute(`content`,t)}),N=U(e=>{typeof document>`u`||document.documentElement.classList.toggle(`vscode-runtime`,e)});Ei(()=>{if(typeof window>`u`)return;let e=Di();n.apply(M),N(E),ie(M);let t=document.documentElement;return t.classList.remove(`light`,`dark`),t.classList.add(M.metadata.variant),e},[N,n,M,E,ie]),(0,X.useEffect)(()=>{if(r.themeMode!==`system`||typeof window>`u`||O)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=e=>{l(e.matches)};return l(e.matches),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[r.themeMode,O]),(0,X.useEffect)(()=>{if(O||typeof window>`u`)return;_e(`themeMode`,r.themeMode),_e(`lightThemeId`,r.lightThemeId),_e(`darkThemeId`,r.darkThemeId),_e(`useSystemTheme`,String(r.themeMode===`system`)),_e(`selectedThemeId`,j.metadata.id),_e(`selectedThemeVariant`,j.metadata.variant===`light`?`light`:`dark`);let e=A(r.lightThemeId,`light`),t=A(r.darkThemeId,`dark`);_e(`splashBgLight`,e.colors.surface.background),_e(`splashFgLight`,e.colors.surface.foreground),_e(`splashBgDark`,t.colors.surface.background),_e(`splashFgDark`,t.colors.surface.foreground),D&&(localStorage.setItem(`themeMode`,r.themeMode),localStorage.setItem(`useSystemTheme`,String(r.themeMode===`system`)),localStorage.setItem(`splashBgLight`,e.colors.surface.background),localStorage.setItem(`splashFgLight`,e.colors.surface.foreground),localStorage.setItem(`splashBgDark`,t.colors.surface.background),localStorage.setItem(`splashFgDark`,t.colors.surface.foreground))},[r,j,A,D,O]),(0,X.useEffect)(()=>{if(typeof window>`u`||O)return;let e=e=>{e.storageArea===window.localStorage&&(Se(e.key,`themeMode`)||Se(e.key,`lightThemeId`)||Se(e.key,`darkThemeId`))&&i(e=>{let t=ve(`themeMode`),n=t===`light`||t===`dark`||t===`system`?t:e.themeMode,r=ve(`lightThemeId`),i=typeof r==`string`&&r.trim().length>0?r.trim():e.lightThemeId,a=ve(`darkThemeId`),o=typeof a==`string`&&a.trim().length>0?a.trim():e.darkThemeId;return n===e.themeMode&&i===e.lightThemeId&&o===e.darkThemeId?e:{themeMode:n,lightThemeId:i,darkThemeId:o}})};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[O]);let P=U(e=>{let t=e.themeMode,n=e.lightThemeId,r=e.darkThemeId,a=xi(e),o=bi(e);if(t!==`light`&&t!==`dark`&&t!==`system`||typeof n!=`string`||typeof r!=`string`)return;let s=n.trim(),c=r.trim();!s||!c||(Di(),(0,ui.flushSync)(()=>{O&&o&&x(o),t===`system`&&a&&l(a===`dark`),i(e=>e.themeMode===t&&e.lightThemeId===s&&e.darkThemeId===c?e:{themeMode:t,lightThemeId:s,darkThemeId:c})}))});(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=window;return e.__yuriApplyThemeSync=P,()=>{e.__yuriApplyThemeSync===P&&delete e.__yuriApplyThemeSync}},[P]),(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(e.origin!==window.location.origin)return;let t=e.data;t?.type!==`yuri:theme-sync`||!t.payload||P(t.payload)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[P]),(0,X.useEffect)(()=>{if(O||!a)return;let e=A(r.lightThemeId,`light`),t=A(r.darkThemeId,`dark`);ge({themeId:j.metadata.id,themeVariant:j.metadata.variant===`light`?`light`:`dark`,useSystemTheme:r.themeMode===`system`,lightThemeId:r.lightThemeId,darkThemeId:r.darkThemeId,splashBgLight:e.colors.surface.background,splashFgLight:e.colors.surface.foreground,splashBgDark:t.colors.surface.background,splashFgDark:t.colors.surface.foreground})},[j.metadata.id,j.metadata.variant,A,r.themeMode,r.lightThemeId,r.darkThemeId,O,a]),(0,X.useEffect)(()=>{O||!ee||(async()=>{await ot(r.themeMode,M.metadata.variant)})()},[M.metadata.variant,ee,r.themeMode,O]),(0,X.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;t&&(i(e=>{let n=e.themeMode;t.useSystemTheme===!0?n=`system`:t.useSystemTheme===!1&&(t.themeVariant===`dark`||t.themeVariant===`light`)&&(n=t.themeVariant);let r=e.lightThemeId;typeof t.lightThemeId==`string`&&t.lightThemeId.length>0&&(r=t.lightThemeId.trim());let i=e.darkThemeId;return typeof t.darkThemeId==`string`&&t.darkThemeId.length>0&&(i=t.darkThemeId.trim()),n===e.themeMode&&r===e.lightThemeId&&i===e.darkThemeId?e:{themeMode:n,lightThemeId:r,darkThemeId:i}}),o(!0))};return window.addEventListener(`yuri:settings-synced`,e),()=>window.removeEventListener(`yuri:settings-synced`,e)},[]),(0,X.useEffect)(()=>{if(!(O||typeof window>`u`))return c(e=>{p(e)&&(i(e=>{let t=ve(`themeMode`),n=t===`light`||t===`dark`||t===`system`?t:e.themeMode,r=ve(`lightThemeId`),i=typeof r==`string`&&r.trim().length>0?r.trim():e.lightThemeId,a=ve(`darkThemeId`),o=typeof a==`string`&&a.trim().length>0?a.trim():e.darkThemeId;return n===e.themeMode&&i===e.lightThemeId&&o===e.darkThemeId?e:{themeMode:n,lightThemeId:i,darkThemeId:o}}),o(!1))})},[O]);let ae=U(e=>{let t=k.find(t=>t.metadata.id===e);t&&i(e=>t.metadata.variant===`dark`?e.darkThemeId===t.metadata.id&&e.themeMode===`dark`?e:{...e,darkThemeId:t.metadata.id,themeMode:`dark`}:e.lightThemeId===t.metadata.id&&e.themeMode===`light`?e:{...e,lightThemeId:t.metadata.id,themeMode:`light`})}),oe=U(e=>{i(t=>t.themeMode===e?t:{...t,themeMode:e})}),F=U(e=>{if(e){i(e=>e.themeMode===`system`?e:{...e,themeMode:`system`});return}let t=M.metadata.variant===`dark`?`dark`:`light`;i(e=>e.themeMode===t?e:{...e,themeMode:t})}),I=U(e=>{let t=k.find(t=>t.metadata.id===e&&t.metadata.variant===`light`);t&&i(e=>e.lightThemeId===t.metadata.id?e:{...e,lightThemeId:t.metadata.id})}),L=U(e=>{let t=k.find(t=>t.metadata.id===e&&t.metadata.variant===`dark`);t&&i(e=>e.darkThemeId===t.metadata.id?e:{...e,darkThemeId:t.metadata.id})}),se=(0,X.useMemo)(()=>({currentTheme:M,availableThemes:k,registerPluginThemes:h,setTheme:ae,customThemesLoading:S,reloadCustomThemes:re,isSystemPreference:r.themeMode===`system`,setSystemPreference:F,themeMode:r.themeMode,setThemeMode:oe,lightThemeId:r.lightThemeId,darkThemeId:r.darkThemeId,setLightThemePreference:I,setDarkThemePreference:L}),[k,h,M,S,r.darkThemeId,r.lightThemeId,r.themeMode,re,L,I,F,ae,oe]);return(0,Q.jsx)(vt.Provider,{value:se,children:e})}var Ai=!1,ji=()=>{if(Ai||typeof window>`u`)return;Ai=!0;let e={showReasoningTraces:W.getState().showReasoningTraces,sessionTitleRefreshEnabled:W.getState().sessionTitleRefreshEnabled,sessionGoalEnabled:W.getState().sessionGoalEnabled,collapsibleThinkingBlocks:W.getState().collapsibleThinkingBlocks,showDeletionDialog:W.getState().showDeletionDialog,nativeNotificationsEnabled:W.getState().nativeNotificationsEnabled,notificationMode:W.getState().notificationMode,notifyOnSubtasks:W.getState().notifyOnSubtasks,notifyOnCompletion:W.getState().notifyOnCompletion,notifyOnError:W.getState().notifyOnError,notifyOnQuestion:W.getState().notifyOnQuestion,notifyOnPermission:W.getState().notifyOnPermission,notifyOnScheduledTasks:W.getState().notifyOnScheduledTasks,notifyOnAssistants:W.getState().notifyOnAssistants,notifyOnGoals:W.getState().notifyOnGoals,notificationTemplates:W.getState().notificationTemplates,summarizeLastMessage:W.getState().summarizeLastMessage,summaryThreshold:W.getState().summaryThreshold,summaryLength:W.getState().summaryLength,maxLastMessageLength:W.getState().maxLastMessageLength,autoDeleteEnabled:W.getState().autoDeleteEnabled,autoDeleteAfterDays:W.getState().autoDeleteAfterDays,sessionRetentionAction:W.getState().sessionRetentionAction,fontSize:W.getState().fontSize,terminalFontSize:W.getState().terminalFontSize,editorFontSize:W.getState().editorFontSize,uiFont:W.getState().uiFont,monoFont:W.getState().monoFont,padding:W.getState().padding,cornerRadius:W.getState().cornerRadius,inputBarOffset:W.getState().inputBarOffset,mobileKeyboardMode:W.getState().mobileKeyboardMode,diffLayoutPreference:W.getState().diffLayoutPreference,gitChangesViewMode:W.getState().gitChangesViewMode},t=null,n=null,r=()=>{let e=t;t=null,n=null,e&&Object.keys(e).length>0&&ge(e)},i=e=>{t={...t??{},...e},!n&&(n=setTimeout(r,150))};W.subscribe(t=>{let n={showReasoningTraces:t.showReasoningTraces,sessionTitleRefreshEnabled:t.sessionTitleRefreshEnabled,sessionGoalEnabled:t.sessionGoalEnabled,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks,showDeletionDialog:t.showDeletionDialog,nativeNotificationsEnabled:t.nativeNotificationsEnabled,notificationMode:t.notificationMode,notifyOnSubtasks:t.notifyOnSubtasks,notifyOnCompletion:t.notifyOnCompletion,notifyOnError:t.notifyOnError,notifyOnQuestion:t.notifyOnQuestion,notifyOnPermission:t.notifyOnPermission,notifyOnScheduledTasks:t.notifyOnScheduledTasks,notifyOnAssistants:t.notifyOnAssistants,notifyOnGoals:t.notifyOnGoals,notificationTemplates:t.notificationTemplates,summarizeLastMessage:t.summarizeLastMessage,summaryThreshold:t.summaryThreshold,summaryLength:t.summaryLength,maxLastMessageLength:t.maxLastMessageLength,autoDeleteEnabled:t.autoDeleteEnabled,autoDeleteAfterDays:t.autoDeleteAfterDays,sessionRetentionAction:t.sessionRetentionAction,fontSize:t.fontSize,terminalFontSize:t.terminalFontSize,editorFontSize:t.editorFontSize,uiFont:t.uiFont,monoFont:t.monoFont,padding:t.padding,cornerRadius:t.cornerRadius,inputBarOffset:t.inputBarOffset,mobileKeyboardMode:t.mobileKeyboardMode,diffLayoutPreference:t.diffLayoutPreference,gitChangesViewMode:t.gitChangesViewMode},r={};n.showReasoningTraces!==e.showReasoningTraces&&(r.showReasoningTraces=n.showReasoningTraces),n.sessionTitleRefreshEnabled!==e.sessionTitleRefreshEnabled&&(r.sessionTitleRefreshEnabled=n.sessionTitleRefreshEnabled),n.sessionGoalEnabled!==e.sessionGoalEnabled&&(r.sessionGoalEnabled=n.sessionGoalEnabled),n.collapsibleThinkingBlocks!==e.collapsibleThinkingBlocks&&(r.collapsibleThinkingBlocks=n.collapsibleThinkingBlocks),n.showDeletionDialog!==e.showDeletionDialog&&(r.showDeletionDialog=n.showDeletionDialog),n.nativeNotificationsEnabled!==e.nativeNotificationsEnabled&&(r.nativeNotificationsEnabled=n.nativeNotificationsEnabled),n.notificationMode!==e.notificationMode&&(r.notificationMode=n.notificationMode),n.notifyOnSubtasks!==e.notifyOnSubtasks&&(r.notifyOnSubtasks=n.notifyOnSubtasks),n.notifyOnCompletion!==e.notifyOnCompletion&&(r.notifyOnCompletion=n.notifyOnCompletion),n.notifyOnError!==e.notifyOnError&&(r.notifyOnError=n.notifyOnError),n.notifyOnQuestion!==e.notifyOnQuestion&&(r.notifyOnQuestion=n.notifyOnQuestion),n.notifyOnPermission!==e.notifyOnPermission&&(r.notifyOnPermission=n.notifyOnPermission),n.notifyOnScheduledTasks!==e.notifyOnScheduledTasks&&(r.notifyOnScheduledTasks=n.notifyOnScheduledTasks),n.notifyOnAssistants!==e.notifyOnAssistants&&(r.notifyOnAssistants=n.notifyOnAssistants),n.notifyOnGoals!==e.notifyOnGoals&&(r.notifyOnGoals=n.notifyOnGoals),JSON.stringify(n.notificationTemplates)!==JSON.stringify(e.notificationTemplates)&&(r.notificationTemplates=n.notificationTemplates),n.summarizeLastMessage!==e.summarizeLastMessage&&(r.summarizeLastMessage=n.summarizeLastMessage),n.summaryThreshold!==e.summaryThreshold&&(r.summaryThreshold=n.summaryThreshold),n.summaryLength!==e.summaryLength&&(r.summaryLength=n.summaryLength),n.maxLastMessageLength!==e.maxLastMessageLength&&(r.maxLastMessageLength=n.maxLastMessageLength),n.autoDeleteEnabled!==e.autoDeleteEnabled&&(r.autoDeleteEnabled=n.autoDeleteEnabled),n.autoDeleteAfterDays!==e.autoDeleteAfterDays&&(r.autoDeleteAfterDays=n.autoDeleteAfterDays),n.sessionRetentionAction!==e.sessionRetentionAction&&(r.sessionRetentionAction=n.sessionRetentionAction),n.fontSize!==e.fontSize&&(r.fontSize=n.fontSize),n.terminalFontSize!==e.terminalFontSize&&(r.terminalFontSize=n.terminalFontSize),n.editorFontSize!==e.editorFontSize&&(r.editorFontSize=n.editorFontSize),n.uiFont!==e.uiFont&&(r.uiFont=n.uiFont),n.monoFont!==e.monoFont&&(r.monoFont=n.monoFont),n.padding!==e.padding&&(r.padding=n.padding),n.cornerRadius!==e.cornerRadius&&(r.cornerRadius=n.cornerRadius),n.inputBarOffset!==e.inputBarOffset&&(r.inputBarOffset=n.inputBarOffset),n.mobileKeyboardMode!==e.mobileKeyboardMode&&(r.mobileKeyboardMode=n.mobileKeyboardMode),n.diffLayoutPreference!==e.diffLayoutPreference&&(r.diffLayoutPreference=n.diffLayoutPreference),n.gitChangesViewMode!==e.gitChangesViewMode&&(r.gitChangesViewMode=n.gitChangesViewMode),e=n,Object.keys(r).length>0&&i(r)})},Mi=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.providerID!==t[n]?.providerID||e[n]?.modelID!==t[n]?.modelID||e[n]?.variant!==t[n]?.variant)return!1;return!0},Ni=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.providerID!==t[n]?.providerID||e[n]?.modelID!==t[n]?.modelID)return!1;return!0},Pi=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0},Fi=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&Pi(e[n],t[n]))},Ii=()=>{let e=W.getState();return{favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,providerOrder:e.providerOrder,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts}},Li=(e,t)=>Mi(e.favoriteModels,t.favoriteModels)&&Ni(e.hiddenModels,t.hiddenModels)&&Pi(e.collapsedModelProviders,t.collapsedModelProviders)&&Pi(e.providerOrder,t.providerOrder)&&Mi(e.recentModels,t.recentModels)&&Pi(e.recentAgents,t.recentAgents)&&Fi(e.recentEfforts,t.recentEfforts),Ri=e=>({favoriteModels:e.favoriteModels.slice(),hiddenModels:e.hiddenModels.slice(),collapsedModelProviders:e.collapsedModelProviders.slice(),providerOrder:e.providerOrder.slice(),recentModels:e.recentModels.slice(),recentAgents:e.recentAgents.slice(),recentEfforts:Object.fromEntries(Object.entries(e.recentEfforts).map(([e,t])=>[e,t.slice()]))}),zi=()=>{if(typeof window>`u`)return()=>{};let e=null,t=null,n=!1,r=()=>{e=null;let n=Ii();t&&Li(t,n)||(t=Ri(n),ge(n).catch(()=>{}))},i=()=>{if(!n){n=!0;return}e!==null&&window.clearTimeout(e),e=window.setTimeout(r,1200)},a=W.subscribe((e,t)=>{Li({favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,providerOrder:e.providerOrder,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts},{favoriteModels:t.favoriteModels,hiddenModels:t.hiddenModels,collapsedModelProviders:t.collapsedModelProviders,providerOrder:t.providerOrder,recentModels:t.recentModels,recentAgents:t.recentAgents,recentEfforts:t.recentEfforts})||i()});return()=>{a(),e!==null&&window.clearTimeout(e)}},Bi=!1,Vi=`yuri-typography-base`,Hi=()=>{if(typeof document>`u`)return;let e=`:root {\n${Object.entries(ze).map(([e,t])=>` --text-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}: ${t};`).join(`
4
+ `)}\n}\n`,t=document.getElementById(Vi);if(t){t.textContent=e;return}let n=document.createElement(`style`);n.id=Vi,n.textContent=e,document.head.appendChild(n)},Ui=()=>{Bi||typeof window>`u`||(Bi=!0,Hi())};function Wi(e){let t=(0,Z.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0],(0,X.useEffect)(Gi,r);let i;return t[1]===n?i=t[2]:(i=(0,Q.jsx)(Te,{client:Ae,children:n}),t[1]=n,t[2]=i),i}function Gi(){return ke(Ae)}var Ki=15,qi=2e3,Ji=40,Yi=2e4,Xi=e=>{let t=G(e=>e.isConnected),n=G(e=>e.providers.length),r=G(e=>e.agents.length),i=G(e=>e.activeDirectoryKey),a=G(e=>e.refreshMissingCatalogs),o=e.enabled&&t&&(n===0||r===0),s=X.useRef(0),c=X.useRef(!1),[l,u]=X.useState(`fast`),d=e.source,f=U(async()=>{if(!o||c.current||l===`done`)return;let e=l===`fast`?Ki:Ji;if(s.current>=e){if(l===`fast`){s.current=0,u(`slow`);return}u(`done`);return}let t=G.getState();if(!(t.providers.length>0&&t.agents.length>0)){c.current=!0,s.current+=1;try{await a({source:d})}catch{}finally{c.current=!1}}});X.useEffect(()=>{s.current=0,c.current=!1,u(`fast`),o&&f()},[o,i]),Ne(f,!o||l===`done`?null:l===`slow`?Yi:qi)},Zi=40,Qi=20971520,$i=new Map,ea=0;function ta(e){return e.length*2}function na(e,t){let n=$i.get(e);n!==void 0&&(ea-=n),$i.delete(e),$i.set(e,t),ea+=t}function ra(e,t){let n=$i.get(e);(n!==void 0||t!==void 0)&&na(e,t??n??0)}function ia(e){let t=$i.get(e);t!==void 0&&($i.delete(e),ea-=t)}function aa(e,t){let n=e??new Set;for(;$i.size>Zi||ea>Qi;){let e=$i.keys().next().value;if(!e)return;if(n.has(e)){if(ra(e),$i.size<=n.size)return;continue}ia(e),t(e)}}function oa(e,t){na(e,t)}function sa(e){ia(e)}function ca(e,t){ra(e,t)}function la(e){let t=new Map,n=e=>{t.delete(e),sa(e)},r=e=>{let r=e.endsWith(`/`)?e:`${e}/`;for(let i of t.keys())(i===e||i.startsWith(r))&&n(i)},i=(e,t)=>t.isFile?e.mtimeMs!==void 0&&t.mtimeMs!==void 0?e.mtimeMs===t.mtimeMs&&e.size===t.size:e.size===t.size:!1,a=(e,r,i)=>{if(r.exists===!1)return n(e),r;let a=ta(r.content);return t.set(e,{...r,size:i?.isFile?i.size:void 0,mtimeMs:i?.isFile?i.mtimeMs:void 0}),oa(e,a),aa(new Set,e=>{t.delete(e)}),r},o=async(t,n)=>{let r=await e.statFile?.(t,n).catch(()=>null),i=await e.readFile(t,n),o=await e.statFile?.(t,n).catch(()=>null);if(r&&o&&r.isFile&&o.isFile){if(r.size===o.size&&r.mtimeMs===o.mtimeMs)return a(t,i,o);let s=await e.statFile?.(t,n).catch(()=>null),c=await e.readFile(t,n),l=await e.statFile?.(t,n).catch(()=>null);return s&&l&&s.isFile&&l.isFile&&s.size===l.size&&(s.mtimeMs,l.mtimeMs),a(t,c,l)}return a(t,i,o??r)},s=e.readFile?async(r,a)=>{if(a?.allowOutsideWorkspace)return o(r,a);let s=t.get(r);if(s){if(a?.optional&&(s.exists===void 0||!e.statFile))return o(r,a);if(e.statFile){let t=await e.statFile(r,a).catch(()=>(n(r),null));if(!t||!i(s,t))return n(r),o(r,a)}return ca(r),{content:s.content,path:s.path,exists:s.exists}}return o(r,a)}:void 0,c=e.writeFile?async(t,r)=>(n(t),e.writeFile(t,r)):void 0,l=e.delete?async t=>(r(t),e.delete(t)):void 0,u=e.rename?async(t,n)=>(r(t),r(n),e.rename(t,n)):void 0;return{...e,readFile:s,writeFile:c,delete:l,rename:u}}function ua(e){let t=(0,Z.c)(8),{apis:n,children:r}=e,i;t[0]===n.files?i=t[1]:(i=la(n.files),t[0]=n.files,t[1]=i);let a;t[2]!==n||t[3]!==i?(a={...n,files:i},t[2]=n,t[3]=i,t[4]=a):a=t[4];let o=a,s;return t[5]!==o||t[6]!==r?(s=(0,Q.jsx)(je.Provider,{value:o,children:r}),t[5]=o,t[6]=r,t[7]=s):s=t[7],s}var da=`var(--yuri-toast-shadow, inset 0 1px 0 0 rgba(255,255,255,0.12), inset 0 0 0 1px rgba(255,255,255,0.08), 0 0 0 1px rgba(0,0,0,0.36), 0 1px 1px -0.5px rgba(0,0,0,0.22), 0 3px 3px -1.5px rgba(0,0,0,0.20), 0 6px 6px -3px rgba(0,0,0,0.16))`,fa=`var(--yuri-toast-shadow, inset 0 1px 0 0 rgba(255,255,255,0.8), inset 0 0 0 1px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.10), 0 1px 2px -0.5px rgba(0,0,0,0.08), 0 4px 8px -2px rgba(0,0,0,0.08), 0 12px 20px -4px rgba(0,0,0,0.08))`,pa={success:(0,Q.jsx)(J,{name:`checkbox-circle`,weight:`medium`,className:`yuri-toast-status-icon size-5`}),info:(0,Q.jsx)(J,{name:`information`,weight:`medium`,className:`yuri-toast-status-icon size-5`}),warning:(0,Q.jsx)(J,{name:`error-warning`,weight:`medium`,className:`yuri-toast-status-icon size-5`}),error:(0,Q.jsx)(J,{name:`close-circle`,weight:`medium`,className:`yuri-toast-status-icon size-5`}),loading:(0,Q.jsx)(J,{name:`loader-4`,weight:`medium`,className:`yuri-toast-status-icon size-5 animate-spin motion-reduce:animate-none`})};function ma(){let e=(0,Z.c)(2),t=ha,[n,r]=X.useState(t),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=()=>r(t()),n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),e(),()=>n.disconnect()},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),X.useEffect(i,a),n}function ha(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)}function ga(e,t){let n=(0,Z.c)(4),r,i;n[0]!==t||n[1]!==e?(r=()=>{let n=t.current;if(!n)return;let r=document.createElement(`div`).style;r.setProperty(`box-shadow`,e,`important`),r.setProperty(`outline`,`none`,`important`);let i=t=>{(t.style.getPropertyValue(`box-shadow`)!==r.getPropertyValue(`box-shadow`)||t.style.getPropertyPriority(`box-shadow`)!==`important`)&&t.style.setProperty(`box-shadow`,e,`important`),(t.style.getPropertyValue(`outline`)!==r.getPropertyValue(`outline`)||t.style.getPropertyPriority(`outline`)!==`important`)&&t.style.setProperty(`outline`,`none`,`important`),t.getAttribute(`tabindex`)===`0`&&t.setAttribute(`tabindex`,`-1`)};n.querySelectorAll(`[data-sonner-toast]`).forEach(i);let a=new MutationObserver(e=>{for(let t of e)t.type===`attributes`&&t.target instanceof HTMLElement&&t.target.matches(`[data-sonner-toast]`)&&i(t.target),t.addedNodes.forEach(e=>{e instanceof HTMLElement&&(e.matches?.(`[data-sonner-toast]`)&&i(e),e.querySelectorAll?.(`[data-sonner-toast]`).forEach(i))})});return a.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`tabindex`,`data-expanded`,`data-swiping`]}),()=>a.disconnect()},i=[e,t],n[0]=t,n[1]=e,n[2]=r,n[3]=i):(r=n[2],i=n[3]),X.useEffect(r,i)}var _a=e=>{let t=(0,Z.c)(8),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r=ma(),i=r?da:fa,a=X.useRef(null);ga(i,a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={display:`contents`},t[2]=o):o=t[2];let s=r?`dark`:`light`,c,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c={classNames:{toast:`group/toast toast !flex !min-w-[min(var(--width),calc(100vw-2rem))] !max-w-[calc(100vw-2rem)] !items-center !rounded-[var(--yuri-toast-radius,var(--radius-xl))] !border-0 !px-[var(--yuri-toast-padding-x,0.875rem)] !py-[var(--yuri-toast-padding-y,0.75rem)] !gap-[var(--yuri-toast-gap,0.625rem)] !text-foreground`,content:`!min-w-0 !flex-1 !text-left`,title:`typography-ui-label !font-medium !text-foreground`,description:`typography-meta !text-muted-foreground !mt-0`,actionButton:`!ms-0 !me-0 !shrink-0 !rounded-[var(--radius-md)] !text-[var(--yuri-toast-action-foreground,var(--foreground))] !px-2 !py-1 typography-meta !font-medium transition-colors`,cancelButton:`!ms-0 !me-0 !shrink-0 !rounded-[var(--radius-md)] !text-[var(--yuri-toast-cancel-foreground,var(--foreground))] !px-2 !py-1 typography-meta !font-medium transition-colors`,closeButton:`!rounded-[var(--radius-md)] !bg-[var(--interactive-hover)] !text-foreground hover:!bg-[var(--interactive-active)]`,icon:`!shrink-0 !text-[var(--yuri-toast-status-color,var(--muted-foreground))]`,success:`[&_[data-icon]]:!text-[var(--status-success)]`,error:`[&_[data-icon]]:!text-[var(--status-error)]`,warning:`[&_[data-icon]]:!text-[var(--status-warning)]`,info:`[&_[data-icon]]:!text-[var(--status-info)]`},style:{borderRadius:`var(--radius-xl)`,backgroundColor:`var(--yuri-toast-background, var(--surface-elevated))`}},l={"--normal-bg":`var(--yuri-toast-background, var(--surface-elevated))`,"--normal-text":`var(--foreground)`,"--normal-border":`transparent`,"--error-bg":`var(--yuri-toast-background, var(--surface-elevated))`,"--error-text":`var(--foreground)`,"--error-border":`transparent`,"--success-bg":`var(--yuri-toast-background, var(--surface-elevated))`,"--success-text":`var(--foreground)`,"--success-border":`transparent`,"--warning-bg":`var(--yuri-toast-background, var(--surface-elevated))`,"--warning-text":`var(--foreground)`,"--warning-border":`transparent`,"--info-bg":`var(--yuri-toast-background, var(--surface-elevated))`,"--info-text":`var(--foreground)`,"--info-border":`transparent`},t[3]=c,t[4]=l):(c=t[3],l=t[4]);let u;return t[5]!==n||t[6]!==s?(u=(0,Q.jsx)(`div`,{ref:a,style:o,children:(0,Q.jsx)(Be,{theme:s,className:`toaster group`,position:`bottom-right`,closeButton:!1,duration:3500,icons:pa,toastOptions:c,style:l,...n})}),t[5]=n,t[6]=s,t[7]=u):u=t[7],u},va=2e4,ya=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus()?`visible`:`hidden`,ba=e=>{if(!_()&&!w())return;let t=O();t?.push?.setVisibility&&t.push.setVisibility({visible:e,platform:E()})},xa=e=>{let t=e?.enabled??!0;X.useEffect(()=>{if(!t||!_()&&!w()||typeof window>`u`)return;if(w()){let e=!0,t=!1,n=null,r=()=>ba(e);Pe(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])).then(async({App:i})=>{if(t)return;let a=await i.getState().catch(()=>null);a&&(e=a.isActive===!0),r();let o=await i.addListener(`appStateChange`,({isActive:t})=>{e=t===!0,r()});if(t){o.remove();return}n=()=>void o.remove()}).catch(()=>void 0);let i=window.setInterval(()=>{e&&ba(!0)},va);return()=>{t=!0,window.clearInterval(i),n?.()}}if(typeof document>`u`)return;let e=()=>{ba(ya()===`visible`)},n=()=>{ya()===`visible`&&ba(!0)},r=()=>{ba(!1)};e();let i=window.setInterval(n,va);return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,r),window.addEventListener(`pageshow`,e),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),()=>{window.clearInterval(i),document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,r),window.removeEventListener(`pageshow`,e),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e)}},[t])},Sa=`Yuri`,Ca=()=>`${m()}\0${u()}`,wa=e=>Ee({queryKey:[`desktop-window-hosts`,e],queryFn:async({signal:e})=>{let t=await j();return e.throwIfAborted(),t.hosts}}),Ta=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``).split(`/`).filter(Boolean);return t[t.length-1]??``},Ea=(e,t)=>[e,t,Sa].filter(e=>typeof e==`string`&&e.trim().length>0).join(` | `),Da=()=>{let e=(0,Z.c)(15),{t}=ct(),n=We(Oa),r=X.useSyncExternalStore(c,Ca,Ca),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=y()&&!v(),e[0]=i):i=e[0];let a=i,o;e[1]===r?o=e[2]:(o=wa(r),e[1]=r,e[2]=o);let s;e[3]===o?s=e[4]:(s={...o,enabled:a},e[3]=o,e[4]=s);let{data:l}=De(s),u;if(e[5]===Symbol.for(`react.memo_cache_sentinel`)){let t=m();u=t.startsWith(`host:`)?t.slice(5):null,e[5]=u}else u=e[5];let d=u,f;if(e[6]!==l||e[7]!==t){let n=h(),r=l?.find(e=>d?e.id===d:!!(n&&P(n,N(e))));f=a?r?.label?.trim()?F(r.label.trim()):t(`desktopHostSwitcher.title`):null,e[6]=l,e[7]=t,e[8]=f}else f=e[8];let p=f,g;e[9]!==p||e[10]!==n?(g=Ea(n,p),e[9]=p,e[10]=n,e[11]=g):g=e[11];let _=g,b,x;e[12]===_?(b=e[13],x=e[14]):(b=()=>{typeof document<`u`&&(document.title=_),y()&&(async()=>{try{await st(_)}catch{return}})()},x=[_],e[12]=_,e[13]=b,e[14]=x),X.useEffect(b,x)};function Oa(e){if(!e.activeProjectId)return null;let t=e.projects.find(t=>t.id===e.activeProjectId);return t&&Ta(t.path)||null}var ka=e=>{let t=[];return e.hideGit||t.push(`git`),t.push(`files`),e.showBrowser&&t.push(`browser`),t},Aa=()=>{let e=K.getState().currentSessionId;if(!e)return``;let t=I().find(t=>t.id===e);return typeof t?.directory==`string`?t.directory:``},ja=async(e,t=6e3)=>{let n=new AbortController,r=setTimeout(()=>n.abort(),t),i=Date.now();try{let t=await g(e,{method:`GET`,headers:{Accept:`application/json`},signal:n.signal}),r=Date.now()-i,a=t.headers.get(`content-type`)||``,o=a.toLowerCase(),s=o.includes(`json`)&&!o.includes(`text/html`),c=``;if(s){let e=await t.json().catch(()=>null);if(Array.isArray(e))c=`json[array] len=${e.length}`;else if(e&&typeof e==`object`){let t=Object.keys(e).slice(0,8);c=`json[object] keys=${t.join(`,`)}${Object.keys(e).length>t.length?`,…`:``}`}else c=`json[${typeof e}]`}else c=a?`content-type=${a}`:`no content-type`;return{ok:t.ok&&s,status:t.status,elapsedMs:r,summary:c}}catch(e){return{ok:!1,status:0,elapsedMs:Date.now()-i,summary:`error=${n.signal.aborted||e instanceof Error&&(e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`))?`timeout after ${t}ms`:e instanceof Error?e.message:String(e)}`}}finally{clearTimeout(r)}},Ma=e=>{if(!e||!Number.isFinite(e))return`(n/a)`;try{return new Date(e).toISOString()}catch{return`(invalid)`}},Na=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.trunc(e);if(typeof e==`string`){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>0)return t}return null},Pa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Fa=(e,t=`(n/a)`)=>typeof e==`string`?e.trim()||t:typeof e==`number`&&Number.isFinite(e)?String(e):typeof e==`boolean`?e?`true`:`false`:t,Ia=(e,t,n)=>e===`node-shebang`||e===`node-launcher`?t?`node (${t})`:`node`:e===`bun-shebang`?n?`bun (${n})`:`bun`:e||`direct executable`,La=async()=>{let e=new Date,t=typeof navigator<`u`?navigator.userAgent:`(no navigator)`,n=Aa(),r=W.getState().eventStreamStatus,i=typeof window<`u`?window.location.origin:``,a=l(),o=a.health(),s=a.api(`/api/`),c=await(async()=>{if(!o)return null;let e=new AbortController,t=setTimeout(()=>e.abort(),5e3);try{let t=await g(o,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!t.ok)return null;let n=await t.json().catch(()=>null);return!n||typeof n!=`object`||Array.isArray(n)?null:n}catch{return null}finally{clearTimeout(t)}})(),u=await(async()=>{if(!s)return null;let e=new AbortController,t=setTimeout(()=>e.abort(),7e3);try{let t=await g(a.api(`/api/config/opencode-resolution`),{method:`GET`,headers:{Accept:`application/json`},signal:e.signal}),n=t.headers.get(`content-type`)||`(none)`;if(!t.ok)return{data:null,status:t.status,error:`http ${t.status} content-type=${n}`};let r=await t.text(),i=null;try{i=JSON.parse(r)}catch{let e=r.replace(/\s+/g,` `).slice(0,120);return{data:null,status:t.status,error:`invalid json content-type=${n} body=${e||`(empty)`}`}}return!i||typeof i!=`object`||Array.isArray(i)?{data:null,status:t.status,error:`invalid json-shape content-type=${n}`}:{data:i,status:t.status,error:null}}catch(e){return{data:null,status:null,error:e instanceof Error?e.message:String(e)}}finally{clearTimeout(t)}})()||{data:null,status:null,error:null},d=(e,t=!0)=>{if(!s)return null;let r=new URL(e.replace(/^\/+/,``),s);return t&&n&&r.searchParams.set(`location[directory]`,n),r.toString()},f=s?await Promise.all([{label:`health`,path:`/info`,includeDirectory:!1},{label:`config`,path:`/config`,includeDirectory:!0},{label:`providers`,path:`/provider`,includeDirectory:!0},{label:`agents`,path:`/agent`,includeDirectory:!0,timeoutMs:12e3},{label:`commands`,path:`/command`,includeDirectory:!0,timeoutMs:1e4},{label:`project`,path:`/project`,includeDirectory:!1},{label:`location`,path:`/location`,includeDirectory:!0},{label:`sessions`,path:`/session`,includeDirectory:!0,timeoutMs:12e3},{label:`sessionActive`,path:`/session/active`,includeDirectory:!1}].map(async e=>{let t=d(e.path,e.includeDirectory!==!1);if(!t)return{label:e.label,url:`(none)`,result:null};let n=await ja(t,typeof e.timeoutMs==`number`?e.timeoutMs:void 0);return{label:e.label,url:t,result:n}})):[],p=[];p.push(`Time: ${e.toISOString()}`),p.push(`Yuri version: 0.3.8-beta.11`),p.push(`Runtime: ${i||`(unknown)`} (api=${s||`(unknown)`})`),p.push(`OpenCode SDK base: ${ue.getBaseUrl()}`),p.push(`Event stream: ${r}`),p.push(`Directory: ${n||`(none)`}`),p.push(`Platform: ${t}`);let m=Na(c?.openCodePort);if(p.push(`OpenCode runtime port: ${m??`(unknown)`}`),typeof c?.openCodeRunning==`boolean`&&p.push(`OpenCode runtime running: ${c.openCodeRunning?`yes`:`no`}`),typeof c?.openCodeSecureConnection==`boolean`&&p.push(`Secure OpenCode connection: ${c.openCodeSecureConnection?`true`:`false`}`),typeof c?.openCodeAuthSource==`string`&&c.openCodeAuthSource.trim()&&p.push(`OpenCode auth source: ${c.openCodeAuthSource}`),typeof c?.openCodeServeVersion==`string`&&c.openCodeServeVersion.trim()&&p.push(`OpenCode serve version: ${c.openCodeServeVersion}`),typeof c?.openCodeCliVersion==`string`&&c.openCodeCliVersion.trim()&&p.push(`OpenCode CLI version: ${c.openCodeCliVersion}`),Pa(c?.runtimeContract)){let e=c.runtimeContract,t=typeof e.phase==`string`?e.phase:`(unknown)`,n=e.executionAllowed===!0?`allowed`:`limited`,r=e.protocolCompatible===!0?`compatible`:`incompatible`;p.push(`OpenCode runtime contract: phase=${t} protocol=${r} execution=${n}`),Array.isArray(e.reasons)&&e.reasons.length>0&&p.push(`OpenCode contract reasons: ${e.reasons.filter(e=>typeof e==`string`).join(`, `)}`)}if(typeof window<`u`){let e=window.__YURI_MACOS_MAJOR__;typeof e==`number`&&Number.isFinite(e)&&e>0&&p.push(`macOS major: ${e}`)}if(/Mac OS X|Macintosh/.test(t)){p.push(``),p.push(`OpenCode CLI resolution:`);let e=Pa(c?.lastOpenCodeLaunchDiagnostics)?c.lastOpenCodeLaunchDiagnostics:null,t=e&&Array.isArray(e.args)?e.args.filter(e=>typeof e==`string`):[],n=u.data,r=n&&typeof n.configured==`string`?n.configured:null,i=n&&typeof n.resolved==`string`?n.resolved:c&&typeof c.opencodeBinaryResolved==`string`?c.opencodeBinaryResolved:``,a=n&&typeof n.resolvedDir==`string`?n.resolvedDir:``,o=n&&typeof n.source==`string`?n.source:c&&typeof c.opencodeBinarySource==`string`?c.opencodeBinarySource:``,s=n&&typeof n.launchBinary==`string`?n.launchBinary:c&&typeof c.opencodeLaunchBinary==`string`?c.opencodeLaunchBinary:``,l=n&&typeof n.launchWrapperType==`string`?n.launchWrapperType:c&&typeof c.opencodeLaunchWrapperType==`string`?c.opencodeLaunchWrapperType:``,d=n&&Array.isArray(n.launchArgs)?n.launchArgs.filter(e=>typeof e==`string`):c&&Array.isArray(c.opencodeLaunchArgs)?c.opencodeLaunchArgs.filter(e=>typeof e==`string`):[],f=n&&typeof n.node==`string`?n.node:c&&typeof c.nodeBinaryResolved==`string`?c.nodeBinaryResolved:``,m=n&&typeof n.bun==`string`?n.bun:c&&typeof c.bunBinaryResolved==`string`?c.bunBinaryResolved:``,h=n&&typeof n.detectedNow==`string`?n.detectedNow:``,g=n&&typeof n.detectedSourceNow==`string`?n.detectedSourceNow:``;if(r!==null&&p.push(`- configured: ${r.trim().length===0?`(cleared)`:r}`),i){let e=a||(i.includes(`/`)?i.split(`/`).slice(0,-1).join(`/`)||`/`:``);p.push(`- opencode: ${i}${e?` (dir=${e})`:``}`)}else p.push(`- opencode: (n/a)`);p.push(`- source: ${o||`(n/a)`}`),h&&(p.push(`- detected-now: ${h}`),p.push(`- detected-source: ${g||`(n/a)`}`)),e?(p.push(`- launched-at: ${Fa(e.launchedAt)}`),p.push(`- launch: ${Fa(e.binary)} ${t.join(` `)}`.trim()),p.push(`- cwd: ${Fa(e.cwd)}`),p.push(`- wrapper: ${Fa(e.wrapperType)}`),p.push(`- runtime: ${Ia(Fa(e.wrapperType,``),f,m)}`),p.push(`- PATH entries: ${Fa(e.pathEntryCount,`(unknown)`)}`),p.push(`- shell env: ${Fa(e.hasShellEnv,`(unknown)`)} (${Fa(e.shellEnvKeysCount,`?`)} keys)`)):(p.push(`- launch-binary: ${s||`(n/a)`}`),p.push(`- launch-wrapper: ${l||`(n/a)`}`),p.push(`- launch-args: ${d.length?d.join(` `):`(none)`}`),p.push(`- runtime: ${Ia(l||``,f,m)}`)),!n&&u.error&&p.push(`- resolution-endpoint: ${u.error}`)}if(p.push(``),f.length){p.push(`OpenCode API probes:`);for(let e of f){if(!e.result){p.push(`- ${e.label}: (no url)`);continue}let{ok:t,status:n,elapsedMs:r,summary:i}=e.result,a=t?``:` url=${e.url}`;p.push(`- ${e.label}: ${t?`ok`:`fail`} status=${n} time=${r}ms ${i}${a}`)}}else p.push(`OpenCode API probes: (skipped)`);return p.push(``),p.push(`Generated: ${Ma(Date.now())}`),p.join(`
5
+ `)},Ra=async()=>{let e=await La(),t=W.getState();t.setOpenCodeStatusText(e),t.setOpenCodeStatusDialogOpen(!0)},za=(e,t)=>e===t?!0:!e||!t?!1:e.scope===t.scope&&e.sessionId===t.sessionId&&e.projectId===t.projectId,Ba=e=>e?`${e.scope}:${e.projectId??``}:${e.sessionId}`:null,Va=e=>({scope:`project`,sessionId:e,projectId:null}),Ha=V()(e=>({focus:null,setFocus:t=>e(e=>za(e.focus,t)?e:{focus:t})})),Ua=null,Wa=0,Ga=(e,t)=>{let n=new Set,r=[];for(let i of t){if(!i.sessionId)continue;let t=e===`pinned`?i.sessionId:`${i.projectId??``}:${i.sessionId}`;n.has(t)||(n.add(t),r.push(i.scope===e?i:{...i,scope:e}))}return r},Ka=e=>{let t=++Wa;return Ua={pinned:Ga(`pinned`,e.pinned),project:Ga(`project`,e.project)},()=>{Wa===t&&(Ua=null)}},qa=()=>Ua,Ja=e=>!!e.parentID,Ya=(e,t)=>{if(!e)return null;let n=new Map(t.map(e=>[e.id,e])),r=n.get(e);if(!r)return e;for(;r&&Ja(r);){let e=r.parentID;if(!e)break;let t=n.get(e);if(!t)return e;r=t}return r?.id??e},Xa=()=>{let e=Ke.getState().activeSessions;if(e.length>0)return e;let t=de();return t.length>0?t:I()},Za=(e,t,n)=>{if(!t)return-1;if(n?.scope){let r=e.findIndex(e=>e.scope===n.scope&&e.sessionId===t&&(!n.projectId||e.projectId===n.projectId));if(r>=0)return r}if(n?.projectId){let r=e.findIndex(e=>e.sessionId===t&&e.projectId===n.projectId);if(r>=0)return r}return e.findIndex(e=>e.sessionId===t)},Qa=e=>[...e.pinned,...e.project],$a=(e,t,n,r)=>{if(e.length===0)return null;let i=Za(e,n,r);return i<0?t>0?e[0]??null:e[e.length-1]??null:e[(i+t+e.length)%e.length]??null},eo=(e,t,n=Ha.getState().focus)=>{let r=Ya(t,Xa()),i=n?.sessionId===t?n:null,a=qa();return a?$a(Qa(a),e,r,i):null},to=(e,t,n=e=>{K.getState().setCurrentSession(e.sessionId,e.directory)})=>{let r=eo(e,t);return r?(Ha.getState().setFocus({scope:r.scope,sessionId:r.sessionId,projectId:r.projectId}),n(r),r):null},no=.5,ro=.1,io=`yuri.webviewZoomFactor`,ao=e=>Number.isFinite(e)?Math.min(3,Math.max(no,Math.round(e*100)/100)):1,oo=()=>{if(typeof window>`u`)return 1;try{let e=window.localStorage.getItem(io);return e?ao(Number.parseFloat(e)):1}catch{return 1}},so=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(io,String(e))}catch{}},co=e=>{let t=ao(e);return typeof document<`u`&&(document.documentElement.style.zoom=t===1?``:String(t)),so(t),t},lo=()=>{if(typeof document>`u`)return 1;let e=document.documentElement.style.zoom;if(!e)return oo();let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?ao(t):oo()},uo=()=>{if(S())return;let e=oo();e!==1&&co(e)},fo=async()=>{if(S())try{let e=await C(`desktop_zoom_in`);if(typeof e==`number`&&Number.isFinite(e))return ao(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_in failed, using CSS zoom`,e)}return co(lo()+ro)},po=async()=>{if(S())try{let e=await C(`desktop_zoom_out`);if(typeof e==`number`&&Number.isFinite(e))return ao(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_out failed, using CSS zoom`,e)}return co(lo()-ro)},mo=async()=>{if(S())try{let e=await C(`desktop_zoom_reset`);if(typeof e==`number`&&Number.isFinite(e))return ao(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_reset failed, using CSS zoom`,e)}return co(1)};function ho(){let e=(0,Z.c)(36),t=(0,X.useContext)(yt),n=on(),r=W(bo),i;e[0]!==n||e[1]!==r?(i=n.length?rn([...Mt(),...n],r):null,e[0]=n,e[1]=r,e[2]=i):i=e[2];let a=i,o;e[3]===n?o=e[4]:(o=new Map(n.map(yo)),e[3]=n,e[4]=o);let s=o,c;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=ee(),e[5]=c):c=e[5];let l=c,u=(0,X.useRef)(`[]`),d=(0,X.useRef)(!0),f;e[6]!==n||e[7]!==r?(f=l?[...new Set(n.flatMap(e=>jt(e,r).filter(Boolean).map(At)))]:[],e[6]=n,e[7]=r,e[8]=f):f=e[8];let p=f,m;e[9]!==a||e[10]!==s||e[11]!==n.length||e[12]!==t?(m=e=>{if(!t||!n.length||e.defaultPrevented||e.isComposing||e.keyCode===229)return;let r=e.target instanceof Element?e.target:document.activeElement;if(r instanceof Element&&r.closest(`[data-shortcut-capture], [data-terminal-view="true"], .terminal-viewport-container, [data-terminal-hidden-input="true"]`))return;let i=a?.match(e,t=>{let n=s.get(t.id);if(!n)return!0;let i=r instanceof Element?r:document.activeElement;return n.scope&&!i?.closest(n.scope)?!1:n.editable||e.metaKey||e.ctrlKey||e.altKey||!i?.closest(`input, textarea, [contenteditable]:not([contenteditable="false"])`)}),o=i?s.get(i.action.id):void 0;return i&&o?{command:o,combo:i.combo}:void 0},e[9]=a,e[10]=s,e[11]=n.length,e[12]=t,e[13]=m):m=e[13];let h=U(m),g;e[14]!==t||e[15]!==h?(g=e=>{let n=h(e);if(!n||!t)return!1;let{command:r,combo:i}=n;return!e.repeat&&!t.runShortcutCommand(r.pluginId,r.commandId)?(l&&queueMicrotask(()=>{e.defaultPrevented||l.fallback(i).catch(vo)}),!1):(e.preventDefault(),e.stopPropagation(),!0)},e[14]=t,e[15]=h,e[16]=g):g=e[16];let _=U(g),v;e[17]!==p||e[18]!==h?(v=()=>{if(!l||!d.current)return;let e=p.filter(e=>!!h(Jt(e))).sort(),t=JSON.stringify(e);u.current!==t&&(u.current=t,l.claim(e).catch(()=>{u.current===t&&(u.current=null,l.claim([]).catch(_o))}))},e[17]=p,e[18]=h,e[19]=v):v=e[19];let y=U(v),b;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>(d.current=!0,()=>{d.current=!1,u.current&&u.current!==`[]`&&l?.claim([]).catch(go),u.current=`[]`}),e[20]=b):b=e[20];let x;e[21]===t?x=e[22]:(x=[t,l],e[21]=t,e[22]=x),(0,X.useEffect)(b,x);let S;e[23]===y?S=e[24]:(S=()=>{y()},e[23]=y,e[24]=S);let C;e[25]!==p||e[26]!==t||e[27]!==y?(C=[t,p,l,y],e[25]=p,e[26]=t,e[27]=y,e[28]=C):C=e[28],(0,X.useEffect)(S,C);let w;e[29]===p?w=e[30]:(w=()=>l&&p.length?window:null,e[29]=p,e[30]=w);let T=w;Me(`focusin`,y,T);let E;e[31]===y?E=e[32]:(E=()=>queueMicrotask(y),e[31]=y,e[32]=E),Me(`focusout`,E,T);let D;return e[33]!==h||e[34]!==_?(D={match:h,run:_},e[33]=h,e[34]=_,e[35]=D):D=e[35],D}function go(){}function _o(){}function vo(){}function yo(e){return[e.id,e]}function bo(e){return e.shortcutOverrides}var xo=9,So=null,Co=0,wo=({pinnedTargets:e,projectTargets:t})=>[...e,...t].slice(0,xo),To=(e,t)=>{let n=e.findIndex(e=>e.scope===t.scope&&e.sessionId===t.sessionId&&(e.projectId??null)===(t.projectId??null));return n>=0?n+1:null},Eo=e=>{let t=++Co;return So={targets:e.targets.slice(0,xo),activate:e.activate},()=>{Co===t&&(So=null)}},Do=e=>{if(!Number.isInteger(e)||e<1||e>xo)return!1;let t=So,n=t?.targets[e-1];return!t||!n?!1:(t.activate(n),!0)},Oo=e=>{let t=e.trim();if(!t)return null;let n=Rn.getState(),r=n.createTab(t);return!r||r===`tab-invalid`?null:(n.setActiveTab(t,r),r)},ko=e=>{let t=e.trim();if(!t)return null;let n=W.getState();return!n.isBottomTerminalOpen&&n.activeMainTab!==`terminal`&&n.setBottomTerminalOpen(!0),Oo(t)},Ao=(e,t)=>{let n=e.trim();if(!n)return!1;let r=Rn.getState(),i=r.getDirectoryState(n);if(!i||i.tabs.length<2)return!1;let a=i.tabs.findIndex(e=>e.id===i.activeTabId),o=((a>=0?a:0)+t+i.tabs.length)%i.tabs.length,s=i.tabs[o]?.id;return!s||s===i.activeTabId?!1:(r.setActiveTab(n,s),!0)},jo=e=>{let t=e.trim();if(!t)return{closed:!1,wasLastTab:!1};let n=Rn.getState(),r=n.getDirectoryState(t),i=r?.activeTabId??null;if(!r||!i)return{closed:!1,wasLastTab:!1};let a=r.tabs.length===1;return n.closeTab(t,i),{closed:!0,wasLastTab:a}},Mo=()=>typeof window>`u`||window.parent===window||!fn(window.location.search)?!1:(window.parent.postMessage({type:pn},window.location.origin),!0),No=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=W.getState();if(e)return!1;let n=Po();return n&&t(n)?!0:S()?(C(`desktop_close_current_window`).catch(e=>{console.warn(`[keyboard-shortcuts] failed to close current window`,e)}),!0):!1},Po=()=>{let e=Et(),t=We.getState().getActiveProject();if(!t?.hostId)return e;if(!(!t.hubId||!e))return T({hubId:t.hubId,hostId:t.hostId,directory:e})},Fo=({sessionId:e,surfaceKind:t,wiringCanAbort:n,primaryCanAbort:r,pendingSend:i=!1})=>e?i||n?!0:t!==`secondary`&&r:!1,Io=async({sessionId:e,currentProviderId:t,currentModelId:n,waitForConnectionOrThrow:r,getAuthoritativeDirectoryForSession:i,summarizeSession:a,onCompactFailed:o})=>{try{await r();let s=i(e);if(!s){o();return}await a(e,t,n,s)}catch(e){o(e)}},Lo=()=>{let e=(0,Z.c)(73),{t}=ct(),{match:n,run:r}=ho(),i=K(Ro),a=K(zo),o=K(Bo),s=K(Vo),c=Je,l=W(Ho),u=W(Uo),d=W(Wo),f=W(Go),p=W(Ko),m=W(qo),h=W(Jo),g=W(Yo),_=W(Xo),v=W(Zo),y=W(Qo),b=W($o),x=W(es),w=W(ts),T=W(ns),E=W(rs),D=W(is),ee=W(as),O=W(os),k=xe(ss),ne=We(cs),{themeMode:A,setThemeMode:j}=_t(),{working:M}=xn(),re=X.useRef(null),ie=X.useRef(null),N=X.useRef(null),P=X.useRef(!1),ae=X.useRef(A),oe,F;e[0]===A?(oe=e[1],F=e[2]):(oe=()=>{ae.current=A},F=[A],e[0]=A,e[1]=oe,e[2]=F),X.useEffect(oe,F);let I;e[3]===o?I=e[4]:(I=()=>{ie.current&&=(clearTimeout(ie.current),null),re.current=null,o()},e[3]=o,e[4]=I);let L=I,se;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{N.current&&=(clearTimeout(N.current),null),_n.getState().clear()},e[5]=se):se=e[5];let ce=se,le;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{N.current&&=(clearTimeout(N.current),null);let e=_n.getState().arm(bn);N.current=setTimeout(()=>{let{expiresAt:e}=_n.getState();e&&Date.now()>=e&&_n.getState().clear(),N.current=null},Math.max(0,e-Date.now()))},e[6]=le):le=e[6];let ue=le,R;e[7]!==ne?.id||e[8]!==ne?.path||e[9]!==a||e[10]!==k||e[11]!==_||e[12]!==n||e[13]!==i||e[14]!==L||e[15]!==r||e[16]!==y||e[17]!==w||e[18]!==g||e[19]!==x||e[20]!==D||e[21]!==p||e[22]!==m||e[23]!==v||e[24]!==b||e[25]!==j||e[26]!==T||e[27]!==O||e[28]!==t||e[29]!==h||e[30]!==l||e[31]!==f||e[32]!==ee||e[33]!==u||e[34]!==E||e[35]!==d||e[36]!==M?(R=()=>{let e=e=>Pt(e,O),o=e=>jt(e,O),s=()=>{let e=We.getState().getActiveProject();if(!e?.hostId)return!1;if(y(`chat`),v(!1),!e.hubId)return q.error(t(`remoteProjects.host-unavailable`)),!0;let n=Ue.getState().remoteSession,r=n?.projectId===e.id&&n.location.hubId===e.hubId&&n.location.hostId===e.hostId?n.location:{hubId:e.hubId,hostId:e.hostId,directory:e.path};return Ue.getState().openRemoteSession(e,r,null),!0},A=ls,N=[`[data-slot="dropdown-menu-content"]`,`[data-slot="select-content"]`,`[role="combobox"]`,`[role="listbox"]`,`[role="menu"]`,`[role="menuitem"]`,`[role="option"]`,`[data-radix-popper-content-wrapper]`].join(`,`),oe=e=>e instanceof Element&&!!e.closest(N),F=ds,I=ps,se=ms,le=async()=>{let e=vn(),n=e?Sn(e):null;if(n&&e){try{await n.compact({providerID:e.selection.value.providerID,modelID:e.selection.value.modelID,agent:e.selection.value.agent,variant:e.selection.value.variant})}catch(e){let n=e;q.error(n instanceof Error?n.message:t(`chat.chatInput.toast.compactFailed`))}return}let r=K.getState().currentSessionId;if(!r)return;let{currentProviderId:i,currentModelId:a}=G.getState();await Io({sessionId:r,currentProviderId:i,currentModelId:a,waitForConnectionOrThrow:tt,getAuthoritativeDirectoryForSession:K.getState().getAuthoritativeDirectoryForSession,summarizeSession:hs,onCompactFailed:e=>{q.error(e instanceof Error?e.message:t(`chat.chatInput.toast.compactFailed`))}})},R=t=>{let r=_n.getState().pending;if(t.repeat||t.isComposing&&!r||t.defaultPrevented&&!r||A(t.target)&&!r)return;let a=e(`leader_key`);if(r){let e=()=>{P.current=!0,window.setTimeout(()=>{P.current=!1},0)};if(a&&Y(t,a)){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),ue();return}let n=t.key.toLowerCase();if(n===`escape`){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),ce();return}if(t.key===`Control`||t.key===`Shift`||t.key===`Alt`||t.key===`Meta`)return;if(t.metaKey||t.ctrlKey||t.altKey){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce();return}let{activeMainTab:r,isModelSelectorOpen:o,isAgentSelectorOpen:c}=W.getState(),l=hn(r)&&!se();if(n===`m`&&l){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce(),window.requestAnimationFrame(()=>{x(!o,{instant:!0})});return}if(n===`a`&&l){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce(),w(!c,{instant:!0});return}if(n===`n`&&l){if(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce(),s())return;let n=vn(),r=n?Sn(n):null;r?r.shortcut(`new`):(y(`chat`),v(!1),i());return}if(n===`c`&&l){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce(),le(),I();return}t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),ce(),I();return}if(!a||!Y(t,a)||n(t)||se())return;let{activeMainTab:o}=W.getState();hn(o)&&(t.preventDefault(),t.stopPropagation(),ue())},de=()=>_n.getState().pending||P.current,fe=e=>{de()&&e.preventDefault()},z=e=>{de()&&(e.preventDefault(),e.stopPropagation())},B=t=>{if(A(t.target)){if(!te()&&Y(t,e(`new_terminal_tab`))){let e=Po();if(!e||!Oo(e))return;t.preventDefault(),t.stopPropagation();return}if(!te()&&Y(t,e(`previous_terminal_tab`))){let e=Po();if(!e||!Ao(e,-1))return;t.preventDefault(),t.stopPropagation();return}if(!te()&&Y(t,e(`next_terminal_tab`))){let e=Po();if(!e||!Ao(e,1))return;t.preventDefault(),t.stopPropagation();return}if(Y(t,e(`close_context_panel_tab`))){let e=Po();if(!e)return;let{closed:n,wasLastTab:r}=jo(e);if(!n)return;if(t.preventDefault(),t.stopPropagation(),r){let e=W.getState();e.setBottomTerminalOpen(!1),e.activeMainTab===`terminal`&&e.setActiveMainTab(`chat`)}return}if(o(`toggle_terminal`).some(e=>Y(t,e))){let{isMobile:e}=W.getState();if(e)return;t.preventDefault(),t.stopPropagation(),h();return}if(Y(t,e(`toggle_terminal_expanded`))){let{isMobile:e,isBottomTerminalExpanded:n}=W.getState();if(e)return;t.preventDefault(),t.stopPropagation(),g(!n);return}}},V=gs,pe=n=>{if(n.defaultPrevented||n.isComposing||n.keyCode===229||r(n))return;if(Y(n,e(`close_context_panel_tab`))){(Mo()||No())&&(n.preventDefault(),n.stopPropagation());return}if(A(n.target))return;let a=_s;if(a(n.target)&&n.ctrlKey&&!n.metaKey&&!n.shiftKey&&!n.altKey&&n.key.toLowerCase()===`t`){n.preventDefault(),V();return}if(Y(n,e(`open_command_palette`))){n.preventDefault(),l();return}if(Y(n,e(`open_timeline_dialog`))){n.preventDefault(),T(!0);return}if(Y(n,e(`toggle_prompt_navigator`))){let{activeMainTab:e,promptNavigatorEnabled:t,isSettingsDialogOpen:r,isCommandPaletteOpen:i,isHelpDialogOpen:a,isSessionSwitcherOpen:o,isAboutDialogOpen:s,isTimelineDialogOpen:c,isMultiRunLauncherOpen:l,isImagePreviewOpen:u}=W.getState();if(!t||_||te()||e!==`chat`||r||i||a||o||s||c||l||u)return;n.preventDefault(),E();return}if(Y(n,e(`open_status`))){n.preventDefault(),Ra();return}if(Y(n,e(`open_help`))){n.preventDefault(),u();return}if(S()&&Y(n,e(`new_mini_chat`))){if(n.preventDefault(),We.getState().getActiveProject()?.hostId){q.error(t(`miniChat.unavailable.title`),{description:t(`remoteProjects.miniChatUnsupportedReason`)});return}C(`desktop_open_draft_mini_chat_window`,{directory:k||ne?.path||``,projectId:ne?.id??null}).catch(vs);return}let c=Y(n,e(`new_chat`)),w=Y(n,e(`new_chat_worktree`));if(c||w){if(n.preventDefault(),y(`chat`),v(!1),!te()&&w){gn();return}s()||i();return}if(Y(n,e(`cycle_theme`))){if(n.preventDefault(),_i()!==null&&window.parent&&window.parent!==window){window.parent.postMessage({type:`yuri:cycle-theme-request`},window.location.origin);return}let e=[`light`,`dark`,`system`],t=document.activeElement,r=(e.indexOf(ae.current)+1)%e.length;j(e[r]),requestAnimationFrame(()=>{typeof document>`u`||typeof window>`u`||(document.hasFocus()||window.focus(),t&&document.contains(t)&&t.focus({preventScroll:!0}))});return}if(Nt(n,`in`,e(`zoom_in`))){n.preventDefault(),fo();return}if(Nt(n,`out`,e(`zoom_out`))){n.preventDefault(),po();return}if(Y(n,e(`zoom_reset`))){n.preventDefault(),mo();return}if(Y(n,e(`open_settings`))){n.preventDefault();let{isSettingsDialogOpen:e}=W.getState();b(!e);return}if(Y(n,e(`toggle_sidebar`))){n.preventDefault();let{isMobile:e,isSessionSwitcherOpen:t}=W.getState();e?v(!t):d();return}if(Y(n,e(`focus_input`))){n.preventDefault(),document.querySelector(`textarea[data-chat-input="true"]`)?.focus();return}let D=e(`cycle_agent`),O=D&&!D.includes(`shift`)?At(`shift+${D}`):``,M=O&&Y(n,O)?-1:+!!Y(n,D);if(M!==0){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:r,isSessionSwitcherOpen:i,isAboutDialogOpen:o,activeMainTab:s}=W.getState();if(e||t||r||i||o||!hn(s)||!a(n.target))return;let c=vn(),l=c?Sn(c):null;if(l){n.preventDefault(),l.shortcut(`cycle`,M);return}let u=G.getState(),d=et(u.getVisibleAgents(),u.currentAgentName,M);if(!d)return;n.preventDefault(),u.setAgent(d),W.getState().addRecentAgent(d);let f=K.getState().currentSessionId;f&&nt.getState().saveSessionAgentSelection(f,d);return}if(o(`toggle_right_sidebar`).some(e=>Y(n,e))){let{isMobile:e}=W.getState();if(e)return;n.preventDefault();let t=Po();t&&f(t);return}if(Y(n,e(`open_right_sidebar_git`))){let{isMobile:e}=W.getState();if(e)return;n.preventDefault();let t=Po();t&&W.getState().openContextPanel(t),p(!0),m(`git`);return}if(Y(n,e(`open_right_sidebar_files`))){let{isMobile:e}=W.getState();if(e)return;n.preventDefault();let t=Po();t&&W.getState().openContextPanel(t),p(!0),m(`files`);return}if(Y(n,e(`cycle_right_sidebar_tab`))){let{isMobile:e,rightSidebarTab:t}=W.getState();if(e)return;let r=ka({hideGit:W.getState().activeMainTab===`git`,showBrowser:tn(Xt())}),i=r[(r.indexOf(t)+1)%r.length];n.preventDefault();let a=Po();a&&W.getState().openContextPanel(a),p(!0),m(i);return}let re=e=>to(e,K.getState().currentSessionId,e=>{y(`chat`),v(!1),K.getState().setCurrentSession(e.sessionId,e.directory)});if(o(`previous_session`).some(e=>Y(n,e))){n.preventDefault(),re(-1);return}if(o(`next_session`).some(e=>Y(n,e))){n.preventDefault(),re(1);return}for(let t=1;t<=9;t+=1)if(Y(n,e(`switch_tab_${t}`))){Do(t)&&n.preventDefault();return}if(o(`toggle_terminal`).some(e=>Y(n,e))){let{isMobile:e}=W.getState();if(e)return;n.preventDefault(),h();return}if(Y(n,e(`open_new_terminal`))){let{isMobile:e}=W.getState();if(e||te())return;let t=Po();if(!t||!ko(t))return;n.preventDefault();return}if(Y(n,e(`toggle_terminal_expanded`))){let{isMobile:e,isBottomTerminalExpanded:t}=W.getState();if(e)return;n.preventDefault(),g(!t);return}if(Y(n,e(`open_model_selector`))){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:r,isSessionSwitcherOpen:i,isAboutDialogOpen:a,activeMainTab:o,isModelSelectorOpen:s}=W.getState();if(e)return;let c=t||r||i||a,l=hn(o);if(c||!l)return;n.preventDefault(),x(!s,{instant:!0});return}if(Y(n,e(`cycle_thinking_variant`))){V()&&n.preventDefault();return}if(Y(n,e(`cycle_favorite_model_forward`))||Y(n,e(`cycle_favorite_model_backward`))){let{isSettingsDialogOpen:t,isCommandPaletteOpen:r,isHelpDialogOpen:i,isSessionSwitcherOpen:a,isAboutDialogOpen:o,activeMainTab:s,favoriteModels:c,addRecentModel:l}=W.getState();if(t)return;let u=r||i||a||o,d=hn(s);if(u||!d||c.length===0)return;n.preventDefault();let f=c.length,p=Y(n,e(`cycle_favorite_model_forward`))?1:-1,m=vn();if(m?.selection.change){let e=m.selection.value.providerID,t=m.selection.value.modelID,n=c[(c.findIndex(n=>n.providerID===e&&n.modelID===t)+p+f)%f],r=G.getState().providers.find(e=>e.id===n.providerID)?.models?.find(e=>e.id===n.modelID),i=r?.variants?Object.keys(r.variants):[],a=n.variant!==void 0&&i.includes(n.variant)?n.variant:void 0;m.selection.change({...m.selection.value,providerID:n.providerID,modelID:n.modelID,variant:a}),l(n.providerID,n.modelID,a);return}let{currentProviderId:h,currentModelId:g,providers:_,setProvider:v,setModel:y,setCurrentVariant:b}=G.getState(),x=c[(c.findIndex(e=>e.providerID===h&&e.modelID===g)+p+f)%f];v(x.providerID),y(x.modelID);let S=_.find(e=>e.id===x.providerID)?.models?.find(e=>e.id===x.modelID),C=S?.variants?Object.keys(S.variants):[],w=x.variant!==void 0&&C.includes(x.variant)?x.variant:void 0;b(w),l(x.providerID,x.modelID,w);return}if(Y(n,e(`expand_input`))){if(_)return;n.preventDefault(),ee();return}if(Y(n,e(`toggle_dictation`))){let{activeMainTab:e,isCommandPaletteOpen:t,isHelpDialogOpen:r,isSessionSwitcherOpen:i,isSettingsDialogOpen:a}=W.getState();if(!hn(e)||t||r||i||a)return;n.preventDefault(),window.dispatchEvent(new CustomEvent(`yuri:dictation-toggle`));return}},H=e=>{if(e.key!==`Escape`||e.isComposing)return;let t=e.target,n=!!t?.closest(`[role="dialog"]`),r=!!document.querySelector(`[data-settings-view="true"]`),i=!!(t?.closest(`.terminal-viewport-container`)||t?.getAttribute(`data-terminal-hidden-input`)===`true`),o=oe(t)||F(),{isSettingsDialogOpen:s,isCommandPaletteOpen:l,isHelpDialogOpen:u,isSessionSwitcherOpen:d,isAboutDialogOpen:f,isMultiRunLauncherOpen:p,isImagePreviewOpen:m,isPromptNavigatorPanelOpen:h,workStatusOverlayOpen:g}=W.getState();if(n||i||o){L();return}if(g){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),W.getState().setWorkStatusOverlayOpen(!1),L();return}if(h){e.preventDefault(),D(!1),L();return}if(s){e.preventDefault(),b(!1),L();return}if(r){L();return}if(l||u||d||f||p||m){L();return}let _=vn(),v=_?Sn(_):null,y=_?.sessionID??K.getState().currentSessionId,x=!!(y&&K.getState().pendingSendMessageIDs.get(y));if(!Fo({sessionId:y,surfaceKind:_?.kind,wiringCanAbort:v?.canAbort,primaryCanAbort:M.canAbort,pendingSend:x})){L();return}e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();let S=Date.now(),C=re.current;if(C&&S<C){L(),v?v.abort():(y&&Pn(y),c(y??``));return}let w=_?.kind===`secondary`?S+3e3:a(3e3)??S+3e3;re.current=w,ie.current&&clearTimeout(ie.current);let T=Math.max(w-S,0);ie.current=setTimeout(()=>{re.current&&Date.now()>=re.current&&L()},T||0)};return window.addEventListener(`keydown`,R,!0),window.addEventListener(`beforeinput`,fe,!0),window.addEventListener(`compositionstart`,z,!0),window.addEventListener(`compositionupdate`,z,!0),window.addEventListener(`compositionend`,z,!0),window.addEventListener(`keydown`,B,!0),window.addEventListener(`keydown`,H,!0),window.addEventListener(`keydown`,pe),()=>{window.removeEventListener(`keydown`,R,!0),window.removeEventListener(`beforeinput`,fe,!0),window.removeEventListener(`compositionstart`,z,!0),window.removeEventListener(`compositionupdate`,z,!0),window.removeEventListener(`compositionend`,z,!0),window.removeEventListener(`keydown`,B,!0),window.removeEventListener(`keydown`,H,!0),window.removeEventListener(`keydown`,pe)}},e[7]=ne?.id,e[8]=ne?.path,e[9]=a,e[10]=k,e[11]=_,e[12]=n,e[13]=i,e[14]=L,e[15]=r,e[16]=y,e[17]=w,e[18]=g,e[19]=x,e[20]=D,e[21]=p,e[22]=m,e[23]=v,e[24]=b,e[25]=j,e[26]=T,e[27]=O,e[28]=t,e[29]=h,e[30]=l,e[31]=f,e[32]=ee,e[33]=u,e[34]=E,e[35]=d,e[36]=M,e[37]=R):R=e[37];let de=ne?.id,fe=ne?.path,z;e[38]!==a||e[39]!==k||e[40]!==s||e[41]!==_||e[42]!==n||e[43]!==i||e[44]!==L||e[45]!==r||e[46]!==y||e[47]!==w||e[48]!==g||e[49]!==x||e[50]!==D||e[51]!==p||e[52]!==m||e[53]!==v||e[54]!==b||e[55]!==j||e[56]!==T||e[57]!==O||e[58]!==t||e[59]!==de||e[60]!==fe||e[61]!==h||e[62]!==l||e[63]!==f||e[64]!==ee||e[65]!==u||e[66]!==E||e[67]!==d||e[68]!==M?(z=[i,c,l,u,d,f,p,m,h,g,_,v,y,b,x,w,T,E,D,ee,j,M,a,L,ue,ce,s,k,de,fe,O,n,r,t],e[38]=a,e[39]=k,e[40]=s,e[41]=_,e[42]=n,e[43]=i,e[44]=L,e[45]=r,e[46]=y,e[47]=w,e[48]=g,e[49]=x,e[50]=D,e[51]=p,e[52]=m,e[53]=v,e[54]=b,e[55]=j,e[56]=T,e[57]=O,e[58]=t,e[59]=de,e[60]=fe,e[61]=h,e[62]=l,e[63]=f,e[64]=ee,e[65]=u,e[66]=E,e[67]=d,e[68]=M,e[69]=z):z=e[69],X.useEffect(R,z);let B,V;e[70]===L?(B=e[71],V=e[72]):(V=()=>()=>{L(),ce()},B=[L,ce],e[70]=L,e[71]=B,e[72]=V),X.useEffect(V,B)};function Ro(e){return e.openNewSessionDraft}function zo(e){return e.armAbortPrompt}function Bo(e){return e.clearAbortPrompt}function Vo(e){return e.currentSessionId}function Ho(e){return e.toggleCommandPalette}function Uo(e){return e.toggleHelpDialog}function Wo(e){return e.toggleSidebar}function Go(e){return e.toggleContextPanel}function Ko(e){return e.setRightSidebarOpen}function qo(e){return e.setRightSidebarTab}function Jo(e){return e.toggleBottomTerminal}function Yo(e){return e.setBottomTerminalExpanded}function Xo(e){return e.isMobile}function Zo(e){return e.setSessionSwitcherOpen}function Qo(e){return e.setActiveMainTab}function $o(e){return e.setSettingsDialogOpen}function es(e){return e.setModelSelectorOpen}function ts(e){return e.setAgentSelectorOpen}function ns(e){return e.setTimelineDialogOpen}function rs(e){return e.togglePromptNavigatorPanel}function is(e){return e.setPromptNavigatorPanelOpen}function as(e){return e.toggleExpandedInput}function os(e){return e.shortcutOverrides}function ss(e){return e.currentDirectory}function cs(e){return e.getActiveProject()}function ls(e){return e instanceof Element&&!!(e.closest(`[data-terminal-view="true"]`)||e.closest(`.terminal-viewport-container`)||e.getAttribute(`data-terminal-hidden-input`)===`true`)}function us(e){return e.getClientRects().length>0}function ds(){let e=document.querySelectorAll(`[data-slot="dropdown-menu-content"], [data-slot="select-content"], [role="menu"], [data-radix-popper-content-wrapper]`);return Array.from(e).some(us)}function fs(){document.querySelector(`textarea[data-chat-input="true"]`)?.focus({preventScroll:!0})}function ps(){window.requestAnimationFrame(fs)}function ms(){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:n,isSessionSwitcherOpen:r,isAboutDialogOpen:i}=W.getState();return e||t||n||r||i}function hs(e,t,n,r){return ue.summarizeSession(e,t,n,r)}function gs(){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:n,isSessionSwitcherOpen:r,isAboutDialogOpen:i,activeMainTab:a}=W.getState();if(e||t||n||r||i||!hn(a))return!1;let o=vn();if(o?.selection.change){let e=o.selection.catalog?.variants??[];if(e.length===0)return!1;let t=o.selection.value.variant,n=e[((t?e.indexOf(t):-1)+1)%e.length];return o.selection.change({...o.selection.value,variant:n}),!0}let s=G.getState();if(s.getCurrentModelVariants().length===0)return!1;s.cycleCurrentVariant();let c=G.getState().currentVariant,l=K.getState().currentSessionId,u=G.getState().currentAgentName,d=G.getState().currentProviderId,f=G.getState().currentModelId;return l&&u&&d&&f&&nt.getState().saveAgentModelVariantForSession(l,u,d,f,c),u&&d&&f&&G.getState().saveAgentModelSelection(u,d,f,c),!0}function _s(e){return e instanceof HTMLTextAreaElement&&e.getAttribute(`data-chat-input`)===`true`}function vs(e){console.warn(`[keyboard-shortcuts] failed to open draft mini chat window`,e)}var ys=3,bs=(e,t)=>{if(typeof e!=`string`)return t;let n=e.trim().replace(/\s+/g,` `);return n?n.slice(0,48):t},xs=(e,t)=>{let n=t?[...e.filter(e=>e.id===t),...e.filter(e=>e.id!==t)]:e,r=[],i=new Set;for(let e of n){let t=typeof e.id==`string`?e.id.trim():``;if(!(!t||i.has(t))&&(i.add(t),r.push({sessionId:t,title:bs(e.title,`Session ${r.length+1}`)}),r.length>=ys))break}return r},Ss=()=>{let e=(0,Z.c)(9),t=at(),n=K(Cs),r;e[0]!==n||e[1]!==t?(r=xs(t,n),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i=r,a;e[3]===i?a=e[4]:(a=JSON.stringify(i),e[3]=i,e[4]=a);let o=a,s,c;e[5]!==i||e[6]!==o?(s=()=>{if(!(typeof window>`u`||!_())){try{i.length===0?localStorage.removeItem(sn):localStorage.setItem(sn,o)}catch{return}window.__YURI_UPDATE_PWA_MANIFEST__?.()}},c=[i,o],e[5]=i,e[6]=o,e[7]=s,e[8]=c):(s=e[7],c=e[8]),X.useEffect(s,c)};function Cs(e){return e.currentSessionId}var ws=e=>Number.isFinite(e)?`${Math.max(0,Math.round(e))}px`:`0px`,Ts=(e,t,n,r)=>{e.style.setProperty(`--yuri-wco-left-inset`,ws(t)),e.style.setProperty(`--yuri-wco-right-inset`,ws(n)),e.style.setProperty(`--yuri-wco-titlebar-height`,ws(r))},Es=()=>{let e=(0,Z.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],X.useEffect(Ds,t)};function Ds(){if(typeof window>`u`||!_())return;let e=document.documentElement,t=typeof window.matchMedia==`function`?window.matchMedia(`(display-mode: window-controls-overlay)`):null,n=window.navigator.windowControlsOverlay,r=()=>{if(!n||!t?.matches||!n.visible){Ts(e,0,0,0);return}let r=n.getTitlebarAreaRect(),i=Math.max(0,Number(r.x)||0),a=Math.max(0,Number(r.width)||0),o=Math.max(0,Number(r.height)||0),s=Math.max(0,window.innerWidth-(i+a));Ts(e,i,s,o)},i=()=>{r()};return r(),window.addEventListener(`resize`,r),window.addEventListener(`focus`,r),t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,i):typeof t.addListener==`function`&&t.addListener(i)),n&&typeof n.addEventListener==`function`&&n.addEventListener(`geometrychange`,r),()=>{window.removeEventListener(`resize`,r),window.removeEventListener(`focus`,r),t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,i):typeof t.removeListener==`function`&&t.removeListener(i)),n&&typeof n.removeEventListener==`function`&&n.removeEventListener(`geometrychange`,r),Ts(e,0,0,0)}}var Os=3e4,ks=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,As=e=>e instanceof Dn?e.status===501?`unsupported`:e.status>=400&&e.status<500&&e.status!==408&&e.status!==429&&e.code!==`revision_conflict`?`permanent`:`retry`:`retry`,js=(e,t)=>new Promise((n,r)=>{let i=()=>{clearTimeout(a),t.removeEventListener(`abort`,i),r(new DOMException(`Aborted`,`AbortError`))},a=setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.aborted?i():t.addEventListener(`abort`,i,{once:!0})}),Ms=(e,t)=>e.then(e=>{if(t?.aborted)throw new DOMException(`Aborted`,`AbortError`);return e}),Ns={fetchSnapshot:e=>Ms(An(Ae),e),refreshSnapshot:e=>Ms(En(Ae),e),fetchOrder:Cn,setOrder:wn,waitInvalidation:Tn,captureRuntime:()=>({transportIdentity:u(),generation:f()}),isCurrent:e=>e.transportIdentity===u()&&e.generation===f(),sleep:js,createRequestID:()=>typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`worktree-order-${Date.now()}-${Math.random().toString(36).slice(2)}`},Ps=new Map,Fs=()=>{for(let e of Ps.values())e.controller.abort();Ps.clear()},Is=(e,t,n,r=Ns)=>{Ps.get(e)?.controller.abort();let i={projectDirectory:ks(t),orderedPaths:[...n],capture:r.captureRuntime(),controller:new AbortController,backoffMs:500,running:!1};Ps.set(e,i),Ls(e,r)},Ls=async(e,t=Ns)=>{let n=Ps.get(e);if(!(!n||n.running)){n.running=!0;try{for(;;){let n=Ps.get(e);if(!n||!t.isCurrent(n.capture)||n.controller.signal.aborted)return;let r=Qe.getState().serverRevisionByProject[e]??0;n.expectedRevision!==r&&(n.expectedRevision=r,n.requestID=t.createRequestID());try{let i=await t.setOrder({requestID:n.requestID,projectDirectory:n.projectDirectory,expectedRevision:r,orderedPaths:n.orderedPaths,signal:n.controller.signal});if(!t.isCurrent(n.capture)||Ps.get(e)!==n)return;let a=i.worktreeOrder??{projectDirectory:n.projectDirectory,orderedPaths:n.orderedPaths,revision:i.revision};Qe.getState().setServerRevision(e,a.revision),Qe.getState().resolvePendingWorktreeOrder(e,a.revision),Ps.delete(e);return}catch(r){if(n.controller.signal.aborted||!t.isCurrent(n.capture)||Ps.get(e)!==n)return;if(r instanceof Dn&&r.code===`revision_conflict`)try{let r=await t.fetchOrder(n.projectDirectory,n.controller.signal);if(Ps.get(e)!==n||!t.isCurrent(n.capture))return;Qe.getState().applyServerWorktreeOrder(e,r.orderedPaths,r.revision),n.expectedRevision=void 0,n.requestID=void 0,n.backoffMs=500;continue}catch(e){if(As(e)!==`retry`)return}else if(As(r)!==`retry`)return;if(await t.sleep(n.backoffMs,n.controller.signal).catch(()=>{}),n.backoffMs=Math.min(n.backoffMs*2,Os),n.controller.signal.aborted)return}}}finally{Ps.get(e)===n&&(!t.isCurrent(n.capture)||n.controller.signal.aborted)&&Ps.delete(e),Ps.get(e)===n&&(n.running=!1)}}},Rs=(e,t,n,r)=>{let i=new Map(t.map(e=>[ks(e.path),e.id]));for(let t of e){let e=i.get(ks(t.projectDirectory));e&&r.isCurrent(n)&&Qe.getState().applyServerWorktreeOrder(e,t.orderedPaths,t.revision)}},zs=(e,t=Ns)=>{let n=null,r=()=>n?.abort();return{start:()=>{r(),n=new AbortController;let i=n.signal,a=t.captureRuntime();(async()=>{let n=0,r=500;for(;!i.aborted&&t.isCurrent(a);)try{let r=await t.fetchSnapshot(i);if(i.aborted||!t.isCurrent(a))return;n=r.revision;let o=e();Rs(r.worktreeOrders,o,a,t);let s=new Set(r.worktreeOrders.map(e=>ks(e.projectDirectory)));for(let e of o){let n=Qe.getState(),r=n.orderByProject[e.id];n.pendingProjectIDs[e.id]?Is(e.id,e.path,r??[],t):r?.length&&!s.has(ks(e.path))&&(n.markPendingWorktreeOrder(e.id),Is(e.id,e.path,r,t))}break}catch(e){if(As(e)!==`retry`)return;await t.sleep(r,i).catch(()=>{}),r=Math.min(r*2,Os)}for(;!i.aborted&&t.isCurrent(a);)try{let o=await t.waitInvalidation(n,{signal:i});if(i.aborted||!t.isCurrent(a)||o===`aborted`)return;let s=await(t.refreshSnapshot??t.fetchSnapshot)(i);if(i.aborted||!t.isCurrent(a))return;n=s.revision,Rs(s.worktreeOrders,e(),a,t),r=500}catch(e){if(As(e)!==`retry`)return;await t.sleep(r,i).catch(()=>{}),r=Math.min(r*2,Os)}})()},stop:r}},Bs=()=>{let e=(0,Z.c)(2),t=We(Hs),n;e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),X.useEffect(Gs,n)};function Vs(e){return[e.id,ks(e.path)]}function Hs(e){return JSON.stringify(e.projects.map(Vs))}function Us(e,t,n){return Is(e,t,n)}function Ws(){return We.getState().projects}function Gs(){let e=u();Qe.getState().activateWorktreeOrderRuntime(e);let t=qe(Us),n=zs(Ws);n.start();let r=c(e=>{p(e)&&(Fs(),Qe.getState().activateWorktreeOrderRuntime(u()),n.start())});return()=>{t(),r(),n.stop(),Fs()}}var Ks=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,qs=e=>{let t=!1,n=0,r=0,i=0,a=!1,o=new Set,s=new Map,c=new Map,l=new Map,u=new Map,d=new Set,f=new Set,p=new Map,m=new Set,h=new Set,g=new Set,_=``,v=[],y=(n,i=150,a=!1,c={})=>{let d=Ks(n.path);if(a&&(o.has(d)||s.has(d)||u.has(d)))return;let f=(l.get(d)??0)+1;l.set(d,f);let p=u.get(d);p&&e.clearTimer(p.timer);let m=r,h=e.setTimer(()=>{!t||m!==r||(u.delete(d),s.set(d,{project:n,refreshBatch:c,version:f}),b(m))},i);u.set(d,{timer:h,epoch:m})},b=(n=r)=>{if(!(!t||n!==r))for(;i<2&&s.size>0;){let n=[...s.entries()].find(([e])=>!o.has(e));if(!n)break;let[a,{project:u,refreshBatch:d,version:f}]=n;s.delete(a),i+=1,o.add(a);let h=e.generation(),_=r,v=()=>t&&_===r&&h===e.generation()&&l.get(a)===f;e.refresh(u,{isCurrent:v,refreshBatch:d}).then(t=>{if(v()){t.repositoryDirectory&&c.set(a,Ks(t.repositoryDirectory)),g.add(a);for(let n of t.addedDirectories){let t=Ks(n);(!e.needsSessionSync||e.needsSessionSync(t))&&m.add(t)}if(e.needsSessionSync)for(let n of t.worktrees){let t=Ks(n.path);e.needsSessionSync(t)&&m.add(t)}x(_,h),S()}}).then(()=>{v()&&p.delete(a)}).catch(()=>{if(!v())return;let e=(p.get(a)??0)+1;p.set(a,e),t&&_===r&&y(u,[1e3,2e3,5e3,15e3,3e4][Math.min(e-1,4)])}).finally(()=>{_===r&&(--i,o.delete(a),b(_))})}},x=(n,i)=>{if(m.size===0)return;let a=[...m];m.clear(),e.syncAdded(a).catch(()=>{if(t&&n===r&&i===e.generation()){for(let e of a)m.add(e);let o=e.setTimer(()=>{d.delete(o),t&&n===r&&x(n,i)},1e3);d.add(o)}})},S=()=>{if(g.size!==e.getProjects().length)return;let t=e.getCatalog();for(let e of h){let n=e.slice(e.indexOf(`:`)+1);[...t.entries()].some(([e,t])=>Ks(e)===n||t.some(e=>Ks(e.path)===n))||f.add(e)}},C=()=>{g.clear();let t={};for(let n of e.getProjects())y(n,0,!0,t)},w=()=>{let t=e.getCatalog(),r=e.getProjects(),i=new Set;for(let t of e.getActiveDirectories())t.trim()&&i.add(Ks(t));for(let e of[...h]){let t=e.slice(e.indexOf(`:`)+1);i.has(t)||h.delete(e)}for(let e of[...f]){let t=e.slice(e.indexOf(`:`)+1);i.has(t)||f.delete(e)}for(let e of i)if(!r.find(n=>{let r=Ks(n.path),i=t.get(r)?.some(t=>Ks(t.path)===e);return e===r||i})){let t=`${n}:${e}`;!f.has(t)&&!h.has(t)&&(h.add(t),C())}},T=()=>{r+=1,f.clear(),h.clear(),p.clear(),m.clear(),g.clear();for(let t of u.values())e.clearTimer(t.timer);u.clear();for(let t of d)e.clearTimer(t);d.clear(),s.clear(),o.clear(),i=0,c.clear(),l.clear()};return{start:()=>{t||e.isVSCode()||(t=!0,a=!1,v.push(e.subscribeEvents(i=>{if(i.type===`event-stream-ready`){if(!a){a=!0,C();return}n+=1,T(),C()}if(i.type===`worktree-topology-changed`&&i.projectDirectory){let n=Ks(i.projectDirectory),a={},o=c.get(n),s=e.getCatalog();for(let t of e.getProjects()){let e=Ks(t.path),r=s.get(e)?.some(t=>Ks(t.worktreeRoot??t.path)===n||t.relativePath&&e===`${n}/${t.relativePath}`),i=o&&c.has(e)?c.get(e)===o:r;(e===n||i)&&y(t,150,!1,a)}if(e.resolveRepository){let i=r,s=e.generation();(async()=>{let l=o??Ks(await e.resolveRepository(n));for(let n of e.getProjects()){let u=Ks(n.path);if(!(o&&c.has(u)))try{let o=c.get(u)??Ks(await e.resolveRepository(u));if(!t||i!==r||s!==e.generation())return;c.set(u,o),o===l&&y(n,150,!1,a)}catch{t&&i===r&&s===e.generation()&&y(n)}}})().catch(()=>{t&&i===r&&s===e.generation()&&C()})}}})),_=e.getProjects().map(e=>`${e.id}\u0000${Ks(e.path)}`).sort().join(`
6
+ `),v.push(e.subscribeProjects(()=>{let t=e.getProjects().map(e=>`${e.id}\u0000${Ks(e.path)}`).sort().join(`
7
+ `);t!==_&&(_=t,T(),C(),w())})),v.push(e.subscribeCatalog(w)),v.push(e.subscribeSessions(w)),v.push(e.subscribeRuntime(e=>{e&&(a=!1,n+=1,T(),C())})),C(),w())},stop:()=>{t=!1,T();for(let{timer:t}of u.values())e.clearTimer(t);for(u.clear(),s.clear(),i=0;v.length;)v.pop()?.()},reconcileAll:C}},Js=null,Ys=0,Xs=()=>(Js||=qs({isVSCode:te,getProjects:()=>We.getState().projects,getCatalog:()=>K.getState().availableWorktreesByProject,getActiveDirectories:()=>{let e=Ke.getState(),t=[];for(let n of e.activeSessions)typeof n.directory==`string`&&t.push(n.directory);for(let n of e.cachedDirectories)t.push(n);return t},needsSessionSync:e=>{let t=Ke.getState(),n=Ks(e);return!t.loadedDirectories.has(n)&&!t.loadingDirectories.has(n)&&!t.refreshingDirectories.has(n)},refresh:Ln,resolveRepository:Dt,syncAdded:e=>Ve(e,Ke.getState().activeSessions),subscribeProjects:e=>We.subscribe(e),subscribeCatalog:e=>K.subscribe((t,n)=>{t.availableWorktreesByProject!==n.availableWorktreesByProject&&e()}),subscribeSessions:e=>Ke.subscribe((t,n)=>{(t.activeSessions!==n.activeSessions||t.cachedDirectories!==n.cachedDirectories)&&e()}),subscribeEvents:Oe,subscribeRuntime:e=>c(t=>e(p(t))),generation:f,setTimer:(e,t)=>globalThis.setTimeout(e,t),clearTimer:e=>globalThis.clearTimeout(e)}),Ys+=1,Js.start(),()=>{Ys=Math.max(0,Ys-1),Ys===0&&Js?.stop()});function Zs(){if(O()?.runtime.isVSCode)return()=>{};let e=new we(Ae,zn()),t=Oe(e=>{(e.type===`speech-settings-changed`||e.type===`event-stream-ready`)&&Ae.invalidateQueries({queryKey:zn().queryKey,exact:!0})}),n=t=>{if(!t.data||e.options.queryKey[0]!==u())return;let n=G.getState();Object.entries(t.data).some(([e,t])=>n[e]!==t)&&G.setState(t.data)},r=e.subscribe(n);n(e.getCurrentResult());let i=c(()=>{G.setState(Ye),e.setOptions(zn()),n(e.getCurrentResult())});return()=>{i(),r(),t(),e.destroy()}}var Qs=`yuri:mini-chat-presence`,$s=()=>{let e=yn(),t=X.useRef(e.optimistic.add),n=X.useRef(e.optimistic.remove),r=X.useRef(e.optimistic.confirm);return t.current=e.optimistic.add,n.current=e.optimistic.remove,r.current=e.optimistic.confirm,X.useEffect(()=>{it(e=>t.current(e),e=>n.current(e),e=>r.current(e))},[]),X.useEffect(()=>Xs(),[]),null},ec=()=>{let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],X.useEffect(ic,t),null},tc=X.memo(function(e){let t=(0,Z.c)(3),{embeddedBackgroundWorkEnabled:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0],X.useEffect(Zs,r);let i=X.useSyncExternalStore(In,Mn,Mn);kn(n&&i===`legacy-enabled`),Nn();let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1],X.useEffect(ac,a);let o;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)($s,{}),t[2]=o):o=t[2],o}),nc=X.memo(function(e){let t=(0,Z.c)(6),{embeddedBackgroundWorkEnabled:n}=e;Ss(),Es(),Lo(),Bs();let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0],X.useEffect(oc,r);let i;t[1]===n?i=t[2]:(i=(0,Q.jsx)(tc,{embeddedBackgroundWorkEnabled:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(ec,{}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,Q.jsxs)(Q.Fragment,{children:[i,a]}),t[4]=i,t[5]=o),o});function rc(e){let t=e.data;if(t?.type!==`mini-chat-session-presence`||!t.sessionId||!t.directory)return;let n=t.viewed!==!1;Ge(t.directory,t.sessionId,n),n&&Xe(t.sessionId)}function ic(){if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(Qs);return e.onmessage=rc,()=>e.close()}function ac(){let e=On(),t=Fn();e.start(),t.start();let n=jn(e);return()=>{n(),t.stop(),e.stop()}}function oc(){uo()}var sc=new Set,cc=new Map,lc=(e,t)=>`https://cdn.jsdelivr.net/npm/${encodeURIComponent(e.packageName).replace(`%40`,`@`).replace(`%2F`,`/`)}/files/${e.filePrefix}-latin-${t}-normal.woff2`,uc=(e,t)=>{let n=`${e.family}:${t}`;if(sc.has(n))return Promise.resolve();let r=cc.get(n);if(r)return r;if(typeof document>`u`||typeof FontFace>`u`||!document.fonts)return Promise.resolve();let i=new FontFace(e.family,`url(${lc(e,t)}) format('woff2')`,{style:`normal`,weight:String(t),display:`swap`});document.fonts.add(i);let a=i.load().then(()=>{sc.add(n)}).catch(n=>{document.fonts.delete(i),console.warn(`Failed to load font: ${e.family} ${t}`,n)}).finally(()=>{cc.delete(n)});return cc.set(n,a),a},dc=e=>e?Promise.all(e.weights.map(t=>uc(e,t))).then(()=>void 0):Promise.resolve(),fc=e=>dc(Re[e]?.source),pc=e=>dc(Le[e]?.source),mc={family:`Syne`,packageName:`@fontsource/syne`,filePrefix:`syne`,weights:[700]},hc=()=>dc(mc);function gc(){let e=(0,Z.c)(4),{uiFont:t,monoFont:n}=Bn(),r,i;e[0]!==n||e[1]!==t?(r=()=>{if(typeof document>`u`)return;let e=document.documentElement,r=Re[t]?.stack??Re.system.stack,i=Le[n]?.stack??Le[`system-mono`].stack;fc(t),pc(n),e.style.setProperty(`--font-sans`,r),e.style.setProperty(`--font-heading`,r),e.style.setProperty(`--font-family-sans`,r),e.style.setProperty(`--font-mono`,i),e.style.setProperty(`--font-family-mono`,i),e.style.setProperty(`--ui-regular-font-weight`,`400`),document.body&&(document.body.style.fontFamily=r)},i=[t,n],e[0]=n,e[1]=t,e[2]=r,e[3]=i):(r=e[2],i=e[3]),X.useEffect(r,i)}export{ki as A,_a as C,Ui as D,Wi as E,Zn as F,qn as I,Wn as L,ri as M,Xr as N,zi as O,gr as P,Kn as R,xa as S,Xi as T,za as _,tc as a,ka as b,To as c,fo as d,po as f,Ba as g,Va as h,nc as i,ii as j,ji as k,Eo as l,Ka as m,hc as n,ko as o,to as p,fc as r,wo as s,gc as t,mo as u,Ha as v,ua as w,Da as x,Ra as y,Hn as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{X as t,j as n,k as r,st as i}from"./platform-B2ylz14u.js";import{H as a,ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{dr as c}from"./client-CmtAKi5B.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{D as d,W as f}from"./runtime-file-resource-BGZ4tGr5.js";import{r as p}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as m}from"./summaries-BQMyJaaw.js";import{r as h}from"./useUIStore-68ZPpgYA.js";import{Bi as g,Ga as _,Ha as v,Ii as y,K as b,Kr as x,Ni as S,Xn as C,f as w,io as T,t as E,tr as D}from"./ui-BqoDhEiW.js";import{n as O}from"./Icon-CUOVBCQn.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-BQzoY_Y9.js";import{t as ee}from"./i18n-Sh2Qk9nD.js";import{i as M,n as N,t as P}from"./tooltip-B9I9lmf0.js";import{c as F,n as I,t as L}from"./dropdown-menu-W3Ii298F.js";import{s as R}from"./useGitStore-Dvd_1jyD.js";import{_ as z,w as B,y as V}from"./pwa-CLwERclR.js";import{t as te}from"./MobileOverlayPanel-DLDL_a6S.js";import{l as ne,r as re}from"./quota-jMPnmJTS.js";import{n as H,t as U}from"./sessionChangeSummary-BCF9VwAA.js";import{n as W}from"./openRemoteProjectSession-DPb8H79n.js";var G=l(),K=e(s(),1),q=o(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:_}=e,v=n!==void 0&&n,y=c===void 0?`default`:c,b=l!==void 0&&l,x=u!==void 0&&u,S=d!==void 0&&d,C=f===void 0?`default`:f,w=_!==void 0&&_,{t:E}=ee(),[D,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==C||t[1]!==A||t[2]!==o||t[3]!==b||t[4]!==g||t[5]!==s||t[6]!==v||t[7]!==h||t[8]!==i||t[9]!==E||t[10]!==r){let e=v?0:re(i)??0;U=C===`subtle`;let n=ne(A);W=U||v?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===v?a=t[33]:(a=e=>v?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=v,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==v||t[36]!==i||t[37]!==J||t[38]!==E||t[39]!==r?(Q=v?E(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=v?`—`:B(r),z=B(o),c=v?[E(`contextUsage.pendingDescription`)]:[E(`contextUsage.tooltip.usage`,{percent:Q}),E(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),E(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=v,t[36]=i,t[37]=J,t[38]=E,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!b&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=T(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===E?Y=t[48]:(Y=E(`contextUsage.aria.label`),t[47]=E,t[48]=Y),t[49]!==v||t[50]!==E?(X=v?E(`contextUsage.pending`):void 0,t[49]=v,t[50]=E,t[51]=X):X=t[51],se=v?void 0:Math.round(e),t[0]=C,t[1]=A,t[2]=o,t[3]=b,t[4]=g,t[5]=s,t[6]=v,t[7]=h,t[8]=i,t[9]=E,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=w||v?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=T(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==x||t[89]!==b||t[90]!==U||t[91]!==v||t[92]!==i||t[93]!==_e||t[94]!==S||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!b&&!x&&(0,q.jsx)(O,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:T(`font-medium inline-flex items-center gap-1.5`,m),children:v?(0,q.jsxs)(q.Fragment,{children:[S&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):S?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=x,t[89]=b,t[90]=U,t[91]=v,t[92]=i,t[93]=_e,t[94]=S,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=y===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==w||t[103]!==De||t[104]!==Oe?(ke=T(`app-region-no-drag flex items-center select-none`,De,Oe,H?T(`group rounded-md text-foreground transition-colors`,U?T(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,w&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=w,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==b||t[109]!==g||t[110]!==w||t[111]!==Ae||t[112]!==E?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":E(`contextUsage.aria.label`),"aria-pressed":w,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":E(`contextUsage.aria.label`),onClick:b?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=b,t[109]=g,t[110]=w,t[111]=Ae,t[112]=E,t[113]=je):je=t[113];let Me=je;if(b){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===E?n=t[116]:(n=E(`contextUsage.mobile.title`),t[115]=E,t[116]=n);let r;t[117]===E?r=t[118]:(r=E(`contextUsage.mobile.usedTokens`),t[117]=E,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===E?s=t[127]:(s=E(`contextUsage.mobile.contextLimit`),t[126]=E,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===E?d=t[136]:(d=E(`contextUsage.mobile.outputLimit`),t[135]=E,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===E?g=t[148]:(g=E(`contextUsage.mobile.usage`),t[147]=E,t[148]=g);let _;t[149]===g?_=t[150]:(_=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=_);let v;t[151]!==A||t[152]!==V?(v=T(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=v):v=t[153];let y;t[154]!==v||t[155]!==Q?(y=(0,q.jsx)(`span`,{className:v,children:Q}),t[154]=v,t[155]=Q,t[156]=y):y=t[156];let b;t[157]!==_||t[158]!==y?(b=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[_,y]}),t[157]=_,t[158]=y,t[159]=b):b=t[159];let x;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==b?(x=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,b]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=b,t[164]=x):x=t[164];let S;t[165]!==D||t[166]!==n||t[167]!==x?(S=(0,q.jsx)(te,{open:D,onClose:e,title:n,children:x}),t[165]=D,t[166]=n,t[167]=x,t[168]=S):S=t[168];let C;return t[169]!==Me||t[170]!==S?(C=(0,q.jsxs)(q.Fragment,{children:[Me,S]}),t[169]=Me,t[170]=S,t[171]=C):C=t[171],C}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=y(ce),s=v(Z),c=g(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>B(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(S(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>z(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let _=K.useRef(h),b;n[18]===m?b=n[19]:(b=e=>{let t=_.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),_.current=r,r},n[18]=m,n[19]=b);let x=R(b),C;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],C=e;break bb1}let t;if(n[21]!==o||n[22]!==x||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>z(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=S(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>z(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=S(e),n=f(t),r=X(n),i=t?x.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=x,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];C=t}return C};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return S(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=T(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let _;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(_=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=_):_=t[17],_}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=v(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,o;t[0]===i?o=t[1]:(o={scopeProjectId:i},t[0]=i,t[1]=o);let s=se(!0,o),c=w(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=p(d),m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=new Set,t[6]=m):m=t[6];let[g,_]=K.useState(m),v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=v):v=t[7];let y=p(v),b,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=T(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),x=(0,q.jsx)(O,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=b,t[9]=x):(b=t[8],x=t[9]);let S;t[10]===u?S=t[11]:(S=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=S);let C;t[12]===S?C=t[13]:(C=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:S}),t[12]=S,t[13]=C);let E;t[14]!==f||t[15]!==C?(E=(0,q.jsxs)(a,{onClick:f,className:b,children:[x,C]}),t[14]=f,t[15]=C,t[16]=E):E=t[16];let D;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==y||t[22]!==r?(D=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:y,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=y,t[22]=r,t[23]=D):D=t[23];let k;return t[24]!==D||t[25]!==E?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[E,D]})}),t[24]=D,t[25]=E,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=p(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let m=f,h,g;t[12]!==m||t[13]!==r||t[14]!==i?(h=()=>{m&&E.error(m,{id:`remote-switcher:${i}:${r}:catalog`})},g=[m,i,r],t[12]=m,t[13]=r,t[14]=i,t[15]=h,t[16]=g):(h=t[15],g=t[16]),K.useEffect(h,g);let _;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(_=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(C,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=_):_=t[23],_}async function we(){try{await A()}catch(e){let t=e;E.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),o=d(e,t.hostId),s=j(e,t.hostId),c=v(e=>e.projects),l=_(e=>e.remoteSession),u=h(e=>e.isMobile),f=s.data,g=o?.state===`connected`&&t.remoteState===`ok`&&!f?.stale,y=K.useMemo(()=>{let n=new Set(f?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,m(c,e.hubId,t.hostId,n,f?.worktrees)?.id===t.id),r.get(n));return(f?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>z(e.session,t.session,n)).slice(0,7)},[f,c,t.hostId,t.id,e.hubId]),b=s.error?.message,{refetch:x}=s;K.useEffect(()=>{b&&E.error(b,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[b,t.id,x,i]);let S=p((r,a)=>{try{if(m(c,e.hubId,t.hostId,a,f?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){E.error(e instanceof Error?e.message:String(e))}}),C=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(a,{onClick:()=>S(null,C),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(O,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${o?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!y.length&&f?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,y.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:f,online:g,navigate:S,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:a,snapshot:o,online:s,navigate:l,selected:d,depth:h,ancestors:g}){let{t:_}=ee(),[v,y]=K.useState(!1),[b,x]=K.useState(30),S=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,S),enabled:!1,staleTime:1/0,gcTime:1/0}),[S,i]),T=u(w,f).data?.current,O=u({queryKey:[...S.queryScope,`navigation-children`,r.id,b],enabled:v&&s,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&S.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[S.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],a,o=!1;for(let s=0;s<Math.ceil(b/30);s++){let s=await S.sdk().session.list({directory:i,parentID:r.id,limit:30,...a?{cursor:a}:{}},{signal:t});if(e.assertCurrent(),S.sdk(),!Array.isArray(s.data))throw Error(`Remote child session list returned no data`);n.push(...s.data.map(c).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=s.cursor?.next||void 0;if(o=!!(l&&l!==a),!o)break;a=l}return{sessions:n,hasMore:o}}},f),{error:k,refetch:A}=O;K.useEffect(()=>{k&&E.error(k.message,{id:`remote-children:${S.key}:${r.id}`,action:{label:_(`remoteProjects.retry`),onClick:()=>void A()}})},[k,S.key,r.id,A,_]);let j=p(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&f.invalidateQueries({queryKey:[...S.queryScope,`navigation-children`,r.id,b],exact:!0})});K.useEffect(()=>{if(v&&s)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,v,s,j]);let M=o?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(O.data?.sessions??M).filter(a=>a.id!==r.id&&!g.includes(a.id)&&m(n,e.hubId,t.hostId,a.directory||i,o?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=d?.projectId===t.id&&d.location.hubId===e.hubId&&d.location.hostId===t.hostId&&d.location.directory===i&&d.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:a,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:v,onToggleExpand:()=>y(e=>!e),isActive:F,unseenCount:o?.unread?.sessions[r.id]?.unreadCount??0,statusType:s?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),v?(0,q.jsxs)(q.Fragment,{children:[N.map(c=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:a,snapshot:o,online:s,navigate:l,selected:d,directory:c.directory||i,session:c,depth:h+1,ancestors:[...g,r.id]},c.id)),O.data?.hasMore?(0,q.jsx)(C,{size:`xs`,variant:`ghost`,disabled:!s||O.isFetching,onClick:()=>x(e=>e+30),children:_(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=w(Ae),d=w(ke),f=b(n.id),m=x(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,S(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=p(g),v=f?.type??`idle`,y;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==m||t[15]!==i?(y=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:m,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=m,t[15]=i,t[16]=y):y=t[16],y}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:o,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,_;t[3]===n?_=t[4]:(_=U(H(n)),t[3]=n,t[4]=_);let v=_,y=!!n.parentID,b=d>0&&!y,x=f===`busy`||f===`retry`,S=!x&&b,C;t[5]!==n.time?.created||t[6]!==n.time?.updated?(C=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=C):C=t[7];let w=C,E;t[8]===w?E=t[9]:(E=V(w),t[8]=w,t[9]=E);let D=E,k;t[10]===o?.projectLabel?k=t[11]:(k=o?.projectLabel?.trim()||null,t[10]=o?.projectLabel,t[11]=k);let A=k,j;t[12]===o?.branchLabel?j=t[13]:(j=o?.branchLabel?.trim()||null,t[12]=o?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=T(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(O,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(O,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,B;t[25]===z?B=t[26]:(B=T(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=B);let te;t[27]!==g||t[28]!==B?(te=(0,q.jsx)(`span`,{className:B,children:g}),t[27]=g,t[28]=B,t[29]=te):te=t[29];let ne;t[30]===v?ne=t[31]:(ne=v?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:v}):null,t[30]=v,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==D||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(O,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(O,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:D}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(O,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=D,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==x||t[49]!==S||t[50]!==m?(J=x||S?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:x?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=x,t[49]=S,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(a,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=T(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,_;t[5]===g?_=t[6]:(_=T(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=_);let v=_,y;t[7]===s?y=t[8]:(y=s(`header.windowControls.groupAria`),t[7]=s,t[8]=y);let b;t[9]===s?b=t[10]:(b=s(`header.windowControls.minimize`),t[9]=s,t[10]=b);let x;t[11]===s?x=t[12]:(x=s(`header.windowControls.minimize`),t[11]=s,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,q.jsx)(O,{name:`subtract`,className:`h-4 w-4`}),t[13]=S):S=t[13];let C;t[14]!==x||t[15]!==b?(C=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:b,"aria-label":x,children:S}),t[14]=x,t[15]=b,t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=w):w=t[17];let E;t[18]!==c||t[19]!==s?(E=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=E):E=t[20];let D;t[21]!==c||t[22]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=D):D=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(O,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==E||t[27]!==D||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:w,title:E,"aria-label":D,children:A}),t[26]=E,t[27]=D,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=T(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(O,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==v||t[40]!==C||t[41]!==j||t[42]!==I||t[43]!==y?(L=(0,q.jsxs)(`div`,{className:v,"aria-label":y,children:[C,j,I]}),t[39]=v,t[40]=C,t[41]=j,t[42]=I,t[43]=y,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{X as t,j as n,k as r,st as i}from"./platform-B2ylz14u.js";import{dr as a}from"./client-A12QacVZ.js";import{H as o,ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{D as d,W as f}from"./runtime-file-resource-BGZ4tGr5.js";import{r as p}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as m}from"./summaries-BQMyJaaw.js";import{r as h}from"./useUIStore-68ZPpgYA.js";import{Bi as g,Ga as _,Ha as v,Ii as y,K as b,Kr as x,Ni as S,Xn as C,f as w,io as T,t as E,tr as D}from"./ui-l6IO9PTO.js";import{n as O}from"./Icon-EsiJulCS.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-Dq2vrCZs.js";import{t as ee}from"./i18n-G4mBbEvx.js";import{i as M,n as N,t as P}from"./tooltip-C3xkMhqj.js";import{c as F,n as I,t as L}from"./dropdown-menu-DYZL6MMz.js";import{s as R}from"./useGitStore-n7r0qj_Y.js";import{T as z,b as B,v as V}from"./pwa-BJKKdnmb.js";import{t as te}from"./MobileOverlayPanel-BSoJXidn.js";import{d as ne,r as re}from"./quota-kI30nh9N.js";import{n as H,t as U}from"./sessionChangeSummary-BCF9VwAA.js";import{n as W}from"./openRemoteProjectSession-BWUT1ORe.js";var G=l(),K=e(c(),1),q=s(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:_}=e,v=n!==void 0&&n,y=c===void 0?`default`:c,b=l!==void 0&&l,x=u!==void 0&&u,S=d!==void 0&&d,C=f===void 0?`default`:f,w=_!==void 0&&_,{t:E}=ee(),[D,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==C||t[1]!==A||t[2]!==o||t[3]!==b||t[4]!==g||t[5]!==s||t[6]!==v||t[7]!==h||t[8]!==i||t[9]!==E||t[10]!==r){let e=v?0:re(i)??0;U=C===`subtle`;let n=ne(A);W=U||v?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===v?a=t[33]:(a=e=>v?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=v,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==v||t[36]!==i||t[37]!==J||t[38]!==E||t[39]!==r?(Q=v?E(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=v?`—`:B(r),z=B(o),c=v?[E(`contextUsage.pendingDescription`)]:[E(`contextUsage.tooltip.usage`,{percent:Q}),E(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),E(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=v,t[36]=i,t[37]=J,t[38]=E,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!b&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=T(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===E?Y=t[48]:(Y=E(`contextUsage.aria.label`),t[47]=E,t[48]=Y),t[49]!==v||t[50]!==E?(X=v?E(`contextUsage.pending`):void 0,t[49]=v,t[50]=E,t[51]=X):X=t[51],se=v?void 0:Math.round(e),t[0]=C,t[1]=A,t[2]=o,t[3]=b,t[4]=g,t[5]=s,t[6]=v,t[7]=h,t[8]=i,t[9]=E,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=w||v?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=T(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==x||t[89]!==b||t[90]!==U||t[91]!==v||t[92]!==i||t[93]!==_e||t[94]!==S||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!b&&!x&&(0,q.jsx)(O,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:T(`font-medium inline-flex items-center gap-1.5`,m),children:v?(0,q.jsxs)(q.Fragment,{children:[S&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):S?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=x,t[89]=b,t[90]=U,t[91]=v,t[92]=i,t[93]=_e,t[94]=S,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=y===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==w||t[103]!==De||t[104]!==Oe?(ke=T(`app-region-no-drag flex items-center select-none`,De,Oe,H?T(`group rounded-md text-foreground transition-colors`,U?T(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,w&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=w,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==b||t[109]!==g||t[110]!==w||t[111]!==Ae||t[112]!==E?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":E(`contextUsage.aria.label`),"aria-pressed":w,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":E(`contextUsage.aria.label`),onClick:b?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=b,t[109]=g,t[110]=w,t[111]=Ae,t[112]=E,t[113]=je):je=t[113];let Me=je;if(b){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===E?n=t[116]:(n=E(`contextUsage.mobile.title`),t[115]=E,t[116]=n);let r;t[117]===E?r=t[118]:(r=E(`contextUsage.mobile.usedTokens`),t[117]=E,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===E?s=t[127]:(s=E(`contextUsage.mobile.contextLimit`),t[126]=E,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===E?d=t[136]:(d=E(`contextUsage.mobile.outputLimit`),t[135]=E,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===E?g=t[148]:(g=E(`contextUsage.mobile.usage`),t[147]=E,t[148]=g);let _;t[149]===g?_=t[150]:(_=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=_);let v;t[151]!==A||t[152]!==V?(v=T(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=v):v=t[153];let y;t[154]!==v||t[155]!==Q?(y=(0,q.jsx)(`span`,{className:v,children:Q}),t[154]=v,t[155]=Q,t[156]=y):y=t[156];let b;t[157]!==_||t[158]!==y?(b=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[_,y]}),t[157]=_,t[158]=y,t[159]=b):b=t[159];let x;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==b?(x=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,b]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=b,t[164]=x):x=t[164];let S;t[165]!==D||t[166]!==n||t[167]!==x?(S=(0,q.jsx)(te,{open:D,onClose:e,title:n,children:x}),t[165]=D,t[166]=n,t[167]=x,t[168]=S):S=t[168];let C;return t[169]!==Me||t[170]!==S?(C=(0,q.jsxs)(q.Fragment,{children:[Me,S]}),t[169]=Me,t[170]=S,t[171]=C):C=t[171],C}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=y(ce),s=v(Z),c=g(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>z(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(S(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>V(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let _=K.useRef(h),b;n[18]===m?b=n[19]:(b=e=>{let t=_.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),_.current=r,r},n[18]=m,n[19]=b);let x=R(b),C;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],C=e;break bb1}let t;if(n[21]!==o||n[22]!==x||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>V(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=S(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>V(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=S(e),n=f(t),r=X(n),i=t?x.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=x,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];C=t}return C};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return S(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=T(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let _;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(_=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=_):_=t[17],_}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=v(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a={scopeProjectId:i},t[0]=i,t[1]=a);let s=se(!0,a),c=w(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=p(d),m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=new Set,t[6]=m):m=t[6];let[g,_]=K.useState(m),v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=v):v=t[7];let y=p(v),b,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=T(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),x=(0,q.jsx)(O,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=b,t[9]=x):(b=t[8],x=t[9]);let S;t[10]===u?S=t[11]:(S=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=S);let C;t[12]===S?C=t[13]:(C=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:S}),t[12]=S,t[13]=C);let E;t[14]!==f||t[15]!==C?(E=(0,q.jsxs)(o,{onClick:f,className:b,children:[x,C]}),t[14]=f,t[15]=C,t[16]=E):E=t[16];let D;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==y||t[22]!==r?(D=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:y,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=y,t[22]=r,t[23]=D):D=t[23];let k;return t[24]!==D||t[25]!==E?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[E,D]})}),t[24]=D,t[25]=E,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=p(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let m=f,h,g;t[12]!==m||t[13]!==r||t[14]!==i?(h=()=>{m&&E.error(m,{id:`remote-switcher:${i}:${r}:catalog`})},g=[m,i,r],t[12]=m,t[13]=r,t[14]=i,t[15]=h,t[16]=g):(h=t[15],g=t[16]),K.useEffect(h,g);let _;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(_=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(C,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=_):_=t[23],_}async function we(){try{await A()}catch(e){let t=e;E.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),a=d(e,t.hostId),s=j(e,t.hostId),c=v(e=>e.projects),l=_(e=>e.remoteSession),u=h(e=>e.isMobile),f=s.data,g=a?.state===`connected`&&t.remoteState===`ok`&&!f?.stale,y=K.useMemo(()=>{let n=new Set(f?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,m(c,e.hubId,t.hostId,n,f?.worktrees)?.id===t.id),r.get(n));return(f?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>V(e.session,t.session,n)).slice(0,7)},[f,c,t.hostId,t.id,e.hubId]),b=s.error?.message,{refetch:x}=s;K.useEffect(()=>{b&&E.error(b,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[b,t.id,x,i]);let S=p((r,a)=>{try{if(m(c,e.hubId,t.hostId,a,f?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){E.error(e instanceof Error?e.message:String(e))}}),C=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(o,{onClick:()=>S(null,C),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(O,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${a?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!y.length&&f?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,y.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:f,online:g,navigate:S,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:o,snapshot:s,online:c,navigate:l,selected:d,depth:h,ancestors:g}){let{t:_}=ee(),[v,y]=K.useState(!1),[b,x]=K.useState(30),S=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,S),enabled:!1,staleTime:1/0,gcTime:1/0}),[S,i]),T=u(w,f).data?.current,O=u({queryKey:[...S.queryScope,`navigation-children`,r.id,b],enabled:v&&c,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&S.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[S.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],o,s=!1;for(let c=0;c<Math.ceil(b/30);c++){let c=await S.sdk().session.list({directory:i,parentID:r.id,limit:30,...o?{cursor:o}:{}},{signal:t});if(e.assertCurrent(),S.sdk(),!Array.isArray(c.data))throw Error(`Remote child session list returned no data`);n.push(...c.data.map(a).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=c.cursor?.next||void 0;if(s=!!(l&&l!==o),!s)break;o=l}return{sessions:n,hasMore:s}}},f),{error:k,refetch:A}=O;K.useEffect(()=>{k&&E.error(k.message,{id:`remote-children:${S.key}:${r.id}`,action:{label:_(`remoteProjects.retry`),onClick:()=>void A()}})},[k,S.key,r.id,A,_]);let j=p(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&f.invalidateQueries({queryKey:[...S.queryScope,`navigation-children`,r.id,b],exact:!0})});K.useEffect(()=>{if(v&&c)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,v,c,j]);let M=s?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(O.data?.sessions??M).filter(a=>a.id!==r.id&&!g.includes(a.id)&&m(n,e.hubId,t.hostId,a.directory||i,s?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=d?.projectId===t.id&&d.location.hubId===e.hubId&&d.location.hostId===t.hostId&&d.location.directory===i&&d.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:o,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:v,onToggleExpand:()=>y(e=>!e),isActive:F,unseenCount:s?.unread?.sessions[r.id]?.unreadCount??0,statusType:c?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),v?(0,q.jsxs)(q.Fragment,{children:[N.map(a=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:o,snapshot:s,online:c,navigate:l,selected:d,directory:a.directory||i,session:a,depth:h+1,ancestors:[...g,r.id]},a.id)),O.data?.hasMore?(0,q.jsx)(C,{size:`xs`,variant:`ghost`,disabled:!c||O.isFetching,onClick:()=>x(e=>e+30),children:_(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=w(Ae),d=w(ke),f=b(n.id),m=x(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,S(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=p(g),v=f?.type??`idle`,y;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==m||t[15]!==i?(y=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:m,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=m,t[15]=i,t[16]=y):y=t[16],y}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,_;t[3]===n?_=t[4]:(_=U(H(n)),t[3]=n,t[4]=_);let v=_,y=!!n.parentID,b=d>0&&!y,x=f===`busy`||f===`retry`,S=!x&&b,C;t[5]!==n.time?.created||t[6]!==n.time?.updated?(C=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=C):C=t[7];let w=C,E;t[8]===w?E=t[9]:(E=B(w),t[8]=w,t[9]=E);let D=E,k;t[10]===a?.projectLabel?k=t[11]:(k=a?.projectLabel?.trim()||null,t[10]=a?.projectLabel,t[11]=k);let A=k,j;t[12]===a?.branchLabel?j=t[13]:(j=a?.branchLabel?.trim()||null,t[12]=a?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=T(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(O,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(O,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,V;t[25]===z?V=t[26]:(V=T(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=V);let te;t[27]!==g||t[28]!==V?(te=(0,q.jsx)(`span`,{className:V,children:g}),t[27]=g,t[28]=V,t[29]=te):te=t[29];let ne;t[30]===v?ne=t[31]:(ne=v?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:v}):null,t[30]=v,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==D||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(O,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(O,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:D}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(O,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=D,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==x||t[49]!==S||t[50]!==m?(J=x||S?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:x?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=x,t[49]=S,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(o,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=T(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,_;t[5]===g?_=t[6]:(_=T(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=_);let v=_,y;t[7]===s?y=t[8]:(y=s(`header.windowControls.groupAria`),t[7]=s,t[8]=y);let b;t[9]===s?b=t[10]:(b=s(`header.windowControls.minimize`),t[9]=s,t[10]=b);let x;t[11]===s?x=t[12]:(x=s(`header.windowControls.minimize`),t[11]=s,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,q.jsx)(O,{name:`subtract`,className:`h-4 w-4`}),t[13]=S):S=t[13];let C;t[14]!==x||t[15]!==b?(C=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:b,"aria-label":x,children:S}),t[14]=x,t[15]=b,t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=w):w=t[17];let E;t[18]!==c||t[19]!==s?(E=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=E):E=t[20];let D;t[21]!==c||t[22]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=D):D=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(O,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==E||t[27]!==D||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:w,title:E,"aria-label":D,children:A}),t[26]=E,t[27]=D,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=T(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(O,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==v||t[40]!==C||t[41]!==j||t[42]!==I||t[43]!==y?(L=(0,q.jsxs)(`div`,{className:v,"aria-label":y,children:[C,j,I]}),t[39]=v,t[40]=C,t[41]=j,t[42]=I,t[43]=y,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};