@yuriai/web 0.3.7 → 0.3.8-beta.4
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.
- package/README.md +5 -3
- package/dist/assets/{AgentAvatar-4HfTeQK1.js → AgentAvatar-DQahgz6W.js} +1 -1
- package/dist/assets/{AgentSelector-Db0C7nfY.js → AgentSelector-CQAUsIHb.js} +1 -1
- package/dist/assets/{ArchivedSessionsDialog-Cja7TIg6.js → ArchivedSessionsDialog-B9oCRtSW.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-Cg0Z0laN.js → AssistantConversationSurface-B8rYx0nb.js} +3 -3
- package/dist/assets/{AssistantSessionCard-CRaYbAwR.js → AssistantSessionCard-C_rD9JKw.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-B0XaBtKU.js → AssistantUnreadBadge-BMdRVBJx.js} +1 -1
- package/dist/assets/AssistantView-cr9bTXPb.js +1 -0
- package/dist/assets/{AssistantWorkingAvatar-QmEGmd3p.js → AssistantWorkingAvatar-CPgSMbqx.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-SynpDBbu.js → AssistantsSettingsPage-B0m1fbio.js} +1 -1
- package/dist/assets/{BinaryFileFallback-CLr78pii.js → BinaryFileFallback-BWLSh4aQ.js} +1 -1
- package/dist/assets/{BtwPanel-eNUn2HxV.js → BtwPanel-C2Zj9shf.js} +1 -1
- package/dist/assets/{BusyDots-CGTf_jqS.js → BusyDots-BNeYGoxJ.js} +1 -1
- package/dist/assets/{ChatContainer-DUJRc6kx.js → ChatContainer-DDKY-fow.js} +4 -4
- package/dist/assets/{ChatView-DJnxvyiB.js → ChatView-C1Hu4sr0.js} +1 -1
- package/dist/assets/{DiagramView-BQ_5mLmc.js → DiagramView-C_mC_LvJ.js} +1 -1
- package/dist/assets/{DiffView-KE3aMklA.js → DiffView-CneDl1JW.js} +1 -1
- package/dist/assets/{DiffViewToggle-B-fDu13M.js → DiffViewToggle-DxTIprpm.js} +1 -1
- package/dist/assets/{ErrorBoundary-BMkurwx0.js → ErrorBoundary-CyUuGOzH.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BNxn8bBO.js → FadeInOnReveal-CZacMUJf.js} +1 -1
- package/dist/assets/{GuiPluginMount-CcxWjZGn.js → GuiPluginMount-CD9acYWN.js} +1 -1
- package/dist/assets/{GuiPluginPage-B6DZGRf5.js → GuiPluginPage-ggAcwLBX.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CZ-rTgd0.js → GuiPluginSurface-DCgCy3-A.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-ByapzQyJ.js → GuiPluginTitlebarItems-DBpWZ8tI.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DtZqX_qS.js → GuiPluginWindow-DvK6aucF.js} +1 -1
- package/dist/assets/{Icon-CUOVBCQn.js → Icon-hrdOSdw7.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-ON75MLXx.js → ImageLoadingPlaceholder-DyhvQsbH.js} +1 -1
- package/dist/assets/{LoadingImage-CE1QZoPZ.js → LoadingImage-CWtpvtMJ.js} +1 -1
- package/dist/assets/MarkdownRenderer-LxzshJFz.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-SH7kLqNr.js → MarkdownRendererImpl-B2W1Ms4P.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-kWCEeJ84.js → MarkstreamRendererImpl-QC_ixefX.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-DkSgJLH5.js → MobileAssistantSettingsPage-BVV_Juge.js} +1 -1
- package/dist/assets/{MobileAssistantTab-DlreBfpD.js → MobileAssistantTab-Dtfwui9h.js} +1 -1
- package/dist/assets/{MobileBtwPage-DUOHjbOb.js → MobileBtwPage-DkwKIpyM.js} +1 -1
- package/dist/assets/{MobileChangesSurface-s-IkQzDj.js → MobileChangesSurface-B3Sx3f6N.js} +1 -1
- package/dist/assets/{MobileChatScreen-RJicegCg.js → MobileChatScreen-C0eRERQZ.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-B0Xb37E5.js → MobileDetailNavigation-DUrDQU8T.js} +1 -1
- package/dist/assets/{MobileFilesSurface-CR7C7ern.js → MobileFilesSurface-DEYSi4q_.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-CG4kdWvo.js → MobileHtmlNetworkBoundary-DwVi2y5V.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-DLDL_a6S.js → MobileOverlayPanel-CJ4CsOHE.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BTsMGacb.js → MobileResizableSheet-D85c-vYd.js} +1 -1
- package/dist/assets/{MobileSettingsTab-DIqufnwp.js → MobileSettingsTab-BmOymEFP.js} +1 -1
- package/dist/assets/{MobileShareBridge-BgAD2FqK.js → MobileShareBridge-DrDv_1IU.js} +1 -1
- package/dist/assets/{MobileSurface-D_9tJDu_.js → MobileSurface-Dm0xTV-5.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-CPEY1sVL.js → MobileTabPageHeader-BC7K7_gn.js} +1 -1
- package/dist/assets/{ModelLogo-CoEkCK6k.js → ModelLogo-CY3iE4qx.js} +1 -1
- package/dist/assets/{ModelSelector-CdSx-1l3.js → ModelSelector-C7kyXQ9H.js} +1 -1
- package/dist/assets/{MultiRunWindow-08NX-bpU.js → MultiRunWindow-CD6qcH5-.js} +1 -1
- package/dist/assets/{OnboardingScreen-DW4PQZ48.js → OnboardingScreen-EDIhAqeK.js} +1 -1
- package/dist/assets/{OverlayScrollbar-D4U670-p.js → OverlayScrollbar-DciAoWmX.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CU2O_Gqy.js → PierreDiffViewer-Mw9WqNgH.js} +1 -1
- package/dist/assets/{ProviderLogo-C9ON1xS-.js → ProviderLogo-DVv4dlal.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-44WC5u9f.js → RemoteAssistantSessionCard-C9G8_T8N.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-BfdjP2Ug.js → RemoteDesktopPanel-CGmMgJj-.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-p2z6x4k7.js → ScheduledTasksDialog-Cvgu-awq.js} +1 -1
- package/dist/assets/{ScrollableOverlay-B5Mx_IrY.js → ScrollableOverlay-eu-28p0g.js} +1 -1
- package/dist/assets/{SettingsGroup-Bd0hGXKp.js → SettingsGroup-DR9IIe1G.js} +1 -1
- package/dist/assets/{SettingsView-BbEPSEy3.js → SettingsView-Bw2deXoc.js} +1 -1
- package/dist/assets/{SettingsWindow-DO2ySMZ8.js → SettingsWindow-BH7mfEqr.js} +1 -1
- package/dist/assets/{SetupTourDialog-Bm0scCiD.js → SetupTourDialog-DN6ZFIdW.js} +1 -1
- package/dist/assets/{SyncActions-ktq_QbjA.js → SyncActions-DUiPgXWp.js} +1 -1
- package/dist/assets/{TerminalView-tXyVGRwg.js → TerminalView-Ctim95iK.js} +1 -1
- package/dist/assets/{TextSelectionMenu-CCsFVQha.js → TextSelectionMenu-C5dGvNub.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BX3Vi-k5.js → ToolOutputDialog-CKW0Y7tX.js} +1 -1
- package/dist/assets/{YuriLogo-1yVZFnVN.js → YuriLogo-CwUks1oQ.js} +1 -1
- package/dist/assets/{assistantMessagePreview-Bh2bPUPh.js → assistantMessagePreview-u0WDxQmn.js} +1 -1
- package/dist/assets/{assistantQueries-9sjQcHoO.js → assistantQueries-BzuSM6J9.js} +1 -1
- package/dist/assets/{auto-read-context-JBvQYPyM.js → auto-read-context-Dc7DiaAt.js} +1 -1
- package/dist/assets/{capgoAdapter-llXcw7v2.js → capgoAdapter-C9eRPvhA.js} +1 -1
- package/dist/assets/{card-YOYJB2Bf.js → card-q4RNJ9-a.js} +1 -1
- package/dist/assets/{chatUpwardIntent-Z6bMNkax.js → chatUpwardIntent-tFsDuqKZ.js} +1 -1
- package/dist/assets/{checkbox-ByuwPnuS.js → checkbox-Bgn_6HLp.js} +1 -1
- package/dist/assets/{collapsible-ByaFR6Oc.js → collapsible-BVu3YJOB.js} +1 -1
- package/dist/assets/{connection-hint-DugoAaao.js → connection-hint-gFtwcaS0.js} +1 -1
- package/dist/assets/{context-menu-DKL8DaT6.js → context-menu-DhyZwlqz.js} +1 -1
- package/dist/assets/{diagram-DkVURCJZ.js → diagram-CSmQ9dxP.js} +1 -1
- package/dist/assets/{dialog-CQbyU8pU.js → dialog-C_FAAyAo.js} +1 -1
- package/dist/assets/{dropdown-menu-W3Ii298F.js → dropdown-menu-ClVMhIUI.js} +1 -1
- package/dist/assets/{es-C1spVk4O.js → es-Bun7ffim.js} +2 -2
- package/dist/assets/{fileMentionTouchSelection-CwTAmgan.js → fileMentionTouchSelection-Dy9C4mwB.js} +1 -1
- package/dist/assets/{fr-yyP7Hlty.js → fr-DW8P_a9_.js} +2 -2
- package/dist/assets/{gitApi-droqYZ9A.js → gitApi-CqYtA25T.js} +1 -1
- package/dist/assets/{i18n-Sh2Qk9nD.js → i18n-Cl6MPHiF.js} +1 -1
- package/dist/assets/{icons-CLvvQeAy.js → icons-Bci77Q3R.js} +1 -1
- package/dist/assets/{input-DSdEvspA.js → input-BjYTPnlP.js} +1 -1
- package/dist/assets/{insertionBoundaries-Bf3EMWj8.js → insertionBoundaries-DgtYyA-t.js} +1 -1
- package/dist/assets/{ja-ChftrfCh.js → ja-CMg6JDzO.js} +2 -2
- package/dist/assets/{kbd-hp3-RDSe.js → kbd-B8llf0CR.js} +1 -1
- package/dist/assets/{ko-BrLgX_6B.js → ko-2GXumDJG.js} +2 -2
- package/dist/assets/main-C5ruSn_v.css +1 -0
- package/dist/assets/main-C5xXoiKS.js +169 -0
- package/dist/assets/{main-ClNDsxXD.js → main-C8mL1JTV.js} +2 -2
- package/dist/assets/{markdownHeightCache-qX2f-vgi.js → markdownHeightCache-UTJqLFoH.js} +1 -1
- package/dist/assets/{mcpQueries-DKxn0-Iq.js → mcpQueries-BuPzkbq2.js} +1 -1
- package/dist/assets/{miniChat-DuWGMHPI.js → miniChat-BhuPglJJ.js} +2 -2
- package/dist/assets/{mobile-CjbFG_ps.js → mobile-CMWTX8mO.js} +2 -2
- package/dist/assets/{mobileBackNavigation-Ce-CFzRu.js → mobileBackNavigation-5x78t-gF.js} +1 -1
- package/dist/assets/{mobileConnections-BWToBinV.js → mobileConnections-fYn7daqn.js} +2 -2
- package/dist/assets/{multirun-ByBZh9To.js → multirun-ouv_EGgz.js} +1 -1
- package/dist/assets/{native-config-BDAV-Sn-.js → native-config-Dq0UlZv_.js} +1 -1
- package/dist/assets/{nativeComposerCover-DcWXqfZa.js → nativeComposerCover-D7UBIuNP.js} +1 -1
- package/dist/assets/{navigation-DiqbYNCD.js → navigation-CPzyqYzc.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-DPb8H79n.js → openRemoteProjectSession-C9DZdUxN.js} +1 -1
- package/dist/assets/{openSessionFromDeepLink-gJWOkm8w.js → openSessionFromDeepLink-DtU9XJJp.js} +2 -2
- package/dist/assets/{pl-DlKDQDhl.js → pl-Blg4z4xW.js} +1 -1
- package/dist/assets/{pluginPresentation-C8XRIFn5.js → pluginPresentation-BihrAxof.js} +1 -1
- package/dist/assets/{pt-BR-BldJPFQ5.js → pt-BR-WWvogF30.js} +2 -2
- package/dist/assets/{pwa-CLwERclR.js → pwa-IFU95Pi8.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-BET9wo1a.js → queue-abort-optimistic-CIYOL5L8.js} +1 -1
- package/dist/assets/{quota-jMPnmJTS.js → quota-DJzfHqVc.js} +1 -1
- package/dist/assets/{reference-history-BAPLZtrN.js → reference-history-DZzShz77.js} +1 -1
- package/dist/assets/{remoteSessionReference-B-5Nd45t.js → remoteSessionReference-jSx-IJi0.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DudyNNIU.js → renderElectronMiniChatApp-C-EjIYIR.js} +2 -2
- package/dist/assets/{renderMobileApp-GIRJpszx.js → renderMobileApp-CW1rpQOR.js} +4 -4
- package/dist/assets/{runtimeConfig-CUiokUFx.js → runtimeConfig-CPAyuXMW.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DXfdUC1r.js → runtimeEndpointReset-CVtUnGxD.js} +2 -2
- package/dist/assets/{select--wmAuAOB.js → select-D0Rt9zfS.js} +1 -1
- package/dist/assets/{sessionLookup-on217pcK.js → sessionLookup-Rh9qnxXZ.js} +1 -1
- package/dist/assets/{sessionOwnership-BoiTRI2O.js → sessionOwnership-C8LXESP1.js} +1 -1
- package/dist/assets/{shortcuts-D3O9f1E5.js → shortcuts-Da3pJfxI.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DvvltU2l.js → sortable-tabs-strip-BTdgoeIZ.js} +1 -1
- package/dist/assets/{speechSettingsQueries-Cqj3BM7O.js → speechSettingsQueries-DQqu4idY.js} +1 -1
- package/dist/assets/src-BrcWGrVp.css +2 -0
- package/dist/assets/{store-BGuutgkJ.js → store-BYA4rnBC.js} +3 -3
- package/dist/assets/{switch-ClpM-4qX.js → switch-BHiYm7UO.js} +1 -1
- package/dist/assets/{textarea-Cpcy0ejH.js → textarea-CFiZJsTY.js} +1 -1
- package/dist/assets/{timeFormat-BaiPCZgf.js → timeFormat-BFmquwJx.js} +1 -1
- package/dist/assets/{tooltip-B9I9lmf0.js → tooltip-CT7PLBB7.js} +1 -1
- package/dist/assets/{truncated-path-BPcF8ywI.js → truncated-path-3v9CTKMU.js} +1 -1
- package/dist/assets/types-BCAMWVzt.js +2 -0
- package/dist/assets/{ui-BqoDhEiW.js → ui-Dc9pgW0G.js} +9 -9
- package/dist/assets/{uk-Cw2L_unr.js → uk-ONVyiLJf.js} +2 -2
- package/dist/assets/useAppFontEffects-CWUKP3TV.js +7 -0
- package/dist/assets/{useDesktopWindowControlsLayout-BA4DI_W1.js → useDesktopWindowControlsLayout-PPxZz8or.js} +1 -1
- package/dist/assets/{useDictation-83-qDgkn.js → useDictation-kKVOTVPh.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DQMEyl5O.js → useEffectiveDirectory-C2cIcRUL.js} +1 -1
- package/dist/assets/{useGitStore-Dvd_1jyD.js → useGitStore-RwmhQZHK.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-DWSuMEHF.js → useInlineCommentDraftStore-BdbKq7sf.js} +1 -1
- package/dist/assets/{useMcpConfigStore-7NoTGiyv.js → useMcpConfigStore-Ch5MJL3n.js} +1 -1
- package/dist/assets/{useMobileSwipeActions-7iuGbwWj.js → useMobileSwipeActions-adlq7Avs.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-B3NigAUx.js → useMobileTranscriptSyncHint-C4Ca-_5L.js} +1 -1
- package/dist/assets/{useModelLists-C5fB7vLV.js → useModelLists-AVuaMLh_.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-B4IGjODK.js → useOpenCodeReadiness-3XzhiXua.js} +1 -1
- package/dist/assets/{usePluginsStore-D2P-bQeH.js → usePluginsStore-D3fa2FX-.js} +1 -1
- package/dist/assets/{useProjectGitActions-CiL6W09h.js → useProjectGitActions-CsYphJIT.js} +1 -1
- package/dist/assets/{useProjectGitStore-Bv65Bj_P.js → useProjectGitStore-CuB_ofWO.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-CYT-3dZd.js → useProjectRuntimeAPIs-BT39e4mL.js} +1 -1
- package/dist/assets/{useQuotaStore-CHxR2ZkD.js → useQuotaStore-Ghvt5bI4.js} +1 -1
- package/dist/assets/{useSessionBtwStore-H4R5jYT2.js → useSessionBtwStore-Ch3uOtco.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-D9STYrQw.js → useStreamingTextThrottle-C4XuXBpR.js} +1 -1
- package/dist/assets/{worktreeManager-33ddwAq1.js → worktreeManager-BAb2ZJmi.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-Cp5jF1M9.js → worktreeSourceBranchPreference-Drs2-jAD.js} +1 -1
- package/dist/assets/{zh-CN-BQXjCmNe.js → zh-CN-BEurkI-Q.js} +2 -2
- package/dist/assets/{zh-TW-Y0lErpEY.js → zh-TW-DioYJnff.js} +2 -2
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/host-update/DOCUMENTATION.md +28 -16
- package/server/lib/host-update/cli-worker.js +71 -24
- package/server/lib/host-update/cli.js +9 -6
- package/server/lib/host-update/cli.test.js +28 -5
- package/server/lib/host-update/releases.js +33 -2
- package/server/lib/host-update/runtime.test.js +16 -1
- package/dist/assets/AssistantView-D7Ec_wbs.js +0 -1
- package/dist/assets/MarkdownRenderer-DL1l4dgn.js +0 -2
- package/dist/assets/main-D71N_bhn.js +0 -169
- package/dist/assets/main-qSeeJRW1.css +0 -1
- package/dist/assets/src-B7qham90.css +0 -2
- package/dist/assets/types-DjBXLnbS.js +0 -2
- package/dist/assets/useAppFontEffects-CaZbgo4R.js +0 -7
|
@@ -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{_ as k,b as A,c as j,d as M,f as N,g as P,h as F,i as ne,l as re,m as ie,n as ae,o as oe,r as se,s as I,v as L}from"./desktopHosts-COI-czjF.js";import{r as R}from"./desktopRelayRestore-BEPNc7qb.js";import{a as ce}from"./vendor-zustand-CTekDqaS.js";import{it as le,ot as z,st as B}from"./vendor-base-ui-wXsskyKm.js";import{Dt as ue,Ft as V,Jt as H,Kt as U,Mt as de,Pt as fe,St as pe,Wt as me}from"./gitApiHttp-ZjM4HkSo.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{gt as he,ht as ge,mt as _e,n as ve,o as ye,ut as be,xr as xe}from"./client-CmtAKi5B.js";import{n as Se}from"./vendor-react-BkccXcWz.js";import{a as Ce}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{l as we,o as Te,s as Ee}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{P as De,V as Oe,W as ke,z as Ae}from"./runtime-file-resource-BGZ4tGr5.js";import{i as je,o as Me,r as W}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as Ne}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{C as Pe,b as Fe,f as Ie,g as Le,r as G,y as Re}from"./useUIStore-68ZPpgYA.js";import{t as ze}from"./vendor-sonner-DX3nfJx4.js";import{Fi as Be,Fn as Ve,Ga as He,Ha as Ue,I as We,Ii as Ge,Jr as Ke,Kt as qe,Qa as Je,Ur as Ye,Xn as Xe,Yr as Ze,Zi as K,f as q,io as Qe,oa as $e,pn as et,ra as tt,ro as nt,t as rt,un as it,xt as at}from"./ui-Dc9pgW0G.js";import{n as J}from"./Icon-hrdOSdw7.js";import{o as ot,s as st,t as ct}from"./i18n-Cl6MPHiF.js";import{a as lt,n as ut,o as dt,r as ft,t as pt}from"./dialog-C_FAAyAo.js";import{i as mt,n as ht,t as gt}from"./tooltip-CT7PLBB7.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-C2cIcRUL.js";import{m as Dt,t as Ot}from"./gitApi-CqYtA25T.js";import{t as kt}from"./input-BjYTPnlP.js";import{n as Y,o as At,p as jt,r as Mt,s as Nt,u as Pt}from"./shortcuts-Da3pJfxI.js";import{a as Ft}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{t as It}from"./checkbox-Bgn_6HLp.js";import{A as Lt,B as Rt,F as zt,G as Bt,H as Vt,J as Ht,K as Ut,O as Wt,P as Gt,Q as Kt,R as qt,V as Jt,at as Yt,f as Xt,i as Zt,it as Qt,j as $t,k as en,nt as tn,o as nn,r as rn,rt as an,s as on,t as sn,z as cn}from"./pwa-IFU95Pi8.js";import{t as ln}from"./YuriLogo-CwUks1oQ.js";import{t as un}from"./ErrorBoundary-CyUuGOzH.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-BNeYGoxJ.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-CIYOL5L8.js";import{n as Ln}from"./worktreeManager-BAb2ZJmi.js";import{t as Rn}from"./useTerminalStore-C_QzSEgP.js";import{n as zn}from"./speechSettingsQueries-DQqu4idY.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=q.getState().currentSessionId;if(!e)return null;let t=_e(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=(ge(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:(ge(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=q.getState().currentSessionId;if(!t)return[];let n=_e(t);return`${n.length}`,n.forEach((e,t)=>{let n=ge(e.id)||[];`${t}${e.role}${e.id}${n.length}`}),e?this.truncateMessages(n):n},async getAppStatus(){let e=pe.getState(),t=q.getState(),n=Ue.getState(),r=e.currentDirectory||null,i=ve.getDirectory()??null,a=he(),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 ve.getSdkClient().location.get(Vn(r));m=ye(e)}catch(e){m={error:e instanceof Error?e.message:String(e)}}try{h=(await ve.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 nt(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=q.getState(),t=Ve.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=q.getState().currentSessionId;if(!e)return[];let t=_e(e).filter(e=>e.role===`assistant`).filter(e=>{let t=ge(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=ge(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=q.getState().currentSessionId;if(!i)return{summary:null,rows:[]};let a=_e(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=ge(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=q.getState().currentSessionId;if(!e)return null;let t=_e(e).filter(e=>e.role===`assistant`);if(t.length===0)return null;let n=t[t.length-1],r=(ge(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=Ve.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}}},ue(),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(B(),1),Z=Se(),Hn=async()=>{if(typeof window>`u`)return;let e=null;try{e=xe(`lastDirectory`)}catch(e){console.warn(`Failed to read saved directory preferences:`,e)}e&&!te()&&pe.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=z(),$=`local`,Qn=9e4,$n=`SSH connection cancelled`,er=e=>R(e),tr={},nr=e=>{let t=P(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()?``:oe().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 Kt().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 Kt(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=P(n)||n,a=P(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&&F(r,n))return{id:$,label:`Local`,url:i};let c=e.find(e=>r?F(r,M(e)):!1);if(c)return{id:c.id,label:c.label,url:P(M(c))||M(c)};if(t&&F(t,n))return{id:$,label:`Local`,url:i};let l=e.find(e=>t?F(t,e.url):!1);return l?{id:l.id,label:l.label,url:P(l.url)||l.url}:t.startsWith(`yuri-ui://`)?{id:$,label:`Local`,url:i}:{id:`custom`,label:L(a||`Instance`),url:a}};function gr({open:e,onOpenChange:t,embedded:n=!1,onHostSwitched:r,onBusyChange:i}){let{t:a}=ct(),o=G(e=>e.setSettingsDialogOpen),s=G(e=>e.setSettingsPage),l=K(e=>e.isConnected),d=K(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=Qt(),ee=Yt(),[te,O]=X.useState(null),N=te||ee,F=X.useRef(!1),oe=W(e=>{F.current=e!==null,O(e),i?.(e!==null)}),[R,ce]=X.useState({}),[le,z]=X.useState({}),[B,ue]=X.useState({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),[V,H]=X.useState(``),[U,de]=X.useState(()=>rr()),[fe,pe]=X.useState(null),[me,he]=X.useState(``),[ge,_e]=X.useState(``),[ve,ye]=X.useState(0),be=X.useRef(0),xe=X.useMemo(()=>[mr(U),...f.map(e=>({...e,url:P(e.url)||e.url}))],[f,U]),Se=X.useMemo(()=>new Set(Object.keys(R)),[R]),Ce=X.useMemo(()=>{let e=hr(xe).id;return xe.filter(t=>t.id===$||ie(t,Se)||t.id===e)},[xe,Se,ve]);X.useEffect(()=>c(()=>ye(e=>e+1)),[]);let we=X.useMemo(()=>hr(xe),[xe,ve]),Te=X.useMemo(()=>u().startsWith(`relay:`),[ve]),Ee=X.useMemo(()=>{let e=m||$;return xe.find(t=>t.id===e)?.label||a(`desktopHostSwitcher.instance.local`)},[xe,m,a]),De=W(async(e,t)=>{if(y()){E(!0),H(``);try{if(b()&&!x()){await I();return}let n=e.filter(e=>e.id!==$);await ne({hosts:n,defaultHostId:t}),p(n),h(t)}catch(e){H(e instanceof Error?e.message:a(`desktopHostSwitcher.error.failedToSave`))}finally{E(!1)}}}),Oe=W(()=>{if(b()&&!x()){I().catch(e=>rt.error(String(e))),t(!1);return}s(`remote-instances`),o(!0),t(!1)}),ke=X.useCallback(async()=>{if(y()){S(!0),H(``);try{let[e,t,n]=await Promise.all([se(),x()?Ht().catch(()=>({instances:[]})):Promise.resolve({instances:[]}),x()?fr():Promise.resolve({})]);e.localOrigin&&de(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),z(n)}catch(e){H(e instanceof Error?e.message:a(`desktopHostSwitcher.error.failedToLoad`)),p([]),h(null),ce({}),z({})}finally{S(!1)}}},[a]),Ae=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 k(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=P(b()?M(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){pe(null),he(``),_e(``),O(null),ue({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),H(``);return}ke()},[e,ke]),X.useEffect(()=>{e&&Ae(Ce)},[e,Ce,Ae]),X.useEffect(()=>{if(!e||!y()||!x())return;let t=!1,n=async()=>{let e=await fr();t||z(e)};n();let r=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||n()},1500);return()=>{t=!0,window.clearInterval(r)}},[e]);let je=W(async e=>{if(F.current||D)return;let t=e.id===$?U:P(e.url)||``,n=e.id===$?U:P(M(e))||``,i=!!e.relay&&!e.apiUrl&&e.id!==$;if(!t&&!i)return;if(b()){if(!n&&!e.relay||D)return;oe(e.id);try{let t=e.id===$?await ir():null,i=await an({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{oe(null)}return}let o=!!R[e.id];if(e.id!==$&&o&&y()){let n=le[e.id],i=await Kt(e.id).then(t=>t.find(t=>t.id===e.id)||null).catch(()=>null);i&&(n=i,z(t=>({...t,[e.id]:i})));let o=P(n?.localUrl||e.url||``);if(n?.phase===`ready`&&o){let e=nr(o);r?.(),window.location.assign(e);return}O(e.id);let s=be.current+1;be.current=s,ue({open:!0,hostId:e.id,hostLabel:L(e.label),phase:`master_connecting`,detail:null,error:null,errorCode:null});try{if(await Bt(e.id),s!==be.current)return;let n=await pr(e.id,Qn,e=>{z(t=>({...t,[e.id]:e})),ue(t=>({...t,phase:e.phase,detail:e.detail||null,errorCode:e.errorCode||null}))},()=>s!==be.current);if(s!==be.current)return;let i=nr(P(n.localUrl||``)||t);r?.(),window.location.assign(i);return}catch(t){if(s!==be.current)return;let n=t instanceof Error?t.message:String(t);if(n===$n)return;let r=Rt(B.errorCode,n);ue(e=>({...e,error:n,errorCode:r})),rt.error(a(`desktopHostSwitcher.toast.sshFailedToConnect`,{host:L(e.label)}),{description:cn(a(Jt(r)),r,n)});return}finally{s===be.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)){rt.error(a(`desktopHostSwitcher.toast.instanceUnreachable`,{host:L(e.label)})),O(null);return}}let s=nr(t);r?.();try{window.location.assign(s)}catch{window.location.href=s}}),Me=X.useCallback(()=>{pe(null),he(``),_e(``)},[]),Ne=X.useCallback(e=>{e.stopPropagation()},[]),Pe=X.useCallback(async()=>{if(!fe)return;if(fe===$){Me();return}let e=A(ge);if(!e){H(a(`desktopHostSwitcher.error.invalidUrl`));return}let t=e.persistedUrl,n=(me||L(t)).trim(),r=f.map(e=>e.id===fe?{...e,label:n,url:t,apiUrl:t}:e);await De(r,m),Me(),e.redeemUrl&&window.location.assign(e.redeemUrl)},[Me,f,m,me,ge,fe,De,a]),Fe=X.useCallback(async e=>{await De(f,e===$?$:e)},[f,De]),Ie=W(async e=>{if(F.current||D)return;oe(e.id);let t=e=>{rt.error(a(`desktopHostSwitcher.error.failedToOpenNewWindow`),{description:e instanceof Error?e.message:String(e)})};try{if(e.relay&&e.id!==$)await re(e.id);else{let t=e.id===$?U:M(e);if(!t)return;let n=nr(t);await j(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null})}r?.()}catch(e){t(e)}finally{oe(null)}}),Le=W(async()=>{be.current+=1,O(null),ue(e=>({...e,open:!1,hostId:null,error:null,errorCode:null,detail:null,phase:`idle`}));let e=nr(U);if(b()){if(D)return;let e=await ir();(await an({host:mr(U),localApiOrigin:U,localClientToken:e})).ok&&r?.();return}r?.(),window.location.assign(e)}),Re=X.useCallback(async()=>{let e=B.hostId||N;be.current+=1,O(null),ue({open:!1,hostId:null,hostLabel:``,phase:`idle`,detail:null,error:null,errorCode:null}),!(!e||e===$||!y())&&await Ut(e).catch(()=>{})},[B.hostId,N]),ze=X.useCallback(()=>{let e=B.hostId;if(!e)return;let t=xe.find(t=>t.id===e);t&&je(t)},[xe,je,B.hostId]),Be=W(async e=>{if(!(!y()||F.current||D)){oe(e.id);try{await Bt(e.id),(await pr(e.id,Qn,e=>{z(t=>({...t,[e.id]:e}))})).phase===`ready`&&rt.success(a(`desktopHostSwitcher.toast.sshConnected`,{host:L(e.label)}))}catch(t){let n=t instanceof Error?t.message:String(t);if(n!==$n){let t=Rt(null,n);rt.error(a(`desktopHostSwitcher.toast.sshFailedToConnect`,{host:L(e.label)}),{description:cn(a(Jt(t)),t,n)})}}finally{oe(null)}}});if(!y())return null;let Ve=y(),He=(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:L(we.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:L(Ee)})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,Q.jsxs)(Xe,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void Ae(Ce),disabled:!Ve||v||C,children:[(0,Q.jsx)(J,{name:`refresh`,className:Qe(`h-4 w-4`,C&&`animate-spin`)}),a(`desktopHostSwitcher.actions.refresh`)]})})]}),!Ve&&(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:Qe(`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`)}):Ce.map(e=>{let t=e.id===$,r=!!R[e.id],i=r&&x(),o=e.id===we.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:Te,probe:c,sshPhase:u?.phase}),p=f.statusKind,h=f.showViaRelay,_=Zn({isLocal:t,isSsh:r,isRelay:o?Te:h||!!(e.relay&&!e.apiUrl)}),v=_===`connection-local`?a(`desktopHostSwitcher.instance.local`):_===`connection-relay`?`Relay`:_===`connection-ssh`?`SSH`:`LAN`,y=fe===e.id,b=t?U:P(e.url)||e.url,S=e.id===$?a(`desktopHostSwitcher.instance.local`):L(e.label),C=e.relay&&!e.apiUrl?a(`mobile.connect.relay.badge`):L(b);return(0,Q.jsxs)(`div`,{className:Qe(`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:Qe(`flex items-center gap-2 flex-1 min-w-0 text-left`,y&&`pointer-events-none opacity-70`),onClick:()=>void je(e),disabled:N===e.id,"aria-busy":N===e.id,"aria-current":o?`true`:void 0,"aria-label":a(`desktopHostSwitcher.actions.switchToAria`,{instance:S}),children:[(0,Q.jsx)(J,{name:N===e.id?`loader-4`:_,className:Qe(`size-8 shrink-0 text-muted-foreground`,N===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:Qe(`truncate`,or(p)),children:i&&(!o||N===e.id)?a(dr(u?.phase)):a(lr(p))})]}):(0,Q.jsxs)(`div`,{className:Qe(`typography-micro truncate`,or(p)),children:[(0,Q.jsx)(`span`,{className:Qe(`mr-1 inline-block h-1.5 w-1.5 rounded-full`,ar(p))}),i&&(!o||N===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)(Xe,{type:`button`,variant:`outline`,size:`sm`,className:`h-8 px-2.5`,disabled:N===e.id,onClick:t=>{t.stopPropagation(),Be(e)},children:[N===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:Qe(`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 Fe(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:Qe(`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(),Ie(e)},disabled:N===e.id||cr(p),"aria-busy":N===e.id,"aria-label":a(`desktopHostSwitcher.actions.openInNewWindowAria`),children:(0,Q.jsx)(J,{name:N===e.id?`loader-4`:`window`,className:Qe(`h-4 w-4`,N===e.id&&`animate-spin`)})})}),(0,Q.jsx)(ht,{sideOffset:6,children:cr(p)?a(`desktopHostSwitcher.state.instanceUnreachable`):a(`desktopHostSwitcher.actions.openInNewWindow`)})]})]})]},e.id)})})}),Ve&&fe&&fe!==$&&(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)(Xe,{type:`button`,variant:`outline`,size:`sm`,onClick:Me,disabled:T,children:a(`desktopHostSwitcher.actions.cancel`)}),(0,Q.jsxs)(Xe,{type:`button`,size:`sm`,onClick:()=>void Pe(),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:me,onChange:e=>he(e.target.value),onKeyDown:Ne,placeholder:a(`desktopHostSwitcher.field.labelPlaceholder`),disabled:T}),(0,Q.jsx)(kt,{value:ge,onChange:e=>_e(e.target.value),onKeyDown:Ne,placeholder:a(`desktopHostSwitcher.field.urlPlaceholder`),disabled:T})]})]}),(0,Q.jsx)(`div`,{className:Qe(`flex-shrink-0 border-t border-[var(--interactive-border)]`,n&&`px-3 py-1`),children:(0,Q.jsxs)(`button`,{type:`button`,className:Qe(`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:Oe,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`)})]})}),V&&(0,Q.jsx)(`div`,{className:`flex-shrink-0 typography-meta text-status-error`,children:V})]}),Ue=(0,Q.jsx)(pt,{open:B.open,onOpenChange:e=>{if(!e&&N){Re();return}ue(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:Qe(`h-4 w-4`,!B.error&&`animate-spin`)}),a(`desktopHostSwitcher.ssh.connectingTo`,{host:B.hostLabel||a(`desktopHostSwitcher.ssh.instanceFallback`)})]}),B.error?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ft,{className:`sr-only`,children:a(Vt(Rt(B.errorCode,B.error)))}),(0,Q.jsx)(qt,{errorCode:B.errorCode,detail:B.error})]}):(0,Q.jsx)(ft,{children:B.detail||a(dr(B.phase))})]}),B.error?(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Q.jsx)(Xe,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{Oe(),Re()},children:a(`desktopHostSwitcher.sshError.openRemoteSettings`)}),(0,Q.jsx)(Xe,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void Le(),children:a(`desktopHostSwitcher.actions.switchToLocal`)}),(0,Q.jsx)(Xe,{type:`button`,size:`sm`,onClick:ze,disabled:!B.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:He}),Ue]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pt,{open:e,onOpenChange:e=>{!e&&F.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:He})}),Ue]})}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)(Xe,{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=P(e),r=P(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=async(e={})=>{if(!b()||t())return`not-ssh`;let n=br();if(!n||e.hostId&&e.hostId!==n)return`not-ssh`;let i=m(),o=f(),s=a(),c=()=>i===m()&&o===f()&&s===a(),l=await se().catch(()=>null);if(!l||!c())return`unchanged`;if(!l.sshHostIds?.includes(n))return`not-ssh`;if(e.refresh){try{await C(`desktop_ssh_host_token_refresh`,{hostId:n})}catch{return`failed`}if(l=await se().catch(()=>null),!l||!c())return`unchanged`}let u=l.hosts.find(e=>e.id===n),p=u?P(M(u)):null;return!u||u.relay||!p||!u.clientToken||u.clientToken===r()&&P(h())===p?`unchanged`:(d({apiBaseUrl:p,clientToken:u.clientToken,requestHeaders:u.requestHeaders||null,runtimeKey:R(u)}),`switched`)},Sr=e=>e.shouldUseDesktopShellPasswordLogin?`locked`:`error`,Cr=`/auth/session`,wr=4,Tr=1500,Er=2,Dr=`yuri.uiAuth.trustDevice`,Or=`desktop-local`,kr=`desktop-local`,Ar=()=>{if(typeof window>`u`)return``;let e=window.__YURI_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},jr=(e,t)=>{let n=P(e),r=P(t);if(!n||!r)return!1;try{return new URL(n).origin===new URL(r).origin}catch{return!1}},Mr=()=>y(),Nr=e=>{let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`127.0.0.1`||t===`::1`},Pr=()=>{if(!y())return!1;let e=Ar();if(!e)return!1;let t=h()||(typeof window<`u`?window.location.origin:``);if(jr(e,t))return!0;try{let e=P(t);return!!(e&&Nr(new URL(e).hostname))}catch{return!1}},Fr=()=>Pr()?{clientKind:Or,dedupeKey:kr}:{},Ir=async()=>await g(Cr,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}}),Lr=()=>typeof window>`u`?!1:window.localStorage.getItem(Dr)===`true`,Rr=async(e,t)=>{let n=Mr();return await g(Cr,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({password:e,trustDevice:t,issueClientToken:n,clientLabel:`Yuri Desktop`,...Fr()})})},zr=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`,...Fr()})}).catch(()=>null);if(!e?.ok)return``;let t=await e.json().catch(()=>null);return typeof t?.token==`string`?t.token.trim():``},Br=()=>y()&&!Pr(),Vr=async()=>{if(!y())return null;let e=m(),t=br();if(!t)return null;let n=await se().catch(()=>null);if(m()!==e||!n)return;let r=n?.hosts.find(e=>e.id===t);if(r)return r&&N(r)?r:null},Hr=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}:{}}},Ur=async(e,t)=>{if(!y()||!t)return;let n=await se().catch(()=>null);if(!n)return;if(n.localOrigin&&jr(n.localOrigin,e)){await ne({hosts:n.hosts,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted,localClientToken:t}).catch(()=>void 0);return}let r=!1,i=n.hosts.map(n=>!jr(M(n),e)||n.clientToken===t?n:(r=!0,{...n,clientToken:t}));r&&await ne({hosts:i,defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>void 0)},Wr=async e=>{if(!e)return;let t=h(),r=i();await Ur(t,e),d({apiBaseUrl:t,clientToken:e,requestHeaders:Object.keys(r).length>0?r:null,relay:n()})},Gr=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},Kr=()=>{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},qr=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)(Xe,{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)(Gr,{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],_},Jr=({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(Lt),[O,k]=X.useState(!1),[A,j]=X.useState(!1),[M,N]=X.useState(()=>Lr()),[P,F]=X.useState(null),[ne,re]=X.useState(l),ie=X.useRef(null),ae=X.useRef(l),oe=X.useRef(0);X.useEffect(()=>()=>{oe.current+=1},[]),X.useEffect(()=>{typeof window>`u`||window.localStorage.setItem(Dr,M?`true`:`false`)},[M]);let se=X.useCallback(async()=>{if(l)return Lt;let e=m(),t=f(),n=a(),r=()=>e===m()&&t===f()&&n===a();try{let e=await $t();return r()&&ee(e),e}catch{return r()&&ee(Lt),Lt}},[l]);X.useEffect(()=>{let e=!1;if(!l)return(async()=>{try{if(!window.isSecureContext||!Ft()){e||k(!1);return}e||k(!0)}catch{e||k(!1)}})(),()=>{e=!0}},[l]);let L=X.useRef(0),R=X.useRef(null),ce=X.useRef(null),le=X.useRef(0),z=X.useCallback(()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[]),B=X.useCallback(()=>{L.current=0,z()},[z]),ue=X.useCallback(()=>L.current>=wr?!1:(L.current+=1,z(),R.current=window.setTimeout(()=>{R.current=null,ce.current?.()},Tr*L.current),!0),[z]);X.useEffect(()=>z,[z]);let V=X.useCallback(async e=>{if(l){h(`authenticated`);return}let n=++oe.current,r=m(),i=f(),o=a(),s=()=>n===oe.current&&r===m()&&i===f()&&o===a(),c=y()?t():null;if(c?.getStatus().failureCode===`relay_authentication_rejected`){B(),h(`relay-auth-error`);return}h(e=>e===`authenticated`?e:`pending`);try{let[t,n]=await Promise.all([e??Ir(),e?Lt:se()]),r=await t.text();if(!s())return;if(t.ok){B(),le.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=le.current<Er;e&&(le.current+=1);let t=await xr({refresh:e}).catch(()=>`not-ssh`);if(t===`switched`){ce.current?.();return}if(t!==`not-ssh`){if(!s())return;B(),E(!1),w(void 0),h(`ssh-expired`);return}}let i=c?!0:await Vr();if(!s())return;if(i===void 0){B(),h(`error`);return}if(i){B(),E(!1),h(`pairing-expired`),w(void 0);return}if(t.status===403){if(ue())return;h(`error`);return}let a={};try{a=JSON.parse(r)}catch{a={}}B(),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={}}B(),w(e.retryAfter),E(!1),h(`rate-limited`);return}if(ue())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`){B(),h(`relay-auth-error`);return}let t=c?!0:await Vr();if(!s())return;if(t||t===void 0){if(ue())return;h(`error`),E(!1);return}if(Sr({shouldUseDesktopShellPasswordLogin:Br()})===`locked`){h(`locked`),w(void 0),E(!1);return}if(ue())return;h(`error`),E(!1)}},[se,B,ue,l]);X.useEffect(()=>{ce.current=V},[V]),X.useEffect(()=>{l||V()},[V,l]),X.useEffect(()=>{if(!(l||d!==`authenticated`))return vr(e=>{e.kind===`relay-authentication`?(oe.current+=1,B(),h(`relay-auth-error`)):V(e.response)},{desktop:y()})},[V,B,l,d]),X.useEffect(()=>{if(l||!y())return;let e=!1,t=null;return tn(t=>{t.phase===`ready`&&xr({hostId:t.id}).then(t=>{!e&&t===`switched`&&ce.current?.()}).catch(()=>void 0)}).then(n=>{e?n():t=n}).catch(()=>void 0),()=>{e=!0,t?.()}},[l]),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),B(),re(!1),ae.current=!1,h(`pending`),V())}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V,B,l]),X.useEffect(()=>{!l&&(d===`locked`||d===`pairing-expired`||d===`ssh-expired`)&&(ae.current=!1,re(!1))},[l,d]),X.useEffect(()=>{d===`locked`&&ie.current&&(ie.current.focus(),ie.current.select())},[d]),X.useEffect(()=>{if(!l&&d===`authenticated`&&!ae.current){ae.current=!0;let e=!1;return Gn({runtimeKey:m(),initializeAppearance:de,syncSettings:fe,applyDirectory:Hn,onError:(e,t)=>{console.error(`[SessionAuthGate] ${e} settings hydration failed:`,t)}},{force:!0}).then(()=>{e||re(!0)}),()=>{e=!0}}},[l,d]);let H=async e=>{e.preventDefault(),await me(!1)},U=X.useCallback(async()=>{F(`register`),j(!0);try{await zt()}finally{F(null),j(!1)}await se()},[se]),pe=X.useCallback(()=>{en(),F(null),j(!1)},[]),me=X.useCallback(async e=>{if(!T&&!(!g||v)){A&&pe(),b(!0),S(``);try{if(Br()){let e=await Hr(g,M);if(e?.token){_(``),E(!1),await Wr(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 Rr(g,M);if(t.ok){let n=await t.json().catch(()=>null),i=Mr(),a=``;if(i&&(a=typeof n?.clientToken==`string`&&n.clientToken.trim()?n.clientToken.trim():``,a||=(await Hr(g,M))?.token||await zr()),_(``),E(!1),a&&await Wr(a),e&&O)try{await U(),rt.success(r(`sessionAuth.toast.passkeyAdded`)),h(`authenticated`);return}catch(e){if(Gt(e))rt.message(r(`sessionAuth.toast.passkeySetupCanceled`));else{let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySetupFailed`);rt.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=Br()?await Hr(g,M):null;if(t?.token){_(``),E(!1),await Wr(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)}}},[pe,A,v,T,g,U,O,r,M]),he=X.useCallback(async()=>{if(!(v||!O)){if(A){pe();return}j(!0),F(`auth`),S(``);try{let e=await Wt(M,{issueClientToken:Mr(),clientLabel:`Yuri Desktop`,...Fr()}),t=Mr()&&typeof e?.clientToken==`string`&&e.clientToken.trim()?e.clientToken.trim():``;t&&await Wr(t),_(``),h(`authenticated`)}catch(e){if(Gt(e))S(``);else{let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySignInCanceled`);S(t)}}finally{F(null),j(!1)}}},[pe,A,v,O,r,M]),ge=X.useCallback(async()=>{if(!(v||T||!O)){if(A){pe();return}if(d!==`authenticated`){if(!g){S(r(`sessionAuth.error.enterPasswordForPasskey`));return}await me(!0);return}S(``);try{await U(),rt.success(r(`sessionAuth.toast.passkeyAdded`))}catch(e){if(Gt(e)){rt.message(r(`sessionAuth.toast.passkeySetupCanceled`));return}let t=e instanceof Error?e.message:r(`sessionAuth.error.passkeySetupFailed`);rt.error(t)}}},[pe,me,A,v,T,g,U,d,O,r]),_e=O&&D.enabled,ve=_e&&D.hasPasskeys;return d===`pending`||d===`authenticated`&&!ne?(0,Q.jsx)(Kr,{}):d===`error`?(0,Q.jsx)(qr,{onRetry:()=>{B(),V()},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`)})]})}):d===`rate-limited`?(0,Q.jsx)(qr,{onRetry:()=>void V(),errorType:`rate-limit`,retryAfter:C}):d===`pairing-expired`?(0,Q.jsx)(Gr,{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)(Xe,{type:`button`,className:`w-full`,onClick:()=>{I().catch(()=>rt.error(r(`sessionAuth.error.networkTitle`)))},children:r(`settings.remoteInstances.openLocalManager`)}),(0,Q.jsx)(_r,{})]})}):d===`ssh-expired`?(0,Q.jsx)(Gr,{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(`sessionAuth.sshExpired.title`)}),(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`sessionAuth.sshExpired.description`)})]}),(0,Q.jsx)(Xe,{type:`button`,className:`w-full`,onClick:()=>{le.current=0,B(),h(`pending`),V()},children:r(`sessionAuth.sshExpired.reconnect`)}),(0,Q.jsx)(_r,{})]})}):d===`relay-auth-error`?(0,Q.jsx)(qr,{errorType:`relay-auth`,onRetry:()=>{let e=n();e&&(o(),s(e)),B(),V()},children:u&&(0,Q.jsx)(_r,{})}):d===`locked`?(0,Q.jsx)(Gr,{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:H,className:`w-full space-y-2`,children:[ve&&(0,Q.jsxs)(Xe,{type:`button`,variant:`outline`,className:`w-full`,onClick:()=>void he(),disabled:v||A&&P!==`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&&P===`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:ie,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)(Xe,{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`})})]}),_e?(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:N,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)(Xe,{type:`button`,variant:`ghost`,size:`sm`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>void ge(),disabled:v,children:r(A&&P===`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:N,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})},Yr=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Xr=e=>typeof e==`string`&&e.trim()?e.trim():null,Zr=e=>{if(!Yr(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=Xr(e.minimumVersion),i=Xr(e.targetVersion);if(!r||!i||typeof e.canInstall!=`boolean`)throw Error(`Could not check OpenCode compatibility`);return{state:t,version:Xr(e.version),installation:n,minimumVersion:r,targetVersion:i,canInstall:e.canInstall,guidance:Xr(e.guidance)}},Qr=async()=>{let e=await g(`/api/opencode/compatibility`,{signal:AbortSignal.timeout(2e4)});if(!e.ok)throw Error(`Could not check OpenCode compatibility`);return Zr(await e.json())},$r=async()=>{let e=await g(`/api/opencode/install-required`,{method:`POST`}),t=await e.json().catch(()=>null),n=Yr(t)?t:null,r=Xr(n?.error);if(!e.ok||n?.success!==!0||n?.upgraded!==!0)throw Error(r||`OpenCode installation failed`);let i=Xr(n.version);if(!i)throw Error(r||`OpenCode installation did not report a verified version`);return{version:i}},ei=(e,t)=>e instanceof Error&&e.message.trim()?e.message.trim():t,ti=({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 Qr();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=W(async e=>{if(o)return;let n=++p.current;s(e),u(null);try{if(e===`install`){let e=await $r();if(n!==p.current)return;if(!e.version)throw Error(t(`opencodeUpgrade.screen.failedGeneric`));window.location.reload();return}let i=await Qr();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(ei(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)(Xe,{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)(Xe,{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,{})})]})})},ni=e=>{let t=(0,Z.c)(14),{children:n}=e,r=G(ri),i=G(ii),a=G(ai),o=G(oi),s=G(si),{deviceType:c,hasTouchInput:l}=bt(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=typeof document<`u`&&Pe(),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 ri(e){return e.fontSize}function ii(e){return e.codeFontSize}function ai(e){return e.applyTypography}function oi(e){return e.padding}function si(e){return e.applyPadding}var ci=e(le(),1),li={light:`#212121`,dark:`#DEDEDE`},ui=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)},di=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},fi=e=>{let t=li[e.metadata.variant],n=di(ui(t)),r=e.colors,i=!1,a=(e,r)=>{let a=ui(e);if(!a)return e;let o=ui(r);return di(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=ui(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},pi=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}`},mi=class{inheritanceMap=new Map;constructor(){this.initializeInheritanceMap()}generate(e){e=fi(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=pi(e.colors.surface.muted),r=pi(e.colors.surface.subtle),i=pi(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()?Fe:Re;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()}},hi=()=>dn()?new URLSearchParams(window.location.search):null,gi=()=>typeof window>`u`||window.matchMedia(`(prefers-color-scheme: dark)`).matches,_i=()=>{let e=hi()?.get(`themeVariant`);return e===`dark`||e===`light`?e===`dark`:gi()},vi=e=>mn(e.currentTheme)?e.currentTheme:null,yi=e=>vi(e)?.metadata.variant??null,bi=Ct,xi=Tt,Si=()=>{let e=hi()?.get(`currentTheme`);if(!e)return null;try{let t=JSON.parse(e);return mn(t)?t:null}catch{return null}},Ci=e=>wt(e===`dark`),wi=typeof window<`u`?X.useLayoutEffect:X.useEffect,Ti=()=>{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`)}},Ei=e=>{let t=bi,n=xi,r=`system`;if(typeof window<`u`){let e=hi(),i=e?.get(`themeMode`),a=e?.get(`lightThemeId`),o=e?.get(`darkThemeId`),s=U(`themeMode`),c=U(`lightThemeId`),l=U(`darkThemeId`),u=U(`useSystemTheme`),d=U(`selectedThemeId`),f=U(`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 Di({children:e,defaultThemeId:t}){let n=(0,X.useMemo)(()=>new mi,[]),[r,i]=(0,X.useState)(()=>Ei(t)),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(()=>_i()),[u,d]=(0,X.useState)([]),[f,m]=(0,X.useState)([]),h=W(e=>(m(e),()=>{m(t=>t===e?[]:t)})),[_]=(0,X.useState)(()=>Si()),[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:hi()!==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(fi(n)))};return E&&w&&n(w),b&&n(b),_&&n(_),u.forEach(n),xt.forEach(n),e},[u,_,b,E,w]),A=(0,X.useMemo)(()=>e=>k.find(t=>t.metadata.id===e),[k]),j=(0,X.useMemo)(()=>(e,t)=>{let n=A(e);return n&&n.metadata.variant===t?n:k.find(e=>e.metadata.variant===t)??Ci(t)},[k,A]),M=(0,X.useMemo)(()=>E&&w?A(w.metadata.id)??fi(w):r.themeMode===`light`?j(r.lightThemeId,`light`):r.themeMode===`dark`||s?j(r.darkThemeId,`dark`):j(r.lightThemeId,`light`),[j,A,E,r,s,w]),N=(0,X.useMemo)(()=>{if(E||O)return M;let e=f.find(e=>e.metadata.variant===M.metadata.variant);return e?fi(e):M},[E,O,f,M]),P=W(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)(()=>{P()},[P]),(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 F=W(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)}),ne=W(e=>{typeof document>`u`||document.documentElement.classList.toggle(`vscode-runtime`,e)});wi(()=>{if(typeof window>`u`)return;let e=Ti();n.apply(N),ne(E),F(N);let t=document.documentElement;return t.classList.remove(`light`,`dark`),t.classList.add(N.metadata.variant),e},[ne,n,N,E,F]),(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;H(`themeMode`,r.themeMode),H(`lightThemeId`,r.lightThemeId),H(`darkThemeId`,r.darkThemeId),H(`useSystemTheme`,String(r.themeMode===`system`)),H(`selectedThemeId`,M.metadata.id),H(`selectedThemeVariant`,M.metadata.variant===`light`?`light`:`dark`);let e=j(r.lightThemeId,`light`),t=j(r.darkThemeId,`dark`);H(`splashBgLight`,e.colors.surface.background),H(`splashFgLight`,e.colors.surface.foreground),H(`splashBgDark`,t.colors.surface.background),H(`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,M,j,D,O]),(0,X.useEffect)(()=>{if(typeof window>`u`||O)return;let e=e=>{e.storageArea===window.localStorage&&(me(e.key,`themeMode`)||me(e.key,`lightThemeId`)||me(e.key,`darkThemeId`))&&i(e=>{let t=U(`themeMode`),n=t===`light`||t===`dark`||t===`system`?t:e.themeMode,r=U(`lightThemeId`),i=typeof r==`string`&&r.trim().length>0?r.trim():e.lightThemeId,a=U(`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 re=W(e=>{let t=e.themeMode,n=e.lightThemeId,r=e.darkThemeId,a=yi(e),o=vi(e);if(t!==`light`&&t!==`dark`&&t!==`system`||typeof n!=`string`||typeof r!=`string`)return;let s=n.trim(),c=r.trim();!s||!c||(Ti(),(0,ci.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=re,()=>{e.__yuriApplyThemeSync===re&&delete e.__yuriApplyThemeSync}},[re]),(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||re(t.payload)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[re]),(0,X.useEffect)(()=>{if(O||!a)return;let e=j(r.lightThemeId,`light`),t=j(r.darkThemeId,`dark`);V({themeId:M.metadata.id,themeVariant:M.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})},[M.metadata.id,M.metadata.variant,j,r.themeMode,r.lightThemeId,r.darkThemeId,O,a]),(0,X.useEffect)(()=>{O||!ee||(async()=>{await ot(r.themeMode,N.metadata.variant)})()},[N.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=U(`themeMode`),n=t===`light`||t===`dark`||t===`system`?t:e.themeMode,r=U(`lightThemeId`),i=typeof r==`string`&&r.trim().length>0?r.trim():e.lightThemeId,a=U(`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 ie=W(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`})}),ae=W(e=>{i(t=>t.themeMode===e?t:{...t,themeMode:e})}),oe=W(e=>{if(e){i(e=>e.themeMode===`system`?e:{...e,themeMode:`system`});return}let t=N.metadata.variant===`dark`?`dark`:`light`;i(e=>e.themeMode===t?e:{...e,themeMode:t})}),se=W(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})}),I=W(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})}),L=(0,X.useMemo)(()=>({currentTheme:N,availableThemes:k,registerPluginThemes:h,setTheme:ie,customThemesLoading:S,reloadCustomThemes:P,isSystemPreference:r.themeMode===`system`,setSystemPreference:oe,themeMode:r.themeMode,setThemeMode:ae,lightThemeId:r.lightThemeId,darkThemeId:r.darkThemeId,setLightThemePreference:se,setDarkThemePreference:I}),[k,h,N,S,r.darkThemeId,r.lightThemeId,r.themeMode,P,I,se,oe,ie,ae]);return(0,Q.jsx)(vt.Provider,{value:L,children:e})}var Oi=!1,ki=()=>{if(Oi||typeof window>`u`)return;Oi=!0;let e={showReasoningTraces:G.getState().showReasoningTraces,sessionTitleRefreshEnabled:G.getState().sessionTitleRefreshEnabled,sessionGoalEnabled:G.getState().sessionGoalEnabled,collapsibleThinkingBlocks:G.getState().collapsibleThinkingBlocks,showDeletionDialog:G.getState().showDeletionDialog,nativeNotificationsEnabled:G.getState().nativeNotificationsEnabled,notificationMode:G.getState().notificationMode,notifyOnSubtasks:G.getState().notifyOnSubtasks,notifyOnCompletion:G.getState().notifyOnCompletion,notifyOnError:G.getState().notifyOnError,notifyOnQuestion:G.getState().notifyOnQuestion,notifyOnPermission:G.getState().notifyOnPermission,notifyOnScheduledTasks:G.getState().notifyOnScheduledTasks,notifyOnAssistants:G.getState().notifyOnAssistants,notifyOnGoals:G.getState().notifyOnGoals,notificationTemplates:G.getState().notificationTemplates,summarizeLastMessage:G.getState().summarizeLastMessage,summaryThreshold:G.getState().summaryThreshold,summaryLength:G.getState().summaryLength,maxLastMessageLength:G.getState().maxLastMessageLength,autoDeleteEnabled:G.getState().autoDeleteEnabled,autoDeleteAfterDays:G.getState().autoDeleteAfterDays,sessionRetentionAction:G.getState().sessionRetentionAction,fontSize:G.getState().fontSize,terminalFontSize:G.getState().terminalFontSize,editorFontSize:G.getState().editorFontSize,uiFont:G.getState().uiFont,monoFont:G.getState().monoFont,padding:G.getState().padding,cornerRadius:G.getState().cornerRadius,inputBarOffset:G.getState().inputBarOffset,mobileKeyboardMode:G.getState().mobileKeyboardMode,diffLayoutPreference:G.getState().diffLayoutPreference,gitChangesViewMode:G.getState().gitChangesViewMode},t=null,n=null,r=()=>{let e=t;t=null,n=null,e&&Object.keys(e).length>0&&V(e)},i=e=>{t={...t??{},...e},!n&&(n=setTimeout(r,150))};G.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)})},Ai=(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},ji=(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},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]!==t[n])return!1;return!0},Ni=(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])&&Mi(e[n],t[n]))},Pi=()=>{let e=G.getState();return{favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,providerOrder:e.providerOrder,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts}},Fi=(e,t)=>Ai(e.favoriteModels,t.favoriteModels)&&ji(e.hiddenModels,t.hiddenModels)&&Mi(e.collapsedModelProviders,t.collapsedModelProviders)&&Mi(e.providerOrder,t.providerOrder)&&Ai(e.recentModels,t.recentModels)&&Mi(e.recentAgents,t.recentAgents)&&Ni(e.recentEfforts,t.recentEfforts),Ii=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()]))}),Li=()=>{if(typeof window>`u`)return()=>{};let e=null,t=null,n=!1,r=()=>{e=null;let n=Pi();t&&Fi(t,n)||(t=Ii(n),V(n).catch(()=>{}))},i=()=>{if(!n){n=!0;return}e!==null&&window.clearTimeout(e),e=window.setTimeout(r,1200)},a=G.subscribe((e,t)=>{Fi({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)}},Ri=!1,zi=`yuri-typography-base`,Bi=()=>{if(typeof document>`u`)return;let e=`:root {\n${Object.entries(Re).map(([e,t])=>` --text-${e.replace(/([A-Z])/g,`-$1`).toLowerCase()}: ${t};`).join(`
|
|
4
|
+
`)}\n}\n`,t=document.getElementById(zi);if(t){t.textContent=e;return}let n=document.createElement(`style`);n.id=zi,n.textContent=e,document.head.appendChild(n)},Vi=()=>{Ri||typeof window>`u`||(Ri=!0,Bi())};function Hi(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)(Ui,r);let i;return t[1]===n?i=t[2]:(i=(0,Q.jsx)(we,{client:ke,children:n}),t[1]=n,t[2]=i),i}function Ui(){return Oe(ke)}var Wi=15,Gi=2e3,Ki=40,qi=2e4,Ji=e=>{let t=K(e=>e.isConnected),n=K(e=>e.providers.length),r=K(e=>e.agents.length),i=K(e=>e.activeDirectoryKey),a=K(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=W(async()=>{if(!o||c.current||l===`done`)return;let e=l===`fast`?Wi:Ki;if(s.current>=e){if(l===`fast`){s.current=0,u(`slow`);return}u(`done`);return}let t=K.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]),Me(f,!o||l===`done`?null:l===`slow`?qi:Gi)},Yi=40,Xi=20971520,Zi=new Map,Qi=0;function $i(e){return e.length*2}function ea(e,t){let n=Zi.get(e);n!==void 0&&(Qi-=n),Zi.delete(e),Zi.set(e,t),Qi+=t}function ta(e,t){let n=Zi.get(e);(n!==void 0||t!==void 0)&&ea(e,t??n??0)}function na(e){let t=Zi.get(e);t!==void 0&&(Zi.delete(e),Qi-=t)}function ra(e,t){let n=e??new Set;for(;Zi.size>Yi||Qi>Xi;){let e=Zi.keys().next().value;if(!e)return;if(n.has(e)){if(ta(e),Zi.size<=n.size)return;continue}na(e),t(e)}}function ia(e,t){ea(e,t)}function aa(e){na(e)}function oa(e,t){ta(e,t)}function sa(e){let t=new Map,n=e=>{t.delete(e),aa(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=$i(r.content);return t.set(e,{...r,size:i?.isFile?i.size:void 0,mtimeMs:i?.isFile?i.mtimeMs:void 0}),ia(e,a),ra(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 oa(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 ca(e){let t=(0,Z.c)(8),{apis:n,children:r}=e,i;t[0]===n.files?i=t[1]:(i=sa(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)(Ae.Provider,{value:o,children:r}),t[5]=o,t[6]=r,t[7]=s):s=t[7],s}var la=`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))`,ua=`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))`,da={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 fa(){let e=(0,Z.c)(2),t=pa,[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 pa(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)}function ma(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 ha=e=>{let t=(0,Z.c)(8),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r=fa(),i=r?la:ua,a=X.useRef(null);ma(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)(ze,{theme:s,className:`toaster group`,position:`bottom-right`,closeButton:!1,duration:3500,icons:da,toastOptions:c,style:l,...n})}),t[5]=n,t[6]=s,t[7]=u):u=t[7],u},ga=2e4,_a=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus()?`visible`:`hidden`,va=e=>{if(!_()&&!w())return;let t=O();t?.push?.setVisibility&&t.push.setVisibility({visible:e,platform:E()})},ya=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=()=>va(e);Ne(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&&va(!0)},ga);return()=>{t=!0,window.clearInterval(i),n?.()}}if(typeof document>`u`)return;let e=()=>{va(_a()===`visible`)},n=()=>{_a()===`visible`&&va(!0)},r=()=>{va(!1)};e();let i=window.setInterval(n,ga);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])},ba=`Yuri`,xa=()=>`${m()}\0${u()}`,Sa=e=>Te({queryKey:[`desktop-window-hosts`,e],queryFn:async({signal:e})=>{let t=await se();return e.throwIfAborted(),t.hosts}}),Ca=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``).split(`/`).filter(Boolean);return t[t.length-1]??``},wa=(e,t)=>[e,t,ba].filter(e=>typeof e==`string`&&e.trim().length>0).join(` | `),Ta=()=>{let e=(0,Z.c)(15),{t}=ct(),n=Ue(Ea),r=X.useSyncExternalStore(c,xa,xa),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=Sa(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}=Ee(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&&F(n,M(e))));f=a?r?.label?.trim()?L(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=wa(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 Ea(e){if(!e.activeProjectId)return null;let t=e.projects.find(t=>t.id===e.activeProjectId);return t&&Ca(t.path)||null}var Da=e=>{let t=[];return e.hideGit||t.push(`git`),t.push(`files`),e.showBrowser&&t.push(`browser`),t},Oa=()=>{let e=q.getState().currentSessionId;if(!e)return``;let t=he().find(t=>t.id===e);return typeof t?.directory==`string`?t.directory:``},ka=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)}},Aa=e=>{if(!e||!Number.isFinite(e))return`(n/a)`;try{return new Date(e).toISOString()}catch{return`(invalid)`}},ja=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},Ma=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Na=(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,Pa=(e,t,n)=>e===`node-shebang`||e===`node-launcher`?t?`node (${t})`:`node`:e===`bun-shebang`?n?`bun (${n})`:`bun`:e||`direct executable`,Fa=async()=>{let e=new Date,t=typeof navigator<`u`?navigator.userAgent:`(no navigator)`,n=Oa(),r=G.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 ka(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.4`),p.push(`Runtime: ${i||`(unknown)`} (api=${s||`(unknown)`})`),p.push(`OpenCode SDK base: ${ve.getBaseUrl()}`),p.push(`Event stream: ${r}`),p.push(`Directory: ${n||`(none)`}`),p.push(`Platform: ${t}`);let m=ja(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}`),Ma(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=Ma(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: ${Na(e.launchedAt)}`),p.push(`- launch: ${Na(e.binary)} ${t.join(` `)}`.trim()),p.push(`- cwd: ${Na(e.cwd)}`),p.push(`- wrapper: ${Na(e.wrapperType)}`),p.push(`- runtime: ${Pa(Na(e.wrapperType,``),f,m)}`),p.push(`- PATH entries: ${Na(e.pathEntryCount,`(unknown)`)}`),p.push(`- shell env: ${Na(e.hasShellEnv,`(unknown)`)} (${Na(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: ${Pa(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: ${Aa(Date.now())}`),p.join(`
|
|
5
|
+
`)},Ia=async()=>{let e=await Fa(),t=G.getState();t.setOpenCodeStatusText(e),t.setOpenCodeStatusDialogOpen(!0)},La=(e,t)=>e===t?!0:!e||!t?!1:e.scope===t.scope&&e.sessionId===t.sessionId&&e.projectId===t.projectId,Ra=e=>e?`${e.scope}:${e.projectId??``}:${e.sessionId}`:null,za=e=>({scope:`project`,sessionId:e,projectId:null}),Ba=ce()(e=>({focus:null,setFocus:t=>e(e=>La(e.focus,t)?e:{focus:t})})),Va=null,Ha=0,Ua=(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},Wa=e=>{let t=++Ha;return Va={pinned:Ua(`pinned`,e.pinned),project:Ua(`project`,e.project)},()=>{Ha===t&&(Va=null)}},Ga=()=>Va,Ka=e=>!!e.parentID,qa=(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&&Ka(r);){let e=r.parentID;if(!e)break;let t=n.get(e);if(!t)return e;r=t}return r?.id??e},Ja=()=>{let e=Ge.getState().activeSessions;if(e.length>0)return e;let t=be();return t.length>0?t:he()},Ya=(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)},Xa=e=>[...e.pinned,...e.project],Za=(e,t,n,r)=>{if(e.length===0)return null;let i=Ya(e,n,r);return i<0?t>0?e[0]??null:e[e.length-1]??null:e[(i+t+e.length)%e.length]??null},Qa=(e,t,n=Ba.getState().focus)=>{let r=qa(t,Ja()),i=n?.sessionId===t?n:null,a=Ga();return a?Za(Xa(a),e,r,i):null},$a=(e,t,n=e=>{q.getState().setCurrentSession(e.sessionId,e.directory)})=>{let r=Qa(e,t);return r?(Ba.getState().setFocus({scope:r.scope,sessionId:r.sessionId,projectId:r.projectId}),n(r),r):null},eo=.5,to=.1,no=`yuri.webviewZoomFactor`,ro=e=>Number.isFinite(e)?Math.min(3,Math.max(eo,Math.round(e*100)/100)):1,io=()=>{if(typeof window>`u`)return 1;try{let e=window.localStorage.getItem(no);return e?ro(Number.parseFloat(e)):1}catch{return 1}},ao=e=>{if(!(typeof window>`u`))try{window.localStorage.setItem(no,String(e))}catch{}},oo=e=>{let t=ro(e);return typeof document<`u`&&(document.documentElement.style.zoom=t===1?``:String(t)),ao(t),t},so=()=>{if(typeof document>`u`)return 1;let e=document.documentElement.style.zoom;if(!e)return io();let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?ro(t):io()},co=()=>{if(S())return;let e=io();e!==1&&oo(e)},lo=async()=>{if(S())try{let e=await C(`desktop_zoom_in`);if(typeof e==`number`&&Number.isFinite(e))return ro(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_in failed, using CSS zoom`,e)}return oo(so()+to)},uo=async()=>{if(S())try{let e=await C(`desktop_zoom_out`);if(typeof e==`number`&&Number.isFinite(e))return ro(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_out failed, using CSS zoom`,e)}return oo(so()-to)},fo=async()=>{if(S())try{let e=await C(`desktop_zoom_reset`);if(typeof e==`number`&&Number.isFinite(e))return ro(e)}catch(e){console.warn(`[webview-zoom] desktop_zoom_reset failed, using CSS zoom`,e)}return oo(1)};function po(){let e=(0,Z.c)(36),t=(0,X.useContext)(yt),n=nn(),r=G(vo),i;e[0]!==n||e[1]!==r?(i=n.length?rn([...Pt(),...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(_o)),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=>Nt(e,r).filter(Boolean).map(jt)))]:[],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=W(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(go)}),!1):(e.preventDefault(),e.stopPropagation(),!0)},e[14]=t,e[15]=h,e[16]=g):g=e[16];let _=W(g),v;e[17]!==p||e[18]!==h?(v=()=>{if(!l||!d.current)return;let e=p.filter(e=>!!h(Zt(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(ho))}))},e[17]=p,e[18]=h,e[19]=v):v=e[19];let y=W(v),b;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>(d.current=!0,()=>{d.current=!1,u.current&&u.current!==`[]`&&l?.claim([]).catch(mo),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;je(`focusin`,y,T);let E;e[31]===y?E=e[32]:(E=()=>queueMicrotask(y),e[31]=y,e[32]=E),je(`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 mo(){}function ho(){}function go(){}function _o(e){return[e.id,e]}function vo(e){return e.shortcutOverrides}var yo=9,bo=null,xo=0,So=({pinnedTargets:e,projectTargets:t})=>[...e,...t].slice(0,yo),Co=(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},wo=e=>{let t=++xo;return bo={targets:e.targets.slice(0,yo),activate:e.activate},()=>{xo===t&&(bo=null)}},To=e=>{if(!Number.isInteger(e)||e<1||e>yo)return!1;let t=bo,n=t?.targets[e-1];return!t||!n?!1:(t.activate(n),!0)},Eo=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)},Do=e=>{let t=e.trim();if(!t)return null;let n=G.getState();return!n.isBottomTerminalOpen&&n.activeMainTab!==`terminal`&&n.setBottomTerminalOpen(!0),Eo(t)},Oo=(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)},ko=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}},Ao=()=>typeof window>`u`||window.parent===window||!fn(window.location.search)?!1:(window.parent.postMessage({type:pn},window.location.origin),!0),jo=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=G.getState();if(e)return!1;let n=Mo();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},Mo=()=>{let e=Et(),t=Ue.getState().getActiveProject();if(!t?.hostId)return e;if(!(!t.hubId||!e))return T({hubId:t.hubId,hostId:t.hostId,directory:e})},No=({sessionId:e,surfaceKind:t,wiringCanAbort:n,primaryCanAbort:r,pendingSend:i=!1})=>e?i||n?!0:t!==`secondary`&&r:!1,Po=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)}},Fo=()=>{let e=(0,Z.c)(73),{t}=ct(),{match:n,run:r}=po(),i=q(Io),a=q(Lo),o=q(Ro),s=q(zo),c=qe,l=G(Bo),u=G(Vo),d=G(Ho),f=G(Uo),p=G(Wo),m=G(Go),h=G(Ko),g=G(qo),_=G(Jo),v=G(Yo),y=G(Xo),b=G(Zo),x=G(Qo),w=G($o),T=G(es),E=G(ts),D=G(ns),ee=G(rs),O=G(is),k=pe(as),A=Ue(os),{themeMode:j,setThemeMode:M}=_t(),{working:N}=xn(),P=X.useRef(null),F=X.useRef(null),ne=X.useRef(null),re=X.useRef(!1),ie=X.useRef(j),ae,oe;e[0]===j?(ae=e[1],oe=e[2]):(ae=()=>{ie.current=j},oe=[j],e[0]=j,e[1]=ae,e[2]=oe),X.useEffect(ae,oe);let se;e[3]===o?se=e[4]:(se=()=>{F.current&&=(clearTimeout(F.current),null),P.current=null,o()},e[3]=o,e[4]=se);let I=se,L;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{ne.current&&=(clearTimeout(ne.current),null),_n.getState().clear()},e[5]=L):L=e[5];let R=L,ce;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{ne.current&&=(clearTimeout(ne.current),null);let e=_n.getState().arm(bn);ne.current=setTimeout(()=>{let{expiresAt:e}=_n.getState();e&&Date.now()>=e&&_n.getState().clear(),ne.current=null},Math.max(0,e-Date.now()))},e[6]=ce):ce=e[6];let le=ce,z;e[7]!==A?.id||e[8]!==A?.path||e[9]!==a||e[10]!==k||e[11]!==_||e[12]!==n||e[13]!==i||e[14]!==I||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]!==M||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]!==N?(z=()=>{let e=e=>At(e,O),o=e=>Nt(e,O),s=()=>{let e=Ue.getState().getActiveProject();if(!e?.hostId)return!1;if(y(`chat`),v(!1),!e.hubId)return rt.error(t(`remoteProjects.host-unavailable`)),!0;let n=He.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 He.getState().openRemoteSession(e,r,null),!0},j=ss,ne=[`[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(`,`),ae=e=>e instanceof Element&&!!e.closest(ne),oe=ls,se=ds,L=fs,ce=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;rt.error(n instanceof Error?n.message:t(`chat.chatInput.toast.compactFailed`))}return}let r=q.getState().currentSessionId;if(!r)return;let{currentProviderId:i,currentModelId:a}=K.getState();await Po({sessionId:r,currentProviderId:i,currentModelId:a,waitForConnectionOrThrow:et,getAuthoritativeDirectoryForSession:q.getState().getAuthoritativeDirectoryForSession,summarizeSession:ps,onCompactFailed:e=>{rt.error(e instanceof Error?e.message:t(`chat.chatInput.toast.compactFailed`))}})},z=t=>{let r=_n.getState().pending;if(t.repeat||t.isComposing&&!r||t.defaultPrevented&&!r||j(t.target)&&!r)return;let a=e(`leader_key`);if(r){let e=()=>{re.current=!0,window.setTimeout(()=>{re.current=!1},0)};if(a&&Y(t,a)){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),le();return}let n=t.key.toLowerCase();if(n===`escape`){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),R();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(),R();return}let{activeMainTab:r,isModelSelectorOpen:o,isAgentSelectorOpen:c}=G.getState(),l=hn(r)&&!L();if(n===`m`&&l){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),R(),window.requestAnimationFrame(()=>{x(!o,{instant:!0})});return}if(n===`a`&&l){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),R(),w(!c,{instant:!0});return}if(n===`n`&&l){if(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),R(),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(),R(),ce(),se();return}t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e(),R(),se();return}if(!a||!Y(t,a)||n(t)||L())return;let{activeMainTab:o}=G.getState();hn(o)&&(t.preventDefault(),t.stopPropagation(),le())},B=()=>_n.getState().pending||re.current,ue=e=>{B()&&e.preventDefault()},V=e=>{B()&&(e.preventDefault(),e.stopPropagation())},H=t=>{if(j(t.target)){if(!te()&&Y(t,e(`new_terminal_tab`))){let e=Mo();if(!e||!Eo(e))return;t.preventDefault(),t.stopPropagation();return}if(!te()&&Y(t,e(`previous_terminal_tab`))){let e=Mo();if(!e||!Oo(e,-1))return;t.preventDefault(),t.stopPropagation();return}if(!te()&&Y(t,e(`next_terminal_tab`))){let e=Mo();if(!e||!Oo(e,1))return;t.preventDefault(),t.stopPropagation();return}if(Y(t,e(`close_context_panel_tab`))){let e=Mo();if(!e)return;let{closed:n,wasLastTab:r}=ko(e);if(!n)return;if(t.preventDefault(),t.stopPropagation(),r){let e=G.getState();e.setBottomTerminalOpen(!1),e.activeMainTab===`terminal`&&e.setActiveMainTab(`chat`)}return}if(Y(t,e(`toggle_terminal`))){let{isMobile:e}=G.getState();if(e)return;t.preventDefault(),t.stopPropagation(),h();return}if(Y(t,e(`toggle_bottom_panel`))){let{isMobile:e}=G.getState();if(e)return;t.preventDefault(),t.stopPropagation(),h();return}if(Y(t,e(`toggle_terminal_expanded`))){let{isMobile:e,isBottomTerminalExpanded:n}=G.getState();if(e)return;t.preventDefault(),t.stopPropagation(),g(!n);return}}},U=ms,de=n=>{if(n.defaultPrevented||n.isComposing||n.keyCode===229||r(n))return;if(Y(n,e(`close_context_panel_tab`))){(Ao()||jo())&&(n.preventDefault(),n.stopPropagation());return}if(j(n.target))return;let a=hs;if(a(n.target)&&n.ctrlKey&&!n.metaKey&&!n.shiftKey&&!n.altKey&&n.key.toLowerCase()===`t`){n.preventDefault(),U();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}=G.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(),Ia();return}if(Y(n,e(`open_help`))){n.preventDefault(),u();return}if(S()&&Y(n,e(`new_mini_chat`))){if(n.preventDefault(),Ue.getState().getActiveProject()?.hostId){rt.error(t(`miniChat.unavailable.title`),{description:t(`remoteProjects.miniChatUnsupportedReason`)});return}C(`desktop_open_draft_mini_chat_window`,{directory:k||A?.path||``,projectId:A?.id??null}).catch(gs);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(),hi()!==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(ie.current)+1)%e.length;M(e[r]),requestAnimationFrame(()=>{typeof document>`u`||typeof window>`u`||(document.hasFocus()||window.focus(),t&&document.contains(t)&&t.focus({preventScroll:!0}))});return}if(Mt(n,`in`,e(`zoom_in`))){n.preventDefault(),lo();return}if(Mt(n,`out`,e(`zoom_out`))){n.preventDefault(),uo();return}if(Y(n,e(`zoom_reset`))){n.preventDefault(),fo();return}if(Y(n,e(`open_settings`))){n.preventDefault();let{isSettingsDialogOpen:e}=G.getState();b(!e);return}if(Y(n,e(`toggle_sidebar`))){n.preventDefault();let{isMobile:e,isSessionSwitcherOpen:t}=G.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`)?jt(`shift+${D}`):``,N=O&&Y(n,O)?-1:+!!Y(n,D);if(N!==0){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:r,isSessionSwitcherOpen:i,isAboutDialogOpen:o,activeMainTab:s}=G.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`,N);return}let u=K.getState(),d=$e(u.getVisibleAgents(),u.currentAgentName,N);if(!d)return;n.preventDefault(),u.setAgent(d),G.getState().addRecentAgent(d);let f=q.getState().currentSessionId;f&&tt.getState().saveSessionAgentSelection(f,d);return}if(o(`toggle_right_sidebar`).some(e=>Y(n,e))){let{isMobile:e}=G.getState();if(e)return;n.preventDefault();let t=Mo();t&&f(t);return}if(Y(n,e(`open_right_sidebar_git`))){let{isMobile:e}=G.getState();if(e)return;n.preventDefault();let t=Mo();t&&G.getState().openContextPanel(t),p(!0),m(`git`);return}if(Y(n,e(`open_right_sidebar_files`))){let{isMobile:e}=G.getState();if(e)return;n.preventDefault();let t=Mo();t&&G.getState().openContextPanel(t),p(!0),m(`files`);return}if(Y(n,e(`cycle_right_sidebar_tab`))){let{isMobile:e,rightSidebarTab:t}=G.getState();if(e)return;let r=Da({hideGit:G.getState().activeMainTab===`git`,showBrowser:Xt(on())}),i=r[(r.indexOf(t)+1)%r.length];n.preventDefault();let a=Mo();a&&G.getState().openContextPanel(a),p(!0),m(i);return}let P=e=>$a(e,q.getState().currentSessionId,e=>{y(`chat`),v(!1),q.getState().setCurrentSession(e.sessionId,e.directory)});if(o(`previous_session`).some(e=>Y(n,e))){n.preventDefault(),P(-1);return}if(o(`next_session`).some(e=>Y(n,e))){n.preventDefault(),P(1);return}for(let t=1;t<=9;t+=1)if(Y(n,e(`switch_tab_${t}`))){To(t)&&n.preventDefault();return}if(Y(n,e(`toggle_terminal`))){let{isMobile:e}=G.getState();if(e)return;n.preventDefault(),h();return}if(Y(n,e(`open_new_terminal`))){let{isMobile:e}=G.getState();if(e||te())return;let t=Mo();if(!t||!Do(t))return;n.preventDefault();return}if(Y(n,e(`toggle_bottom_panel`))){let{isMobile:e}=G.getState();if(e)return;n.preventDefault(),h();return}if(Y(n,e(`toggle_terminal_expanded`))){let{isMobile:e,isBottomTerminalExpanded:t}=G.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}=G.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`))){U()&&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}=G.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=K.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}=K.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}=G.getState();if(!hn(e)||t||r||i||a)return;n.preventDefault(),window.dispatchEvent(new CustomEvent(`yuri:dictation-toggle`));return}},fe=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=ae(t)||oe(),{isSettingsDialogOpen:s,isCommandPaletteOpen:l,isHelpDialogOpen:u,isSessionSwitcherOpen:d,isAboutDialogOpen:f,isMultiRunLauncherOpen:p,isImagePreviewOpen:m,isPromptNavigatorPanelOpen:h,workStatusOverlayOpen:g}=G.getState();if(n||i||o){I();return}if(g){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),G.getState().setWorkStatusOverlayOpen(!1),I();return}if(h){e.preventDefault(),D(!1),I();return}if(s){e.preventDefault(),b(!1),I();return}if(r){I();return}if(l||u||d||f||p||m){I();return}let _=vn(),v=_?Sn(_):null,y=_?.sessionID??q.getState().currentSessionId,x=!!(y&&q.getState().pendingSendMessageIDs.get(y));if(!No({sessionId:y,surfaceKind:_?.kind,wiringCanAbort:v?.canAbort,primaryCanAbort:N.canAbort,pendingSend:x})){I();return}e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();let S=Date.now(),C=P.current;if(C&&S<C){I(),v?v.abort():(y&&Pn(y),c(y??``));return}let w=_?.kind===`secondary`?S+3e3:a(3e3)??S+3e3;P.current=w,F.current&&clearTimeout(F.current);let T=Math.max(w-S,0);F.current=setTimeout(()=>{P.current&&Date.now()>=P.current&&I()},T||0)};return window.addEventListener(`keydown`,z,!0),window.addEventListener(`beforeinput`,ue,!0),window.addEventListener(`compositionstart`,V,!0),window.addEventListener(`compositionupdate`,V,!0),window.addEventListener(`compositionend`,V,!0),window.addEventListener(`keydown`,H,!0),window.addEventListener(`keydown`,fe,!0),window.addEventListener(`keydown`,de),()=>{window.removeEventListener(`keydown`,z,!0),window.removeEventListener(`beforeinput`,ue,!0),window.removeEventListener(`compositionstart`,V,!0),window.removeEventListener(`compositionupdate`,V,!0),window.removeEventListener(`compositionend`,V,!0),window.removeEventListener(`keydown`,H,!0),window.removeEventListener(`keydown`,fe,!0),window.removeEventListener(`keydown`,de)}},e[7]=A?.id,e[8]=A?.path,e[9]=a,e[10]=k,e[11]=_,e[12]=n,e[13]=i,e[14]=I,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]=M,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]=N,e[37]=z):z=e[37];let B=A?.id,ue=A?.path,V;e[38]!==a||e[39]!==k||e[40]!==s||e[41]!==_||e[42]!==n||e[43]!==i||e[44]!==I||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]!==M||e[56]!==T||e[57]!==O||e[58]!==t||e[59]!==B||e[60]!==ue||e[61]!==h||e[62]!==l||e[63]!==f||e[64]!==ee||e[65]!==u||e[66]!==E||e[67]!==d||e[68]!==N?(V=[i,c,l,u,d,f,p,m,h,g,_,v,y,b,x,w,T,E,D,ee,M,N,a,I,le,R,s,k,B,ue,O,n,r,t],e[38]=a,e[39]=k,e[40]=s,e[41]=_,e[42]=n,e[43]=i,e[44]=I,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]=M,e[56]=T,e[57]=O,e[58]=t,e[59]=B,e[60]=ue,e[61]=h,e[62]=l,e[63]=f,e[64]=ee,e[65]=u,e[66]=E,e[67]=d,e[68]=N,e[69]=V):V=e[69],X.useEffect(z,V);let H,U;e[70]===I?(H=e[71],U=e[72]):(U=()=>()=>{I(),R()},H=[I,R],e[70]=I,e[71]=H,e[72]=U),X.useEffect(U,H)};function Io(e){return e.openNewSessionDraft}function Lo(e){return e.armAbortPrompt}function Ro(e){return e.clearAbortPrompt}function zo(e){return e.currentSessionId}function Bo(e){return e.toggleCommandPalette}function Vo(e){return e.toggleHelpDialog}function Ho(e){return e.toggleSidebar}function Uo(e){return e.toggleContextPanel}function Wo(e){return e.setRightSidebarOpen}function Go(e){return e.setRightSidebarTab}function Ko(e){return e.toggleBottomTerminal}function qo(e){return e.setBottomTerminalExpanded}function Jo(e){return e.isMobile}function Yo(e){return e.setSessionSwitcherOpen}function Xo(e){return e.setActiveMainTab}function Zo(e){return e.setSettingsDialogOpen}function Qo(e){return e.setModelSelectorOpen}function $o(e){return e.setAgentSelectorOpen}function es(e){return e.setTimelineDialogOpen}function ts(e){return e.togglePromptNavigatorPanel}function ns(e){return e.setPromptNavigatorPanelOpen}function rs(e){return e.toggleExpandedInput}function is(e){return e.shortcutOverrides}function as(e){return e.currentDirectory}function os(e){return e.getActiveProject()}function ss(e){return e instanceof Element&&!!(e.closest(`[data-terminal-view="true"]`)||e.closest(`.terminal-viewport-container`)||e.getAttribute(`data-terminal-hidden-input`)===`true`)}function cs(e){return e.getClientRects().length>0}function ls(){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(cs)}function us(){document.querySelector(`textarea[data-chat-input="true"]`)?.focus({preventScroll:!0})}function ds(){window.requestAnimationFrame(us)}function fs(){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:n,isSessionSwitcherOpen:r,isAboutDialogOpen:i}=G.getState();return e||t||n||r||i}function ps(e,t,n,r){return ve.summarizeSession(e,t,n,r)}function ms(){let{isSettingsDialogOpen:e,isCommandPaletteOpen:t,isHelpDialogOpen:n,isSessionSwitcherOpen:r,isAboutDialogOpen:i,activeMainTab:a}=G.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=K.getState();if(s.getCurrentModelVariants().length===0)return!1;s.cycleCurrentVariant();let c=K.getState().currentVariant,l=q.getState().currentSessionId,u=K.getState().currentAgentName,d=K.getState().currentProviderId,f=K.getState().currentModelId;return l&&u&&d&&f&&tt.getState().saveAgentModelVariantForSession(l,u,d,f,c),u&&d&&f&&K.getState().saveAgentModelSelection(u,d,f,c),!0}function hs(e){return e instanceof HTMLTextAreaElement&&e.getAttribute(`data-chat-input`)===`true`}function gs(e){console.warn(`[keyboard-shortcuts] failed to open draft mini chat window`,e)}var _s=3,vs=(e,t)=>{if(typeof e!=`string`)return t;let n=e.trim().replace(/\s+/g,` `);return n?n.slice(0,48):t},ys=(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:vs(e.title,`Session ${r.length+1}`)}),r.length>=_s))break}return r},bs=()=>{let e=(0,Z.c)(9),t=at(),n=q(xs),r;e[0]!==n||e[1]!==t?(r=ys(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 xs(e){return e.currentSessionId}var Ss=e=>Number.isFinite(e)?`${Math.max(0,Math.round(e))}px`:`0px`,Cs=(e,t,n,r)=>{e.style.setProperty(`--yuri-wco-left-inset`,Ss(t)),e.style.setProperty(`--yuri-wco-right-inset`,Ss(n)),e.style.setProperty(`--yuri-wco-titlebar-height`,Ss(r))},ws=()=>{let e=(0,Z.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],X.useEffect(Ts,t)};function Ts(){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){Cs(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));Cs(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),Cs(e,0,0,0)}}var Es=3e4,Ds=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,Os=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`,ks=(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})}),As=(e,t)=>e.then(e=>{if(t?.aborted)throw new DOMException(`Aborted`,`AbortError`);return e}),js={fetchSnapshot:e=>As(An(ke),e),refreshSnapshot:e=>As(En(ke),e),fetchOrder:Cn,setOrder:wn,waitInvalidation:Tn,captureRuntime:()=>({transportIdentity:u(),generation:f()}),isCurrent:e=>e.transportIdentity===u()&&e.generation===f(),sleep:ks,createRequestID:()=>typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`worktree-order-${Date.now()}-${Math.random().toString(36).slice(2)}`},Ms=new Map,Ns=()=>{for(let e of Ms.values())e.controller.abort();Ms.clear()},Ps=(e,t,n,r=js)=>{Ms.get(e)?.controller.abort();let i={projectDirectory:Ds(t),orderedPaths:[...n],capture:r.captureRuntime(),controller:new AbortController,backoffMs:500,running:!1};Ms.set(e,i),Fs(e,r)},Fs=async(e,t=js)=>{let n=Ms.get(e);if(!(!n||n.running)){n.running=!0;try{for(;;){let n=Ms.get(e);if(!n||!t.isCurrent(n.capture)||n.controller.signal.aborted)return;let r=Ze.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)||Ms.get(e)!==n)return;let a=i.worktreeOrder??{projectDirectory:n.projectDirectory,orderedPaths:n.orderedPaths,revision:i.revision};Ze.getState().setServerRevision(e,a.revision),Ze.getState().resolvePendingWorktreeOrder(e,a.revision),Ms.delete(e);return}catch(r){if(n.controller.signal.aborted||!t.isCurrent(n.capture)||Ms.get(e)!==n)return;if(r instanceof Dn&&r.code===`revision_conflict`)try{let r=await t.fetchOrder(n.projectDirectory,n.controller.signal);if(Ms.get(e)!==n||!t.isCurrent(n.capture))return;Ze.getState().applyServerWorktreeOrder(e,r.orderedPaths,r.revision),n.expectedRevision=void 0,n.requestID=void 0,n.backoffMs=500;continue}catch(e){if(Os(e)!==`retry`)return}else if(Os(r)!==`retry`)return;if(await t.sleep(n.backoffMs,n.controller.signal).catch(()=>{}),n.backoffMs=Math.min(n.backoffMs*2,Es),n.controller.signal.aborted)return}}}finally{Ms.get(e)===n&&(!t.isCurrent(n.capture)||n.controller.signal.aborted)&&Ms.delete(e),Ms.get(e)===n&&(n.running=!1)}}},Is=(e,t,n,r)=>{let i=new Map(t.map(e=>[Ds(e.path),e.id]));for(let t of e){let e=i.get(Ds(t.projectDirectory));e&&r.isCurrent(n)&&Ze.getState().applyServerWorktreeOrder(e,t.orderedPaths,t.revision)}},Ls=(e,t=js)=>{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();Is(r.worktreeOrders,o,a,t);let s=new Set(r.worktreeOrders.map(e=>Ds(e.projectDirectory)));for(let e of o){let n=Ze.getState(),r=n.orderByProject[e.id];n.pendingProjectIDs[e.id]?Ps(e.id,e.path,r??[],t):r?.length&&!s.has(Ds(e.path))&&(n.markPendingWorktreeOrder(e.id),Ps(e.id,e.path,r,t))}break}catch(e){if(Os(e)!==`retry`)return;await t.sleep(r,i).catch(()=>{}),r=Math.min(r*2,Es)}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,Is(s.worktreeOrders,e(),a,t),r=500}catch(e){if(Os(e)!==`retry`)return;await t.sleep(r,i).catch(()=>{}),r=Math.min(r*2,Es)}})()},stop:r}},Rs=()=>{let e=(0,Z.c)(2),t=Ue(Bs),n;e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),X.useEffect(Us,n)};function zs(e){return[e.id,Ds(e.path)]}function Bs(e){return JSON.stringify(e.projects.map(zs))}function Vs(e,t,n){return Ps(e,t,n)}function Hs(){return Ue.getState().projects}function Us(){let e=u();Ze.getState().activateWorktreeOrderRuntime(e);let t=Ke(Vs),n=Ls(Hs);n.start();let r=c(e=>{p(e)&&(Ns(),Ze.getState().activateWorktreeOrderRuntime(u()),n.start())});return()=>{t(),r(),n.stop(),Ns()}}var Ws=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,Gs=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=Ws(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,Ws(t.repositoryDirectory)),g.add(a);for(let n of t.addedDirectories){let t=Ws(n);(!e.needsSessionSync||e.needsSessionSync(t))&&m.add(t)}if(e.needsSessionSync)for(let n of t.worktrees){let t=Ws(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])=>Ws(e)===n||t.some(e=>Ws(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(Ws(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=Ws(n.path),i=t.get(r)?.some(t=>Ws(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=Ws(i.projectDirectory),a={},o=c.get(n),s=e.getCatalog();for(let t of e.getProjects()){let e=Ws(t.path),r=s.get(e)?.some(t=>Ws(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??Ws(await e.resolveRepository(n));for(let n of e.getProjects()){let u=Ws(n.path);if(!(o&&c.has(u)))try{let o=c.get(u)??Ws(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${Ws(e.path)}`).sort().join(`
|
|
6
|
+
`),v.push(e.subscribeProjects(()=>{let t=e.getProjects().map(e=>`${e.id}\u0000${Ws(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}},Ks=null,qs=0,Js=()=>(Ks||=Gs({isVSCode:te,getProjects:()=>Ue.getState().projects,getCatalog:()=>q.getState().availableWorktreesByProject,getActiveDirectories:()=>{let e=Ge.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=Ge.getState(),n=Ws(e);return!t.loadedDirectories.has(n)&&!t.loadingDirectories.has(n)&&!t.refreshingDirectories.has(n)},refresh:Ln,resolveRepository:Dt,syncAdded:e=>Be(e,Ge.getState().activeSessions),subscribeProjects:e=>Ue.subscribe(e),subscribeCatalog:e=>q.subscribe((t,n)=>{t.availableWorktreesByProject!==n.availableWorktreesByProject&&e()}),subscribeSessions:e=>Ge.subscribe((t,n)=>{(t.activeSessions!==n.activeSessions||t.cachedDirectories!==n.cachedDirectories)&&e()}),subscribeEvents:De,subscribeRuntime:e=>c(t=>e(p(t))),generation:f,setTimer:(e,t)=>globalThis.setTimeout(e,t),clearTimer:e=>globalThis.clearTimeout(e)}),qs+=1,Ks.start(),()=>{qs=Math.max(0,qs-1),qs===0&&Ks?.stop()});function Ys(){if(O()?.runtime.isVSCode)return()=>{};let e=new Ce(ke,zn()),t=De(e=>{(e.type===`speech-settings-changed`||e.type===`event-stream-ready`)&&ke.invalidateQueries({queryKey:zn().queryKey,exact:!0})}),n=t=>{if(!t.data||e.options.queryKey[0]!==u())return;let n=K.getState();Object.entries(t.data).some(([e,t])=>n[e]!==t)&&K.setState(t.data)},r=e.subscribe(n);n(e.getCurrentResult());let i=c(()=>{K.setState(Je),e.setOptions(zn()),n(e.getCurrentResult())});return()=>{i(),r(),t(),e.destroy()}}var Xs=`yuri:mini-chat-presence`,Zs=()=>{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(()=>Js(),[]),null},Qs=()=>{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(nc,t),null},$s=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(Ys,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(rc,a);let o;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Zs,{}),t[2]=o):o=t[2],o}),ec=X.memo(function(e){let t=(0,Z.c)(6),{embeddedBackgroundWorkEnabled:n}=e;bs(),ws(),Fo(),Rs();let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0],X.useEffect(ic,r);let i;t[1]===n?i=t[2]:(i=(0,Q.jsx)($s,{embeddedBackgroundWorkEnabled:n}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Qs,{}),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 tc(e){let t=e.data;if(t?.type!==`mini-chat-session-presence`||!t.sessionId||!t.directory)return;let n=t.viewed!==!1;We(t.directory,t.sessionId,n),n&&Ye(t.sessionId)}function nc(){if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(Xs);return e.onmessage=tc,()=>e.close()}function rc(){let e=On(),t=Fn();e.start(),t.start();let n=jn(e);return()=>{n(),t.stop(),e.stop()}}function ic(){co()}var ac=new Set,oc=new Map,sc=(e,t)=>`https://cdn.jsdelivr.net/npm/${encodeURIComponent(e.packageName).replace(`%40`,`@`).replace(`%2F`,`/`)}/files/${e.filePrefix}-latin-${t}-normal.woff2`,cc=(e,t)=>{let n=`${e.family}:${t}`;if(ac.has(n))return Promise.resolve();let r=oc.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(${sc(e,t)}) format('woff2')`,{style:`normal`,weight:String(t),display:`swap`});document.fonts.add(i);let a=i.load().then(()=>{ac.add(n)}).catch(n=>{document.fonts.delete(i),console.warn(`Failed to load font: ${e.family} ${t}`,n)}).finally(()=>{oc.delete(n)});return oc.set(n,a),a},lc=e=>e?Promise.all(e.weights.map(t=>cc(e,t))).then(()=>void 0):Promise.resolve(),uc=e=>lc(Le[e]?.source),dc=e=>lc(Ie[e]?.source),fc={family:`Syne`,packageName:`@fontsource/syne`,filePrefix:`syne`,weights:[700]},pc=()=>lc(fc);function mc(){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=Le[t]?.stack??Le.system.stack,i=Ie[n]?.stack??Ie[`system-mono`].stack;uc(t),dc(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{Di as A,ha as C,Vi as D,Hi as E,Zn as F,qn as I,Wn as L,ti as M,Jr as N,Li as O,gr as P,Kn as R,ya as S,Ji as T,La as _,$s as a,Da as b,Co as c,lo as d,uo as f,Ra as g,za as h,ec as i,ni as j,ki as k,wo as l,Wa as m,pc as n,Do as o,$a as p,uc as r,So as s,mc as t,fo as u,Ba as v,ca as w,Ta as x,Ia 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{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-Dc9pgW0G.js";import{n as O}from"./Icon-hrdOSdw7.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-BQzoY_Y9.js";import{t as ee}from"./i18n-Cl6MPHiF.js";import{i as M,n as N,t as P}from"./tooltip-CT7PLBB7.js";import{c as F,n as I,t as L}from"./dropdown-menu-ClVMhIUI.js";import{s as R}from"./useGitStore-RwmhQZHK.js";import{_ as z,w as B,y as V}from"./pwa-IFU95Pi8.js";import{t as te}from"./MobileOverlayPanel-CJ4CsOHE.js";import{l as ne,r as re}from"./quota-DJzfHqVc.js";import{n as H,t as U}from"./sessionChangeSummary-BCF9VwAA.js";import{n as W}from"./openRemoteProjectSession-C9DZdUxN.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};
|