@yuriai/web 0.3.7 → 0.3.8-beta.10
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-DPnZENEt.js} +1 -1
- package/dist/assets/{AgentSelector-Db0C7nfY.js → AgentSelector-B46Op3oG.js} +1 -1
- package/dist/assets/ArchivedSessionsDialog-hPG_ZF_w.js +1 -0
- package/dist/assets/{AssistantConversationSurface-Cg0Z0laN.js → AssistantConversationSurface-CG41t5TZ.js} +3 -3
- package/dist/assets/{AssistantSessionCard-CRaYbAwR.js → AssistantSessionCard-DwR2e2Op.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-B0XaBtKU.js → AssistantUnreadBadge-DEwJnQbL.js} +1 -1
- package/dist/assets/AssistantView-BB_CRg4L.js +1 -0
- package/dist/assets/{AssistantWorkingAvatar-QmEGmd3p.js → AssistantWorkingAvatar-B-ciPk2V.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-SynpDBbu.js → AssistantsSettingsPage-CgsSV4mH.js} +1 -1
- package/dist/assets/{BinaryFileFallback-CLr78pii.js → BinaryFileFallback-BZCfJNKH.js} +1 -1
- package/dist/assets/{BtwPanel-eNUn2HxV.js → BtwPanel-DGXcgxQV.js} +2 -2
- package/dist/assets/{BusyDots-CGTf_jqS.js → BusyDots-kwYd9Qsa.js} +2 -2
- package/dist/assets/ChatContainer-BTmCJ0r9.js +65 -0
- package/dist/assets/{ChatView-DJnxvyiB.js → ChatView-5s43Y5II.js} +3 -3
- package/dist/assets/{DiagramView-BQ_5mLmc.js → DiagramView-D4CKBzKi.js} +1 -1
- package/dist/assets/{DiffView-KE3aMklA.js → DiffView-B20uCbQX.js} +2 -2
- package/dist/assets/{DiffViewToggle-B-fDu13M.js → DiffViewToggle-DBQpSRIo.js} +1 -1
- package/dist/assets/{ErrorBoundary-BMkurwx0.js → ErrorBoundary-DKq1dmQm.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BNxn8bBO.js → FadeInOnReveal-v5HRJxQe.js} +1 -1
- package/dist/assets/{GuiPluginMount-CcxWjZGn.js → GuiPluginMount-HFg1spLR.js} +1 -1
- package/dist/assets/{GuiPluginPage-B6DZGRf5.js → GuiPluginPage-BldXLT7J.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CZ-rTgd0.js → GuiPluginSurface-SMONtsaS.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-ByapzQyJ.js → GuiPluginTitlebarItems-DJjbMDL7.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DtZqX_qS.js → GuiPluginWindow-9eobm2HP.js} +1 -1
- package/dist/assets/{Icon-CUOVBCQn.js → Icon-DRYS22Bv.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-ON75MLXx.js → ImageLoadingPlaceholder-DVvOvego.js} +1 -1
- package/dist/assets/{LoadingImage-CE1QZoPZ.js → LoadingImage-Dod2774c.js} +1 -1
- package/dist/assets/MarkdownRenderer-QZiD7To8.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-SH7kLqNr.js → MarkdownRendererImpl-16EYvj2e.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-kWCEeJ84.js → MarkstreamRendererImpl-BF2CJ1Br.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-DkSgJLH5.js → MobileAssistantSettingsPage-DLB8ArSr.js} +1 -1
- package/dist/assets/{MobileAssistantTab-DlreBfpD.js → MobileAssistantTab-B7EWKsL-.js} +1 -1
- package/dist/assets/{MobileBtwPage-DUOHjbOb.js → MobileBtwPage-B2E9Mrjn.js} +1 -1
- package/dist/assets/{MobileChangesSurface-s-IkQzDj.js → MobileChangesSurface-gg1BLxbj.js} +1 -1
- package/dist/assets/{MobileChatScreen-RJicegCg.js → MobileChatScreen-dSGMP_cS.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-B0Xb37E5.js → MobileDetailNavigation-HFdB1csw.js} +1 -1
- package/dist/assets/{MobileFilesSurface-CR7C7ern.js → MobileFilesSurface-CMbKHoLM.js} +2 -2
- package/dist/assets/{MobileHtmlNetworkBoundary-CG4kdWvo.js → MobileHtmlNetworkBoundary-sRFhJXff.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-DLDL_a6S.js → MobileOverlayPanel-u_wq6uYl.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BTsMGacb.js → MobileResizableSheet-D7mX3hic.js} +1 -1
- package/dist/assets/{MobileSettingsTab-DIqufnwp.js → MobileSettingsTab-CpqHKgQr.js} +1 -1
- package/dist/assets/{MobileShareBridge-BgAD2FqK.js → MobileShareBridge-DinsyF38.js} +2 -2
- package/dist/assets/{MobileSurface-D_9tJDu_.js → MobileSurface-D25CgpkA.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-CPEY1sVL.js → MobileTabPageHeader-DZueoczl.js} +1 -1
- package/dist/assets/{ModelLogo-CoEkCK6k.js → ModelLogo-6rKdl3Oo.js} +1 -1
- package/dist/assets/{ModelSelector-CdSx-1l3.js → ModelSelector-_rBHp6p6.js} +1 -1
- package/dist/assets/{MultiRunWindow-08NX-bpU.js → MultiRunWindow-CpPHLNh6.js} +1 -1
- package/dist/assets/{OnboardingScreen-DW4PQZ48.js → OnboardingScreen-BecSplt9.js} +1 -1
- package/dist/assets/{OverlayScrollbar-D4U670-p.js → OverlayScrollbar-n7s4ry-S.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CU2O_Gqy.js → PierreDiffViewer-DzM2fd3I.js} +1 -1
- package/dist/assets/ProviderLogo-DsIQuH14.js +1 -0
- package/dist/assets/{RemoteAssistantSessionCard-44WC5u9f.js → RemoteAssistantSessionCard-D9eJUpK-.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-BfdjP2Ug.js → RemoteDesktopPanel-BMaQHTOl.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-p2z6x4k7.js → ScheduledTasksDialog-BSxPw-np.js} +1 -1
- package/dist/assets/{ScrollableOverlay-B5Mx_IrY.js → ScrollableOverlay-D1BVukId.js} +1 -1
- package/dist/assets/{SettingsGroup-Bd0hGXKp.js → SettingsGroup-CKOh9w7t.js} +1 -1
- package/dist/assets/SettingsView-nMaFvRQ8.js +29 -0
- package/dist/assets/{SettingsWindow-DO2ySMZ8.js → SettingsWindow-DFw624ap.js} +1 -1
- package/dist/assets/{SetupTourDialog-Bm0scCiD.js → SetupTourDialog-BT8DhFGd.js} +1 -1
- package/dist/assets/{SyncActions-ktq_QbjA.js → SyncActions-bV7M8nD9.js} +1 -1
- package/dist/assets/{TerminalView-tXyVGRwg.js → TerminalView-DFQ5LQFM.js} +2 -2
- package/dist/assets/{TextSelectionMenu-CCsFVQha.js → TextSelectionMenu-DjIKcOvS.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BX3Vi-k5.js → ToolOutputDialog-DManupRM.js} +1 -1
- package/dist/assets/{YuriLogo-1yVZFnVN.js → YuriLogo-CrpZasNm.js} +1 -1
- package/dist/assets/YuriWordmark-CqWOXOaU.js +1 -0
- package/dist/assets/{assistantMessagePreview-Bh2bPUPh.js → assistantMessagePreview-CL7aPQNb.js} +1 -1
- package/dist/assets/{assistantQueries-9sjQcHoO.js → assistantQueries-CSf1LSid.js} +1 -1
- package/dist/assets/{auto-read-context-JBvQYPyM.js → auto-read-context-D3F0UdYo.js} +1 -1
- package/dist/assets/{capgoAdapter-llXcw7v2.js → capgoAdapter-BQmoIY_V.js} +1 -1
- package/dist/assets/{card-YOYJB2Bf.js → card-DbO12aT2.js} +1 -1
- package/dist/assets/{chatUpwardIntent-Z6bMNkax.js → chatUpwardIntent-Bes8fOez.js} +1 -1
- package/dist/assets/{checkbox-ByuwPnuS.js → checkbox-BcPtk77d.js} +1 -1
- package/dist/assets/client-A12QacVZ.js +7 -0
- package/dist/assets/{collapsible-ByaFR6Oc.js → collapsible-BGE4f0JY.js} +1 -1
- package/dist/assets/connection-hint-DPOCdR6S.js +2 -0
- package/dist/assets/{context-menu-DKL8DaT6.js → context-menu-JFytjJX_.js} +1 -1
- package/dist/assets/desktopRelayRestore-DtGRUKC-.js +1 -0
- package/dist/assets/{diagram-DkVURCJZ.js → diagram-AxsHXJ5W.js} +1 -1
- package/dist/assets/{dialog-CQbyU8pU.js → dialog-CunzOg5u.js} +1 -1
- package/dist/assets/{dropdown-menu-W3Ii298F.js → dropdown-menu-BKaUC_RK.js} +1 -1
- package/dist/assets/es-D_Gfd9Fr.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-CwTAmgan.js → fileMentionTouchSelection-Doo_ED67.js} +1 -1
- package/dist/assets/fr-DrnzV0-7.js +13 -0
- package/dist/assets/{gitApi-droqYZ9A.js → gitApi-CR5Ik-QG.js} +4 -4
- package/dist/assets/gitApiHttp-BLNjaxGv.js +3 -0
- package/dist/assets/{i18n-Sh2Qk9nD.js → i18n-Do5ekTxf.js} +1 -1
- package/dist/assets/{icons-CLvvQeAy.js → icons-DtK1ZGy1.js} +1 -1
- package/dist/assets/{input-DSdEvspA.js → input-Wb8eI0Ik.js} +1 -1
- package/dist/assets/{insertionBoundaries-Bf3EMWj8.js → insertionBoundaries-BPedMREl.js} +1 -1
- package/dist/assets/ja-DF-CGXwT.js +15 -0
- package/dist/assets/{kbd-hp3-RDSe.js → kbd-D07oDFdN.js} +1 -1
- package/dist/assets/ko-o89xwzdK.js +15 -0
- package/dist/assets/main-10EuKAcH.js +2 -0
- package/dist/assets/main-BbCr0xc0.js +169 -0
- package/dist/assets/main-C5ruSn_v.css +1 -0
- package/dist/assets/{markdownHeightCache-qX2f-vgi.js → markdownHeightCache-D08JEMYV.js} +1 -1
- package/dist/assets/{mcpQueries-DKxn0-Iq.js → mcpQueries-CT_XajCf.js} +1 -1
- package/dist/assets/miniChat-Oriel0PR.js +2 -0
- package/dist/assets/mobile-BXcWitYY.js +2 -0
- package/dist/assets/{mobileBackNavigation-Ce-CFzRu.js → mobileBackNavigation-CC9_oTr0.js} +1 -1
- package/dist/assets/{mobileConnections-BWToBinV.js → mobileConnections-BQXSBf4C.js} +2 -2
- package/dist/assets/{multirun-ByBZh9To.js → multirun-snw4oD5m.js} +1 -1
- package/dist/assets/{native-config-BDAV-Sn-.js → native-config-DBOpCdps.js} +1 -1
- package/dist/assets/{nativeComposerCover-DcWXqfZa.js → nativeComposerCover-CzrbG_Nf.js} +1 -1
- package/dist/assets/{navigation-DiqbYNCD.js → navigation-CkjjVHYQ.js} +1 -1
- package/dist/assets/{openRemoteProjectSession-DPb8H79n.js → openRemoteProjectSession-cchV6HLE.js} +1 -1
- package/dist/assets/{openSessionFromDeepLink-gJWOkm8w.js → openSessionFromDeepLink-Cm-ztlpD.js} +2 -2
- package/dist/assets/pl-Bu4HgXY8.js +15 -0
- package/dist/assets/{pluginPresentation-C8XRIFn5.js → pluginPresentation-CZayU9PL.js} +1 -1
- package/dist/assets/pt-BR-CPj1I-qb.js +15 -0
- package/dist/assets/pwa-Dp5Xs-u1.js +2 -0
- package/dist/assets/queue-abort-optimistic-Do-1nBis.js +1 -0
- package/dist/assets/{quota-jMPnmJTS.js → quota-DbpKrGcG.js} +1 -1
- package/dist/assets/{reference-history-BAPLZtrN.js → reference-history-DYFlcEu-.js} +1 -1
- package/dist/assets/remoteProjectQueries-Dq2vrCZs.js +1 -0
- package/dist/assets/{remoteSessionReference-B-5Nd45t.js → remoteSessionReference-2OJnH6aS.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DudyNNIU.js → renderElectronMiniChatApp-C1my_IMR.js} +2 -2
- package/dist/assets/{renderMobileApp-GIRJpszx.js → renderMobileApp-B5z9RNM8.js} +5 -5
- package/dist/assets/{runtimeConfig-CUiokUFx.js → runtimeConfig-rcHH0B0Q.js} +1 -1
- package/dist/assets/runtimeEndpointReset-D3BlEzsh.js +4 -0
- package/dist/assets/{select--wmAuAOB.js → select-BiGMjrlP.js} +1 -1
- package/dist/assets/{sessionLookup-on217pcK.js → sessionLookup-BpYYVMt5.js} +1 -1
- package/dist/assets/{sessionOwnership-BoiTRI2O.js → sessionOwnership--zFZQ_Pv.js} +1 -1
- package/dist/assets/shortcuts-DryfJT69.js +1 -0
- package/dist/assets/{sortable-tabs-strip-DvvltU2l.js → sortable-tabs-strip-4riKQQLu.js} +1 -1
- package/dist/assets/{speechSettingsQueries-Cqj3BM7O.js → speechSettingsQueries-BIyDqqzx.js} +1 -1
- package/dist/assets/src-7dXqzKwf.css +2 -0
- package/dist/assets/store-CR0ht2xS.js +17 -0
- package/dist/assets/{switch-ClpM-4qX.js → switch-B3-h0Mhz.js} +1 -1
- package/dist/assets/{terminalApi-wdwb9MVG.js → terminalApi-DpnhkNX3.js} +1 -1
- package/dist/assets/{textarea-Cpcy0ejH.js → textarea-C-_iWeiY.js} +1 -1
- package/dist/assets/{timeFormat-BaiPCZgf.js → timeFormat-hKdieKsY.js} +1 -1
- package/dist/assets/{tooltip-B9I9lmf0.js → tooltip-DDpHN7zw.js} +1 -1
- package/dist/assets/{truncated-path-BPcF8ywI.js → truncated-path-BNX6u2x_.js} +1 -1
- package/dist/assets/types-ClkyiHj-.js +2 -0
- package/dist/assets/ui-C8B5mZoA.js +13 -0
- package/dist/assets/uk-DT8-H_V5.js +15 -0
- package/dist/assets/useAppFontEffects-CU_bIPu5.js +7 -0
- package/dist/assets/{useDesktopWindowControlsLayout-BA4DI_W1.js → useDesktopWindowControlsLayout-zSKzBJ6Z.js} +1 -1
- package/dist/assets/{useDictation-83-qDgkn.js → useDictation-hDNKhzOz.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DQMEyl5O.js → useEffectiveDirectory-DPQ_Lpkt.js} +1 -1
- package/dist/assets/{useGitStore-Dvd_1jyD.js → useGitStore-DAkV9L3y.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-DWSuMEHF.js → useInlineCommentDraftStore-CK4BJaHk.js} +1 -1
- package/dist/assets/{useMcpConfigStore-7NoTGiyv.js → useMcpConfigStore-CawLA6lj.js} +1 -1
- package/dist/assets/{useMobileSwipeActions-7iuGbwWj.js → useMobileSwipeActions-BZJ68v8x.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-B3NigAUx.js → useMobileTranscriptSyncHint-EfO9MDPX.js} +2 -2
- package/dist/assets/{useModelLists-C5fB7vLV.js → useModelLists-B8HN6eBH.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-B4IGjODK.js → useOpenCodeReadiness-C9PvijnZ.js} +1 -1
- package/dist/assets/usePluginsStore-BfjcgvtM.js +1 -0
- package/dist/assets/{useProjectGitActions-CiL6W09h.js → useProjectGitActions-yvPEth2A.js} +1 -1
- package/dist/assets/{useProjectGitStore-Bv65Bj_P.js → useProjectGitStore-D_q2csGs.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-CYT-3dZd.js → useProjectRuntimeAPIs-V33EYekW.js} +1 -1
- package/dist/assets/{useQuotaStore-CHxR2ZkD.js → useQuotaStore-CrOyolUQ.js} +1 -1
- package/dist/assets/{useSessionBtwStore-H4R5jYT2.js → useSessionBtwStore-DBhEqs0r.js} +2 -2
- package/dist/assets/{useStreamingTextThrottle-D9STYrQw.js → useStreamingTextThrottle-DfPMoxv4.js} +1 -1
- package/dist/assets/{useTerminalStore-C_QzSEgP.js → useTerminalStore-ax8bDQrp.js} +1 -1
- package/dist/assets/{worktreeManager-33ddwAq1.js → worktreeManager-CAjuvwiZ.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-Cp5jF1M9.js → worktreeSourceBranchPreference-Dumu-CMk.js} +1 -1
- package/dist/assets/zh-CN-C8IpuSKz.js +15 -0
- package/dist/assets/zh-TW-Iy2Vs5Bb.js +15 -0
- package/dist/index.html +12 -13
- package/dist/mini-chat.html +12 -13
- 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/ArchivedSessionsDialog-Cja7TIg6.js +0 -1
- package/dist/assets/AssistantView-D7Ec_wbs.js +0 -1
- package/dist/assets/ChatContainer-DUJRc6kx.js +0 -65
- package/dist/assets/MarkdownRenderer-DL1l4dgn.js +0 -2
- package/dist/assets/ProviderLogo-C9ON1xS-.js +0 -1
- package/dist/assets/SettingsView-BbEPSEy3.js +0 -29
- package/dist/assets/YuriWordmark-CqkcfAJl.js +0 -1
- package/dist/assets/client-CmtAKi5B.js +0 -7
- package/dist/assets/connection-hint-DugoAaao.js +0 -2
- package/dist/assets/desktopHosts-COI-czjF.js +0 -1
- package/dist/assets/desktopRelayRestore-BEPNc7qb.js +0 -1
- package/dist/assets/es-C1spVk4O.js +0 -15
- package/dist/assets/fr-yyP7Hlty.js +0 -13
- package/dist/assets/gitApiHttp-ZjM4HkSo.js +0 -3
- package/dist/assets/ja-ChftrfCh.js +0 -15
- package/dist/assets/ko-BrLgX_6B.js +0 -15
- package/dist/assets/main-ClNDsxXD.js +0 -2
- package/dist/assets/main-D71N_bhn.js +0 -169
- package/dist/assets/main-qSeeJRW1.css +0 -1
- package/dist/assets/miniChat-DuWGMHPI.js +0 -2
- package/dist/assets/mobile-CjbFG_ps.js +0 -2
- package/dist/assets/pl-DlKDQDhl.js +0 -15
- package/dist/assets/pt-BR-BldJPFQ5.js +0 -15
- package/dist/assets/pwa-CLwERclR.js +0 -2
- package/dist/assets/queue-abort-optimistic-BET9wo1a.js +0 -1
- package/dist/assets/remoteProjectQueries-BQzoY_Y9.js +0 -1
- package/dist/assets/runtimeEndpointReset-DXfdUC1r.js +0 -4
- package/dist/assets/shortcuts-D3O9f1E5.js +0 -1
- package/dist/assets/src-B7qham90.css +0 -2
- package/dist/assets/store-BGuutgkJ.js +0 -17
- package/dist/assets/types-DjBXLnbS.js +0 -2
- package/dist/assets/ui-BqoDhEiW.js +0 -13
- package/dist/assets/uk-Cw2L_unr.js +0 -15
- package/dist/assets/useAppFontEffects-CaZbgo4R.js +0 -7
- package/dist/assets/usePluginsStore-D2P-bQeH.js +0 -1
- package/dist/assets/zh-CN-BQXjCmNe.js +0 -15
- package/dist/assets/zh-TW-Y0lErpEY.js +0 -15
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-DManupRM.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-B2ylz14u.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-BGZ4tGr5.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-68ZPpgYA.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/runtime-file-download-CaeLqIEY.js","assets/vendor-pierre-diffs-B0OmIhMO.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/ui-C8B5mZoA.js","assets/client-A12QacVZ.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BzYqZdzd.js","assets/gitApiHttp-BLNjaxGv.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-Dq2vrCZs.js","assets/i18n-Do5ekTxf.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-CR0ht2xS.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-CzG_3qFv.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-BUWPTwNV.js","assets/Icon-DRYS22Bv.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-CunzOg5u.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-DPQ_Lpkt.js","assets/mobileBackNavigation-CC9_oTr0.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-DVvOvego.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-QZiD7To8.js","assets/markdownHeightCache-D08JEMYV.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-qzgDdfT4.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-DBQpSRIo.js","assets/touch-gestures-DOoBxhz5.js","assets/TerminalView-DFQ5LQFM.js","assets/terminalApi-DpnhkNX3.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/OverlayScrollbar-n7s4ry-S.js","assets/device-TCHW5U2y.js","assets/useProjectRuntimeAPIs-V33EYekW.js","assets/sortable-tabs-strip-4riKQQLu.js","assets/vendor-dnd-kit-core-qy5stxu5.js","assets/vendor-dnd-kit-accessibility-u0XSXxKq.js","assets/vendor-dnd-kit-sortable-CiTIuX4o.js","assets/useTerminalStore-ax8bDQrp.js","assets/useFontPreferences-C4dQT72k.js","assets/project-preview-yQerlKs2.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-B11KAI3f.js","assets/DiagramView-D4CKBzKi.js","assets/diagram-AxsHXJ5W.js","assets/vendor-react-drawio-C9rszQEJ.js","assets/SettingsView-nMaFvRQ8.js","assets/desktopRelayRestore-DtGRUKC-.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/ScrollableOverlay-D1BVukId.js","assets/tooltip-DDpHN7zw.js","assets/react-CPBNl-S9.js","assets/dropdown-menu-BKaUC_RK.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/context-menu-JFytjJX_.js","assets/collapsible-BGE4f0JY.js","assets/textarea-C-_iWeiY.js","assets/kbd-D07oDFdN.js","assets/gitApi-CR5Ik-QG.js","assets/GuiPluginMount-HFg1spLR.js","assets/MobileHtmlNetworkBoundary-sRFhJXff.js","assets/input-Wb8eI0Ik.js","assets/shortcuts-DryfJT69.js","assets/assistantQueries-CSf1LSid.js","assets/MobileDetailNavigation-HFdB1csw.js","assets/pwa-Dp5Xs-u1.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/ErrorBoundary-DKq1dmQm.js","assets/card-DbO12aT2.js","assets/ProviderLogo-DsIQuH14.js","assets/zhipuai-coding-plan-CcFj8zKy.js","assets/select-BiGMjrlP.js","assets/MobileResizableSheet-D7mX3hic.js","assets/githubAuthQueries-3AJp5LD5.js","assets/projectMeta-vIaGFaQr.js","assets/timeFormat-hKdieKsY.js","assets/permission-rules-DoQUXKll.js","assets/useQuotaStore-CrOyolUQ.js","assets/quota-DbpKrGcG.js","assets/router-DXUi1sBd.js","assets/contextPanelEmbeddedChat-Dm5R_b5X.js","assets/sessionOwnership--zFZQ_Pv.js","assets/types-ClkyiHj-.js","assets/checkbox-BcPtk77d.js","assets/mcpQueries-CT_XajCf.js","assets/usePluginsStore-BfjcgvtM.js","assets/switch-B3-h0Mhz.js","assets/SettingsGroup-CKOh9w7t.js","assets/useMcpConfigStore-CawLA6lj.js","assets/native-config-DBOpCdps.js","assets/YuriLogo-CrpZasNm.js","assets/MobileTabPageHeader-DZueoczl.js","assets/MobileSurface-D25CgpkA.js","assets/GuiPluginWindow-9eobm2HP.js","assets/pluginPresentation-CZayU9PL.js","assets/ModelLogo-6rKdl3Oo.js","assets/useDictation-hDNKhzOz.js","assets/audio-session-BFWjrDbp.js","assets/browserVoiceService-x5Pci8L3.js","assets/speechSettingsQueries-BIyDqqzx.js","assets/pluginPresentation-C0HSdVvS.css","assets/ModelSelector-_rBHp6p6.js","assets/useModelLists-B8HN6eBH.js","assets/useOpenCodeReadiness-C9PvijnZ.js","assets/AgentSelector-B46Op3oG.js","assets/AgentAvatar-DPnZENEt.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/AssistantsSettingsPage-CgsSV4mH.js","assets/MobileShareBridge-DinsyF38.js","assets/mobileConnections-BQXSBf4C.js","assets/assistantPresentation-DRbsH1Ej.js","assets/scheduledTaskNavigation-r3g3DfXq.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/ArchivedSessionsDialog-hPG_ZF_w.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/MobileOverlayPanel-u_wq6uYl.js","assets/worktreeManager-CAjuvwiZ.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-DFw624ap.js","assets/MultiRunWindow-CpPHLNh6.js","assets/multirun-snw4oD5m.js","assets/useGitStore-DAkV9L3y.js","assets/insertionBoundaries-BPedMREl.js","assets/spacedFileMention-Ds4GtgiF.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useDebouncedValue-BHlMPqY8.js","assets/fileMentionTouchSelection-Doo_ED67.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionAutocompleteState-B9411b4o.js","assets/worktreeSourceBranchPreference-Dumu-CMk.js","assets/AssistantView-BB_CRg4L.js","assets/mobileAppContext-BQgdTp5T.js","assets/AssistantConversationSurface-CG41t5TZ.js","assets/LoadingImage-Dod2774c.js","assets/chatUpwardIntent-Bes8fOez.js","assets/reference-history-DYFlcEu-.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-vLNN8EMu.js","assets/assistant-attachment-cache-CIij0OGm.js","assets/AssistantWorkingAvatar-B-ciPk2V.js","assets/AssistantSessionCard-DwR2e2Op.js","assets/sessionChangeSummary-BCF9VwAA.js","assets/sessionLookup-BpYYVMt5.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-DEwJnQbL.js","assets/sortAssistantContacts-CcEdm3mS.js","assets/assistantMessagePreview-CL7aPQNb.js","assets/navigation-CkjjVHYQ.js","assets/OnboardingScreen-BecSplt9.js","assets/openSessionFromDeepLink-Cm-ztlpD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,B as y,E as b,F as x,G as S,I as C,K as w,L as T,R as E,U as D,W as O,Z as k,a as A,at as j,c as M,ct as N,d as P,dt as F,et as I,f as L,ft as R,g as z,j as ee,k as B,l as V,lt as te,s as ne,u as re,ut as ie,z as ae}from"./platform-B2ylz14u.js";import{n as H,t as U}from"./runtimeAPIRegistry-C2VogTny.js";import{B as oe,Er as se,H as ce,Jt as le,Lr as ue,Pr as de,Rr as fe,Rt as pe,St as me,Vr as he,Xt as ge,Zt as _e,an as ve,ft as ye,ht as be,mt as xe,n as Se,on as Ce,qt as we,rn as Te,tn as Ee,vr as De,zt as Oe}from"./client-A12QacVZ.js";import{a as ke,i as Ae,t as je}from"./vendor-zustand-CTekDqaS.js";import{A as Me,B as Ne,C as Pe,H as Fe,M as Ie,P as Le,S as W,V as Re,b as ze,it as Be,j as Ve,k as He,ot as Ue,st as We,v as Ge,x as Ke,y as qe,z as Je}from"./vendor-base-ui-wXsskyKm.js";import{Ct as Ye,Et as Xe,Ft as Ze,Mt as Qe,Pt as $e,St as et,Tt as tt,an as nt,jt as rt,on as it,wt as at,xt as ot}from"./gitApiHttp-BLNjaxGv.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as st,r as ct,t as lt}from"./safeStorage-DTOhKN0V.js";import{P as ut,d as dt,z as ft}from"./prompt-attachment-upload-BzYqZdzd.js";import{n as pt}from"./pathNormalization-ewtPqJWn.js";import{n as mt,t as ht}from"./vendor-react-BkccXcWz.js";import{f as gt,u as _t}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as vt,o as yt,s as bt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as xt,I as St,O as Ct,P as wt,R as Tt,W as Et,c as Dt,r as Ot,s as kt,t as At,y as jt,z as Mt}from"./runtime-file-resource-BGZ4tGr5.js";import{a as Nt,n as Pt}from"./path-utils-jGozTg9d.js";import{h as Ft,l as It,m as Lt,r as G}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as Rt}from"./summaries-BQMyJaaw.js";import{o as zt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Bt,i as Vt,o as Ht,r as K,s as Ut,t as Wt}from"./useUIStore-68ZPpgYA.js";import{o as Gt}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Kt,r as qt}from"./terminalApi-DpnhkNX3.js";import{a as Jt}from"./types-ClkyiHj-.js";import{t as Yt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Xt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Zt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Qt,A as $t,Ai as en,Bi as tn,Ci as nn,Et as rn,F as an,Fa as on,Fi as sn,Fn as cn,Ga as ln,Gr as un,H as dn,Ha as fn,Hr as pn,I as mn,Ii as hn,Kr as gn,Mi as _n,Ni as vn,Oi as yn,R as bn,S as xn,St as Sn,Tt as Cn,U as wn,Ur as Tn,Vi as En,Vr as Dn,W as On,Wa as kn,Xi as An,Xn as q,Yi as jn,Yr as Mn,Zi as Nn,Zr as Pn,_n as Fn,an as In,ao as Ln,at as Rn,b as zn,br as Bn,bt as Vn,ci as Hn,co as Un,ct as Wn,da as Gn,dn as Kn,ei as qn,f as Jn,ft as Yn,gt as Xn,h as Zn,ht as Qn,io as J,ji as $n,k as er,lo as tr,lt as nr,mi as rr,mt as ir,nt as ar,o as or,on as sr,oo as cr,or as lr,p as ur,qt as dr,ra as fr,ro as pr,so as mr,st as hr,t as Y,tt as gr,ui as _r,uo as vr,ut as yr,v as br,wt as xr,x as Sr,xr as Cr,xt as wr,y as Tr}from"./ui-C8B5mZoA.js";import{n as X,t as Er}from"./Icon-DRYS22Bv.js";import{g as Dr,m as Or,p as kr}from"./remoteProjectQueries-Dq2vrCZs.js";import{a as Ar,i as jr,n as Mr,r as Nr,t as Pr}from"./i18n-Do5ekTxf.js";import{n as Fr}from"./store-CR0ht2xS.js";import{n as Ir}from"./input-store-CzG_3qFv.js";import{a as Lr,c as Rr,i as zr,l as Br,o as Vr,s as Hr}from"./toolHelpers-iEHVHQ9p.js";import{n as Ur}from"./useAssistantUIStore-BUWPTwNV.js";import{n as Wr,t as Gr}from"./ScrollableOverlay-D1BVukId.js";import{n as Kr,o as qr}from"./vendor-framer-motion-D5NyyC73.js";import{a as Jr,i as Yr,n as Xr,o as Zr,r as Qr,t as $r}from"./dialog-CunzOg5u.js";import{i as ei,n as ti,r as ni,t as ri}from"./tooltip-DDpHN7zw.js";import{n as ii,t as ai}from"./useInlineCommentDraftStore-CK4BJaHk.js";import{n as oi}from"./useThemeSystem-BIXghnHj.js";import{a as si,i as ci,n as li,r as ui,t as di}from"./useProjectGitActions-yvPEth2A.js";import{a as fi,r as pi}from"./device-TCHW5U2y.js";import{t as mi}from"./SyncActions-bV7M8nD9.js";import{i as hi,n as gi,r as _i,t as vi}from"./dropdown-menu.styles-BDla58Rm.js";import{c as yi,i as bi,n as xi,r as Si,s as Ci,t as wi}from"./dropdown-menu-BKaUC_RK.js";import{a as Ti,i as Ei,n as Di,r as Oi,t as ki}from"./context-menu-JFytjJX_.js";import{n as Ai,r as ji,t as Mi}from"./collapsible-BGE4f0JY.js";import{a as Ni,i as Pi,n as Fi,o as Ii,r as Li}from"./PierreDiffViewer-DzM2fd3I.js";import{n as Ri,t as zi}from"./kbd-D07oDFdN.js";import{t as Bi}from"./DiffWorkerProvider-VFPkag9y.js";import{n as Vi,t as Hi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Ui}from"./themes-BgDJcxRc.js";import{n as Wi,t as Gi}from"./useEffectiveDirectory-DPQ_Lpkt.js";import{n as Ki,t as qi}from"./useProjectRuntimeAPIs-V33EYekW.js";import{b as Ji,h as Yi,m as Xi}from"./gitApi-CR5Ik-QG.js";import{a as Zi,o as Qi,s as $i}from"./useGitStore-DAkV9L3y.js";import{a as ea,i as ta,n as na,o as ra,r as ia,s as aa,t as oa}from"./useProjectGitStore-D_q2csGs.js";import{i as sa,n as ca,r as la}from"./MobileHtmlNetworkBoundary-sRFhJXff.js";import{n as ua,t as da}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as fa,i as pa,n as ma,r as ha,t as ga}from"./BinaryFileFallback-BZCfJNKH.js";import{t as _a}from"./ImageLoadingPlaceholder-DVvOvego.js";import{t as va}from"./LoadingImage-Dod2774c.js";import{t as ya}from"./input-Wb8eI0Ik.js";import{n as ba,o as xa}from"./MarkdownRenderer-QZiD7To8.js";import{c as Sa,d as Ca,i as wa,n as Ta,s as Ea,u as Da}from"./shortcuts-DryfJT69.js";import{n as Oa,r as ka}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as Aa}from"./useSessionBtwStore-DBhEqs0r.js";import{t as ja}from"./useDebouncedValue-BHlMPqY8.js";import{m as Ma,x as Na,y as Pa}from"./assistantQueries-CSf1LSid.js";import{A as Fa,C as Ia,D as La,E as Ra,F as za,I as Ba,M as Va,N as Ha,O as Ua,P as Wa,R as Ga,S as Ka,T as qa,_ as Ja,b as Ya,c as Xa,d as Za,f as Qa,g as $a,h as eo,i as to,j as no,k as ro,l as io,m as ao,n as oo,p as so,s as co,t as lo,u as uo,v as fo,w as po,x as mo,y as ho,z as go}from"./useAppFontEffects-CU_bIPu5.js";import{C as _o,D as vo,O as yo,S as bo,Y as xo,at as So,b as Co,d as wo,f as To,h as Eo,l as Do,p as Oo,v as ko,x as Ao,y as jo}from"./pwa-Dp5Xs-u1.js";import{t as Mo}from"./YuriLogo-CrpZasNm.js";import{t as No}from"./card-DbO12aT2.js";import{t as Po}from"./ErrorBoundary-DKq1dmQm.js";import{a as Fo,n as Io,o as Lo,r as Ro}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{a as zo,i as Bo}from"./connection-hint-DPOCdR6S.js";import{u as Vo}from"./insertionBoundaries-BPedMREl.js";import{t as Ho}from"./ModelLogo-6rKdl3Oo.js";import{_ as Uo,a as Wo,c as Go,d as Ko,f as qo,i as Jo,l as Yo,n as Xo,o as Zo,p as Qo,r as $o,s as es,u as ts,y as ns}from"./ChatContainer-BTmCJ0r9.js";import{C as rs,i as is,n as as,r as os}from"./BtwPanel-DGXcgxQV.js";import{A as ss,D as cs,E as ls,M as us,O as ds,P as fs,T as ps,X as ms,j as hs,k as gs}from"./BusyDots-kwYd9Qsa.js";import{_ as _s,i as vs,l as ys,n as bs,s as xs,t as Ss,v as Cs}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as ws,n as Ts,s as Es,t as Ds}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Os}from"./MobileOverlayPanel-u_wq6uYl.js";import{t as ks}from"./ProviderLogo-DsIQuH14.js";import{t as As}from"./vendor-motion-vLNN8EMu.js";import{c as js,i as Ms,n as Ns,s as Ps,t as Fs}from"./select-BiGMjrlP.js";import{a as Is}from"./githubAuthQueries-3AJp5LD5.js";import{c as Ls,i as Rs,n as zs,s as Bs}from"./worktreeManager-CAjuvwiZ.js";import{t as Vs}from"./sortable-tabs-strip-4riKQQLu.js";import{i as Hs}from"./auto-read-context-D3F0UdYo.js";import{n as Us,t as Ws}from"./timeFormat-hKdieKsY.js";import{a as Gs,c as Ks,i as qs,n as Js,o as Ys,r as Xs,u as Zs}from"./useQuotaStore-CrOyolUQ.js";import{a as Qs,i as $s,n as ec,s as tc,t as nc}from"./quota-DbpKrGcG.js";import{i as rc,n as ic,r as ac,t as oc}from"./useDesktopWindowControlsLayout-zSKzBJ6Z.js";import{n as sc,t as cc}from"./sessionChangeSummary-BCF9VwAA.js";import{n as lc,t as uc}from"./openRemoteProjectSession-cchV6HLE.js";import{t as dc}from"./useTerminalStore-ax8bDQrp.js";import{$ as fc,A as pc,At as mc,B as hc,Bt as gc,Ct as _c,D as vc,E as yc,F as bc,Ft as xc,G as Sc,Ht as Cc,I as wc,It as Tc,J as Ec,K as Dc,L as Oc,Lt as kc,M as Ac,Mt as jc,N as Mc,Nt as Nc,O as Pc,Ot as Fc,P as Ic,Pt as Lc,Q as Rc,R as zc,Rt as Bc,S as Vc,St as Hc,U as Uc,Ut as Wc,V as Gc,Vt as Kc,W as qc,X as Jc,Y as Yc,a as Xc,at as Zc,b as Qc,bt as $c,et as el,g as tl,i as nl,it as rl,j as il,jt as al,k as ol,kt as sl,n as cl,nt as ll,o as ul,ot as dl,q as fl,r as pl,rt as ml,s as hl,st as gl,tt as _l,v as vl,w as yl,wt as bl,x as xl,xt as Sl,y as Cl,yt as wl,z as Tl,zt as El}from"./runtimeEndpointReset-D3BlEzsh.js";import{t as Dl}from"./YuriWordmark-CqWOXOaU.js";import{_ as Ol,d as kl,g as Al,h as jl,m as Ml,p as Nl,r as Pl,t as Fl,v as Il,y as Ll}from"./sessionOwnership--zFZQ_Pv.js";import{i as Rl,n as zl}from"./icons-DtK1ZGy1.js";import{r as Bl,t as Vl}from"./navigation-CkjjVHYQ.js";import{t as Hl}from"./AssistantUnreadBadge-DEwJnQbL.js";import{n as Ul,t as Wl}from"./GuiPluginPage-BldXLT7J.js";import{d as Gl,i as Kl,n as ql,r as Jl,u as Yl}from"./historyImportQueries-B_mfphxe.js";import{n as Xl}from"./ScheduledTasksDialog-BSxPw-np.js";import{t as Zl}from"./ChatView-5s43Y5II.js";import{t as Ql}from"./diagram-AxsHXJ5W.js";import{t as $l}from"./DiffView-B20uCbQX.js";import{a as eu,i as tu,n as nu,o as ru,r as iu,t as au}from"./multirun-snw4oD5m.js";import{_ as ou,a as su,c as cu,d as lu,f as uu,g as du,h as fu,i as pu,l as mu,m as hu,o as gu,p as _u,r as vu,s as yu,t as bu,u as xu}from"./ArchivedSessionsDialog-hPG_ZF_w.js";import{a as Su,i as Cu,n as wu,r as Tu,t as Eu}from"./projectActions-B11KAI3f.js";import{t as Du}from"./GuiPluginTitlebarItems-DJjbMDL7.js";import{t as Ou}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as ku,t as Au}from"./vendor-html-to-image-BDMm2v6d.js";var Z=e(We(),1),ju=ht(),Q=mt(),$=Ue();function Mu(e){let t=(0,Q.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var Nu=!1,Pu=0,Fu=new Set,Iu=async()=>{let e=++Pu;try{let t=await ee(`desktop_is_window_fullscreen`);if(e!==Pu||t===Nu)return;Nu=t===!0,Fu.forEach(e=>e())}catch{}},Lu=e=>C()?(Fu.add(e),Fu.size===1&&(window.addEventListener(`yuri:window-resized`,Iu),Iu()),()=>{Fu.delete(e),Fu.size===0&&(window.removeEventListener(`yuri:window-resized`,Iu),Pu++,Nu=!1)}):()=>{};function Ru(){return(0,Z.useSyncExternalStore)(Lu,Bu,zu)}function zu(){return!1}function Bu(){return Nu}function Vu(){let e=(0,Q.c)(19),{t}=Pr(),n=K(Ku),r=K(Gu),i=K(Wu),a=K(Uu),o=K(Hu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=G(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=J(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Hu(e){return e.setWorkStatusOverlayOpen}function Uu(e){return e.setWorkStatusPanelEnabled}function Wu(e){return e.workStatusOverlayOpen}function Gu(e){return e.workStatusPanelFits}function Ku(e){return e.workStatusPanelEnabled}var qu=(e,t,n)=>yt({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await se(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&P()){let e=await xo();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>ue(e,i)||t===`host:${e.id}`||!!(n&&fe(n,de(e)))),sshIds:i}}});function Ju(e){let t=(0,Q.c)(18),{onClick:n,open:r}=e,{t:i}=Pr(),a=Z.useSyncExternalStore(c,u,u),o=K(Yu),s=p(),l=h(),d=x(),{data:f}=bt({...qu(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&fe(l,de(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?he(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=za({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ri,b=ei,S=q,C=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),w;t[0]===v?w=t[1]:(w=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(X,{name:v,className:`size-5`})}),t[0]=v,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==S||t[4]!==n||t[5]!==r||t[6]!==C||t[7]!==w?(E=(0,$.jsxs)(S,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":C,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[w,T]}),t[3]=S,t[4]=n,t[5]=r,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(ti,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function Yu(e){return e.isSettingsDialogOpen}var Xu=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Zu=`finder`,Qu=new Set([`finder`,`terminal`]),$u=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,ed=e=>{if(!e)return null;let t=Xu.find(t=>t.id===e)??null;return t?$u(t):null},td=()=>Xu.filter(e=>Qu.has(e.id)).map(e=>({...$u(e)})),nd=e=>{let t=new Map(e.map(e=>[e.name,e]));return Xu.filter(e=>t.has(e.appName)||Qu.has(e.id)).map(e=>{let n=t.get(e.appName);return{...$u(e),...e.id===`terminal`&&n?.appName&&n.label?{appName:n.appName,label:n.label}:{},iconDataUrl:n?.iconDataUrl??void 0}})},rd=()=>{if(typeof window>`u`)return Zu;let e=window.localStorage.getItem(`openInAppId`);return e&&ed(e)?e:Zu},id=!1,ad=!1,od=!1,sd=0,cd=null,ld=()=>{cd&&=(clearTimeout(cd),null)},ud=ke()((e,t)=>({selectedAppId:rd(),availableApps:td(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(id||typeof window>`u`)return;id=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:td(),hasLoadedApps:n});return}e({availableApps:nd(t),hasLoadedApps:!0})},r=async i=>{if(!C()||ad||t().hasLoadedApps&&!i)return;let a=Xu.map(e=>e.appName);ld(),i&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await z(a,i),l=o&&!s&&t.length===0&&sd<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][sd]??3200;sd+=1,od=!0,cd=setTimeout(()=>{r()},e);return}sd=0,od=!1;return}if(sd<3){let e=[1e3,3e3,7e3][sd]??7e3;sd+=1,od=!0,cd=setTimeout(()=>{r()},e)}}finally{ad=!1,od||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&ed(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(sd=3,od=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(id||t().initialize(),!C()||ad||t().hasLoadedApps&&!n)return;let r=Xu.map(e=>e.appName);ld(),n&&e({hasLoadedApps:!1}),ad=!0,od=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await z(r,n),o=nd(t);e({availableApps:o.length>0?o:td(),hasLoadedApps:o.length>0,isCacheStale:i?a:!1})}finally{ad=!1,od||e({isScanning:!1})}},selectApp:async t=>{ed(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Ze({openInAppId:t}))}})),dd=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:C()&&v()&&n!==null,queryFn:async({signal:e})=>{let t=await ee(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},fd=()=>{let e=(0,Q.c)(3),t=(0,Z.useSyncExternalStore)(c,p,pd),n=(0,Z.useSyncExternalStore)(c,u,md),r;return e[0]!==t||e[1]!==n?(r=dd(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],bt(r)};function pd(){return``}function md(){return``}var hd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,gd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,_d=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?hd:e.id===`terminal`&&e.label===`Terminal`?gd:void 0}),vd=e=>{let t=(0,Q.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Z.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=J(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},yd=({directory:e,className:t})=>{let{t:n}=Pr(),r=ud(e=>e.selectedAppId),i=ud(e=>e.availableApps),a=ud(e=>e.isCacheStale),o=ud(e=>e.isScanning),s=ud(e=>e.initialize),c=ud(e=>e.loadInstalledApps),l=ud(e=>e.selectApp),{data:u}=fd(),d=Z.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Z.useEffect(()=>{s()},[s]);let f=C()&&x(),p=Z.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?_d(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await w(e,t.id,t.appName,u?.hostId);!r&&!u?await S(e,t.appName):r||Y.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){Y.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await pr(e)};return(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:J(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(vd,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(wi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(xi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Ci,{}),d.map(e=>{let t=_d(e);return(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(vd,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(X,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},bd=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],xd=[`dev`,`start`,`preview`,`serve`];async function Sd(e,t,n,r){if(!e)return null;let i=Td(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Ed(n);if(t){let n=await Dd(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await Cd(e,r)){let e=await wd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function Cd(e,t){let n=await Od(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function wd(e){if(e){let t=await St(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Td(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(xd.some(t=>e.includes(t)))return t}return null}function Ed(e){for(let{pattern:t}of bd)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function Dd(e,t){let n=await Od(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Od(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Od(e,t,n){if(n){let r=St(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=U()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function kd(e,t){try{let n=await Od(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var Ad=e=>new Promise(t=>{window.setTimeout(t,e)}),jd=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),Md=/https?:\/\/[^\s<>'"`]+/gi,Nd=`__yuri_auto_discover_preview__`,Pd=15e3,Fd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Id=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Ld=e=>{let t=e.replace(jd,``).match(Md);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Rd=e=>{let t=(0,Q.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Or(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):Bd,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Z.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(zd,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},zd=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Pr(),{terminal:s,runtime:c}=Tt(),l=Z.useRef(null),u=Z.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&St(a).assertCurrent()},f=G(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=qt(a)}),p=Z.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=pi(),h=Z.useMemo(()=>C(),[]),g=yu(e=>e.instances),_=yu(e=>e.load),v=K(e=>e.setBottomTerminalOpen),y=K(e=>e.setActiveMainTab),b=K(e=>e.setSettingsPage),x=K(e=>e.setSettingsDialogOpen),S=K(e=>e.setSettingsProjectsSelectedId),w=K(e=>e.openContextPreview),T=dc(e=>e.sessions),E=dc(e=>e.ensureDirectory),D=dc(e=>e.setTabLabel),O=dc(e=>e.setTabIconKey),k=dc(e=>e.setActiveTab),A=dc(e=>e.setConnecting),j=dc(e=>e.setTabSessionId),M=dc(e=>e.setTabPreviewUrl),N=dc(e=>e.projectActionRuns),P=dc(e=>e.setProjectActionRun),F=dc(e=>e.updateProjectActionRunStatus),I=dc(e=>e.removeProjectActionRun),[L,R]=Z.useState([]),[z,ee]=Z.useState(null),[B,te]=Z.useState(!1),re=Z.useRef({}),ie=Z.useRef({}),ae=Z.useRef({}),H=Z.useRef({}),U=Z.useRef(0),oe=Z.useRef(new Set),se=e?.id??null,ce=e?.path??``,le=Z.useMemo(()=>se?{id:se,path:ce,hostId:e?.hostId,hubId:e?.hubId}:null,[se,ce,e?.hostId,e?.hubId]);Z.useEffect(()=>{u.current=!0;let e=ae.current,t=H.current;return()=>{u.current=!1,U.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Z.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let ue=G(async e=>{await Gt(e)}),de=G(async()=>{if(!le)return;let e=U.current+1;U.current=e,te(!0);try{d();let t=await qn(le,a);if(U.current!==e)return;let n=t.actions;R(n),ee(e=>e===Nd||e&&n.some(t=>t.id===e)?e:null)}catch{if(U.current!==e)return}finally{U.current===e&&te(!1)}}),fe=t||le?.path||``,pe=Z.useMemo(()=>a?V(ne({...a.location,directory:fe})):le?.hostId?le.hubId?V(ne({hubId:le.hubId,hostId:le.hostId,directory:fe})):``:Tu(fe),[fe,le,a]),me=Z.useMemo(()=>z?L.find(e=>e.id===z)??null:null,[L,z]),he=Z.useMemo(()=>({id:Nd,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),ge=!m,_e=Z.useMemo(()=>ge?[he,...L]:L,[L,he,ge]);Z.useEffect(()=>{de()},[de,le,a]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;se&&(t?.projectId&&t.projectId!==se||de())};return window.addEventListener(Eu,e),()=>{window.removeEventListener(Eu,e)}},[de,se]),Z.useEffect(()=>{z&&(z===Nd&&ge||L.some(e=>e.id===z)||ee(null))},[L,ge,z]),Z.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==pe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[pe,N,I,T]),Z.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==pe)continue;let n=ie.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ie.current[e]=n;let r=_e.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Ld(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(H.current[e]),delete H.current[e],w(t.directory,u))}else a||le?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(ue(u),Y.success(o(`projectActions.toast.openedUrlFromOutput`)));ie.current[e]=n}for(let e of Object.keys(ie.current))N[e]||(delete ie.current[e],window.clearTimeout(H.current[e]),delete H.current[e])},[pe,a,le?.hostId,_e,w,ue,N,M,o,T,F]);let ve=G(async(e,t={})=>{if(!pe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=Su(pe,e.id);E(pe);let r=dc.getState(),i=r.getDirectoryState(pe),a=re.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(pe),re.current[n]=a),D(pe,a,`Action: ${e.name}`),O(pe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(pe,a),v(!0),y(`terminal`));let c=dc.getState().getDirectoryState(pe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ye=G(async e=>{if(c.isVSCode||!i&&m)return;if(!pe){Y.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=Su(pe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!oe.current.has(t)){oe.current.add(t);try{d();let t=e.id===Nd?await(async()=>{let[e,t]=await Promise.all([qn({...le,id:le?.id??``,path:fe},a),kd(fe,a)]),n=await Sd(fe,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Nd,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await ve(t,{revealTerminal:!n&&e.id!==Nd}),c=s,l=!1;if(!c){A(pe,i,!0);try{let e=await p.createSession({cwd:fe});d(),c=e.sessionId,l=!0,j(pe,i,c)}finally{A(pe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await Ad(350),d(),t.id===Nd&&(ae.current[r]?.(),A(pe,i,!0),ae.current[r]=(a?f().connectTerminalStream:Kt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&dc.getState().appendToBuffer(pe,i,e.data),e.type===`exit`&&(dc.getState().setTabLifecycle(pe,i,`exited`),dc.getState().setConnecting(pe,i,!1),dc.getState().removeProjectActionRun(r),delete ie.current[r],ae.current[r]?.(),delete ae.current[r],window.clearTimeout(H.current[r]),delete H.current[r])}},()=>{u.current&&dc.getState().setConnecting(pe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Id(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?Cu(t.desktopOpenSshForward,g):null;P({key:r,directory:pe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Nd&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(H.current[r]),delete H.current[r],t.id===Nd&&!_&&(H.current[r]=window.setTimeout(()=>{dc.getState().updateProjectActionRunStatus(r,`running`),delete H.current[r]},Pd)),v?(M(pe,i,null,{locked:!0}),ue(v),Y.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(pe,i,_,{locked:!0,autoOpened:!0}),w(pe,_),Y.success(o(`projectActions.toast.openedActionUrl`))):n?(M(pe,i,null,{locked:!0}),Y.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(pe,i,null,{locked:!0}),Y.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(pe,i,null,{locked:!1,autoOpened:!1}),ie.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Nd};let y=Fd(t.command.trim().replace(/\r\n|\r/g,`
|
|
3
|
+
`));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t],Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{oe.current.delete(t)}}}),be=G(async e=>{let t=Su(pe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||le?.hostId){F(t,`running`),Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),dc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||le?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ie.current[t],ae.current[t]?.(),delete ae.current[t],window.clearTimeout(H.current[t]),delete H.current[t]}}),xe=G(()=>{let e=me??_e[0];if(!e)return;let t=Su(pe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){be(e);return}ye(e)}}),Se=G((e,t=!1)=>{if(ee(e.id),!t){ye(e);return}let n=Su(pe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){be(e);return}ye(e)}}),Ce=G(()=>{if(le?.id){if(a||le.hostId){Y.info(o(`remoteProjects.configurationReadOnly`)),b(`remoteInstances`),x(!0);return}S(le.id),b(`projects`),x(!0)}});if(c.isVSCode||!i&&m||!le||!pe)return null;let we=me??_e[0]??null;if(!we)return null;let Te=we.icon||`play`,Ee=we.id===Nd?`search`:wu[Te]||`play`,De=N[Su(pe,we.id)],Oe=De?.status===`stopping`,ke=De?.status===`waiting-for-preview`,Ae=De?T.get(De.directory)?.tabs.find(e=>e.id===De.tabId)?.previewUrl??null:null,je=!!(De&&Ae),Me=()=>{!De||!Ae||w(De.directory,Ae)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:B||Oe,className:J(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:xe,"aria-label":o(De?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:we.name}),children:Oe||ke?(0,$.jsx)(X,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):De?(0,$.jsx)(X,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(X,{name:Ee,className:`h-5 w-5`})}),je?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:Me,children:(0,$.jsx)(X,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ti,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(wi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(xi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:Ce,children:[(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Ci,{}),_e.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:wu[t]||`play`,r=Su(pe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>{Se(e,!0)},children:[(0,$.jsx)(X,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(X,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:xe,disabled:B||Oe,className:J(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(De?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:we.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:Oe||ke?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):De?(0,$.jsx)(X,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(X,{name:Ee,className:`h-4 w-4`})})}),je?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Me,className:J(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(X,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ti,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(wi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(xi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:Ce,children:[(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Ci,{}),_e.map(e=>{let t=e.icon||`play`,n=e.id===Nd?`search`:wu[t]||`play`,r=Su(pe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>{Se(e,!0)},children:[(0,$.jsx)(X,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(X,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function Bd(){}function Vd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var Hd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Ud=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Wd=Z.memo(function(e){let t=(0,Q.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??Hd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=J(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(X,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ri,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Gd=Z.memo(function(e){let t=(0,Q.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Pr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(Hd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(bi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ci,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(Si,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(xi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(wi,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Kd=Z.memo(function(e){let t=(0,Q.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Pr(),E=Z.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=G(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(yi,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Vs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(kl,{})]})}):null,(0,$.jsx)(Wa,{embedded:!0,open:i&&s===`instance`,onOpenChange:nf,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(El,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Vs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(X,{name:`refresh`,className:J(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(ks,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=zl(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ec(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(s.elapsedRatio):nc(s.elapsedRatio),l=Qs(i.valueLabel,o),u=$s(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Z.Fragment,{children:[a?(0,$.jsx)(`div`,{className:J(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(gu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(su,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(Mi,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ai,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=ec(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(a.elapsedRatio):nc(a.elapsedRatio),s=Qs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(gu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(su,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(xi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(wi,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),qd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Jd=(e,t)=>{if(!e)return`-`;try{return Us(e,t,{fallback:`-`})}catch{return`-`}},Yd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Xd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Zd=e=>{let t=(0,Q.c)(3),n=fn(rf),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Qd,{...e,hostId:n}):(0,$.jsx)(tf,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Qd=e=>{let t=(0,Q.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=xt(),a=Or(!0),o=kr(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(tf,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},$d=Z.memo(e=>{let t=(0,Q.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:gt,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=bt(s,Et).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),ef=Z.memo(e=>{let t=(0,Q.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Z.useSyncExternalStore(ve,_e,_e),c;t[0]===o?c=t[1]:(c=ge(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?Ce(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):af,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Z.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=on(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=bt(b,Et),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=fr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=Oe([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=pe(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(rc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),tf=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Pr(),l=K(e=>e.setSessionSwitcherOpen),d=K(e=>e.toggleSidebar),f=K(e=>e.isSidebarOpen),m=K(e=>e.toggleBottomTerminal),_=K(e=>e.toggleContextPanel),v=K(e=>e.openContextOverview),y=K(e=>e.openContextBrowser),b=K(e=>e.closeContextPanel),S=K(e=>e.activeMainTab),w=K(e=>e.setActiveMainTab),T=K(e=>e.shortcutOverrides),E=K(e=>e.timeFormatPreference),D=Nn(e=>e.getCurrentModel),O=Tt(),k=Jn(e=>!!e.newSessionDraft?.open),A=Jn(e=>e.currentSessionId),M=fn(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),N=!!M?.hostId,P=ln(e=>e.remoteSession),F=M?.hostId&&P?.projectId===M.id&&P.location.hostId===M.hostId&&(!M.hubId||P.location.hubId===M.hubId)?P:null,I=N?F?.sessionId??null:A,R=N?!F?.sessionId:k,z=Yn(N?``:I??``),V=dn(N?null:I),te=fn(e=>e.projects),re=Z.useMemo(()=>{if(!N)return V;let e=F?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||Rt(te,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===I&&t.directory===e)},[N,V,F?.location.directory,M,s?.hubId,te,a,I]),ie=Z.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),H=Xs(e=>e.results),U=Xs(e=>e.fetchAllQuotas),oe=Xs(e=>e.isLoading),ce=Xs(e=>e.lastUpdated),le=Xs(e=>e.displayMode),ue=Xs(e=>e.showPredValues),pe=Xs(e=>e.dropdownProviderIds),me=Xs(e=>e.loadSettings),ge=Xs(e=>e.setDisplayMode),{isMobile:_e}=pi(),ve=Is().data??null,ye=Pl(e=>e.setStatus),be=Z.useRef(null),[xe,Se]=Z.useState(()=>typeof window>`u`?!1:C()),Ce=Z.useMemo(()=>L(),[]),we=xe&&B()===`win32`,Te=fi(),Ee=Ru(),De=Z.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:Oe,side:ke}=oc(),Ae=Z.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Z.useEffect)(()=>{typeof window>`u`||Se(C())},[]);let je=D(),Me=je&&typeof je.limit==`object`&&je.limit!==null?je.limit:null,Ne=Me&&typeof Me.context==`number`?Me.context:0,Pe=Me&&typeof Me.output==`number`?Me.output:0,Fe=ar(N?``:I??``,Ne,Pe),Ie=R?null:Fe,[Le,W]=Z.useState(null),Re=!I||z;(0,Z.useEffect)(()=>{if(!I){W(e=>e===null?e:null);return}if(Ie){W(e=>qd(e,Ie)?e:Ie);return}Re&&W(e=>e===null?e:null)},[Ie,I,Re]);let ze=K(e=>e.isSessionSwitcherOpen),Be=ve?.connected?ve.user?.avatarUrl??null:null,Ve=ve?.connected?ve.user?.login??null:null,He=ve?.accounts??[],[Ue,We]=Z.useState(!1),[Ge,Ke]=Z.useState(!1),[qe,Je]=Z.useState(!1),[Ye,Xe]=Z.useState(!1),[Qe,$e]=Z.useState(`Local`),[et,tt]=Z.useState(!1),[nt,rt]=Z.useState(xe?`instance`:`usage`),[it,at]=Z.useState(`usage`);(0,Z.useEffect)(()=>{!xe&&nt===`instance`&&rt(`usage`)},[nt,xe]);let ot=Z.useMemo(()=>ae(),[]),st=!ot&&S===`chat`&&!!Le,ct=Le&&Le.contextLimit>0?Math.min(999,Le.totalTokens/Le.contextLimit*100):0,lt=G(async()=>{if(!(typeof window>`u`||!xe))try{if(x()){$e(`Local`),tt(!1);return}let e=u(),t=await se();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?fe(n,de(e)):!1);if(h()!==n)return;if(tt(!!n),a?.label?.trim()){$e(he(a.label.trim()));return}$e(`Instance`)}catch{$e(`Local`),tt(!1)}});(0,Z.useEffect)(()=>{lt()},[xe]),Js();let ut=Xs(e=>e.selectedModels),dt=Xs(e=>e.expandedFamilies),ft=Xs(e=>e.toggleFamilyExpanded),pt=Z.useMemo(()=>{let e=[];for(let t of Zs(H)){if(!pe.includes(t.id))continue;let n=H.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Rl(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=ut[t.id]??[],n=e.length>0,r=Ys(i,t.id),a=qs(t.id),s=Ks(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[pe,H,ut,c]),mt=pt.length>0;Z.useEffect(()=>{me()},[me]);let ht=Z.useCallback(async e=>{ge(e);try{await Ze({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[ge]),gt=Z.useCallback(()=>{if(Ye)return;Xe(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([U(),e]).finally(()=>{Xe(!1)})},[U,Ye]),_t=Jn(e=>N||!I?``:e.worktreeMetadata.get(I)?.path??``),vt=Z.useMemo(()=>Yd(_t||``),[_t]),yt=Z.useMemo(()=>Yd((typeof re?.directory==`string`?re.directory:``)||``),[re?.directory]),bt=Jn(e=>e.newSessionDraft?.open?Yd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),xt=Z.useMemo(()=>N?F?.location.directory??M?.path??``:vt||yt||bt,[N,F?.location.directory,M?.path,bt,yt,vt]),St=Wi(),Ct=F?ne(F.location):M?.hostId&&M.hubId?ne({hubId:M.hubId,hostId:M.hostId,directory:St??M.path}):``,wt=Z.useMemo(()=>N?Ct:Yd(St||xt||M?.path||``),[N,Ct,M?.path,St,xt]),Et=K(e=>Wt(e,wt)),Dt=!!Et?.isOpen,Ot=G(()=>_(wt)),kt=Z.useMemo(()=>{if(!I)return ie??`Yuri`;let e=re?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[ie,re?.title,I]),At=Z.useMemo(()=>N?xt:Yd(xt||M?.path||``),[N,M?.path,xt]),jt=Z.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),Mt=Z.useRef(null);Z.useEffect(()=>{!jt||!At||(Mt.current={projectRef:jt,directory:At})},[At,jt]);let Nt=Z.useMemo(()=>jt&&At?{projectRef:jt,directory:At}:Mt.current,[At,jt]),Pt=Z.useCallback(async e=>{if(!(!e||Ue)){We(!0);try{let t=O.github?await O.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ye(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{We(!1)}}},[Ue,O.github,ye]),Ft=Z.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),It=Z.useCallback(()=>{if(_e){Ft(),l(!ze);return}d()},[Ft,_e,ze,l,d]),zt=Z.useCallback(()=>{N||ee(`desktop_open_draft_mini_chat_window`,{directory:Yd(xt||M?.path||``),projectId:M?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N,M?.id,M?.path,xt]),Bt=Z.useCallback(()=>{if(!N){if(R){zt();return}I&&ee(`desktop_open_session_mini_chat_window`,{sessionId:I,directory:Yd(xt||M?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[N,M?.path,I,zt,R,xt]),Vt=Z.useCallback(()=>{let e=wt;if(e){if(Xd(Et)===`context`){b(e);return}v(e)}},[b,wt,Et,v]),Ht=Z.useMemo(()=>wt?Xd(Et)===`context`:!1,[wt,Et]),Ut=Z.useCallback(()=>{let e=wt;if(e){if(Xd(Et)===`browser`){b(e);return}y(e)}},[b,wt,Et,y]),Gt=Z.useMemo(()=>wt?Xd(Et)===`browser`:!1,[wt,Et]),Kt=Hd,qt=Ud,Jt=Z.useMemo(()=>Ge?`services`:r?`sessions`:i?`git`:S,[S,Ge,r,i]),Yt=Z.useCallback(()=>{Ke(!1),r&&e&&e(),i&&t&&t(),!e&&ze&&l(!1)},[ze,r,e,t,i,l]),Xt=Z.useCallback(()=>{r||Ke(!1),e?.()},[r,e]),Zt=Z.useCallback(()=>{i||Ke(!1),t?.()},[t,i]),Qt=Z.useMemo(()=>xe&&De&&!Ee?`5.5rem`:Te?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!xe||Oe)&&!ot?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[xe,Ee,De,Te,ot,Oe]);(0,Z.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Qt)},[Qt]);let $t=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,en=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,tn=Z.useMemo(()=>!xe||!De||Ae===null?``:Ae>=26?`h-12`:Ae<=15?`h-14`:``,[xe,De,Ae]),nn=Z.useMemo(()=>{if(!(xe&&!Oe||ot))return{paddingRight:Dt?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[xe,ot,Dt,Oe]),rn=G(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});Lt(be,([e])=>{e&&rn(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Z.useLayoutEffect(()=>{rn(be.current?.getBoundingClientRect().height)},[rn,_e,tn]);let an=Z.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&xe&&await j()},[xe]),on=Z.useMemo(()=>{if(_e){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[_e,c]),sn=Z.useCallback(e=>wa(Ea(e,T)),[T]);(0,Z.useEffect)(()=>{!_e&&(S===`git`||S===`terminal`||S===`diff`||S===`files`)&&w(`chat`)},[S,_e,w]);let cn=Z.useMemo(()=>{let e=[];return xe&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(X,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ll,{className:`h-3.5 w-3.5`})}),e},[xe,c]),un=Z.useMemo(()=>cn.map(e=>({id:e.value,label:e.label,icon:e.icon})),[cn]),pn=Z.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),mn=Z.useMemo(()=>pn.map(e=>({id:e.value,label:e.label})),[pn]),hn=Z.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Ll,{className:`h-3.5 w-3.5`})}],[c]);(0,Z.useEffect)(()=>{let e=e=>{if(tr(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=on.length&&(e.preventDefault(),_e&&(Ft(),Yt()),w(on[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Ft,Yt,_e,w,on]);let gn=G(e=>{rt(e),Je(!0),lt(),e===`usage`&&ce===null&&U()});(0,Z.useEffect)(()=>{let e=e=>{let t=Ea(`toggle_services_menu`,T);if(Ta(e,t)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:nt,targetTab:xe?`instance`:`usage`});t.open?gn(t.tab):Je(!1);return}let n=Ea(`cycle_services_tab`,T);if(Ta(e,n)){e.preventDefault();let t=cn.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(nt),r=t[n===-1?0:(n+1)%t.length];rt(r),Je(!0),lt(),r===`usage`&&ce===null&&U();return}let r=Ea(`open_usage`,T);if(Ta(e,r)){e.preventDefault();let t=Vd({isOpen:qe,activeTab:nt,targetTab:`usage`});t.open?gn(t.tab):Je(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T,xe,qe,nt,cn,ce,U,lt,gn]);let _n=e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Mu,{size:e}):r?(0,$.jsx)(X,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:J(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!_e&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[_e?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Z.Fragment,{children:o},e.id)},vn=!N&&Ce&&(R||!!I),yn=Z.useCallback(e=>{window.setTimeout(e,0)},[]),bn=Z.useCallback(e=>{gn(e)},[gn]),xn=Z.useRef(null),Sn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:xn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(wi,{children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:J(Kt,`text-muted-foreground`),children:(0,$.jsx)(X,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(xi,{align:`start`,className:`min-w-[14rem]`,children:[vn?(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>yn(Bt),children:[(0,$.jsx)(X,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(R?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,xe?(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>yn(()=>bn(`instance`)),children:[(0,$.jsx)(X,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Qe})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:sn(`toggle_services_menu`)})]}):null,(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>yn(()=>bn(`usage`)),children:[(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:sn(`open_usage`)})]}),(0,$.jsx)(Ci,{}),(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>yn(m),children:[(0,$.jsx)(X,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:sn(`toggle_terminal`)})]}),(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>yn(Ut),children:[(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Gt?(0,$.jsx)(X,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Kd,{isDesktopApp:xe,currentInstanceSupportsUpdate:et,isDesktopServicesOpen:qe,setIsDesktopServicesOpen:Je,refreshCurrentInstanceLabel:lt,desktopServicesTab:nt,setDesktopServicesTab:rt,fetchAllQuotas:U,servicesTabItems:un,quotaLastUpdated:ce,quotaDisplayMode:le,showPredValues:ue,quotaDisplayTabItems:mn,handleDisplayModeChange:ht,handleUsageRefresh:gt,isQuotaLoading:oe,isUsageRefreshSpinning:Ye,hasRateLimits:mt,rateLimitGroups:pt,expandedFamilies:dt,toggleFamilyExpanded:ft,timeFormatPreference:E,anchorRef:xn})]}),Cn=(0,$.jsxs)($.Fragment,{children:[!N&&!_e&&!ot&&S===`chat`?(0,$.jsx)(Vu,{}):null,N?null:(0,$.jsx)(yd,{directory:At}),xe&&(0,$.jsx)(Ju,{open:qe&&nt===`instance`,onClick:()=>gn(`instance`)}),(0,$.jsx)(Wd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:sn(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Dt,onClick:Ot,className:J(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Dt?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Gd,{isMobile:_e,githubAuthStatus:ve,githubAccounts:He,githubAvatarUrl:Be,githubLogin:Ve,isSwitchingGitHubAccount:Ue,handleGitHubAccountSwitch:Pt})]}),wn=()=>(0,$.jsxs)(`div`,{onMouseDown:an,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,tn),style:nn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:$t}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ac,{scopeProjectId:N?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:R?c(`sessions.switcher.draftTitle`):N&&s&&F?.sessionId?(0,$.jsx)($d,{entry:s.resolve(F.location),sessionId:F.sessionId,fallback:kt},ne(F.location)):kt})})}),N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(X,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Bo,{registry:s,hostId:M.hostId}):null]}):null]}),on.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:on.map(e=>_n(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[Sn,N&&!ot&&S===`chat`&&s&&F?.sessionId?(0,$.jsx)(ef,{entry:s.resolve(F.location),sessionId:F.sessionId,onClick:Vt,pressed:Ht},ne(F.location)):null,st&&Le?(0,$.jsx)(rc,{pending:Le.pending,totalTokens:Le.totalTokens,percentage:ct,colorPercentage:Le.percentage,contextLimit:Le.contextLimit,outputLimit:Le.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Vt,pressed:Ht}):null,Cn,(0,$.jsx)(ic,{visible:Oe&&ke===`right`&&!Dt,position:`right`})]})]})]}),Tn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:J(qt,Jt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(X,{name:`layout-left`,className:`h-5 w-5`})}):ze?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:It,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(X,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&ze&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!ze||!!e)&&(0,$.jsxs)($.Fragment,{children:[N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(Bo,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:on.map(e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{_e&&(Ft(),Yt()),w(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(qt,`relative rounded-lg`,Jt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Mu,{className:`h-5 w-5`}):r?(0,$.jsx)(X,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Du,{mobile:!0}),Nt&&(0,$.jsx)(Rd,{projectRef:Nt.projectRef,directory:Nt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(wi,{open:Ge,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),Ke(n),n&&ce===null&&U()},children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:J(qt,Jt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(X,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(xi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Vs,{items:hn,activeId:it,onSelect:e=>{let t=e;at(t),t===`usage`&&ce===null&&U()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ke(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})]})}),it===`mcp`&&(0,$.jsx)(El,{active:Ge&&it===`mcp`}),it===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Jd(ce,E)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>ht(`usage`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,le===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ht(`remaining`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,le===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:gt,disabled:oe||Ye,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(X,{name:`refresh`,className:J(`h-4 w-4`,Ye&&`animate-spin`)})})]})]})}),!mt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:pt.map((e,t)=>(0,$.jsxs)(Z.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(ks,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=zl(e.entries,r),a=le===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ec(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:le===`remaining`?100-nc(o.elapsedRatio):nc(o.elapsedRatio),c=Qs(n.valueLabel,a),l=$s(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,E);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:J(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(gu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&ue?(0,$.jsx)(su,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(dt[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(Mi,{open:n,onOpenChange:()=>ft(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Ai,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=le===`remaining`?n.remainingPercent:n.usedPercent,i=ec(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:le===`remaining`?100-nc(i.elapsedRatio):nc(i.elapsedRatio),o=Qs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(gu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&ue?(0,$.jsx)(su,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Zt,className:J(qt,`relative`,Jt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(X,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),En=J(`header-safe-area relative z-10 bg-background`,we&&`bg-[var(--surface-background)] backdrop-blur-none`,_e&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:be,className:En,style:{"--padding-scale":`1`},children:_e?Tn():wn()})})};function nf(){}function rf(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function af(){}var of=180,sf=640,cf=110,lf=e=>{let t=(0,Q.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Pr(),o=K(uf),s=K(df),c=K(ff),l=K(pf),[u,d]=Z.useState(null),[f,p]=Z.useState(!1),m=Z.useRef(null),h=Z.useRef(0),g=Z.useRef(o||300),_=Math.min(sf,Math.max(of,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Z.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Z.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(sf,Math.max(of,g.current+t));c(n)},t=()=>{p(!1),K.getState().bottomTerminalHeight<=cf&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Z.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=J(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:J(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=J(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function uf(e){return e.bottomTerminalHeight}function df(e){return e.isBottomTerminalExpanded}function ff(e){return e.setBottomTerminalHeight}function pf(e){return e.setBottomTerminalOpen}var mf=260,hf=260,gf=500,_f=e=>Math.min(gf,Math.max(hf,e)),vf=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Pr(),o=K(e=>e.sidebarWidth),s=K(e=>e.setSidebarWidth),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o||mf),f=Z.useRef(null),p=Z.useRef(null),m=Z.useRef(null),h=Z.useRef(null),g=G(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Z.useEffect(()=>{t&&c&&l(!1)},[t,c]),Z.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(gf,Math.max(hf,o||mf)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=_f(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=_f(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:J(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:J(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:J(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(Po,{children:n})})]})]})},yf=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},bf=e=>{let t=(0,Q.c)(26),{className:n}=e,{t:r}=Pr(),i=K(xf),a=vu(Sf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(Cf);if(Z.useEffect(()=>{c&&oo()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=J(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=q,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=J(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(Mo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Dl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function xf(e){return e.openSettingsAtItem}function Sf(e){return e.sidebarBrandName}function Cf(e){return e!==`Yuri`}var wf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,Tf=()=>{let e=(0,Q.c)(50),{t}=Pr(),n=fn(Ef),r=ln(Df),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?ne(i.location):n?.hostId&&n.hubId?ne({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=K(Of),c=K(kf),l=K(Af),u=K(jf),d=vu(Mf),f=Z.useRef(null),p=wa(Ea(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=oc(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=C(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!ae()&&!_&&y(),e[4]=b):b=e[4];let x=b,S=Pf,w,T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},T=[],e[5]=w,e[6]=T):(w=e[5],T=e[6]),Z.useEffect(w,T);let E=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=J(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(bf,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(ic,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:J(wf,`shrink-0`),children:(0,$.jsx)(X,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(ti,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(ol,{}):null,e[19]=v,e[20]=P);let F=ri,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=J(wf,`group shrink-0`),R=(0,$.jsx)(X,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let ee=ti,B=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),V;e[28]===B?V=e[29]:(V=(0,$.jsx)(`p`,{children:B}),e[28]=B,e[29]=V);let te;e[30]!==ee||e[31]!==V?(te=(0,$.jsx)(ee,{children:V}),e[30]=ee,e[31]=V,e[32]=te):te=e[32];let re;e[33]!==F||e[34]!==z||e[35]!==te?(re=(0,$.jsxs)(F,{children:[z,te]}),e[33]=F,e[34]=z,e[35]=te,e[36]=re):re=e[36];let ie;e[37]!==P||e[38]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,re]}),e[37]=P,e[38]=re,e[39]=ie):ie=e[39];let H;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ie?(H=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ie]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ie,e[45]=H):H=e[45];let U;return e[46]!==H||e[47]!==E||e[48]!==O?(U=(0,$.jsx)(`div`,{"data-titlebar-location":E,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:H}),e[46]=H,e[47]=E,e[48]=O,e[49]=U):U=e[49],U};function Ef(e){return e.projects.find(t=>t.id===e.activeProjectId)}function Df(e){return e.remoteSession}function Of(e){return e.isSidebarOpen}function kf(e){return e.sidebarWidth}function Af(e){return e.toggleSidebar}function jf(e){return e.shortcutOverrides}function Mf(e){return e.sidebarBrandName.trim().length>0}function Nf(e){console.warn(`[titlebar] failed to open app menu`,e)}function Pf(e){let t=e.currentTarget.getBoundingClientRect();ee(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Nf)}var Ff=(e,t)=>{let n=Pt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},If=(e,t,n=10)=>{let r=Nt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=Nt(t.path);if(!e||i.has(e))continue;let o=Ff(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},Lf=e=>e.some(e=>!!Nt(e)),Rf=(e,t)=>{let n=new Set(t.map(e=>Nt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},zf=(e,t,n)=>t.length===0?e.length===0:Rf(e,t).length>0?!1:t.every(e=>n.has(Nt(e))),Bf=xa(()=>zt(()=>import(`./ToolOutputDialog-DManupRM.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),Vf=e=>{let t=Wf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},Hf=e=>{let t=(0,Q.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Z.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=J(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Uf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Wf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},Gf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Kf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,qf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!n||!r)return!1;let i=Kf(n),a=Kf(r);return a===i||a.startsWith(`${i}/`)},Jf=(e,t)=>{let n=Wf(t),r=Wf(e);if(!qf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Yf=(e,t)=>{if(!t)return``;let n=Wf(t);if(!e||!qf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},Xf=new Set([`node_modules`]),Zf=e=>{let t=(0,Q.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Qf=e=>{let t=(0,Q.c)(11),{name:n}=e,r=Z.useRef(null),i=Z.useRef(null),[a,o]=Z.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Z.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},$f=e=>Xf.has(e),ep=e=>{let t=Wf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},tp=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},np=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},rp=2e5,ip=`yuri:files:auto-save-enabled`,ap=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`},op=e=>e.replace(/\r\n/g,`
|
|
6
|
+
`).replace(/\r/g,`
|
|
7
|
+
`),sp=(e,t)=>{let n=op(e);return t===`\r
|
|
8
|
+
`?n.replace(/\n/g,`\r
|
|
9
|
+
`):n},cp=()=>{if(typeof window>`u`)return!0;try{return window.localStorage.getItem(ip)!==`false`}catch{return!0}},lp=(e,t)=>(0,$.jsx)(ii,{filePath:e,extension:t}),up=e=>{if(!e)return!1;let t=e.toLowerCase().split(`.`).pop();return t===`md`||t===`markdown`},dp=e=>{let t=(0,Q.c)(83),{node:n,root:r,isExpanded:i,isActive:a,isMobile:o,alwaysShowActions:s,status:c,badge:l,permissions:u,downloadFile:d,contextMenuPath:f,setContextMenuPath:p,rightClickMenuPath:m,setRightClickMenuPath:h,onSelect:g,onToggle:_,onRevealPath:v,onOpenDialog:y}=e,{t:b}=Pr(),x=n.type===`directory`,{canRename:S,canCreateFile:C,canCreateFolder:w,canDelete:T,canReveal:E}=u,D;t[0]!==C||t[1]!==w||t[2]!==T||t[3]!==S||t[4]!==E||t[5]!==n.path||t[6]!==h?(D=e=>{!S&&!C&&!w&&!T&&!E||(e?.preventDefault(),h(n.path))},t[0]=C,t[1]=w,t[2]=T,t[3]=S,t[4]=E,t[5]=n.path,t[6]=h,t[7]=D):D=t[7];let O=D,k;t[8]!==x||t[9]!==n||t[10]!==g||t[11]!==_?(k=()=>{x?_(n.path):g(n)},t[8]=x,t[9]=n,t[10]=g,t[11]=_,t[12]=k):k=t[12];let A=k,j;t[13]!==n.path||t[14]!==p||t[15]!==h?(j=e=>{e.stopPropagation(),h(null),p(n.path)},t[13]=n.path,t[14]=p,t[15]=h,t[16]=j):j=t[16];let M=j,N;t[17]!==C||t[18]!==w||t[19]!==T||t[20]!==S||t[21]!==E||t[22]!==d||t[23]!==x||t[24]!==n||t[25]!==y||t[26]!==v||t[27]!==r||t[28]!==b?(N=e=>{let{Item:t,Separator:i}=e;return(0,$.jsxs)($.Fragment,{children:[S&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`rename`,n)},children:[(0,$.jsx)(X,{name:`edit`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.rename`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),pr(n.path).then(e=>{e.ok||Y.error(b(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.copyPath`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation();let t=Yf(r,n.path)||n.path;pr(t).then(e=>{if(e.ok){Y.success(b(`filesView.toast.relativePathCopied`));return}Y.error(b(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy-2`,className:`mr-2 size-4`}),` `,b(`filesView.tree.menu.copyRelativePath`)]}),!x&&d&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),d(n.path).catch(e=>{console.error(`Download failed:`,e),Y.error(b(`sidebarFilesTree.toast.operationFailed`))})},children:[(0,$.jsx)(X,{name:`download`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.save`)]}),E&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),v(n.path)},children:[(0,$.jsx)(X,{name:`folder-received`,className:`mr-2 size-4`}),` `,b(Un())]}),x&&(C||w)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(i,{}),C&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`createFile`,n)},children:[(0,$.jsx)(X,{name:`file-add`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.newFile`)]}),w&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`createFolder`,n)},children:[(0,$.jsx)(X,{name:`folder-add`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.newFolder`)]})]}),T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(i,{}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`delete`,n)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-2 size-4 text-inherit`}),` `,b(`sidebarFilesTree.menu.delete`)]})]})]})},t[17]=C,t[18]=w,t[19]=T,t[20]=S,t[21]=E,t[22]=d,t[23]=x,t[24]=n,t[25]=y,t[26]=v,t[27]=r,t[28]=b,t[29]=N):N=t[29];let P=N,F=m===n.path,I;t[30]!==n.path||t[31]!==h?(I=e=>h(e?n.path:null),t[30]=n.path,t[31]=h,t[32]=I):I=t[32];let L=o?void 0:O,R;t[33]===L?R=t[34]:(R=(0,$.jsx)(`div`,{className:`group relative flex items-center`,onContextMenu:L}),t[33]=L,t[34]=R);let z=o?void 0:O,ee=a?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`,B;t[35]===ee?B=t[36]:(B=J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none`,ee),t[35]=ee,t[36]=B);let V;t[37]!==x||t[38]!==i||t[39]!==n.extension||t[40]!==n.path?(V=x?i?(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-4 flex-shrink-0 text-muted-foreground`}):lp(n.path,n.extension),t[37]=x,t[38]=i,t[39]=n.extension,t[40]=n.path,t[41]=V):V=t[41];let te;t[42]!==n.name||t[43]!==n.path?(te=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-meta`,title:n.path,children:n.name}),t[42]=n.name,t[43]=n.path,t[44]=te):te=t[44];let ne;t[45]!==x||t[46]!==c?(ne=!x&&c&&(0,$.jsx)(Zf,{status:c}),t[45]=x,t[46]=c,t[47]=ne):ne=t[47];let re;t[48]!==l||t[49]!==x?(re=x&&l&&(0,$.jsxs)(`span`,{className:`text-xs flex items-center gap-1 ml-auto mr-1`,children:[l.modified>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-warning)]`,children:[`M`,l.modified]}),l.added>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,l.added]})]}),t[48]=l,t[49]=x,t[50]=re):re=t[50];let ie;t[51]!==A||t[52]!==B||t[53]!==V||t[54]!==te||t[55]!==ne||t[56]!==re||t[57]!==z?(ie=(0,$.jsxs)(`button`,{type:`button`,onClick:A,onContextMenu:z,className:B,children:[V,te,ne,re]}),t[51]=A,t[52]=B,t[53]=V,t[54]=te,t[55]=ne,t[56]=re,t[57]=z,t[58]=ie):ie=t[58];let ae;t[59]!==s||t[60]!==C||t[61]!==w||t[62]!==T||t[63]!==S||t[64]!==E||t[65]!==f||t[66]!==M||t[67]!==o||t[68]!==n.path||t[69]!==P||t[70]!==p?(ae=(S||C||w||T||E)&&(0,$.jsx)(`div`,{className:J(`absolute right-1 top-1/2 -translate-y-1/2`,s?`opacity-100`:`opacity-0 focus-within:opacity-100 group-hover:opacity-100`),children:(0,$.jsxs)(wi,{open:f===n.path,onOpenChange:e=>p(e?n.path:null),children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:M,children:(0,$.jsx)(X,{name:`more-2-fill`,className:`size-4`})})}),(0,$.jsx)(xi,{align:`end`,side:`bottom`,onCloseAutoFocus:()=>p(null),children:P({Item:Si,Separator:Ci})})]})}),t[59]=s,t[60]=C,t[61]=w,t[62]=T,t[63]=S,t[64]=E,t[65]=f,t[66]=M,t[67]=o,t[68]=n.path,t[69]=P,t[70]=p,t[71]=ae):ae=t[71];let H;t[72]!==ie||t[73]!==ae||t[74]!==R?(H=(0,$.jsxs)(Ti,{render:R,children:[ie,ae]}),t[72]=ie,t[73]=ae,t[74]=R,t[75]=H):H=t[75];let U;t[76]===P?U=t[77]:(U=(0,$.jsx)(Di,{className:`min-w-[180px]`,children:P({Item:Oi,Separator:Ei})}),t[76]=P,t[77]=U);let oe;return t[78]!==H||t[79]!==U||t[80]!==F||t[81]!==I?(oe=(0,$.jsxs)(ki,{open:F,onOpenChange:I,children:[H,U]}),t[78]=H,t[79]=U,t[80]=F,t[81]=I,t[82]=oe):oe=t[82],oe},fp=e=>{let t=(0,Q.c)(83),{activeDialog:n,dialogData:r,dialogInputValue:i,onDialogInputChange:a,isDialogSubmitting:o,onDialogSubmit:s,onClose:c,inputRef:l}=e,{t:u}=Pr(),d=!!n,f;t[0]===c?f=t[1]:(f=e=>!e&&c(),t[0]=c,t[1]=f);let p;t[2]!==n||t[3]!==u?(p=n===`createFile`&&u(`filesView.dialog.createFile.title`),t[2]=n,t[3]=u,t[4]=p):p=t[4];let m;t[5]!==n||t[6]!==u?(m=n===`createFolder`&&u(`filesView.dialog.createFolder.title`),t[5]=n,t[6]=u,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==u?(h=n===`rename`&&u(`filesView.dialog.rename.title`),t[8]=n,t[9]=u,t[10]=h):h=t[10];let g;t[11]!==n||t[12]!==u?(g=n===`delete`&&u(`filesView.dialog.delete.title`),t[11]=n,t[12]=u,t[13]=g):g=t[13];let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,$.jsxs)(Zr,{children:[p,m,h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n||t[20]!==r?.path||t[21]!==u?(v=n===`createFile`&&u(`filesView.dialog.createFile.description`,{path:r?.path??u(`filesView.dialog.rootFallback`)}),t[19]=n,t[20]=r?.path,t[21]=u,t[22]=v):v=t[22];let y;t[23]!==n||t[24]!==r?.path||t[25]!==u?(y=n===`createFolder`&&u(`filesView.dialog.createFolder.description`,{path:r?.path??u(`filesView.dialog.rootFallback`)}),t[23]=n,t[24]=r?.path,t[25]=u,t[26]=y):y=t[26];let b;t[27]!==n||t[28]!==r?.name||t[29]!==u?(b=n===`rename`&&u(`filesView.dialog.rename.description`,{name:r?.name??``}),t[27]=n,t[28]=r?.name,t[29]=u,t[30]=b):b=t[30];let x;t[31]!==n||t[32]!==r?.name||t[33]!==u?(x=n===`delete`&&u(`filesView.dialog.delete.description`,{name:r?.name??``}),t[31]=n,t[32]=r?.name,t[33]=u,t[34]=x):x=t[34];let S;t[35]!==b||t[36]!==x||t[37]!==v||t[38]!==y?(S=(0,$.jsxs)(Qr,{children:[v,y,b,x]}),t[35]=b,t[36]=x,t[37]=v,t[38]=y,t[39]=S):S=t[39];let C;t[40]!==S||t[41]!==_?(C=(0,$.jsxs)(Jr,{children:[_,S]}),t[40]=S,t[41]=_,t[42]=C):C=t[42];let w;t[43]!==n||t[44]!==i||t[45]!==l||t[46]!==a||t[47]!==s||t[48]!==u?(w=n!==`delete`&&(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsx)(ya,{value:i,onChange:e=>a(e.target.value),placeholder:u(n===`rename`?`filesView.dialog.rename.placeholder`:`filesView.dialog.namePlaceholder`),onKeyDown:e=>{e.key===`Enter`&&s()},ref:l})}),t[43]=n,t[44]=i,t[45]=l,t[46]=a,t[47]=s,t[48]=u,t[49]=w):w=t[49];let T;t[50]===u?T=t[51]:(T=u(`filesView.dialog.cancel`),t[50]=u,t[51]=T);let E;t[52]!==o||t[53]!==c||t[54]!==T?(E=(0,$.jsx)(q,{variant:`outline`,onClick:c,disabled:o,children:T}),t[52]=o,t[53]=c,t[54]=T,t[55]=E):E=t[55];let D=n===`delete`?`destructive`:`default`,O;t[56]===s?O=t[57]:(O=()=>void s(),t[56]=s,t[57]=O);let k;t[58]!==n||t[59]!==i||t[60]!==o?(k=o||n!==`delete`&&!i.trim(),t[58]=n,t[59]=i,t[60]=o,t[61]=k):k=t[61];let A;t[62]!==n||t[63]!==o||t[64]!==u?(A=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):u(n===`delete`?`filesView.dialog.delete.confirm`:`filesView.dialog.confirm`),t[62]=n,t[63]=o,t[64]=u,t[65]=A):A=t[65];let j;t[66]!==D||t[67]!==O||t[68]!==k||t[69]!==A?(j=(0,$.jsx)(q,{variant:D,onClick:O,disabled:k,children:A}),t[66]=D,t[67]=O,t[68]=k,t[69]=A,t[70]=j):j=t[70];let M;t[71]!==E||t[72]!==j?(M=(0,$.jsxs)(Yr,{children:[E,j]}),t[71]=E,t[72]=j,t[73]=M):M=t[73];let N;t[74]!==l||t[75]!==C||t[76]!==w||t[77]!==M?(N=(0,$.jsxs)(Xr,{initialFocus:l,children:[C,w,M]}),t[74]=l,t[75]=C,t[76]=w,t[77]=M,t[78]=N):N=t[78];let P;return t[79]!==d||t[80]!==f||t[81]!==N?(P=(0,$.jsx)($r,{open:d,onOpenChange:f,children:N}),t[79]=d,t[80]=f,t[81]=N,t[82]=P):P=t[82],P},pp=(e,t,n)=>e&&!!t&&n===t,mp=(e,t,n)=>{let r=(0,Q.c)(8),[s,c]=Z.useState(``),[l,u]=Z.useState(0),d,f;r[0]!==e||r[1]!==n||r[2]!==t?(d=()=>{if(!e){c(``);return}let r=!1;c(``);let s=h(),l=a(s);i(s).then(n=>{r||!n||(c(e),t(null))}).catch(i=>{r||(t(i instanceof Error?i.message:n),c(e))});let d=o(()=>{r||(c(e),u(_p),t(null))});return()=>{r=!0,l(),d()}},f=[e,t,n],r[0]=e,r[1]=n,r[2]=t,r[3]=d,r[4]=f):(d=r[3],f=r[4]),Z.useEffect(d,f);let p;return r[5]!==l||r[6]!==s?(p={readyKey:s,nonce:l},r[5]=l,r[6]=s,r[7]=p):p=r[7],p},hp=e=>{let t=(0,Q.c)(5),n=xt();if(!n?.entry.location.hostId){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(gp,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==n.entry.key||t[3]!==e?(r=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(gp,{...e},n.entry.key)})}),t[2]=n.entry.key,t[3]=e,t[4]=r):r=t[4],r},gp=({mode:e=`full`,isActive:t=!0,targetPath:n})=>{let{t:r}=Pr(),{files:i,runtime:a,projectScope:o}=Ki(),{currentTheme:s,availableThemes:c,lightThemeId:l,darkThemeId:d}=oi(),{isMobile:f,isTablet:p,screenWidth:m}=pi({includeScreenWidth:!0}),h=f||p,_=it(),v=nt(),y=qi()??``,b=o?y:Wf(y.trim()),C=f||e!==`editor-only`,w=e===`editor-only`&&!f,T=rt(e=>e.searchFiles),E=Qi(y),[D,k]=Z.useState(``),A=ja(D,200),j=Z.useRef(null),[M,N]=Z.useState(!1),[P,F]=Z.useState(!0),[I,L]=Z.useState(!1),[R,z]=Z.useState(!1),[ee,B]=Z.useState(!1),[V,te]=Z.useState({open:!1,title:``,content:``}),re=Z.useRef(null),ie=Z.useRef(0),ae=Z.useCallback(e=>{ie.current=Math.max(0,ie.current+(e?1:-1))},[]),H=Z.useCallback(e=>e instanceof Element&&e.closest(`[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]`)!==null,[]);Z.useEffect(()=>{if(!ee)return;let e=e=>{ie.current>0||H(e.target)||re.current&&!re.current.contains(e.target)&&B(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[H,ee]);let[U,oe]=Z.useState(`edit`),[se,ce]=Z.useState(`edit`),[le,ue]=Z.useState(`edit`),[de,fe]=Z.useState(`preview`),[pe,me]=Z.useState(0),he=Z.useRef({}),ge=Z.useRef({}),_e=Z.useRef({}),ve=Z.useRef({}),ye=Z.useMemo(()=>c.find(e=>e.metadata.id===l)??Ui(!1),[c,l]),be=Z.useMemo(()=>c.find(e=>e.metadata.id===d)??Ui(!0),[c,d]);Z.useEffect(()=>{Hi(ye),Hi(be)},[ye,be]);let xe=Z.useMemo(()=>[],[]),Ce=o?ne({...o.location,directory:b||o.location.directory}):b,we=Vo(e=>Ce?e.byRoot[Ce]?.openPaths??xe:xe),Te=Vo(e=>Ce?e.byRoot[Ce]?.selectedPath??null:null),Ee=Vo(e=>Ce?e.byRoot[Ce]?.expandedPaths??xe:xe),{addOpenPath:De,removeOpenPath:Oe,removeOpenPathsByPrefix:ke,removeExpandedPathsByPrefix:Ae,setSelectedPath:je,toggleExpandedPath:Me,expandPaths:Ne}=Z.useMemo(()=>{let e=Vo.getState();return o?{addOpenPath:(t,n,r)=>e.addOpenPath(Ce,n,r),removeOpenPath:(t,n)=>e.removeOpenPath(Ce,n),removeOpenPathsByPrefix:(t,n)=>e.removeOpenPathsByPrefix(Ce,n),removeExpandedPathsByPrefix:(t,n)=>e.removeExpandedPathsByPrefix(Ce,n),setSelectedPath:(t,n,r)=>e.setSelectedPath(Ce,n,r),toggleExpandedPath:(t,n)=>e.toggleExpandedPath(Ce,n),expandPaths:(t,n)=>e.expandPaths(Ce,n)}:e},[o,Ce]),Pe=Z.useCallback(e=>{let t=Wf(e),n=t.split(`/`),r=n[n.length-1]||t;return{name:r,path:t,type:`file`,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0}},[]),Fe=Z.useMemo(()=>we.map(Pe),[we,Pe]),Ie=e===`editor-only`&&n?Wf(n):null,Le=Z.useMemo(()=>{if(Ie)return Ie;if(Te){let e=Kf(Te);if(we.some(t=>Kf(t)===e))return Te}return we[0]??null},[Ie,we,Te]),W=Z.useMemo(()=>Le?Pe(Le):null,[Le,Pe]),Re=W?.path??``;Z.useEffect(()=>{if(!b||!Te)return;let e=Kf(Te);we.some(t=>Kf(t)===e)||je(b,we[0]??null)},[we,b,Te,je]);let ze=!!(b&&Re&&!qf(Re,b)),Be=ze?rs(Re):void 0,Ve=Z.useMemo(()=>({allowOutsideWorkspace:e===`editor-only`&&ze,outsideFileGrant:Be,directory:b||void 0}),[e,ze,Be,b]),He=Z.useRef(null),[Ue,We]=Z.useState({left:!1,right:!1}),Ge=Z.useCallback(()=>{let e=He.current;e&&We({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},[]),Ke=Z.useRef(Ge);Ke.current=Ge,Z.useEffect(()=>{let e=He.current;if(!e)return;let t=()=>Ke.current();t(),e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect()}},[Fe.length]);let[qe,Je]=Z.useState({}),[Ye,Xe]=Z.useState({}),Ze=Z.useRef(new Set),Qe=Z.useRef(new Set),$e=Z.useRef(!1),et=Z.useRef(new Map),tt=Z.useRef(0),[at,ot]=Z.useState([]),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState(``),{isPlaying:ft,play:pt,stop:mt}=Hs(),[ht,gt]=Z.useState(!1),[_t,vt]=Z.useState(null),[yt,bt]=Z.useState(``),xt=Z.useRef(``),[St,Ct]=Z.useState(null),wt=ht&&St!==Re,[Tt,Mt]=Z.useState(0),[Nt,Pt]=Z.useState(null),Ft=!!(Re&&Nt===Re),[It,Lt]=Z.useState(null),[Rt,zt]=Z.useState(``),[Bt,Vt]=Z.useState(!1),[Ht,Ut]=Z.useState(`
|
|
10
|
+
`),Wt=Z.useRef(null),Gt=Z.useRef(null),Kt=Z.useRef(null),qt=Z.useRef(``),Jt=Z.useRef(``),Yt=Z.useRef(null),Qt=Z.useRef(null),$t=Z.useRef(null),en=Z.useRef(0),tn=Z.useRef(null),[nn,rn]=Z.useState(`idle`),[an,on]=Z.useState(!1),[sn,cn]=Z.useState(cp),[ln,un]=Z.useState(!1),dn=Z.useRef(null),fn=Z.useRef(null),pn=Z.useRef(null),mn=Z.useRef(!1),hn=Z.useRef(null),gn=Z.useRef(null),_n=Z.useRef(null),vn=Z.useRef(null),[yn,bn]=Z.useState(0),xn=Z.useRef(null),Sn=Z.useRef({key:``,attempts:0});Z.useEffect(()=>()=>{xn.current!==null&&typeof window<`u`&&(window.cancelAnimationFrame(xn.current),xn.current=null)},[]);let[Cn,wn]=Z.useState(null),[Tn,En]=Z.useState(null),[Dn,On]=Z.useState(``),[kn,An]=Z.useState(!1),[jn,Mn]=Z.useState(null),[Pn,Fn]=Z.useState(null),[In,Ln]=Z.useState(!1),[Rn,zn]=Z.useState(!1),[Bn,Vn]=Z.useState(!1),[Hn,Un]=Z.useState(null),Wn=Ir(e=>e.addCodeSelectionAttachment),Gn=Ir(e=>e.setPendingInputText),Kn=!!i.writeFile,qn=!!i.createDirectory,Jn=!!i.rename,Yn=!!i.delete,Xn=!!i.revealPath,Zn=ud(e=>e.availableApps),Qn=ud(e=>e.isCacheStale),$n=ud(e=>e.initialize),er=ud(e=>e.loadInstalledApps);Z.useEffect(()=>{o||$n()},[$n,o]);let nr=Z.useCallback(e=>{i.revealPath&&i.revealPath(e).catch(()=>{Y.error(r(`sidebarFilesTree.toast.revealFailed`))})},[i,r]),rr=Z.useCallback(async e=>{if(o||!W?.path||await O(W.path,e.id,e.appName)||await S(W.path,e.appName))return;let t=Vf(W.path)||b;t&&await S(t,e.appName)||Y.error(r(`filesView.toast.openInAppFailed`,{app:e.appName}))},[b,W?.path,r,o]),ir=Z.useCallback((e,t)=>{wn(e),En(t),On(e===`rename`&&t.name||``),An(!1)},[]),[ar,or]=Z.useState(null),sr=Z.useRef(!1),cr=Z.useRef(null),[lr,ur]=Z.useState(!1),dr=K(e=>e.setMainTabGuard),fr=K(e=>e.pendingFileNavigation),hr=K(e=>e.setPendingFileNavigation),gr=K(e=>e.pendingFileFocusPath),_r=K(e=>e.setPendingFileFocusPath),vr=K(e=>e.pendingFileViewerMode),yr=K(e=>e.setPendingFileViewerMode),br=K(e=>e.fileEditorKeymap),xr=Nn(e=>e.settingsDefaultFileViewerPreview),Sr=Nn(e=>e.showMessageTTSButtons);Z.useEffect(()=>{let e=()=>{sr.current=!1,cr.current=null,ur(!1)};return document.addEventListener(`mouseup`,e),()=>document.removeEventListener(`mouseup`,e)},[]),Z.useEffect(()=>()=>{hn.current!==null&&window.clearTimeout(hn.current),gn.current!==null&&window.clearTimeout(gn.current)},[]);let Cr=Z.useCallback((e,t)=>{let n=e.split(`
|
|
11
|
+
`),r=Math.max(1,t.start),i=Math.min(n.length,t.end);return r>i?``:n.slice(r-1,i).join(`
|
|
12
|
+
`)},[]),{drafts:wr,commentText:Tr,setCommentText:Er,editingDraftId:Dr,setSelection:Or,saveComment:kr,cancel:Ar,reset:jr,startEdit:Mr,deleteDraft:Nr}=Ii({source:`file`,fileLabel:W?.path??null,language:W?.path&&Lr(W.path)||`text`,getCodeForRange:e=>Cr(lt,Ni(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})});Z.useEffect(()=>{or(null),jr(),dr(null),zt(``),Vt(!1)},[W?.path,jr,dr]),Z.useEffect(()=>{Or(ar)},[ar,Or]),Z.useEffect(()=>{if(!ar&&!Dr)return;let e=e=>{let t=e.target;t.closest(`[data-comment-input="true"]`)||t.closest(`[data-comment-card="true"]`)||t.closest(`.cm-gutterElement`)||t.closest(`[data-sonner-toast]`)||t.closest(`[data-sonner-toaster]`)||Tr.trim()||(or(null),Ar())},t=setTimeout(()=>{document.addEventListener(`click`,e)},100);return()=>{clearTimeout(t),document.removeEventListener(`click`,e)}},[Ar,Tr,Dr,ar]);let Fr=Z.useCallback((e,t)=>{let n=t??ar??void 0;t&&or(t),kr(e,n),or(null)},[ar,kr]),Ur=Z.useCallback((e,t)=>{let n=[];for(let r of t){if(!(r&&typeof r.name==`string`&&r.name.length>0)||!_&&r.name.startsWith(`.`)||!v&&$f(r.name))continue;let t=r.name,i=Wf(r.path||``),a=i?Gf(i)?i:Wf(`${e}/${i}`):Wf(`${e}/${t}`),o=r.isDirectory?`directory`:`file`,s=o===`file`&&t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():void 0;n.push({name:t,path:a,type:o,extension:s})}return Uf(n)},[v,_]),Wr=Z.useCallback(async e=>{let t=Wf(e.trim());if(!t||Ze.current.has(t)||Qe.current.has(t))return;Qe.current=new Set(Qe.current),Qe.current.add(t);let n=tt.current+1;tt.current=n,et.current=new Map(et.current),et.current.set(t,n);let r=()=>et.current.get(t)===n;await(i.listDirectory?i.listDirectory(t).then(e=>e.entries.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory}))):Se.listLocalDirectory(t).then(e=>e.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory})))).then(e=>{if(!r())return;let n=Ur(t,e);Ze.current=new Set(Ze.current),Ze.current.add(t),Xe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),Je(e=>({...e,[t]:n}))}).catch(e=>{if(!r())return;let n=e instanceof Error?e.message:String(e??``);if(n===`Directory not found`&&b&&t!==b){Ae(b,t),Xe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n});return}console.error(`Failed to load files directory:`,e),Xe(e=>({...e,[t]:n}))}).finally(()=>{r()&&(et.current=new Map(et.current),et.current.delete(t),Qe.current=new Set(Qe.current),Qe.current.delete(t))})},[i,Ur,Ae,b]),Kr=Z.useCallback(async()=>{b&&(Ze.current=new Set,Qe.current=new Set,et.current=new Map,Xe({}),Je(e=>Object.keys(e).length===0?e:{}),await Wr(b))},[Wr,b]),qr=Z.useCallback(async e=>{if(!e){await Kr();return}let t=Wf(e);Ze.current=new Set(Ze.current),Ze.current.delete(t),Qe.current=new Set(Qe.current),Qe.current.delete(t),await Wr(t)},[Wr,Kr]),ni=Z.useRef(``),ai=Z.useRef(``);Z.useEffect(()=>{if(!b)return;let e=`${b}|h${_?`1`:`0`}|g${v?`1`:`0`}`,t=ni.current!==b,n=ai.current!==e;!t&&!n||(t&&(ni.current=b,ut(``),vt(null),bt(``),Ct(null),N(!1)),n&&(ai.current=e,$e.current=!1,Ze.current=new Set,Qe.current=new Set,et.current=new Map,Xe({}),Je(e=>Object.keys(e).length===0?e:{}),Wr(b)))},[Wr,b,v,_]),Z.useEffect(()=>{if(!i.listDirectory)return;let e=()=>{if(!document.hidden&&Ee.length>0)for(let e of Ee)qr(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Ee,i.listDirectory,qr]),Z.useEffect(()=>{if(!b||Ee.length===0)return;let e=Ee.map(e=>Wf(e)).filter(e=>!!e&&e!==b&&e.startsWith(`${b}/`)&&!Ze.current.has(e)&&!Qe.current.has(e)).sort((e,t)=>e.split(`/`).length-t.split(`/`).length);if(e.length===0)return;let t=!1;return(async()=>{for(let n=0;n<e.length&&!t;n+=3){let t=e.slice(n,n+3);await Promise.all(t.map(e=>Wr(e)))}})(),()=>{t=!0}},[Ee,Wr,b]);let si=Z.useCallback(async e=>{if(e?.preventDefault(),!Tn||!Cn)return;An(!0);let t=()=>{wn(null)},n=e=>{Y.error(e)},a=()=>{An(!1)};if(Cn===`createFile`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.filenameRequired`)),a();return}if(!i.writeFile){n(r(`sidebarFilesTree.toast.writeNotSupported`)),a();return}let e=Tn.path,o=Wf(`${e?`${e}/`:``}${Dn.trim()}`);await i.writeFile(o,``).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.fileCreated`)),await qr(e)),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`createFolder`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.folderNameRequired`)),a();return}let e=Tn.path,o=Wf(`${e?`${e}/`:``}${Dn.trim()}`);await i.createDirectory(o).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.folderCreated`)),await qr(e)),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`rename`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.nameRequired`)),a();return}if(!i.rename){n(r(`sidebarFilesTree.toast.renameNotSupported`)),a();return}let e=Tn.path,o=e.split(`/`).slice(0,-1).join(`/`),s=Wf(`${o?`${o}/`:``}${Dn.trim()}`);await i.rename(e,s).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.renamedSuccessfully`)),await qr(o),b&&ke(b,e),(W?.path===e||W?.path.startsWith(`${e}/`))&&(b&&je(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1))),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`delete`){if(!i.delete){n(r(`sidebarFilesTree.toast.deleteNotSupported`)),a();return}let e=Tn.path,o=e.split(`/`).slice(0,-1).join(`/`);await i.delete(e).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.deletedSuccessfully`)),await qr(o),b&&ke(b,e),(W?.path===e||W?.path.startsWith(`${e}/`))&&(b&&je(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1))),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}a()},[Cn,Tn,Dn,i,qr,f,ke,b,W?.path,je,r]);Z.useEffect(()=>{if(!y){ot([]),ct(!1);return}let e=A.trim();if(!e){ot([]),ct(!1);return}let t=!1;return ct(!0),(o?Et.fetchQuery(jt(i,{scope:o,directory:y,query:e,maxResults:150,includeHidden:_,respectGitignore:!v})).then(e=>e.map(e=>({path:e.path,name:e.path.split(/[\\/]/).pop()??e.path,extension:e.path.split(`.`).pop(),relativePath:Yf(b,e.path)}))):T(y,e,150,{includeHidden:_,respectGitignore:!v,type:`file`})).then(e=>{if(t)return;let n=e.filter(e=>v||!ep(e.path)).map(e=>({name:e.name,path:Wf(e.path),type:`file`,extension:e.extension,relativePath:e.relativePath}));ot(n)}).catch(()=>{t||ot([])}).finally(()=>{t||ct(!1)}),()=>{t=!0}},[y,A,T,_,v,o,i,b]);let ci=Z.useCallback(async(e,t)=>{if(i.readFile)return(await i.readFile(e,{...t??{},directory:b||void 0})).content??``;let n=new URLSearchParams({path:e});t?.allowOutsideWorkspace&&n.set(`allowOutsideWorkspace`,`true`),t?.outsideFileGrant&&n.set(`outsideFileGrant`,t.outsideFileGrant),t?.optional&&n.set(`optional`,`true`),b&&n.set(`directory`,b);let a=await g(`/api/fs/read?${n.toString()}`,{cache:t?.optional?`no-store`:`default`});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||r(`filesView.error.readFileFailed`))}return a.text()},[i,b,r]),li=Z.useCallback(async(e,t)=>{if(i.statFile){let n=await i.statFile(e,{...t??{},directory:b||void 0});return{path:n.path,size:n.size,mtimeMs:n.mtimeMs,isBinary:n.isBinary}}return null},[i,b]);Z.useEffect(()=>{if(!b||!i.statFile||we.length===0)return;let e=!1,t=we.filter(e=>e!==Re||Rr(e)&&!e.toLowerCase().endsWith(`.svg`)||Br(e));return Promise.all(t.map(async t=>{try{let n=await i.statFile?.(t,{directory:b||void 0});!e&&n&&!n.isFile&&ke(b,t)}catch(n){!e&&np(n)&&ke(b,t)}})),()=>{e=!0}},[i,we,ke,b,Re]);let ui=Z.useMemo(()=>lt.length>rp?`${lt.slice(0,rp)}\n\n… truncated …`:lt,[lt]),di=Rt!==ui,fi=Z.useCallback(async()=>{if(Ft||ht||_t||St!==W?.path)return!1;if(!W||!i.writeFile)return Y.error(r(`filesView.toast.savingNotSupported`)),!1;if(!di)return!0;if(Rt===``&<!==``&&St!==W.path)return console.warn(`[saveDraft] refusing to save empty draft for "${W.path}" (${lt.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;Vt(!0);try{let e=sp(Rt,Ht);return(await i.writeFile(W.path,e))?.success?(ut(Rt),W?.path&&Vr(W.path)&&(qt.current=Rt,Jt.current=Rt),li(W.path).then(e=>{e&&($t.current=e)}).catch(()=>{}),!0):(Y.error(r(`filesView.toast.writeFileFailed`)),!1)}catch(e){return Y.error(e instanceof Error?e.message:r(`filesView.toast.saveFailed`)),!1}finally{Vt(!1)}},[Rt,lt,i,di,Ht,St,li,W,r,Ft,ht,_t]);Z.useEffect(()=>{if(!di){dr(null);return}let e=(e,t)=>mn.current?(mn.current=!1,!0):(un(!0),fn.current=t??e,!1);return dr(e),()=>{K.getState().mainTabGuard===e&&dr(null)}},[di,dr]),Z.useEffect(()=>{try{window.localStorage.setItem(ip,sn?`true`:`false`)}catch{}},[sn]),Z.useEffect(()=>{sn||(rn(`idle`),Gt.current&&=(clearTimeout(Gt.current),null))},[sn]);let mi=1500;Z.useEffect(()=>{let e=!!(W&&i.writeFile);if(!(!sn||!di||!e||Bt))return Gt.current=setTimeout(()=>{fi().then(e=>{e&&(rn(`saved`),setTimeout(()=>rn(`idle`),2e3))})},mi),()=>{Gt.current&&=(clearTimeout(Gt.current),null)}},[sn,Rt,di,W,i.writeFile,Bt,fi]),Z.useEffect(()=>{rn(`idle`)},[W?.path]),Z.useEffect(()=>{let e=e=>{!tr(e)||e.metaKey&&e.ctrlKey||(e.key.toLowerCase()===`s`?(e.preventDefault(),Gt.current&&=(clearTimeout(Gt.current),null),Bt||fi().then(e=>{e&&(rn(`saved`),setTimeout(()=>rn(`idle`),2e3))})):e.key.toLowerCase()===`f`&&(e.preventDefault(),z(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Bt,fi]);let hi=G(e=>{K.setState(t=>{let n=Wf(t.pendingFileFocusPath??``)===e,r=Wf(t.pendingFileNavigation?.path??``)===e;return!n&&!r?t:{...n?{pendingFileFocusPath:null,pendingFileViewerMode:null}:{},...r?{pendingFileNavigation:null}:{}}})}),gi=G(async t=>{let n=u(),i=en.current+1;en.current=i;let s=()=>{if(!b)return!1;let e=Vo.getState().byRoot[Ce],r=Ie??e?.selectedPath??e?.openPaths[0]??null;return en.current===i&&r===t.path&&n===u()},c=Rr(t.path),l=t.path.toLowerCase().endsWith(`.svg`),d=Br(t.path),p=St===t.path&&!c&&!d;if(vt(null),Lt(null),p||(bt(``),Ct(null),Pt(null)),f&&N(!0),(a.isDesktop||o)&&c&&!l){ut(``),zt(``),gt(!0);return}if(!a.isDesktop&&!o&&c&&!l){ut(``),zt(``),Ct(t.path),gt(!1);return}if(d){ut(``),zt(``),Ct(t.path),gt(!1);return}gt(!0);let m=rs(t.path),h={allowOutsideWorkspace:e===`editor-only`&&!!b&&!qf(t.path,b),outsideFileGrant:m};tn.current=t.path,await li(t.path,h).then(async e=>{if(s()){if(!e)throw Error(r(`filesView.error.readFileFailed`));if($t.current=e,e.isBinary){Pt(t.path),ut(``),zt(``),Ct(t.path),hi(t.path);return}return ci(t.path,h)}}).then(e=>{if(!s()||e===void 0)return;let n=op(e);p&&Hr(t.path)&&n!==lt&&Mt(e=>e+1),Pt(null),Ut(ap(e)),ut(n),qt.current=n,Jt.current=n,zt(n.length>rp?`${n.slice(0,rp)}\n\n… truncated …`:n),Ct(t.path)}).catch(n=>{if(!s())return;if(p&&!np(n)&&!tp(n)){Y.error(n instanceof Error?n.message:r(`filesView.error.readFileFailed`));return}hi(t.path),tn.current=null,gt(!1),Lt(t.path),ut(``),zt(``),$t.current=null;let i=n instanceof Error?n.message:r(`filesView.error.readFileFailed`);if(vt(i),e===`editor-only`){b&&tp(n)?Oe(b,t.path):b&&np(n)&&ke(b,t.path);return}if(tp(n)){if(b&&Oe(b,t.path),vt(null),D.trim().length>0&&k(``),f&&N(!1),b){let e=[...Jf(t.path,b),t.path];e.length>0&&Ne(b,e);for(let t of e)Ze.current.has(t)||Wr(t)}return}if(np(n)){b&&ke(b,t.path),vt(null),f&&N(!1);return}}).finally(()=>{s()&&(tn.current=null,gt(!1))})}),_i=Z.useCallback(async(e,t)=>{if(!b)return;let n=Jf(e,b),r=t?[...n,e]:n;r.length>0&&Ne(b,r);let i=r.map(e=>{if(!Ze.current.has(e))return Wr(e)}).filter(Boolean);await Promise.all(i)},[Ne,Wr,b]),vi=Z.useCallback((e,t)=>{let n=t.findIndex(t=>t.path===e);return n===-1||t.length<=1?null:t[n+1]??t[n-1]??null},[]),bi=Z.useCallback(async e=>{if(mn.current)mn.current=!1;else if(di){un(!0),dn.current=e;return}b&&(je(b,e.path),De(b,e.path),_i(e.path,!1)),vt(null),bt(``),ut(``),qt.current=``,Jt.current=``,zt(``),Ct(null),Lt(null),f&&N(!0)},[De,_i,di,f,b,je]);Z.useEffect(()=>{W?.path&&_i(W.path,!1)},[_i,W?.path]),Z.useEffect(()=>{if(!W){en.current+=1,gt(!1);return}St!==W.path&&It!==W.path&&tn.current!==W.path&&gi(W)},[i,e,b,a.isDesktop,f,gi,St,It,W]),Z.useEffect(()=>()=>{en.current+=1,tn.current=null},[b,Re]);let Ci=Z.useRef(di);Ci.current=di,Z.useEffect(()=>{let e=W?.path??``;if(!pp(t,e,St))return;let n=!1,r=window.setInterval(()=>{document.hidden||li(e,Ve).then(t=>{if(n||!t)return;let r=$t.current;if(!r||r.path!==e){$t.current=t;return}let i=t.mtimeMs!==void 0&&r.mtimeMs!==void 0&&t.mtimeMs!==r.mtimeMs,a=t.size!==r.size;!i&&!a&&t.isBinary===r.isBinary||Ci.current||tn.current===e||($t.current=t,W&&gi(W))}).catch(()=>{})},2e3);return()=>{n=!0,window.clearInterval(r)}},[t,St,li,W,Ve,gi]);let Ti=Z.useCallback(()=>{let e=dn.current,t=fn.current,n=pn.current;if(dn.current=null,fn.current=null,pn.current=null,mn.current=!0,un(!1),zt(ui),n){b&&Oe(b,n),W?.path===n&&(e?bi(e):(b&&je(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)));return}if(e){bi(e);return}t&&(dr(null),typeof t==`function`?(mn.current=!1,t()):K.getState().setActiveMainTab(t))},[ui,bi,f,Oe,b,W?.path,dr,je]),Ei=Z.useCallback(async()=>{let e=dn.current,t=fn.current,n=pn.current;if(!await fi()){mn.current=!1;return}if(dn.current=null,fn.current=null,pn.current=null,mn.current=!0,un(!1),n){b&&Oe(b,n),W?.path===n&&(e?await bi(e):(b&&je(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)));return}if(e){await bi(e);return}t&&(dr(null),typeof t==`function`?(mn.current=!1,t()):K.getState().setActiveMainTab(t))},[bi,f,Oe,b,fi,W?.path,dr,je]),Di=G(()=>{if(Bt)return;let e=dn.current;e&&hi(e.path),dn.current=null,fn.current=null,pn.current=null,mn.current=!1,un(!1)}),Oi=G(()=>{!W||ht||(Lt(null),vt(null),Ct(null),gt(!0))}),ki=Z.useCallback(e=>{let t=W?.path===e,n=vi(e,Fe);if(t&&di){un(!0),dn.current=n,pn.current=e;return}if(b&&Oe(b,e),t){if(n){bi(n);return}b&&je(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)}},[vi,bi,di,f,Fe,Oe,b,W?.path,je]),Ai=Z.useCallback(e=>{if(we.includes(e))return`open`;if(E?.files){let t=e.startsWith(b+`/`)?e.slice(b.length+1):e,n=E.files.find(e=>e.path===t);if(n){if(n.index===`A`||n.working_dir===`?`)return`git-added`;if(n.index===`D`)return`git-deleted`;if(n.index===`M`||n.working_dir===`M`)return`git-modified`}}return null},[we,E,b]),ji=Z.useCallback(e=>{if(!E?.files)return null;let t=e.startsWith(b+`/`)?e.slice(b.length+1):e,n=t?`${t}/`:``,r=0,i=0;for(let e of E.files)e.path.startsWith(n)&&((e.index===`M`||e.working_dir===`M`)&&r++,(e.index===`A`||e.working_dir===`?`)&&i++);return r+i>0?{modified:r,added:i}:null},[E,b]),Mi=Z.useCallback(async e=>{let t=Wf(e);b&&(Me(b,t),Ze.current.has(t)||await Wr(t))},[Wr,b,Me]),Fi=Z.useMemo(()=>b?If(b,qe):[],[qe,b]),zi=Z.useMemo(()=>new Set(Ee.map(e=>Wf(e))),[Ee]),Bi=Lf(Ee),Wi=Z.useCallback(()=>{if(b){if(Bi){$e.current=!1,Ae(b,b);return}$e.current=!0,Ne(b,Fi)}},[Bi,Fi,Ne,Ae,b]);Z.useEffect(()=>{if(!b||!$e.current)return;let e=Rf(Fi,Ee);if(e.length>0){Ne(b,e);return}let t=new Set([...Ze.current,...Object.keys(Ye)]);zf(Fi,Ee,t)&&($e.current=!1)},[Fi,Ne,Ee,Ye,b]);let Gi=Z.useMemo(()=>({canRename:Jn,canCreateFile:Kn,canCreateFolder:qn,canDelete:Yn,canReveal:Xn}),[Jn,Kn,qn,Yn,Xn]);function Ji(e,t){let n=qe[e]??[];return n.map((e,a)=>{let o=e.type===`directory`,s=o&&zi.has(Wf(e.path)),c=W?.path===e.path,l=a===n.length-1;return(0,$.jsxs)(`li`,{className:`relative`,children:[t>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`absolute top-3.5 left-[-12px] w-3 h-px bg-border/40`}),l&&(0,$.jsx)(`span`,{className:`absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background`})]}),(0,$.jsx)(dp,{node:e,root:b,isExpanded:s,isActive:c,isMobile:f,alwaysShowActions:h,status:o?void 0:Ai(e.path),badge:o?ji(e.path):void 0,permissions:Gi,downloadFile:i.downloadFile,contextMenuPath:jn,setContextMenuPath:Mn,rightClickMenuPath:Pn,setRightClickMenuPath:Fn,onSelect:bi,onToggle:Mi,onRevealPath:nr,onOpenDialog:ir}),o&&s&&(0,$.jsxs)(`ul`,{className:`flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative`,children:[Ye[e.path]?(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--status-error)]`,title:Ye[e.path],children:Ye[e.path]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`h-6 gap-1`,onClick:()=>void qr(e.path),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`}),r(`filesView.tree.actions.refreshTitle`)]})]}):null,Ji(e.path,t+1)]})]},e.path)})}let Yi=!!(W?.path&&Rr(W.path)),Xi=!!(W?.path&&W.path.toLowerCase().endsWith(`.svg`)),Zi=!!(W?.path&&Br(W.path)),$i=Z.useMemo(()=>Wf(fr?.path??``),[fr?.path]),ea=!!(fr&&$i&&Re&&Re===$i&&!ht&&!_t&&!Yi&&!Zi&&!Ft),ta=Z.useMemo(()=>Yf(b,Re),[Re,b]),na=Z.useCallback(e=>{let t=!e.state.selection.main.empty;if(Vn(e=>e===t?e:t),!t){Un(null);return}let n=e.state.selection.main,r=e.state.doc.lineAt(n.from).from,i=e.coordsAtPos(r);i&&Un({x:Math.min(window.innerWidth-240,Math.max(8,i.left)),y:Math.max(8,i.top-8)})},[]),ra=Z.useCallback(()=>{let e=_n.current,t=e?.state.selection.main;if(!e||!t||t.empty||!W)return;let n=e.state.sliceDoc(t.from,t.to),r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(Math.max(t.from,t.to-1)).number,a=r===i?`${r}`:`${r}-${i}`,o=`${W.name}:${a}`;Wn(W.path,o,n),Gn(dt(o),`append-inline`),Un(null),K.getState().setActiveMainTab(`chat`)},[Wn,W,Gn]),ia=Z.useCallback(e=>{if(!W)return;let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end),r=Rt.split(`
|
|
13
|
+
`).slice(t-1,n).join(`
|
|
14
|
+
`);if(!r)return;let i=t===n?`${t}`:`${t}-${n}`,a=`${W.name}:${i}`;Wn(W.path,a,r),Gn(dt(a),`append-inline`),K.getState().setActiveMainTab(`chat`)},[Wn,Rt,W,Gn]),aa=!!(W&&!Ft&&(!Yi||Xi)&&!Zi&<.length>0),oa=!!(W&&ta.length>0),ca=!!(W&&!Ft&&!ht&&!_t&&St===Re&&!ze&&!Yi&&!Zi&&i.writeFile&<.length<=rp),la=!!(!Ft&&W?.path&&up(W.path)),ua=!!(!Ft&&W?.path&&Hr(W.path)),da=!!(!Ft&&W?.path&&Vr(W.path)),fa=!!(W&&!Ft&&!Yi&&!Zi),pa=fa&&!la&&!da&&!(ua&&le===`preview`),xa=la&&se===`edit`||ua&&le===`edit`||!la&&!ua&&U===`edit`,Sa=Z.useMemo(()=>Re?uu(Re):null,[Re]),[Ca,Ea]=Z.useState(null);Z.useEffect(()=>{let e=!1,t=W?.path;if(!t||Sa){Ea(null);return}return Ea(null),_u(t).then(t=>{e||Ea(t)}),()=>{e=!0}},[W?.path,Sa]),Z.useEffect(()=>{!ca&&U===`edit`&&oe(`view`)},[ca,U]);let Da=`yuri:files:md-viewer-mode`,Oa=`yuri:files:html-viewer-mode`;Z.useEffect(()=>{let e=W?.path;if(!e)return;oe(he.current[e]??`edit`);let t=xr?`preview`:`edit`;try{let e=localStorage.getItem(Da);(e===`preview`||e===`edit`)&&(t=e)}catch{}ce(ge.current[e]??t);let n=xr?`preview`:`edit`;try{let e=localStorage.getItem(Oa);(e===`preview`||e===`edit`)&&(n=e)}catch{}vr&&Hr(e)&&gr===e&&(_e.current[e]=vr,yr(null)),ue(_e.current[e]??n),fe(ve.current[e]??(xr?`preview`:`edit`))},[gr,vr,W?.path,yr,xr]);let ka=Z.useCallback(e=>{let t=W?.path;t&&(he.current[t]=e),oe(e)},[W?.path]),Aa=Z.useCallback(e=>{let t=W?.path;t&&(ge.current[t]=e),ce(e);try{localStorage.setItem(Da,e)}catch{}},[W?.path]),Ma=Z.useCallback(()=>se,[se]),Na=Z.useCallback(e=>{let t=W?.path;t&&(_e.current[t]=e),ue(e);try{localStorage.setItem(Oa,e)}catch{}},[W?.path]),Pa=Z.useCallback(e=>{let t=W?.path;if(t&&(ve.current[t]=e),Kt.current&&=(clearTimeout(Kt.current),null),Yt.current!==null&&(cancelAnimationFrame(Yt.current),Yt.current=null),e===`edit`)zt(qt.current||lt),fe(e);else{qt.current=Rt;let e=t;fe(`edit`),Yt.current=requestAnimationFrame(()=>{Yt.current=requestAnimationFrame(()=>{Yt.current=null,!(b&&e&&Vo.getState().byRoot[Ce]?.selectedPath!==e)&&(me(e=>e+1),fe(`preview`))})});return}},[Rt,lt,b,W?.path,Ce]),Fa=Z.useCallback(async(e,t)=>{if(!i.writeFile||t===Jt.current)return!1;if(!(await i.writeFile(e,t))?.success)return Y.error(r(`filesView.toast.writeFileFailed`)),!1;qt.current=t,Jt.current=t,zt(t);let n=await li(e,Ve).catch(()=>null);return n&&($t.current=n),!0},[i,li,Ve,r]);Z.useEffect(()=>()=>{Kt.current&&=(clearTimeout(Kt.current),null),Yt.current!==null&&(cancelAnimationFrame(Yt.current),Yt.current=null)},[de,W?.path]);let Ia=Z.useCallback(e=>{if(qt.current=e,!W?.path||de!==`preview`||!i.writeFile)return;Kt.current&&clearTimeout(Kt.current);let t=W.path;Kt.current=setTimeout(()=>{Kt.current=null,Fa(t,e).then(e=>{e&&(on(!0),setTimeout(()=>on(!1),1500))}).catch(e=>{Y.error(e instanceof Error?e.message:r(`filesView.toast.saveFailed`))})},mi)},[de,i.writeFile,Fa,W?.path,r]),La=Z.useMemo(()=>da&&(qt.current||Rt)||lt,[Rt,lt,da]),Ra=Z.useCallback(()=>le,[le]);Z.useEffect(()=>{let e=e=>{let t=e?`preview`:`edit`;for(let e of we)he.current[e]=`edit`,up(e)&&(ge.current[e]=t),Hr(e)&&(_e.current[e]=t),Vr(e)&&(ve.current[e]=t);oe(`edit`),ce(t),ue(t),fe(t);try{localStorage.setItem(Da,t),localStorage.setItem(Oa,t)}catch{}},t=t=>{let n=!!t.detail?.enabled;e(n)};return window.addEventListener(`yuri:file-viewer-preview-mode-changed`,t),()=>{window.removeEventListener(`yuri:file-viewer-preview-mode-changed`,t)}},[we]),Z.useEffect(()=>{if(!fr||!b)return;let e=()=>{typeof window>`u`||xn.current===null&&(xn.current=window.requestAnimationFrame(()=>{xn.current=null,bn(e=>e+1)}))},t=(e,t)=>{if(e.state.doc.length!==t.length)return!1;if(t.length===0)return!0;let n=Math.min(128,t.length);if(e.state.sliceDoc(0,n)!==t.slice(0,n))return!1;let r=Math.max(0,t.length-n);return e.state.sliceDoc(r,t.length)===t.slice(r)},n=Wf(fr.path);if(It===n){hi(n),Sn.current={key:``,attempts:0};return}if(!n){hr(null),Sn.current={key:``,attempts:0};return}let r=`${n}:${fr.line}:${fr.column??1}`;if(Sn.current.key!==r&&(Sn.current={key:r,attempts:0}),W?.path!==n){if(ln||Ie)return;bi(Pe(n));return}if(ht||St!==n)return;if(_t||Yi||Zi){hr(null),Sn.current={key:``,attempts:0};return}if(!ca)return;if(U!==`edit`){oe(`edit`);return}let i=_n.current;if(!i){e();return}if(!t(i,Rt)){e();return}let a=Math.max(1,Math.min(fr.line,i.state.doc.lines)),o=i.state.doc.line(a),s=Math.max(1,fr.column||1),c=Math.max(0,o.to-o.from),l=Math.min(c,s-1),u=o.from+l;if(i.state.selection.main.head!==u||Sn.current.attempts===0){Sn.current.attempts+=1,i.dispatch({selection:{anchor:u},effects:Xt.scrollIntoView(u,{y:`center`})}),i.focus(),e();return}typeof window<`u`&&window.requestAnimationFrame(()=>{let e=_n.current;e&&(e.dispatch({selection:{anchor:u},effects:Xt.scrollIntoView(u,{y:`center`})}),e.focus())}),hr(null),Sn.current={key:``,attempts:0}},[Ie,ca,hi,ln,Rt,yn,_t,It,ht,Yi,Zi,St,bi,fr,b,W?.path,hr,U,Pe]),Z.useEffect(()=>{if(!gr||!b)return;let e=Wf(gr);if(It===e){hi(e);return}if(!e){_r(null);return}if(W?.path!==e){if(ln||Ie)return;bi(Pe(e));return}if(!(ht||St!==e||_t||Yi||Zi)){if(ca&&U===`edit`){let e=_n.current;if(!e)return;e.focus()}_r(null)}},[Ie,ca,hi,ln,_t,It,ht,bi,Yi,Zi,St,gr,b,W?.path,_r,U,Pe]);let za=Z.useCallback(e=>{if(!f||!e||!e.hasFocus||typeof window>`u`)return;let t=window.visualViewport;if(!t)return;let n=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,n-(t.offsetTop+t.height))<=0)return;let r=e.state.selection.main.head,i=e.coordsAtPos(r);if(!i)return;let a=Math.round(t.offsetTop+t.height),o=i.bottom+20-a;o<=0||(e.scrollDOM.scrollTop+=o)},[f]);Z.useEffect(()=>{if(!f||typeof window>`u`)return;let e=()=>{window.requestAnimationFrame(()=>{za(_n.current)})},t=window.visualViewport;return t?.addEventListener(`resize`,e),t?.addEventListener(`scroll`,e,{passive:!0}),document.addEventListener(`selectionchange`,e),()=>{t?.removeEventListener(`resize`,e),t?.removeEventListener(`scroll`,e),document.removeEventListener(`selectionchange`,e)}},[f,za]),Z.useEffect(()=>{if(U!==`edit`||f)return;let e=e=>{let t=e.target;if(t?.closest(`[role="dialog"]`))return;let n=!!t?.closest(`.cm-editor`);if(!(t?.closest(`input, textarea, [contenteditable="true"], [role="textbox"]`)&&!n||!document.activeElement?.closest(`.cm-editor`))&&Ta(e,`mod+l`)){let t=_n.current?.state.selection.main;t&&!t.empty&&(e.preventDefault(),ra())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ra,f,U]);let Ba=K(e=>e.editorFontSize),Va=Z.useMemo(()=>{if(!W?.path)return[lu(s,{fontSize:Ba})];let e=Lr(W.path),t=[lu(s,e?{syntaxColors:!1,fontSize:Ba}:{fontSize:Ba})],n=Sa??Ca;return n&&t.push(n),e&&t.push(xu({language:e,themeName:s.metadata.id,theme:Vi(s)})),P&&t.push(Xt.lineWrapping),t.push(Xt.updateListener.of(e=>{(e.selectionSet||e.docChanged)&&na(e.view)})),f&&t.push(Xt.updateListener.of(e=>{e.view.hasFocus&&(e.selectionSet||e.focusChanged||e.viewportChanged||e.geometryChanged)&&window.requestAnimationFrame(()=>{za(e.view)})})),t},[s,W?.path,Sa,Ca,P,f,za,Ba,na]),Ha=Z.useMemo(()=>({light:ye.metadata.id,dark:be.metadata.id}),[ye.metadata.id,be.metadata.id]),Ua=W?.path&&Yi&&!a.isDesktop&&!o&&!Xi?`${W.path}|${Ve.allowOutsideWorkspace?`outside`:`workspace`}|${Ve.outsideFileGrant??``}`:``,Wa=W?.path&&Zi&&!o?`${W.path}|${Ve.allowOutsideWorkspace?`outside`:`workspace`}|${Ve.outsideFileGrant??``}`:``,Ga=r(`filesView.error.readFileFailed`),{readyKey:Ka,nonce:qa}=mp(Ua,vt,Ga),{readyKey:Ja,nonce:Ya}=mp(Wa,vt,Ga),Xa=!!(Ua&&Ka!==Ua),[Za,Qa]=Z.useState(),$a=o&&W?.path&&Zi?JSON.stringify([o.queryScope,W.path]):``;Z.useEffect(()=>{if(!o||!$a||!W?.path)return;let e=new AbortController,t;return Dt({path:W.path,scope:o,signal:e.signal,...Ve,directory:b||void 0}).then(n=>{e.signal.aborted||(t=URL.createObjectURL(n),Qa({key:$a,url:t}))}).catch(t=>{e.signal.aborted||vt(t instanceof Error?t.message:Ga)}),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[o,$a,W?.path,Ve,b,Ga]);let eo=!!($a?Za?.key!==$a:Wa&&Ja!==Wa),to=W?.path&&Yi?a.isDesktop||o?Xi?`data:${zr(W.path)};utf8,${encodeURIComponent(lt)}`:yt:Xi?`data:${zr(W.path)};utf8,${encodeURIComponent(lt)}`:Ka===Ua?Ot(`/api/fs/raw`,{path:W.path,allowOutsideWorkspace:Ve.allowOutsideWorkspace?`true`:void 0,outsideFileGrant:Ve.outsideFileGrant,directory:b||void 0},o).url:``:``,no=G(e=>{if(!W?.path||!Yi)return;let t=Xi?to:W.path||to;if(!t)return;let n=W.name||W.path;te({open:!0,title:n,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:n,mime:zr(W.path)},image:{url:t,mimeType:zr(W.path),filename:n}})}),ro=Z.useCallback(e=>{te(t=>t.open===e?t:{...t,open:e})},[]),io=Z.useCallback((e,t)=>{let n=e.name||r(`filesView.editor.imageAltFallback`);return(0,$.jsx)(`div`,{className:J(`flex items-center justify-center`,t?.fullHeight?`h-full p-4`:`h-full p-3`),children:(0,$.jsx)(`button`,{type:`button`,className:`max-h-full max-w-full cursor-zoom-in rounded-md border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:no,"aria-label":n,disabled:!to,children:(0,$.jsx)(va,{src:to,alt:n,className:J(`object-contain rounded-md border border-border/30 bg-primary/10`,t?.fullHeight?`max-h-full max-w-full`:`max-h-[70vh] max-w-full`),draggable:!1},qa)})})},[qa,to,no,r]),ao=$a?Za?.key===$a?Za.url:``:W?.path&&Zi&&Ja===Wa?Ot(`/api/fs/raw`,{path:W.path,allowOutsideWorkspace:Ve.allowOutsideWorkspace?`true`:void 0,outsideFileGrant:Ve.outsideFileGrant,directory:b||void 0},o).url:``,oo=Z.useCallback(e=>(0,$.jsx)(`div`,{className:`h-full overflow-hidden bg-[var(--surface-background)]`,children:(0,$.jsx)(`iframe`,{src:ao,className:`h-full w-full border-0`,title:e.name},Ya)}),[ao,Ya]);Z.useEffect(()=>{let e=!1,t,n=async()=>{if(!a.isDesktop&&!o||!W?.path||!Yi||Xi){xt.current&&=(URL.revokeObjectURL(xt.current),``),bt(``);return}vt(null),xt.current&&=(URL.revokeObjectURL(xt.current),``),await(async()=>{if(o){let n=await At(W.path,i.signal,`preview`,o);return e?(n.release(),``):(t=n.release,n.url)}let n=await kt({path:W.path,...Ve,directory:b||void 0,signal:i.signal,scope:o});if(!n.ok)throw Error(r(`filesView.error.readFileFailed`));let a=await n.blob(),s=URL.createObjectURL(a);return e?(URL.revokeObjectURL(s),``):(xt.current=s,s)})().then(t=>{e||(bt(t),Ct(W.path))}).catch(t=>{xt.current&&=(URL.revokeObjectURL(xt.current),``),e||(bt(``),vt(t instanceof Error?t.message:r(`filesView.error.readFileFailed`)),Ct(null))}).finally(()=>{e||gt(!1)})},i=new AbortController;return n(),()=>{e=!0,i.abort(),t?.()}},[i,Yi,Xi,b,a.isDesktop,W?.path,Ve,r,o]),Z.useEffect(()=>()=>{xt.current&&=(URL.revokeObjectURL(xt.current),``)},[]);let so=Z.useCallback(()=>wn(null),[]),co=Z.useMemo(()=>Pi({drafts:wr,editingDraftId:Dr,commentText:Tr,onTextChange:Er,selection:ar,isDragging:lr,fileLabel:W?.path??``,newWidgetId:`files-new-comment-input`,mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Fr,onCancel:()=>{or(null),Ar()},onEdit:e=>{Mr(e),or({start:e.startLine,end:e.endLine})},onDelete:Nr,onAddToChat:ia}),[ia,Ar,Tr,Nr,Dr,wr,Fr,lr,ar,W?.path,Er,Mr]),lo=Z.useCallback((e,t)=>(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(Zt,{file:{name:e.name,contents:t,lang:Lr(e.path)||void 0},options:{disableFileHeader:!0,overflow:P?`wrap`:`scroll`,theme:Ha,themeType:s.metadata.variant===`dark`?`dark`:`light`},className:`block h-full w-full`,style:{height:`100%`}})}),[s.metadata.variant,Ha,P]),uo=({exitFullscreenOnly:t=!1,previewToggle:n}={})=>{if(!W)return null;let s=(e,t)=>(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:t})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:e})]});return(0,$.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm`,children:[ca&&xa&&(0,$.jsxs)($.Fragment,{children:[Bt?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-1 text-muted-foreground typography-meta`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}),r(`filesView.editor.saving`)]}):sn&&nn===`saved`&&!di?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta`,children:[(0,$.jsx)(X,{name:`check`,className:`size-3.5`}),r(`filesView.editor.saved`)]}):di?s(r(sn?`filesView.editor.saveNowTitle`:`filesView.editor.saveNowManualTitle`,{shortcut:`${mr()}+S`}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>void fi(),className:`h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,title:r(sn?`filesView.editor.saveNowTitle`:`filesView.editor.saveNowManualTitle`,{shortcut:`${mr()}+S`}),"aria-label":r(`filesView.editor.saveAria`,{shortcut:`${mr()}+S`}),children:(0,$.jsx)(X,{name:`save-3`,className:`size-4`})})):null,s(r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>cn(e=>!e),className:J(`size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,sn?`text-foreground opacity-100`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),"aria-label":r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),"aria-pressed":sn,children:(0,$.jsx)(X,{name:`file-check`,className:`size-4`})}))]}),fa&&Bn?s(`${r(`chat.textSelection.title.addToCurrentChat`)} (${wa(`mod+l`)})`,(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ra,className:`h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,title:`${r(`chat.textSelection.title.addToCurrentChat`)} (${wa(`mod+l`)})`,"aria-label":`${r(`chat.textSelection.title.addToCurrentChat`)} (${wa(`mod+l`)})`,children:[(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{children:r(`chat.textSelection.actions.addToChat`)}),(0,$.jsx)(Ri,{shortcut:wa(`mod+l`)})]})):null,!o&&a.isDesktop&&x()&&(0,$.jsxs)(wi,{onOpenChange:ae,children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.openInDesktopApp`),"aria-label":r(`filesView.editor.openInDesktopApp`),children:(0,$.jsx)(X,{name:`file-transfer`,className:`size-4`})})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(`filesView.editor.openInDesktopApp`)})]}),(0,$.jsxs)(xi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[Zn.map(e=>(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>void rr(e),children:[(0,$.jsx)(Hf,{label:e.label,iconDataUrl:e.iconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label})]},e.id)),Qn?(0,$.jsxs)(Si,{className:`flex items-center gap-2`,onClick:()=>void er(!0),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`filesView.editor.refreshApps`)})]}):null]})]}),fa&&(0,$.jsxs)($.Fragment,{children:[s(r(P?`filesView.editor.disableLineWrap`:`filesView.editor.enableLineWrap`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>F(!P),className:J(`size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,P?`text-foreground opacity-100`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(P?`filesView.editor.disableLineWrap`:`filesView.editor.enableLineWrap`),children:(0,$.jsx)(X,{name:`text-wrap`,className:`size-4`})})),U===`edit`&&(0,$.jsx)($.Fragment,{children:s(r(`filesView.editor.findInFile`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{z(!R),e.currentTarget.blur()},className:`size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.findInFile`),children:(0,$.jsx)(X,{name:`search`,className:`size-4`})}))})]}),n,!n&&pa&&ca&&!ua&&(0,$.jsx)(mu,{currentMode:U===`view`?`preview`:`edit`,onToggle:()=>{ka(U===`view`?`edit`:`view`)}}),la&&s(r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>Aa(Ma()===`preview`?`edit`:`preview`),className:J(`size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]`,Ma()===`preview`?`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),"aria-label":r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),children:(0,$.jsx)(X,{name:Ma()===`preview`?`eye`:`eye-off`,className:`size-4`})})),Hr(W?.path??``)&&(0,$.jsx)(mu,{currentMode:Ra(),onToggle:()=>{Na(Ra()===`preview`?`edit`:`preview`)}}),la&&Ma()===`preview`&&Sr&&(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,"aria-label":r(ft?`filesView.tts.stopSpeaking`:`filesView.tts.readAloud`),onClick:()=>{ft?mt():lt.trim()&&pt(lt)},children:ft?(0,$.jsx)(X,{name:`stop`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`volume-up`,className:`size-4`})})}),(0,$.jsx)(ti,{sideOffset:8,children:r(ft?`filesView.tts.stopSpeaking`:`filesView.tts.readAloud`)})]}),da&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mu,{currentMode:de,onToggle:()=>Pa(de===`preview`?`edit`:`preview`)}),de===`preview`&&(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{let e=Qt.current?.getXml();if(Kt.current&&=(clearTimeout(Kt.current),null),W?.path&&e){if(!await Fa(W.path,e))return;on(!0),setTimeout(()=>on(!1),1500)}},className:`size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.diagram.saveDiagram`),children:an?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`save-3`,className:`size-4`})})]}),aa&&s(r(`filesView.editor.copyFileContents`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{(await pr(lt)).ok?(Ln(!0),hn.current!==null&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>{Ln(!1)},1200)):Y.error(r(`filesView.toast.copyFailed`))},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.copyFileContents`),"aria-label":r(`filesView.editor.copyFileContents`),children:In?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`clipboard`,className:`size-4`})})),oa&&s(r(`filesView.editor.copyFilePathTitle`,{path:ta}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{(await pr(ta)).ok?(zn(!0),gn.current!==null&&window.clearTimeout(gn.current),gn.current=window.setTimeout(()=>{zn(!1)},1200)):Y.error(r(`filesView.toast.copyFailed`))},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.copyFilePathTitle`,{path:ta}),"aria-label":r(`filesView.editor.copyFilePathTitle`,{path:ta}),children:Rn?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`file-copy-2`,className:`size-4`})})),i.downloadFile&&s(r(`filesView.editor.saveFile`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{let e=i.downloadFile;e&&e(W.path).catch(e=>{console.error(`Download failed:`,e),Y.error(r(`sidebarFilesTree.toast.operationFailed`))})},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.saveFile`),"aria-label":r(`filesView.editor.saveFile`),children:(0,$.jsx)(X,{name:`download`,className:`size-4`})})),t?s(r(`filesView.editor.exitFullscreen`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>L(!1),className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.exitFullscreen`),"aria-label":r(`filesView.editor.exitFullscreen`),children:(0,$.jsx)(X,{name:`fullscreen-exit`,className:`size-4`})})):!f&&e===`full`&&s(r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>L(!I),className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),"aria-label":r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),children:I?(0,$.jsx)(X,{name:`fullscreen-exit`,className:`size-4`}):(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})}))]})},fo=(0,$.jsx)(ma,{path:W?.path??``,base:b||void 0,active:!!(W&&t&&(!f||M)),children:({preview:e,controls:t})=>(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,children:[(0,$.jsx)($r,{open:ln,onOpenChange:e=>{e||Di()},children:(0,$.jsxs)(Xr,{showCloseButton:!1,className:`max-w-md`,children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Zr,{children:r(`filesView.unsaved.title`)}),(0,$.jsx)(Qr,{children:r(`filesView.unsaved.description`)})]}),(0,$.jsxs)(Yr,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:Di,disabled:Bt,children:r(`filesView.dialog.cancel`)}),(0,$.jsx)(q,{variant:`outline`,onClick:()=>void Ei(),disabled:Bt,className:`border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]`,children:r(`filesView.unsaved.saveChanges`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:Ti,disabled:Bt,children:r(`filesView.unsaved.discard`)})]})]})}),(0,$.jsx)(`div`,{className:J(`flex flex-col flex-shrink-0`,C&&`border-b border-border/40`),children:C?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center px-3 py-1.5`,children:[f&&M&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>N(!1),"aria-label":r(`filesView.editor.back`),className:`inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`size-5`})}),f?W?(0,$.jsxs)(wi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium`,"aria-label":r(`filesView.editor.openFilesAria`),children:[(0,$.jsx)(ii,{filePath:W.path,extension:W.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(Qf,{name:W.name}),(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 flex-shrink-0 text-muted-foreground`})]})}),(0,$.jsx)(xi,{align:`start`,className:`w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]`,children:Fe.map(e=>{let t=W?.path===e.path;return(0,$.jsxs)(Si,{onSelect:n=>{if(n.target.closest(`[data-close-open-file]`)){n.preventDefault();return}t||bi(e)},className:J(`flex min-w-0 items-center justify-between gap-2 overflow-hidden`,t&&`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:[(0,$.jsx)(ii,{filePath:e.path,extension:e.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(Qf,{name:e.name})]}),(0,$.jsx)(`button`,{type:`button`,"data-close-open-file":!0,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>{t.preventDefault(),t.stopPropagation(),ki(e.path)},className:`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]`,"aria-label":r(`filesView.editor.closeFileAria`,{name:e.name}),children:(0,$.jsx)(X,{name:`close`,className:`size-3.5`})})]},e.path)})})]}):(0,$.jsx)(`div`,{className:`typography-ui-label font-medium truncate`,children:r(`filesView.editor.selectFile`)}):Fe.length>0?(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[Ue.left&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent`}),Ue.right&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent`}),(0,$.jsx)(`div`,{ref:He,className:`flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:Fe.map(e=>{let t=W?.path===e.path;return(0,$.jsxs)(`div`,{title:Yf(b,e.path),className:J(`group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap`,t?`bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]`:`bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]`),children:[(0,$.jsx)(ii,{filePath:e.path,extension:e.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{t||bi(e)},className:`max-w-[12rem] truncate text-left`,children:e.name}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),ki(e.path)},className:J(`rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]`,!t&&!h&&`opacity-0 group-hover:opacity-100`),"aria-label":r(`filesView.editor.closeFileAria`,{name:e.name}),children:(0,$.jsx)(X,{name:`close`,className:`size-3.5`})})]},e.path)})})]}):(0,$.jsx)(`div`,{className:`typography-ui-label font-medium truncate`,children:r(`filesView.editor.selectFile`)})]}):null}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[e?(0,$.jsx)(`div`,{className:`absolute right-6 top-3 z-30 flex items-center gap-1`,"data-gui-preview-controls":!0,children:t}):null,W&&!e&&!R&&(0,$.jsx)(`div`,{ref:re,className:`absolute right-3 top-3 z-30`,onMouseLeave:()=>{ie.current>0||B(!1)},children:ee?uo({previewToggle:t}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,la?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>Aa(Ma()===`preview`?`edit`:`preview`),className:J(`size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors`,Ma()===`preview`?`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]`:`text-muted-foreground hover:text-foreground`),"aria-label":r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),title:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),children:(0,$.jsx)(X,{name:Ma()===`preview`?`eye`:`eye-off`,className:`size-4`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`)})]}):null,(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,onMouseEnter:()=>B(!0),children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>B(!0),className:`size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground`,"aria-label":r(`filesView.editor.showControlsAria`),title:r(`filesView.editor.controlsTitle`),children:(0,$.jsx)(X,{name:`more-2-fill`,className:`size-4`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(`filesView.editor.controlsTitle`)})]})]})}),e??(0,$.jsx)(Gr,{outerClassName:`h-full min-w-0`,className:`h-full min-w-0`,children:W?wt||Xa||eo?Yi?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-3`,children:(0,$.jsx)(_a,{className:`size-48 max-w-full rounded-md`})}):w?(0,$.jsx)(`div`,{className:`p-3`}):(0,$.jsxs)(`div`,{className:`p-3 flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.loading`)]}):_t?(0,$.jsx)(sa,{message:_t,onRetry:It===Re?Oi:void 0}):Ft?(0,$.jsx)(ga,{path:Re},Re):Yi&&W?io(W):Zi?oo(W):W&&da&&de===`preview`?(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,style:{minHeight:`400px`},children:(0,$.jsx)(Ql,{ref:Qt,xml:La,onChange:Ia},`${W.path}:${pe}`)}):W&&la&&Ma()===`preview`?(0,$.jsxs)(`div`,{className:`h-full overflow-auto p-3`,children:[lt.length>512e3&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning`,children:r(`filesView.warning.largeFilePreviewLimited`,{sizeKb:Math.round(lt.length/1024)})}),(0,$.jsx)(Po,{fallback:(0,$.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium text-destructive`,children:r(`filesView.error.previewUnavailable`)}),(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`filesView.error.switchToEditMode`)})]}),children:(0,$.jsx)(ba,{content:lt,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})]}):W&&ua&&le===`preview`?(0,$.jsx)(ha,{path:W.path,directory:o?.location.directory??b??``,entry:o,revision:Tt}):W&&pa&&U===`view`?lo(W,Rt):(0,$.jsxs)(`div`,{className:J(`relative h-full`,ea&&`overflow-hidden`),ref:vn,children:[(0,$.jsx)(`div`,{className:J(`h-full`,ea&&`invisible`),children:(0,$.jsx)(hu,{value:Rt,onChange:zt,readOnly:!ca,vimMode:br===`vim`,extensions:Va,className:`h-full`,blockWidgets:co,onViewReady:e=>{_n.current=e,na(e),bn(e=>e+1),window.requestAnimationFrame(()=>{za(e)})},onViewDestroy:()=>{_n.current&&=null,Vn(!1),Un(null),bn(e=>e+1)},enableSearch:!0,searchOpen:R,onSearchOpenChange:z,highlightLines:ar?{start:Math.min(ar.start,ar.end),end:Math.max(ar.start,ar.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,t,n)=>{if(!(n instanceof MouseEvent)||n.button!==0)return!1;n.preventDefault();let r=e.state.doc.lineAt(t.from).number;if(ar&&!n.shiftKey&&Math.min(ar.start,ar.end)===r&&Math.max(ar.start,ar.end)===r)return or(null),Ar(),sr.current=!1,cr.current=null,ur(!1),!0;if(f&&ar&&!n.shiftKey){let e=Math.min(ar.start,ar.end,r),t=Math.max(ar.start,ar.end,r);return or({start:e,end:t}),sr.current=!1,cr.current=null,ur(!1),!0}if(sr.current=!0,cr.current=r,ur(!0),ar&&n.shiftKey){let e=Math.min(ar.start,r),t=Math.max(ar.end,r);or({start:e,end:t})}else or({start:r,end:r});return!0},mouseover:(e,t,n)=>{if(!(n instanceof MouseEvent)||n.buttons!==1||!sr.current||cr.current===null)return!1;let r=e.state.doc.lineAt(t.from).number,i=Math.min(cr.current,r),a=Math.max(cr.current,r);return or({start:i,end:a}),ur(!0),!1},mouseup:()=>(sr.current=!1,cr.current=null,ur(!1),!1)}}})}),ea&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-background`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.openingFileAtChange`)]})})]}):(0,$.jsx)(`div`,{className:`p-3 typography-ui text-muted-foreground`,children:r(`filesView.editor.pickFileFromTree`)})})]})]})}),po=!!(b&&qe[b]),mo=b?Ye[b]:null,ho=(0,$.jsxs)(`section`,{className:J(`flex min-h-0 flex-col overflow-hidden`,f?`h-full w-full bg-background`:`h-full rounded-xl border border-border/60 bg-background/70`),children:[(0,$.jsx)(`div`,{className:J(`flex flex-col gap-2 py-2`,f?`px-3`:`px-2`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground`}),(0,$.jsx)(ya,{ref:j,value:D,onChange:e=>k(e.target.value),placeholder:r(`filesView.tree.search.placeholder`),className:`h-8 pl-8 pr-8 typography-meta`}),D.trim().length>0&&(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`filesView.tree.search.clearAria`),className:`absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground`,onClick:()=>{k(``),j.current?.focus()},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ir(`createFile`,{path:y,type:`directory`}),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.newFileTitle`),"aria-label":r(`filesView.tree.actions.newFileTitle`),children:(0,$.jsx)(X,{name:`file-add`,className:`size-4`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.newFileTitle`)})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ir(`createFolder`,{path:y,type:`directory`}),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.newFolderTitle`),"aria-label":r(`filesView.tree.actions.newFolderTitle`),children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.newFolderTitle`)})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>void Kr(),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.refreshTitle`),"aria-label":r(`filesView.tree.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:`size-4`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.refreshTitle`)})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:Wi,disabled:Fi.length===0&&Ee.length===0,className:`size-8 flex-shrink-0 p-0`,title:r(Bi?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`),"aria-label":r(Bi?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`),children:(0,$.jsx)(X,{name:Bi?`contract-up-down`:`expand-up-down`,className:`size-4`})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:r(Bi?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`)})]})]})}),(0,$.jsx)(Gr,{outerClassName:`flex-1 min-h-0`,className:J(`py-2`,f?`px-3`:`px-2`),children:(0,$.jsx)(`ul`,{className:`flex flex-col`,children:st?(0,$.jsxs)(`li`,{className:`flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.tree.search.searching`)]}):at.length>0?at.map(e=>{let t=W?.path===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void bi(e),className:J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors`,t?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`),children:[lp(e.path,e.extension),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-meta`,style:{direction:`rtl`,textAlign:`left`},title:e.path,children:e.relativePath??e.path})]})},e.path)}):mo?(0,$.jsxs)(`li`,{className:`flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:mo}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`w-fit gap-1.5`,onClick:()=>void Kr(),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`}),r(`filesView.tree.actions.refreshTitle`)]})]}):po?Ji(b,0):(0,$.jsx)(`li`,{className:`px-2 py-1 typography-meta text-muted-foreground`,children:r(`filesView.state.loading`)})})})]}),go=e===`full`&&I&&W&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex flex-col bg-background`,children:(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 relative`,children:[(0,$.jsx)(`div`,{className:`absolute right-4 top-4 z-30`,children:uo({exitFullscreenOnly:!0})}),(0,$.jsx)(Gr,{outerClassName:`h-full min-w-0`,className:`h-full min-w-0`,children:wt||Xa||eo?Yi?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,$.jsx)(_a,{className:`size-48 max-w-full rounded-md`})}):w?(0,$.jsx)(`div`,{className:`p-4`}):(0,$.jsxs)(`div`,{className:`p-4 flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),`Loading…`]}):_t?(0,$.jsx)(sa,{message:_t,onRetry:It===Re?Oi:void 0}):Ft?(0,$.jsx)(ga,{path:Re},Re):Yi?io(W,{fullHeight:!0}):Zi?oo(W):la&&Ma()===`preview`?(0,$.jsxs)(`div`,{className:`h-full overflow-auto p-4`,children:[lt.length>512e3&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning`,children:r(`filesView.warning.largeFilePreviewLimited`,{sizeKb:Math.round(lt.length/1024)})}),(0,$.jsx)(Po,{fallback:(0,$.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium text-destructive`,children:r(`filesView.error.previewUnavailable`)}),(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`filesView.error.switchToEditMode`)})]}),children:(0,$.jsx)(ba,{content:lt,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})]}):pa&&U===`view`?lo(W,Rt):(0,$.jsxs)(`div`,{className:J(`relative h-full`,ea&&`overflow-hidden`),children:[(0,$.jsx)(`div`,{className:J(`h-full`,ea&&`invisible`),children:(0,$.jsx)(hu,{value:Rt,onChange:zt,readOnly:!ca,vimMode:br===`vim`,extensions:Va,className:`h-full`,onViewReady:e=>{_n.current=e,na(e),window.requestAnimationFrame(()=>{za(e)})},onViewDestroy:()=>{_n.current&&=null,Vn(!1),Un(null)}})}),ea&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-background`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.openingFileAtChange`)]})})]})})]})});return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden bg-background relative`,children:[(0,$.jsx)(fp,{activeDialog:Cn,dialogData:Tn,dialogInputValue:Dn,onDialogInputChange:On,isDialogSubmitting:kn,onDialogSubmit:si,onClose:so,inputRef:Wt}),go,Hn?(0,$.jsx)(Li,{position:Hn,onDismiss:()=>Un(null),onAddToChat:ra}):null,V.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Bf,{popup:V,onOpenChange:ro,isMobile:f})}):null,f?M?fo:ho:e===`editor-only`?(0,$.jsx)(`div`,{className:`flex flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden bg-background`,children:fo})}):(0,$.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2`,children:[m>=700&&(0,$.jsx)(`div`,{className:`w-72 flex-shrink-0 min-h-0 overflow-hidden`,children:ho}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background`,children:fo})]})]})};function _p(e){return e+1}var vp={system:`contextSidebar.window.part.system`,files:`contextSidebar.window.part.files`,results:`contextSidebar.window.part.results`,chat:`contextSidebar.window.part.chat`},yp={system:`contextSidebar.window.role.system`,user:`contextSidebar.window.role.user`,assistant:`contextSidebar.window.role.assistant`,thinking:`contextSidebar.window.role.thinking`,call:`contextSidebar.window.role.call`,result:`contextSidebar.window.role.result`},bp=(e,t)=>e(vp[t]),xp=e=>{let t=e.lastIndexOf(`/`);return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t+1)}},Sp=(e,t)=>t.kind===`baseline`?bp(e,`system`):t.kind===`turn`?e(`contextSidebar.window.turn`,{n:t.name}):t.name,Cp=e=>e.kind===`file`?`read`:e.kind===`tool`?`result`:``,wp=[`system`,`files`,`results`,`chat`],Tp=11904,Ep=e=>{let t=0;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)>=Tp&&(t+=1);return t+(e.length-t)/4},Dp=e=>{if(typeof e==`string`)return e.length;if(e==null)return 0;try{return JSON.stringify(e)?.length??0}catch{return 0}},Op=e=>{if(!e||typeof e!=`object`)return``;let t=e;for(let e of[`filePath`,`path`,`file_path`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}return``},kp=(e,t,n,r)=>{let i=e.get(t.id);if(i){i.count+=1,i.tokens+=n,i.pieces.push(...r);return}e.set(t.id,{...t,count:1,tokens:n,pieces:[...r]})},Ap=(e,t)=>t.tokens-e.tokens,jp=(e,t)=>{let{used:n,firstRequestInput:r,systemPrompt:i}=t;if(n<=0)return[];let a=new Map,o=new Map,s=[],c=null,l=0,u=!1;for(let t of e){let e=Yo(t.info).isUser;(e||!c)&&(c={id:`turn:${s.length+1}`,kind:`turn`,name:String(s.length+1),count:1,tokens:0,pieces:[]},s.push(c));let n=e&&!u;for(let r of t.parts){let t=r;if(t.type===`text`||t.type===`reasoning`){if(t.ignored===!0||typeof t.text!=`string`)continue;let r=Ep(t.text);c.tokens+=r,n&&(l+=r),t.text.length>0&&c.pieces.push({role:t.type===`reasoning`?`thinking`:e?`user`:`assistant`,value:t.text});continue}if(t.type!==`tool`)continue;let i=t.state;if(!i)continue;let s=typeof t.tool==`string`&&t.tool.length>0?t.tool:`tool`;if(c.tokens+=Dp(i.input)/4,c.pieces.push({role:`call`,name:s,value:i.input}),i.time?.compacted)continue;let u=(Dp(i.output)+Dp(i.error))/4;if(u<=0)continue;let d={role:`result`,name:s,value:i.output??i.error},f=s===`read`?Op(i.input):``;f?kp(a,{id:`file:${f}`,kind:`file`,name:f},u,[{...d,name:f}]):kp(o,{id:`tool:${s}`,kind:`tool`,name:s},u,[{role:`call`,name:s,value:i.input},d])}e&&(u=!0)}let d=[...s,...a.values(),...o.values()].reduce((e,t)=>e+t.tokens,0),f=Math.max(0,r-l),p,m;if(d<=0)p=n,m=0;else if(f<n)p=f,m=(n-f)/d;else{let e=n/(f+d);p=f*e,m=e}let h=e=>[...e].map(e=>({...e,tokens:e.tokens*m})).filter(e=>e.tokens>.5).sort(Ap),g={system:p>.5?[{id:`baseline`,kind:`baseline`,name:``,count:1,tokens:p,pieces:i?[{role:`system`,value:i}]:[]}]:[],files:h(a.values()),results:h(o.values()),chat:h(s)};return wp.filter(e=>g[e].length>0).map(e=>({kind:e,items:g[e],tokens:g[e].reduce((e,t)=>e+t.tokens,0)}))},Mp=e=>{if(e.length===0)return 0;let t=[...e].sort((e,t)=>e-t);return t[t.length>>1]},Np=(e,t)=>{let n=[];for(let t=1;t<e.length;t+=1){let r=e[t]-e[t-1];r>0&&e[t]>=e[t-1]*.6&&n.push(r)}let r=Mp(n);return r>0?Math.floor(t/r):null},Pp=e=>e<.75?`ok`:e<.9?`warn`:`bad`,Fp=e=>{let t=Math.max(0,Math.round(e||0)),n=(e,t)=>e.toFixed(t).replace(/\.0+$/,``);return t>=1e6?`${n(t/1e6,t>=1e7?1:2)}M`:t>=1e3?`${n(t/1e3,t>=1e5?0:1)}K`:String(t)},Ip=(e,t)=>{let n=[],r=e.filter(e=>e.v>0),i=r.reduce((e,t)=>e+t.v,0),{x:a,y:o,w:s,h:c}=t;if(!i||s<=0||c<=0)return n;let l=s*c/i,u=(e,t)=>{let n=0,r=0,i=1/0;for(let t of e){let e=t.v*l;n+=e,r=Math.max(r,e),i=Math.min(i,e)}return Math.max(t*t*r/(n*n),n*n/(t*t*i))},d=e=>{let t=e.reduce((e,t)=>e+t.v*l,0);if(s>=c){let r=t/c,i=o;for(let t of e){let e=t.v*l/r;n.push({a:t,x:a,y:i,w:r,h:e}),i+=e}a+=r,s-=r}else{let r=t/s,i=a;for(let t of e){let e=t.v*l/r;n.push({a:t,x:i,y:o,w:e,h:r}),i+=e}o+=r,c-=r}},f=[];for(let e of r){let t=Math.min(s,c);if(!f.length||u([...f,e],t)<=u(f,t)){f.push(e);continue}d(f),f=[e]}return f.length&&d(f),n},Lp=1500,Rp=12,zp=700,Bp=16,Vp=14,Hp=(e,t)=>{let n=e.reduce((e,t)=>e+t.v,0)*zp/Math.max(1,t);return e.map(e=>({...e,v:Math.max(e.v,n)}))},Up=(e,t,n)=>{let r=Math.min(400,Math.round(t/Math.max(n??0,t,1)*400)),i=e.reduce((e,t)=>e+t.tokens,0)||1,a=e.map(e=>e.tokens/i*r),o=a.map(e=>Math.max(1,Math.floor(e))),s=r-o.reduce((e,t)=>e+t,0),c=a.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]);for(let e=0;s>0&&c.length;e=(e+1)%c.length,--s)o[c[e][1]]+=1;for(let e=o.length-1;s<0&&e>=0;--e)for(;s<0&&o[e]>1;)--o[e],s+=1;let l=[];for(e.forEach((e,t)=>{let n=e.items.reduce((e,t)=>e+t.tokens,0)||1,r=0,i=0;for(let a=0;a<o[t];a+=1){let s=(a+.5)/o[t]*n;for(;r<e.items.length-1&&i+e.items[r].tokens<s;)i+=e.items[r].tokens,r+=1;l.push({kind:e.kind,item:e.items.length?r:-1})}});l.length<400;)l.push(null);return l.slice(0,400)},Wp=(e,t,n,r,i)=>{let a=[];if(t<=0||r<=0||i<=0)return a;let o=Math.max(n??0,t,1),s=r>=i,c=s?r:i,l=c;t<o&&(l=Math.min(c,Math.max(c*(t/o)**.35,Math.min(c,36))));let u=s?{x:0,y:0,w:l,h:i}:{x:0,y:0,w:r,h:l},d=Hp(e.map(e=>({v:e.tokens,ref:e})),u.w*u.h),f=Ip(d,u);for(let e=0;e<8;e+=1){let e=f.filter(e=>Math.min(e.w,e.h)<Bp);if(!e.length)break;for(let t of e)t.a.v*=Bp/Math.max(1,Math.min(t.w,t.h))*1.05;f=Ip(d,u)}for(let e of f){let t=e.a.ref,n={key:t.kind,kind:t.kind,item:null,items:t.items,tokens:t.tokens,x:e.x,y:e.y,w:e.w,h:e.h},r=e.w*e.h;if(!t.items.length||r<Lp*2){a.push(n);continue}let i=[],o=[];for(let e of t.items)i.length<Rp&&e.tokens/t.tokens*r>=Lp?i.push(e):o.push(e);let s=i.map(e=>({v:e.tokens,ref:{item:e}}));o.length===1&&!i.length?s.push({v:o[0].tokens,ref:{item:o[0]}}):o.length&&s.push({v:o.reduce((e,t)=>e+t.tokens,0),ref:{rest:o}});let c=Ip(Hp(s,r),e);if(c.some(e=>Math.min(e.w,e.h)<Vp)){a.push(n);continue}for(let e of c){let{item:n,rest:r}=e.a.ref,i=n?[n]:r??[];a.push({key:`${t.kind}:${n?n.id:`rest`}`,kind:t.kind,item:n??null,items:i,tokens:i.reduce((e,t)=>e+t.tokens,0),x:e.x,y:e.y,w:e.w,h:e.h})}}if(t<o){let e=s?{x:l,y:0,w:r-l,h:i}:{x:0,y:l,w:r,h:i-l};a.push({key:`free`,kind:`free`,item:null,items:[],tokens:o-t,...e})}return a},Gp=2e4,Kp=100,qp=e=>{if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}},Jp=e=>{let t=(0,Q.c)(13),{item:n}=e,{t:r}=Pr(),i,a,o;if(t[0]!==n||t[1]!==r){o=Symbol.for(`react.early_return_sentinel`);bb0:{if(i=Sp(r,n),n.kind!==`file`||!i.includes(`/`)){o=(0,$.jsx)(`span`,{className:`yuri-ctx-name`,title:i,children:(0,$.jsx)(`b`,{children:i})});break bb0}a=xp(i)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o}else i=t[2],a=t[3],o=t[4];if(o!==Symbol.for(`react.early_return_sentinel`))return o;let{base:s,dir:c}=a,l;t[5]===s?l=t[6]:(l=(0,$.jsx)(`b`,{children:s}),t[5]=s,t[6]=l);let u;t[7]===c?u=t[8]:(u=(0,$.jsx)(`small`,{children:c}),t[7]=c,t[8]=u);let d;return t[9]!==i||t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`span`,{className:`yuri-ctx-name`,title:i,children:[l,u]}),t[9]=i,t[10]=l,t[11]=u,t[12]=d):d=t[12],d},Yp=e=>{let t=(0,Q.c)(11),{text:n}=e,{t:r}=Pr(),[i,a]=Z.useState(Gp),o=n.length-i,s;t[0]!==i||t[1]!==n?(s=n.slice(0,i),t[0]=i,t[1]=n,t[2]=s):s=t[2];let c;t[3]===s?c=t[4]:(c=(0,$.jsx)(`pre`,{className:`yuri-ctx-text`,children:s}),t[3]=s,t[4]=c);let l;t[5]!==o||t[6]!==r?(l=o>0?(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-more`,onClick:()=>a($p),children:r(`contextSidebar.window.text.showMore`,{count:o.toLocaleString()})}):null,t[5]=o,t[6]=r,t[7]=l):l=t[7];let u;return t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`div`,{className:`yuri-ctx-text-box`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Xp=e=>{let t=(0,Q.c)(26),{piece:n}=e,{t:r}=Pr(),[i,a]=Z.useState(!1),o;t[0]===n.value?o=t[1]:(o=qp(n.value),t[0]=n.value,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=async()=>{(await pr(s)).ok&&(a(!0),window.setTimeout(()=>a(!1),2e3))},t[2]=s,t[3]=c);let l=G(c),u=yp[n.role],d;t[4]!==r||t[5]!==u?(d=r(u),t[4]=r,t[5]=u,t[6]=d):d=t[6];let f;t[7]===d?f=t[8]:(f=(0,$.jsx)(`span`,{className:`yuri-ctx-role`,children:d}),t[7]=d,t[8]=f);let p;t[9]===n.name?p=t[10]:(p=n.name?(0,$.jsx)(`code`,{className:`yuri-ctx-piece-name`,children:n.name}):null,t[9]=n.name,t[10]=p);let m;t[11]!==i||t[12]!==l||t[13]!==r||t[14]!==s?(m=s?(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-copy`,onClick:l,"aria-label":r(i?`contextSidebar.actions.copied`:`contextSidebar.actions.copy`),title:r(i?`contextSidebar.actions.copied`:`contextSidebar.actions.copy`),children:(0,$.jsx)(X,{name:i?`check`:`file-copy`,className:`size-3.5`})}):null,t[11]=i,t[12]=l,t[13]=r,t[14]=s,t[15]=m):m=t[15];let h;t[16]!==f||t[17]!==p||t[18]!==m?(h=(0,$.jsxs)(`div`,{className:`yuri-ctx-piece-head`,children:[f,p,m]}),t[16]=f,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==r||t[21]!==s?(g=s?(0,$.jsx)(Yp,{text:s}):(0,$.jsx)(`div`,{className:`yuri-ctx-piece-note`,children:r(`contextSidebar.window.text.empty`)}),t[20]=r,t[21]=s,t[22]=g):g=t[22];let _;return t[23]!==h||t[24]!==g?(_=(0,$.jsxs)(`div`,{className:`yuri-ctx-piece`,children:[h,g]}),t[23]=h,t[24]=g,t[25]=_):_=t[25],_},Zp=e=>{let t=(0,Q.c)(32),{item:n,kind:r,defaultOpen:i}=e,{t:a}=Pr(),[o,s]=Z.useState(i),c;t[0]===n?c=t[1]:(c=Cp(n),t[0]=n,t[1]=c);let l=c,u=o&&`is-open`,d;t[2]===u?d=t[3]:(d=J(`yuri-ctx-vi`,u),t[2]=u,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>s(em),t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`span`,{className:`yuri-ctx-vi-tw`,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-3`})}),t[5]=p):p=t[5];let m;t[6]===n?m=t[7]:(m=(0,$.jsx)(Jp,{item:n}),t[6]=n,t[7]=m);let h;t[8]!==n.count||t[9]!==n.kind?(h=n.count>1&&n.kind!==`turn`?(0,$.jsxs)(`span`,{className:`yuri-ctx-x`,children:[`×`,n.count]}):null,t[8]=n.count,t[9]=n.kind,t[10]=h):h=t[10];let g;t[11]===l?g=t[12]:(g=l?(0,$.jsx)(`code`,{className:`yuri-ctx-tag`,children:l}):null,t[11]=l,t[12]=g);let _;t[13]===n.tokens?_=t[14]:(_=Fp(n.tokens),t[13]=n.tokens,t[14]=_);let v;t[15]===_?v=t[16]:(v=(0,$.jsx)(`span`,{className:`yuri-ctx-v`,children:_}),t[15]=_,t[16]=v);let y;t[17]!==o||t[18]!==v||t[19]!==m||t[20]!==h||t[21]!==g?(y=(0,$.jsxs)(`button`,{type:`button`,className:`yuri-ctx-vi-head`,"aria-expanded":o,onClick:f,children:[p,m,h,g,v]}),t[17]=o,t[18]=v,t[19]=m,t[20]=h,t[21]=g,t[22]=y):y=t[22];let b;t[23]!==n.pieces||t[24]!==r||t[25]!==o||t[26]!==a?(b=o?(0,$.jsx)(`div`,{className:`yuri-ctx-vi-text`,children:n.pieces.length>0?n.pieces.map(tm):(0,$.jsx)(`div`,{className:`yuri-ctx-piece-note`,children:a(r===`system`?`contextSidebar.window.text.baselineUnavailable`:`contextSidebar.window.text.empty`)})}):null,t[23]=n.pieces,t[24]=r,t[25]=o,t[26]=a,t[27]=b):b=t[27];let x;return t[28]!==y||t[29]!==b||t[30]!==d?(x=(0,$.jsxs)(`div`,{className:d,children:[y,b]}),t[28]=y,t[29]=b,t[30]=d,t[31]=x):x=t[31],x},Qp=e=>{let t=(0,Q.c)(10),{target:n,parts:r,onClose:i}=e,{t:a}=Pr(),[o,s]=Z.useState(null),[c,l]=Z.useState(Kp),u=n?r.find(e=>e.kind===n.kind)??null:null,d=n?`${n.kind}:${n.itemId??``}`:null,f=u&&n?.itemId&&o!==d?u.items.find(e=>e.id===n.itemId)??null:null,p=u?.items??[],m=u?f?`${bp(a,u.kind)} · ${Sp(a,f)}`:bp(a,u.kind):``,h=f?f.tokens:p.reduce(nm,0),g;t[0]===i?g=t[1]:(g=e=>{e||(s(null),l(Kp),i())},t[0]=i,t[1]=g);let _=G(g),v;t[2]===d?v=t[3]:(v=()=>s(d),t[2]=d,t[3]=v);let y=G(v),b=Fp(h),x;t[4]===a?x=t[5]:(x=a(`contextSidebar.window.tokens`),t[4]=a,t[5]=x);let S;t[6]===a?S=t[7]:(S=a(`contextSidebar.window.text.note`),t[6]=a,t[7]=S);let C;return t[8]===S?C=t[9]:(C=(0,$.jsx)(Qr,{className:`yuri-ctx-dialog-note`,children:S}),t[8]=S,t[9]=C),(0,$.jsx)($r,{open:n!==null,onOpenChange:_,children:(0,$.jsxs)(Xr,{className:`yuri-ctx-dialog max-w-[880px] w-[min(880px,calc(100vw-2rem))]`,children:[(0,$.jsxs)(`div`,{className:`yuri-ctx-dialog-head`,children:[u?(0,$.jsx)(`span`,{className:J(`yuri-ctx-dot`,`yuri-ctx-k-${u.kind}`)}):null,(0,$.jsx)(Zr,{className:`leading-snug`,children:m}),(0,$.jsxs)(`span`,{className:`yuri-ctx-dialog-total`,children:[b,` `,x]})]}),(0,$.jsxs)(`div`,{className:`yuri-ctx-dialog-body`,children:[C,u?f?(0,$.jsx)(Zp,{item:f,kind:u.kind,defaultOpen:!0},f.id):p.slice(0,c).map(e=>(0,$.jsx)(Zp,{item:e,kind:u.kind,defaultOpen:p.length===1},e.id)):null,u&&!f&&p.length>c?(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-more`,onClick:()=>l(rm),children:a(`contextSidebar.window.text.showMoreItems`,{count:p.length-c})}):null]}),f&&p.length>1?(0,$.jsx)(`div`,{className:`yuri-ctx-dialog-foot`,children:(0,$.jsx)(q,{size:`sm`,onClick:y,children:a(`contextSidebar.window.text.allOf`,{part:bp(a,u.kind),count:p.length})})}):null]})})};function $p(e){return e+Gp}function em(e){return!e}function tm(e,t){return(0,$.jsx)(Xp,{piece:e},t)}function nm(e,t){return e+t.tokens}function rm(e){return e+Kp}var im=132,am=232,om=3.1,sm=1.5,cm=520,lm=8,um=`yuri.contextWindowLook`,dm=(e,t,n,r,i)=>`M${e+i} ${t}h${n-2*i}a${i} ${i} 0 0 1 ${i} ${i}v${r-2*i}a${i} ${i} 0 0 1 ${-i} ${i}h${-(n-2*i)}a${i} ${i} 0 0 1 ${-i} ${-i}v${-(r-2*i)}a${i} ${i} 0 0 1 ${i} ${-i}z`,fm=(0,$.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:(0,$.jsx)(`path`,{d:`${dm(1.5,2,5.5,12,1.6)}${dm(8.5,2,6,6.5,1.6)}${dm(8.5,10,6,4,1.4)}`})}),pm=(0,$.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,"aria-hidden":`true`,children:(0,$.jsx)(`path`,{d:[2,6.5,11].flatMap(e=>[2,6.5,11].map(t=>dm(t,e,3,3,.8))).join(``)})}),mm=(e,t)=>Math.round(e/Math.max(1,t)*100),hm=(e,t,n)=>e?.type===`item`&&e.kind===t&&n.some(t=>t.id===e.id),gm=(e,t)=>e?e.type===`part`?t.kind!==e.kind:e.type===`tile`?t.key!==e.key:t.kind===`free`||!hm(e,t.kind,t.items):!1,_m=e=>{let t=(0,Q.c)(53),{series:n,limit:r}=e,i=Math.max(...n,1),a=r&&i>r*.6?Math.max(r,i):i*1.2,o;t[0]===n.length?o=t[1]:(o=e=>n.length<2?120:3+e/(n.length-1)*234,t[0]=n.length,t[1]=o);let s=o,c;t[2]===a?c=t[3]:(c=e=>31-e/a*28,t[2]=a,t[3]=c);let l=c,u,d,f,p,m,h,g,_,v;if(t[4]!==r||t[5]!==n||t[6]!==a||t[7]!==s||t[8]!==l){let e;t[18]!==s||t[19]!==l?(e=(e,t)=>`${s(t).toFixed(1)},${l(e).toFixed(1)}`,t[18]=s,t[19]=l,t[20]=e):e=t[20];let i=n.map(e);u=n.length-1,d=`yuri-ctx-spark`,m=`0 0 240 34`,h=`none`,g=`true`,t[21]!==r||t[22]!==a||t[23]!==l?(_=r&&r<=a?(0,$.jsx)(`line`,{className:`win`,x1:0,x2:240,y1:l(r),y2:l(r)}):null,t[21]=r,t[22]=a,t[23]=l,t[24]=_):_=t[24];let o=i[0],c=i.slice(1).join(` L`),y;t[25]!==u||t[26]!==s?(y=s(u).toFixed(1),t[25]=u,t[26]=s,t[27]=y):y=t[27];let b;t[28]===s?b=t[29]:(b=s(0).toFixed(1),t[28]=s,t[29]=b);let x=`M${o} L${c} L${y},34 L${b},34 Z`;t[30]===x?v=t[31]:(v=(0,$.jsx)(`path`,{className:`area`,d:x}),t[30]=x,t[31]=v),f=`line`,p=i.join(` `),t[4]=r,t[5]=n,t[6]=a,t[7]=s,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v}else u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17];let y;t[32]!==f||t[33]!==p?(y=(0,$.jsx)(`polyline`,{className:f,points:p}),t[32]=f,t[33]=p,t[34]=y):y=t[34];let b;t[35]!==y||t[36]!==m||t[37]!==h||t[38]!==g||t[39]!==_||t[40]!==v?(b=(0,$.jsxs)(`svg`,{viewBox:m,preserveAspectRatio:h,"aria-hidden":g,children:[_,v,y]}),t[35]=y,t[36]=m,t[37]=h,t[38]=g,t[39]=_,t[40]=v,t[41]=b):b=t[41];let x=s(u)/240*100,S;t[42]===x?S=t[43]:(S=x.toFixed(2),t[42]=x,t[43]=S);let C=`${S}%`,w=l(n[u])/34*100,T;t[44]===w?T=t[45]:(T=w.toFixed(2),t[44]=w,t[45]=T);let E=`${T}%`,D;t[46]!==C||t[47]!==E?(D=(0,$.jsx)(`span`,{className:`at`,style:{left:C,top:E}}),t[46]=C,t[47]=E,t[48]=D):D=t[48];let O;return t[49]!==d||t[50]!==b||t[51]!==D?(O=(0,$.jsxs)(`span`,{className:d,children:[b,D]}),t[49]=d,t[50]=b,t[51]=D,t[52]=O):O=t[52],O},vm=e=>{let t=(0,Q.c)(195),{used:n,limit:r,parts:i,requestTotals:a,cache:o}=e,{t:s}=Pr(),c=Z.useRef(null),[l,u]=Z.useState(0),[d,f]=Z.useState(null),[p,m]=Z.useState(`all`),[h,g]=Z.useState(!1),[_,v]=Z.useState(null),[y,b]=It(um,`map`),x=y===`grid`?`grid`:`map`,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{let[t]=e;t&&u(Math.round(t.contentRect.width))},t[0]=S):S=t[0],Lt(c,S);let C=l>0&&l<=cm,w;t[1]!==C||t[2]!==l?(w=Math.round(l/(C?2:om)),t[1]=C,t[2]=l,t[3]=w):w=t[3];let T=Math.min(am,Math.max(im,w)),E;t[4]!==T||t[5]!==r||t[6]!==x||t[7]!==i||t[8]!==n||t[9]!==l?(E=x===`map`?Wp(i,n,r,l,T):[],t[4]=T,t[5]=r,t[6]=x,t[7]=i,t[8]=n,t[9]=l,t[10]=E):E=t[10];let D=E,O;t[11]!==r||t[12]!==x||t[13]!==i||t[14]!==n?(O=x===`grid`?Up(i,n,r):[],t[11]=r,t[12]=x,t[13]=i,t[14]=n,t[15]=O):O=t[15];let k=O,A=r&&r>n?r-n:0,j=r&&r>0?n/r:0,M;t[16]!==j||t[17]!==r?(M=r?Pp(j):null,t[16]=j,t[17]=r,t[18]=M):M=t[18];let N=M,P;t[19]!==A||t[20]!==a?(P=A>0?Np(a,A):null,t[19]=A,t[20]=a,t[21]=P):P=t[21];let F=P,I;t[22]!==i||t[23]!==p?(I=p===`all`||i.some(e=>e.kind===p)?p:`all`,t[22]=i,t[23]=p,t[24]=I):I=t[24];let L=I,R;if(t[25]!==L||t[26]!==i){let e;t[28]===L?e=t[29]:(e=e=>L===`all`||e.kind===L,t[28]=L,t[29]=e),R=i.filter(e).flatMap(ym).sort(bm),t[25]=L,t[26]=i,t[27]=R}else R=t[27];let z=R,ee;t[30]===z?ee=t[31]:(ee=Math.max(1,...z.map(xm)),t[30]=z,t[31]=ee);let B=ee,V;t[32]!==h||t[33]!==z?(V=h?z:z.slice(0,lm),t[32]=h,t[33]=z,t[34]=V):V=t[34];let te=V,ne;t[35]===s?ne=t[36]:(ne=e=>{if(e.kind===`free`)return s(`contextSidebar.window.freeSpace`);if(!e.item)return e.key===e.kind?bp(s,e.kind):s(`contextSidebar.window.more`,{count:e.items.length});let{item:t}=e,n=t.kind===`file`?Sp(s,t).slice(t.name.lastIndexOf(`/`)+1):Sp(s,t);return t.count>1&&t.kind!==`turn`?`${n} ×${t.count}`:n},t[35]=s,t[36]=ne);let re=ne,ie;t[37]!==r||t[38]!==s||t[39]!==n?(ie=e=>e.kind===`free`?`${Fp(e.tokens)} · ${mm(e.tokens,Math.max(r??0,n))}%`:!e.item&&e.key===e.kind?Fp(e.tokens):`${Fp(e.tokens)} · ${bp(s,e.kind)}`,t[37]=r,t[38]=s,t[39]=n,t[40]=ie):ie=t[40];let ae=ie,H,U,oe,se,ce,le,ue,de;if(t[41]!==o||t[42]!==k||t[43]!==j||t[44]!==d||t[45]!==A||t[46]!==F||t[47]!==N||t[48]!==T||t[49]!==r||t[50]!==x||t[51]!==C||t[52]!==i||t[53]!==s||t[54]!==re||t[55]!==ae||t[56]!==D||t[57]!==n||t[58]!==l){let e=[...i.map(e=>({kind:e.kind,label:bp(s,e.kind),tokens:e.tokens})),...A>0?[{kind:`free`,label:s(`contextSidebar.window.freeSpace`),tokens:A}]:[]],a;t[67]===s?a=t[68]:(a=s(`contextSidebar.window.tab.all`),t[67]=s,t[68]=a);let u;t[69]===a?u=t[70]:(u={id:`all`,label:a},t[69]=a,t[70]=u);let p;if(t[71]!==i||t[72]!==s||t[73]!==u){let e;t[75]===s?e=t[76]:(e=e=>({id:e.kind,label:bp(s,e.kind)}),t[75]=s,t[76]=e),p=[u,...i.map(e)],t[71]=i,t[72]=s,t[73]=u,t[74]=p}else p=t[74];de=p;let m;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>f(null),t[77]=m):m=t[77],H=m;let h=C&&`is-narrow`;t[78]===h?se=t[79]:(se=J(`yuri-ctx-card`,h),t[78]=h,t[79]=se);let g;t[80]===s?g=t[81]:(g=s(`contextSidebar.window.title`),t[80]=s,t[81]=g),t[82]===g?ce=t[83]:(ce=(0,$.jsx)(`div`,{className:`yuri-ctx-title`,children:g}),t[82]=g,t[83]=ce);let _;t[84]===s?_=t[85]:(_=s(`contextSidebar.window.used`),t[84]=s,t[85]=_);let y;t[86]===_?y=t[87]:(y=(0,$.jsx)(`span`,{children:_}),t[86]=_,t[87]=y);let b;t[88]!==N||t[89]!==s?(b=N?(0,$.jsx)(`span`,{className:J(`yuri-ctx-health`,`is-${N}`),children:s(`contextSidebar.window.health.${N}`)}):null,t[88]=N,t[89]=s,t[90]=b):b=t[90];let S;t[91]!==y||t[92]!==b?(S=(0,$.jsxs)(`div`,{className:`yuri-ctx-label`,children:[y,b]}),t[91]=y,t[92]=b,t[93]=S):S=t[93];let w;t[94]===n?w=t[95]:(w=Fp(n),t[94]=n,t[95]=w);let E;t[96]===w?E=t[97]:(E=(0,$.jsx)(`b`,{children:w}),t[96]=w,t[97]=E);let O;t[98]!==r||t[99]!==s?(O=r?(0,$.jsxs)(`span`,{children:[`/ `,Fp(r),` `,s(`contextSidebar.window.tokens`)]}):(0,$.jsx)(`span`,{children:s(`contextSidebar.window.tokens`)}),t[98]=r,t[99]=s,t[100]=O):O=t[100];let M;t[101]!==E||t[102]!==O?(M=(0,$.jsxs)(`div`,{className:`yuri-ctx-big`,children:[E,O]}),t[101]=E,t[102]=O,t[103]=M):M=t[103];let P;t[104]!==j||t[105]!==F||t[106]!==r||t[107]!==s?(P=r?[s(`contextSidebar.context.percentUsed`,{percent:Math.round(j*100)}),F===null?null:F>=999?s(`contextSidebar.window.headroomPlenty`):F>1?s(`contextSidebar.window.headroom`,{count:F}):null].filter(Boolean).join(` · `):s(`contextSidebar.window.limitUnknown`),t[104]=j,t[105]=F,t[106]=r,t[107]=s,t[108]=P):P=t[108];let I;t[109]===P?I=t[110]:(I=(0,$.jsx)(`div`,{className:`yuri-ctx-sub`,children:P}),t[109]=P,t[110]=I);let L;t[111]!==S||t[112]!==M||t[113]!==I?(L=(0,$.jsxs)(`div`,{className:`yuri-ctx-stat`,children:[S,M,I]}),t[111]=S,t[112]=M,t[113]=I,t[114]=L):L=t[114];let R;t[115]!==o||t[116]!==s?(R=o?(0,$.jsxs)(`div`,{className:`yuri-ctx-stat`,children:[(0,$.jsx)(`div`,{className:`yuri-ctx-label`,children:s(`contextSidebar.window.cache.title`)}),(0,$.jsxs)(`div`,{className:`yuri-ctx-big`,children:[(0,$.jsxs)(`b`,{children:[mm(o.read,o.total),`%`]}),(0,$.jsx)(`span`,{children:s(`contextSidebar.window.cache.hit`)})]}),(0,$.jsx)(`span`,{className:`yuri-ctx-bar`,children:(0,$.jsx)(`i`,{style:{width:`${Math.min(100,o.read/Math.max(1,o.total)*100).toFixed(1)}%`}})}),(0,$.jsx)(`div`,{className:`yuri-ctx-sub`,children:s(`contextSidebar.window.cache.detail`,{cached:Fp(o.read),fresh:Fp(o.total-o.read)})})]}):null,t[115]=o,t[116]=s,t[117]=R):R=t[117],t[118]!==L||t[119]!==R?(le=(0,$.jsxs)(`div`,{className:`yuri-ctx-top`,children:[L,R]}),t[118]=L,t[119]=R,t[120]=le):le=t[120],t[121]!==k||t[122]!==d||t[123]!==T||t[124]!==r||t[125]!==x||t[126]!==C||t[127]!==i||t[128]!==s||t[129]!==re||t[130]!==ae||t[131]!==D||t[132]!==n||t[133]!==l?(ue=(0,$.jsx)(`div`,{ref:c,className:`yuri-ctx-viz`,children:x===`map`?(0,$.jsx)(`div`,{role:`img`,"aria-label":`${Fp(n)}${r?` / ${Fp(r)}`:``}`,className:`yuri-ctx-map`,style:{height:T},onPointerLeave:H,children:l>0?D.map(e=>{let t=e.kind===`free`,n=e.w<54||e.h<30,r=!n&&e.h<46,i=gm(d,e),a=re(e),o=ae(e);return(0,$.jsxs)(`div`,{role:t?void 0:`button`,tabIndex:t?void 0:0,title:`${a} · ${o}`,className:J(`yuri-ctx-tile`,`yuri-ctx-k-${e.kind}`,t&&`is-free`,n&&`is-bare`,r&&`is-low`,i&&`is-dim`),style:{left:e.x+sm,top:e.y+sm,width:Math.max(0,e.w-sm*2),height:Math.max(0,e.h-sm*2)},onPointerEnter:()=>f({type:`tile`,key:e.key}),onClick:t?void 0:()=>v({kind:e.kind,itemId:e.item?.id??null}),onKeyDown:t?void 0:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),v({kind:e.kind,itemId:e.item?.id??null}))},children:[n?null:(0,$.jsx)(`span`,{className:`yuri-ctx-tile-n`,children:a}),n||r?null:(0,$.jsx)(`span`,{className:`yuri-ctx-tile-v`,children:o})]},e.key)}):null}):(0,$.jsx)(`div`,{role:`img`,"aria-label":`${Fp(n)}${r?` / ${Fp(r)}`:``}`,className:J(`yuri-ctx-grid`,C&&`is-narrow`),onPointerLeave:H,children:k.map((e,t)=>{if(!e)return(0,$.jsx)(`i`,{className:J(`yuri-ctx-cell is-free`,d!==null&&(d.type!==`part`||d.kind!==`free`)&&`is-dim`),onPointerEnter:()=>f({type:`part`,kind:`free`})},t);let n=i.find(t=>t.kind===e.kind)?.items[e.item]??null,r=d!==null&&(d.type===`part`?d.kind!==e.kind:d.type!==`item`||d.kind!==e.kind||d.id!==n?.id);return(0,$.jsx)(`button`,{type:`button`,"aria-label":bp(s,e.kind),className:J(`yuri-ctx-cell`,`yuri-ctx-k-${e.kind}`,r&&`is-dim`,!r&&d?.type===`item`&&`is-on`),onPointerEnter:()=>f(n?{type:`item`,kind:e.kind,id:n.id}:{type:`part`,kind:e.kind}),onClick:()=>v({kind:e.kind,itemId:n?.id??null})},t)})})}),t[121]=k,t[122]=d,t[123]=T,t[124]=r,t[125]=x,t[126]=C,t[127]=i,t[128]=s,t[129]=re,t[130]=ae,t[131]=D,t[132]=n,t[133]=l,t[134]=ue):ue=t[134],U=`yuri-ctx-legend`,oe=e.map(e=>{let t=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`i`,{className:J(`yuri-ctx-dot`,`yuri-ctx-k-${e.kind}`,e.kind===`free`&&`is-free`)}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`v`,children:Fp(e.tokens)})]});return e.kind===`free`?(0,$.jsx)(`span`,{className:`yuri-ctx-leg is-static`,onPointerEnter:()=>f({type:`part`,kind:`free`}),onPointerLeave:H,children:t},e.kind):(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-leg`,onPointerEnter:()=>f({type:`part`,kind:e.kind}),onPointerLeave:H,onClick:()=>v({kind:e.kind,itemId:null}),children:t},e.kind)}),t[41]=o,t[42]=k,t[43]=j,t[44]=d,t[45]=A,t[46]=F,t[47]=N,t[48]=T,t[49]=r,t[50]=x,t[51]=C,t[52]=i,t[53]=s,t[54]=re,t[55]=ae,t[56]=D,t[57]=n,t[58]=l,t[59]=H,t[60]=U,t[61]=oe,t[62]=se,t[63]=ce,t[64]=le,t[65]=ue,t[66]=de}else H=t[59],U=t[60],oe=t[61],se=t[62],ce=t[63],le=t[64],ue=t[65],de=t[66];let fe;t[135]!==H||t[136]!==x||t[137]!==b||t[138]!==s?(fe=(0,$.jsx)(`span`,{className:`yuri-ctx-look`,role:`group`,children:[[`map`,`contextSidebar.window.look.map`,fm],[`grid`,`contextSidebar.window.look.grid`,pm]].map(e=>{let[t,n,r]=e;return(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-look-b`,title:s(n),"aria-label":s(n),"aria-pressed":x===t,onClick:()=>{H(),b(t)},children:r},t)})}),t[135]=H,t[136]=x,t[137]=b,t[138]=s,t[139]=fe):fe=t[139];let pe;t[140]!==U||t[141]!==oe||t[142]!==fe?(pe=(0,$.jsxs)(`div`,{className:U,children:[oe,fe]}),t[140]=U,t[141]=oe,t[142]=fe,t[143]=pe):pe=t[143];let me;t[144]===s?me=t[145]:(me=s(`contextSidebar.window.contents`),t[144]=s,t[145]=me);let he;t[146]===me?he=t[147]:(he=(0,$.jsx)(`span`,{className:`yuri-ctx-label`,children:me}),t[146]=me,t[147]=he);let ge;t[148]!==L||t[149]!==de?(ge=(0,$.jsx)(`span`,{className:`yuri-ctx-tabs`,role:`group`,children:de.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-tab`,"aria-pressed":L===e.id,onClick:()=>{m(e.id),g(!1)},children:e.label},e.id))}),t[148]=L,t[149]=de,t[150]=ge):ge=t[150];let _e;t[151]!==he||t[152]!==ge?(_e=(0,$.jsxs)(`div`,{className:`yuri-ctx-contents-head`,children:[he,ge]}),t[151]=he,t[152]=ge,t[153]=_e):_e=t[153];let ve;if(t[154]!==H||t[155]!==d||t[156]!==B||t[157]!==te){let e;t[159]!==H||t[160]!==d||t[161]!==B?(e=e=>{let{item:t,kind:n}=e,r=Cp(t);return(0,$.jsxs)(`button`,{type:`button`,className:J(`yuri-ctx-row`,`yuri-ctx-k-${n}`,d?.type===`item`&&d.id===t.id&&`is-on`),onPointerEnter:()=>f({type:`item`,kind:n,id:t.id}),onPointerLeave:H,onClick:()=>v({kind:n,itemId:t.id}),children:[(0,$.jsx)(`i`,{className:`yuri-ctx-dot`}),(0,$.jsx)(Jp,{item:t}),t.count>1&&t.kind!==`turn`?(0,$.jsxs)(`span`,{className:`yuri-ctx-x`,children:[`×`,t.count]}):null,r?(0,$.jsx)(`code`,{className:`yuri-ctx-tag`,children:r}):null,(0,$.jsx)(`span`,{className:`yuri-ctx-mini`,children:(0,$.jsx)(`i`,{style:{width:`${Math.max(2,t.tokens/B*100).toFixed(1)}%`}})}),(0,$.jsx)(`span`,{className:`yuri-ctx-v`,children:Fp(t.tokens)})]},t.id)},t[159]=H,t[160]=d,t[161]=B,t[162]=e):e=t[162],ve=te.map(e),t[154]=H,t[155]=d,t[156]=B,t[157]=te,t[158]=ve}else ve=t[158];let ye;t[163]===ve?ye=t[164]:(ye=(0,$.jsx)(`div`,{className:`yuri-ctx-rows`,children:ve}),t[163]=ve,t[164]=ye);let be;t[165]!==h||t[166]!==z.length||t[167]!==s?(be=z.length>lm?(0,$.jsx)(`button`,{type:`button`,className:`yuri-ctx-more`,onClick:()=>g(Sm),children:h?s(`contextSidebar.window.showFewer`):s(`contextSidebar.window.showAll`,{count:z.length})}):null,t[165]=h,t[166]=z.length,t[167]=s,t[168]=be):be=t[168];let xe;t[169]!==_e||t[170]!==ye||t[171]!==be?(xe=(0,$.jsxs)(`div`,{className:`yuri-ctx-contents`,children:[_e,ye,be]}),t[169]=_e,t[170]=ye,t[171]=be,t[172]=xe):xe=t[172];let Se;t[173]!==r||t[174]!==a||t[175]!==s?(Se=a.length>1?(0,$.jsxs)(`div`,{className:`yuri-ctx-session`,children:[(0,$.jsx)(`span`,{className:`yuri-ctx-label`,children:s(`contextSidebar.window.session`)}),(0,$.jsx)(_m,{series:a,limit:r}),(0,$.jsx)(`span`,{className:`yuri-ctx-sub`,children:a.length===1?s(`contextSidebar.window.requests.one`):s(`contextSidebar.window.requests.other`,{count:a.length})})]}):null,t[173]=r,t[174]=a,t[175]=s,t[176]=Se):Se=t[176];let Ce;t[177]===s?Ce=t[178]:(Ce=s(`contextSidebar.window.estimateNote`),t[177]=s,t[178]=Ce);let we;t[179]===Ce?we=t[180]:(we=(0,$.jsx)(`div`,{className:`yuri-ctx-note`,children:Ce}),t[179]=Ce,t[180]=we);let Te;t[181]===Symbol.for(`react.memo_cache_sentinel`)?(Te=()=>v(null),t[181]=Te):Te=t[181];let Ee;t[182]!==i||t[183]!==_?(Ee=(0,$.jsx)(Qp,{target:_,parts:i,onClose:Te}),t[182]=i,t[183]=_,t[184]=Ee):Ee=t[184];let De;return t[185]!==se||t[186]!==ce||t[187]!==le||t[188]!==ue||t[189]!==pe||t[190]!==xe||t[191]!==Se||t[192]!==we||t[193]!==Ee?(De=(0,$.jsxs)(`div`,{className:se,children:[ce,le,ue,pe,xe,Se,we,Ee]}),t[185]=se,t[186]=ce,t[187]=le,t[188]=ue,t[189]=pe,t[190]=xe,t[191]=Se,t[192]=we,t[193]=Ee,t[194]=De):De=t[194],De};function ym(e){return e.items.map(t=>({item:t,kind:e.kind}))}function bm(e,t){return t.item.tokens-e.item.tokens}function xm(e){return e.item.tokens}function Sm(e){return!e}var Cm={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},wm=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?0:e,Tm=e=>{let t=e.info.tokens,n=t===void 0?e.parts.find(e=>e.tokens!==void 0)?.tokens:t;if(typeof n==`number`)return{...Cm,total:wm(n)};if(!n||typeof n!=`object`)return Cm;let r=n,i=wm(r.input),a=wm(r.output),o=wm(r.reasoning),s=wm(r.cache?.read),c=wm(r.cache?.write);return{input:i,output:a,reasoning:o,cacheRead:s,cacheWrite:c,total:i+a+o+s+c}},Em=e=>e.toLocaleString(Mr()),Dm=e=>!Number.isFinite(e)||e<=0?new Intl.NumberFormat(Mr(),{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat(Mr(),{style:`currency`,currency:`USD`,minimumFractionDigits:e<.01?4:2,maximumFractionDigits:e<.01?4:2}).format(e),Om=(e,t)=>!e||!Number.isFinite(e)?`-`:Ws(e,t,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}),km=(e,t,n)=>{let r=e.find(e=>e.id===t),i=r?.models?.find(e=>e.id===n);return{providerName:r?.name||t||`-`,modelName:i?.name||n||`-`,contextLimit:typeof i?.limit?.context==`number`?i.limit.context:null}},Am=e=>{let t=(0,Q.c)(3),{active:n}=e,r=n===void 0||n,i=xt(),a;return t[0]!==r||t[1]!==i?(a=i?.entry.location.hostId?(0,$.jsx)(Mm,{active:r},i.entry.key):(0,$.jsx)(jm,{}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a},jm=()=>{let e=(0,Q.c)(5),t=Jn(Pm),n=wr(),r=yr(t??``),i=Nn(Fm),a;return e[0]!==t||e[1]!==i||e[2]!==r||e[3]!==n?(a=(0,$.jsx)(Nm,{currentSessionId:t,sessions:n,sessionMessages:r,providers:i}),e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=a):a=e[4],a},Mm=e=>{let t=(0,Q.c)(58),{active:n}=e,r=xt(),{t:i}=Pr(),a=r.entry,o=ln(Im),s;t[0]!==a.key||t[1]!==o?(s=o&&ne(o.location)===a.key?o.sessionId:null,t[0]=a.key,t[1]=o,t[2]=s):s=t[2];let c=s,l=Z.useSyncExternalStore(ve,_e,_e),d;t[3]===a.location?d=t[4]:(d=ge(a.location),t[3]=a.location,t[4]=d);let f=d,p;t[5]!==c||t[6]!==a.location||t[7]!==f?(p=f&&c?Ce(a.location,c):null,t[5]=c,t[6]=a.location,t[7]=f,t[8]=p):p=t[8];let m;t[9]!==l||t[10]!==p?(m={revision:l,scope:p},t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m.scope,g;t[12]!==n||t[13]!==f||t[14]!==h?(g=e=>n&&f&&h?f.subscribe(h,e):Lm,t[12]=n,t[13]=f,t[14]=h,t[15]=g):g=t[15];let _=g,v;t[16]!==n||t[17]!==f||t[18]!==h?(v=()=>n&&f&&h?f.getTranscript(h):null,t[16]=n,t[17]=f,t[18]=h,t[19]=v):v=t[19];let y=v,b=Z.useSyncExternalStore(_,y,y),[x,S]=Z.useState(null),C;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>S(e instanceof Error?e.message:String(e)),t[20]=C):C=t[20];let w=G(C),T;t[21]!==c||t[22]!==a||t[23]!==f||t[24]!==h?(T=async()=>{f&&h&&c&&(a.sdk(),await Ee(a.location,c,{background:!0}),a.sdk()),S(null)},t[21]=c,t[22]=a,t[23]=f,t[24]=h,t[25]=T):T=t[25];let E=G(T);Ct(n?c:null,E,w);let D=kr(r.registry,a.location.hostId,n&&!!c),O;t[26]===a?O=t[27]:(O=on(a.location.directory,u(),a),t[26]=a,t[27]=O);let k=n&&!!c,A;t[28]!==k||t[29]!==O?(A={...O,enabled:k},t[28]=k,t[29]=O,t[30]=A):A=t[30];let j=bt(A,Et),M;t[31]===j.data?.providers?M=t[32]:(M=j.data?.providers.map(Rm)??[],t[31]=j.data?.providers,t[32]=M);let N=M,P;t[33]!==a.key||t[34]!==a.location||t[35]!==D.data?.directories?(P=D.data?.directories.find(e=>ne({...a.location,directory:e.directory})===a.key)?.sessions??[],t[33]=a.key,t[34]=a.location,t[35]=D.data?.directories,t[36]=P):P=t[36];let F=P,I;t[37]===b?I=t[38]:(I=b?.messageOrder.flatMap(e=>b.messagesByID[e]?[{info:b.messagesByID[e],parts:Array.from(b.partsByMessageID[e]??[])}]:[])??[],t[37]=b,t[38]=I);let L=I,R=x??j.error?.message??D.error?.message,z;t[39]!==j||t[40]!==E||t[41]!==w||t[42]!==D?(z=async()=>{await Promise.all([E(),j.refetch(),D.refetch()]).catch(w)},t[39]=j,t[40]=E,t[41]=w,t[42]=D,t[43]=z):z=t[43],zo(r.registry,a.location.hostId,n?R:null,z);let ee;t[44]!==c||t[45]!==R||t[46]!==i||t[47]!==b?(ee=c&&!b&&!R?(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-2 typography-meta text-muted-foreground`,children:i(`common.loading`)}):null,t[44]=c,t[45]=R,t[46]=i,t[47]=b,t[48]=ee):ee=t[48];let B;t[49]!==c||t[50]!==N||t[51]!==L||t[52]!==F?(B=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Nm,{currentSessionId:c,sessions:F,sessionMessages:L,providers:N})}),t[49]=c,t[50]=N,t[51]=L,t[52]=F,t[53]=B):B=t[53];let V;return t[54]!==a.key||t[55]!==ee||t[56]!==B?(V=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-remote-context-location":a.key,children:[ee,B]}),t[54]=a.key,t[55]=ee,t[56]=B,t[57]=V):V=t[57],V},Nm=e=>{let t=(0,Q.c)(125),{currentSessionId:n,sessions:r,sessionMessages:i,providers:a}=e,{t:o}=Pr(),s=K(zm),c=K(Bm),l;t[0]!==n||t[1]!==r?(l=n?r.find(e=>e.id===n)??null:null,t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d,f,p,m,h,g,_,v,y,b,x,S;if(t[3]!==a||t[4]!==i||t[5]!==c){d=i.filter(Vm);let e;t[18]===i?e=t[19]:(e=i.filter(Hm),t[18]=i,t[19]=e),x=e;let n=c?Go(i):null,r=null;for(let e=d.length-1;e>=0;--e){let t=d[e];if(Tm(t).total>0){r=t;break}}y=r?Tm(r):Cm,f=ns({input:y.input,cache:{read:y.cacheRead,write:y.cacheWrite}}),b=d.reduce(Um,0);let o=[];for(let e of n?.turns??[]){let t=e.assistantMessages.map(Wm),n=Ko(t),r=n[n.length-1]??null;e.completionDisposition!==`active`&&r!==null&&o.push(...t)}let s=ts(o);_=s===null?null:qo(s);let l=r?.info??null;h=km(a,l?.providerID||``,l?.modelID||``),p=h.contextLimit;let u=[...i].reverse().find(Gm)?.info?.system||``;g=[];for(let e of d){let t=Tm(e),n=t.input+t.cacheRead+t.cacheWrite;n>0&&g.push(n)}m=y.input+y.cacheRead+y.cacheWrite,S=m>0?m+y.output:0,v=jp(i,{used:S,firstRequestInput:g[0]??0,systemPrompt:u}),t[3]=a,t[4]=i,t[5]=c,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17];let C=v,w;t[20]!==f.hasInput||t[21]!==m||t[22]!==y?(w=f.hasInput?{read:y.cacheRead,total:m}:null,t[20]=f.hasInput,t[21]=m,t[22]=y,t[23]=w):w=t[23];let T=w,E=i[0]?.info?.time?.created,D=i.length>0?i[i.length-1]?.info?.time?.created:null,O;t[24]!==u?.title||t[25]!==o?(O=u?.title||o(`contextSidebar.session.untitled`),t[24]=u?.title,t[25]=o,t[26]=O):O=t[26];let k=u?.time?.created??E??null,A=D??u?.time?.created??null,j=_&&_.length>0?_:null,M;t[27]!==g||t[28]!==T||t[29]!==C||t[30]!==S?(M={used:S,parts:C,requestTotals:g,cache:T},t[27]=g,t[28]=T,t[29]=C,t[30]=S,t[31]=M):M=t[31];let N;t[32]!==d.length||t[33]!==f||t[34]!==p||t[35]!==h||t[36]!==i.length||t[37]!==O||t[38]!==k||t[39]!==A||t[40]!==j||t[41]!==M||t[42]!==y||t[43]!==b||t[44]!==x.length?(N={sessionTitle:O,messagesCount:i.length,userMessagesCount:x.length,assistantMessagesCount:d.length,createdAt:k,lastActivityAt:A,providerModel:h,tokenBreakdown:y,cacheHitRate:f,totalAssistantCost:b,sessionTpsLabel:j,contextLimit:p,window:M},t[32]=d.length,t[33]=f,t[34]=p,t[35]=h,t[36]=i.length,t[37]=O,t[38]=k,t[39]=A,t[40]=j,t[41]=M,t[42]=y,t[43]=b,t[44]=x.length,t[45]=N):N=t[45];let P=N;if(!n){let e;t[46]===o?e=t[47]:(e=o(`contextSidebar.empty.openSession`),t[46]=o,t[47]=e);let n;return t[48]===e?n=t[49]:(n=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground`,children:e}),t[48]=e,t[49]=n),n}let F;t[50]===P.sessionTitle?F=t[51]:(F=(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:P.sessionTitle}),t[50]=P.sessionTitle,t[51]=F);let I;t[52]!==P.providerModel.modelName||t[53]!==P.providerModel.providerName?(I=(0,$.jsxs)(`span`,{children:[P.providerModel.providerName,` / `,P.providerModel.modelName]}),t[52]=P.providerModel.modelName,t[53]=P.providerModel.providerName,t[54]=I):I=t[54];let L;t[55]!==s||t[56]!==P.createdAt?(L=P.createdAt&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:`·`}),(0,$.jsx)(`span`,{children:Om(P.createdAt,s)})]}),t[55]=s,t[56]=P.createdAt,t[57]=L):L=t[57];let R;t[58]!==I||t[59]!==L?(R=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70`,children:[I,L]}),t[58]=I,t[59]=L,t[60]=R):R=t[60];let z;t[61]!==F||t[62]!==R?(z=(0,$.jsxs)(`div`,{className:`mb-6`,children:[F,R]}),t[61]=F,t[62]=R,t[63]=z):z=t[63];let ee;t[64]!==P.contextLimit||t[65]!==P.window.cache||t[66]!==P.window.parts||t[67]!==P.window.requestTotals||t[68]!==P.window.used?(ee=P.window.used>0?(0,$.jsx)(vm,{used:P.window.used,limit:P.contextLimit,parts:P.window.parts,requestTotals:P.window.requestTotals,cache:P.window.cache}):null,t[64]=P.contextLimit,t[65]=P.window.cache,t[66]=P.window.parts,t[67]=P.window.requestTotals,t[68]=P.window.used,t[69]=ee):ee=t[69];let B;t[70]===o?B=t[71]:(B=o(`contextSidebar.stats.messages`),t[70]=o,t[71]=B);let V;t[72]===P.messagesCount?V=t[73]:(V=Em(P.messagesCount),t[72]=P.messagesCount,t[73]=V);let te;t[74]!==B||t[75]!==V?(te={label:B,value:V},t[74]=B,t[75]=V,t[76]=te):te=t[76];let ne;t[77]===o?ne=t[78]:(ne=o(`contextSidebar.stats.user`),t[77]=o,t[78]=ne);let re;t[79]===P.userMessagesCount?re=t[80]:(re=Em(P.userMessagesCount),t[79]=P.userMessagesCount,t[80]=re);let ie;t[81]!==ne||t[82]!==re?(ie={label:ne,value:re},t[81]=ne,t[82]=re,t[83]=ie):ie=t[83];let ae;t[84]===o?ae=t[85]:(ae=o(`contextSidebar.stats.assistant`),t[84]=o,t[85]=ae);let H;t[86]===P.assistantMessagesCount?H=t[87]:(H=Em(P.assistantMessagesCount),t[86]=P.assistantMessagesCount,t[87]=H);let U;t[88]!==ae||t[89]!==H?(U={label:ae,value:H},t[88]=ae,t[89]=H,t[90]=U):U=t[90];let oe;t[91]!==te||t[92]!==ie||t[93]!==U?(oe=[te,ie,U],t[91]=te,t[92]=ie,t[93]=U,t[94]=oe):oe=t[94];let se=oe,ce;t[95]===se?ce=t[96]:(ce=(0,$.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:se.map(Km)}),t[95]=se,t[96]=ce);let le=c?`grid-cols-2`:`grid-cols-1`,ue;t[97]===le?ue=t[98]:(ue=J(`grid gap-2`,le),t[97]=le,t[98]=ue);let de;t[99]===o?de=t[100]:(de=o(`contextSidebar.stats.cost`),t[99]=o,t[100]=de);let fe;t[101]===de?fe=t[102]:(fe=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:de}),t[101]=de,t[102]=fe);let pe;t[103]===P.totalAssistantCost?pe=t[104]:(pe=Dm(P.totalAssistantCost),t[103]=P.totalAssistantCost,t[104]=pe);let me;t[105]===pe?me=t[106]:(me=(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:pe}),t[105]=pe,t[106]=me);let he;t[107]!==fe||t[108]!==me?(he=(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[fe,me]}),t[107]=fe,t[108]=me,t[109]=he):he=t[109];let ge;t[110]!==c||t[111]!==o||t[112]!==P.sessionTpsLabel?(ge=c?(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:o(`contextSidebar.stats.sessionTps`)}),(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:P.sessionTpsLabel??`—`})]}):null,t[110]=c,t[111]=o,t[112]=P.sessionTpsLabel,t[113]=ge):ge=t[113];let _e;t[114]!==ue||t[115]!==he||t[116]!==ge?(_e=(0,$.jsxs)(`div`,{className:ue,children:[he,ge]}),t[114]=ue,t[115]=he,t[116]=ge,t[117]=_e):_e=t[117];let ve;t[118]!==ce||t[119]!==_e?(ve=(0,$.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[ce,_e]}),t[118]=ce,t[119]=_e,t[120]=ve):ve=t[120];let ye;return t[121]!==z||t[122]!==ee||t[123]!==ve?(ye=(0,$.jsx)(`div`,{className:`h-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[52rem] px-5 py-6`,children:[z,ee,ve]})}),t[121]=z,t[122]=ee,t[123]=ve,t[124]=ye):ye=t[124],ye};function Pm(e){return e.currentSessionId}function Fm(e){return e.providers}function Im(e){return e.remoteSession}function Lm(){}function Rm(e){return{...e,models:Object.values(e.models)}}function zm(e){return e.timeFormatPreference}function Bm(e){return e.showAssistantTps}function Vm(e){return Yo(e.info).role===`assistant`}function Hm(e){return Yo(e.info).isUser}function Um(e,t){return e+wm(t.info.cost)}function Wm(e){let{info:t}=e;return{createdAt:t.time.created,streamedAt:t.time.streamed,outputTokens:t.tokens?.output,reasoningTokens:t.tokens?.reasoning}}function Gm(e){return Yo(e.info).isUser&&typeof e.info.system==`string`}function Km(e){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:e.label}),(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:e.value})]},e.label)}var qm=420,Jm=({isOpen:e,children:t,className:n})=>{let{t:r}=Pr(),i=K(e=>e.rightSidebarWidth),a=K(e=>e.setRightSidebarWidth),[o,s]=Z.useState(!1),c=Z.useRef(0),l=Z.useRef(i||qm),u=Z.useRef(null),d=Z.useRef(null),f=Z.useRef(null),p=Z.useCallback(e=>Math.min(860,Math.max(240,e)),[]),m=Z.useCallback(e=>{let t=f.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,t.style.setProperty(`--yuri-right-sidebar-width`,`${e}px`))},[]),h=Math.min(860,Math.max(240,i||qm)),g=e?h:0;Z.useLayoutEffect(()=>{if(o)return;let e=f.current;e&&(e.style.minWidth=``,e.style.maxWidth=``)},[e,o,h]);let _=t=>{if(!e)return;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}d.current=t.pointerId,s(!0),c.current=t.clientX;let n=f.current?.clientWidth||g;l.current=n,u.current=n,m(n),t.preventDefault()},v=e=>{if(!o||d.current!==e.pointerId)return;let t=c.current-e.clientX,n=p(l.current+t);u.current!==n&&(u.current=n,m(n))},y=e=>{if(d.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=p(u.current??g);d.current=null,u.current=null,s(!1),a(t)},b=o?u.current??g:g;return(0,$.jsxs)(`aside`,{ref:f,className:J(`relative flex h-full overflow-hidden yuri-layout-divider-l will-change-[width] motion-reduce:transition-none`,`bg-sidebar`,!e&&`border-l-0`,n),style:{width:`${b}px`,"--yuri-right-sidebar-width":`${o?b:h}px`,overflowX:`clip`,transitionProperty:o?`none`:`width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||g===0,children:[e&&(0,$.jsx)(`div`,{className:J(`absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,o&&`bg-[var(--interactive-border)]`),onPointerDown:_,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`sidebar.resize.rightPanelAria`)}),(0,$.jsx)(`div`,{className:J(`relative z-10 flex h-full w-full min-h-0 min-w-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,o&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),"aria-hidden":!e,children:e?t:null})]})},Ym=12,Xm=[{id:`left`,x:22,y:58,delay:0,radius:120,colorVar:`--status-success`},{id:`center`,x:50,y:42,delay:120,radius:150,colorVar:`--primary-base`},{id:`right`,x:78,y:55,delay:200,radius:130,colorVar:`--status-info`}],Zm=e=>{let t=(0,Q.c)(18),{isActive:n,burstKey:r,className:i,durationMs:a,bursts:o,onComplete:s}=e,c=r===void 0?0:r,l=a===void 0?900:a,u=o===void 0?Xm:o,d=Z.useRef(!1),f,p;t[0]!==n||t[1]!==s?(f=()=>{!n&&d.current&&s?.(),n&&(d.current=!0)},p=[n,s],t[0]=n,t[1]=s,t[2]=f,t[3]=p):(f=t[2],p=t[3]),Z.useEffect(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=Array.from({length:Ym},Qm),t[4]=m):m=t[4];let h=m;if(!n)return null;let g;t[5]===i?g=t[6]:(g=J(`fireworks-overlay pointer-events-none`,i),t[5]=i,t[6]=g);let _;if(t[7]!==c||t[8]!==u||t[9]!==l){let e;t[11]!==c||t[12]!==l?(e=e=>{let t={"--burst-delay":`${e.delay}ms`,"--burst-x":`${e.x}%`,"--burst-y":`${e.y}%`,"--firework-color":`var(${e.colorVar})`,"--firework-duration":`${l}ms`};return(0,$.jsx)(`div`,{className:`firework-burst`,style:t,children:h.map((t,n)=>{let r=t.x*e.radius,i=t.y*e.radius,a={"--translate-x":`${r}px`,"--translate-y":`${i}px`,"--particle-delay":`${t.delay}ms`,color:`var(${e.colorVar})`};return(0,$.jsx)(`span`,{className:`firework-particle`,style:a},`${e.id}-${n}-${c}`)})},`${e.id}-${c}`)},t[11]=c,t[12]=l,t[13]=e):e=t[13],_=u.map(e),t[7]=c,t[8]=u,t[9]=l,t[10]=_}else _=t[10];let v;return t[14]!==c||t[15]!==g||t[16]!==_?(v=(0,$.jsx)(`div`,{className:g,"aria-hidden":`true`,"data-burst-key":c,children:_}),t[14]=c,t[15]=g,t[16]=_,t[17]=v):v=t[17],v};function Qm(e,t){let n=Math.PI*2*t/Ym;return{x:Math.cos(n),y:Math.sin(n),delay:t*18}}var $m=e=>{let t=(0,Q.c)(13),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{durationMs:r}=n,i=r===void 0?3400:r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={isActive:!1,cycle:0},t[2]=a):a=t[2];let[o,s]=Z.useState(a),c=Z.useRef(null),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current&&=(window.clearTimeout(c.current),null)},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{u(),s(eh)},t[4]=d):d=t[4];let f=d,p;t[5]===i?p=t[6]:(p=()=>{u(),s(th),c.current=window.setTimeout(()=>{s(nh),c.current=null},i)},t[5]=i,t[6]=p);let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>()=>u(),g=[u],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _;return t[9]!==o.cycle||t[10]!==o.isActive||t[11]!==m?(_={isActive:o.isActive,burstKey:o.cycle,triggerFireworks:m,dismissFireworks:f},t[9]=o.cycle,t[10]=o.isActive,t[11]=m,t[12]=_):_=t[12],_};function eh(e){return e.isActive?{...e,isActive:!1}:e}function th(e){return{isActive:!0,cycle:e.cycle+1}}function nh(e){return e.isActive?{...e,isActive:!1}:e}var rh=Z.createContext(void 0),ih=e=>{let t=(0,Q.c)(10),{children:n}=e,{isActive:r,burstKey:i,triggerFireworks:a,dismissFireworks:o}=$m(),s;t[0]!==o||t[1]!==a?(s={triggerFireworks:a,dismissFireworks:o},t[0]=o,t[1]=a,t[2]=s):s=t[2];let c=s,l;t[3]!==i||t[4]!==r?(l=(0,$.jsx)(Zm,{isActive:r,burstKey:i}),t[3]=i,t[4]=r,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==l||t[8]!==c?(u=(0,$.jsxs)(rh.Provider,{value:c,children:[n,l]}),t[6]=n,t[7]=l,t[8]=c,t[9]=u):u=t[9],u},ah=()=>{let e=Z.useContext(rh);if(!e)throw Error(`useFireworksCelebration must be used within FireworksProvider`);return e},oh=`gitmojiCache`,sh=6048e5,ch=`1`,lh=`https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json`,uh=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.emoji==`string`&&typeof t.code==`string`&&typeof t.description==`string`},dh=()=>{if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(oh);if(!e)return null;let t=JSON.parse(e);return!t||t.version!==ch||typeof t.fetchedAt!=`number`||!Array.isArray(t.gitmojis)?null:{gitmojis:t.gitmojis.filter(uh),fetchedAt:t.fetchedAt,version:t.version}}catch{return null}},fh=e=>{if(!(typeof window>`u`))try{let t={gitmojis:e,fetchedAt:Date.now(),version:ch};window.localStorage.setItem(oh,JSON.stringify(t))}catch{return}},ph=e=>Date.now()-e.fetchedAt<sh,mh=null,hh=new Set,gh=async()=>{if(mh)return mh;let e=(async()=>{try{let e=await fetch(lh);if(!e.ok)throw Error(`Failed to load gitmojis: ${e.statusText}`);let t=await e.json(),n=Array.isArray(t.gitmojis)?t.gitmojis.filter(uh):[];return fh(n),hh.forEach(e=>e(n)),n}catch(e){console.warn(`Failed to load gitmoji list:`,e);let t=[];return hh.forEach(e=>e(t)),t}finally{mh=null}})();return mh=e,e},_h=e=>{let[t,n]=Z.useState(()=>e?dh()?.gitmojis??[]:[]),[r,i]=Z.useState(!1),a=Z.useRef(e);return a.current=e,Z.useEffect(()=>{if(!e){hh.delete(n),n([]),i(!1);return}let t=dh();if(t&&(n(t.gitmojis),ph(t)))return;hh.add(n),i(!0);let r=!1;return gh().finally(()=>{!r&&a.current&&i(!1)}),()=>{r=!0,hh.delete(n)}},[e]),{gitmojis:t,isLoading:r,ensureLoaded:Z.useCallback(async()=>{if(!a.current)return[];if(t.length>0)return t;let e=dh();return e&&ph(e)?e.gitmojis:gh()},[t])}},vh=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)};function yh(e,t,n){let r=(0,Q.c)(5),[i,a]=Z.useState(),o,s;return r[0]!==n||r[1]!==e||r[2]!==t?(o=()=>{if(t){a(void 0);return}if(!e){a(void 0);return}a(void 0);let r=!1;return(async()=>{let[t,i]=await Promise.all([Xi(e),Yi(e)]).catch(bh);if(r)return;let o=vh(t),s=vh(i);if(!o||!s||s===o)return;let c=n||``,l=s.split(`/`).filter(Boolean).pop()||s;a({source:`sdk`,path:s,projectDirectory:o,branch:c,label:c||l,name:l,worktreeRoot:s,worktreeStatus:`ready`,headState:c?`branch`:`unborn`,worktreeSource:`existing`})})(),()=>{r=!0}},s=[e,t,n],r[0]=n,r[1]=e,r[2]=t,r[3]=o,r[4]=s):(o=r[3],s=r[4]),Z.useEffect(o,s),t??i}function bh(){return[``,``]}function xh(e,t,n){let r=(0,Q.c)(15),i=xt(),a=i?.entry.location.hostId?i.entry:void 0,o=yh(a?void 0:e,a?void 0:t,a?void 0:n),s,c,l;r[0]!==n||r[1]!==e||r[2]!==a?(s=St(a),l=bt,c=s.key([`project-worktree-metadata`,e,n]),r[0]=n,r[1]=e,r[2]=a,r[3]=s,r[4]=c,r[5]=l):(s=r[3],c=r[4],l=r[5]);let u=!!(a&&e),d;r[6]!==n||r[7]!==e||r[8]!==a||r[9]!==s?(d=async t=>{let{signal:r}=t;if(!e||!a)throw Error(`Project worktree scope required`);let[i,o]=await Promise.all([`primary-root`,`toplevel`].map(t=>s.json(`/api/git/${t}`,{query:{directory:e},headers:{"x-opencode-directory":e},signal:r})));return!i.root||!o.root||i.root===o.root?null:{source:`sdk`,path:o.root,projectDirectory:i.root,branch:n??``,label:n||o.root,worktreeRoot:o.root,worktreeStatus:`ready`,headState:n?`branch`:`unborn`,worktreeSource:`existing`}},r[6]=n,r[7]=e,r[8]=a,r[9]=s,r[10]=d):d=r[10];let f;r[11]!==c||r[12]!==u||r[13]!==d?(f={queryKey:c,enabled:u,queryFn:d,staleTime:3e4},r[11]=c,r[12]=u,r[13]=d,r[14]=f):f=r[14];let p=l(f);return a?p.data??void 0:o}var Sh=({open:e,onOpenChange:t,directory:n,hasUncommittedChanges:r,hasStagedChanges:i=!1,uncommittedFileCount:a,onChanged:o})=>{let{t:s}=Pr(),{applyGitStash:c,countGitStashFiles:l,dropGitStash:u,listGitStashes:d,popGitStash:f,stashGitChanges:p}=di(),{isMobile:m}=pi(),[h,g]=Z.useState([]),[_,v]=Z.useState(!1),[y,b]=Z.useState(``),[x,S]=Z.useState(``),[C,w]=Z.useState(null),[T,E]=Z.useState({}),D=Z.useCallback(async()=>{if(n){v(!0);try{let e=await d(n);g(e.stashes),E({})}catch(e){Y.error(e instanceof Error?e.message:s(`gitView.stashes.toast.loadFailed`))}finally{v(!1)}}},[n,s]);Z.useEffect(()=>{e&&D()},[D,e]),Z.useEffect(()=>{if(!e||!n||h.length===0)return;let t=!1,r=h.map(e=>e.ref);return l(n,r).then(e=>{t||E(e.counts)}).catch(()=>void 0),()=>{t=!0}},[n,e,h]);let O=Z.useMemo(()=>{let e=y.trim().toLowerCase();return e?h.filter(t=>`${t.ref} ${t.message} ${t.relativeTime}`.toLowerCase().includes(e)):h},[y,h]),k=Z.useCallback(async e=>{await D(),await o?.(e)},[D,o]),A=async()=>{if(!(!n||C)){w(`create`);try{let e=await p(n,{message:x.trim()||void 0});e.created?(Y.success(s(`gitView.stashes.toast.created`)),S(``)):Y.info(s(`gitView.stashes.toast.noChanges`)),await k({affectsIndex:!!(e.created&&i)})}catch(e){Y.error(e instanceof Error?e.message:s(`gitView.stashes.toast.createFailed`))}finally{w(null)}}},j=async(e,t)=>{if(!(!n||C)&&!(t===`drop`&&!window.confirm(s(`gitView.stashes.confirm.drop`,{ref:e.ref})))){w(`${t}:${e.ref}`);try{t===`apply`&&await c(n,{ref:e.ref}),t===`pop`&&await f(n,{ref:e.ref}),t===`drop`&&await u(n,{ref:e.ref});let r=t===`apply`?`gitView.stashes.toast.applySuccess`:t===`pop`?`gitView.stashes.toast.popSuccess`:`gitView.stashes.toast.dropSuccess`;Y.success(s(r)),await k({affectsIndex:t!==`drop`})}catch(e){let n=t===`apply`?`gitView.stashes.toast.applyFailed`:t===`pop`?`gitView.stashes.toast.popFailed`:`gitView.stashes.toast.dropFailed`;Y.error(e instanceof Error?e.message:s(n)),await k({affectsIndex:t!==`drop`})}finally{w(null)}}},M=C!==null;return(0,$.jsx)($r,{open:e,onOpenChange:t,children:(0,$.jsxs)(Xr,{presentation:m?`default`:`picker`,className:m?`max-w-2xl max-h-[70vh] flex flex-col`:void 0,children:[(0,$.jsx)(Jr,{className:`yuri-picker-header`,children:(0,$.jsx)(Zr,{className:`yuri-picker-title`,children:s(`gitView.stashes.title`)})}),(0,$.jsxs)(`div`,{className:`yuri-picker-form`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(ya,{value:x,onChange:e=>S(e.target.value),placeholder:s(`gitView.stashes.messagePlaceholder`),disabled:M||!r,className:`flex-1`}),(0,$.jsxs)(q,{onClick:A,disabled:!r||M||!n,children:[C===`create`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`inbox-archive`,className:`size-4`}),s(`gitView.stashes.actions.stashCurrentWithCount`,{count:a})]})]}),(0,$.jsx)(`p`,{className:`yuri-picker-meta typography-meta mt-2 text-muted-foreground`,children:s(`gitView.stashes.includeUntrackedHint`)})]}),(0,$.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(ya,{value:y,onChange:e=>b(e.target.value),placeholder:s(`gitView.stashes.searchPlaceholder`),className:`pl-9`})]}),(0,$.jsx)(`div`,{className:`yuri-picker-list flex-1 overflow-y-auto`,children:_?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted-foreground`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin`})}):O.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-muted-foreground`,children:s(y?`gitView.stashes.empty.search`:`gitView.stashes.empty.list`)}):O.map((e,t)=>(0,$.jsxs)(`div`,{className:`yuri-picker-row group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`yuri-picker-label typography-small truncate text-foreground`,children:e.message||s(`gitView.stashes.untitled`)}),(0,$.jsxs)(`p`,{className:`yuri-picker-meta typography-meta truncate text-muted-foreground`,children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{children:t===0&&!y.trim()?s(`gitView.stashes.latestLabel`):s(`gitView.stashes.itemNumber`,{number:t+1})})}),(0,$.jsx)(ti,{sideOffset:6,children:e.ref})]}),` · `,e.relativeTime,` · `,typeof T[e.ref]==`number`?s(`gitView.stashes.fileCount`,{count:T[e.ref]}):s(`gitView.stashes.fileCountLoading`)]})]}),(0,$.jsxs)(`div`,{className:`mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100`,children:[(0,$.jsx)(Ch,{label:s(`gitView.stashes.actions.apply`),loading:C===`apply:${e.ref}`,onClick:()=>j(e,`apply`),disabled:M,children:(0,$.jsx)(X,{name:`inbox-unarchive`,className:`size-4`})}),(0,$.jsx)(Ch,{label:s(`gitView.stashes.actions.pop`),loading:C===`pop:${e.ref}`,onClick:()=>j(e,`pop`),disabled:M,children:(0,$.jsx)(X,{name:`inbox-unarchive-fill`,className:`size-4`})}),(0,$.jsx)(Ch,{label:s(`gitView.stashes.actions.drop`),loading:C===`drop:${e.ref}`,onClick:()=>j(e,`drop`),disabled:M,destructive:!0,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})})]})]},e.ref))})]})})},Ch=e=>{let t=(0,Q.c)(17),{label:n,loading:r,disabled:i,destructive:a,onClick:o,children:s}=e,c=r||void 0,l=a?`text-[var(--status-error)] hover:text-[var(--status-error)]`:`text-muted-foreground hover:text-foreground`,u;t[0]===l?u=t[1]:(u=J(`flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50`,l),t[0]=l,t[1]=u);let d;t[2]!==s||t[3]!==r?(d=r?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):s,t[2]=s,t[3]=r,t[4]=d):d=t[4];let f;t[5]!==i||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==u||t[10]!==d?(f=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":n,"aria-busy":c,className:u,onClick:o,disabled:i,children:d})}),t[5]=i,t[6]=n,t[7]=o,t[8]=c,t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;t[12]===n?p=t[13]:(p=(0,$.jsx)(ti,{sideOffset:6,children:n}),t[12]=n,t[13]=p);let m;return t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(ri,{children:[f,p]}),t[14]=f,t[15]=p,t[16]=m):m=t[16],m},wh=e=>{let t=(0,Q.c)(16),{onOpenStashes:n}=e,{t:r}=Pr(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(X,{name:`git-commit`,className:`size-10 text-muted-foreground/70 mb-4`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`gitView.empty.cleanTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground mb-1`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`gitView.empty.cleanDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mb-4`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==n||t[10]!==r?(l=n?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:n,className:`gap-1.5`,children:[(0,$.jsx)(X,{name:`archive-stack`,className:`size-4`}),r(`gitView.stashes.title`)]}):null,t[9]=n,t[10]=r,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 px-4 text-center`,children:[i,o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u},Th=8,Eh=e=>{let t=(0,Q.c)(18),{laned:n,totalLanes:r,isExpanded:i}=e,{lane:a,color:o,connectors:s}=n,c=Math.max(r,a+1)*Th+Th/2,l=Z.useRef(null),u=Z.useRef(null),d;t[0]!==o||t[1]!==s||t[2]!==a||t[3]!==c?(d=()=>{let e=l.current,t=u.current;if(!e||!t)return;let n=e.offsetHeight;if(n===0)return;let r=window.devicePixelRatio||1;t.width=c*r,t.height=n*r;let i=t.getContext(`2d`);if(!i)return;i.scale(r,r),i.clearRect(0,0,c,n);let d=n/2,f=a*Th+Th/2,p=getComputedStyle(t),m=p.getPropertyValue(`--surface-muted-foreground`).trim()||p.color,h=e=>{if(!e.startsWith(`var(`))return e;let t=e.slice(4,-1).trim();return p.getPropertyValue(t).trim()||m},g=[...s].sort(Oh);for(let e of g){let t=e.fromLane*Th+Th/2,r=e.toLane*Th+Th/2,a=e.type===`passing`?.72:e.type===`branch-out`||e.type===`merge-in`?.95:1;i.beginPath(),i.strokeStyle=h(e.color),i.globalAlpha=a,i.lineWidth=1.25,i.lineCap=`round`;bb64:switch(e.type){case`passing`:case`commit-lane`:i.moveTo(t,0),i.lineTo(t,n);break bb64;case`top-stub`:i.moveTo(t,0),i.lineTo(t,d);break bb64;case`bottom-stub`:i.moveTo(t,d),i.lineTo(t,n);break bb64;case`branch-out`:{let e=(d+n)/2;i.moveTo(f,d),i.bezierCurveTo(f,e,r,e,r,n);break bb64}case`merge-in`:{let e=d/2;i.moveTo(t,0),i.bezierCurveTo(t,e,f,e,f,d);break bb64}default:continue}i.stroke(),i.globalAlpha=1}let _=p.getPropertyValue(`--background`).trim()||p.getPropertyValue(`--surface-background`).trim();i.beginPath(),i.arc(f,d,4,0,Math.PI*2),i.fillStyle=h(o),i.fill(),i.beginPath(),i.arc(f,d,5,0,Math.PI*2),i.strokeStyle=_||m,i.lineWidth=2,i.stroke()},t[0]=o,t[1]=s,t[2]=a,t[3]=c,t[4]=d):d=t[4];let f;t[5]!==o||t[6]!==s||t[7]!==i||t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==c?(f=[n,a,o,s,r,i,c],t[5]=o,t[6]=s,t[7]=i,t[8]=a,t[9]=n,t[10]=r,t[11]=c,t[12]=f):f=t[12],Z.useLayoutEffect(d,f);let p;t[13]===c?p=t[14]:(p={width:c,height:`100%`,position:`relative`,flexShrink:0,overflow:`hidden`},t[13]=c,t[14]=p);let m;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`canvas`,{ref:u,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,display:`block`}}),t[15]=m):m=t[15];let h;return t[16]===p?h=t[17]:(h=(0,$.jsx)(`div`,{ref:l,style:p,children:m}),t[16]=p,t[17]=h),h};function Dh(e){return e===`branch-out`||e===`merge-in`}function Oh(e,t){let n=Dh;return!!n(e.type)-+!!n(t.type)}var kh=15e3,Ah=500,jh=12,Mh=8388608,Nh=e=>typeof e==`string`?0:(e.original?.length??0)+(e.modified?.length??0),Ph=e=>{if(e.size<=jh){let t=0;for(let n of e.values())t+=Nh(n);if(t<=Mh)return e}let t=Array.from(e.entries()).reverse(),n=new Map,r=0;for(let[e,i]of t){if(n.size>=jh)continue;let t=Nh(i);r+t>Mh&&n.size>0||(n.set(e,i),r+=t)}return new Map(Array.from(n.entries()).reverse())};function Fh(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?e:Ws(n,t,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Ih(e){switch(e){case`A`:return`text-[var(--status-success)]`;case`D`:return`text-[var(--status-error)]`;case`M`:return`text-[var(--status-warning)]`;case`R`:return`text-[var(--status-info)]`;default:return`text-muted-foreground`}}function Lh(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.startsWith(`HEAD ->`);return{label:t?e.replace(`HEAD -> `,``):e.replace(`tag: `,``),isHead:t,isTag:e.startsWith(`tag: `)}}):[]}var Rh=Z.memo(({entry:e,mode:t=`history`,laned:n,totalLanes:r,isExpanded:i,onToggle:a,files:o,isLoadingFiles:s,onCopyHash:c,directory:l,onConflict:u,onActionSuccess:d})=>{let{t:f}=Pr(),p=di(),{getCommitFileDiff:m}=p,h=K(e=>e.timeFormatPreference),g=t===`graph`,[_,v]=Z.useState(null),[y,b]=Z.useState(!1),[x,S]=Z.useState(``),[C,w]=Z.useState(null),[T,E]=Z.useState(new Set),[D,O]=Z.useState(new Map),[k,A]=Z.useState(new Set),j=async()=>{if(l){v(`checkout`);try{await p.checkoutCommit(l,e.hash),Y.success(f(`gitView.history.actions.detachedHead`)),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},M=async()=>{if(!(!l||!x.trim())){v(`createBranch`);try{await p.createBranch(l,x.trim(),e.hash),b(!1),S(``),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},N=async()=>{if(l){v(`cherryPick`);try{let t=await p.cherryPick(l,e.hash);t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`cherry-pick`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},P=async()=>{if(l){v(`revert`);try{let t=await p.revertCommit(l,e.hash);t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`revert`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},F=async(t,n=!1)=>{if(!(!l||_!==null)){v(`reset`);try{await p.resetToCommit(l,e.hash,t,n),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},I=async()=>{if(!C)return;let e=C;switch(w(null),e){case`checkout`:return j();case`cherryPick`:return N();case`revert`:return P();case`merge`:return L();case`rebase`:return R();case`resetSoft`:return F(`soft`);case`resetMixed`:return F(`mixed`);case`resetHard`:return F(`hard`,!0)}},L=async()=>{if(l){v(`merge`);try{let t=await p.merge(l,{branch:e.hash});t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`merge`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},R=async()=>{if(l){v(`rebase`);try{let t=await p.rebase(l,{onto:e.hash});t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`rebase`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},z=Z.useCallback(async t=>{let n=t.path;if(!l){O(e=>new Map(e).set(n,`error`));return}O(e=>Ph(new Map(e).set(n,`loading`)));try{let r=m(l,e.hash,t.path,!1),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${kh}ms`)),kh)}),a=await Promise.race([r,i]);O(e=>Ph(new Map(e).set(n,a)))}catch{O(e=>new Map(e).set(n,`error`))}},[l,e.hash]),ee=Z.useCallback(async e=>{let t=e.path;if(e.changeType===`R`||e.isBinary){E(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});return}let n=D.get(t);if(T.has(t)&&n&&n!==`error`){E(e=>{let n=new Set(e);return n.delete(t),n});return}E(e=>{let n=new Set(e);return n.add(t),n}),!(n&&n!==`error`)&&(e.insertions+e.deletions>Ah&&!k.has(t)||await z(e))},[D,k,z,T]);return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:J(`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors`,g?`hover:bg-[var(--interactive-hover)]/40`:i?`bg-sidebar/90`:`hover:bg-sidebar/40`),children:[g&&n&&r!==void 0?(0,$.jsx)(`div`,{className:`-my-2 shrink-0 self-stretch`,children:(0,$.jsx)(Eh,{laned:n,totalLanes:r,isExpanded:i})}):(0,$.jsx)(`div`,{className:`h-2 w-2 translate-y-2 rounded-full shrink-0`,style:{backgroundColor:`var(--status-success)`},"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g?(()=>{let t=Lh(e.refs);return t.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-0.5`,children:t.map(e=>(0,$.jsx)(`span`,{className:J(`inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium`,e.isHead?`bg-[var(--chart-1)] text-[var(--primary-foreground)]`:e.isTag?`bg-[var(--chart-5)] text-[var(--primary-foreground)]`:`bg-[var(--interactive-hover)] text-[var(--foreground)]`),children:e.label},e.label))}):null})():null,(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground line-clamp-1`,children:e.message}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 typography-meta text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate min-w-[3ch]`,title:e.author_name,children:e.author_name}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`}),(0,$.jsx)(`span`,{className:`truncate min-w-0`,title:Fh(e.date,h),children:Fh(e.date,h)})]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`}),(0,$.jsx)(`code`,{className:`shrink-0 font-mono`,children:e.hash.slice(0,8)}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-5 px-1 shrink-0`,onClick:t=>{t.stopPropagation(),c(e.hash)},children:(0,$.jsx)(X,{name:`file-copy`,className:`size-3`})})}),(0,$.jsx)(ti,{sideOffset:8,children:f(`gitView.history.copySha`)})]})]})]})]}),i&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 pl-8 border-t border-border/40`,children:[g&&C?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-2 border-b border-border/30 mb-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground flex-1 min-w-0`,children:f(`gitView.history.actions.${C}Confirm`)}),(0,$.jsxs)(q,{variant:`destructive`,size:`xs`,className:`h-6 shrink-0`,disabled:_!==null,onClick:e=>{e.stopPropagation(),I()},children:[_===null?null:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}),f(`gitView.history.actions.confirmButton`)]}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`h-6 shrink-0`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(null)},children:f(`gitView.history.actions.cancelButton`)})]}):g?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`checkout`)},children:f(`gitView.history.actions.checkout`)}),y?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{autoFocus:!0,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(),e.key===`Escape`&&(b(!1),S(``))},placeholder:f(`gitView.history.actions.createBranchPlaceholder`),className:`h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32`}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:!x.trim()||_!==null,onClick:e=>{e.stopPropagation(),M()},children:[_===`createBranch`?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}):null,f(`gitView.history.actions.createBranchConfirm`)]})]}):(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,onClick:e=>{e.stopPropagation(),b(!0)},children:f(`gitView.history.actions.createBranch`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`cherryPick`)},children:f(`gitView.history.actions.cherryPick`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`revert`)},children:f(`gitView.history.actions.revert`)}),(0,$.jsxs)(wi,{children:[(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>e.stopPropagation(),children:[_===`reset`?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}):null,f(`gitView.history.actions.reset`)]})}),(0,$.jsx)(xi,{align:`start`,className:`min-w-max`,children:[`soft`,`mixed`,`hard`].map(e=>(0,$.jsx)(Si,{disabled:_!==null,onSelect:t=>{t.stopPropagation(),w(`reset${e.charAt(0).toUpperCase()+e.slice(1)}`)},children:f(`gitView.history.actions.reset${e.charAt(0).toUpperCase()+e.slice(1)}`)},e))})]}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`merge`)},children:f(`gitView.history.actions.merge`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`rebase`)},children:f(`gitView.history.actions.rebase`)})]}):null,s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:f(`gitView.history.loadingFiles`)})]}):o.length===0?(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground py-2`,children:f(`gitView.history.noFiles`)}):(0,$.jsx)(`ul`,{className:`space-y-0.5 py-2`,children:o.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(e),className:J(`w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1`,T.has(e.path)?`bg-sidebar/90`:`hover:bg-sidebar/40`),children:[(0,$.jsx)(`span`,{className:J(`font-semibold w-3 text-center shrink-0`,Ih(e.changeType)),children:e.changeType}),(0,$.jsx)(`span`,{className:`truncate text-foreground min-w-0`,title:e.path,children:e.path}),!e.isBinary&&(0,$.jsxs)(`span`,{className:`shrink-0`,children:[(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,e.insertions]}),(0,$.jsx)(`span`,{className:`text-muted-foreground mx-0.5`,children:`/`}),(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,e.deletions]})]}),e.isBinary&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:f(`gitView.history.binary`)}),(0,$.jsx)(X,{name:T.has(e.path)?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),T.has(e.path)&&(0,$.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.changeType===`R`?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.renamedNoDiff`)}):e.isBinary?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.binaryNoDiff`)}):(()=>{let t=e.insertions+e.deletions;if(!k.has(e.path)&&t>Ah)return(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`gitView.history.largeDiffTitle`,{count:t})}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:f(`gitView.history.largeDiffDescription`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`h-6 px-0 text-primary hover:bg-transparent hover:underline`,onClick:()=>{A(t=>new Set(t).add(e.path)),z(e)},children:f(`gitView.history.renderDiffAnyway`)})]});let n=D.get(e.path);return n===`loading`||n===void 0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.loadingDiff`)}):n===`error`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>ee(e),className:`w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors`,children:f(`gitView.history.diffError`)}):(0,$.jsx)(Fi,{original:n.original,modified:n.modified,language:Lr(e.path)||``,fileName:e.path,renderSideBySide:!1,layout:`inline`,enableComments:!1})})()})]},e.path))})]})]})}),zh=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`,`var(--syntax-keyword)`,`var(--syntax-string)`,`var(--status-info)`];function Bh(e){return zh[e%zh.length]}function Vh(e){if(e.length===0)return[];let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r],a=[];for(let e=0;e<t.length;e++)t[e]===i.hash&&a.push(e);let o=a.length>0?a[0]:-1;if(o===-1){let e=t.indexOf(null);e===-1?(o=t.length,t.push(null)):o=e}let s=a.slice(1),c=Bh(o),l=t[o]===i.hash,u=i.parents.length>0;u?t[o]=i.parents[0]:t[o]=null;let d=[];for(let e=1;e<i.parents.length;e++){let n=i.parents[e],r=t.indexOf(n);if(r!==-1)d.push(r);else{let e=t.indexOf(null),r=e===-1?t.length:e;t[r]=n,r===t.length&&t.push(n),d.push(r)}}let f=[];l&&u?f.push({fromLane:o,toLane:o,color:c,type:`commit-lane`}):l&&!u?f.push({fromLane:o,toLane:o,color:c,type:`top-stub`}):!l&&u&&f.push({fromLane:o,toLane:o,color:c,type:`bottom-stub`});for(let e of s)f.push({fromLane:e,toLane:o,color:Bh(e),type:`merge-in`}),t[e]=null;for(let e of d)f.push({fromLane:o,toLane:e,color:Bh(e),type:`branch-out`});for(let e=0;e<t.length;e++)t[e]!==null&&e!==o&&(d.includes(e)||f.push({fromLane:e,toLane:e,color:Bh(e),type:`passing`}));n.push({commit:i,lane:o,color:c,connectors:f})}return n}var Hh=[{labelKey:`gitView.history.logSize25`,value:25},{labelKey:`gitView.history.logSize50`,value:50},{labelKey:`gitView.history.logSize100`,value:100}],Uh=e=>{let t=(0,Q.c)(84),{mode:n,log:r,isLogLoading:i,logMaxCount:a,onLogMaxCountChange:o,expandedCommitHashes:s,onToggleCommit:c,commitFilesMap:l,loadingCommitHashes:u,onCopyHash:d,directory:f,showHeader:p,contentMaxHeightClassName:m,branchDivider:h,onConflict:g,onActionSuccess:_}=e,v=n===void 0?`history`:n,y=p===void 0||p,b=m===void 0?`max-h-[50vh]`:m,x=h===void 0?null:h,{t:S}=Pr(),[C,w]=Z.useState(!0),T=v===`graph`,E;t[0]!==T||t[1]!==r?(E=T&&r?Vh(r.all):[],t[0]=T,t[1]=r,t[2]=E):E=t[2];let D=E,O;t[3]===D?O=t[4]:(O=Math.max(1,...D.map(Wh)),t[3]=D,t[4]=O);let k=O,A;t[5]===D?A=t[6]:(A=new Map(D.map(Gh)),t[5]=D,t[6]=A);let j=A;if(!r)return null;let M=x!==null&&x.insertBeforeIndex>0&&x.insertBeforeIndex<r.all.length,N=x!==null&&x.insertBeforeIndex===r.all.length,P=M||N,F;t[7]!==x||t[8]!==M||t[9]!==N||t[10]!==r.all?(F=M?r.all.slice(0,x.insertBeforeIndex):N?r.all:[],t[7]=x,t[8]=M,t[9]=N,t[10]=r.all,t[11]=F):F=t[11];let I=F,L;if(t[12]!==x||t[13]!==l||t[14]!==b||t[15]!==f||t[16]!==s||t[17]!==M||t[18]!==P||t[19]!==T||t[20]!==i||t[21]!==j||t[22]!==u||t[23]!==r.all||t[24]!==a||t[25]!==k||t[26]!==v||t[27]!==_||t[28]!==g||t[29]!==d||t[30]!==o||t[31]!==c||t[32]!==S||t[33]!==I){let e=M?r.all.slice(x.insertBeforeIndex):[],n;t[35]===x?.direction?n=t[36]:(n=x?.direction===`down`?(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-3.5`}):(0,$.jsx)(X,{name:`arrow-up`,className:`size-3.5`}),t[35]=x?.direction,t[36]=n);let p=n,m;t[37]!==l||t[38]!==f||t[39]!==s||t[40]!==T||t[41]!==j||t[42]!==u||t[43]!==k||t[44]!==v||t[45]!==_||t[46]!==g||t[47]!==d||t[48]!==c?(m=e=>(0,$.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,$.jsx)(Rh,{entry:e,mode:v,laned:T?j.get(e.hash):void 0,totalLanes:T?k:void 0,isExpanded:s.has(e.hash),onToggle:()=>c(e.hash),files:l.get(e.hash)??[],isLoadingFiles:u.has(e.hash),onCopyHash:d,directory:f,onConflict:g,onActionSuccess:_},e.hash))}),t[37]=l,t[38]=f,t[39]=s,t[40]=T,t[41]=j,t[42]=u,t[43]=k,t[44]=v,t[45]=_,t[46]=g,t[47]=d,t[48]=c,t[49]=m):m=t[49];let h=m,y;t[50]!==i||t[51]!==r.all.length||t[52]!==a||t[53]!==o||t[54]!==S?(y=r.all.length>=a?(0,$.jsx)(`div`,{className:`flex justify-center py-2 border-t border-border/40`,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>o(a+25),disabled:i,className:`px-3 text-muted-foreground hover:text-foreground`,children:i?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`}),S(`gitView.history.loadingMore`)]}):S(`gitView.history.loadMore`)})}):null,t[50]=i,t[51]=r.all.length,t[52]=a,t[53]=o,t[54]=S,t[55]=y):y=t[55];let C=y;L=(0,$.jsx)(Gr,{outerClassName:`min-h-0 ${b}`,className:`h-full w-full`,children:r.all.length===0?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:S(`gitView.history.noCommits`)})}):P&&x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0`,children:[I.length>0?(0,$.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:h(I)}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/60`}),(0,$.jsxs)(`span`,{className:`inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate`,title:x.branchName,children:x.branchName}),p]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/60`})]}),e.length>0?(0,$.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:h(e)}):null]}),C]}):(0,$.jsxs)($.Fragment,{children:[h(r.all),C]})}),t[12]=x,t[13]=l,t[14]=b,t[15]=f,t[16]=s,t[17]=M,t[18]=P,t[19]=T,t[20]=i,t[21]=j,t[22]=u,t[23]=r.all,t[24]=a,t[25]=k,t[26]=v,t[27]=_,t[28]=g,t[29]=d,t[30]=o,t[31]=c,t[32]=S,t[33]=I,t[34]=L}else L=t[34];let R=L;if(!y){if(P){let e;return t[56]===R?e=t[57]:(e=(0,$.jsx)(`section`,{className:`h-full min-h-0`,children:R}),t[56]=R,t[57]=e),e}let e;return t[58]===R?e=t[59]:(e=(0,$.jsx)(`section`,{className:`h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:R}),t[58]=R,t[59]=e),e}let z;t[60]===S?z=t[61]:(z=S(`gitView.history.title`),t[60]=S,t[61]=z);let ee;t[62]===z?ee=t[63]:(ee=(0,$.jsx)(`h3`,{className:`typography-ui-header font-semibold text-foreground`,children:z}),t[62]=z,t[63]=ee);let B;t[64]!==i||t[65]!==C||t[66]!==a||t[67]!==o||t[68]!==S?(B=C&&(0,$.jsx)(`div`,{onClick:Kh,onPointerDown:qh,children:(0,$.jsxs)(Fs,{value:String(a),onValueChange:e=>o(Number(e)),disabled:i,children:[(0,$.jsx)(Ps,{size:`sm`,className:`data-[size=sm]:h-auto h-7 min-h-7 w-auto justify-between px-2 py-0`,disabled:i,children:(0,$.jsx)(js,{placeholder:S(`gitView.history.commitsPlaceholder`)})}),(0,$.jsx)(Ns,{children:Hh.map(e=>(0,$.jsx)(Ms,{value:String(e.value),children:S(e.labelKey)},e.value))})]})}),t[64]=i,t[65]=C,t[66]=a,t[67]=o,t[68]=S,t[69]=B):B=t[69];let V;t[70]===C?V=t[71]:(V=C?(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 text-muted-foreground`}),t[70]=C,t[71]=V);let te;t[72]!==B||t[73]!==V?(te=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B,V]}),t[72]=B,t[73]=V,t[74]=te):te=t[74];let ne;t[75]!==ee||t[76]!==te?(ne=(0,$.jsxs)(ji,{className:`flex w-full items-center justify-between px-3 h-10 hover:bg-transparent`,children:[ee,te]}),t[75]=ee,t[76]=te,t[77]=ne):ne=t[77];let re;t[78]===R?re=t[79]:(re=(0,$.jsx)(Ai,{children:R}),t[78]=R,t[79]=re);let ie;return t[80]!==C||t[81]!==ne||t[82]!==re?(ie=(0,$.jsxs)(Mi,{open:C,onOpenChange:w,className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:[ne,re]}),t[80]=C,t[81]=ne,t[82]=re,t[83]=ie):ie=t[83],ie};function Wh(e){return e.lane+1}function Gh(e){return[e.commit.hash,e]}function Kh(e){return e.stopPropagation()}function qh(e){return e.stopPropagation()}var Jh=e=>{let t=(0,Q.c)(154),{open:n,onOpenChange:r,conflictFiles:i,directory:a,operation:o,onAbort:s,onClearState:c}=e,l;t[0]===i?l=t[1]:(l=i===void 0?[]:i,t[0]=i,t[1]=l);let u=l,{t:d}=Pr(),{getConflictDetails:f}=di(),p=Jn(Yh),m=Jn(Xh),h=Ir(Zh),g=Ir(Qh),_=K($h),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),w;t[2]!==a||t[3]!==f||t[4]!==n||t[5]!==d?(w=()=>{!n||!a||(y(!0),C(null),x(null),f(a).then(e=>{x(e)}).catch(e=>{let t=e instanceof Error?e.message:d(`gitView.conflict.loadFailed`);C(t)}).finally(()=>{y(!1)}))},t[2]=a,t[3]=f,t[4]=n,t[5]=d,t[6]=w):w=t[6];let T;t[7]!==a||t[8]!==n||t[9]!==d?(T=[n,a,d],t[7]=a,t[8]=n,t[9]=d,t[10]=T):T=t[10],Z.useEffect(w,T);let E;t[11]!==b||t[12]!==a||t[13]!==o?(E=async()=>{if(!b)return null;let e=o===`merge`?`merge`:`rebase`,t=b.headInfo||(o===`merge`?`MERGE_HEAD`:`REBASE_HEAD`),n=o===`merge`?`git commit --no-edit`:`git rebase --continue`;return{visibleText:await Ji(`git.conflict.resolve.visible`,{operation_label:e,head_ref:t}),instructionsText:await Ji(`git.conflict.resolve.instructions`,{operation_label:e,directory:a,operation:o,head_info:b.headInfo||`N/A`,continue_cmd:n}),payloadText:`${e} conflict context (JSON)\n${JSON.stringify({directory:a,operation:b.operation,headInfo:b.headInfo,statusPorcelain:b.statusPorcelain,unmergedFiles:b.unmergedFiles,diff:b.diff},null,2)}`}},t[11]=b,t[12]=a,t[13]=o,t[14]=E):E=t[14];let D=E,O;t[15]!==s||t[16]!==r?(O=()=>{s(),r(!1)},t[15]=s,t[16]=r,t[17]=O):O=t[17];let k=O,A;t[18]!==c||t[19]!==r?(A=()=>{c?.(),r(!1)},t[18]=c,t[19]=r,t[20]=A):A=t[20];let j=A,M;t[21]!==D||t[22]!==m||t[23]!==c||t[24]!==r||t[25]!==_||t[26]!==h||t[27]!==g||t[28]!==d?(M=async()=>{let e=await D();if(!e){Y.error(d(`gitView.conflict.noDetailsAvailable`));return}if(!m){Y.error(d(`gitView.conflict.noActiveSession`),{description:d(`gitView.conflict.noActiveSessionDescription`)});return}h(e.visibleText,`replace`),g([{text:e.instructionsText,synthetic:!0},{text:e.payloadText,synthetic:!0}]),_(`chat`),c?.(),r(!1)},t[21]=D,t[22]=m,t[23]=c,t[24]=r,t[25]=_,t[26]=h,t[27]=g,t[28]=d,t[29]=M):M=t[29];let N=M,P;t[30]!==D||t[31]!==a||t[32]!==c||t[33]!==r||t[34]!==p||t[35]!==_||t[36]!==d?(P=async()=>{let e=await D();if(!e){Y.error(d(`gitView.conflict.noDetailsAvailable`));return}p({directoryOverride:a,initialPrompt:e.visibleText,syntheticParts:[{text:e.instructionsText,synthetic:!0},{text:e.payloadText,synthetic:!0}]}),_(`chat`),c?.(),r(!1)},t[30]=D,t[31]=a,t[32]=c,t[33]=r,t[34]=p,t[35]=_,t[36]=d,t[37]=P):P=t[37];let F=P,I,L,R,z,ee,B,V,te,ne,re,ie,ae,H,U,oe,se,ce,le,ue,de,fe,pe;if(t[38]!==b||t[39]!==u||t[40]!==m||t[41]!==k||t[42]!==j||t[43]!==N||t[44]!==F||t[45]!==v||t[46]!==S||t[47]!==r||t[48]!==n||t[49]!==o||t[50]!==d){let e=d(o===`merge`?`gitView.operation.merge`:`gitView.operation.rebase`),i=b?.unmergedFiles||u;R=$r,fe=n,pe=r,L=Xr,de=`max-w-md w-[calc(100vw-2rem)]`,U=`flex flex-col gap-4 overflow-hidden`;let a;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`alert`,className:`size-5 shrink-0 text-[var(--status-warning)]`}),t[73]=a):a=t[73];let s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,(0,$.jsx)(Zr,{children:d(`gitView.conflict.detectedTitle`,{operation:e})})]}),c;t[74]!==o||t[75]!==d?(c=d(`gitView.conflict.detectedDescription`,{operation:o}),t[74]=o,t[75]=d,t[76]=c):c=t[76];let l;t[77]===c?l=t[78]:(l=(0,$.jsx)(Qr,{children:c}),t[77]=c,t[78]=l),t[79]!==s||t[80]!==l?(oe=(0,$.jsxs)(Jr,{children:[s,l]}),t[79]=s,t[80]=l,t[81]=oe):oe=t[81],t[82]!==v||t[83]!==d?(se=v&&(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-4 text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:d(`gitView.conflict.loading`)})]}),t[82]=v,t[83]=d,t[84]=se):se=t[84],t[85]!==S||t[86]!==d?(ce=S&&(0,$.jsx)(`div`,{className:`rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words`,children:d(`gitView.conflict.errorLoadingDetails`,{message:S})}),t[85]=S,t[86]=d,t[87]=ce):ce=t[87],t[88]!==i||t[89]!==d?(le=i.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:d(`gitView.conflict.conflictedFiles`)}),(0,$.jsx)(`span`,{className:`typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground`,children:i.length})]}),(0,$.jsx)(`div`,{className:`bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden`,children:(0,$.jsx)(`ul`,{className:`space-y-1`,children:i.map(eg)})})]}),t[88]=i,t[89]=d,t[90]=le):le=t[90],t[91]!==b||t[92]!==d?(ue=b?.headInfo&&(0,$.jsxs)(`div`,{className:`space-y-1 overflow-hidden`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:d(`gitView.conflict.headInfo`)}),(0,$.jsx)(`div`,{className:`typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap`,children:b.headInfo})]}),t[91]=b,t[92]=d,t[93]=ue):ue=t[93],ie=`flex flex-col gap-2 pt-2`;let f;t[94]===F?f=t[95]:(f=()=>{F()},t[94]=F,t[95]=f);let p=v||!b,h;t[96]===v?h=t[97]:(h=v?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[96]=v,t[97]=h);let g;t[98]===d?g=t[99]:(g=d(`gitView.conflict.resolveNewSession`),t[98]=d,t[99]=g),t[100]!==f||t[101]!==p||t[102]!==h||t[103]!==g?(ae=(0,$.jsxs)(q,{variant:`default`,onClick:f,disabled:p,className:`w-full gap-2`,children:[h,g]}),t[100]=f,t[101]=p,t[102]=h,t[103]=g,t[104]=ae):ae=t[104];let _;t[105]===N?_=t[106]:(_=()=>void N(),t[105]=N,t[106]=_);let y=v||!b||!m,x;t[107]===v?x=t[108]:(x=v?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`chat-1`,className:`size-4`}),t[107]=v,t[108]=x);let C;t[109]===d?C=t[110]:(C=d(`gitView.conflict.resolveCurrentSession`),t[109]=d,t[110]=C),t[111]!==_||t[112]!==y||t[113]!==x||t[114]!==C?(H=(0,$.jsxs)(q,{variant:`outline`,onClick:_,disabled:y,className:`w-full gap-2`,children:[x,C]}),t[111]=_,t[112]=y,t[113]=x,t[114]=C,t[115]=H):H=t[115],ne=`flex gap-2 pt-1`;let w;t[116]===d?w=t[117]:(w=d(`gitView.conflict.continueLater`),t[116]=d,t[117]=w),t[118]!==j||t[119]!==w?(re=(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:j,className:`flex-1`,children:w}),t[118]=j,t[119]=w,t[120]=re):re=t[120],I=q,z=`destructive`,ee=`sm`,B=k,V=`flex-1`,te=d(`gitView.conflict.abortOperation`,{operation:e}),t[38]=b,t[39]=u,t[40]=m,t[41]=k,t[42]=j,t[43]=N,t[44]=F,t[45]=v,t[46]=S,t[47]=r,t[48]=n,t[49]=o,t[50]=d,t[51]=I,t[52]=L,t[53]=R,t[54]=z,t[55]=ee,t[56]=B,t[57]=V,t[58]=te,t[59]=ne,t[60]=re,t[61]=ie,t[62]=ae,t[63]=H,t[64]=U,t[65]=oe,t[66]=se,t[67]=ce,t[68]=le,t[69]=ue,t[70]=de,t[71]=fe,t[72]=pe}else I=t[51],L=t[52],R=t[53],z=t[54],ee=t[55],B=t[56],V=t[57],te=t[58],ne=t[59],re=t[60],ie=t[61],ae=t[62],H=t[63],U=t[64],oe=t[65],se=t[66],ce=t[67],le=t[68],ue=t[69],de=t[70],fe=t[71],pe=t[72];let me;t[121]!==I||t[122]!==z||t[123]!==ee||t[124]!==B||t[125]!==V||t[126]!==te?(me=(0,$.jsx)(I,{variant:z,size:ee,onClick:B,className:V,children:te}),t[121]=I,t[122]=z,t[123]=ee,t[124]=B,t[125]=V,t[126]=te,t[127]=me):me=t[127];let he;t[128]!==ne||t[129]!==re||t[130]!==me?(he=(0,$.jsxs)(`div`,{className:ne,children:[re,me]}),t[128]=ne,t[129]=re,t[130]=me,t[131]=he):he=t[131];let ge;t[132]!==ie||t[133]!==ae||t[134]!==H||t[135]!==he?(ge=(0,$.jsxs)(`div`,{className:ie,children:[ae,H,he]}),t[132]=ie,t[133]=ae,t[134]=H,t[135]=he,t[136]=ge):ge=t[136];let _e;t[137]!==U||t[138]!==oe||t[139]!==se||t[140]!==ce||t[141]!==le||t[142]!==ue||t[143]!==ge?(_e=(0,$.jsxs)(`div`,{className:U,children:[oe,se,ce,le,ue,ge]}),t[137]=U,t[138]=oe,t[139]=se,t[140]=ce,t[141]=le,t[142]=ue,t[143]=ge,t[144]=_e):_e=t[144];let ve;t[145]!==L||t[146]!==de||t[147]!==_e?(ve=(0,$.jsx)(L,{className:de,children:_e}),t[145]=L,t[146]=de,t[147]=_e,t[148]=ve):ve=t[148];let ye;return t[149]!==R||t[150]!==fe||t[151]!==pe||t[152]!==ve?(ye=(0,$.jsx)(R,{open:fe,onOpenChange:pe,children:ve}),t[149]=R,t[150]=fe,t[151]=pe,t[152]=ve,t[153]=ye):ye=t[153],ye};function Yh(e){return e.openNewSessionDraft}function Xh(e){return e.currentSessionId}function Zh(e){return e.setPendingInputText}function Qh(e){return e.setPendingSyntheticParts}function $h(e){return e.setActiveMainTab}function eg(e){return(0,$.jsx)(`li`,{className:`typography-micro text-foreground font-mono truncate block`,title:e,children:e},e)}var tg=({mergeInProgress:e,rebaseInProgress:t,onContinue:n,onAbort:r,onResolveWithAI:i,hasUnresolvedConflicts:a=!1,isLoading:o=!1})=>{let{t:s}=Pr(),[c,l]=Z.useState(null),u=e&&e.head,d=t&&(t.headName||t.onto),f=u?`merge`:d?`rebase`:null;if(!f)return null;let p=async()=>{l(`continue`);try{await n()}finally{l(null)}},m=async()=>{l(`abort`);try{await r()}finally{l(null)}},h=c!==null,g=s(f===`merge`?`gitView.operation.merge`:`gitView.operation.rebase`),_=f===`merge`?`git-merge`:`git-branch`,v=``;return e?v=e.message?s(`gitView.operation.mergingMessage`,{message:e.message}):s(`gitView.operation.mergeInProgressWithHead`,{head:e.head}):t&&(v=t.headName?s(`gitView.operation.rebasingOnto`,{headName:t.headName,onto:t.onto||``}):s(`gitView.operation.rebaseInProgress`)),(0,$.jsx)(`div`,{className:`bg-[var(--status-warning-bg)] border border-[var(--status-warning)] rounded-lg p-3 mx-3 mt-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,$.jsx)(X,{name:_,className:`size-4 text-[var(--status-warning)] shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-warning)]`,children:s(`gitView.operation.inProgressTitle`,{operation:g})}),v&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&i&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,onClick:i,disabled:h||o,className:`gap-1.5`,children:[(0,$.jsx)(X,{name:`sparkling`,className:`size-4`}),s(`gitView.operation.resolveWithAi`)]}),c!==`continue`&&(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:m,disabled:h||o,className:`gap-1.5`,children:[c===`abort`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`close`,className:`size-4`}),s(`gitView.operation.abort`)]}),!a&&(0,$.jsxs)(q,{variant:`default`,size:`sm`,onClick:p,disabled:h||o,className:`gap-1.5`,children:[c===`continue`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`check`,className:`size-4`}),s(`gitView.operation.continue`)]})]}),a&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-warning)]`,children:s(`gitView.operation.resolveConflictsHint`)})]})})},ng=({runMutation:e,onMutationComplete:t,onMutationError:n,onPathsComplete:r,scheduleFlush:i})=>{let a=[],o=!1;return{enqueue:e=>{let t=a[a.length-1];if(t?.directory===e.directory&&t.direction===e.direction){e.paths.forEach(e=>t.paths.add(e));return}a.push(e)},flush:()=>{if(o)return;let s=a.shift();if(!s)return;o=!0;let c={directory:s.directory,direction:s.direction,paths:Array.from(s.paths),rollback:s.rollback};(async()=>{try{await e(c),t(c)}catch(e){n(c,e)}finally{r(c.paths),o=!1,a.length>0&&i()}})()},clear:()=>{a.length=0},size:()=>a.length,isRunning:()=>o}},rg=15e3,ig=40,ag=20,og={feat:`:sparkles:`,feature:`:sparkles:`,fix:`:bug:`,bug:`:bug:`,hotfix:`:ambulance:`,docs:`:memo:`,documentation:`:memo:`,style:`:lipstick:`,refactor:`:recycle:`,perf:`:zap:`,performance:`:zap:`,test:`:white_check_mark:`,tests:`:white_check_mark:`,build:`:construction_worker:`,ci:`:green_heart:`,chore:`:wrench:`,revert:`:rewind:`,wip:`:construction:`,security:`:lock:`,release:`:bookmark:`,merge:`:twisted_rightwards_arrows:`,mv:`:truck:`,move:`:truck:`,rename:`:truck:`,remove:`:fire:`,delete:`:fire:`,add:`:sparkles:`,create:`:sparkles:`,implement:`:sparkles:`,update:`:recycle:`,improve:`:zap:`,optimize:`:zap:`,upgrade:`:arrow_up:`,downgrade:`:arrow_down:`,deploy:`:rocket:`,init:`:tada:`,initial:`:tada:`},sg=(e,t)=>{let n=e.toLowerCase(),r=n.match(/^([a-z]+)(?:\(.*\))?!?:/);if(r){let e=og[r[1]];if(e)return t.find(t=>t.code===e)||null}let i=og[n.split(` `)[0]];return i&&t.find(e=>e.code===i)||null},cg=20,lg=new Map,ug=(e,t)=>{if(lg.delete(e),lg.set(e,t),lg.size>cg){let e=lg.keys().next().value;e!==void 0&&lg.delete(e)}},dg=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),fg=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},pg=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},mg=({isActive:e})=>{let{t}=Pr(),{git:n,projectScope:r}=Ki(),{generateCommitMessage:i,getGitWorktreeBootstrapStatus:a}=di(),o=qi(),[s,c]=Z.useState(null),[l,u]=Z.useState(!1),d=Jn(e=>e.currentSessionId),f=ln(e=>e.remoteSession?.sessionId??null),p=r?f:d,m=Jn(e=>e.newSessionDraft),h=r?null:m,g=Jn(e=>e.setDraftBootstrapPendingDirectory),_=Jn(e=>e.worktreeMetadata),v=Jn(e=>e.availableWorktrees),y=dg(o),b=Z.useMemo(()=>{if(!y)return;let e=v.find(e=>dg(e.path)===y);if(e)return e;for(let e of _.values())if(dg(e.path)===y)return e},[v,y,_]),x=Z.useMemo(()=>{if(!r){if(p)return _.get(p)??b;if(h?.open)return b}},[p,b,h?.open,_,r]),S=aa(o??null),C=ea(o??null),w=zn(e=>p&&!r?e.getAttachment(p):void 0),T=w?Tr(w):[],E=w&&!w.degraded&&!w.legacy?w.worktreeRoot??void 0:void 0,D=xh(o,x,C?.current??void 0),O=oa(o??null),k=ta(o??null),A=ia(o??null),j=na(o??null),{setActiveDirectory:N,fetchAll:P,ensureAll:F,fetchStatus:I,fetchBranches:L,fetchLog:R,setLogMaxCount:z,prefetchDiffs:ee,moveStatusPathsOptimistically:B,restoreStatus:V,bumpIndexRevision:te}=ra(je(e=>({setActiveDirectory:e.setActiveDirectory,fetchAll:e.fetchAll,ensureAll:e.ensureAll,fetchStatus:e.fetchStatus,fetchBranches:e.fetchBranches,fetchLog:e.fetchLog,setLogMaxCount:e.setLogMaxCount,prefetchDiffs:e.prefetchDiffs,moveStatusPathsOptimistically:e.moveStatusPathsOptimistically,restoreStatus:e.restoreStatus,bumpIndexRevision:e.bumpIndexRevision}))),ne=K(e=>e.isMobile),re=K(e=>e.openContextFileDiff),ie=K(e=>e.navigateToDiff),ae=K(e=>e.setRightSidebarOpen),H=Z.useRef(null),U=Z.useRef(null),oe=Z.useRef(null),se=Z.useRef(null),ce=Z.useRef(!0);Z.useEffect(()=>()=>{ce.current=!1},[]);let le=Z.useCallback(()=>{U.current!==null&&(window.clearTimeout(U.current),U.current=null)},[]),ue=Z.useCallback(e=>{le(),U.current=window.setTimeout(()=>{U.current=null,dg(e)===dg(o)&&I(e,n,{silent:!0})},rg)},[le,o,I,n]);Z.useEffect(()=>le,[le]);let de=Z.useCallback(()=>{oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null)},[]),fe=Z.useCallback(()=>{oe.current===null&&(oe.current=window.setTimeout(()=>{oe.current=null,se.current?.()},0))},[]),pe=Z.useCallback(async(e,t,r)=>{if(t===`stage`){if(n.stageGitFiles){await n.stageGitFiles(e,r);return}await Promise.all(r.map(t=>n.stageGitFile(e,t)));return}if(n.unstageGitFiles){await n.unstageGitFiles(e,r);return}await Promise.all(r.map(t=>n.unstageGitFile(e,t)))},[n]),me=Z.useMemo(()=>ng({runMutation:({directory:e,direction:t,paths:n})=>pe(e,t,n),onMutationComplete:({directory:e})=>{te(e),ue(e)},onMutationError:({directory:e,direction:n,rollback:r},i)=>{r?.(),te(e),ue(e);let a=t(n===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`);Y.error(i instanceof Error?i.message:a)},onPathsComplete:e=>{Ge(t=>{let n=new Set(t);return e.forEach(e=>n.delete(e)),n})},scheduleFlush:fe}),[te,pe,fe,ue,t]);Z.useEffect(()=>(se.current=me.flush,()=>{se.current=null}),[me]),Z.useEffect(()=>()=>me.clear(),[me]),Z.useEffect(()=>de,[de]),Z.useEffect(()=>{if(!e)return;if(!o){c(null),u(!1);return}let t=!1;if(r)return a(o).then(e=>{t||c(e.status)}).catch(()=>{t||c(null)}),()=>{t=!0};let n=_r(o);n&&c(n.status);let i=rr((e,n)=>{t||dg(e)===dg(o)&&c(n.status)});return a(o).then(e=>{if(t)return;Hn(o,e);let n=_r(o);c(n?.status??e.status)}).catch(()=>{!t&&!_r(o)&&c(null)}),()=>{t=!0,i()}},[e,o,r,a]),Z.useEffect(()=>{let e=H.current;H.current=s,!(!o||!n)&&(e===`pending`&&s===`ready`&&(u(!0),P(o,n).finally(()=>{window.setTimeout(()=>{u(!1)},1200)})),s===`failed`&&(g(null),u(!1)))},[o,P,n,g,s]);let he=dg(h?.bootstrapPendingDirectory??null),ge=!!(o&&he&&he===dg(o)),_e=!!(o&&(s===`pending`||ge))||l,ve=Z.useMemo(()=>o?lg.get(r?.key??o)??null:null,[o,r]),ye=Nn(e=>e.settingsGitmojiEnabled),[be,xe]=Z.useState(null),{gitmojis:Se}=_h(ye);Z.useEffect(()=>{let e=E||D?.projectDirectory;if(!e){xe(null);return}let t=!1;return(r?n.getGitStatus(e).then(e=>e.current??``):Bs(e)).then(e=>{if(t)return;let n=e.trim();xe(n&&n!==`HEAD`?n:null)}).catch(()=>{t||xe(null)}),()=>{t=!0}},[E,D?.projectDirectory,r,n]);let[Ce,we]=Z.useState(ve?.commitMessage??``),[Te,Ee]=Z.useState([]),[De,Oe]=Z.useState(!1),ke=ui(C)&&!De,[Ae,Me]=Z.useState(!1),Ne=Z.useRef(null),[Pe,Fe]=Z.useState(null),[Ie,Le]=Z.useState(!1),[W,Re]=Z.useState(null),[ze,Be]=Z.useState(25),{triggerFireworks:Ve}=ah(),[He,Ue]=Z.useState(new Set),[We,Ge]=Z.useState(new Set),[Ke,qe]=Z.useState(!1),[Je,Ye]=Z.useState(!1),[Xe,Ze]=Z.useState(ve?.generatedHighlights??[]),Qe=We.size>0||me.size()>0||me.isRunning(),$e=Z.useCallback(()=>{let e=Ne.current;e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:`smooth`})})})},[]),et=Z.useCallback(()=>{Ze([])},[]),[tt,nt]=Z.useState(new Set),[rt,it]=Z.useState(new Map),[at,ot]=Z.useState(new Set),st=Z.useRef(rt),ct=Z.useRef(at),[lt,ut]=Z.useState(null),[dt,ft]=Z.useState(null),[pt,mt]=Z.useState(``),[ht,gt]=Z.useState(null),[_t,vt]=Z.useState([]),[yt,bt]=Z.useState(!1),[xt,St]=Z.useState([]),[Ct,wt]=Z.useState(`merge`),[Tt,Et]=Z.useState(null),[Dt,Ot]=Z.useState(!1),[kt,At]=Z.useState(100),jt=Z.useMemo(()=>p?`yuri.conflict:${r?M(r.location,p):p}`:null,[p,r]),Mt=Z.useCallback((e,t,n)=>{if(!jt||typeof window>`u`)return;let r={directory:e,conflictFiles:t,operation:n};window.localStorage.setItem(jt,JSON.stringify(r))},[jt]),Nt=Z.useCallback(()=>{!jt||typeof window>`u`||window.localStorage.removeItem(jt)},[jt]);Z.useEffect(()=>{if(!jt||typeof window>`u`||!o)return;let e=window.localStorage.getItem(jt);if(e)try{let t=JSON.parse(e);if(t.directory!==o){window.localStorage.removeItem(jt);return}St(t.conflictFiles??[]),wt(t.operation??`merge`),bt(!0)}catch{window.localStorage.removeItem(jt)}},[jt,o]);let Pt=Z.useCallback(e=>{pr(e).then(e=>{if(e.ok){Y.success(t(`gitView.toast.commitHashCopied`));return}Y.error(t(`gitView.toast.copyFailed`))})},[t]),Ft=Z.useCallback(e=>{nt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);Z.useEffect(()=>{st.current=rt},[rt]),Z.useEffect(()=>{ct.current=at},[at]),Z.useEffect(()=>{if(!o||!n)return;let e=Array.from(tt).filter(e=>!st.current.has(e)&&!ct.current.has(e));if(e.length===0)return;let t=!1;return ot(t=>{let n=new Set(t);for(let t of e)n.add(t);return ct.current=n,n}),Promise.all(e.map(e=>n.getCommitFiles(o,e).then(t=>({hash:e,files:t.files})).catch(t=>(console.error(`Failed to fetch commit files:`,t),{hash:e,files:[]})))).then(e=>{t||(it(t=>{let n=new Map(t);for(let{hash:t,files:r}of e)n.set(t,r);return st.current=n,n}),ot(t=>{let n=new Set(t);for(let{hash:t}of e)n.delete(t);return ct.current=n,n}))}),()=>{t=!0,ot(t=>{let n=!1,r=new Set(t);for(let t of e)r.delete(t)&&(n=!0);return n?(ct.current=r,r):t})}},[tt,o,n]),Z.useEffect(()=>{o&&ug(r?.key??o,{directory:o,commitMessage:Ce,generatedHighlights:Xe})},[Ce,o,Xe,r?.key]),Z.useEffect(()=>{if(!e)return;if(!o||!n?.getRemoteUrl){ft(null);return}let t=!1;return n.getRemoteUrl(o).then(e=>{t||ft(e)}).catch(()=>{t||ft(null)}),()=>{t=!0}},[e,o,n]);let It=Z.useCallback(async()=>{if(!o||!n?.getRemotes){vt([]);return}try{let e=await n.getRemotes(o);ce.current&&vt(e)}catch{ce.current&&vt([])}},[o,n]);Z.useEffect(()=>{e&&It()},[e,It]),Z.useEffect(()=>{e&&o&&(N(o),F(o,n))},[e,o,N,F,n]),Z.useEffect(()=>{if(e&&o)return lr.onGitRefreshHint(e=>{dg(e.directory)===dg(o)&&I(o,n)})},[e,o,I,n]);let Lt=Z.useCallback(async(e=!0)=>{if(o)try{await Promise.all([I(o,n),L(o,n,{force:!0})])}catch(n){if(e){let e=n instanceof Error?n.message:t(`gitView.toast.refreshRepositoryFailed`);Y.error(e)}}},[o,n,I,L,t]),G=Z.useCallback(async()=>{o&&await R(o,n,ze)},[o,n,R,ze]),Rt=Z.useMemo(()=>!C||ke?[]:[...C.files??[]].sort((e,t)=>e.path.localeCompare(t.path)),[C,ke]),zt=Z.useMemo(()=>Rt.filter(fg),[Rt]),Bt=Z.useMemo(()=>Rt.filter(pg),[Rt]),{deferredStagedCount:Vt,deferredUnstagedCount:Ht}=Z.useMemo(()=>{if(!ke||!C)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of C.files??[])fg(n)&&(e+=1),pg(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[ke,C]);Z.useEffect(()=>{if(!o||Rt.length===0)return;let e=[],t=new Set,r=n=>{!n||t.has(n)||(t.add(n),e.push(n))};if(zt.forEach(e=>r(e.path)),Te.forEach(r),Rt.slice(0,ag).forEach(e=>r(e.path)),e.length===0)return;let i=window.setTimeout(()=>{ee(o,n,e,{maxFiles:ig})},120);return()=>{window.clearTimeout(i)}},[Rt,o,n,ee,zt,Te]);let Ut=e=>e?.pushed[0]?.remote||C?.tracking?.split(`/`)[0]||$t.find(e=>e.name===`origin`)?.name||$t[0]?.name||`origin`,Wt=async(e,r)=>{if(o){Fe(e);try{let i=e=>{let t=`${e.name}/`,n=C?.tracking?.startsWith(t)?C.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!r)throw Error(`No remote available for fetch`);await n.gitFetch(o,{remote:r.name}),Y.success(t(`gitView.toast.fetchedFromRemote`,{name:r.name}))}else if(e===`pull`){if(!r)throw Error(`No remote available for pull`);let e=await n.gitPull(o,i(r));Y.success(e.files.length===1?t(`gitView.toast.pulledFilesSingle`,{count:e.files.length,name:r.name}):t(`gitView.toast.pulledFilesPlural`,{count:e.files.length,name:r.name}))}else if(e===`push`){let e=await n.gitPush(o);Y.success(t(`gitView.toast.pushedToUpstream`,{name:Ut(e)}))}else if(e===`sync`){if(!r)throw Error(`No remote available for sync`);let e=0,a=!1;await n.gitFetch(o,{remote:r.name});let s=await n.getGitStatus(o);if((s.behind??0)>0){if((s.files?.length??0)>0){Y.error(t(`gitView.toast.commitOrStashBeforeSync`));return}e=(await n.gitPull(o,i(r))).files.length}((await n.getGitStatus(o)).ahead??0)>0&&(await n.gitPush(o),a=!0),e>0&&a?Y.success(t(e===1?`gitView.toast.syncedPulledSingleAndPushed`:`gitView.toast.syncedPulledPluralAndPushed`,{count:e,name:r.name})):e>0?Y.success(t(e===1?`gitView.toast.pulledFilesSingle`:`gitView.toast.pulledFilesPlural`,{count:e,name:r.name})):a?Y.success(t(`gitView.toast.pushedToUpstream`,{name:r.name})):Y.success(t(`gitView.toast.alreadyUpToDate`))}await Lt(!1),await G()}catch(n){let r=n instanceof Error?n.message:t(`gitView.toast.syncActionFailed`,{action:e===`sync`?t(`gitView.sync.syncChanges`):e===`pull`?t(`gitView.sync.pull`):e});Y.error(r)}finally{Fe(null)}}},Gt=async(e={})=>{if(!o)return;if(!Ce.trim()){Y.error(t(`gitView.toast.enterCommitMessage`));return}let r=zt.map(e=>e.path).sort();if(r.length===0){Y.error(t(`gitView.toast.stageFileToCommit`));return}let i=e.pushAfter?`commitAndPush`:`commit`;Re(i);try{if(await n.createGitCommit(o,Ce.trim(),{files:r,stageFiles:[]}),te(o),Y.success(t(`gitView.toast.commitCreated`)),we(``),et(),await Lt(),e.pushAfter){let e=C?.tracking?.split(`/`)[0],r=$t.find(t=>t.name===e)??$t[0];if(!r)throw Error(t(`mobile.changes.noRemote`));Fe(`sync`);let i=`${r.name}/`,a=C?.tracking?.startsWith(i)?C.tracking.slice(i.length):void 0;await n.gitFetch(o,{remote:r.name});let s=await n.getGitStatus(o);if((s.behind??0)>0){if((s.files?.length??0)>0){Y.error(t(`gitView.toast.commitOrStashBeforeSync`)),await Lt(!1);return}await n.gitPull(o,{remote:r.name,branch:a,rebase:!0})}let c=await n.getGitStatus(o),l;(c.ahead??0)>0&&(l=await n.gitPush(o)),Y.success(t(`gitView.toast.pushedToUpstream`,{name:Ut(l)})),Ve(),await Lt(!1)}else await Lt(!1);await G()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.createCommitFailed`);Y.error(n)}finally{Re(null),e.pushAfter&&Fe(null)}},Kt=Z.useCallback(async()=>{if(!o)return;let e=zt.map(e=>e.path).sort();if(e.length===0){Y.error(t(`gitView.toast.stageFileToDescribe`));return}console.error(`[git-generation][browser] generate button clicked`,{directory:o,selectedFiles:e.length}),Ye(!0);try{let{message:t}=await i(o,e),n=t.subject?.trim()??``,r=Array.isArray(t.highlights)?t.highlights:[];if(n){let e=n;if(ye&&Se.length>0){let t=sg(n,Se);if(t){let{code:r,emoji:i}=t;!n.startsWith(r)&&!n.startsWith(i)&&(e=`${r} ${n}`)}}we(e)}Ze(r),$e()}catch(e){console.error(`[git-generation][browser] GitView generate handler failed`,{message:e instanceof Error?e.message:String(e),error:e});let n=e instanceof Error?e.message:t(`gitView.toast.generateCommitMessageFailed`);Y.error(n)}finally{Ye(!1)}},[o,zt,ye,Se,$e,t,i]),qt=e=>e.reason===`attention`?`${e.attentionReason} in progress`:e.reason===`missing`?`worktree is missing`:`worktree is invalid`,Jt=async(e,r)=>{if(!o||!C)return;let i=br(w);if(i.length>0){Y.error(t(`gitView.toast.cannotCreateBranch`,{reason:qt(i[0])}));return}let a=C.current??null,s=r?.name??`origin`;try{await n.createBranch(o,e,a??`HEAD`),Y.success(t(`gitView.toast.createdBranch`,{name:e})),await n.checkoutBranch(o,e);let r=!1;try{await n.gitPush(o,{remote:s,branch:e,options:[`--set-upstream`]}),r=!0}catch(e){let n=e instanceof Error?e.message:`Unable to push new branch to ${s}.`;Y.warning(t(`gitView.toast.branchCreatedLocally`),{description:(0,$.jsxs)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:[`Upstream setup failed: `,n]})})}await Lt(),await G(),r&&Y.success(t(`gitView.toast.upstreamSet`,{branch:e,remote:s}))}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.createBranchFailed`);throw Y.error(n),e}},Yt=async(e,r)=>{if(!o)return;let i=br(w);if(i.length>0){Y.error(t(`gitView.toast.cannotRenameBranch`,{reason:qt(i[0])}));return}try{await n.renameBranch(o,e,r),Y.success(t(`gitView.toast.renamedBranch`,{oldName:e,newName:r})),await Lt(),await G()}catch(n){let i=n instanceof Error?n.message:t(`gitView.toast.renameBranchFailed`,{oldName:e,newName:r});Y.error(i)}},Xt=async e=>{if(!o)return;let r=br(w);if(r.length>0){Y.error(t(`gitView.toast.cannotCheckout`,{reason:qt(r[0])}));return}let i=e.replace(/^remotes\//,``);if(C?.current!==i)try{await n.checkoutBranch(o,i),Y.success(t(`gitView.toast.checkedOut`,{name:i})),await Lt(),await G()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.checkoutFailed`,{name:i});Y.error(n)}},Zt=Z.useMemo(()=>O?.all?O.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[O]),Qt=Z.useMemo(()=>O?.all?O.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[O]),$t=Z.useMemo(()=>{if(_t.length>0)return _t;let e=new Set,t=C?.tracking?.trim();t&&t.includes(`/`)&&e.add(t.split(`/`)[0]);for(let t of Qt){let n=t.indexOf(`/`);n>0&&e.add(t.slice(0,n))}return e.size===0&&dt&&e.add(`origin`),Array.from(e).map(e=>({name:e,fetchUrl:dt??``,pushUrl:dt??``}))},[_t,Qt,dt,C?.tracking]),en=Z.useMemo(()=>{let e=new Set($t.map(e=>e.name)),t=t=>{if(!t)return``;let n=t.trim();if(!n||n===`HEAD`)return``;if(Zt.includes(n))return n;n.startsWith(`refs/heads/`)&&(n=n.slice(11)),n.startsWith(`heads/`)&&(n=n.slice(6)),n.startsWith(`remotes/`)&&(n=n.slice(8));let r=n.indexOf(`/`);if(r>0){let t=n.slice(0,r);if(e.has(t)){let e=n.slice(r+1).trim();e&&(n=e)}}return n};return t(typeof D?.createdFromBranch==`string`?D.createdFromBranch:``)||t(typeof be==`string`?be:``)||(Zt.includes(`main`)?`main`:Zt.includes(`master`)?`master`:Zt.includes(`develop`)?`develop`:`main`)},[$t,Zt,be,D?.createdFromBranch]),tn=zt.length,nn=C?.current??null;Z.useEffect(()=>{if(!o||!n||!k?.all?.length||!nn||!en||nn===en){ut(null);return}let e=!1;return(async()=>{try{let t=await n.getGitLog(o,{from:en,to:`HEAD`,maxCount:ze});if(e)return;let r=new Set((t?.all??[]).map(e=>e.hash).filter(e=>typeof e==`string`&&e.length>0));if(r.size===0){ut(null);return}let i=k.all.findIndex(e=>!r.has(e.hash));if(i===0){ut(null);return}if(i===-1){ut({insertBeforeIndex:k.all.length,branchName:nn,direction:`up`});return}ut({insertBeforeIndex:i,branchName:nn,direction:`up`})}catch{e||ut(null)}})(),()=>{e=!0}},[en,nn,o,n,k,ze]),Z.useEffect(()=>{Et(null)},[o]),Z.useEffect(()=>{if(ht!==`graph`||!o){ht!==`graph`&&Et(null);return}let e=!1;return Ot(!0),n.getGitLog(o,{maxCount:kt,all:!0}).then(t=>{e||Et(t)}).catch(e=>{console.error(`Failed to fetch graph log:`,e)}).finally(()=>{e||Ot(!1)}),()=>{e=!0}},[ht,o,kt,n]);let rn=Z.useCallback((e,t)=>{if(!o||e.length===0)return;let n=Array.from(new Set(e));Ge(e=>{let t=new Set(e);return n.forEach(e=>t.add(e)),t});let r=B(o,n,t);me.enqueue({directory:o,direction:t,paths:new Set(n),rollback:()=>V(o,r)}),fe()},[o,me,B,V,fe]),an=Z.useCallback(async e=>{if(o){Ue(t=>{let n=new Set(t);return n.add(e),n});try{await n.revertGitFile(o,e,{scope:`working`}),Y.success(t(`gitView.toast.revertedFile`,{path:e})),await Lt(!1)}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.revertFailed`);Y.error(n)}finally{Ue(t=>{let n=new Set(t);return n.delete(e),n})}}},[o,Lt,n,t]),on=Z.useCallback(async(e,r,i=`all`)=>{if(!o||e.length===0)return;let a=Array.from(new Set(e));if(Ke||a.some(e=>He.has(e)))return;let s=new Set(zt.map(e=>e.path)),c=i===`all`&&a.some(e=>s.has(e));r&&qe(!0),Ue(e=>{let t=new Set(e);return a.forEach(e=>t.add(e)),t});let l=[];try{if(await Promise.all(a.map(async e=>{try{await n.revertGitFile(o,e,{scope:i})}catch(n){l.push({path:e,message:n instanceof Error?n.message:t(`gitView.toast.revertFailed`)})}})),c&&l.length<a.length&&te(o),await Lt(!1),l.length===0)Y.success(a.length===1?t(`gitView.toast.revertedFilesSingle`,{count:a.length}):t(`gitView.toast.revertedFilesPlural`,{count:a.length}));else if(l.length===a.length)Y.error(l[0]?.message||t(`gitView.toast.revertFailed`));else{let e=a.length-l.length;Y.warning(t(e===1?`gitView.toast.revertedSomeSingle`:`gitView.toast.revertedSomePlural`,{success:e,failed:l.length}))}}finally{Ue(e=>{let t=new Set(e);return a.forEach(e=>t.delete(e)),t}),r&&qe(!1)}},[te,o,n,Ke,Lt,He,zt,t]),sn=Z.useCallback(async e=>{await on(e,!0)},[on]),cn=Z.useCallback(async e=>{await on(e,!1,`working`)},[on]),un=Z.useCallback((e,t)=>{if(o&&!ne){re(r?.key??o,e,t);return}ie(e,t),ne&&ae(!1)},[o,ne,ie,re,ae,r?.key]),dn=Z.useCallback(()=>Le(!0),[]),fn=Z.useMemo(()=>{let e=[];return zt.length>0&&e.push({id:`staged`,title:t(`gitView.changes.stagedTitle`),entries:zt,actionSymbol:`-`,actionAllLabel:t(`gitView.changes.unstageAllAria`),getActionLabel:e=>t(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void rn([e],`unstage`),onActionAll:e=>void rn(e,`unstage`),onViewDiff:e=>un(e,!0),onRevertFile:an,showRevertActions:!1,accent:!0}),Bt.length>0&&e.push({id:`unstaged`,title:t(`gitView.changes.title`),entries:Bt,actionSymbol:`+`,actionAllLabel:t(`gitView.changes.stageAllAria`),getActionLabel:e=>t(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void rn([e],`stage`),onActionAll:e=>void rn(e,`stage`),onViewDiff:e=>un(e,!1),onRevertFile:an}),e},[an,un,rn,zt,t,Bt]),pn=Z.useCallback(e=>{if(e.length===0)return;let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){et();return}we(e=>{let n=e.trim();return`${n}${n.length>0?`
|
|
15
|
+
|
|
16
|
+
`:``}${t.join(`
|
|
17
|
+
`)}`.trim()}),et()},[et]),mn=Z.useCallback((e,t)=>{let n=t||e;we(r=>{let i=r.trimStart();return i.startsWith(e)||t&&i.startsWith(t)?r:`${n.endsWith(` `)?n:`${n} `}${r}`.trimStart()}),mt(``),Me(!1)},[]),hn=Z.useCallback(async()=>{if(o)try{Ct===`merge`?(await n.abortMerge(o),Y.success(t(`gitView.toast.mergeAborted`))):(await n.abortRebase(o),Y.success(t(`gitView.toast.rebaseAborted`))),Nt(),await Lt(),await G()}catch(e){let t=e instanceof Error?e.message:`Failed to abort ${Ct}`;Y.error(t)}},[o,n,Ct,Lt,G,Nt,t]),gn=Z.useMemo(()=>C?.files?C.files.some(e=>e.index===`U`||e.working_dir===`U`||e.index===`A`&&e.working_dir===`A`||e.index===`D`&&e.working_dir===`D`):!1,[C?.files]),_n=Z.useCallback(async()=>{if(o)try{let e=!!C?.mergeInProgress?.head,r=!!(C?.rebaseInProgress?.headName||C?.rebaseInProgress?.onto);if(e){let e=await n.continueMerge(o);e.conflict?(St(e.conflictFiles??[]),wt(`merge`),bt(!0),Mt(o,e.conflictFiles??[],`merge`),Y.error(t(`gitView.toast.mergeConflictsDetected`))):(Nt(),Y.success(t(`gitView.toast.mergeCompleted`)),await Lt(),await G())}else if(r){let e=await n.continueRebase(o);e.conflict?(St(e.conflictFiles??[]),wt(`rebase`),bt(!0),Mt(o,e.conflictFiles??[],`rebase`),Y.error(t(`gitView.toast.rebaseConflictsDetected`))):(Nt(),Y.success(t(`gitView.toast.rebaseStepCompleted`)),await Lt(),await G())}}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.continueOperationFailed`);Y.error(n)}},[o,n,C,Lt,G,Mt,Nt,t]),vn=Z.useCallback(async()=>{if(o)try{C?.mergeInProgress?.head?(await n.abortMerge(o),Y.success(t(`gitView.toast.mergeAborted`))):(await n.abortRebase(o),Y.success(t(`gitView.toast.rebaseAborted`))),Nt(),await Lt(),await G()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.abortOperationFailed`);Y.error(n)}},[o,n,C,Lt,G,Nt,t]),yn=Z.useCallback(()=>{if(!o)return;let e=C?.mergeInProgress?.head?`merge`:`rebase`,t=C?.files?.filter(e=>e.index===`U`||e.working_dir===`U`).map(e=>e.path)??[];t.length>0&&St(t),wt(e),bt(!0)},[o,C]),bn=Z.useCallback(e=>{Be(e),o&&(z(o,e),R(o,n,e))},[o,R,n,z]),xn=Z.useCallback(e=>{At(e)},[]),Sn=Z.useCallback(()=>{gt(null),o&&(I(o,n),L(o,n,{force:!0}),R(o,n,ze))},[o,I,L,R,ze,n]),Cn=Z.useCallback(e=>{if(e.conflict){if(e.operation===`cherry-pick`||e.operation===`revert`){Y.error(t(`gitView.history.actions.conflictToastTitle`),{description:t(`gitView.history.actions.conflictToastDescription`,{files:e.conflictFiles?.join(`, `)??`unknown files`})}),o&&(I(o,n),L(o,n,{force:!0}),R(o,n,ze));return}St(e.conflictFiles??[]),wt(e.operation),bt(!0),o&&Mt(o,e.conflictFiles??[],e.operation)}},[t,St,wt,bt,Mt,o,I,L,R,ze,n]);if(!o)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:t(`gitView.empty.selectSessionOrDirectory`)})});if(S===null||S===!0&&!C)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:t(`gitView.loading.checkingRepository`)})]})});if(S===!1)return _e?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-4 text-center`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mb-3 size-6 animate-spin text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:t(`gitView.empty.worktreeSetupInProgress`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 text-muted-foreground`,children:t(`gitView.empty.worktreeSetupDescription`)})]}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-4 text-center`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`mb-3 size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:t(`gitView.empty.notGitRepository`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 text-muted-foreground`,children:t(`gitView.empty.notGitRepositoryDescription`)}),T.includes(`open-without-worktree-features`)?(0,$.jsx)(`p`,{className:`typography-meta mt-2 text-muted-foreground`,children:t(`gitView.empty.worktreeFeaturesUnavailable`)}):null]});let wn=C?D?(0,$.jsx)(ll,{currentBranch:C.current,onRename:Yt,iconOnly:!0}):(0,$.jsx)(ls,{currentBranch:C.current,localBranches:Zt,remoteBranches:Qt,branchInfo:O?.branches,onCheckout:Xt,onCreate:Jt,remotes:$t,iconOnly:!0}):null,Tn=C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mi,{syncAction:Pe,remotes:$t,onSync:e=>Wt(`sync`,e),disabled:!C,aheadCount:C.ahead,behindCount:C.behind,trackingRemoteName:C.tracking?.split(`/`)[0],hasUncommittedChanges:(C.files?.length??0)>0}),(0,$.jsxs)(wi,{children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":t(`gitView.header.repositoryViews`),children:(0,$.jsx)(X,{name:`git-repository`,className:`size-3.5`})})})}),(0,$.jsx)(ti,{sideOffset:8,children:t(`gitView.header.repositoryViews`)})]}),(0,$.jsxs)(xi,{align:`end`,children:[(0,$.jsxs)(Si,{onSelect:()=>gt(`history`),children:[(0,$.jsx)(X,{name:`history`,className:`size-4`}),t(`gitView.history.title`)]}),(0,$.jsxs)(Si,{onSelect:()=>gt(`graph`),children:[(0,$.jsx)(X,{name:`git-merge`,className:`size-4`}),t(`gitView.graph.title`)]}),(0,$.jsxs)(Si,{onSelect:dn,children:[(0,$.jsx)(X,{name:`archive-stack`,className:`size-4`}),t(`gitView.stashes.title`)]})]})]})]}):null,En=C?(0,$.jsxs)($.Fragment,{children:[wn,Tn]}):null;return(0,$.jsxs)(`div`,{className:J(`flex h-full flex-col overflow-hidden`),children:[o&&(C?.mergeInProgress?.head||C?.rebaseInProgress?.headName||C?.rebaseInProgress?.onto)&&(0,$.jsx)(tg,{mergeInProgress:C?.mergeInProgress,rebaseInProgress:C?.rebaseInProgress,onContinue:_n,onAbort:vn,onResolveWithAI:yn,hasUnresolvedConflicts:gn,isLoading:A}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full min-h-0 flex flex-col`,children:(0,$.jsx)(`div`,{className:J(`min-w-0 min-h-0 h-full flex flex-col`),children:(0,$.jsx)(Gr,{as:Wr,ref:Ne,outerClassName:`flex-1 min-h-0`,className:ne?`px-4 pt-2 pb-4`:`px-2 pt-0 pb-0`,disableHorizontal:!0,preventOverscroll:!0,children:(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:ke?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center bg-background pr-2`,children:[(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate font-semibold text-foreground`,ne?`typography-ui-label`:`text-xs leading-4`),children:t(`gitView.changes.deferredTitle`,{count:C?.files?.length??0})}),(0,$.jsx)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:En})]}),(0,$.jsx)(ci,{stagedCount:Vt,unstagedCount:Ht,onLoad:()=>Oe(!0)})]}):(Rt?.length??0)>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(si,{compact:!ne,groups:fn,diffStats:C?.diffStats,revertingPaths:He,isRevertingAll:Ke,onVisiblePathsChange:Ee,onRevertAll:sn,onRevertDirectory:cn,headerBackgroundClassName:`bg-background`,headerLeadingActions:wn,headerActions:Tn})}),(0,$.jsx)(li,{compact:!ne,stagedCount:tn,commitMessage:Ce,onCommitMessageChange:we,generatedHighlights:Xe,onInsertHighlights:pn,onGenerateMessage:Kt,isGeneratingMessage:Je,onCommit:()=>Gt({pushAfter:!1}),onCommitAndPush:()=>Gt({pushAfter:!0}),commitAction:W,hasPendingIndexMutation:Qe,gitmojiEnabled:ye,onOpenGitmojiPicker:()=>Me(!0)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center bg-background pr-2`,children:[(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate font-semibold text-foreground`,ne?`typography-ui-label`:`text-xs leading-4`),children:t(`gitView.empty.cleanTitle`)}),(0,$.jsx)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:En})]}),(0,$.jsx)(wh,{onOpenStashes:()=>Le(!0)})]})})})})})}),(0,$.jsx)($r,{open:ht!==null,onOpenChange:e=>{e||gt(null)},children:(0,$.jsxs)(Xr,{className:`max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden`,children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Zr,{children:t(ht===`graph`?`gitView.graph.title`:`gitView.history.title`)}),(0,$.jsx)(Qr,{children:t(`gitView.history.dialogDescription`)})]}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,$.jsx)(Uh,{mode:ht===`graph`?`graph`:`history`,log:ht===`graph`?Tt??k:k,isLogLoading:ht===`graph`&&Dt||j,logMaxCount:ht===`graph`?kt:ze,onLogMaxCountChange:ht===`graph`?xn:bn,expandedCommitHashes:tt,onToggleCommit:Ft,commitFilesMap:rt,loadingCommitHashes:at,onCopyHash:Pt,directory:o??void 0,showHeader:!1,contentMaxHeightClassName:`h-full max-h-none`,branchDivider:ht===`graph`?null:lt,onConflict:ht===`graph`?Cn:void 0,onActionSuccess:ht===`graph`?Sn:void 0})})]})}),(0,$.jsx)(Sh,{open:Ie,onOpenChange:Le,directory:o,hasUncommittedChanges:(C?.files?.length??0)>0,hasStagedChanges:zt.length>0,uncommittedFileCount:C?.files?.length??0,onChanged:async e=>{o&&e?.affectsIndex&&te(o),await Lt(!1),await G()}}),(0,$.jsx)($r,{open:Ae,onOpenChange:Me,children:(0,$.jsxs)(Xr,{className:`max-w-md p-0 overflow-hidden`,children:[(0,$.jsx)(Jr,{className:`px-4 pt-4`,children:(0,$.jsx)(Zr,{children:t(`gitView.gitmoji.title`)})}),(0,$.jsxs)(cs,{className:`h-[420px]`,children:[(0,$.jsx)(ss,{placeholder:t(`gitView.gitmoji.searchPlaceholder`),value:pt,onValueChange:mt}),(0,$.jsxs)(us,{children:[(0,$.jsx)(ds,{children:t(`gitView.gitmoji.empty`)}),(0,$.jsx)(gs,{children:(Se.length===0?[]:Se.filter(e=>{let t=pt.trim().toLowerCase();return!t||e.emoji.includes(t)||e.code.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)})).map(e=>(0,$.jsxs)(hs,{onSelect:()=>mn(e.emoji,e.code),children:[(0,$.jsx)(`span`,{className:`text-lg`,children:e.emoji}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.code}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e.description})]},e.code))})]})]})]})}),o&&(0,$.jsx)(Jh,{open:yt,onOpenChange:bt,conflictFiles:xt,directory:o,operation:Ct,onAbort:hn,onClearState:Nt})]})},hg=1,gg=8e3,_g={refreshAuth:()=>i(),clearUrlAuthToken:r,openSocket:e=>ot(l().websocket(wo(e)))},vg=class{providerId;handlers;dependencies;socket=null;pendingFrame=null;reconnectTimer=null;failures=0;generation=0;disposed=!1;ended=!1;constructor(e,t,n=_g){this.providerId=e,this.handlers=t,this.dependencies=n}start(){this.handlers.onConnection({status:`connecting`}),this.connect()}dispose(){this.disposed=!0,this.generation+=1,this.cancelReconnect();let e=this.socket;this.socket=null,e?.close()}ack(e){this.send({type:`ack`,seq:e})}sendInput(e){return e.length!==0&&this.send({type:`input`,events:e})}release(){this.send({type:`release`})}resize(e,t){e<1||t<1||this.send({type:`resize`,width:Math.round(e),height:Math.round(t)})}retry(){this.disposed||(this.ended=!1,this.failures=0,this.generation+=1,this.socket?.close(),this.socket=null,this.handlers.onConnection({status:`connecting`}),this.connect())}send(e){let t=this.socket;if(!t||t.readyState!==hg)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}async connect(){if(this.disposed||this.ended)return;let e=this.generation;try{await this.dependencies.refreshAuth()}catch{this.scheduleReconnect();return}if(e!==this.generation||this.disposed||this.ended)return;let t;try{t=this.dependencies.openSocket(this.providerId)}catch{this.scheduleReconnect();return}t.binaryType=`arraybuffer`,this.socket=t;let n=!1;t.onopen=()=>{this.socket===t&&(n=!0,this.failures=0,this.pendingFrame=null,this.handlers.onConnection({status:`open`}))},t.onmessage=e=>{this.socket===t&&this.handleMessage(e.data)},t.onerror=()=>{this.dependencies.clearUrlAuthToken()},t.onclose=()=>{this.socket===t&&(this.socket=null),!(this.disposed||this.ended)&&(n&&(this.failures=Math.max(this.failures,1)),this.scheduleReconnect())}}handleMessage(e){if(e instanceof ArrayBuffer){let t=this.pendingFrame;if(this.pendingFrame=null,!t||e.byteLength!==t.bytes)return;this.handlers.onFrame({...t,bytes:e});return}if(typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}let n=To(t);n&&this.applyHostMessage(n)}applyHostMessage(e){if(e.type===`frame`){this.pendingFrame=e;return}if(e.type===`control`){this.handlers.onControl({controller:e.controller,mine:e.mine});return}e.type===`ended`&&(this.ended=!0,this.cancelReconnect(),this.handlers.onConnection({status:`ended`,reason:e.reason}),this.handlers.onEnded?.(e.reason),this.socket?.close())}scheduleReconnect(){if(this.disposed||this.ended||this.reconnectTimer)return;this.failures+=1;let e=this.failures;this.handlers.onConnection({status:`reconnecting`,attempt:e});let t=Math.min(gg,250*2**Math.min(e,5));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}cancelReconnect(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}},yg=250,bg=e=>({alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey}),xg=e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`v`,Sg=(e,t)=>new vg(e,t),Cg=({provider:e,clientFactory:t=Sg})=>{let{t:n}=Pr(),r=Z.useRef(null),i=Z.useRef(null),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef([]),c=Z.useRef(null),l=Z.useRef({controller:`none`,mine:!1}),u=Z.useRef(null),[d,f]=Z.useState({status:`connecting`}),[p,m]=Z.useState({controller:`none`,mine:!1}),[h,g]=Z.useState(``),[_,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(!1),C=G(e=>{l.current=e,m(e)}),w=G(async e=>{let t=i.current,n=a.current;if(!(!t||!n))try{let n=await createImageBitmap(new Blob([e.bytes],{type:e.mime}));(t.width!==e.width||t.height!==e.height)&&(t.width=e.width,t.height=e.height),t.getContext(`2d`)?.drawImage(n,0,0,e.width,e.height),n.close(),o.current={width:e.width,height:e.height},b(!0),g(e.title??``),v(e.agentActive)}catch{}finally{n.ack(e.seq)}}),T=Z.useRef({onFrame:e=>{w(e)},onControl:C,onConnection:f});T.current={onFrame:e=>{w(e)},onControl:C,onConnection:f};let E=Z.useRef(t);E.current=t,Z.useEffect(()=>{if(!e.surface)return;let t=E.current(e.id,{onFrame:e=>{T.current.onFrame(e)},onControl:e=>{T.current.onControl(e)},onConnection:e=>{T.current.onConnection(e)}});return a.current=t,t.start(),()=>{t.dispose(),a.current===t&&(a.current=null),c.current!==null&&cancelAnimationFrame(c.current),c.current=null,s.current=[],o.current=null,b(!1),f({status:`connecting`}),C({controller:`none`,mine:!1})}},[e.id,e.surface,C]);let D=G(()=>{let t=r.current;!t||!e.surface||(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null;let e=t.getBoundingClientRect(),n=window.devicePixelRatio||1,r=Math.round(e.width*n),i=Math.round(e.height*n);r>0&&i>0&&a.current?.resize(r,i)},yg))});Lt(e.surface?r:null,D);let O=G(e=>{s.current.push(e),c.current===null&&(c.current=requestAnimationFrame(()=>{c.current=null;let e=s.current;s.current=[],a.current?.sendInput(e)}))}),k=e=>{let t=i.current,n=o.current;if(!t||!n)return null;let r=t.getBoundingClientRect();return r.width===0||r.height===0?null:{x:Math.round((e.clientX-r.left)/r.width*n.width),y:Math.round((e.clientY-r.top)/r.height*n.height)}},A=e=>t=>{if(!y||e===`move`&&t.buttons===0&&!(l.current.controller===`user`&&l.current.mine))return;let n=k(t);n&&(e===`down`?(r.current?.focus(),t.currentTarget.setPointerCapture(t.pointerId)):e===`up`&&t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),t.preventDefault(),O({type:`pointer`,action:e,x:n.x,y:n.y,button:e===`move`?-1:t.button,buttons:t.buttons,modifiers:bg(t)}))},j=e=>{if(!y)return;let t=k(e);t&&(e.preventDefault(),O({type:`wheel`,x:t.x,y:t.y,deltaX:e.deltaX,deltaY:e.deltaY,modifiers:bg(e)}))},M=e=>t=>{!y||xg(t)||(t.preventDefault(),t.stopPropagation(),O({type:`key`,action:e,key:t.key,code:t.code,modifiers:bg(t)}))},N=e=>{if(!y)return;let t=e.clipboardData.getData(`text/plain`);e.preventDefault(),t&&O({type:`text`,text:t})},P=G(()=>{a.current?.release()}),F=G(()=>{a.current?.retry()});if(!e.surface)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(`layout.browserProvider.noSurface`,{name:e.name})});let I=d.status===`connecting`?`layout.browserProvider.status.connecting`:d.status===`reconnecting`?`layout.browserProvider.status.reconnecting`:d.status===`ended`?d.reason===`service-stopped`?`layout.browserProvider.ended.service-stopped`:d.reason===`extension-unavailable`?`layout.browserProvider.ended.extension-unavailable`:`layout.browserProvider.ended.host-shutdown`:p.controller===`user`?p.mine?`layout.browserProvider.status.youControl`:`layout.browserProvider.status.otherControls`:p.controller===`agent`||_?`layout.browserProvider.status.agentWorking`:x?`layout.browserProvider.status.readyFocused`:`layout.browserProvider.status.ready`,L=p.controller===`user`&&p.mine;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,title:h||e.name,children:h||e.name}),(0,$.jsx)(`span`,{className:J(`shrink-0 truncate text-xs`,L?`text-foreground`:`text-muted-foreground`),"aria-live":`polite`,children:n(I)}),L?(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:P,children:n(`layout.browserProvider.handBack`)}):null,d.status===`ended`?(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:F,children:n(`layout.browserProvider.retry`)}):null]}),(0,$.jsxs)(`div`,{ref:r,tabIndex:0,role:`application`,"aria-label":n(`layout.browserProvider.canvasAria`,{name:e.name}),className:J(`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden outline-none`,x&&`ring-1 ring-inset ring-[var(--interactive-selection-border)]`),onFocus:()=>S(!0),onBlur:()=>S(!1),onKeyDown:M(`down`),onKeyUp:M(`up`),onPaste:N,children:[(0,$.jsx)(`canvas`,{ref:i,className:J(`max-h-full max-w-full`,y?`block`:`hidden`,p.controller===`user`&&!p.mine?`cursor-not-allowed`:`cursor-default`),onPointerDown:A(`down`),onPointerMove:A(`move`),onPointerUp:A(`up`),onWheel:j,onContextMenu:e=>e.preventDefault()}),!y||d.status!==`open`?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(d.status===`ended`?d.reason===`service-stopped`?`layout.browserProvider.ended.service-stopped`:d.reason===`extension-unavailable`?`layout.browserProvider.ended.extension-unavailable`:`layout.browserProvider.ended.host-shutdown`:d.status===`reconnecting`?`layout.browserProvider.status.reconnecting`:`layout.browserProvider.status.connecting`)}):null]})]})},wg=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Tg=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Eg=(e,t)=>{let n=Tg(t),r=Tg(e).replace(/\/+$/,``);return n===r?`.`:!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Dg=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Og=new Set([`node_modules`]),kg=e=>Og.has(e),Ag=e=>{let t=Tg(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},jg=8,Mg=new Map,Ng=e=>{let t=Mg.get(e);return t?(t.touchedAt=Date.now(),Mg.delete(e),Mg.set(e,t),t):null},Pg=e=>{let t=Mg.get(e);if(t)return t.touchedAt=Date.now(),t;if(Mg.size>=jg){let e=Mg.keys().next().value;e!==void 0&&Mg.delete(e)}let n={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Mg.set(e,n),n},Fg=e=>{Mg.delete(e)},Ig=(e,t)=>(0,$.jsx)(ii,{filePath:e,extension:t,className:`size-3.5`}),Lg=e=>{let t=(0,Q.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Rg=Z.memo(e=>{let t=(0,Q.c)(73),{node:n,root:r,isExpanded:i,isActive:a,status:o,badge:s,permissions:c,downloadFile:l,onSelect:u,onToggle:d,onRevealPath:f,onOpenDialog:p}=e,{t:m}=Pr(),h=n.type===`directory`,{canRename:g,canCreateFile:_,canCreateFolder:v,canDelete:y,canReveal:b}=c,[x,S]=Z.useState(!1),[C,w]=Z.useState(!1),T;t[0]!==_||t[1]!==v||t[2]!==y||t[3]!==g||t[4]!==b?(T=e=>{!g&&!_&&!v&&!y&&!b||(e?.preventDefault(),w(!0))},t[0]=_,t[1]=v,t[2]=y,t[3]=g,t[4]=b,t[5]=T):T=t[5];let E=T,D;t[6]!==h||t[7]!==n||t[8]!==u||t[9]!==d?(D=()=>{h?d(n.path):u(n)},t[6]=h,t[7]=n,t[8]=u,t[9]=d,t[10]=D):D=t[10];let O=D,k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{e.stopPropagation(),w(!1),S(!0)},t[11]=k):k=t[11];let A=k,j;t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==g||t[16]!==b||t[17]!==l||t[18]!==h||t[19]!==n||t[20]!==p||t[21]!==f||t[22]!==m?(j=e=>{let{Item:t,Separator:r}=e;return(0,$.jsxs)($.Fragment,{children:[g&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`rename`,n)},children:[(0,$.jsx)(X,{name:`edit`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.rename`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),pr(n.path).then(e=>{e.ok||Y.error(m(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.copyPath`)]}),!h&&l&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),l(n.path).catch(e=>{console.error(`Download failed:`,e),Y.error(m(`sidebarFilesTree.toast.operationFailed`))})},children:[(0,$.jsx)(X,{name:`download`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.save`)]}),b&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),f(n.path)},children:[(0,$.jsx)(X,{name:`folder-received`,className:`mr-2 h-4 w-4`}),` `,m(Un())]}),h&&(_||v)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(r,{}),_&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`createFile`,n)},children:[(0,$.jsx)(X,{name:`file-add`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.newFile`)]}),v&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`createFolder`,n)},children:[(0,$.jsx)(X,{name:`folder-add`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.newFolder`)]})]}),y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(r,{}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`delete`,n)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-2 h-4 w-4 text-inherit`}),` `,m(`sidebarFilesTree.menu.delete`)]})]})]})},t[12]=_,t[13]=v,t[14]=y,t[15]=g,t[16]=b,t[17]=l,t[18]=h,t[19]=n,t[20]=p,t[21]=f,t[22]=m,t[23]=j):j=t[23];let M=j,N;t[24]!==n.path||t[25]!==r?(N=e=>{let t=Eg(r,n.path);!t||t===`.`||(e.dataTransfer.setData(`application/x-yuri-file-path`,t),e.dataTransfer.effectAllowed=`copy`)},t[24]=n.path,t[25]=r,t[26]=N):N=t[26];let P=N,F;t[27]===E?F=t[28]:(F=(0,$.jsx)(`div`,{className:`group relative flex items-center`,onContextMenu:E}),t[27]=E,t[28]=F);let I=a?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`,L;t[29]===I?L=t[30]:(L=J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none`,I,`cursor-grab active:cursor-grabbing`),t[29]=I,t[30]=L);let R;t[31]!==h||t[32]!==i||t[33]!==n.extension||t[34]!==n.path?(R=h?i?(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-3.5 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-3.5 flex-shrink-0 text-muted-foreground`}):Ig(n.path,n.extension),t[31]=h,t[32]=i,t[33]=n.extension,t[34]=n.path,t[35]=R):R=t[35];let z;t[36]!==n.name||t[37]!==n.path?(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code`,title:n.path,children:n.name}),t[36]=n.name,t[37]=n.path,t[38]=z):z=t[38];let ee;t[39]!==h||t[40]!==o?(ee=!h&&o&&(0,$.jsx)(Lg,{status:o}),t[39]=h,t[40]=o,t[41]=ee):ee=t[41];let B;t[42]!==s||t[43]!==h?(B=h&&s&&(0,$.jsxs)(`span`,{className:`text-xs flex items-center gap-1 ml-auto mr-1`,children:[s.modified>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-warning)]`,children:[`M`,s.modified]}),s.added>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,s.added]})]}),t[42]=s,t[43]=h,t[44]=B):B=t[44];let V;t[45]!==E||t[46]!==P||t[47]!==O||t[48]!==z||t[49]!==ee||t[50]!==B||t[51]!==L||t[52]!==R?(V=(0,$.jsxs)(`button`,{type:`button`,onClick:O,onContextMenu:E,draggable:!0,onDragStart:P,className:L,children:[R,z,ee,B]}),t[45]=E,t[46]=P,t[47]=O,t[48]=z,t[49]=ee,t[50]=B,t[51]=L,t[52]=R,t[53]=V):V=t[53];let te;t[54]!==_||t[55]!==v||t[56]!==y||t[57]!==g||t[58]!==b||t[59]!==x||t[60]!==M||t[61]!==m?(te=(g||_||v||y||b)&&(0,$.jsx)(`div`,{className:`absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100`,children:(0,$.jsxs)(wi,{open:x,onOpenChange:S,children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:A,title:m(`sidebarFilesTree.actions.fileMenuTitle`),"aria-label":m(`sidebarFilesTree.actions.fileMenuTitle`),children:(0,$.jsx)(X,{name:`more-2-fill`,className:`h-4 w-4`})})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:m(`sidebarFilesTree.actions.fileMenuTitle`)})]}),(0,$.jsx)(xi,{align:`end`,side:`bottom`,onCloseAutoFocus:()=>S(!1),children:M({Item:Si,Separator:Ci})})]})}),t[54]=_,t[55]=v,t[56]=y,t[57]=g,t[58]=b,t[59]=x,t[60]=M,t[61]=m,t[62]=te):te=t[62];let ne;t[63]!==V||t[64]!==te||t[65]!==F?(ne=(0,$.jsxs)(Ti,{render:F,children:[V,te]}),t[63]=V,t[64]=te,t[65]=F,t[66]=ne):ne=t[66];let re;t[67]===M?re=t[68]:(re=(0,$.jsx)(Di,{className:`min-w-[180px]`,children:M({Item:Oi,Separator:Ei})}),t[67]=M,t[68]=re);let ie;return t[69]!==C||t[70]!==ne||t[71]!==re?(ie=(0,$.jsxs)(ki,{open:C,onOpenChange:w,children:[ne,re]}),t[69]=C,t[70]=ne,t[71]=re,t[72]=ie):ie=t[72],ie},(e,t)=>e.node===t.node&&e.root===t.root&&e.isExpanded===t.isExpanded&&e.isActive===t.isActive&&e.status===t.status&&e.badge===t.badge&&e.permissions===t.permissions&&e.downloadFile===t.downloadFile&&e.onSelect===t.onSelect&&e.onToggle===t.onToggle&&e.onRevealPath===t.onRevealPath&&e.onOpenDialog===t.onOpenDialog),zg=()=>{let{t:e}=Pr(),{files:t}=Ki(),n=xt(),r=n?.entry,i=Wi()??``,a=Tg(i.trim()),o=r?.key??a,s=n?.entry.location.hostId?JSON.stringify([n.entry.queryScope,a]):a,c=it(),l=nt(),u=rt(e=>e.searchFiles),d=K(e=>e.openContextFile),f=ea(i),[p,m]=Z.useState(``),h=ja(p,200),g=Z.useRef(null),[_,v]=Z.useState([]),[y,b]=Z.useState(!1),[x,S]=Z.useState({}),[C,w]=Z.useState({}),T=Z.useRef(new Set),E=Z.useRef(new Set),D=Z.useRef(null),O=Z.useRef(!1);Z.useEffect(()=>{if(!a){S({}),w({}),T.current=new Set;return}let e=Ng(s);e?(S({...e.childrenByDir}),w({...e.loadErrorsByDir}),T.current=new Set(e.loadedDirs)):(S({}),w({}),T.current=new Set)},[a,s]),Z.useEffect(()=>{if(!a)return;let e=Pg(s);e.childrenByDir=x},[a,s,x]),Z.useEffect(()=>{if(!a)return;let e=Pg(s);e.loadErrorsByDir=C},[a,s,C]),Z.useEffect(()=>{if(!a)return;let e=Pg(s);e.loadedDirs=new Set(T.current)},[a,s,x,C]),Z.useEffect(()=>()=>{if(!a)return;let e=Mg.get(s);e&&e.loadedDirs.size===0&&Object.keys(e.childrenByDir).length===0&&Fg(s)},[a,s]);let k=Z.useMemo(()=>[],[]),A=Z.useMemo(()=>[],[]),j=Vo(e=>a?e.byRoot[o]?.expandedPaths??k:k),M=Vo(e=>a?e.byRoot[o]?.selectedPath??null:null),N=Vo(e=>e.setSelectedPath),P=Vo(e=>e.addOpenPath),F=Vo(e=>e.removeOpenPathsByPrefix),I=Vo(e=>e.removeExpandedPathsByPrefix),L=Vo(e=>e.toggleExpandedPath),R=Vo(e=>e.expandPaths),z=K(e=>a?e.contextPanelByDirectory[o]?.tabs??A:A),ee=Z.useMemo(()=>new Set(z.map(e=>e.mode===`file`?e.targetPath:null).filter(e=>typeof e==`string`&&e.length>0).map(e=>Tg(e))),[z]),[B,V]=Z.useState(null),[te,ne]=Z.useState(null),[re,ie]=Z.useState(``),[ae,H]=Z.useState(!1),U=!!t.writeFile,oe=!!t.createDirectory,se=!!t.rename,ce=!!t.delete,le=!!t.revealPath,ue=Z.useMemo(()=>({canRename:se,canCreateFile:U,canCreateFolder:oe,canDelete:ce,canReveal:le}),[se,U,oe,ce,le]),de=Z.useCallback(n=>{t.revealPath&&t.revealPath(n).catch(()=>{Y.error(e(`sidebarFilesTree.toast.revealFailed`))})},[t,e]),fe=Z.useCallback((e,t)=>{V(e),ne(t),ie(e===`rename`&&t.name||``),H(!1)},[]),pe=Z.useCallback((e,t)=>wg(t.filter(e=>e&&typeof e.name==`string`&&e.name.length>0).filter(e=>c||!e.name.startsWith(`.`)).filter(e=>l||!kg(e.name)).map(t=>{let n=t.name,r=Tg(t.path||``),i=r?Dg(r)?r:Tg(`${e}/${r}`):Tg(`${e}/${n}`),a=t.isDirectory?`directory`:`file`;return{name:n,path:i,type:a,extension:a===`file`&&n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})),[l,c]),me=Z.useCallback(async(e,n)=>{let i=Tg(e.trim());if(!i||T.current.has(i)||E.current.has(i))return;E.current=new Set(E.current),E.current.add(i);let a=t.listDirectory?t.listDirectory(i).then(e=>e.entries.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory}))):(r?.service()??Se).listLocalDirectory(i).then(e=>e.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory})));try{let e=await a;if(n?.())return;let t=pe(i,e);T.current=new Set(T.current),T.current.add(i),w(e=>{if(!e[i])return e;let t={...e};return delete t[i],t}),S(e=>({...e,[i]:t}))}catch(e){if(n?.())return;let t=e instanceof Error?e.message:String(e??``);console.error(`Failed to load sidebar directory:`,e),w(e=>({...e,[i]:t}))}finally{E.current=new Set(E.current),E.current.delete(i)}},[t,pe,r]),he=Z.useCallback(async()=>{if(!a)return;D.current?.abort();let e=new AbortController;D.current=e;try{let t=(Vo.getState().byRoot[o]?.expandedPaths??[]).map(e=>Tg(e)).filter(e=>!!e&&e!==a&&e.startsWith(`${a}/`)),n=[a,...t];T.current=new Set(T.current);for(let e of n)T.current.delete(e);w(e=>{if(Object.keys(e).length===0)return e;let t={...e},r=!1;for(let e of n)e in t&&(delete t[e],r=!0);return r?t:e});let r=()=>e.signal.aborted;await me(a,r);for(let n=0;n<t.length&&!e.signal.aborted;n+=3){let e=t.slice(n,n+3);await Promise.all(e.map(e=>me(e,r)))}}catch(t){if(e.signal.aborted)return;console.error(`Failed to refresh sidebar tree:`,t)}finally{D.current===e&&(D.current=null)}},[me,a,o]),ge=Z.useCallback(async e=>{if(!e){await he();return}let t=Tg(e);T.current=new Set(T.current),T.current.delete(t),E.current=new Set(E.current),E.current.delete(t),await me(t)},[me,he]);Z.useEffect(()=>{a&&(D.current?.abort(),O.current=!1,T.current=new Set,E.current=new Set,w({}),S(e=>Object.keys(e).length===0?e:{}),me(a))},[me,a,c,l]),Z.useEffect(()=>{if(!a||j.length===0)return;let e=j.map(e=>Tg(e)).filter(e=>!!e&&e!==a&&e.startsWith(`${a}/`)&&!T.current.has(e)&&!E.current.has(e)).sort((e,t)=>e.split(`/`).length-t.split(`/`).length);if(e.length===0)return;let t=!1,n=()=>t;return(async()=>{for(let r=0;r<e.length&&!t;r+=3){let t=e.slice(r,r+3);await Promise.all(t.map(e=>me(e,n)))}})(),()=>{t=!0}},[j,me,a]),Z.useEffect(()=>{if(!i){v([]),b(!1);return}let e=h.trim();if(!e){v([]),b(!1);return}let t=!1;b(!0);let n={includeHidden:c,respectGitignore:!l,type:`file`};return(r?.location.hostId?r.service().searchFiles(e,{...n,directory:i,limit:150}):u(i,e,150,n)).then(e=>{if(t)return;let n=e.filter(e=>l||!Ag(e.path)).map(e=>({name:e.name,path:Tg(e.path),type:`file`,extension:e.extension,relativePath:e.relativePath}));v(n)}).catch(()=>{t||v([])}).finally(()=>{t||b(!1)}),()=>{t=!0}},[i,h,u,c,l,r]);let _e=Z.useMemo(()=>{let e=new Map;if(!f?.files)return e;for(let t of f.files)t.index===`A`||t.working_dir===`?`?e.set(t.path,`git-added`):t.index===`D`?e.set(t.path,`git-deleted`):(t.index===`M`||t.working_dir===`M`)&&e.set(t.path,`git-modified`);return e},[f]),ve=Z.useMemo(()=>{let e=new Map;if(!f?.files||!a)return e;for(let t of f.files){let n=t.index===`M`||t.working_dir===`M`,r=t.index===`A`||t.working_dir===`?`;if(!n&&!r)continue;let i=t.path.split(`/`);if(i.length<=1)continue;let o=a;for(let t=0;t<i.length-1;t++){o=`${o}/${i[t]}`;let a=e.get(o);a||(a={modified:0,added:0},e.set(o,a)),n&&a.modified++,r&&a.added++}}return e},[f,a]),ye=Z.useCallback(e=>{if(ee.has(e))return`open`;if(_e.size===0)return null;let t=e.startsWith(a+`/`)?e.slice(a.length+1):e;return _e.get(t)??null},[ee,_e,a]),be=Z.useCallback(e=>{if(ve.size===0)return null;let t=ve.get(e);return t&&t.modified+t.added>0?t:null},[ve]),xe=Z.useCallback(async e=>{if(!a)return;let n=await Lc(t,e.path);if(!n.ok){Y.error(Nc(n.reason));return}N(o,e.path),P(o,e.path),d(o,e.path)},[P,t,d,a,o,N]),Ce=Z.useCallback(async e=>{let t=Tg(e);a&&(L(o,t),T.current.has(t)||await me(t))},[me,a,o,L]),we=Z.useMemo(()=>a?If(a,x):[],[x,a]),Te=Z.useMemo(()=>new Set(j.map(e=>Tg(e))),[j]),Ee=Lf(j),De=Z.useCallback(()=>{if(a){if(Ee){O.current=!1,I(o,a);return}O.current=!0,R(o,we)}},[Ee,we,R,I,a,o]);Z.useEffect(()=>{if(!a||!O.current)return;let e=Rf(we,j);if(e.length>0){R(o,e);return}let t=new Set([...T.current,...Object.keys(C)]);zf(we,j,t)&&(O.current=!1)},[we,R,j,C,a,o]);let Oe=Z.useCallback(async n=>{if(n?.preventDefault(),!te||!B)return;H(!0);let r=()=>H(!1),i=()=>V(null);if(B===`createFile`){if(!re.trim()){Y.error(e(`sidebarFilesTree.toast.filenameRequired`)),r();return}if(!t.writeFile){Y.error(e(`sidebarFilesTree.toast.writeNotSupported`)),r();return}let n=te.path,a=Tg(`${n?`${n}/`:``}${re.trim()}`);await t.writeFile(a,``).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.fileCreated`)),await ge(n)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`createFolder`){if(!re.trim()){Y.error(e(`sidebarFilesTree.toast.folderNameRequired`)),r();return}let n=te.path,a=Tg(`${n?`${n}/`:``}${re.trim()}`);await t.createDirectory(a).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.folderCreated`)),await ge(n)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`rename`){if(!re.trim()){Y.error(e(`sidebarFilesTree.toast.nameRequired`)),r();return}if(!t.rename){Y.error(e(`sidebarFilesTree.toast.renameNotSupported`)),r();return}let n=te.path,s=n.split(`/`).slice(0,-1).join(`/`),c=Tg(`${s?`${s}/`:``}${re.trim()}`);await t.rename(n,c).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.renamedSuccessfully`)),await ge(s),a&&F(o,n),(M===n||M&&M.startsWith(`${n}/`))&&N(o,null)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`delete`){if(!t.delete){Y.error(e(`sidebarFilesTree.toast.deleteNotSupported`)),r();return}let n=te.path,s=n.split(`/`).slice(0,-1).join(`/`);await t.delete(n).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.deletedSuccessfully`)),await ge(s),a&&F(o,n),(M===n||M&&M.startsWith(n+`/`))&&N(o,null)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}r()},[B,te,re,t,ge,F,a,o,M,N,e]);function ke(n,r){return(x[n]??[]).map(n=>{let i=n.type===`directory`,o=i&&Te.has(Tg(n.path)),s=M===n.path;return(0,$.jsxs)(`li`,{className:`relative`,children:[r>0&&(0,$.jsx)(`span`,{className:`absolute top-3 left-[-12px] h-px w-3 bg-border/40`}),(0,$.jsx)(Rg,{node:n,root:a,isExpanded:o,isActive:s,status:i?void 0:ye(n.path),badge:i?be(n.path):void 0,permissions:ue,downloadFile:t.downloadFile,onSelect:xe,onToggle:Ce,onRevealPath:de,onOpenDialog:fe}),i&&o&&(0,$.jsxs)(`ul`,{className:`relative ml-3 flex flex-col border-l border-border/40 pl-3`,children:[C[n.path]?(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--status-error)]`,title:C[n.path],children:C[n.path]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`h-6 gap-1`,onClick:()=>void ge(n.path),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`sidebarFilesTree.actions.refreshTitle`)]})]}):null,ke(n.path,r+1)]})]},n.path)})}let Ae=!!(a&&x[a]),je=a?C[a]:null,Me=e(Ee?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`);return(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 px-2 py-1.5`,"data-sidebar-file-search":!0,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(ya,{ref:g,value:p,onChange:e=>m(e.target.value),placeholder:e(`sidebarFilesTree.search.placeholder`),"aria-label":e(`sidebarFilesTree.search.placeholder`),className:`h-7 rounded-md py-0 pl-7 pr-6 !text-xs leading-4 focus:ring-1 bg-[color-mix(in_srgb,var(--surface-foreground)_2%,var(--background))] hover:[&:not(:focus)]:bg-[color-mix(in_srgb,var(--surface-foreground)_4%,var(--background))]`}),p.trim().length>0?(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`sidebarFilesTree.search.clearAria`),className:`absolute right-1.5 top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground`,onClick:()=>{m(``),g.current?.focus()},children:(0,$.jsx)(X,{name:`close`,className:`size-3`})}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5`,children:[U&&(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>fe(`createFile`,{path:i,type:`directory`}),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.newFileTitle`),"aria-label":e(`sidebarFilesTree.actions.newFileTitle`),children:(0,$.jsx)(X,{name:`file-add`,className:`size-3.5`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.newFileTitle`)})]}),oe&&(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>fe(`createFolder`,{path:i,type:`directory`}),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.newFolderTitle`),"aria-label":e(`sidebarFilesTree.actions.newFolderTitle`),children:(0,$.jsx)(X,{name:`folder-add`,className:`size-3.5`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.newFolderTitle`)})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>void he(),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.refreshTitle`),"aria-label":e(`sidebarFilesTree.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`})})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.refreshTitle`)})]}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:De,disabled:we.length===0&&j.length===0,className:`w-6 flex-shrink-0 p-0`,title:Me,"aria-label":Me,children:(0,$.jsx)(X,{name:Ee?`contract-up-down`:`expand-up-down`,className:`size-3.5`})})}),(0,$.jsx)(ti,{side:`bottom`,sideOffset:6,children:Me})]})]})]}),(0,$.jsx)(Gr,{outerClassName:`flex-1 min-h-0`,className:`p-2`,children:(0,$.jsx)(`ul`,{className:`flex flex-col`,children:y?(0,$.jsxs)(`li`,{className:`flex items-center gap-1.5 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),e(`sidebarFilesTree.state.searching`)]}):_.length>0?_.map(e=>{let t=M===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>xe(e),draggable:!0,onDragStart:t=>{let n=e.relativePath||Eg(a??``,e.path);!n||n===`.`||(t.dataTransfer.setData(`application/x-yuri-file-path`,n),t.dataTransfer.effectAllowed=`copy`)},className:J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing`,t?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`),title:e.path,children:[Ig(e.path,e.extension),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code`,style:{direction:`rtl`,textAlign:`left`},children:e.relativePath??e.path})]})},e.path)}):je?(0,$.jsxs)(`li`,{className:`flex flex-col gap-2 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:je}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`w-fit gap-1.5`,onClick:()=>void he(),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`sidebarFilesTree.actions.refreshTitle`)]})]}):Ae&&a?ke(a,0):(0,$.jsx)(`li`,{className:`px-2 py-1 typography-code text-muted-foreground`,children:e(`sidebarFilesTree.state.loading`)})})}),(0,$.jsx)($r,{open:!!B,onOpenChange:e=>!e&&V(null),children:(0,$.jsxs)(Xr,{children:[(0,$.jsxs)(Jr,{children:[(0,$.jsxs)(Zr,{children:[B===`createFile`&&e(`sidebarFilesTree.dialog.createFile.title`),B===`createFolder`&&e(`sidebarFilesTree.dialog.createFolder.title`),B===`rename`&&e(`sidebarFilesTree.dialog.rename.title`),B===`delete`&&e(`sidebarFilesTree.dialog.delete.title`)]}),(0,$.jsxs)(Qr,{children:[B===`createFile`&&e(`sidebarFilesTree.dialog.createFile.description`,{path:te?.path??e(`sidebarFilesTree.dialog.rootFallback`)}),B===`createFolder`&&e(`sidebarFilesTree.dialog.createFolder.description`,{path:te?.path??e(`sidebarFilesTree.dialog.rootFallback`)}),B===`rename`&&e(`sidebarFilesTree.dialog.rename.description`,{name:te?.name??``}),B===`delete`&&e(`sidebarFilesTree.dialog.delete.description`,{name:te?.name??``})]})]}),B!==`delete`&&(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsx)(ya,{value:re,onChange:e=>ie(e.target.value),placeholder:e(B===`rename`?`sidebarFilesTree.dialog.rename.placeholder`:`sidebarFilesTree.dialog.namePlaceholder`),onKeyDown:e=>{e.key===`Enter`&&Oe()},autoFocus:!0})}),(0,$.jsxs)(Yr,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>V(null),disabled:ae,children:e(`sidebarFilesTree.dialog.cancel`)}),(0,$.jsx)(q,{variant:B===`delete`?`destructive`:`default`,onClick:()=>void Oe(),disabled:ae||B!==`delete`&&!re.trim(),children:ae?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):e(B===`delete`?`sidebarFilesTree.dialog.delete.confirm`:`sidebarFilesTree.dialog.confirm`)})]})]})})]})},Bg=()=>!(typeof document<`u`&&document.hidden||typeof navigator<`u`&&!navigator.onLine);function Vg(e,t,n,r){let i=(0,Q.c)(6),{git:a}=Ki(),o=ra(Hg),s=!!(e&&a&&t&&n===`git`&&r!==`git`),c,l;i[0]!==e||i[1]!==o||i[2]!==a||i[3]!==s?(c=()=>{if(!s||!e||!a)return;o(e,a);let t=window.setInterval(()=>{Bg()&&o(e,a)},1e4);return()=>window.clearInterval(t)},l=[s,e,a,o],i[0]=e,i[1]=o,i[2]=a,i[3]=s,i[4]=c,i[5]=l):(c=i[4],l=i[5]),Z.useEffect(c,l)}function Hg(e){return e.ensureStatus}var Ug=e=>{let t=(0,Q.c)(22),{railVisible:n}=e,{t:r}=Pr(),i=K(Gg),a=K(Kg),o=K(qg),s=K(Jg),c=K(Yg),l=xt(),u=!l?.entry.location.hostId,d;t[0]===u?d=t[1]:(d={enabled:u},t[0]=u,t[1]=d);let f=Do(d),p,m,h,g;if(t[2]!==f||t[3]!==l?.entry.location.hostId||t[4]!==i||t[5]!==c||t[6]!==a||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==r){let e=Ya({hideGit:c===`git`,showBrowser:!l?.entry.location.hostId&&Oo(f.data)}),u=e.includes(a)?a:e[0]??`files`;p=`group`,t[15]===r?m=t[16]:(m=r(`header.actions.toggleRightSidebarAria`),t[15]=r,t[16]=m),h=`inline-flex h-7 items-center overflow-hidden rounded-md border border-border/40 divide-x divide-border/40`,g=e.map(e=>{let t=(n??i)&&u===e,a=r(e===`git`?`layout.rightSidebar.git`:e===`files`?`contextPanel.actions.toggleFileTree`:`layout.rightSidebar.browser`);return(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:J(`h-full w-7 !rounded-none text-muted-foreground hover:text-foreground focus-visible:z-10 focus-visible:ring-inset`,t&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-pressed":t,"aria-label":a,title:a,onClick:()=>{s(e),o(!t)},children:(0,$.jsx)(X,{name:e===`git`?`git-branch`:e===`files`?`list-unordered`:`global`,className:`size-4`})},e)}),t[2]=f,t[3]=l?.entry.location.hostId,t[4]=i,t[5]=c,t[6]=a,t[7]=n,t[8]=o,t[9]=s,t[10]=r,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else p=t[11],m=t[12],h=t[13],g=t[14];let _;return t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,$.jsx)(`div`,{role:p,"aria-label":m,className:h,children:g}),t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_},Wg=e=>{let t=(0,Q.c)(34),{isActive:n}=e,r=K(Xg),i=K(Zg),a=Wi(),o=xt(),s=!o?.entry.location.hostId,c;t[0]===s?c=t[1]:(c={enabled:s},t[0]=s,t[1]=c);let l=Do(c),u;t[2]!==l.data?.providers||t[3]!==l.data?.selectedId?(u=l.data?.providers.find(e=>e.id===l.data?.selectedId)??null,t[2]=l.data?.providers,t[3]=l.data?.selectedId,t[4]=u):u=t[4];let d=u,f;t[5]!==l.data||t[6]!==o?.entry.location.hostId?(f=!o?.entry.location.hostId&&Oo(l.data),t[5]=l.data,t[6]=o?.entry.location.hostId,t[7]=f):f=t[7];let p=f,m=i===`git`,h;t[8]!==m||t[9]!==p?(h=Ya({hideGit:m,showBrowser:p}),t[8]=m,t[9]=p,t[10]=h):h=t[10];let g=h,_;t[11]!==r||t[12]!==g?(_=g.includes(r)?r:g[0]??`files`,t[11]=r,t[12]=g,t[13]=_):_=t[13];let v=_;Vg(a,n,v,i);let y=n&&v===`git`&&!m,b=v!==`git`&&`hidden`,x;t[14]===b?x=t[15]:(x=J(`h-full`,b),t[14]=b,t[15]=x);let S;t[16]===y?S=t[17]:(S=(0,$.jsx)(mg,{isActive:y}),t[16]=y,t[17]=S);let C;t[18]!==x||t[19]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[18]=x,t[19]=S,t[20]=C):C=t[20];let w=v!==`files`&&`hidden`,T;t[21]===w?T=t[22]:(T=J(`h-full`,w),t[21]=w,t[22]=T);let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(zg,{}),t[23]=E):E=t[23];let D;t[24]===T?D=t[25]:(D=(0,$.jsx)(`div`,{className:T,children:E}),t[24]=T,t[25]=D);let O;t[26]!==v||t[27]!==d||t[28]!==p?(O=p&&d?(0,$.jsx)(`div`,{className:J(`h-full`,v!==`browser`&&`hidden`),children:(0,$.jsx)(Cg,{provider:d})}):null,t[26]=v,t[27]=d,t[28]=p,t[29]=O):O=t[29];let k;return t[30]!==C||t[31]!==D||t[32]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-transparent`,children:(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[C,D,O]})}),t[30]=C,t[31]=D,t[32]=O,t[33]=k):k=t[33],k};function Gg(e){return e.isRightSidebarOpen}function Kg(e){return e.rightSidebarTab}function qg(e){return e.setRightSidebarOpen}function Jg(e){return e.setRightSidebarTab}function Yg(e){return e.activeMainTab}function Xg(e){return e.rightSidebarTab}function Zg(e){return e.activeMainTab}var Qg=e=>{if(re(e,`local`).hostId)return V(e);let t=e.trim().replace(/\\/g,`/`);if(!t)return``;let n=t.startsWith(`//`),r=t.replace(/\/+$/g,``).replace(/\/+/g,`/`);return n&&!r.startsWith(`//`)?`/${r}`:r||(t.startsWith(`/`)?`/`:``)},$g=()=>`react-surface`,e_=(e,t)=>JSON.stringify([Qg(e),t]),t_=(e,t,n,r)=>JSON.stringify([e,t,Qg(n),r]),n_=(e,t,n)=>n?t:e===t?e:null,r_=(e,t)=>e.sessionId===t.sessionId&&Qg(e.directory)===Qg(t.directory),i_=(e,t)=>Qg(e)===Qg(t),a_=e=>({anchor:e,current:e,stack:[]}),o_=(e,t)=>e??a_(t),s_=(e,t)=>e?.current.sessionId??t,c_=(e,t)=>r_(e.current,t)?e:{...e,current:t,stack:[...e.stack,e.current]},l_=e=>{let t=e.stack[e.stack.length-1];return t?{...e,current:t,stack:e.stack.slice(0,-1)}:e},u_=(e,t,n)=>!i_(e.anchor.directory,t.directory)||!i_(e.current.directory,t.directory)||n(t.sessionId,t.directory)===!1?{status:`rejected-cross-directory`,state:e}:{status:`navigated`,state:c_(e,t)},d_=(e,t,n)=>{let r=e[t];if(!r)return{accepted:!1,navigationBySurfaceId:e};let i=u_(r,n,()=>!0);return i.status===`navigated`?{accepted:!0,navigationBySurfaceId:i.state===r?e:{...e,[t]:i.state}}:{accepted:!1,navigationBySurfaceId:e}},f_=(e,t)=>{let n=!1,r={};for(let[i,a]of Object.entries(e)){if(!t.has(i)){n=!0;continue}r[i]=a}return n?r:e},p_=e=>e.directoryMatches?e.error?e.messageCount>0?`partial-error`:`fatal-error`:!e.renderable&&e.requested?`cold-loading`:e.messageCount===0?e.working?`working-empty`:`authoritative-empty`:`transcript`:`directory-mismatch`,m_=e=>e===`retry`,h_=e=>e.active&&e.visible&&e.messageCount<=0,g_=e=>e?`load-more`:`ensure`,__=e=>e.kind===`has-more`,v_=(e,t)=>`${e}\n${t}`,y_=(e,t,n,r)=>r&&!e.has(v_(t,n)),b_=(e,t)=>({scrollHeight:e,scrollTop:t}),x_=(e,t)=>Math.max(0,e.scrollTop+Math.max(0,t-e.scrollHeight)),S_=(e,t)=>e&&!t,C_=e=>e,w_=e=>!e,T_=e=>!S_(e.hasMore,e.isLoading)||!w_(e.historyVirtualized)?null:b_(e.scrollHeight,e.scrollTop),E_=(e,t,n)=>!!(e&&e.token===t&&e.viewportKey===n),D_=33554432,O_=e=>Math.min(D_,262144+Math.max(0,Math.ceil(e))*64*1024),k_=e=>Math.min(D_,Math.max(0,Math.round(Number.isFinite(e)?e:0))),A_=e=>{let t=Object.values(e.mountedViews),n=t.length,r=t.reduce((e,t)=>e+t.estimatedBytes,0),i=new Set,a=t.filter(t=>t.viewKey!==e.activeViewKey).sort((e,t)=>e.lastAccessed-t.lastAccessed);for(let e of a){if(n<=3&&r<=33554432)break;i.add(e.viewKey),--n,r-=e.estimatedBytes}if(i.size===0)return e;let o={...e.mountedViews};return i.forEach(e=>delete o[e]),{...e,mountedViews:o}},j_=(e,t)=>{if(t.type===`close-tab`){let n=Object.values(e.mountedViews).filter(e=>e.tabId===t.tabId);if(!e.tabs[t.tabId]&&n.length===0)return e;let r={...e.tabs},i={...e.mountedViews};return delete r[t.tabId],n.forEach(e=>delete i[e.viewKey]),{activeViewKey:n.some(t=>t.viewKey===e.activeViewKey)?null:e.activeViewKey,tabs:r,mountedViews:i}}if(t.type===`activate`){if(t.viewKey===e.activeViewKey)return e;let n=t.viewKey?e.mountedViews[t.viewKey]:void 0;if(t.viewKey&&!n)return e;if(!n)return{...e,activeViewKey:null};let r=n.lastAccessed===t.now?e.mountedViews:{...e.mountedViews,[n.viewKey]:{...n,lastAccessed:t.now}};return A_({...e,activeViewKey:t.viewKey,mountedViews:r})}if(t.type===`estimate`){let n=e.mountedViews[t.viewKey],r=k_(t.estimatedBytes);return!n||n.estimatedBytes===r?e:A_({...e,mountedViews:{...e.mountedViews,[n.viewKey]:{...n,estimatedBytes:r}}})}let n=e.tabs[t.tab.tabId],r=e.mountedViews[t.view.viewKey],i=n&&n.sessionId===t.tab.sessionId&&n.directory===t.tab.directory&&n.title===t.tab.title,a=r&&r.tabId===t.view.tabId&&r.surfaceId===t.view.surfaceId&&r.lastAccessed===t.now;return i&&a&&e.activeViewKey===t.view.viewKey?e:A_({...e,activeViewKey:t.view.viewKey,tabs:i?e.tabs:{...e.tabs,[t.tab.tabId]:t.tab},mountedViews:{...e.mountedViews,[t.view.viewKey]:{...t.view,estimatedBytes:r?.estimatedBytes??O_(0),lastAccessed:t.now}}})},M_=e=>{let t=(0,Q.c)(17),{state:n,error:r,onRetry:i}=e,{t:a}=Pr();if(n===`cold-loading`||n===`working-empty`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`})}),t[0]=e):e=t[0],e}if(n===`fatal-error`||n===`directory-mismatch`){let e;t[1]!==r||t[2]!==a?(e=r||a(`chat.emptyState.opencodeUnreachable`),t[1]=r,t[2]=a,t[3]=e):e=t[3];let o;t[4]===e?o=t[5]:(o=(0,$.jsx)(`div`,{className:`text-center`,children:e}),t[4]=e,t[5]=o);let s;t[6]!==i||t[7]!==n||t[8]!==a?(s=n===`fatal-error`?(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`sm`,onClick:i,children:a(`chat.history.retry`)}):null,t[6]=i,t[7]=n,t[8]=a,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-sm text-muted-foreground`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}let o;t[13]===a?o=t[14]:(o=a(`chat.timeline.empty.session`),t[13]=a,t[14]=o);let s;return t[15]===o?s=t[16]:(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:o}),t[15]=o,t[16]=s),s},N_=e=>{let t=(0,Q.c)(173),{surfaceId:n,sessionId:r,directory:i,active:a,canNavigateBack:o,onNavigateSession:s,onNavigateBack:c,onEstimateBytes:l,syncDirectory:u}=e,{t:d}=Pr(),f=ms(),m,h,g;t[0]!==i||t[1]!==r||t[2]!==n?(h=p(),m=Qg(i),g=t_(h,n,m,r),t[0]=i,t[1]=r,t[2]=n,t[3]=m,t[4]=h,t[5]=g):(m=t[3],h=t[4],g=t[5]);let _=g,v=Z.useRef(null),y=Z.useRef(null),b=Z.useRef(0),[x,S]=Z.useState(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=new Set,t[6]=C):C=t[6];let w=Z.useRef(C),T=Wn(r,u),E=yr(r,u),D=Nn(F_),O;t[7]===E?O=t[8]:(O=Xo(E),t[7]=E,t[8]=O);let k=O,A;bb0:{if(!k.modelId){let e;t[9]===d?e=t[10]:(e=d(`common.unavailable`),t[9]=d,t[10]=e),A=e;break bb0}let e;if(t[11]!==k.modelId||t[12]!==k.providerId||t[13]!==D){let n;t[15]===k.providerId?n=t[16]:(n=e=>e.id===k.providerId,t[15]=k.providerId,t[16]=n);let r=D.find(n);e=r?.models.some(e=>e.id===k.modelId)&&Gn(r,k.modelId)||k.modelId,t[11]=k.modelId,t[12]=k.providerId,t[13]=D,t[14]=e}else e=t[14];A=e}let j=A,M=Xn(r,u),N=hr(r,u).renderable,P;t[17]===r?P=t[18]:(P=e=>!!e.session.find(e=>e.id===r)?.parentID,t[17]=r,t[18]=P);let F=On(P,u),[I,L]=Z.useState(null),R,z;t[19]!==F||t[20]!==_?(R=()=>{L(e=>n_(e,_,F))},z=[F,_],t[19]=F,t[20]=_,t[21]=R,t[22]=z):(R=t[21],z=t[22]),Z.useLayoutEffect(R,z);let ee=F||I===_,B=nr(r,u),V;t[23]===r?V=t[24]:(V=e=>e.streamingMessageIds.get(r)??null,t[23]=r,t[24]=V);let te=cn(V),ne;t[25]===te?ne=t[26]:(ne=e=>te?e.messageStreamStates.get(te)?.phase??null:null,t[25]=te,t[26]=ne);let re=cn(ne),ie=M?.type===`busy`||M?.type===`retry`,ae;t[27]!==a||t[28]!==r||t[29]!==ie||t[30]!==T||t[31]!==_?(ae={scrollControllerRef:v,enabled:a,currentSessionId:r,viewportKey:_,sessionMessageCount:T,sessionIsWorking:ie,isMobile:!1},t[27]=a,t[28]=r,t[29]=ie,t[30]=T,t[31]=_,t[32]=ae):ae=t[32];let{scrollRef:H,notifyContentChange:U,getAnimationHandlers:oe,goToBottom:se,restoreSnapshot:ce,showScrollButton:ue}=os(ae),de;t[33]===se?de=t[34]:(de=e=>{se(e===void 0?`instant`:e)},t[33]=se,t[34]=de);let fe=G(de),pe;t[35]!==r||t[36]!==f?(pe=e=>{f.ensureSessionRenderable(r,m_(e))},t[35]=r,t[36]=f,t[37]=pe):pe=t[37];let me=G(pe),he,ge;t[38]!==a||t[39]!==me?(he=()=>{a&&me(`active`)},ge=[a,me],t[38]=a,t[39]=me,t[40]=he,t[41]=ge):(he=t[40],ge=t[41]),Z.useEffect(he,ge);let _e,ve;t[42]!==a||t[43]!==me||t[44]!==T?(_e=()=>{if(typeof window>`u`)return;let e=()=>{let e=document.visibilityState!==`hidden`&&document.hasFocus();h_({active:a,visible:e,messageCount:T})&&me(`retry`)};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},ve=[a,me,T],t[42]=a,t[43]=me,t[44]=T,t[45]=_e,t[46]=ve):(_e=t[45],ve=t[46]),Z.useEffect(_e,ve);let ye,be;t[47]!==l||t[48]!==T||t[49]!==_?(ye=()=>{l?.(_,O_(T))},be=[l,T,_],t[47]=l,t[48]=T,t[49]=_,t[50]=ye,t[51]=be):(ye=t[50],be=t[51]),Z.useEffect(ye,be);let xe,Se;t[52]!==N||t[53]!==ce||t[54]!==r||t[55]!==_?(xe=()=>{if(!y_(w.current,r,_,N))return;let e=v_(r,_);w.current.add(e),ce()},Se=[N,ce,r,_],t[52]=N,t[53]=ce,t[54]=r,t[55]=_,t[56]=xe,t[57]=Se):(xe=t[56],Se=t[57]),Z.useEffect(xe,Se);let Ce;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{y.current=null,S(null)},t[58]=Ce):Ce=t[58];let Te;t[59]===_?Te=t[60]:(Te=[_],t[59]=_,t[60]=Te),Z.useLayoutEffect(Ce,Te);let Ee;t[61]!==x||t[62]!==H||t[63]!==_?(Ee=()=>{let e=y.current,t=H.current;if(E_(e,x,_)){if(!t||!w_(!!v.current?.isHistoryVirtualized())){y.current=null;return}t.scrollTop=x_(e.anchor,t.scrollHeight),y.current=null}},t[61]=x,t[62]=H,t[63]=_,t[64]=Ee):Ee=t[64];let De;t[65]!==x||t[66]!==H||t[67]!==E||t[68]!==_?(De=[x,H,E,_],t[65]=x,t[66]=H,t[67]=E,t[68]=_,t[69]=De):De=t[69],Z.useLayoutEffect(Ee,De);let Oe;t[70]===m?Oe=t[71]:(Oe={directory:m},t[70]=m,t[71]=Oe);let ke=Oe,Ae=Vn(r,u).boundary,je;t[72]===Ae?je=t[73]:(je=__(Ae),t[72]=Ae,t[73]=je);let Me=je,Ne;t[74]!==B?.status||t[75]!==ke||t[76]!==r||t[77]!==f?(Ne=B?.status===`loading`||f.isLoading(r,ke),t[74]=B?.status,t[75]=ke,t[76]=r,t[77]=f,t[78]=Ne):Ne=t[78];let Pe=Ne,Fe;t[79]!==m||t[80]!==h||t[81]!==r?(Fe=[`context-panel-load-older`,h,m,r],t[79]=m,t[80]=h,t[81]=r,t[82]=Fe):Fe=t[82];let Ie;t[83]!==Ae||t[84]!==r||t[85]!==u?(Ie=async()=>{Ae.kind===`unknown`&&await we(u,r),await le(u,r)},t[83]=Ae,t[84]=r,t[85]=u,t[86]=Ie):Ie=t[86];let Le;t[87]!==Fe||t[88]!==Ie?(Le={mutationKey:Fe,mutationFn:Ie},t[87]=Fe,t[88]=Ie,t[89]=Le):Le=t[89];let W=vt(Le),Re=W.isPending,ze;t[90]!==Pe||t[91]!==Me||t[92]!==Re||t[93]!==W||t[94]!==H||t[95]!==d||t[96]!==_?(ze=()=>{if(!S_(Me,Re||Pe)||W.isPending)return;let e=b.current+1;b.current=e;let t=H.current,n=t?T_({hasMore:Me,isLoading:Re,historyVirtualized:!!v.current?.isHistoryVirtualized(),scrollHeight:t.scrollHeight,scrollTop:t.scrollTop}):null;y.current=n?{token:e,viewportKey:_,anchor:n}:null,W.mutateAsync().then(()=>{S(e)},()=>{S(e),Y.error(d(`chat.history.loadOlderFailed`))})},t[90]=Pe,t[91]=Me,t[92]=Re,t[93]=W,t[94]=H,t[95]=d,t[96]=_,t[97]=ze):ze=t[97];let Be=G(ze),Ve=B?.status===`error`?B.error:void 0,He;t[98]!==a||t[99]!==N||t[100]!==ie||t[101]!==E.length||t[102]!==Ve?(He=p_({directoryMatches:!0,requested:a,renderable:N,messageCount:E.length,working:ie,error:Ve}),t[98]=a,t[99]=N,t[100]=ie,t[101]=E.length,t[102]=Ve,t[103]=He):He=t[103];let Ue=He,We;t[104]!==a||t[105]!==m||t[106]!==s||t[107]!==r||t[108]!==n?(We={kind:`panel`,surfaceId:n,sessionId:r,directory:m,active:a,capabilities:Oa,navigateSession:s},t[104]=a,t[105]=m,t[106]=s,t[107]=r,t[108]=n,t[109]=We):We=t[109];let Ge=We,Ke;t[110]!==me||t[111]!==Me||t[112]!==Be?(Ke=()=>{if(g_(Me)===`load-more`){Be();return}me(`retry`)},t[110]=me,t[111]=Me,t[112]=Be,t[113]=Ke):Ke=t[113];let qe=G(Ke),Je;t[114]!==B?.error||t[115]!==qe||t[116]!==d||t[117]!==Ue?(Je=Ue===`partial-error`?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--status-error-foreground)]`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:B?.error}),(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`xs`,onClick:qe,children:d(`chat.history.retry`)})]}):null,t[114]=B?.error,t[115]=qe,t[116]=d,t[117]=Ue,t[118]=Je):Je=t[118];let Ye=Je,Xe;t[119]!==Me||t[120]!==Re||t[121]!==Be||t[122]!==d?(Xe=C_(Me)?(0,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsxs)(q,{type:`button`,variant:`secondary`,size:`sm`,onClick:Be,disabled:Re,children:[Re?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):null,d(`chat.history.loadOlder`)]})}):null,t[119]=Me,t[120]=Re,t[121]=Be,t[122]=d,t[123]=Xe):Xe=t[123];let Ze=Xe,Qe;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=(0,$.jsx)(`div`,{className:`flex-shrink-0`,style:{height:is},"aria-hidden":`true`}),t[124]=Qe):Qe=t[124];let $e=Qe,et;t[125]===fe?et=t[126]:(et=()=>fe(`instant`),t[125]=fe,t[126]=et);let tt;t[127]!==re||t[128]!==oe||t[129]!==Re||t[130]!==U||t[131]!==H||t[132]!==r||t[133]!==ie||t[134]!==E||t[135]!==te||t[136]!==u||t[137]!==et||t[138]!==_?(tt=(0,$.jsx)(es,{ref:v,sessionKey:r,virtualizerKey:_,messages:E,sessionIsWorking:ie,activeStreamingMessageId:te,activeStreamingPhase:re,onMessageContentChange:U,getAnimationHandlers:oe,isLoadingOlder:Re,scrollToBottom:et,scrollRef:H,directory:u,enableSendPark:!1}),t[127]=re,t[128]=oe,t[129]=Re,t[130]=U,t[131]=H,t[132]=r,t[133]=ie,t[134]=E,t[135]=te,t[136]=u,t[137]=et,t[138]=_,t[139]=tt):tt=t[139];let nt=tt,rt;t[140]===fe?rt=t[141]:(rt=()=>fe(`smooth`),t[140]=fe,t[141]=rt);let it;t[142]!==ue||t[143]!==rt?(it=(0,$.jsx)(Uo,{visible:ue,onClick:rt}),t[142]=ue,t[143]=rt,t[144]=it):it=t[144];let at=it,ot;t[145]!==o||t[146]!==c||t[147]!==d?(ot=o?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:c,className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":d(`chat.container.returnToParent.aria`),title:d(`chat.container.returnToParent.title`),children:[(0,$.jsx)(X,{name:`arrow-left`,className:`h-4 w-4`}),d(`chat.container.returnToParent.label`)]}):null,t[145]=o,t[146]=c,t[147]=d,t[148]=ot):ot=t[148];let st;t[149]!==me||t[150]!==Ze||t[151]!==Ye||t[152]!==B?.error||t[153]!==H||t[154]!==at||t[155]!==nt||t[156]!==Ue?(st=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:Ue===`cold-loading`||Ue===`working-empty`||Ue===`authoritative-empty`||Ue===`fatal-error`?(0,$.jsx)(M_,{state:Ue,error:B?.error,onRetry:()=>me(`retry`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Wr,{ref:H,className:`absolute inset-0 overflow-y-auto overflow-x-hidden chat-scroll overlay-scrollbar-target`,observeMutations:!1,"data-scroll-shadow":`true`,"data-scrollbar":`chat`,children:(0,$.jsxs)(`div`,{className:`relative min-h-full`,children:[Ye,Ze,nt,$e]})}),at]})}),t[149]=me,t[150]=Ze,t[151]=Ye,t[152]=B?.error,t[153]=H,t[154]=at,t[155]=nt,t[156]=Ue,t[157]=st):st=t[157];let ct;t[158]!==k.agentName||t[159]!==k.modelId||t[160]!==k.providerId||t[161]!==j||t[162]!==ee?(ct=ee?(0,$.jsx)($o,{agentName:k.agentName,providerId:k.providerId,modelId:k.modelId,modelName:j}):null,t[158]=k.agentName,t[159]=k.modelId,t[160]=k.providerId,t[161]=j,t[162]=ee,t[163]=ct):ct=t[163];let lt;t[164]!==r||t[165]!==n||t[166]!==ot||t[167]!==st||t[168]!==ct?(lt=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col bg-background`,"data-context-session-surface":`true`,"data-session-id":r,"data-surface-id":n,children:[ot,st,ct]}),t[164]=r,t[165]=n,t[166]=ot,t[167]=st,t[168]=ct,t[169]=lt):lt=t[169];let ut;return t[170]!==Ge||t[171]!==lt?(ut=(0,$.jsx)(ka.Provider,{value:Ge,children:lt}),t[170]=Ge,t[171]=lt,t[172]=ut):ut=t[172],ut},P_=e=>{let t=(0,Q.c)(22),n=Sn(),{t:r}=Pr(),i;t[0]===e.directory?i=t[1]:(i=Qg(e.directory),t[0]=e.directory,t[1]=i);let a=i,o=a===Qg(n),s;t[2]!==a||t[3]!==e.active||t[4]!==e.onNavigateSession||t[5]!==e.sessionId||t[6]!==e.surfaceId?(s={kind:`panel`,surfaceId:e.surfaceId,sessionId:e.sessionId,directory:a,active:e.active,capabilities:Oa,navigateSession:e.onNavigateSession},t[2]=a,t[3]=e.active,t[4]=e.onNavigateSession,t[5]=e.sessionId,t[6]=e.surfaceId,t[7]=s):s=t[7];let c=s;if(!o){let n=e.sessionId,i=e.surfaceId,a;t[8]===r?a=t[9]:(a=r(`chat.emptyState.opencodeUnreachable`),t[8]=r,t[9]=a);let o;t[10]===a?o=t[11]:(o=(0,$.jsx)(M_,{state:`directory-mismatch`,onRetry:I_,error:a}),t[10]=a,t[11]=o);let s;t[12]!==e.sessionId||t[13]!==e.surfaceId||t[14]!==o?(s=(0,$.jsx)(`div`,{className:`h-full`,"data-context-session-surface":`true`,"data-session-id":n,"data-surface-id":i,children:o}),t[12]=e.sessionId,t[13]=e.surfaceId,t[14]=o,t[15]=s):s=t[15];let l;return t[16]!==c||t[17]!==s?(l=(0,$.jsx)(ka.Provider,{value:c,children:s}),t[16]=c,t[17]=s,t[18]=l):l=t[18],l}let l;return t[19]!==e||t[20]!==n?(l=(0,$.jsx)(N_,{...e,syncDirectory:n}),t[19]=e,t[20]=n,t[21]=l):l=t[21],l};function F_(e){return e.providers}function I_(){}var L_=e=>{let t=e.trim();if(!t)return`about:blank`;try{let e=new URL(t.includes(`://`)?t:`https://${t}`);return e.protocol!==`http:`&&e.protocol!==`https:`?`about:blank`:e.toString()}catch{return`about:blank`}},R_=(e,t)=>{let n=L_(e),r=n===`about:blank`?``:n;return!r||r===t?null:r},z_=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.x==`number`&&typeof t.y==`number`},B_=e=>!e||typeof e!=`object`?!1:Object.values(e).every(e=>typeof e==`string`),V_=e=>{if(!e||typeof e!=`object`)return!1;let t=e,n=t.bounds;return typeof t.tag==`string`&&typeof t.text==`string`&&typeof t.selector==`string`&&typeof t.path==`string`&&!!n&&typeof n?.x==`number`&&typeof n?.y==`number`&&typeof n?.width==`number`&&typeof n?.height==`number`&&z_(t.center)&&B_(t.attributes)&&B_(t.computedStyle)&&Array.isArray(t.ancestry)},H_=({pageUrl:e,viewport:t,devicePixelRatio:n,target:r,screenshotAttached:i,intro:a})=>{let o=r.text.trim(),s=Object.entries(r.attributes).map(([e,t])=>`${e}="${t}"`).join(` `),c=r.computedStyle,l=r.bounds,u=r.center,d=a.replace(/[.:]+$/g,``),f=r.ancestry.map(e=>e.selectorPart).join(` > `);return[`${d}:`,`Page: ${e||`preview`}`,`Viewport: ${t.width}x${t.height}, DPR ${n}`,`Screenshot: ${i?`attached`:`not attached`}`,`Element: ${r.tag}`,o?`Text: ${o}`:null,`- Selector: ${r.selector}`,`- Path: ${r.path}`,f?`- Ancestry: ${f}`:null,s?`- Attributes: ${s}`:null,`- Bounds: x=${Math.round(l.x)}, y=${Math.round(l.y)}, width=${Math.round(l.width)}, height=${Math.round(l.height)}`,`- Center: x=${Math.round(u.x)}, y=${Math.round(u.y)}`,`Styles: display=${c.display}; position=${c.position}; font=${c.fontWeight} ${c.fontSize} / ${c.lineHeight} ${c.fontFamily}; color=${c.color}; background=${c.backgroundColor}; z-index=${c.zIndex}`].filter(e=>typeof e==`string`).join(`
|
|
18
|
+
`)},U_=async(e,t,n)=>{let r=St(n);if(r.assertCurrent(),typeof window<`u`)try{let n=e.getBoundingClientRect(),i=await ee(`desktop_capture_page_rect`,{x:n.left,y:n.top,width:n.width,height:n.height});if(r.assertCurrent(),!i)throw Error(`Desktop screenshot capture is not available`);let a=new Image;await new Promise((e,t)=>{a.onload=()=>e(),a.onerror=()=>t(Error(`Failed to load desktop preview screenshot`)),a.src=`data:${i.mime};base64,${i.base64}`});let o=Math.max(1,a.naturalWidth||i.width||Math.floor(n.width)),s=Math.max(1,a.naturalHeight||i.height||Math.floor(n.height)),c=Math.min(1,1200/o),l=document.createElement(`canvas`);l.width=Math.floor(o*c),l.height=Math.floor(s*c);let u=l.getContext(`2d`);if(!u)return null;u.scale(c,c),u.drawImage(a,0,0,o,s);let d=o/Math.max(1,n.width),f=s/Math.max(1,n.height);u.fillStyle=`rgba(37, 99, 235, 0.28)`,u.strokeStyle=`rgb(37, 99, 235)`,u.lineWidth=Math.max(2,2*d),u.fillRect(t.bounds.x*d,t.bounds.y*f,t.bounds.width*d,t.bounds.height*f),u.strokeRect(t.bounds.x*d,t.bounds.y*f,t.bounds.width*d,t.bounds.height*f);let p=await new Promise(e=>l.toBlob(e,`image/jpeg`,.82));return r.assertCurrent(),p?new File([p],`preview-annotation-${Date.now()}.jpg`,{type:`image/jpeg`}):null}catch(e){return console.warn(`[preview] failed to capture annotation screenshot:`,e),null}let i=await yv(e,t,n);return r.assertCurrent(),i},W_=async(e,t,n,r,i,a)=>{if(!e)return null;try{let o=new Image;await new Promise((t,n)=>{o.onload=()=>t(),o.onerror=()=>n(Error(`Failed to load desktop browser screenshot`)),o.src=`data:image/jpeg;base64,${e}`});let s=Math.max(1,o.naturalWidth||t),c=Math.max(1,o.naturalHeight||n),l=Math.min(1,1200/s),u=document.createElement(`canvas`);u.width=Math.floor(s*l),u.height=Math.floor(c*l);let d=u.getContext(`2d`);if(!d)return null;d.scale(l,l),d.drawImage(o,0,0,s,c);let f=s/Math.max(1,r||s),p=c/Math.max(1,i||c);d.fillStyle=`rgba(37, 99, 235, 0.14)`,d.strokeStyle=`rgb(37, 99, 235)`,d.lineWidth=Math.max(2,2*f),d.fillRect(a.bounds.x*f,a.bounds.y*p,a.bounds.width*f,a.bounds.height*p),d.strokeRect(a.bounds.x*f,a.bounds.y*p,a.bounds.width*f,a.bounds.height*p);let m=await new Promise(e=>u.toBlob(e,`image/jpeg`,.82));return m?new File([m],`browser-annotation-${Date.now()}.jpg`,{type:`image/jpeg`}):null}catch{return null}},G_=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=`,K_=new Map,q_=new Map,J_=3e4,Y_=e=>{let t=K_.get(e);return t?t.expiresAt-Date.now()<=J_?(K_.delete(e),null):t:null};function X_(e){let t=e.defaultView??window;try{let n=e.body?t.getComputedStyle(e.body).backgroundColor:``;if(n&&n!==`rgba(0, 0, 0, 0)`&&n!==`transparent`)return n;let r=t.getComputedStyle(e.documentElement).backgroundColor;if(r&&r!==`rgba(0, 0, 0, 0)`&&r!==`transparent`)return r}catch{}return`#ffffff`}var Z_=e=>new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(typeof r.result==`string`?r.result:G_),r.onerror=()=>n(r.error??Error(`Failed to read image blob`)),r.readAsDataURL(e)}),Q_=async(e,t=.82)=>{let n=await new Promise(n=>e.toBlob(n,`image/jpeg`,t));return n&&(await Z_(n)).split(`,`,2)[1]||``},$_=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},ev=(...e)=>{$_()&&[...e]},tv=(e,t=8)=>{let n=[];try{let r=e.querySelectorAll(`*`);for(let e of r){let r=e.scrollTop||0,i=e.scrollLeft||0;if(r<=0&&i<=0)continue;let a=e.tagName.toLowerCase(),o=e.id?`#${e.id}`:``,s=typeof e.className==`string`&&e.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(`.`)}`:``;if(n.push({selector:`${a}${o}${s}`,scrollTop:r,scrollLeft:i,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight}),n.length>=t)break}}catch{}return n},nv=`data-yuri-fixed-pin`,rv=(e,t,n)=>{if(t<=0&&n<=0)return()=>{};let r=e.defaultView;if(!r)return()=>{};let i=[],a=[];try{for(let o of e.querySelectorAll(`*`)){if(r.getComputedStyle(o).position!==`fixed`)continue;let e=o.getBoundingClientRect();if(!(e.width>0&&e.height>0))continue;o.setAttribute(nv,JSON.stringify({top:e.top+n,left:e.left+t,width:e.width,height:e.height})),i.push(o);let s=o.tagName.toLowerCase(),c=typeof o.className==`string`&&o.className?`.${o.className.trim().split(/\s+/).slice(0,2).join(`.`)}`:``;a.push({selector:`${s}${c}`,top:Math.round(e.top),left:Math.round(e.left),width:Math.round(e.width),height:Math.round(e.height)})}}catch{}return ev(`tagged fixed elements`,a),()=>{for(let e of i)try{e.removeAttribute(nv)}catch{}}},iv={name:`yuri-fixed-pin`,afterClone(e){let t=e?.clone;if(!(!t||typeof t.querySelectorAll!=`function`))for(let e of t.querySelectorAll(`[${nv}]`)){let t;try{t=JSON.parse(e.getAttribute(nv)||``)}catch{continue}e.style.setProperty(`position`,`absolute`,`important`),e.style.setProperty(`top`,`${t.top}px`,`important`),e.style.setProperty(`left`,`${t.left}px`,`important`),e.style.setProperty(`right`,`auto`,`important`),e.style.setProperty(`bottom`,`auto`,`important`),e.style.setProperty(`width`,`${t.width}px`,`important`),e.style.setProperty(`height`,`${t.height}px`,`important`),e.removeAttribute(nv)}}},av=`data-yuri-scroll-pin`,ov=e=>{let t=[],n=tv(e,64);try{let n=e.documentElement,r=e.body;for(let i of e.querySelectorAll(`*`)){let e=i.scrollTop||0,a=i.scrollLeft||0;if(e<=0&&a<=0)continue;let o=i!==n&&i!==r;o&&i.setAttribute(av,JSON.stringify({top:e,left:a})),t.push({el:i,top:e,left:a,tagged:o})}}catch{}return{reapply:()=>{for(let e of t)try{e.el.scrollHeight,e.el.scrollTop!==e.top&&(e.el.scrollTop=e.top),e.el.scrollLeft!==e.left&&(e.el.scrollLeft=e.left)}catch{}},cleanup:()=>{for(let e of t)if(e.tagged)try{e.el.removeAttribute(av)}catch{}},snapshot:n}},sv={name:`yuri-nested-scroll`,afterClone(e){let t=e?.clone;if(!t||typeof t.querySelectorAll!=`function`)return;let n=t.ownerDocument;if(n)for(let e of t.querySelectorAll(`[${av}]`)){let t;try{t=JSON.parse(e.getAttribute(av)||``)}catch{e.removeAttribute(av);continue}let r=`translate(${-t.left}px, ${-t.top}px)`,i=e.children.length===1&&e.firstElementChild instanceof HTMLElement&&e.firstElementChild.style.willChange===`transform`?e.firstElementChild:null;if(i)i.style.transform=r;else{e.style.overflow=`hidden`;let t=n.createElement(`div`);for(t.style.transform=r,t.style.willChange=`transform`,t.style.display=`inline-block`,t.style.width=`100%`;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t)}e.removeAttribute(av)}}},cv=async(e,t)=>{try{let n=await fetch(e,{credentials:t});return n.ok?await Z_(await n.blob()):null}catch{return null}},lv=async(e,t)=>{if(e.protocol!==`http:`&&e.protocol!==`https:`)return``;let n=t?JSON.stringify([t.queryScope,e.origin]):e.origin,r=t=>{let n=new URLSearchParams(e.search);return t.previewToken&&n.set(`yuri_preview_token`,t.previewToken),`${t.proxyBasePath}${e.pathname}${n.size?`?${n}`:``}${e.hash}`},i=Y_(n);if(i)return r(i);let a=q_.get(n),o=a??(async()=>{try{let r=St(t),i=await r.fetch(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({url:e.toString(),allowExternal:!0})});if(!i.ok)return K_.delete(n),null;let a=await i.json();r.assertCurrent();let o=typeof a.proxyBasePath==`string`?a.proxyBasePath:``,s=typeof a.expiresAt==`number`?a.expiresAt:0;if(!o||t&&(!da(o)||o.startsWith(`/api/hosts/`)&&!o.startsWith(A(t.location.hostId,`/api/preview/proxy/`))))return K_.delete(n),null;let c={proxyBasePath:o,expiresAt:s,...typeof a.previewToken==`string`?{previewToken:a.previewToken}:{}};if(t){for(let[e,t]of K_)t.expiresAt<=Date.now()&&K_.delete(e);for(;K_.size>=64;)K_.delete(K_.keys().next().value)}return K_.set(n,c),c}catch{return K_.delete(n),null}finally{q_.delete(n)}})();a||q_.set(n,o);let s=await o;return s?r(s):``},uv=async(e,t,n)=>{if(!e||e.startsWith(`data:`))return e;try{let r=new URL(e,t.baseURI);if(n&&[`http:`,`https:`].includes(r.protocol)){let e=St(n),t=A(n.location.hostId,`/api`).slice(0,-4),i;if(r.pathname.startsWith(`${t}/api/`))i=`${r.pathname.slice(t.length)}${r.search}`;else if(r.origin===window.location.origin&&r.pathname.startsWith(`/api/`)&&!r.pathname.startsWith(`/api/hosts/`))i=`${r.pathname}${r.search}`;else{let e=await lv(r,n);if(!e)return G_;i=e.startsWith(`${t}/api/`)?e.slice(t.length):e}let a=await e.fetch(i);if(!a.ok)return G_;let o=await Z_(await a.blob());return e.assertCurrent(),o}if(r.origin===window.location.origin||r.protocol!==`http:`&&r.protocol!==`https:`)return await cv(r.toString(),`include`)??G_;let i=await lv(r);return(i?await cv(i,`include`):null)||(await cv(r.toString(),`omit`)??G_)}catch{return G_}},dv=async(e,t,n)=>{if(!e||e===`none`||!e.includes(`url(`))return e;let r=Array.from(e.matchAll(/url\((['"]?)(.*?)\1\)/g)),i=e;for(let e of r){let r=e[2]||``;if(!r||r.startsWith(`data:`))continue;let a=await uv(r,t,n);i=i.replace(e[0],`url("${a}")`)}return i},fv=e=>e.complete?Promise.resolve():new Promise(t=>{e.addEventListener(`load`,()=>t(),{once:!0}),e.addEventListener(`error`,()=>t(),{once:!0})}),pv=e=>{let t=e.style.cssText;return()=>{e.style.cssText=t}},mv=e=>{let t=Number.parseFloat(e.lineHeight);if(Number.isFinite(t)&&t>0)return t;let n=Number.parseFloat(e.fontSize);return Number.isFinite(n)&&n>0?n*1.2:16},hv=(e,t,n)=>{let r=[],i=e.defaultView??window,a=Array.from(e.querySelectorAll(`button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *`));for(let e of a){let a=e.textContent?.replace(/\s+/g,` `).trim()??``;if(!a||!a.includes(` `))continue;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0||o.right<0||o.bottom<0||o.left>t||o.top>n)continue;let s=i.getComputedStyle(e);if(s.display===`none`||s.visibility===`hidden`||Number(s.opacity)===0)continue;let c=s.getPropertyValue(`text-wrap`),l=s.getPropertyValue(`text-wrap-mode`),u=s.whiteSpace.includes(`nowrap`)||c===`nowrap`||l===`nowrap`,d=o.height<=mv(s)*1.7;!u&&(!d||o.width>t*.72)||(r.push(pv(e)),e.style.whiteSpace=`nowrap`,e.style.overflowWrap=`normal`,e.style.wordBreak=`normal`,e.style.setProperty(`text-wrap`,`nowrap`),e.style.setProperty(`text-wrap-mode`,`nowrap`))}return()=>{for(let e=r.length-1;e>=0;--e)r[e]?.()}},gv=(e,t,n,r)=>{let i=[],a=e.defaultView??window,o=a.scrollX||e.documentElement.scrollLeft||e.body?.scrollLeft||0,s=a.scrollY||e.documentElement.scrollTop||e.body?.scrollTop||0,c=Array.from(e.querySelectorAll(`*`)).filter(e=>{let r=a.getComputedStyle(e);if(r.position!==`fixed`||r.display===`none`||r.visibility===`hidden`||Number(r.opacity)===0)return!1;let i=e.getBoundingClientRect();return i.width>0&&i.height>0&&i.right>=0&&i.bottom>=0&&i.left<=t&&i.top<=n}).filter((e,t,n)=>!n.some((n,r)=>r<t&&n.contains(e)));for(let e of c){let t=e.getBoundingClientRect(),n=a.getComputedStyle(e),c=Math.ceil(t.width)+8,l=Math.ceil(t.height)+2;r?.add(e),i.push(pv(e)),e.style.position=`absolute`,e.style.top=`${t.top+s}px`,e.style.left=`${t.left+o}px`,e.style.right=`auto`,e.style.bottom=`auto`,e.style.width=`${c}px`,e.style.minWidth=`${c}px`,e.style.height=`${l}px`,e.style.minHeight=`${l}px`,e.style.margin=`0`,e.style.boxSizing=`border-box`,e.style.transform=`none`,n.zIndex!==`auto`&&(e.style.zIndex=n.zIndex)}return()=>{for(let e=i.length-1;e>=0;--e)i[e]?.()}},_v=async(e,t,n,r={})=>{let i=[],a=e.defaultView??window,o=r=>{if(r===e.documentElement||r===e.body)return!0;try{let e=r.getBoundingClientRect();return e.width>0&&e.height>0&&e.right>=0&&e.bottom>=0&&e.left<=t&&e.top<=n}catch{return!1}};if(r.applyLayoutWorkarounds){let r=new WeakSet;i.push(gv(e,t,n,r)),i.push(hv(e,t,n))}let s=new Map;for(let t of Array.from(e.images))s.set(t,t.currentSrc||t.src||t.getAttribute(`src`)||``);let c=Array.from(e.querySelectorAll(`picture`));for(let e of c){let t=Array.from(e.querySelectorAll(`source`));if(t.length===0)continue;let n=t.map(e=>({source:e,srcset:e.getAttribute(`srcset`),sizes:e.getAttribute(`sizes`)}));i.push(()=>{for(let e of n)e.srcset===null?e.source.removeAttribute(`srcset`):e.source.setAttribute(`srcset`,e.srcset),e.sizes===null?e.source.removeAttribute(`sizes`):e.source.setAttribute(`sizes`,e.sizes)});for(let e of t)e.removeAttribute(`srcset`),e.removeAttribute(`sizes`)}let l=Array.from(e.images).filter(e=>o(e));await Promise.all(l.map(async t=>{let n=s.get(t)||t.currentSrc||t.src||t.getAttribute(`src`)||``;if(!n)return;await fv(t);let a=await uv(n,e,r.entry),o={src:t.getAttribute(`src`),srcset:t.getAttribute(`srcset`),sizes:t.getAttribute(`sizes`)};i.push(()=>{o.src===null?t.removeAttribute(`src`):t.setAttribute(`src`,o.src),o.srcset===null?t.removeAttribute(`srcset`):t.setAttribute(`srcset`,o.srcset),o.sizes===null?t.removeAttribute(`sizes`):t.setAttribute(`sizes`,o.sizes)}),t.removeAttribute(`srcset`),t.removeAttribute(`sizes`),t.setAttribute(`src`,a||G_),await fv(t)}));let u=Array.from(e.querySelectorAll(`*`)).filter(o);return await Promise.all(u.map(async t=>{let n=a.getComputedStyle(t).backgroundImage;if(!n||n===`none`||!n.includes(`url(`))return;let o=await dv(n,e,r.entry);if(o===n)return;let s=t.style.backgroundImage;i.push(()=>{t.style.backgroundImage=s}),t.style.backgroundImage=o})),()=>{for(let e=i.length-1;e>=0;--e)try{i[e]?.()}catch{}}};async function vv(e,t,n){try{let r=e.contentWindow,i=e.contentDocument??r?.document,a=i?.documentElement;if(!r||!i||!a)return null;let o=e.getBoundingClientRect(),s=Math.max(1,Math.ceil(r.innerWidth||e.clientWidth||o.width)),c=Math.max(1,Math.ceil(r.innerHeight||e.clientHeight||o.height)),l=i.body,u=i.scrollingElement instanceof HTMLElement?i.scrollingElement:null,d=r.scrollX||0,f=r.scrollY||0,p=r.pageXOffset||0,m=r.pageYOffset||0,h=r.visualViewport?.pageLeft||r.visualViewport?.offsetLeft||0,g=r.visualViewport?.pageTop||r.visualViewport?.offsetTop||0,_=a.scrollLeft||0,v=a.scrollTop||0,y=l?.scrollLeft||0,b=l?.scrollTop||0,x=u?.scrollLeft||0,S=u?.scrollTop||0,C=Math.max(d,p,h,_,y,x),w=Math.max(f,m,g,v,b,S);ev(`scroll sources`,{windowScrollX:d,windowScrollY:f,pageScrollX:p,pageScrollY:m,visualViewportScrollX:h,visualViewportScrollY:g,rootScrollX:_,rootScrollY:v,bodyScrollX:y,bodyScrollY:b,scrollingElementScrollX:x,scrollingElementScrollY:S,scrollingElementTag:u?.tagName?.toLowerCase()??null,resolvedScrollX:C,resolvedScrollY:w,nestedScrolledElements:tv(i)});let T=Math.max(s,a.scrollWidth||0,l?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),E=Math.max(c,a.scrollHeight||0,l?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),D=Math.min(2,Math.max(1,window.devicePixelRatio||1)),O=a.style.scrollBehavior,k=l?.style.scrollBehavior??``;a.style.scrollBehavior=`auto`,l&&(l.style.scrollBehavior=`auto`);let A=ov(i);ev(`nested scroll snapshot`,A.snapshot);let j=()=>{},M=()=>{};try{await i.fonts?.ready.catch(()=>void 0),j=await _v(i,s,c,{applyLayoutWorkarounds:!1,entry:n}),r.scrollTo(C,w),M=rv(i,C,w),A.reapply();let e={backgroundColor:X_(i),cache:`disabled`,dpr:D,embedFonts:!0,fast:!1,height:E,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[iv,sv],quality:.82,width:T},o=await(await Ou(a,e)).toCanvas();if(!o.width||!o.height)return null;let l=o.width/Math.max(1,T),u=o.height/Math.max(1,E),d=Math.min(o.width,Math.max(1,Math.round(s*l))),f=Math.min(o.height,Math.max(1,Math.round(c*u))),p=Math.max(0,o.width-d),m=Math.max(0,o.height-f),h=Math.min(p,Math.max(0,Math.round(C*l))),g=Math.min(m,Math.max(0,Math.round(w*u)));ev(`capture geometry`,{viewportWidth:s,viewportHeight:c,captureWidth:T,captureHeight:E,canvasWidth:o.width,canvasHeight:o.height,xScale:l,yScale:u,sourceX:h,sourceY:g,sourceWidth:d,sourceHeight:f});let _=i.createElement(`canvas`);_.width=d,_.height=f;let v=_.getContext(`2d`);if(!v)return null;v.drawImage(o,h,g,d,f,0,0,d,f);let y=await Q_(_,.82);return y?await W_(y,s,c,s,c,t):null}finally{M(),A.cleanup(),j(),r.scrollTo(C,w),A.reapply(),a.style.scrollBehavior=O,l&&(l.style.scrollBehavior=k)}}catch(e){return console.warn(`[preview] failed to capture iframe DOM screenshot with snapDOM:`,e),null}}async function yv(e,t,n){let r=await vv(e,t,n);if(r)return r;try{let r=e.contentWindow,i=e.contentDocument??r?.document,a=i?.documentElement;if(!r||!i||!a)return null;let o=e.getBoundingClientRect(),s=Math.max(1,Math.ceil(r.innerWidth||e.clientWidth||o.width)),c=Math.max(1,Math.ceil(r.innerHeight||e.clientHeight||o.height)),l=r.scrollX||i.documentElement.scrollLeft||i.body?.scrollLeft||0,u=r.scrollY||i.documentElement.scrollTop||i.body?.scrollTop||0,d=i.body,f=Math.max(c,a.scrollHeight||0,d?.scrollHeight||0),p=Math.min(2,Math.max(1,window.devicePixelRatio||1)),m=a.style.scrollBehavior,h=d?.style.scrollBehavior??``;a.style.scrollBehavior=`auto`,d&&(d.style.scrollBehavior=`auto`);let g=``,_=()=>{};try{await i.fonts?.ready.catch(()=>void 0),_=await _v(i,s,c,{applyLayoutWorkarounds:!0,entry:n}),r.scrollTo(l,u);let e=await Au(a).catch(()=>``);g=await ku(a,{quality:.82,pixelRatio:p,width:s,height:c,backgroundColor:X_(i),imagePlaceholder:G_,fontEmbedCSS:e||void 0,style:{transform:`translate(${-l}px, ${-u}px)`,transformOrigin:`top left`,minWidth:`${s}px`,minHeight:`${f}px`},cacheBust:!0})}finally{_(),r.scrollTo(l,u),a.style.scrollBehavior=m,d&&(d.style.scrollBehavior=h)}let v=g.split(`,`,2)[1]||``;return v?await W_(v,s,c,s,c,t):null}catch(e){return console.warn(`[preview] failed to capture iframe DOM screenshot:`,e),null}}var bv=()=>{if(!(typeof window>`u`))return window.__YURI_DESKTOP__?.browserRelay};async function xv(e,n,r){let i=bv();if(!i)throw Error(`Browser network unsupported`);let a=St(r),o=d(),s=!1,l,u,f=new AbortController,p=()=>{},m=()=>{},h=()=>{},g=()=>{},_=new Promise((e,t)=>{g=t});_.catch(()=>{});let v=()=>{s||(s=!0,e.removeEventListener(`abort`,b),f.abort(),p(),m(),h(),u?.close(),l&&i.stop(l.scope).catch(()=>{}),g(new DOMException(`Browser runtime ended`,`AbortError`)))},y=e=>{s||(v(),n(e))},b=()=>v(),x=()=>{if(s||e.aborted||o!==d())throw new DOMException(`Browser runtime ended`,`AbortError`);a.assertCurrent(e)},S=setTimeout(()=>y(Error(`Browser Relay timed out`)),2e4);try{x(),e.addEventListener(`abort`,b,{once:!0}),m=c(()=>y(Error(`Browser runtime changed`))),h=t(()=>y(Error(`Browser authorization changed`)));let n=Promise.resolve(),a=0;u=await Promise.race([la({signal:f.signal,path:A(r?.location.hostId,`/api/gui-network/ws`),openSocket(e){return x(),ot(e)},onFailure:()=>y(Error(`Browser Relay disconnected`)),onMessage(e){if(s||!l)return;x();let t=typeof e.data==`string`?e.data:new Uint8Array(e.data),r=typeof t==`string`?t.length*2:t.byteLength;if(a+=r,a>4194304){y(Error(`Browser Relay buffer limit`));return}n=n.then(async()=>{!s&&l&&(x(),await i.write(l.scope,t))}).catch(()=>y(Error(`Browser Relay stream failed`))).finally(()=>{a-=r})}}),_]),x();let o=u.socket;p=i.subscribe(e=>{if(!(s||e.scope!==l?.scope))try{if(x(),o.readyState!==1)throw Error(`Browser Relay disconnected`);o.send(e.data)}catch{y(Error(`Browser Relay disconnected`))}});let d=i.start().then(e=>(s&&i.stop(e.scope).catch(()=>{}),e));if(l=await Promise.race([d,_]),x(),!l.partition.startsWith(`yuri-browser-relay-`))throw Error(`Invalid Browser partition`);return{partition:l.partition,release:v}}catch(e){throw v(),e}finally{clearTimeout(S)}}var Sv=()=>!T()||p()===`local`,Cv=300,wv=1400,Tv=600,Ev=24,Dv=400,Ov=new Map,kv=()=>()=>{},Av=200,jv=(e,t)=>t===`all`?!0:t===`errors`?e.level===`error`||e.level===`runtime`||e.level===`resource`:t===`warnings`?e.level===`warn`:e.level===`log`||e.level===`info`||e.level===`debug`,Mv=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},Nv=e=>Number.isFinite(e)?Math.min(wv,Math.max(Cv,Math.round(e))):Tv,Pv=e=>{let t=e?.parentElement?.clientWidth;return!t||t<=0?null:t},Fv=(e,t)=>{let n=Nv(e),r=Pv(t);return r===null?n:Math.min(n,Math.max(1,r))},Iv=(e,t)=>{if(!e)return``;let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`).replace(/\/+$/,``);return r&&n.startsWith(r+`/`)?n.slice(r.length+1):n},Lv=(e,t)=>t(e===`chat`?`contextPanel.mode.chat`:e===`btw`?`chat.btw.title`:e===`file`?`contextPanel.mode.files`:e===`diff`||e===`file-diff`?`contextPanel.mode.diff`:e===`preview`?`contextPanel.mode.preview`:e===`browser`?`contextPanel.mode.browser`:`contextPanel.mode.context`),Rv=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`).trim();if(!t)return null;let n=t.split(`/`).filter(Boolean);return n.length===0?t:n[n.length-1]||null},zv=(e,t,n)=>{if(e.mode===`chat`){let r=Vv(e.dedupeKey);if(r){let e=t.get(r)?.trim();if(e)return e}return e.sessionTitleFallback?.trim()||n(`contextPanel.mode.chat`)}if(e.label)return e.label;if(e.mode===`file`)return Rv(e.targetPath)||n(`contextPanel.mode.files`);if(e.mode===`preview`){let t=e.targetPath;if(t)try{let e=new URL(t);return e.host||e.hostname||n(`contextPanel.mode.preview`)}catch{}return n(`contextPanel.mode.preview`)}return e.mode===`diff`?n(`contextPanel.mode.diff`):e.mode===`file-diff`?Rv(e.targetPath)||n(`contextPanel.mode.diff`):Lv(e.mode,n)},Bv=e=>{if(e.mode===`file`)return e.targetPath?(0,$.jsx)(ii,{filePath:e.targetPath,className:`h-3.5 w-3.5`}):void 0;if(e.mode===`diff`||e.mode===`file-diff`)return(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`});if(e.mode===`context`)return(0,$.jsx)(X,{name:`file-list-2`,className:`h-3.5 w-3.5`});if(e.mode===`chat`)return(0,$.jsx)(X,{name:`chat-thread`,className:`h-3.5 w-3.5`});if(e.mode===`preview`)return(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5 text-[var(--status-info)]`});if(e.mode===`browser`)return(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5`})},Vv=e=>!e||!e.startsWith(`session:`)?null:e.slice(8).trim()||null,Hv=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0},Uv=(e,t)=>{if(t.length===0)return Ov;let n=new Set(t),r=new Map;for(let t of e){if(!n.has(t.id))continue;let e=t.title?.trim();e&&r.set(t.id,e)}return r.size===0?Ov:r},Wv=(e,t,n)=>{let r=xt(),i=!!r?.entry.location.hostId,a=wn(r?.entry.location.hostId?void 0:e,{bootstrap:!r?.entry.location.hostId}),o=Z.useRef(Ov),s=Z.useRef(t);s.current=t;let c=Z.useSyncExternalStore(i?kv:a.subscribe,Z.useMemo(()=>()=>{if(i)return Ov;let e=Uv(a.getState().session,s.current);return Hv(o.current,e)?o.current:(o.current=e,e)},[i,a]),()=>Ov);return Z.useMemo(()=>r?.entry.location.hostId?Uv(n??[],t):c,[r?.entry.location.hostId,c,n,t])},Gv=`new Promise((resolve) => {
|
|
19
|
+
const existing = document.getElementById('__yuri_desktop_browser_overlay');
|
|
20
|
+
if (existing) existing.remove();
|
|
21
|
+
if (typeof window.__yuriDesktopBrowserCancelInspect === 'function') {
|
|
22
|
+
try { window.__yuriDesktopBrowserCancelInspect(); } catch { /* webview not ready */ }
|
|
23
|
+
}
|
|
24
|
+
const overlay = document.createElement('div');
|
|
25
|
+
overlay.id = '__yuri_desktop_browser_overlay';
|
|
26
|
+
overlay.style.cssText = 'position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #60a5fa;background:rgba(96,165,250,.24);border-radius:3px;display:none;box-sizing:border-box;';
|
|
27
|
+
document.documentElement.appendChild(overlay);
|
|
28
|
+
const cssEscape = (value) => {
|
|
29
|
+
try { return CSS.escape(value); } catch { return String(value).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&'); }
|
|
30
|
+
};
|
|
31
|
+
const selectorPart = (element) => {
|
|
32
|
+
const tag = element.tagName.toLowerCase();
|
|
33
|
+
if (element.id) return tag + '#' + cssEscape(element.id);
|
|
34
|
+
const className = String(element.className || '').trim().split(/\\s+/).filter(Boolean).slice(0, 3).map((part) => '.' + cssEscape(part)).join('');
|
|
35
|
+
return tag + className;
|
|
36
|
+
};
|
|
37
|
+
const metadata = (element) => {
|
|
38
|
+
const rect = element.getBoundingClientRect();
|
|
39
|
+
const style = getComputedStyle(element);
|
|
40
|
+
const ancestry = [];
|
|
41
|
+
let current = element;
|
|
42
|
+
while (current && current.nodeType === Node.ELEMENT_NODE && ancestry.length < 8) {
|
|
43
|
+
ancestry.unshift({ tag: current.tagName.toLowerCase(), id: current.id || undefined, className: typeof current.className === 'string' ? current.className : undefined, selectorPart: selectorPart(current) });
|
|
44
|
+
current = current.parentElement;
|
|
45
|
+
}
|
|
46
|
+
const attrs = {};
|
|
47
|
+
for (const attr of Array.from(element.attributes || []).slice(0, 16)) attrs[attr.name] = attr.value.slice(0, 300);
|
|
48
|
+
const path = ancestry.map((entry) => entry.selectorPart).join(' > ');
|
|
49
|
+
return {
|
|
50
|
+
frame: 'top',
|
|
51
|
+
tag: element.tagName.toLowerCase(),
|
|
52
|
+
text: String(element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 500),
|
|
53
|
+
selector: element.id ? '#' + cssEscape(element.id) : path,
|
|
54
|
+
path,
|
|
55
|
+
bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
56
|
+
center: { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
|
|
57
|
+
attributes: attrs,
|
|
58
|
+
computedStyle: { display: style.display, position: style.position, fontWeight: style.fontWeight, fontSize: style.fontSize, lineHeight: style.lineHeight, fontFamily: style.fontFamily, color: style.color, backgroundColor: style.backgroundColor, zIndex: style.zIndex },
|
|
59
|
+
ancestry,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const move = (event) => {
|
|
63
|
+
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
64
|
+
if (!element || element === overlay || element === document.documentElement || element === document.body) return;
|
|
65
|
+
const rect = element.getBoundingClientRect();
|
|
66
|
+
overlay.style.display = 'block';
|
|
67
|
+
overlay.style.left = rect.left + 'px';
|
|
68
|
+
overlay.style.top = rect.top + 'px';
|
|
69
|
+
overlay.style.width = rect.width + 'px';
|
|
70
|
+
overlay.style.height = rect.height + 'px';
|
|
71
|
+
};
|
|
72
|
+
const cleanup = () => {
|
|
73
|
+
window.removeEventListener('mousemove', move, true);
|
|
74
|
+
window.removeEventListener('click', click, true);
|
|
75
|
+
window.removeEventListener('keydown', keydown, true);
|
|
76
|
+
if (window.__yuriDesktopBrowserCancelInspect === cancel) {
|
|
77
|
+
delete window.__yuriDesktopBrowserCancelInspect;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const cancel = () => {
|
|
81
|
+
cleanup();
|
|
82
|
+
overlay.remove();
|
|
83
|
+
resolve(null);
|
|
84
|
+
};
|
|
85
|
+
const click = (event) => {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
event.stopPropagation();
|
|
88
|
+
const element = document.elementFromPoint(event.clientX, event.clientY);
|
|
89
|
+
const result = element ? metadata(element) : null;
|
|
90
|
+
cleanup();
|
|
91
|
+
overlay.remove();
|
|
92
|
+
resolve(result);
|
|
93
|
+
};
|
|
94
|
+
const keydown = (event) => {
|
|
95
|
+
if (event.key !== 'Escape') return;
|
|
96
|
+
cancel();
|
|
97
|
+
};
|
|
98
|
+
window.__yuriDesktopBrowserCancelInspect = cancel;
|
|
99
|
+
window.addEventListener('mousemove', move, true);
|
|
100
|
+
window.addEventListener('click', click, true);
|
|
101
|
+
window.addEventListener('keydown', keydown, true);
|
|
102
|
+
});`,Kv=`(() => {
|
|
103
|
+
if (typeof window.__yuriDesktopBrowserCancelInspect === 'function') {
|
|
104
|
+
window.__yuriDesktopBrowserCancelInspect();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const overlay = document.getElementById('__yuri_desktop_browser_overlay');
|
|
108
|
+
if (overlay) overlay.remove();
|
|
109
|
+
})()`,qv=`(() => {
|
|
110
|
+
if (window.__yuriSameWebviewNavigationInstalled) return;
|
|
111
|
+
window.__yuriSameWebviewNavigationInstalled = true;
|
|
112
|
+
|
|
113
|
+
const navigate = (rawUrl) => {
|
|
114
|
+
if (typeof rawUrl !== 'string' || rawUrl.length === 0) return false;
|
|
115
|
+
try {
|
|
116
|
+
const url = new URL(rawUrl, window.location.href);
|
|
117
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
|
|
118
|
+
window.location.assign(url.href);
|
|
119
|
+
return true;
|
|
120
|
+
} catch (_error) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const originalOpen = window.open.bind(window);
|
|
126
|
+
window.open = (url, target, features) => {
|
|
127
|
+
if (navigate(url)) return null;
|
|
128
|
+
return originalOpen(url, target, features);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
document.addEventListener('click', (event) => {
|
|
132
|
+
if (event.defaultPrevented) return;
|
|
133
|
+
const target = event.target;
|
|
134
|
+
if (!(target instanceof Element)) return;
|
|
135
|
+
const anchor = target.closest('a[target="_blank"][href]');
|
|
136
|
+
if (!(anchor instanceof HTMLAnchorElement)) return;
|
|
137
|
+
if (!navigate(anchor.href)) return;
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
}, true);
|
|
141
|
+
})()`,Jv=async(e,t)=>{let n=e.contentWindow;if(!n)throw Error(`Iframe window is not available`);let r=n.eval.call(n,t);return await Promise.resolve(r)},Yv=(e,t)=>e.length<=t?e:`${e.slice(0,t-3)}...`,Xv=(e,t)=>{let n=A(e?.location.hostId,`/api/preview/proxy/`);return t.startsWith(n)?t:A(e?.location.hostId,t)},Zv=(e,t)=>{let n=A(e?.location.hostId,`/api/preview/proxy/`),r=t.startsWith(n)?t.slice(n.length):t.startsWith(`/api/preview/proxy/`)?t.slice(19):``;return/^[a-f0-9]{16,64}$/i.test(r)},Qv=e=>{if(typeof window>`u`)return``;try{return new URL(e||window.location.href,window.location.href).origin}catch{return window.location.origin}},$v=(e,t,n)=>{let r=Qv(t);e.postMessage(n,r)},ey=e=>{if(!e)return e;try{let t=new URL(e);return t.searchParams.delete(`yuri_preview_token`),t.searchParams.delete(`yuri_client_token`),t.searchParams.delete(`yuri_url_token`),t.toString()}catch{return e}},ty=({rawUrl:e,onNavigate:t})=>{let n=xt()?.entry,r=n?.fetch??g,{t:a}=Pr(),{currentTheme:o}=oi(),[c,d]=Z.useReducer(e=>e+1,0),[f,p]=Z.useReducer(e=>e+1,0),[m,_]=Z.useState({status:`idle`}),[v,y]=Z.useState(``),b=Z.useRef(null),x=Z.useRef(1),[S,C]=Z.useState(!1),[w,T]=Z.useState(!1),[E,D]=Z.useState(`all`),[O,k]=Z.useState([]),[j,N]=Z.useState(!1),[P,F]=Z.useState(null),I=Jn(e=>e.currentSessionId),L=Jn(e=>e.newSessionDraft?.open),R=ln(e=>e.remoteSession),z=n&&R&&ne(R.location)===n.key?R:null,ee=n?.location.hostId?z?.sessionId??null:I,B=n?.location.hostId?!z?.sessionId:L,V=ai(e=>e.addDraft),te=Ir(e=>e.addAttachedFile),re=G(async e=>{if(!n?.location.hostId)return te(e);let t={transportIdentity:u(),location:n.location},r=ee?ft(t,ee):ut(t,`remote-new-session`);await Ir.getState().addDraftLocalAttachment(r,e)}),ie=n?.location.hostId?M(n.location,ee??`draft`):ee??(B?`draft`:null),ae=null;try{ae=e?new URL(e):null}catch{ae=null}let H=ae?ae.hostname===`localhost`||ae.hostname===`127.0.0.1`||ae.hostname===`::1`||ae.hostname===`[::1]`||ae.hostname===`0.0.0.0`:!1,U=H||!!n?.location.hostId,oe=ae?ae.hostname===`0.0.0.0`?new URL(ae.toString().replace(`0.0.0.0`,`127.0.0.1`)):ae:null,se=oe?oe.toString():``,ce=se?n?.location.hostId?`${h()||`same-origin`}|${n.key}|${n.connectionGeneration}|${se}`:`${h()||`same-origin`}|${se}`:``,le=o.metadata.variant;Z.useEffect(()=>{if(!se||!U){_({status:`idle`});return}let e=Y_(ce);if(e?.previewToken)return _({status:`ready`,proxyBasePath:e.proxyBasePath,previewToken:e.previewToken,expiresAt:e.expiresAt}),()=>{n?.location.hostId&&K_.delete(ce)};e&&K_.delete(ce);let t=!1;return _({status:`loading`}),(async()=>{try{let e=await r(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?.location.hostId?{"x-opencode-directory":n.location.directory}:{}},credentials:`include`,body:JSON.stringify({url:se,...n?.location.hostId&&!H?{allowExternal:!0}:{}})});if(!e.ok){K_.delete(ce);let n=await e.json().catch(()=>({})),r=typeof n?.error==`string`?n.error:`HTTP ${e.status}`;t||_({status:`error`,message:r});return}let i=await e.json(),o=typeof i.proxyBasePath==`string`&&Zv(n,i.proxyBasePath)?Xv(n,i.proxyBasePath):``,s=typeof i.previewToken==`string`?i.previewToken:``,c=typeof i.expiresAt==`number`?i.expiresAt:0;if(!Zv(n,o)||!s||!Number.isFinite(c)||c<=Date.now()){K_.delete(ce),t||_({status:`error`,message:a(`contextPanel.preview.proxyError`)});return}if(t)return;n?.sdk(),K_.set(ce,{proxyBasePath:o,previewToken:s,expiresAt:c}),t||_({status:`ready`,proxyBasePath:o,previewToken:s,expiresAt:c})}catch(e){if(K_.delete(ce),!t){let t=e instanceof Error?e.message:String(e);_({status:`error`,message:t})}}})(),()=>{t=!0,n?.location.hostId&&K_.delete(ce)}},[n,r,H,U,ce,f,a,se]);let ue=oe&&(oe.protocol===`http:`||oe.protocol===`https:`)?oe.toString():``,de=U&&m.status===`ready`?`${m.proxyBasePath}|${m.previewToken||``}|${c}`:``;Z.useEffect(()=>{if(!de){y(``);return}let e=!1;return y(``),i(h()).then(t=>{!e&&t&&y(de)}).catch(()=>{}),()=>{e=!0}},[de]);let fe=U&&m.status===`ready`&&oe&&v===de?(()=>{let e=oe.pathname||`/`,t=new URLSearchParams(oe.search);t.delete(`yuri_url_token`),t.delete(`yuri_client_token`),t.set(`yuriPreview`,String(c)),t.set(`yuri_preview_token`,m.previewToken||``);let r=t.toString(),i=oe.hash||``;return l().authenticatedAsset(Xv(n,`${m.proxyBasePath}${e}${r?`?${r}`:``}${i}`))})():``,pe=U&&s()&&fa(),[me,he]=Z.useState(``);Z.useEffect(()=>{if(!pe){he(``);return}let e=!1;return he(``),pa().then(t=>{!e&&t&&he(t)}).catch(()=>{e||he(``)}),()=>{e=!0}},[pe,de]);let ge=U?ua({relayActive:pe,gatewayOrigin:me||null,authenticatedAssetUrl:fe}):``,_e=pe&&!!fe&&!me,ve=U?_e?``:ge:ue,ye=U?ey(ge||fe):ue,be=U&&(m.status===`loading`||m.status===`idle`||v!==de||_e),xe=U&&m.status===`error`,Se=Z.useCallback(t=>{let r=ie;if(!r){Y.error(a(`contextPanel.preview.inspect.attachNoSession`));return}let i=e||ve||``,o=typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},s=typeof window<`u`?window.devicePixelRatio:1;(async()=>{let e=!1;try{let r=b.current,i=r?await U_(r,t,n):null;i&&(await re(i),e=!0)}catch{e=!1}V({sessionKey:r,source:`preview-annotation`,fileLabel:i||`preview`,startLine:1,endLine:1,code:H_({pageUrl:i,viewport:o,devicePixelRatio:s,target:t,screenshotAttached:e,intro:a(`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),Y.success(a(`contextPanel.preview.inspect.attached`))})()},[n,re,V,ie,ve,e,a]);Z.useEffect(()=>{C(!1),k([]),T(!1),D(`all`),N(!1),F(null),x.current=1},[ve]),Z.useEffect(()=>{let e=b.current?.contentWindow;!S||!e||$v(e,ve||fe,{source:`yuri-preview-parent`,version:1,type:`set-inspect-mode`,enabled:j})},[S,ve,j,fe]),Z.useEffect(()=>{let e=b.current?.contentWindow;!S||!e||$v(e,ve||fe,{source:`yuri-preview-parent`,version:1,type:`set-color-scheme`,scheme:le})},[S,ve,le,fe]),Z.useEffect(()=>{if(!j||typeof window>`u`)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),N(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[j]),Z.useEffect(()=>{if(!U||typeof window>`u`)return;let e=e=>{if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}},r=e=>{let t=x.current;x.current+=1,k(n=>{let r=[...n,{...e,id:t}];return r.length>Av?r.slice(r.length-Av):r})},i=i=>{if(i.source!==b.current?.contentWindow)return;let o=i.data;if(!(!o||o.source!==`yuri-preview-bridge`||o.version!==1)){if(o.type===`ready`){C(!0);return}if(o.type===`console`){let t=o.level===`error`||o.level===`warn`||o.level===`info`||o.level===`debug`?o.level:`log`,n=Array.isArray(o.args)?o.args.map(e).filter(Boolean):[];r({level:t,message:n.join(` `),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`runtime-error`){let t=e(o.filename),n=typeof o.line==`number`?o.line:null,i=typeof o.column==`number`?o.column:null,s=t?`${t}${n===null?``:`:${n}${i===null?``:`:${i}`}`}`:``,c=e(o.stack);r({level:`runtime`,message:e(o.message)||a(`contextPanel.preview.console.runtimeError`),details:[s,c].filter(Boolean).join(`
|
|
142
|
+
`),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`resource-error`){let t=e(o.tag)||`resource`,n=e(o.url);r({level:`resource`,message:n?`${t}: ${n}`:t,details:e(o.outerHTML),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`hover`){F(V_(o.target)?o.target:null);return}if(o.type===`select`&&V_(o.target)){F(o.target),N(!1),Se(o.target);return}if(o.type===`navigate-preview`){let e=typeof o.url==`string`?o.url:``,r=o.navigation===`external`?`external`:`proxy`;if(e&&r===`external`&&!n?.location.hostId){Gt(e);return}e&&t(e)}}};return window.addEventListener(`message`,i),()=>{window.removeEventListener(`message`,i)}},[n,Se,U,t,a]);let Ce=O.filter(e=>e.level===`error`||e.level===`runtime`||e.level===`resource`).length,we=O.filter(e=>jv(e,E)),Te=Z.useCallback(()=>{let t=[`Preview URL: ${e||ve||``}`,`Events: ${O.length}`,``].join(`
|
|
143
|
+
`),n=O.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
|
|
144
|
+
`);pr(`${t}${n}`).then(e=>{e.ok?Y.success(a(`contextPanel.preview.console.copied`)):Y.error(a(`contextPanel.preview.console.copyFailed`))})},[O,ve,e,a]),Ee=Z.useCallback(()=>{let t=ie;if(!t){Y.error(a(`contextPanel.preview.console.attachNoSession`));return}let n=[`Preview URL: ${e||ve||``}`,`Events: ${O.length}`,``].join(`
|
|
145
|
+
`),r=O.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
|
|
146
|
+
`);V({sessionKey:t,source:`preview-console`,fileLabel:e||ve||`preview`,startLine:1,endLine:Math.max(1,O.length),code:`${n}${r}`,language:`text`,text:a(`contextPanel.preview.console.attachAnnotation`)}),Y.success(a(`contextPanel.preview.console.attached`))},[V,O,ie,ve,e,a]),[De,Oe]=Z.useState(`unknown`),ke=Z.useRef(0),Ae=Z.useRef(0);Z.useEffect(()=>{if(!fe){Oe(`unknown`),ke.current=0,Ae.current=0;return}let e=!1;return ke.current||(ke.current=Date.now(),Ae.current=0),Oe(`unknown`),(async()=>{let t=await(async()=>{try{let e=new URL(fe,window.location.href),t=n?.location.hostId?A(n.location.hostId,`/api`).slice(0,-4):``,i=`${t&&e.pathname.startsWith(t+`/`)?e.pathname.slice(t.length):e.pathname}${e.search}`;return await r(i,{method:`GET`,credentials:`include`,cache:`no-store`,redirect:`manual`})}catch{return null}})();if(e)return;if(!t){Oe(`unreachable`);return}if(t.status===403||t.status===404){K_.delete(ce),_({status:`loading`}),p();return}if(t.status!==502){Oe(`reachable`);return}let i=ke.current||Date.now();if(Date.now()-i<15e3){Oe(`starting`),Ae.current+=1;let t=Ae.current,n=Math.min(2e3,250*2**Math.min(4,t));setTimeout(()=>{e||d()},n).unref?.();return}Oe(`unreachable`)})(),()=>{e=!0}},[n,r,ce,fe,c]);let je=U&&m.status===`ready`&&(De===`unknown`||De===`starting`),Me=U&&m.status===`ready`&&De===`unreachable`,Ne=Z.useCallback(e=>{if(!U||m.status!==`ready`||typeof window>`u`)return;let t=e.currentTarget.contentWindow;if(t)try{let e=t.location,n=Qv(ve||fe);if(e.origin!==n||e.pathname.startsWith(m.proxyBasePath))return;let r=`${m.proxyBasePath}${e.pathname}${e.search}${e.hash}`;t.location.replace(r)}catch{}},[ve,U,fe,m]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:ye||e,children:ye||e||a(`contextPanel.preview.empty`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>d(),title:a(`contextPanel.preview.actions.reload`),"aria-label":a(`contextPanel.preview.actions.reload`),disabled:!ve,children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>{ue&&Gt(n?.location.hostId?ve:ue)},title:a(`contextPanel.preview.actions.openExternal`),"aria-label":a(`contextPanel.preview.actions.openExternal`),disabled:n?.location.hostId?!ve:!ue,children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})}),U?(0,$.jsx)(q,{type:`button`,size:`sm`,variant:j?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>N(e=>!e),title:a(`contextPanel.preview.inspect.toggle`),"aria-label":a(`contextPanel.preview.inspect.toggle`),disabled:!S,children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}):null,U?(0,$.jsxs)(q,{type:`button`,size:`sm`,variant:w?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>T(e=>!e),title:a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),"aria-label":a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),disabled:!S&&O.length===0,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`h-3.5 w-3.5`}),Ce>0?(0,$.jsx)(`span`,{className:`typography-micro text-status-error`,children:Ce}):null]}):null]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[je?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.startingServer`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.startingServerHint`)})]}):Me?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.upstreamUnreachable`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.upstreamUnreachableHint`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>d(),children:a(`contextPanel.preview.actions.retry`)})]}):ve&&(!U||De===`reachable`)?(0,$.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,$.jsx)(`iframe`,{ref:b,src:ve,title:a(`contextPanel.preview.iframeTitle`),className:`h-full w-full border-0`,style:{colorScheme:le},onLoad:Ne,sandbox:U?`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads`:`allow-scripts allow-forms`},`${ve}:${c}`),j&&P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:P.bounds.x,top:P.bounds.y,width:P.bounds.width,height:P.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[P.tag,P.text?` · ${P.text}`:``]})}):null]}):be?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.loading`)}):xe?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.proxyError`)}),m.status===`error`?(0,$.jsx)(`div`,{className:`text-center text-xs opacity-70`,children:m.message}):null,(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:()=>p(),children:a(`contextPanel.preview.actions.retry`)})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.invalidUrl`)}),w?(0,$.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:a(`contextPanel.preview.console.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:Ee,disabled:O.length===0,children:a(`contextPanel.preview.console.attach`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:Te,disabled:O.length===0,children:a(`contextPanel.preview.console.copy`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>k([]),disabled:O.length===0,children:a(`contextPanel.preview.console.clear`)})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/30 px-3 py-1.5`,children:[`all`,`errors`,`warnings`,`logs`].map(e=>(0,$.jsx)(q,{type:`button`,size:`xs`,variant:E===e?`secondary`:`ghost`,onClick:()=>D(e),children:a(e===`all`?`contextPanel.preview.console.filter.all`:e===`errors`?`contextPanel.preview.console.filter.errors`:e===`warnings`?`contextPanel.preview.console.filter.warnings`:`contextPanel.preview.console.filter.logs`)},e))}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto p-2 typography-code text-xs`,children:O.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.empty`)}):we.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.noFilteredEvents`)}):we.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-1 last:border-b-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:J(`shrink-0 uppercase`,e.level===`error`||e.level===`runtime`||e.level===`resource`?`text-status-error`:e.level===`warn`?`text-status-warning`:`text-muted-foreground`),children:e.level}),(0,$.jsx)(`span`,{className:`min-w-0 break-words text-foreground`,children:e.message})]})},e.id))})]}):null]})]})},ny=()=>typeof window<`u`&&!!window.__YURI_ELECTRON__;function ry(){let e=(0,Q.c)(14),t=xt()?.entry,n=Jn(sy),r=Jn(oy),i=ln(ay),a;e[0]!==t||e[1]!==i?(a=t&&i&&ne(i.location)===t.key?i:null,e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a,s=t?.location.hostId?o?.sessionId??null:n,c=t?.location.hostId?!o?.sessionId:r,l=Ir(iy),d;e[3]!==l||e[4]!==s||e[5]!==t?(d=async e=>{if(!t?.location.hostId)return l(e);let n={transportIdentity:u(),location:t.location},r=s?ft(n,s):ut(n,`remote-new-session`);await Ir.getState().addDraftLocalAttachment(r,e)},e[3]=l,e[4]=s,e[5]=t,e[6]=d):d=e[6];let f=G(d),p;e[7]!==s||e[8]!==t||e[9]!==c?(p=t?.location.hostId?M(t.location,s??`draft`):s??(c?`draft`:null),e[7]=s,e[8]=t,e[9]=c,e[10]=p):p=e[10];let m=p,h;return e[11]!==f||e[12]!==m?(h={annotationSessionKey:m,addAttachedFile:f},e[11]=f,e[12]=m,e[13]=h):h=e[13],h}function iy(e){return e.addAttachedFile}function ay(e){return e.remoteSession}function oy(e){return e.newSessionDraft?.open}function sy(e){return e.currentSessionId}var cy=({initialUrl:e,directory:t,tabID:n})=>{let r=xt()?.entry,{t:i}=Pr(),a=Z.useRef(null),o=K(e=>e.setContextPanelTabTargetPath),s=L_(e),c=s===`about:blank`?``:s,[l,u]=Z.useState(c),[d,f]=Z.useState(c),[p,m]=Z.useState(c),[h,g]=Z.useState(()=>c?[c]:[]),[_,v]=Z.useState(()=>c?0:-1),[y,b]=Z.useReducer(e=>e+1,0),[x,S]=Z.useState(!!c),[C,w]=Z.useState(!1),{annotationSessionKey:T,addAttachedFile:E}=ry(),D=ai(e=>e.addDraft),O=Z.useCallback(e=>{!e||e===`about:blank`||!t||!n||o(t,n,e)},[t,n,o]),k=Z.useCallback((e,t)=>{let n=L_(e),r=n===`about:blank`?``:n;f(r),u(r),t?.inFrame?S(!1):(m(r),S(!!r)),O(r),g(e=>{if(!r)return v(-1),[];if(t?.replaceHistory)return e;let n=_>=0?e.slice(0,_+1):[];if(n[n.length-1]===r)return v(n.length-1),n;let i=[...n,r];return v(i.length-1),i})},[_,O]),A=Z.useRef(d);A.current=d,Z.useEffect(()=>{let t=R_(e,A.current);t!==null&&k(t)},[e,k]);let j=Z.useCallback(e=>{let t=h[e];t&&(v(e),f(t),m(t),u(t),S(!0),O(t))},[h,O]),M=Z.useCallback(()=>{if(d){S(!0);try{a.current?.contentWindow?.location.reload()}catch{b()}}},[d]),N=p,P=Z.useCallback(async e=>{let t=T;if(!t){Y.error(i(`contextPanel.preview.inspect.attachNoSession`));return}let n=a.current,o=n?.contentWindow,s=n?.getBoundingClientRect(),c={width:Number.isFinite(o?.innerWidth)?o?.innerWidth??s?.width??0:s?.width??0,height:Number.isFinite(o?.innerHeight)?o?.innerHeight??s?.height??0:s?.height??0},l=n?await U_(n,e,r):null,u=!!l;l&&await E(l),D({sessionKey:t,source:`preview-annotation`,fileLabel:d||`browser`,startLine:1,endLine:1,code:H_({pageUrl:d,viewport:c,devicePixelRatio:window.devicePixelRatio||1,target:e,screenshotAttached:u,intro:i(u?`contextPanel.preview.inspect.attachAnnotationWithScreenshot`:`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),Y.success(i(`contextPanel.preview.inspect.attached`))},[r,E,D,T,d,i]),F=Z.useCallback(()=>{let e=a.current;e&&Jv(e,Kv).catch(()=>{})},[]);Z.useEffect(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),w(!1),F())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[F,C]),Z.useEffect(()=>()=>F(),[F]);let I=Z.useCallback(()=>{let e=a.current;if(!(!e||!d)){if(C){w(!1),F();return}w(!0),(async()=>{try{let t=await Jv(e,Gv);if(w(!1),!t||!V_(t))return;await P(t)}catch{w(!1),Y.error(i(`contextPanel.browser.inspectUnavailable`))}})()}},[P,F,d,C,i]),L=Z.useCallback(()=>{try{let e=a.current?.contentWindow?.location.href||``;e&&e!==`about:blank`&&k(e,{inFrame:!0})}catch{}S(!1)},[k]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:_<=0,onClick:()=>j(_-1),children:(0,$.jsx)(X,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:_<0||_>=h.length-1,onClick:()=>j(_+1),children:(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:M,children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),k(l)},children:(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":i(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(q,{type:`button`,variant:C?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:I,title:i(`contextPanel.preview.inspect.toggle`),"aria-label":i(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:()=>void Gt(d),children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[N?(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(`iframe`,{ref:a,src:N,title:i(`contextPanel.browser.empty`),className:`absolute inset-0 h-full w-full border-0 bg-background`,allow:`clipboard-read; clipboard-write; fullscreen`,allowFullScreen:!0,onLoad:L},`${n}:${y}`)}):(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(Mo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:i(`contextPanel.browser.empty`)}),(0,$.jsx)(`span`,{className:`max-w-sm typography-micro text-muted-foreground`,children:i(`contextPanel.browser.emptyHint`)}),(0,$.jsx)(`span`,{className:`max-w-md typography-micro leading-relaxed text-status-warning/70`,children:i(`contextPanel.browser.trustNotice`)})]}),x?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:i(`common.loading`)}):null]})]})},ly=e=>{let t=(0,Q.c)(7),n=xt()?.entry,r=Z.useSyncExternalStore(c,d,d),i;t[0]===n?i=t[1]:(i=(e,t)=>xv(e,t,n),t[0]=n,t[1]=i);let a=i,o=`${r}:${n?.key??``}:${n?.connectionGeneration??0}`,s;return t[2]!==n?.location.hostId||t[3]!==a||t[4]!==e||t[5]!==o?(s=n?.location.hostId||!Sv()?(0,$.jsx)(ca,{open:a,children:t=>(0,$.jsx)(uy,{...e,partition:t.partition})},o):(0,$.jsx)(uy,{...e},o),t[2]=n?.location.hostId,t[3]=a,t[4]=e,t[5]=o,t[6]=s):s=t[6],s},uy=({initialUrl:e,directory:t,tabID:n,partition:r=`persist:yuri-browser`})=>{let{t:i}=Pr(),a=Z.useRef(null),o=K(e=>e.setContextPanelTabTargetPath),s=L_(e),c=s===`about:blank`?``:s,l=Z.useRef(L_(e)),[u,d]=Z.useState(c),[f,p]=Z.useState(c),[m,h]=Z.useState(!1),[g,_]=Z.useState(!0),v=Z.useRef(null),y=g,b=Z.useCallback(e=>{!e||e===`about:blank`||!t||!n||o(t,n,e)},[t,n,o]),{annotationSessionKey:x,addAttachedFile:S}=ry(),C=ai(e=>e.addDraft);Z.useEffect(()=>{let e=a.current;if(!e)return;let t=()=>{try{let t=e.getURL();t&&t!==`about:blank`&&(p(t),d(t),b(t))}catch{}},n=e=>{let t=e.detail;typeof t?.url==`string`&&t.url&&(p(t.url),d(t.url),b(t.url))},r=()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>_(!0),200)},i=()=>{v.current&&clearTimeout(v.current),_(!1),t()},o=e=>{let t=e.detail;if(t?.disposition===`new-window`||t?.disposition===`foreground-tab`||t?.disposition===`background-tab`){e.preventDefault();let n=a.current;typeof n?.loadURL==`function`&&t.url&&n.loadURL(t.url)}},s=()=>{try{e.executeJavaScript?.(qv,!0).catch(()=>{})}catch{}};e.addEventListener(`did-navigate`,n),e.addEventListener(`did-navigate-in-page`,n),e.addEventListener(`did-start-loading`,r),e.addEventListener(`did-stop-loading`,i),e.addEventListener(`new-window`,o),e.addEventListener(`dom-ready`,s);try{e.isLoading()||(_(!1),t())}catch{}return s(),()=>{v.current&&clearTimeout(v.current),e.removeEventListener(`did-navigate`,n),e.removeEventListener(`did-navigate-in-page`,n),e.removeEventListener(`did-start-loading`,r),e.removeEventListener(`did-stop-loading`,i),e.removeEventListener(`new-window`,o),e.removeEventListener(`dom-ready`,s)}},[b]),Z.useEffect(()=>{let e=setTimeout(()=>_(!1),3e4);return()=>clearTimeout(e)},[]),Z.useEffect(()=>{if(!m)return;let e=e=>{if(e.key!==`Escape`)return;e.preventDefault(),e.stopImmediatePropagation(),h(!1);let t=a.current;try{t?.executeJavaScript?.(Kv).catch(()=>{})}catch{}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[m]),Z.useEffect(()=>{let e=a.current;return()=>{try{let r=e?.getURL?.();r&&r!==`about:blank`&&o(t,n,r)}catch{}try{e?.executeJavaScript?.(Kv).catch(()=>{})}catch{}}},[t,n,o]);let w=Z.useCallback(e=>{let t=a.current;if(typeof t?.loadURL!=`function`)return;let n=L_(e);try{t.loadURL(n)}catch{}},[]),T=Z.useRef(f);T.current=f,Z.useEffect(()=>{let t=R_(e,T.current);t!==null&&(p(t),d(t),_(!0),w(t))},[e,w]);let E=Z.useCallback(()=>{let e=a.current;if(e){if(m){h(!1);try{e.executeJavaScript?.(Kv).catch(()=>{})}catch{}return}h(!0),e.executeJavaScript?.(Gv,!0).then(async t=>{if(h(!1),!t||!V_(t))return;let n=x;if(!n){Y.error(i(`contextPanel.preview.inspect.attachNoSession`));return}let r=typeof e.getWebContentsId==`function`?e.getWebContentsId():null;if(r==null)return;let a=await Ar(`desktop_browser_capture_page`,{webContentsId:r}),o=await e.executeJavaScript?.(`({ width: window.innerWidth, height: window.innerHeight })`,!0).catch(()=>null),s=Number.isFinite(o?.width)?o.width:a.width,c=Number.isFinite(o?.height)?o.height:a.height,l=await W_(a.base64,a.width,a.height,s,c,t),u=!!l;l&&await S(l),C({sessionKey:n,source:`preview-annotation`,fileLabel:f||`browser`,startLine:1,endLine:1,code:H_({pageUrl:f,viewport:{width:s,height:c},devicePixelRatio:window.devicePixelRatio||1,target:t,screenshotAttached:u,intro:i(`contextPanel.preview.inspect.attachAnnotationWithScreenshot`)}),language:`markdown`,text:``}),Y.success(i(`contextPanel.preview.inspect.attached`))}).catch(()=>h(!1))}},[S,C,x,f,m,i]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.goBack?.()}catch{}},children:(0,$.jsx)(X,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.goForward?.()}catch{}},children:(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.reload?.()}catch{}},children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),w(u)},children:(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":i(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(q,{type:`button`,variant:m?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:E,title:i(`contextPanel.preview.inspect.toggle`),"aria-label":i(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>void Gt(f),children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[(0,$.jsx)(`webview`,{ref:a,src:l.current,partition:r,allowpopups:!0,style:{width:`100%`,height:`100%`,border:`none`}}),(!f||f===`about:blank`)&&!g?(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(Mo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:i(`contextPanel.browser.empty`)})]}):null,y?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:i(`common.loading`)}):null]})]})},dy=e=>{let t=(0,Q.c)(3),n=xt(),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(fy,{...e},n.entry.key):(0,$.jsx)(al,{children:(0,$.jsx)(fy,{...e})}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},fy=e=>{let t=(0,Q.c)(3),n=xt(),r;return t[0]!==n?.entry.location.hostId||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(py,{...e}):(0,$.jsx)(my,{...e}),t[0]=n?.entry.location.hostId,t[1]=e,t[2]=r):r=t[2],r},py=e=>{let t=(0,Q.c)(5),n=xt(),r=kr(n.registry,n.entry.location.hostId),i;t[0]===r.data?.directories?i=t[1]:(i=r.data?.directories.flatMap(hy)??[],t[0]=r.data?.directories,t[1]=i);let a=i,o;return t[2]!==e||t[3]!==a?(o=(0,$.jsx)(my,{...e,remoteSessions:a}),t[2]=e,t[3]=a,t[4]=o):o=t[4],o},my=({directory:e,onReservedWidthChange:t,fillAvailableSpace:n=!1,getMaxSplitWidth:r,remoteSessions:i})=>{let{t:a}=Pr(),o=xt(),s=!!o?.entry.location.hostId,c=Jn(e=>e.currentSessionId),l=ln(e=>e.remoteSession),u=s?l&&ne(l.location)===o.entry.key?l.sessionId:null:c,d=Wi()??``,f=e?re(e,o?.entry.location.hubId??`local`).directory:d,m=s?ne({...o.entry.location,directory:f}):Mv(f),h=K(e=>Wt(e,m)),g=K(e=>m?e.contextToolDiffByDirectory[m]:void 0),_=K(e=>e.closeContextPanel),v=K(e=>e.closeContextPanelTab),y=K(e=>e.openContextPanelTab),b=K(e=>e.toggleContextPanelExpanded),x=K(e=>e.setContextPanelWidth),S=K(e=>e.setActiveContextPanelTab),C=K(e=>e.reorderContextPanelTabs),w=K(e=>e.isRightSidebarOpen),T=K(e=>e.isSidebarOpen),{usesFramelessChrome:E,side:D}=oc(),O=Vo(e=>e.setSelectedPath),k=K(e=>e.openContextPreview),A=K(e=>e.allowPromptingSubagentSessions),{themeMode:j,setThemeMode:M,lightThemeId:N,darkThemeId:P,currentTheme:F}=oi(),I=Z.useMemo(()=>h?.tabs??[],[h?.tabs]),L=I.find(e=>e.id===h?.activeTabId)??I[I.length-1]??null,R=!!h?.isOpen,z=!!h?.expanded,ee=R&&(z||n),B=Z.useRef(null),V=Z.useRef(!0),[te,ie]=Z.useState(!0);Lt(B,([e])=>{if(!e||e.contentRect.width<=0)return;let t=e.contentRect.width<Dv;t!==V.current&&(V.current=t,ie(t))});let ae=R&&(!L||w&&(!te||h?.activeView!==`preview`)),H=R&&(!te||!ae),U=Nv(h?.width??Tv),oe=Z.useMemo(()=>{let e=[];for(let t of I){if(t.mode!==`chat`)continue;let n=Vv(t.dedupeKey);n&&!e.includes(n)&&e.push(n)}return e},[I]),se=Wv(f||void 0,oe,i),[ce,le]=Z.useState(!1),[ue,de]=Z.useState(!1),fe=Z.useRef(0),pe=Z.useRef(U),me=Z.useRef(null),he=Z.useRef(null),ge=Z.useRef({directory:m,width:U});Z.useLayoutEffect(()=>{ce||((ge.current.directory!==m||R&&!ee)&&(ge.current={directory:m,width:U}),t?.(R?z?1/0:U:0))},[m,ee,R,ce,t,z,U]);let _e=Z.useRef(null),ve=Z.useRef(new Map),ye=Z.useRef(new Map),be=Z.useRef(!1),xe=Z.useRef(R),Se=Z.useRef(null),[Ce,we]=Z.useState({}),Te=Z.useRef(Ce);Te.current=Ce;let[Ee,De]=Z.useReducer(j_,{activeViewKey:null,tabs:{},mountedViews:{}}),Oe=s?`react-surface`:$g(),ke=p(),Ae=Z.useCallback(e=>{let t=Te.current,n=e(t);return n!==t&&(Te.current=n,we(n),!0)},[]),je=Z.useCallback(e=>{if(!m)return;if(K.getState().contextPanelByDirectory[m]?.tabs.find(t=>t.id===e)?.mode===`btw`){let e=u;e&&Aa.getState().clear({sessionId:e,directory:f,host:s?o.entry:void 0})}De({type:`close-tab`,tabId:e});let t=e_(m,e);Ae(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),v(m,e)},[u,f,o,s,v,Ae,m]),Me=Z.useCallback(()=>{de(!0),Se.current!==null&&window.cancelAnimationFrame(Se.current),Se.current=window.requestAnimationFrame(()=>{Se.current=null,de(!1)})},[]);Z.useEffect(()=>()=>{Se.current!==null&&window.cancelAnimationFrame(Se.current)},[]),Z.useLayoutEffect(()=>{let e=xe.current;if(xe.current=R,!R){de(!1);return}e||Me()},[R,Me]),Z.useEffect(()=>{if(!R||be.current){be.current=R;return}let e=window.requestAnimationFrame(()=>{let e=_e.current;e&&!e.contains(document.activeElement)&&e.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(e)},[R]);let Ne=G(e=>{let n=_e.current;if(!n)return;let r=Fv(e,n);n.style.setProperty(`--yuri-context-panel-width`,`${r}px`),t?.(r)}),Pe=G(e=>{if(!R||!m)return;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}he.current=e.pointerId,le(!0),fe.current=e.clientX;let t=_e.current?.clientWidth||U;pe.current=t,me.current=t,z&&b(m),Ne(t),e.preventDefault()}),Fe=Z.useCallback(e=>{if(!ce||he.current!==e.pointerId)return;let t=fe.current-e.clientX,n=Fv(pe.current+t,_e.current);me.current!==n&&(me.current=n,Ne(n))},[Ne,ce]),Ie=Z.useCallback(e=>{if(he.current!==e.pointerId||!m)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=Fv(me.current??U,_e.current);Me(),Ne(t),me.current=t,x(m,t),le(!1),he.current=null},[Ne,m,x,Me,U]);Z.useEffect(()=>{ce||(me.current=null)},[ce]);let Le=Z.useCallback(()=>{if(!m)return;let e=u;e&&Aa.getState().cancel({sessionId:e,directory:f,host:s?o.entry:void 0}),_(m)},[u,f,o,s,_,m]),W=G(()=>{if(!m)return;if(!ee){b(m);return}let e=ge.current.width,t=Nv(Math.min(e,r?.()??e));t!==U&&x(m,t),z&&b(m)}),Re=Z.useCallback(e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`w`&&L&&m){e.preventDefault(),e.stopPropagation(),je(L.id);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Le())},[L,je,m,Le]);Z.useEffect(()=>{if(!(!m||!L)&&L.mode===`file`&&L.targetPath){O(m,L.targetPath,{allowOutsideRoot:!0});return}},[L,m,O]);let ze=L?.mode===`chat`?L.id:null,Be=s_(ze?Ce[e_(m,ze)]:void 0,ze?Vv(L?.dedupeKey):null);Z.useEffect(()=>{if(s||!H||!m||!Be){an(``,null);return}return an(m,Be),()=>{an(``,null)}},[Be,m,H,s]),Z.useEffect(()=>{if(s||!H||!m||!Be||typeof window>`u`)return;let e=()=>{if(document.visibilityState===`hidden`||!document.hasFocus()){mn(m,Be,!1);return}Tn(Be),mn(m,Be,!0)};e();let t=window.setInterval(e,1e4);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e),mn(m,Be,!1)}},[Be,m,H,s]);let Ve=Z.useCallback((e,t,n)=>Fo(ye.current,e,t,m||null,n,{mode:j,lightThemeId:N,darkThemeId:P,currentTheme:F}),[F,P,m,N,j]);Z.useEffect(()=>{let e=new Set(I.map(e=>e.id));for(let t of ye.current.keys())e.has(t)||ye.current.delete(t)},[I]);let He=Z.useCallback(e=>{!m||L?.mode!==`diff`&&L?.mode!==`file-diff`||y(m,{mode:L.mode,targetPath:L.targetPath,stagedDiff:e===`staged`,diffScope:e})},[L,m,y]),Ue=Z.useCallback(()=>{if(typeof window>`u`)return;let e={themeMode:j,lightThemeId:N,darkThemeId:P,currentTheme:F};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyThemeSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:theme-sync`,payload:e},window.location.origin)}},[F,P,N,j]),We=Z.useCallback(()=>{if(typeof window>`u`)return;let e={allowPromptingSubagentSessions:A};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyChatSettingsSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:chat-settings-sync`,payload:e},window.location.origin)}},[A]),Ge=Z.useCallback(()=>{if(!(typeof window>`u`))for(let[e,t]of ve.current.entries()){let n=t.contentWindow;if(!n)continue;let r={visible:H&&ze===e},i=n.__yuriSetEmbeddedVisibility;if(typeof i==`function`)try{i(r);continue}catch{}n.postMessage({type:Io,payload:r},window.location.origin)}},[ze,H]);Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{if(e.origin!==window.location.origin||!Array.from(ve.current.values()).some(t=>t.contentWindow===e.source))return;let t=e.data;if(t?.type===`yuri:close-embedded-session-chat`){let t=Array.from(ve.current.entries()).find(([,t])=>t.contentWindow===e.source);t&&m&&je(t[0]);return}if(t?.type===`yuri:chat-settings-request`){We();return}if(t?.type===`yuri:embedded-visibility-request`){Ge();return}if(t?.type!==`yuri:cycle-theme-request`)return;let n=[`light`,`dark`,`system`],r=(n.indexOf(j)+1)%n.length;M(n[r])};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[je,m,We,Ge,M,j]),Z.useLayoutEffect(()=>{I.some(e=>e.mode===`chat`)&&(Ue(),We(),Ge())},[P,N,We,Ge,Ue,I,j]);let Ke=Z.useMemo(()=>I.map(e=>{let t=zv(e,se,a),n=Yv(t,Ev),r=Iv(e.targetPath,f);return{id:e.id,label:n,icon:Bv(e),title:r?`${t}: ${r}`:t,closeLabel:a(`contextPanel.tab.closeTabAria`,{label:n})}}),[f,se,a,I]),qe=L?.mode===`context`?(0,$.jsx)(Am,{active:H}):L?.mode===`preview`?(0,$.jsx)(ty,{rawUrl:L.targetPath??``,onNavigate:e=>k(m,e)},`${m}:${o?.entry.connectionGeneration??``}:${L.id}`):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-18 w-24 flex-col overflow-hidden rounded-lg border border-current/35 text-muted-foreground/45`,children:[(0,$.jsx)(`div`,{className:`flex h-3.5 shrink-0 items-end border-b border-current/25 px-2`,children:(0,$.jsx)(`span`,{className:`h-1.5 w-5 rounded-t-sm bg-current/20`})}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 shrink-0 flex-col gap-1.5 border-r border-current/25 px-1.5 py-3`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/40`}),(0,$.jsx)(`span`,{className:`h-0.5 w-2 rounded-full bg-current/25`}),(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/25`})]}),(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(X,{name:`file-text`,className:`size-7`})})]})]}),(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:a(`contextPanel.empty.selectFile`)})]}),Je=Z.useMemo(()=>I.filter(e=>e.mode===`chat`),[I]),Ye=Z.useMemo(()=>I.filter(e=>e.mode===`browser`),[I]),Xe=Z.useMemo(()=>I.filter(e=>e.mode===`diff`||e.mode===`file-diff`),[I]),Ze=ny()?ly:cy,Qe=H&&L?.mode===`browser`&&Ze===ly;Z.useLayoutEffect(()=>{if(!Qe)return;let e=document.documentElement;return e.setAttribute(`data-yuri-native-browser-visible`,``),()=>e.removeAttribute(`data-yuri-native-browser-visible`)},[Qe]);let $e=Z.useMemo(()=>I.some(e=>e.mode===`file`),[I]),et=L?.mode===`file`,[tt,nt]=Z.useState(null),rt=et?L.targetPath:tt?.directory===m&&I.some(e=>e.mode===`file`&&e.targetPath===tt.path)?tt.path:null;Z.useEffect(()=>{nt(e=>e?.directory===m&&e.path===rt?e:{directory:m,path:rt??null})},[m,rt]);let it=et?L?.fileNotice??null:null;Z.useEffect(()=>{let e=new Set(Je.map(e=>e_(m,e.id)));Ae(t=>{let n=!1,r={};for(let e of Je){let i=Vv(e.dedupeKey);if(!i)continue;let a=e_(m,e.id),o=t[a];r[a]=o??a_({sessionId:i,directory:m}),n||=!o}let i=f_(t,e);return n||=i!==t,n?{...i,...r}:t});for(let t of Object.keys(Ee.tabs))(!e.has(e_(m,t))||Ee.tabs[t]?.directory!==m)&&De({type:`close-tab`,tabId:t})},[Je,Ae,m,Ee.tabs]);let at=ze?e_(m,ze):null,ot=ze?Vv(L?.dedupeKey):null,st=at&&ot?o_(Ce[at],{sessionId:ot,directory:m}):void 0,ct=st&&at?t_(ke,at,st.current.directory,st.current.sessionId):null;Z.useLayoutEffect(()=>{if(Oe!==`react-surface`||!R||!ze||!st||!at||!ct){Oe===`react-surface`&&De({type:`activate`,viewKey:null,now:Date.now()});return}Ae(e=>e[at]?e:{...e,[at]:st}),De({type:`touch`,tab:{tabId:ze,sessionId:st.anchor.sessionId,directory:st.anchor.directory},view:{tabId:ze,surfaceId:at,sessionId:st.current.sessionId,directory:st.current.directory,viewKey:ct},now:Date.now()})},[st,at,ze,ct,Oe,Ae,R]);let lt=Z.useCallback((e,t,n)=>{let r=e_(m,e),i=!1;return Ae(e=>{let a=s&&o?ne({...o.entry.location,directory:re(n,o.entry.location.hubId).directory}):n,c=d_(e,r,{sessionId:t,directory:a});return i=c.accepted,c.navigationBySurfaceId}),i},[Ae,m,s,o]),ut=Z.useCallback(e=>{let t=e_(m,e);Ae(e=>{let n=e[t];if(!n)return e;let r=l_(n);return r===n?e:{...e,[t]:r}})},[Ae,m]),dt=(0,$.jsxs)(`header`,{className:J(`app-region-drag flex shrink-0 select-none items-center pl-2`,F.metadata.variant===`light`&&[`[--interactive-hover:color-mix(in_srgb,var(--surface-foreground)_6%,var(--background))]`,`[--interactive-active:color-mix(in_srgb,var(--surface-foreground)_10%,var(--background))]`]),style:{height:`calc(var(--yuri-header-height, 3rem) - 0.75rem * var(--padding-scale, 1))`,minHeight:`calc(max(3rem, var(--yuri-wco-titlebar-height, 0px)) - 0.75rem * var(--padding-scale, 1))`,paddingRight:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,...n&&!T?{paddingLeft:`calc(var(--yuri-titlebar-left-inset, 0.75rem) + var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}:{}},children:[(0,$.jsx)(Vs,{items:Ke,activeId:L?.id??null,onSelect:e=>{m&&S(m,e)},onClose:e=>{je(e)},onReorder:(e,t)=>{m&&C(m,e,t)},layoutMode:`scrollable`,variant:`compact`,className:`app-region-no-drag h-6`}),(0,$.jsxs)(`div`,{className:`app-region-no-drag flex shrink-0 items-center gap-1 pl-1.5`,children:[R?(0,$.jsx)(Ug,{railVisible:ae}):null,(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:W,className:`h-7 w-7 p-0`,title:a(ee?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-label":a(ee?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-pressed":ee,children:(0,$.jsx)(X,{name:ee?`collapse-diagonal`:`expand-diagonal`,className:`size-4`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:Le,className:`h-7 w-7 p-0`,title:a(`contextPanel.actions.closePanel`),"aria-label":a(`contextPanel.actions.closePanel`),children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(ic,{visible:R&&E&&D===`right`,position:`right`})]})]}),ft=R?{width:ee?`100%`:`min(var(--yuri-context-panel-width), 100%)`,minWidth:`min(${Cv}px, 100%)`,maxWidth:`100%`,"--yuri-context-panel-width":`${ce?me.current??U:U}px`}:{"--yuri-context-panel-width":`${ce?me.current??U:U}px`,width:0,minWidth:0,maxWidth:0,opacity:0,overflow:`hidden`,visibility:`hidden`};return(0,$.jsxs)(`aside`,{ref:_e,"data-context-panel":`true`,"data-native-browser-visible":Qe?`true`:void 0,tabIndex:-1,inert:!R||void 0,className:J(`flex min-h-0 flex-col overflow-visible bg-transparent`,R&&`py-1.5 pl-1 pr-1.5`,`relative h-full flex-shrink-0`,!R&&`pointer-events-none`,ce||!R||ue||t?`transition-none`:`transition-[width] duration-200 ease-in-out`),onKeyDownCapture:Re,style:ft,children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`div`,{className:`group/preview-resize absolute -left-1 top-0 z-50 h-full w-4 touch-none cursor-col-resize`,onPointerDown:Pe,onPointerMove:Fe,onPointerUp:Ie,onPointerCancel:Ie,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`contextPanel.actions.resizePanelAria`),"data-context-resize-handle":!0,children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`pointer-events-none absolute left-[2px] top-1/2 h-14 w-[3px] -translate-y-1/2 rounded-full bg-muted-foreground/25 opacity-0 transition-opacity duration-150 group-hover/preview-resize:opacity-100`,ce&&`opacity-100`)})})}),(0,$.jsx)(ti,{side:`right`,sideOffset:4,children:a(`contextPanel.actions.resizePanel`)})]}),(0,$.jsxs)(Ul,{"data-context-panel-surface":!0,children:[dt,it===`turn-diff-outside-workspace`?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-status-info/20 bg-status-info/10 px-3 py-2 typography-meta text-status-info`,children:a(`contextPanel.file.notice.turnDiffOutsideWorkspace`)}):null,(0,$.jsxs)(`div`,{ref:B,className:J(`relative flex min-h-0 flex-1 overflow-hidden`,ce&&`pointer-events-none`),"data-context-layout":te?`single`:`split`,children:[(0,$.jsx)(`div`,{className:J(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,H?`flex`:`hidden`),inert:!H||void 0,"data-context-preview-content":!0,children:(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[$e&&rt?(0,$.jsx)(`div`,{className:J(`absolute inset-0`,et?`block`:`hidden`),children:(0,$.jsx)(hp,{mode:`editor-only`,targetPath:rt,isActive:H&&et},`${m}:${rt??``}`)}):null,Oe===`legacy-iframe`&&Je.map(e=>{let t=Vv(e.dedupeKey);if(!t)return null;let n=Ve(e.id,t,e.readOnly);return n?(0,$.jsx)(`iframe`,{ref:t=>{if(!t){ve.current.delete(e.id);return}ve.current.set(e.id,t)},src:n,title:a(`contextPanel.iframe.sessionChatTitle`,{sessionID:t}),className:J(`absolute inset-0 h-full w-full border-0 bg-background`,ze===e.id?`block`:`hidden`),onLoad:()=>{Ue(),We(),Ge()}},e.id):null}),Oe===`react-surface`?Object.values(Ee.mountedViews).map(e=>{let t=Ce[e_(m,e.tabId)],n=H&&ze===e.tabId&&ct===e.viewKey;return(0,$.jsx)(Z.Activity,{name:`context-panel-session-${e.sessionId}`,mode:n?`visible`:`hidden`,children:s&&o?(0,$.jsxs)(`div`,{className:`relative h-full min-h-0`,children:[n&&t?.stack.length?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>ut(e.tabId),className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":a(`chat.container.returnToParent.aria`),title:a(`chat.container.returnToParent.title`),children:[(0,$.jsx)(X,{name:`arrow-left`,className:`h-4 w-4`}),a(`chat.container.returnToParent.label`)]}):null,(0,$.jsx)(Jo,{location:{...o.entry.location,directory:re(e.directory,o.entry.location.hubId).directory},sessionId:e.sessionId,active:n,readOnly:I.find(t=>t.id===e.tabId)?.readOnly??!0,onNavigateSession:(t,n)=>{lt(e.tabId,t,n)}})]}):(0,$.jsx)(P_,{surfaceId:e.surfaceId,sessionId:e.sessionId,directory:e.directory,active:n,canNavigateBack:n&&!!t?.stack.length,onNavigateSession:(t,n)=>lt(e.tabId,t,n),onNavigateBack:()=>ut(e.tabId),onEstimateBytes:(e,t)=>De({type:`estimate`,viewKey:e,estimatedBytes:t})})},e.viewKey)}):null,I.filter(e=>e.mode===`btw`).map(e=>{let t=H&&L?.id===e.id;return(0,$.jsx)(Z.Activity,{name:`context-panel-btw`,mode:t?`visible`:`hidden`,children:u?(0,$.jsx)(as,{scope:{sessionId:u,directory:f,host:s?o.entry:void 0},hostRegistry:s?o.registry:void 0,active:t}):(0,$.jsx)(`p`,{className:`p-4 text-muted-foreground`,children:a(`chat.btw.sessionRequired`)})},`btw:${m}:${u}:${e.id}`)}),Ye.map(e=>(0,$.jsx)(`div`,{className:J(`absolute inset-0`,L?.id!==e.id&&`hidden`),children:(0,$.jsx)(Ze,{initialUrl:e.targetPath??``,directory:m,tabID:e.id})},`${m}:${o?.entry.connectionGeneration??``}:${e.id}`)),Xe.map(e=>{let t=e.mode===`diff`&&g?.targetPath===e.targetPath&&g.turnMessageId===e.diffTurnMessageId?g.patches:null;return(0,$.jsx)(`div`,{className:J(`absolute inset-0`,L?.id!==e.id&&`hidden`),children:(0,$.jsx)($l,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!t,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:e.diffScope??(e.stagedDiff?`staged`:`working`),turnMessageId:e.diffTurnMessageId,sessionId:e.diffSessionId,directory:f,onDiffScopeChange:He,targetFilePath:e.targetPath,targetLine:e.diffTargetLine??null,toolPatches:t,navigationRequestKey:e.touchedAt,flushContent:!0,singleFileView:e.mode===`file-diff`,preloadFullFiles:e.mode===`file-diff`})},e.id)}),L?.mode!==`chat`&&L?.mode!==`btw`&&!et&&L?.mode!==`browser`&&L?.mode!==`diff`&&L?.mode!==`file-diff`?qe:null]})}),(0,$.jsx)(Jm,{isOpen:ae,className:J(`!min-w-0 shrink-0 bg-transparent [--layout-chrome-divider-width:1px] [--layout-chrome-divider:color-mix(in_srgb,var(--surface-foreground)_8%,var(--background))]`,te&&`!transition-none`,te&&ae?`!w-full !max-w-full !border-l-0 [&>[role=separator]]:hidden`:`!max-w-[50%]`),children:ae?(0,$.jsx)(Po,{children:(0,$.jsx)(Wg,{isActive:ae})}):null})]})]})]})};function hy(e){return e.sessions}var gy=350,_y=e=>{let t=(0,Q.c)(26),{children:n,header:r,footer:i}=e,a=Z.useRef(null),o=Z.useRef(0),s=Z.useRef(0),c=Z.useRef(!1),[l,u]=Z.useState(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{if(s.current>0&&o.current<=0)return;let e=s.current>0&&o.current-s.current<gy;e!==c.current&&(c.current=e,u(e))},t[0]=d):d=t[0];let f=G(d),p;t[1]===f?p=t[2]:(p=e=>{s.current=e,f()},t[1]=f,t[2]=p);let m=G(p),h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current-gy,t[3]=h):h=t[3];let g=G(h),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{o.current=a.current?.clientWidth??0,f()},v=[f],t[4]=f,t[5]=_,t[6]=v),Z.useLayoutEffect(_,v);let y;t[7]===f?y=t[8]:(y=e=>{let[t]=e;t&&(o.current=t.contentRect.width,f())},t[7]=f,t[8]=y),Lt(a,y);let b;t[9]===l?b=t[10]:(b=l?{display:`none`}:{minWidth:`min(${gy}px, 100%)`},t[9]=l,t[10]=b);let x=l||void 0,S;t[11]===n?S=t[12]:(S=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden yuri-layout-divider-t`,"data-primary-chat-content":!0,children:n}),t[11]=n,t[12]=S);let C;t[13]!==i||t[14]!==r||t[15]!==b||t[16]!==x||t[17]!==S?(C=(0,$.jsxs)(`main`,{className:`flex flex-1 min-w-0 flex-col overflow-hidden bg-background relative`,style:b,inert:x,"data-page-scroll-lock":`true`,"data-primary-chat":!0,children:[r,S,i]}),t[13]=i,t[14]=r,t[15]=b,t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]!==g||t[20]!==m||t[21]!==l?(w=(0,$.jsx)(dy,{onReservedWidthChange:m,fillAvailableSpace:l,getMaxSplitWidth:g}),t[19]=g,t[20]=m,t[21]=l,t[22]=w):w=t[22];let T;return t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{ref:a,className:`relative flex flex-1 min-h-0 min-w-0 overflow-hidden`,"data-page-scroll-lock":`true`,"data-chat-area":!0,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25],T},vy=(e,t,n)=>Ca(e)?Sa(e,n).map(wa):t,yy=()=>{let e=(0,Q.c)(34),{t}=Pr(),{isMobile:n}=pi(),r=K(by),i=K(xy),a=K(Sy),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=Da(),e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=ae(),e[1]=c):c=e[1];let l=c,u,d,f,p,m,h,g,_,v;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==t){let o=[{categoryKey:`helpDialog.section.navigationCommands`,items:[{id:`open_command_palette`,descriptionKey:`helpDialog.item.openCommandPalette`,icon:`command`,keys:``},{id:`open_help`,descriptionKey:`helpDialog.item.showKeyboardShortcuts`,icon:`question`,keys:``},{id:`toggle_sidebar`,descriptionKey:`helpDialog.item.toggleSessionSidebar`,icon:`layout-left`,keys:``},{id:`cycle_agent`,keys:``,descriptionKey:`helpDialog.item.cycleAgent`,icon:`ai-agent`},{id:`open_model_selector`,descriptionKey:`helpDialog.item.openModelSelector`,icon:`ai-generate-2`,keys:``},{keys:[`↑↓`],descriptionKey:`helpDialog.item.navigateModels`,icon:`ai-generate-2`},{keys:[`←→`],descriptionKey:`helpDialog.item.adjustThinkingMode`,icon:`brain-ai-3`},{id:`cycle_thinking_variant`,descriptionKey:`helpDialog.item.cycleThinkingVariant`,icon:`brain-ai-3`,keys:``},{keys:[`Shift + ${s} + N`],descriptionKey:`helpDialog.item.newWindow`,icon:`window`}]},{categoryKey:`helpDialog.section.sessionManagement`,items:[{id:`new_chat`,descriptionKey:`helpDialog.item.createNewSession`,icon:`add`,keys:``},{id:`new_chat_worktree`,descriptionKey:`helpDialog.item.createNewWorktreeDraft`,icon:`git-branch`,keys:``},{id:`previous_session`,descriptionKey:`helpDialog.item.previousSession`,icon:`arrow-left`,keys:``},{id:`next_session`,descriptionKey:`helpDialog.item.nextSession`,icon:`arrow-right`,keys:``},{id:`focus_input`,descriptionKey:`helpDialog.item.focusChatInput`,icon:`text`,keys:``},{id:`toggle_prompt_navigator`,descriptionKey:`helpDialog.item.togglePromptNavigator`,icon:`list-unordered`,keys:``},{id:`abort_run`,descriptionKey:`helpDialog.item.abortActiveRun`,icon:`close-circle`,keys:``}]},{categoryKey:`helpDialog.section.leaderChords`,items:[{keys:`Ctrl+X → M`,descriptionKey:`helpDialog.item.leaderOpenModel`,icon:`ai-generate-2`},{keys:`Ctrl+X → A`,descriptionKey:`helpDialog.item.leaderOpenAgent`,icon:`ai-agent`},{keys:`Ctrl+X → N`,descriptionKey:`helpDialog.item.leaderNewSession`,icon:`add`},{keys:`Ctrl+X → C`,descriptionKey:`helpDialog.item.leaderCompact`,icon:`scissors`}]},{categoryKey:`helpDialog.section.panels`,items:[{id:`toggle_right_sidebar`,descriptionKey:`helpDialog.item.toggleRightSidebar`,icon:`layout-right`,keys:``},{id:`open_right_sidebar_git`,descriptionKey:`helpDialog.item.openRightSidebarGitTab`,icon:`git-branch`,keys:``},{id:`open_right_sidebar_files`,descriptionKey:`helpDialog.item.openRightSidebarFilesTab`,icon:`layout-right`,keys:``},{id:`cycle_right_sidebar_tab`,descriptionKey:`helpDialog.item.cycleRightSidebarTab`,icon:`layout-right`,keys:``},{id:`close_context_panel_tab`,descriptionKey:`helpDialog.item.closeContextPanelTab`,icon:`close`,keys:``},{id:`toggle_terminal`,descriptionKey:`helpDialog.item.toggleTerminal`,icon:`window`,keys:``},{id:`new_terminal_tab`,descriptionKey:`helpDialog.item.newTerminalTab`,icon:`terminal-box`,keys:``},{id:`open_new_terminal`,descriptionKey:`helpDialog.item.openNewTerminal`,icon:`terminal-box`,keys:``},{id:`previous_terminal_tab`,descriptionKey:`helpDialog.item.previousTerminalTab`,icon:`arrow-left`,keys:``},{id:`next_terminal_tab`,descriptionKey:`helpDialog.item.nextTerminalTab`,icon:`arrow-right`,keys:``},{id:`toggle_terminal_expanded`,descriptionKey:`helpDialog.item.toggleTerminalExpanded`,icon:`window`,keys:``}]},{categoryKey:`helpDialog.section.interface`,items:[{id:`cycle_theme`,descriptionKey:`helpDialog.item.cycleTheme`,icon:`palette`,keys:``},{id:`zoom_in`,descriptionKey:`helpDialog.item.zoomIn`,icon:`add`,keys:``},{id:`zoom_out`,descriptionKey:`helpDialog.item.zoomOut`,icon:`subtract`,keys:``},{id:`zoom_reset`,descriptionKey:`helpDialog.item.zoomReset`,icon:`restart`,keys:``},{keys:[`${s} + 1...9`],descriptionKey:`helpDialog.item.switchSession`,icon:`layout-left`},{id:`toggle_services_menu`,descriptionKey:`helpDialog.item.toggleServicesMenu`,icon:`stack`,keys:``},{id:`open_usage`,descriptionKey:`helpDialog.item.openUsage`,icon:`timer`,keys:``},{id:`cycle_services_tab`,descriptionKey:`helpDialog.item.cycleServicesTab`,icon:`stack`,keys:``},{id:`open_settings`,descriptionKey:`helpDialog.item.openSettings`,icon:`settings-3`,keys:``}]}];d=$r,g=r,_=i,u=Xr,p=n?`default`:`picker`,m=n?`max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden`:void 0;let c;e[16]===t?c=e[17]:(c=t(`helpDialog.title`),e[16]=t,e[17]=c),e[18]===c?h=e[19]:(h=(0,$.jsx)(Jr,{className:`yuri-picker-header`,children:(0,$.jsx)(Zr,{className:`yuri-picker-title`,children:c})}),e[18]=c,e[19]=h),f=`yuri-picker-list`,v=(0,$.jsx)(`div`,{children:o.map(e=>(0,$.jsxs)(`div`,{className:`yuri-picker-section`,children:[(0,$.jsx)(`h3`,{className:`yuri-picker-section-title text-muted-foreground`,children:t(e.categoryKey)}),(0,$.jsx)(`div`,{children:e.items.filter(e=>!(l&&e.id===`toggle_prompt_navigator`)).map(e=>{let n=e.id?vy(e.id,Array.isArray(e.keys)?e.keys[0]:e.keys,a):Array.isArray(e.keys)?e.keys:e.keys.split(` / `);return(0,$.jsxs)(`div`,{className:`yuri-picker-row yuri-help-shortcut-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(X,{name:e.icon,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`yuri-picker-label`,children:t(e.descriptionKey)})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-1`,children:(Array.isArray(n)?n:[n]).map((e,n)=>(0,$.jsxs)(Z.Fragment,{children:[n>0&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mx-1`,children:t(`helpDialog.keyCombiner.or`)}),(0,$.jsx)(Ri,{shortcut:e,variant:`hint`})]},`${e}-${n}`))})]},e.id||e.descriptionKey)})})]},e.categoryKey))}),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=h,e[13]=g,e[14]=_,e[15]=v}else u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15];let y;e[20]!==f||e[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),e[20]=f,e[21]=v,e[22]=y):y=e[22];let b;e[23]!==u||e[24]!==p||e[25]!==m||e[26]!==h||e[27]!==y?(b=(0,$.jsxs)(u,{presentation:p,className:m,children:[h,y]}),e[23]=u,e[24]=p,e[25]=m,e[26]=h,e[27]=y,e[28]=b):b=e[28];let x;return e[29]!==d||e[30]!==b||e[31]!==g||e[32]!==_?(x=(0,$.jsx)(d,{open:g,onOpenChange:_,children:b}),e[29]=d,e[30]=b,e[31]=g,e[32]=_,e[33]=x):x=e[33],x};function by(e){return e.isHelpDialogOpen}function xy(e){return e.setHelpDialogOpen}function Sy(e){return e.shortcutOverrides}var Cy=()=>{let e=(0,Q.c)(32),{t}=Pr(),n=K(wy),r=K(Ty),i=K(Ey),a;e[0]!==i||e[1]!==t?(a=async()=>{if(i){if((await pr(i)).ok){Y.success(t(`openCodeStatusDialog.toast.copiedTitle`),{description:t(`openCodeStatusDialog.toast.copiedDescription`)});return}Y.error(t(`openCodeStatusDialog.toast.copyFailed`))}},e[0]=i,e[1]=t,e[2]=a):a=e[2];let o=a,s;e[3]===t?s=e[4]:(s=t(`openCodeStatusDialog.title`),e[3]=t,e[4]=s);let c;e[5]===s?c=e[6]:(c=(0,$.jsx)(Zr,{children:s}),e[5]=s,e[6]=c);let l;e[7]===t?l=e[8]:(l=t(`openCodeStatusDialog.description`),e[7]=t,e[8]=l);let u;e[9]===l?u=e[10]:(u=(0,$.jsx)(Qr,{children:l}),e[9]=l,e[10]=u);let d;e[11]!==c||e[12]!==u?(d=(0,$.jsxs)(Jr,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13];let f;e[14]===t?f=e[15]:(f=t(`openCodeStatusDialog.actions.copy`),e[14]=t,e[15]=f);let p;e[16]!==o||e[17]!==f?(p=(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:f})}),e[16]=o,e[17]=f,e[18]=p):p=e[18];let m;e[19]!==i||e[20]!==t?(m=i||t(`openCodeStatusDialog.empty.noData`),e[19]=i,e[20]=t,e[21]=m):m=e[21];let h;e[22]===m?h=e[23]:(h=(0,$.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap`,children:m}),e[22]=m,e[23]=h);let g;e[24]!==d||e[25]!==p||e[26]!==h?(g=(0,$.jsxs)(Xr,{className:`max-w-2xl`,children:[d,p,h]}),e[24]=d,e[25]=p,e[26]=h,e[27]=g):g=e[27];let _;return e[28]!==n||e[29]!==r||e[30]!==g?(_=(0,$.jsx)($r,{open:n,onOpenChange:r,children:g}),e[28]=n,e[29]=r,e[30]=g,e[31]=_):_=e[31],_};function wy(e){return e.isOpenCodeStatusDialogOpen}function Ty(e){return e.setOpenCodeStatusDialogOpen}function Ey(e){return e.openCodeStatusText}function Dy(){let e=(0,Q.c)(2),t=Na(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Sl,{className:`ml-auto`}):null,e[0]=t,e[1]=n),n}function Oy(){let e=(0,Q.c)(2),t=Pa(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Sl,{}):null,e[0]=t,e[1]=n),n}var ky=e=>{let t=(0,Q.c)(12),{normalizedProjects:n,ownership:r,isSessionsLoading:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,foldersMap:s,createFolder:c,addSessionToFolder:l,cleanupSessions:u,enabled:d}=e,f=d===void 0||d,p,m;t[0]!==l||t[1]!==u||t[2]!==c||t[3]!==f||t[4]!==s||t[5]!==o||t[6]!==a||t[7]!==i||t[8]!==n||t[9]!==r?(p=()=>{!f||i||n.forEach(e=>{let t=bo(e.normalizedPath),n=r.archivedSessionsByProject.get(e.id)??[],i=s[t]??[],d=new Map(i.map(Ay));n.forEach(n=>{let r=yo(n,e.normalizedPath),i=r.toLowerCase(),a=d.get(i);a||(a=c(t,r),d.set(i,a)),a.sessionIds.includes(n.id)||l(t,a.id,n.id)}),o>0&&u(t,a)})},m=[f,n,r,i,o,a,s,c,l,u],t[0]=l,t[1]=u,t[2]=c,t[3]=f,t[4]=s,t[5]=o,t[6]=a,t[7]=i,t[8]=n,t[9]=r,t[10]=p,t[11]=m):(p=t[10],m=t[11]),Z.useEffect(p,m)};function Ay(e){return[e.name.toLowerCase(),e]}var jy=e=>{let t=(0,Q.c)(7),{isSessionsLoading:n,fullCatalogSessionIds:r,fullCatalogGeneration:i,normalizedProjects:a,cleanupSessions:o}=e,s,c;t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==n||t[4]!==a?(s=()=>{if(n||i===0)return;let e=nn.getState().foldersMap;new Set([...Object.keys(e),...a.map(My)]).forEach(e=>{o(e,r)})},c=[o,i,r,n,a],t[0]=o,t[1]=i,t[2]=r,t[3]=n,t[4]=a,t[5]=s,t[6]=c):(s=t[5],c=t[6]),Z.useEffect(s,c)};function My(e){return bo(e.normalizedPath)}var Ny=Z.memo(function(e){let t=(0,Q.c)(17),{normalizedProjects:n,ownership:r,enabled:i}=e;el();let a=hn(Py),o=hn(Fy),s=Jn(Iy),c=nn(Ly),l=nn(Ry),u=nn(zy),d=nn(By),f;t[0]!==d||t[1]!==o||t[2]!==a||t[3]!==s||t[4]!==n?(f={normalizedProjects:n,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,cleanupSessions:d},t[0]=d,t[1]=o,t[2]=a,t[3]=s,t[4]=n,t[5]=f):f=t[5],jy(f);let p;return t[6]!==u||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==c||t[11]!==o||t[12]!==a||t[13]!==s||t[14]!==n||t[15]!==r?(p={normalizedProjects:n,ownership:r,enabled:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,foldersMap:c,createFolder:l,addSessionToFolder:u,cleanupSessions:d},t[6]=u,t[7]=d,t[8]=l,t[9]=i,t[10]=c,t[11]=o,t[12]=a,t[13]=s,t[14]=n,t[15]=r,t[16]=p):p=t[16],ky(p),null});function Py(e){return e.fullCatalogSessionIds}function Fy(e){return e.fullCatalogGeneration}function Iy(e){return e.isLoading}function Ly(e){return e.foldersMap}function Ry(e){return e.createFolder}function zy(e){return e.addSessionToFolder}function By(e){return e.cleanupSessions}var Vy=new WeakMap,Hy=e=>{let{normalizedProjects:t,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:a,projectRootBranches:o,lastRepoStatus:s,buildGroupedSessions:c,hasSessionSearchQuery:l,normalizedSessionSearchQuery:u,filterSessionNodesForSearch:d,buildGroupSearchText:f,foldersMap:p}=e,m=Z.useRef([]),h=Z.useMemo(()=>{let e=new Map(m.current.map(e=>[e.project.id,e])),l=t.map(t=>{let l=e.get(t.id),u=jo([...n(t.id),...r(t.id)]),d=i.get(t.normalizedPath)??[],f=a.has(t.id)?!!a.get(t.id):s,p=new Map(l?.groups.map(e=>[e.id,e])),m=c(u,t.normalizedPath,d,o.get(t.id)??null,f).map(e=>_t(p.get(e.id),e));return _t(l,{project:t,groups:m})});return l.length===m.current.length&&l.every((e,t)=>e===m.current[t])?m.current:l},[t,n,r,i,a,s,c,o]);Z.useLayoutEffect(()=>{m.current=h},[h]);let g=Z.useMemo(()=>h,[h]),_=Z.useMemo(()=>{if(!l)return Vy;let e=new WeakMap,t=e=>e.reduce((e,n)=>e+1+t(n.children),0);return g.forEach(n=>{n.groups.forEach(n=>{let r=d(n.sessions,u),i=t(r),a=f(n).includes(u),o=pt(n.directory??null),s=(o?p[o]??[]:[]).filter(e=>e.name.toLowerCase().includes(u)).length;e.set(n,{filteredNodes:r,matchedSessionCount:i,folderNameMatchCount:s,groupMatches:a,hasMatch:a||i>0||s>0})})}),e},[l,g,d,u,f,p]),v=Z.useMemo(()=>l?g.map(e=>({...e,groups:e.groups.filter(e=>_.get(e)?.hasMatch===!0)})).filter(e=>e.groups.length>0):g,[l,g,_]),y=l?v:g;return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:_,searchableProjectSections:v,sectionsForRender:y,searchMatchCount:Z.useMemo(()=>l?y.reduce((e,t)=>e+t.groups.reduce((e,t)=>{let n=_.get(t);if(!n)return e;let r=n.folderNameMatchCount+ +!!n.groupMatches;return e+n.matchedSessionCount+r},0),0):0,[l,y,_])}},Uy=e=>{let t=(0,Q.c)(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:a,currentSessionId:o,handleSessionSelect:s,newSessionDraftOpen:c,mobileVariant:l,openNewSessionDraft:u,setActiveMainTab:d,setSessionSwitcherOpen:f}=e,p,m;if(t[0]!==n){m=new Map,p=new Map;let e=(t,n,r,i)=>{m.has(t)||m.set(t,new Map);let a=m.get(t);i.forEach(i=>{let o=pt(i.worktree?.path??i.session.directory??r??n);a.set(i.session.id,{directory:o}),p.has(t)||p.set(t,{id:i.session.id,directory:o}),i.children.length>0&&e(t,n,o,i.children)})};n.forEach(t=>{t.groups.forEach(n=>{e(t.project.id,t.project.normalizedPath,n.directory,n.sessions)})}),t[0]=n,t[1]=p,t[2]=m}else p=t[1],m=t[2];let h;t[3]!==p||t[4]!==m?(h={metaByProject:m,firstSessionByProject:p},t[3]=p,t[4]=m,t[5]=h):h=t[5];let g=h,_=Z.useRef(null),v,y;t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==l||t[11]!==c||t[12]!==u||t[13]!==n||t[14]!==g||t[15]!==d||t[16]!==a||t[17]!==f?(v=()=>{if(!r||c||K.getState().isNewWorktreeDialogOpen||_.current===r)return;let e=n.find(e=>e.project.id===r);if(!e)return;_.current=r;let t=g.metaByProject.get(r);if(o&&t&&t.has(o)){a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t});return}if(o&&t)return;if(!t||t.size===0){d(`chat`),l&&f(!1),u({directoryOverride:e.project.normalizedPath});return}let p=i.get(r),m=p&&t.has(p)?p:null,h=g.firstSessionByProject.get(r)?.id??null,v=m??h;if(!v||v===o)return;let y=t.get(v)?.directory??null;s(v,y,r)},y=[r,i,o,s,c,l,u,n,g,d,f,a],t[6]=r,t[7]=i,t[8]=o,t[9]=s,t[10]=l,t[11]=c,t[12]=u,t[13]=n,t[14]=g,t[15]=d,t[16]=a,t[17]=f,t[18]=v,t[19]=y):(v=t[18],y=t[19]),Z.useLayoutEffect(v,y);let b,x;t[20]!==r||t[21]!==o||t[22]!==g||t[23]!==a?(b=()=>{if(!r||!o)return;let e=g.metaByProject.get(r);!e||!e.has(o)||a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t})},x=[r,o,g,a],t[20]=r,t[21]=o,t[22]=g,t[23]=a,t[24]=b,t[25]=x):(b=t[24],x=t[25]),Z.useEffect(b,x)},Wy=e=>{let t=Mn(e=>e.orderByProject);return{getOrderedGroups:Z.useMemo(()=>(n,r)=>{let i=e.get(n),a=t[n];if(!i?.length&&!a?.length)return r;let o=new Map(r.map(e=>[e.id,e])),s=[];if(i?.forEach(e=>{let t=o.get(e);t&&(s.push(t),o.delete(e))}),r.forEach(e=>{o.has(e.id)&&s.push(e)}),!a?.length)return s;let c=new Map(a.map((e,t)=>[pt(e),t])),l=s.filter(e=>e.worktree&&!e.isMain);l.sort((e,t)=>(c.get(pt(e.directory))??2**53-1)-(c.get(pt(t.directory))??2**53-1));let u=0;return s.map(e=>e.worktree&&!e.isMain?l[u++]:e)},[e,t])}},Gy=e=>{let t=(0,Q.c)(9),{isSessionSearchOpen:n,setIsSessionSearchOpen:r,sessionSearchInputRef:i,sessionSearchContainerRef:a}=e,o,s;t[0]!==n||t[1]!==i?(o=()=>{if(!n||typeof window>`u`)return;let e=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(e)},s=[n,i],t[0]=n,t[1]=i,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s);let c,l;t[4]!==n||t[5]!==a||t[6]!==r?(c=()=>{if(!n||typeof document>`u`)return;let e=e=>{a.current&&(a.current.contains(e.target)||r(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},l=[n,r,a],t[4]=n,t[5]=a,t[6]=r,t[7]=c,t[8]=l):(c=t[7],l=t[8]),Z.useEffect(c,l)},Ky=e=>{let t=(0,Q.c)(42),{t:n}=Pr(),[r,i]=Z.useState(null),a=Z.useRef(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),Z.useEffect(o,s);let c;t[2]===e?c=t[3]:(c=(t,n,r)=>{let i=()=>{!e.isSessionSearchOpen&&e.sessionSearchQuery.length===0||(e.setSessionSearchQuery(``),e.setIsSessionSearchOpen(!1))};if(r&&r!==e.activeProjectId&&e.setActiveProjectIdOnly(r),n&&n!==e.currentDirectory&&e.setDirectory(n,{showOverlay:!1}),e.setActiveMainTab(`chat`)){if(e.mobileVariant&&e.setSessionSwitcherOpen(!1),t===e.currentSessionId){e.allowReselect&&e.onSessionSelected?.(t),i();return}e.setCurrentSession(t,n??null),e.onSessionSelected?.(t),i()}},t[2]=e,t[3]=c);let l=c,u;t[4]===e?u=t[5]:(u=(t,n)=>{e.setEditingId(t),e.setEditTitle(n)},t[4]=e,t[5]=u);let d=u,f;t[6]===e?f=t[7]:(f=async t=>{if(!e.editingId)return;let n=(t??e.editTitle).trim();n&&await e.updateSessionTitle(e.editingId,n),e.setEditingId(null),e.setEditTitle(``)},t[6]=e,t[7]=f);let p=f,m;t[8]===e?m=t[9]:(m=()=>{e.setEditingId(null),e.setEditTitle(``)},t[8]=e,t[9]=m);let h=m,g;t[10]!==e||t[11]!==n?(g=async t=>{let r=await e.shareSession(t.id);r&&r.share?.url?Y.success(n(`sessions.sidebar.session.share.successTitle`),{description:n(`sessions.sidebar.session.share.successDescription`)}):Y.error(n(`sessions.sidebar.session.share.error`))},t[10]=e,t[11]=n,t[12]=g):g=t[12];let _=g,v;t[13]===n?v=t[14]:(v=(e,t)=>{pr(e).then(e=>{if(!e.ok){Y.error(n(`sessions.sidebar.session.share.copyUrlError`));return}i(t),a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i(null),a.current=null},2e3)}).catch(()=>{Y.error(n(`sessions.sidebar.session.share.copyUrlError`))})},t[13]=n,t[14]=v);let y=v,b;t[15]!==e||t[16]!==n?(b=async t=>{await e.unshareSession(t)?Y.success(n(`sessions.sidebar.session.unshare.success`)):Y.error(n(`sessions.sidebar.session.unshare.error`))},t[15]=e,t[16]=n,t[17]=b):b=t[17];let x=b,S;t[18]===e.childrenMap?S=t[19]:(S=t=>{let n=[],r=t=>{(e.childrenMap.get(t)??[]).forEach(e=>{n.push(e),r(e.id)})};return r(t),n},t[18]=e.childrenMap,t[19]=S);let C=S,w=Jy,T;t[20]!==e||t[21]!==C||t[22]!==n?(T=async(t,r,i)=>{let a=r?.archivedBucket===!0||r?.hardDelete===!0,o=i?.descendantIds??w(C(t.id),a).map(Yy);if(o.length===0){if(a){wl({sessionIds:[t.id],message:n(`sessions.sidebar.session.delete.success`),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}await e.archiveSession(t.id)?$c({sessionIds:[t.id],message:n(`sessions.sidebar.session.archive.success`),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(n(`sessions.sidebar.session.archive.error`));return}let s=[t.id,...o];if(a){wl({sessionIds:s,message:s.length===1?n(`sessions.sidebar.bulkActions.deletedSingle`,{count:s.length}):n(`sessions.sidebar.bulkActions.deletedPlural`,{count:s.length}),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}let{archivedIds:c,failedIds:l}=await e.archiveSessions(s);c.length>0&&$c({sessionIds:c,message:c.length===1?n(`sessions.sidebar.bulkActions.archivedSingle`,{count:c.length}):n(`sessions.sidebar.bulkActions.archivedPlural`,{count:c.length}),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:c.length===1?n(`sessions.sidebar.session.archive.undoFailed`):n(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:c.length})}),l.length>0&&Y.error(l.length===1?n(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:l.length}):n(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:l.length}))},t[20]=e,t[21]=C,t[22]=n,t[23]=T):T=t[23];let E=T,D;t[24]!==e||t[25]!==C||t[26]!==E?(D=(t,n)=>{let r=n?.archivedBucket===!0||n?.hardDelete===!0,i=w(C(t.id),r).map(Xy);if(!r||!e.showDeletionDialog||n?.skipConfirm===!0){E(t,n,{descendantIds:i});return}e.setDeleteSessionConfirm({session:t,descendantCount:i.length,descendantIds:i,archivedBucket:r})},t[24]=e,t[25]=C,t[26]=E,t[27]=D):D=t[27];let O=D,k;t[28]!==e||t[29]!==E?(k=async()=>{if(!e.deleteSessionConfirm)return;let{session:t,archivedBucket:n,descendantIds:r}=e.deleteSessionConfirm;e.setDeleteSessionConfirm(null),await E(t,{archivedBucket:n},{descendantIds:r})},t[28]=e,t[29]=E,t[30]=k):k=t[30];let A=k,j;return t[31]!==A||t[32]!==r||t[33]!==h||t[34]!==y||t[35]!==O||t[36]!==p||t[37]!==d||t[38]!==l||t[39]!==_||t[40]!==x?(j={copiedSessionId:r,handleSessionSelect:l,handleSessionDoubleClick:d,handleSaveEdit:p,handleCancelEdit:h,handleShareSession:_,handleCopyShareUrl:y,handleUnshareSession:x,handleDeleteSession:O,confirmDeleteSession:A},t[31]=A,t[32]=r,t[33]=h,t[34]=y,t[35]=O,t[36]=p,t[37]=d,t[38]=l,t[39]=_,t[40]=x,t[41]=j):j=t[41],j};function qy(e){return!e.time?.archived}function Jy(e,t){return t?e:e.filter(qy)}function Yy(e){return e.id}function Xy(e){return e.id}var Zy=[`project:active:`,`project:archived:`,`pinned:active:`,`pinned:archived:`],Qy=e=>{let{isVSCode:t,safeStorage:n,keys:r,groupOrderByProject:i,activeSessionByProject:a,collapsedGroups:o,setExpandedParents:s,setCollapsedProjects:c}=e,l=Z.useRef(null),u=Z.useRef(null),[d,f]=Z.useState(!1),p=Z.useCallback(()=>{if(t)return;let e=u.current;if(u.current=null,l.current=null,!e)return;let{projects:n}=fn.getState(),r=n.map(t=>({...t,sidebarCollapsed:e.has(t.id)}));Ze({projects:r}).catch(()=>{})},[t]),m=Z.useCallback(e=>{typeof window>`u`||t||(u.current=e,l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{p()},700))},[t,p]);return Z.useEffect(()=>()=>{typeof window<`u`&&l.current!==null&&window.clearTimeout(l.current),l.current=null,u.current=null},[]),Z.useEffect(()=>{try{let e=n.getItem(r.sessionExpanded);if(e){let t=JSON.parse(e);Array.isArray(t)&&s(new Set(t.filter(e=>typeof e==`string`)))}else{let e=n.getItem(r.sessionExpandedLegacy);if(e){try{let t=JSON.parse(e);if(Array.isArray(t)){let e=new Set;if(t.forEach(t=>{typeof t==`string`&&t.length!==0&&Zy.forEach(n=>e.add(`${n}${t}`))}),e.size>0){s(e);try{n.setItem(r.sessionExpanded,JSON.stringify(Array.from(e)))}catch{}}}}catch{}try{n.removeItem?.(r.sessionExpandedLegacy)}catch{}}}let t=n.getItem(r.projectCollapse);if(t){let e=JSON.parse(t);Array.isArray(e)&&c(new Set(e.filter(e=>typeof e==`string`)))}}catch{}finally{f(!0)}},[r.projectCollapse,r.sessionExpanded,r.sessionExpandedLegacy,n,c,s]),Z.useEffect(()=>{try{let e=Object.fromEntries(i.entries());n.setItem(r.groupOrder,JSON.stringify(e))}catch{}},[i,r.groupOrder,n]),Z.useEffect(()=>{try{let e=Object.fromEntries(a.entries());n.setItem(r.projectActiveSession,JSON.stringify(e))}catch{}},[a,r.projectActiveSession,n]),Z.useEffect(()=>{try{n.setItem(r.groupCollapse,JSON.stringify(Array.from(o)))}catch{}},[o,r.groupCollapse,n]),{scheduleCollapsedProjectsPersist:m,hasRestoredProjectCollapse:d}},$y=async(e,t,n)=>{if(e.length===0)return[];let r=Math.max(1,Math.min(t,e.length)),i=Array(e.length),a=0,o=async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;i[t]=await n(e[t])}};return await Promise.all(Array.from({length:r},()=>o())),i},eb=e=>{let{normalizedProjects:t,activeProjectId:n,gitRepoStatus:r,setProjectRepoStatus:i,setProjectRootBranches:a,enabled:o=!0}=e,{git:s}=Tt(),c=$i(e=>e.ensureStatus),l=Z.useMemo(()=>o?t.filter(e=>e.id===n):[],[n,o,t]);Z.useEffect(()=>{if(!o||!s||l.length===0){if(!o)return;i(e=>e.size===0?e:new Map);return}l.forEach(e=>{c(e.normalizedPath,s)})},[l,o,s,c,i]),Z.useEffect(()=>{let e=new Map;l.forEach(t=>{e.set(t.id,r.get(t.normalizedPath)?.isGitRepo??null)}),i(t=>t.size===e.size&&[...e].every(([e,n])=>t.has(e)&&t.get(e)===n)?t:e)},[l,r,i]);let u=Z.useMemo(()=>l.map(e=>{let t=r.get(e.normalizedPath)?.branch??``;return`${e.id}:${t}`}).join(`|`),[l,r]),d=Z.useRef(new Map),f=Z.useRef(new Map);Z.useEffect(()=>{let e=!1,t=setTimeout(()=>{(async()=>{let t=new Set(l.map(e=>e.id));for(let e of d.current.keys())t.has(e)||(d.current.delete(e),f.current.delete(e));let n=Date.now(),i=l.filter(e=>{let t=r.get(e.normalizedPath);if(t?.isGitRepo===!1)return d.current.delete(e.id),f.current.delete(e.id),!1;if(t?.isGitRepo!==!0||t.branch===null)return!1;let i=t.branch.trim(),a=`${e.normalizedPath}\0${i}`,o=d.current.get(e.id);if(o===a){let t=f.current.get(e.id);return t&&(t.at=n),!1}return!(o!==void 0&&n-(f.current.get(e.id)?.at??0)<3e5)});if(i.length===0)return;let o=await $y(i,2,async e=>{let t=r.get(e.normalizedPath)?.branch?.trim()??``,n=`${e.normalizedPath}\0${t}`,i=await Bs(e.normalizedPath,t?{knownBranch:t}:void 0).catch(()=>null);return{id:e.id,inputKey:n,branch:i}});if(e)return;let s=o.filter(e=>e.branch);if(s.length===0)return;let c=Date.now();a(e=>{let t=e;return s.forEach(({id:n,branch:r})=>{r&&e.get(n)!==r&&(t===e&&(t=new Map(e)),t.set(n,r))}),t}),s.forEach(({id:e,inputKey:t,branch:n})=>{d.current.set(e,t),n&&f.current.set(e,{branch:n,at:c})})})()},150);return()=>{e=!0,clearTimeout(t)}},[l,u,r,a])},tb=e=>{let t=(0,Q.c)(7),{ownership:n}=e,r;t[0]===n?r=t[1]:(r=e=>n.sessionsByProject.get(e)??[],t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=e=>n.archivedSessionsByProject.get(e)??[],t[2]=n,t[3]=a);let o=a,s;return t[4]!==o||t[5]!==i?(s={getSessionsForProject:i,getArchivedSessionsForProject:o},t[4]=o,t[5]=i,t[6]=s):s=t[6],s},nb=e=>{let t=(0,Q.c)(16),{open:n,onOpenChange:r,project:i,onSave:a}=e,o;t[0]!==i?.label||t[1]!==i?.path?(o=i?.label||i?.path.split(/[\\/]/).filter(Boolean).at(-1),t[0]=i?.label,t[1]=i?.path,t[2]=o):o=t[2];let s;t[3]!==a||t[4]!==n||t[5]!==i?(s=n&&i?(0,$.jsx)(cu,{project:i,onIdentitySave:a,compact:!0}):null,t[3]=a,t[4]=n,t[5]=i,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(Gr,{outerClassName:`max-h-[min(85dvh,44rem)]`,disableHorizontal:!0,children:(0,$.jsx)(`div`,{className:`w-full p-4 sm:p-6`,children:s})}),t[7]=s,t[8]=c);let l;t[9]!==o||t[10]!==c?(l=(0,$.jsx)(Xr,{"aria-label":o,className:`yuri-settings-workspace w-full max-w-xl gap-0 overflow-hidden p-0`,children:c}),t[9]=o,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==r||t[13]!==n||t[14]!==l?(u=(0,$.jsx)($r,{open:n,onOpenChange:r,children:l}),t[12]=r,t[13]=n,t[14]=l,t[15]=u):u=t[15],u};function rb(e){let t=(0,Q.c)(36),{t:n}=Pr(),{hideDirectoryControls:r,isSessionSearchOpen:i,setIsSessionSearchOpen:a,sessionSearchInputRef:o,sessionSearchQuery:s,setSessionSearchQuery:c,hasSessionSearchQuery:l,searchMatchCount:u}=e;if(r||!i)return null;let d;t[0]!==l||t[1]!==u||t[2]!==n?(d=l?(0,$.jsx)(`span`,{children:n(u===1?`sessions.sidebar.header.search.matchCountSingle`:`sessions.sidebar.header.search.matchCountPlural`,{count:u})}):(0,$.jsx)(`span`,{}),t[0]=l,t[1]=u,t[2]=n,t[3]=d):d=t[3];let f;t[4]===n?f=t[5]:(f=n(`sessions.sidebar.header.search.escapeHint`),t[4]=n,t[5]=f);let p;t[6]===f?p=t[7]:(p=(0,$.jsx)(`span`,{children:f}),t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=e=>c(e.target.value),t[12]=c,t[13]=g);let _;t[14]===n?_=t[15]:(_=n(`sessions.sidebar.header.search.placeholder`),t[14]=n,t[15]=_);let v;t[16]!==l||t[17]!==a||t[18]!==c?(v=e=>{e.key===`Escape`&&(e.stopPropagation(),l?c(``):a(!1))},t[16]=l,t[17]=a,t[18]=c,t[19]=v):v=t[19];let y;t[20]!==o||t[21]!==s||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(`input`,{ref:o,value:s,onChange:g,placeholder:_,className:`h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,onKeyDown:v}),t[20]=o,t[21]=s,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==s.length||t[27]!==c||t[28]!==n?(b=s.length>0?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":n(`sessions.sidebar.header.search.clear`),children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})}):null,t[26]=s.length,t[27]=c,t[28]=n,t[29]=b):b=t[29];let x;t[30]!==y||t[31]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,children:[h,y,b]}),t[30]=y,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==x||t[34]!==m?(S=(0,$.jsx)(`div`,{className:`select-none flex-shrink-0 px-3 py-1`,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[m,x]})}),t[33]=x,t[34]=m,t[35]=S):S=t[35],S}function ib(e){let t=(0,Q.c)(15),{title:n,accessory:r,isFirst:i,onToggle:a,expanded:o,className:s,titleSlot:c,leadingIcon:l}=e,u=i!==void 0&&i,d=c?u?`pt-1 pb-1.5`:`pt-3 pb-1.5`:u?`pt-1 pb-1`:`pt-4 pb-1`,f;t[0]!==s||t[1]!==d?(f=J(`group/section flex w-full items-center gap-1 px-2`,d,s),t[0]=s,t[1]=d,t[2]=f):f=t[2];let p;t[3]!==o||t[4]!==l||t[5]!==a||t[6]!==n||t[7]!==c?(p=c?(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:c}):a?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`group/toggle flex min-w-0 flex-1 items-center gap-1 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-expanded":o,children:[l,(0,$.jsx)(`span`,{className:`typography-micro font-normal tracking-wide text-muted-foreground/80`,children:n}),(0,$.jsx)(X,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 opacity-0 transition-opacity group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]}):(0,$.jsx)(`span`,{className:J(`flex min-w-0 flex-1 items-center gap-1`,`typography-micro font-normal tracking-wide text-muted-foreground/80`),children:n}),t[3]=o,t[4]=l,t[5]=a,t[6]=n,t[7]=c,t[8]=p):p=t[8];let m;t[9]===r?m=t[10]:(m=r?(0,$.jsx)(`div`,{className:`ml-auto -mr-2 flex shrink-0 items-center`,children:r}):null,t[9]=r,t[10]=m);let h;return t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function ab(e){let t=(0,Q.c)(60),{items:n,reorderEnabled:r,onSessionsReordered:i,inProgressItems:a,renderSessionNode:o,currentSessionId:s,editingId:c,openSidebarMenuKey:l,headerAccessory:u,onVisibleSessionIdsChange:d,isFirst:f,hideHeader:p}=e,m=r!==void 0&&r,h;t[0]===a?h=t[1]:(h=a===void 0?[]:a,t[0]=a,t[1]=h);let g=h,_=f!==void 0&&f,v=p!==void 0&&p,{t:y}=Pr(),[b,x]=Z.useState(!1),S=b&&!v,C=m&&!c&&n.length>1&&!!i,w;t[2]===n?w=t[3]:(w=n.map(pb),t[2]=n,t[3]=w);let T=w,E;t[4]===T?E=t[5]:(E=new Map(T.map(fb)),t[4]=T,t[5]=E);let D=E,O=fo(db),k,A;t[6]!==S||t[7]!==g||t[8]!==n||t[9]!==d?(k=()=>{if(S){d?.([]);return}d?.([...n.map(ub),...g.map(lb)])},A=[S,g,n,d],t[6]=S,t[7]=g,t[8]=n,t[9]=d,t[10]=k,t[11]=A):(k=t[10],A=t[11]),Z.useLayoutEffect(k,A);let j,M;t[12]!==g||t[13]!==n||t[14]!==O?(j=()=>{O&&(n.some(e=>e.node.session.id===O)||g.some(e=>e.node.session.id===O))&&x(!1)},M=[g,n,O],t[12]=g,t[13]=n,t[14]=O,t[15]=j,t[16]=M):(j=t[15],M=t[16]),Z.useLayoutEffect(j,M);let N,P,F,I;if(t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==n||t[21]!==l){let e=[...n,...g].map(cb);F=new Set,il(e,s,F),I=new Set,il(e,c,I),N=Ic(e,l,`pinned`,!1),P=new WeakMap;let r=e=>{P.set(e,Ac(e)),e.children.forEach(r)};e.forEach(r),t[17]=s,t[18]=c,t[19]=g,t[20]=n,t[21]=l,t[22]=N,t[23]=P,t[24]=F,t[25]=I}else N=t[22],P=t[23],F=t[24],I=t[25];let L;t[26]!==N||t[27]!==P||t[28]!==F||t[29]!==I?(L=e=>({subtreeContainsActive:F,subtreeContainsEditing:I,menuOpenSessionId:N,nodeStructureKey:P.get(e)??``,childRenderExtrasFor:L}),t[26]=N,t[27]=P,t[28]=F,t[29]=I,t[30]=L):L=t[30];let R;t[31]!==L||t[32]!==N||t[33]!==P||t[34]!==F||t[35]!==I?(R=e=>({subtreeContainsActive:F,subtreeContainsEditing:I,menuOpenSessionId:N,nodeStructureKey:P.get(e)??``,childRenderExtrasFor:L}),t[31]=L,t[32]=N,t[33]=P,t[34]=F,t[35]=I,t[36]=R):R=t[36];let z=R;if(n.length+g.length===0)return null;let ee;t[37]!==z||t[38]!==o?(ee=e=>e.map(e=>{let t=e.content??o(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`pinned`,z(e.node));return(0,$.jsx)(Z.Fragment,{children:t},e.identity??e.node.session.id)}),t[37]=z,t[38]=o,t[39]=ee):ee=t[39];let B=ee,V=v?`-ml-1 -mr-1`:`pb-1`,te;t[40]!==S||t[41]!==u||t[42]!==v||t[43]!==g.length||t[44]!==_||t[45]!==y?(te=v?null:(0,$.jsx)(ib,{title:g.length>0?y(`directoryTree.section.pinnedInProgress`):y(`directoryTree.section.pinned`),onToggle:()=>x(sb),expanded:!S,isFirst:_,accessory:u}),t[40]=S,t[41]=u,t[42]=v,t[43]=g.length,t[44]=_,t[45]=y,t[46]=te):te=t[46];let ne;t[47]!==C||t[48]!==S||t[49]!==D||t[50]!==g||t[51]!==n||t[52]!==i||t[53]!==B||t[54]!==T?(ne=S?null:(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[C?(0,$.jsx)(fc,{scopeKey:wc,sessionIds:T,folderIdBySessionId:D,onSessionDroppedOnFolder:ob,onSessionsReordered:(e,t)=>i?.(e,t),children:B(n)}):B(n),B(g)]}),t[47]=C,t[48]=S,t[49]=D,t[50]=g,t[51]=n,t[52]=i,t[53]=B,t[54]=T,t[55]=ne):ne=t[55];let re;return t[56]!==V||t[57]!==te||t[58]!==ne?(re=(0,$.jsx)(ni,{delay:0,closeDelay:150,timeout:600,children:(0,$.jsxs)(`div`,{className:V,children:[te,ne]})}),t[56]=V,t[57]=te,t[58]=ne,t[59]=re):re=t[59],re}function ob(){}function sb(e){return!e}function cb(e){return e.node}function lb(e){return e.node.session.id}function ub(e){return e.node.session.id}function db(e){return e.focus?.scope===`pinned`?e.focus.sessionId:null}function fb(e){return[e,null]}function pb(e){return e.node.session.id}function mb(e){let t=(0,Q.c)(41),{collapseAllProjects:n,expandAllProjects:r,buttonClassName:i,iconClassName:a}=e,{t:o}=Pr(),s;t[0]===i?s=t[1]:(s=J(`size-6 p-0 text-muted-foreground`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o(`sessions.sidebar.header.actions.sessionDisplayMode`),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=J(`h-3.5 w-3.5`,a),t[4]=a,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(X,{name:`more-2-fill`,className:l}),t[6]=l,t[7]=u);let d;t[8]!==s||t[9]!==c||t[10]!==u?(d=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:s,"aria-label":c,onClick:hb,children:u})})}),t[8]=s,t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;t[12]===o?f=t[13]:(f=o(`sessions.sidebar.header.displayMode.label`),t[12]=o,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,$.jsx)(ti,{side:`bottom`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f})}),t[14]=f,t[15]=p);let m;t[16]!==d||t[17]!==p?(m=(0,$.jsxs)(ri,{children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18];let h;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`contract-up-down`,className:`h-4 w-4`}),t[19]=h):h=t[19];let g;t[20]===o?g=t[21]:(g=o(`sessions.sidebar.header.displayMode.collapseAll`),t[20]=o,t[21]=g);let _;t[22]===g?_=t[23]:(_=(0,$.jsx)(`span`,{children:g}),t[22]=g,t[23]=_);let v;t[24]!==n||t[25]!==_?(v=(0,$.jsxs)(Si,{onClick:n,className:`flex items-center gap-2`,children:[h,_]}),t[24]=n,t[25]=_,t[26]=v):v=t[26];let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(X,{name:`expand-up-down`,className:`h-4 w-4`}),t[27]=y):y=t[27];let b;t[28]===o?b=t[29]:(b=o(`sessions.sidebar.header.displayMode.expandAll`),t[28]=o,t[29]=b);let x;t[30]===b?x=t[31]:(x=(0,$.jsx)(`span`,{children:b}),t[30]=b,t[31]=x);let S;t[32]!==r||t[33]!==x?(S=(0,$.jsxs)(Si,{onClick:r,className:`flex items-center gap-2`,children:[y,x]}),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==v||t[36]!==S?(C=(0,$.jsxs)(xi,{align:`end`,className:`min-w-[160px]`,children:[v,S]}),t[35]=v,t[36]=S,t[37]=C):C=t[37];let w;return t[38]!==C||t[39]!==m?(w=(0,$.jsxs)(wi,{children:[m,C]}),t[38]=C,t[39]=m,t[40]=w):w=t[40],w}function hb(e){e.stopPropagation()}var gb=()=>yt({queryKey:[u(),d(),`device-connections`],queryFn:async({signal:e})=>{let t=await g(`/api/client-auth/clients`,{signal:e});if(!t.ok)throw Error(`Device list unavailable`);let n=await t.json();if(!Array.isArray(n.clients))throw Error(`Invalid device list`);if(n.clients.some(e=>typeof e.connected!=`boolean`))throw Error(`Presence unavailable`);return n.clients.filter(e=>!e.revokedAt&&e.connected&&e.clientKind!==`desktop-local`&&e.id!==n.currentClientId)},staleTime:0,retry:!1});function _b(){let e=(0,Q.c)(53),{t}=Pr(),{clientAuth:n}=Tt(),[r,i]=(0,Z.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=gb(),e[0]=a):a=e[0];let o=r&&!!n,s=r?5e3:!1,c;e[1]!==o||e[2]!==s?(c={...a,enabled:o,refetchInterval:s},e[1]=o,e[2]=s,e[3]=c):c=e[3];let l=bt(c),u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i(!1);let e=K.getState();e.setSettingsRemoteInstancesSelectedId(null),e.setSettingsPage(`remote-instances`),K.setState({devicePairingRequested:!0}),e.setSettingsDialogOpen(!0)},e[4]=u):u=e[4];let d=G(u);if(!n)return null;let f;e[5]===t?f=e[6]:(f=t(`settings.remoteInstances.quick.title`),e[5]=t,e[6]=f);let p;e[7]===f?p=e[8]:(p=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`group size-7 rounded-md text-foreground/55 hover:bg-interactive-hover hover:text-foreground`,"aria-label":f}),e[7]=f,e[8]=p);let m;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{name:`devices-connected`,className:`size-[18px]`}),e[9]=m):m=e[9];let h;e[10]===p?h=e[11]:(h=(0,$.jsx)(W,{openOnHover:!0,delay:180,closeDelay:200,render:p,children:m}),e[10]=p,e[11]=h);let g;e[12]===t?g=e[13]:(g=t(`settings.remoteInstances.quick.title`),e[12]=t,e[13]=g);let _;e[14]===g?_=e[15]:(_=(0,$.jsx)(Ge,{className:`typography-ui-label font-medium`,children:g}),e[14]=g,e[15]=_);let v;e[16]===l.data?v=e[17]:(v=l.data&&l.data.length>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:l.data.length}):null,e[16]=l.data,e[17]=v);let y;e[18]!==_||e[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pb-2 pt-4`,children:[_,v]}),e[18]=_,e[19]=v,e[20]=y):y=e[20];let b;e[21]!==l.isPending||e[22]!==t?(b=l.isPending?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`common.loading`)}):null,e[21]=l.isPending,e[22]=t,e[23]=b):b=e[23];let x;e[24]!==l.isError||e[25]!==t?(x=l.isError?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`settings.remoteInstances.quick.error`)}):null,e[24]=l.isError,e[25]=t,e[26]=x):x=e[26];let S;e[27]!==l.data?.length||e[28]!==l.isError||e[29]!==t?(S=!l.isError&&l.data?.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-5 pb-5 pt-6 text-center`,children:[(0,$.jsx)(X,{name:`devices-connected`,className:`mb-4 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:t(`settings.remoteInstances.clientAuth.state.empty`)}),(0,$.jsx)(`p`,{className:`mt-2 typography-meta leading-relaxed text-muted-foreground`,children:t(`settings.remoteInstances.quick.emptyHint`)})]}):null,e[27]=l.data?.length,e[28]=l.isError,e[29]=t,e[30]=S):S=e[30];let C;e[31]!==l.data||e[32]!==t?(C=l.data?.map(e=>{let n=e.devicePlatform?.toLowerCase();return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:n===`ios`?`device-ios`:n===`android`?`device-android`:`device-desktop`,className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro text-[var(--status-success)]`,children:t(`desktopHostSwitcher.status.connected`)})]})]},e.id)}),e[31]=l.data,e[32]=t,e[33]=C):C=e[33];let w;e[34]!==b||e[35]!==x||e[36]!==S||e[37]!==C?(w=(0,$.jsxs)(`div`,{className:`max-h-64 space-y-2 overflow-y-auto px-3 pb-2`,"aria-live":`polite`,children:[b,x,S,C]}),e[34]=b,e[35]=x,e[36]=S,e[37]=C,e[38]=w):w=e[38];let T;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`add`,className:`size-4`}),e[39]=T):T=e[39];let E;e[40]===t?E=e[41]:(E=t(`settings.remoteInstances.clientAuth.actions.addDevice`),e[40]=t,e[41]=E);let D;e[42]!==d||e[43]!==E?(D=(0,$.jsx)(`div`,{className:`px-3 pb-3 pt-1`,children:(0,$.jsxs)(q,{variant:`secondary`,size:`sm`,className:`w-full justify-center gap-2 rounded-xl`,onClick:d,children:[T,E]})}),e[42]=d,e[43]=E,e[44]=D):D=e[44];let O;e[45]!==y||e[46]!==w||e[47]!==D?(O=(0,$.jsx)(Ke,{children:(0,$.jsx)(ze,{side:`top`,align:`start`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(qe,{className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[y,w,D]})})}),e[45]=y,e[46]=w,e[47]=D,e[48]=O):O=e[48];let k;return e[49]!==r||e[50]!==O||e[51]!==h?(k=(0,$.jsxs)(Pe,{open:r,onOpenChange:i,children:[h,O]}),e[49]=r,e[50]=O,e[51]=h,e[52]=k):k=e[52],k}function vb(e){let t=(0,Q.c)(11),{task:n}=e,r=n.total>0?Math.min(99,Math.floor(Math.max(0,n.completed)/n.total*100)):void 0,i=`inline-flex size-4 shrink-0 ${n.failed?`text-[var(--status-error)]`:``}`,a=`size-full -rotate-90 ${r===void 0&&!n.failed?`motion-safe:animate-spin`:``}`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:`1.5`}),t[0]=o):o=t[0];let s=100-(r??22),c;t[1]===s?c=t[2]:(c=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:s,className:`motion-safe:transition-[stroke-dashoffset] motion-safe:duration-300`}),t[1]=s,t[2]=c);let l;t[3]!==a||t[4]!==c?(l=(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,"aria-hidden":`true`,className:a,children:[o,c]}),t[3]=a,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==i||t[7]!==l||t[8]!==n.detail||t[9]!==r?(u=(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":n.detail,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:i,children:l}),t[6]=i,t[7]=l,t[8]=n.detail,t[9]=r,t[10]=u):u=t[10],u}function yb({task:e}){let{t,locale:n}=Pr(),[r,i]=Z.useState(!1),a=Z.useRef(!1),o=vt({mutationFn:async t=>{try{await(t===`dismiss`?e.dismiss?.():e.resume?.())}finally{a.current=!1}},onError:(t,n)=>{n===`resume`&&e.dismiss&&(!e.dismissOnError||t.message===e.dismissOnError)&&i(!0)},retry:!1}),s=e=>new Intl.NumberFormat(n).format(e),c=e=>new Intl.NumberFormat(n,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e/1e6),l=e.total>0?Math.min(100,Math.max(0,e.completed/e.total*100)):void 0;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-2 py-2.5`,"data-background-task":e.id,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:(0,$.jsx)(vb,{task:e})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e.label}),e.detail!==e.label&&(0,$.jsx)(`span`,{className:`break-words typography-micro text-muted-foreground`,children:e.detail})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.detail,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,className:`my-1.5 h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full ${e.failed?`bg-[var(--status-error)]`:`bg-[var(--primary-base)]`} ${l===void 0?e.failed?`w-1/3`:`w-1/3 motion-safe:animate-pulse`:`motion-safe:transition-[width] motion-safe:duration-300`}`,style:l===void 0?void 0:{width:`${l}%`}})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 typography-micro tabular-nums text-muted-foreground`,"data-background-task-meta":!0,children:[e.bytes?(0,$.jsx)(`span`,{children:t(e.total>0?`backgroundTasks.downloaded`:`backgroundTasks.downloadedUnknownTotal`,{completed:c(e.completed),total:c(e.total)})}):e.total>0&&!e.hideCounts&&(0,$.jsx)(`span`,{"aria-label":t(`backgroundTasks.processed`,{completed:s(e.completed),total:s(e.total)}),children:`${s(e.completed)} / ${s(e.total)}`}),!!e.failures&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:t(`backgroundTasks.failedCount`,{count:s(e.failures)})})]})]}),e.failed&&e.resume&&(0,$.jsx)(q,{size:`xs`,className:`shrink-0`,disabled:o.isPending,onClick:()=>{a.current||(a.current=!0,o.mutate(r?`dismiss`:`resume`))},children:t(r?o.isPending?`backgroundTasks.removing`:`backgroundTasks.dismiss`:o.isPending?`backgroundTasks.resuming`:`backgroundTasks.resume`)}),e.stale&&(0,$.jsx)(`p`,{className:`col-span-2 col-start-2 typography-micro text-muted-foreground`,children:t(`backgroundTasks.progressUnavailable`)}),o.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`col-span-2 col-start-2 typography-micro text-[var(--status-error)]`,children:t(o.variables===`dismiss`?`backgroundTasks.dismissFailed`:o.error.message===`update_plan_changed`?`backgroundTasks.updateChanged`:o.error.message===`resume_request_missing`?`backgroundTasks.originalSelectionMissing`:`backgroundTasks.resumeFailed`)})]})}var bb=Z.memo(function(e){let t=(0,Q.c)(4),{compactWithRestart:n}=e,r=n!==void 0&&n,i=Z.useSyncExternalStore(c,d,d),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=u(),t[0]=a):a=t[0];let o=`${a}:${i}`,s;return t[1]!==r||t[2]!==o?(s=(0,$.jsx)(xb,{compactWithRestart:r},o),t[1]=r,t[2]=o,t[3]=s):s=t[3],s});function xb(e){let t=(0,Q.c)(126),{compactWithRestart:n}=e,{t:r,locale:i}=Pr(),[a,o]=Z.useState(!1),s=Ol(zb),c=Ol(Rb),l=Ol(Lb),f=Ol(Ib),p=Ol(Fb),m=Ol(Pb),h=Ol(Nb),g=u(),_=d(),v=bt({...Jl(g),retry:!1,refetchInterval:jb}),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={...Wc(),retry:!1,refetchInterval:Ab},t[0]=y):y=t[0];let b=bt(y),S=Ml(g,_),C;t[1]===S?C=t[2]:(C={...S,refetchInterval:kb},t[1]=S,t[2]=C);let w=bt(C),T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[3]=T):T=t[3];let E=Z.useRef(T),D,O;t[4]!==_||t[5]!==v.data||t[6]!==v.isError||t[7]!==g?(D=()=>{if(!v.data||v.isError)return;let e=new Set(v.data.filter(Ob).map(Db)),t=[...E.current].some(t=>!e.has(t));E.current=e,t&&g===u()&&_===d()&&kn(g).catch(Eb)},O=[v.data,v.isError,g,_],t[4]=_,t[5]=v.data,t[6]=v.isError,t[7]=g,t[8]=D,t[9]=O):(D=t[8],O=t[9]),Z.useEffect(D,O);let k;if(t[10]!==m||t[11]!==l||t[12]!==h||t[13]!==f||t[14]!==c||t[15]!==s||t[16]!==_||t[17]!==b||t[18]!==v.data||t[19]!==v.isError||t[20]!==r||t[21]!==g||t[22]!==w||t[23]!==p){k=[];for(let e of v.data??[])if(!Gl(e)){let t=Yl(e);k.push({id:e.id,label:r(`backgroundTasks.import`),detail:r(e.state===`running`?`historyImport.phase.${t.phase}`:`historyImport.state.${e.state}`),...t,stale:v.isError,failed:e.state!==`running`,failures:e.failures,resume:()=>Kl(e.id,g,_),dismiss:()=>ql(e.id,g,_)})}if(b.data&&b.data.phase!==`ready`){let e;t[25]===r?e=t[26]:(e=r(`backgroundTasks.index`),t[25]=r,t[26]=e);let n;t[27]===b.data.phase?n=t[28]:(n=[`partial`,`error`].includes(b.data.phase)?`backgroundTasks.indexFailed`:`backgroundTasks.indexing`,t[27]=b.data.phase,t[28]=n);let i;t[29]!==r||t[30]!==n?(i=r(n),t[29]=r,t[30]=n,t[31]=i):i=t[31];let a=b.data.completed,o=b.data.total,s=b.isError,c;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`partial`,`error`],t[32]=c):c=t[32];let l=c.includes(b.data.phase),u;t[33]!==_||t[34]!==g?(u=()=>Cc(g,_),t[33]=_,t[34]=g,t[35]=u):u=t[35];let d;t[36]!==b.data.completed||t[37]!==b.data.failed||t[38]!==b.data.total||t[39]!==b.isError||t[40]!==l||t[41]!==u||t[42]!==e||t[43]!==i?(d={id:`content-index`,label:e,detail:i,completed:a,total:o,stale:s,failed:l,failures:b.data.failed,resume:u},t[36]=b.data.completed,t[37]=b.data.failed,t[38]=b.data.total,t[39]=b.isError,t[40]=l,t[41]=u,t[42]=e,t[43]=i,t[44]=d):d=t[44],k.push(d)}if(s||l){let e;t[45]===r?e=t[46]:(e=r(`backgroundTasks.download`),t[45]=r,t[46]=e);let n=l?`backgroundTasks.downloadFailed`:`updateDialog.status.downloading`,i;t[47]!==r||t[48]!==n?(i=r(n),t[47]=r,t[48]=n,t[49]=i):i=t[49];let a=!!l,o;t[50]!==m||t[51]!==h||t[52]!==a||t[53]!==e||t[54]!==i?(o={id:`client-update`,label:e,detail:i,completed:m,total:h,stale:!1,bytes:!0,failed:a,resume:Tb,dismiss:wb,dismissOnError:`update_plan_changed`},t[50]=m,t[51]=h,t[52]=a,t[53]=e,t[54]=i,t[55]=o):o=t[55],k.push(o)}let e=w.data?.operation,n=w.data,i=e?.status===`failed`&&!!n&&!n.checkError&&n.update!==void 0&&n.channel===e.channel&&(n.update?.version!==e.version||n.update.kind!==e.kind);if(e&&!i&&(jl(e)||e.status===`failed`)&&!((s||l||c&&jl(e))&&e.version===(f??p)&&x())){let n=e.id,i;t[56]===r?i=t[57]:(i=r(`backgroundTasks.download`),t[56]=r,t[57]=i);let a=e.status===`failed`?`backgroundTasks.downloadFailed`:e.status===`installing`?`updateDialog.status.installingUpdate`:e.status===`restarting`?`updateDialog.status.serverRestarting`:e.status===`checking`?`updateDialog.status.updating`:`updateDialog.status.downloading`,o;t[58]!==r||t[59]!==a?(o=r(a),t[58]=r,t[59]=a,t[60]=o):o=t[60];let s=`${o} · ${e.version}`,c=e.progress??0,l=e.progress==null?0:100,u=e.status===`failed`,d;t[61]!==_||t[62]!==e||t[63]!==g?(d=()=>Al(e,g,_),t[61]=_,t[62]=e,t[63]=g,t[64]=d):d=t[64];let f;t[65]!==e.id||t[66]!==s||t[67]!==c||t[68]!==l||t[69]!==u||t[70]!==d||t[71]!==i||t[72]!==w.isError?(f={id:n,label:i,detail:s,completed:c,total:l,stale:w.isError,hideCounts:!0,failed:u,resume:d},t[65]=e.id,t[66]=s,t[67]=c,t[68]=l,t[69]=u,t[70]=d,t[71]=i,t[72]=w.isError,t[73]=f):f=t[73],k.push(f)}t[10]=m,t[11]=l,t[12]=h,t[13]=f,t[14]=c,t[15]=s,t[16]=_,t[17]=b,t[18]=v.data,t[19]=v.isError,t[20]=r,t[21]=g,t[22]=w,t[23]=p,t[24]=k}else k=t[24];if(!k.length&&!a)return null;let A;t[74]===i?A=t[75]:(A=e=>new Intl.NumberFormat(i).format(e),t[74]=i,t[75]=A);let j=A,M=`w-fit min-w-0 shrink text-muted-foreground/60 ${k.length?``:`invisible`}`,N=k.length?``:void 0,P=n&&c&&k.length===1?`icon`:`xs`,F;t[76]===r?F=t[77]:(F=r(`backgroundTasks.title`),t[76]=r,t[77]=F);let I;t[78]!==n||t[79]!==c||t[80]!==r||t[81]!==k[0]||t[82]!==k.length?(I=n&&c?k.length===1?k[0].label:r(`backgroundTasks.title`):void 0,t[78]=n,t[79]=c,t[80]=r,t[81]=k[0],t[82]=k.length,t[83]=I):I=t[83];let L=`max-w-full gap-2 text-[10px] font-normal text-muted-foreground/60 ${n&&c&&k.length===1?`size-7 rounded-md`:``}`,R;t[84]!==P||t[85]!==F||t[86]!==I||t[87]!==L?(R=(0,$.jsx)(q,{variant:`ghost`,size:P,"aria-label":F,title:I,className:L}),t[84]=P,t[85]=F,t[86]=I,t[87]=L,t[88]=R):R=t[88];let z;t[89]===k?z=t[90]:(z=k.map(Cb),t[89]=k,t[90]=z);let ee;t[91]!==n||t[92]!==c||t[93]!==k[0]||t[94]!==k.length?(ee=k.length===1&&!(n&&c)&&(0,$.jsx)(`span`,{className:`truncate`,children:k[0].label}),t[91]=n,t[92]=c,t[93]=k[0],t[94]=k.length,t[95]=ee):ee=t[95];let B;t[96]!==R||t[97]!==z||t[98]!==ee?(B=(0,$.jsxs)(W,{render:R,children:[z,ee]}),t[96]=R,t[97]=z,t[98]=ee,t[99]=B):B=t[99];let V;t[100]!==B||t[101]!==M||t[102]!==N?(V=(0,$.jsx)(`div`,{className:M,"data-sidebar-background-tasks":N,children:B}),t[100]=B,t[101]=M,t[102]=N,t[103]=V):V=t[103];let te;t[104]===r?te=t[105]:(te=r(`backgroundTasks.title`),t[104]=r,t[105]=te);let ne;t[106]===te?ne=t[107]:(ne=(0,$.jsx)(Ge,{className:`typography-micro font-medium text-muted-foreground`,children:te}),t[106]=te,t[107]=ne);let re;t[108]!==j||t[109]!==k.length?(re=k.length>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:j(k.length)}),t[108]=j,t[109]=k.length,t[110]=re):re=t[110];let ie;t[111]!==ne||t[112]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-3`,children:[ne,re]}),t[111]=ne,t[112]=re,t[113]=ie):ie=t[113];let ae;t[114]!==r||t[115]!==k?(ae=k.length?k.map(Sb):(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:r(`backgroundTasks.empty`)}),t[114]=r,t[115]=k,t[116]=ae):ae=t[116];let H;t[117]===ae?H=t[118]:(H=(0,$.jsx)(`div`,{className:`max-h-64 divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] overflow-y-auto px-3 pb-1`,"data-background-task-details":!0,children:ae}),t[117]=ae,t[118]=H);let U;t[119]!==ie||t[120]!==H?(U=(0,$.jsx)(Ke,{children:(0,$.jsx)(ze,{side:`top`,align:`center`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(qe,{initialFocus:!1,className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[ie,H]})})}),t[119]=ie,t[120]=H,t[121]=U):U=t[121];let oe;return t[122]!==a||t[123]!==V||t[124]!==U?(oe=(0,$.jsxs)(Pe,{open:a,onOpenChange:o,children:[V,U]}),t[122]=a,t[123]=V,t[124]=U,t[125]=oe):oe=t[125],oe}function Sb(e){return(0,$.jsx)(yb,{task:e},e.id)}function Cb(e){return(0,$.jsx)(vb,{task:e},e.id)}async function wb(){return Ol.getState().discardInterruptedDownload()}async function Tb(){if(await Ol.getState().downloadUpdate({resume:!0}),Ol.getState().downloadError)throw Error(Ol.getState().downloadError)}function Eb(){}function Db(e){return e.id}function Ob(e){return e.state===`running`}function kb(e){return jl(e.state.data?.operation)?2e3:e.state.error?.message!==`host_update_unsupported`&&15e3}function Ab(e){return e.state.data===null?!1:e.state.data?.phase===`indexing`||e.state.data?.phase===`pending`?3e3:15e3}function jb(e){return e.state.error?.message===`history_import_unsupported`?!1:e.state.data?.some(Mb)?1e3:15e3}function Mb(e){return e.state===`running`}function Nb(e){return e.progress?.total??0}function Pb(e){return e.progress?.downloaded??0}function Fb(e){return e.info?.version}function Ib(e){return e.downloadVersion}function Lb(e){return e.downloadError}function Rb(e){return e.downloaded}function zb(e){return e.downloading}var Bb=`group size-7 rounded-md text-muted-foreground/75 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary`,Vb=`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`;function Hb(e){let t=(0,Q.c)(32),{onOpenUpdate:n,hideDownload:r}=e,{t:i}=Pr(),a=Ol(Jb),o=Ol(qb),s=Ol(Kb),c=Ol(Gb),l=Ol(Wb),u=Ol(Ub),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`update`,`restart-to-apply`],t[0]=d):d=t[0];let f;t[1]===l?f=t[2]:(f={mutationKey:d,mutationFn:()=>l(),retry:!1,networkMode:`always`},t[1]=l,t[2]=f);let p=vt(f),m=p.isPending,h=Z.useRef(!1),g;t[3]!==o||t[4]!==n||t[5]!==p||t[6]!==m?(g=()=>{if(o&&!m){if(h.current)return;h.current=!0,p.mutate();return}n()},t[3]=o,t[4]=n,t[5]=p,t[6]=m,t[7]=g):g=t[7];let _=G(g),v;t[8]!==o||t[9]!==a||t[10]!==s||t[11]!==m||t[12]!==i?(v=s||i(a?`updateDialog.status.downloading`:m?`updateDialog.status.updating`:o?`sessions.sidebar.footer.actions.restartUpdate`:`sessions.sidebar.footer.actions.update`),t[8]=o,t[9]=a,t[10]=s,t[11]=m,t[12]=i,t[13]=v):v=t[13];let y=v;if(r&&(a||c&&!o))return null;let b=m||void 0,x;t[14]!==o||t[15]!==a||t[16]!==u||t[17]!==m||t[18]!==y?(x=o?(0,$.jsx)(X,{name:`restart`,className:`${Vb} ${m?`motion-safe:animate-spin`:``}`}):a?(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:u===null?`size-4 animate-spin`:`size-4 -rotate-90`,role:`progressbar`,"aria-label":y,"aria-valuenow":u??void 0,"aria-valuemin":0,"aria-valuemax":100,children:[(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`2`}),(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,pathLength:`100`,strokeDasharray:`100`,strokeDashoffset:100-(u===null?25:Math.max(0,Math.min(100,u))),className:`transition-[stroke-dashoffset] duration-300`})]}):(0,$.jsx)(X,{name:`download`,className:Vb}),t[14]=o,t[15]=a,t[16]=u,t[17]=m,t[18]=y,t[19]=x):x=t[19];let S;t[20]!==_||t[21]!==m||t[22]!==b||t[23]!==x||t[24]!==y?(S=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`${Bb} disabled:opacity-100`,onClick:_,disabled:m,"aria-busy":b,"aria-label":y,children:x})}),t[20]=_,t[21]=m,t[22]=b,t[23]=x,t[24]=y,t[25]=S):S=t[25];let C=a&&u!==null?` ${u}%`:``,w;t[26]!==C||t[27]!==y?(w=(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:(0,$.jsxs)(`p`,{children:[y,C]})}),t[26]=C,t[27]=y,t[28]=w):w=t[28];let T;return t[29]!==S||t[30]!==w?(T=(0,$.jsxs)(ri,{children:[S,w]}),t[29]=S,t[30]=w,t[31]=T):T=t[31],T}function Ub(e){return e.progress?.total?Math.round(e.progress.downloaded/e.progress.total*100):null}function Wb(e){return e.restartToUpdate}function Gb(e){return e.downloadError}function Kb(e){return e.error}function qb(e){return e.downloaded}function Jb(e){return e.downloading}function Yb(e){let t=(0,Q.c)(19),{onOpenSettings:n,onOpenShortcuts:r,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:o}=e,s=a===void 0||a,c=o!==void 0&&o,{t:l}=Pr(),u;t[0]!==n||t[1]!==r||t[2]!==s||t[3]!==l?(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:Bb,onClick:n,"aria-label":l(`sessions.sidebar.footer.actions.settings`),children:(0,$.jsx)(X,{name:`settings-3`,className:Vb})})}),(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.settings`)})]}),(0,$.jsx)(_b,{}),(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:Bb,onClick:r,"aria-label":l(`sessions.sidebar.footer.actions.shortcuts`),children:(0,$.jsx)(X,{name:`question`,className:Vb})})}),(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.shortcuts`)})]})]}):null,t[0]=n,t[1]=r,t[2]=s,t[3]=l,t[4]=u):u=t[4];let d;t[5]!==i||t[6]!==s||t[7]!==c?(d=s?(0,$.jsx)(bb,{compactWithRestart:!!(c&&i)}):null,t[5]=i,t[6]=s,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==s||t[11]!==c?(f=c&&i?(0,$.jsx)(Hb,{onOpenUpdate:i,hideDownload:s}):null,t[9]=i,t[10]=s,t[11]=c,t[12]=f):f=t[12];let p;t[13]!==d||t[14]!==f?(p=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-start gap-1 px-2.5 py-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18],m}var Xb=1/3,Zb=1,Qb=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*Xb),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},$b=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,ex=e=>{let t=e.closest(`.overlay-scrollbar-target`);if(t)return t;let n=e.parentElement;for(;n&&n!==document.body;){let e=window.getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return n;n=n.parentElement}return null},tx=(e,t)=>{let n=ex(e),r=t?.behavior??$b();if(!n){e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:r});return}let i=e.getBoundingClientRect(),a=n.getBoundingClientRect().top+n.clientTop,o=a+n.clientHeight;if(i.top>=a&&i.bottom<=o)return;let s=Qb({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<Zb||n.scrollTo({top:s,behavior:r})},nx={activationConstraint:{distance:8}},rx={coordinateGetter:ws},ix=e=>{let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(ni,{delay:0,closeDelay:150,timeout:600,children:n}),t[0]=n,t[1]=r),r};function ax(e){let{t}=Pr(),n=new Map((e.remoteProjects??[]).map(e=>[e.id,e])),r=(e.remoteProjects??[]).map(e=>({project:{id:e.id,hostId:e.hostId,normalizedPath:e.path},groups:[]})),i=[...e.sectionsForRender,...r];if(e.projectOrderIds?.length){let t=new Map(e.projectOrderIds.map((e,t)=>[e,t]));i.sort((e,n)=>(t.get(e.project.id)??1/0)-(t.get(n.project.id)??1/0))}let a=t=>{let r=n.get(t);return r?e.hostRegistry?(0,$.jsx)(hl,{project:r,registry:e.hostRegistry,search:e.remoteSearch,mobile:e.mobileVariant,reorderEnabled:e.projectReorderEnabled,onNavigationTargets:e.onRemoteNavigationTargets,onActivityItems:e.onRemoteActivityItems},t):(0,$.jsx)(Gc,{project:r,loading:e.remoteCatalogLoading===!0,error:e.remoteCatalogError,mobile:e.mobileVariant,reorderEnabled:e.projectReorderEnabled},t):null},o=Cs(_s(xs,nx),_s(vs,rx)),s=e.hasSessionSearchQuery?null:(0,$.jsx)(ib,{title:t(`sessions.sidebar.projectsTitle`),titleSlot:e.headerSwitch,isFirst:!e.hasLeadingSection,accessory:e.headerAccessory}),c=Z.useRef(null),l=Z.useRef(null);Z.useLayoutEffect(()=>{let t=e.projectRevealTarget;if(!t){l.current=null;return}if(e.mobileVariant||e.showOnlyMainWorkspace||e.hasSessionSearchQuery)return;let n=l.current;if(n?.projectId===t.projectId&&n.revision===t.revision)return;let r=c.current?.querySelector(`[data-sidebar-project-header="${CSS.escape(t.projectId)}"]`);r&&(l.current=t,tx(r))},[e.projectRevealTarget,e.mobileVariant,e.showOnlyMainWorkspace,e.hasSessionSearchQuery,e.sectionsForRender]);let u=Z.useRef(new Map),d=Z.useRef(e.getOrderedGroups);d.current!==e.getOrderedGroups&&(d.current=e.getOrderedGroups,u.current.clear());let f=(t,n)=>{let r=u.current,i=r.get(t);if(i&&i.groups===n)return i.ordered;let a=e.getOrderedGroups(t,n);if(r.set(t,{groups:n,ordered:a}),r.size>256){let e=r.keys().next().value;e!==void 0&&r.delete(e)}return a};return e.sharedSessionsOnly?(0,$.jsx)(ix,{children:(0,$.jsxs)(Gr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,e.tabLeadingContent,e.hasSharedSessions?null:e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState]})}):e.taskContent?(0,$.jsxs)(ix,{children:[(0,$.jsxs)(Gr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,s,e.tabLeadingContent,e.taskContent]}),e.taskFooter]}):e.projectSections.length===0&&r.length===0?(0,$.jsx)(ix,{children:(0,$.jsxs)(Gr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,s,e.tabLeadingContent,e.emptyState]})}):i.length===0?(0,$.jsx)(ix,{children:(0,$.jsx)(Gr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:e.searchEmptyState})}):(0,$.jsx)(ix,{children:(0,$.jsxs)(Gr,{ref:c,useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,e.showOnlyMainWorkspace?(0,$.jsx)(`div`,{className:`space-y-[0.6rem] py-1`,children:(()=>{let r=i.find(t=>t.project.id===e.activeProjectId)??i[0];if(!r)return e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState;if(n.has(r.project.id))return a(r.project.id);let o=r.groups.find(e=>e.isMain&&e.sessions.length>0)??r.groups.find(e=>e.sessions.length>0)??r.groups.find(e=>e.isMain)??r.groups[0];if(!o)return(0,$.jsx)(`div`,{className:Eo,children:t(`sessions.sidebar.empty.noSessions.title`)});let s=r.groups.find(e=>e.isArchivedBucket);return[o,...s&&s.id!==o.id?[s]:[]].map(t=>{let n=`${r.project.id}:${t.id}`,i=t.id===o.id;return(0,$.jsx)(Z.Fragment,{children:e.renderGroupSessions(t,n,r.project.id,i,null,!0,c)},n)})})()}):(0,$.jsxs)($.Fragment,{children:[s,e.tabLeadingContent,(0,$.jsxs)(Ss,{sensors:o,collisionDetection:ys,onDragEnd:t=>{if(e.isInlineEditing||e.projectSortOrder!==`manual`)return;let{active:n,over:r}=t;!r||n.id===r.id||e.reorderProjects(String(n.id),String(r.id))},children:[(0,$.jsx)(Ds,{items:i.map(e=>e.project.id),strategy:Es,children:i.map(t=>{let r=t.project,i=r.id;return n.has(i)?a(i):(0,$.jsx)(ox,{project:r,orderedGroups:f(i,t.groups),isCollapsed:e.collapsedProjects.has(i),isActiveProject:i===e.activeProjectId,isRepo:!!e.projectRepoStatus.get(i),hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,toggleProject:e.toggleProject,setActiveProjectIdOnly:e.setActiveProjectIdOnly,setActiveMainTab:e.setActiveMainTab,setSessionSwitcherOpen:e.setSessionSwitcherOpen,openNewSessionDraft:e.openNewSessionDraft,openNewWorktreeDialog:e.openNewWorktreeDialog,syncProjectSessions:e.syncProjectSessions,openProjectEditDialog:e.openProjectEditDialog,removeProject:e.removeProject,openSidebarMenuKey:e.openSidebarMenuKey===`project:${i}`?e.openSidebarMenuKey:null,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,projectReorderEnabled:e.projectReorderEnabled,projectSortOrder:e.projectSortOrder,isInlineEditing:e.isInlineEditing,setGroupOrderByProject:e.setGroupOrderByProject,renderGroupSessions:e.renderGroupSessions,scrollContainerRef:c,homeDirectory:e.homeDirectory,hostRegistry:e.hostRegistry},i)})}),(0,$.jsx)(bs,{dropAnimation:null})]})]})]})})}var ox=Z.memo(function(e){let t=(0,Q.c)(111),{t:n}=Pr(),{project:r,orderedGroups:i,isCollapsed:a,renderGroupSessions:o,scrollContainerRef:s,isInlineEditing:c}=e,l=r.id,u;t[0]===r.normalizedPath?u=t[1]:(u=e=>ae()?void 0:e.availableWorktreesByProject.get(r.normalizedPath),t[0]=r.normalizedPath,t[1]=u);let d=Jn(u),f;t[2]!==r.normalizedPath||t[3]!==d?(f=[r.normalizedPath,...(d??[]).flatMap(sx)],t[2]=r.normalizedPath,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]===p?m=t[6]:(m=e=>p.some(t=>e.loadingDirectories.has(t)),t[5]=p,t[6]=m);let h=hn(m),g;t[7]===p?g=t[8]:(g=e=>p.some(t=>e.refreshingDirectories.has(t)),t[7]=p,t[8]=g);let _=hn(g),v=Cs(_s(xs,nx)),y;t[9]===i?y=t[10]:(y=i.find(cx)??null,t[9]=i,t[10]=y);let b=y,x;t[11]!==i||t[12]!==b?(x=b?i.filter(e=>e.id!==b.id):i,t[11]=i,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]!==l||t[15]!==e?(C=()=>e.toggleProject(l),t[14]=l,t[15]=e,t[16]=C):C=t[16];let w=G(C),T;t[17]!==r.normalizedPath||t[18]!==l||t[19]!==e?(T=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.mobileVariant&&e.setSessionSwitcherOpen(!1),e.openNewSessionDraft({directoryOverride:r.normalizedPath})},t[17]=r.normalizedPath,t[18]=l,t[19]=e,t[20]=T):T=t[20];let E=G(T),D;t[21]!==l||t[22]!==e?(D=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.openNewWorktreeDialog()},t[21]=l,t[22]=e,t[23]=D):D=t[23];let O=G(D),k;t[24]!==l||t[25]!==e?(k=()=>e.syncProjectSessions(l),t[24]=l,t[25]=e,t[26]=k):k=t[26];let A=G(k),j;t[27]!==l||t[28]!==e?(j=()=>e.openProjectEditDialog(l),t[27]=l,t[28]=e,t[29]=j):j=t[29];let M=G(j),N;t[30]!==l||t[31]!==e?(N=()=>e.removeProject(l),t[30]=l,t[31]=e,t[32]=N):N=t[32];let P=G(N),F;t[33]!==c||t[34]!==S||t[35]!==r.normalizedPath||t[36]!==l||t[37]!==e||t[38]!==b?(F=t=>{if(c)return;let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=S.findIndex(e=>e.id===n.id),o=S.findIndex(e=>e.id===i.id);if(a===-1||o===-1||a===o)return;let s=Ts(S,a,o).map(lx),u=b?[b.id,...s]:s,d=new Map(S.map(ux));Mn.getState().setWorktreeOrder(l,r.normalizedPath,s.flatMap(e=>{let t=d.get(e);return t?.worktree&&t.directory?[t.directory]:[]})),e.setGroupOrderByProject(e=>new Map(e).set(l,u))},t[33]=c,t[34]=S,t[35]=r.normalizedPath,t[36]=l,t[37]=e,t[38]=b,t[39]=F):F=t[39];let I=G(F),L;t[40]!==l||t[41]!==o||t[42]!==b||t[43]!==s?(L=b?o(b,`${l}:${b.id}`,l,!0,null,void 0,s):null,t[40]=l,t[41]=o,t[42]=b,t[43]=s,t[44]=L):L=t[44];let R;t[45]===S?R=t[46]:(R=S.map(dx),t[45]=S,t[46]=R);let z;if(t[47]!==c||t[48]!==S||t[49]!==l||t[50]!==o||t[51]!==s){let e;t[53]!==c||t[54]!==l||t[55]!==o||t[56]!==s?(e=e=>(0,$.jsx)(fl,{id:e.id,disabled:c,children:t=>o(e,`${l}:${e.id}`,l,!1,t,void 0,s)},e.id),t[53]=c,t[54]=l,t[55]=o,t[56]=s,t[57]=e):e=t[57],z=S.map(e),t[47]=c,t[48]=S,t[49]=l,t[50]=o,t[51]=s,t[52]=z}else z=t[52];let ee;t[58]!==R||t[59]!==z?(ee=(0,$.jsx)(Ds,{items:R,strategy:Es,children:z}),t[58]=R,t[59]=z,t[60]=ee):ee=t[60];let B;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(bs,{dropAnimation:null}),t[61]=B):B=t[61];let V;t[62]!==v||t[63]!==I||t[64]!==L||t[65]!==ee?(V=(0,$.jsxs)(Ss,{sensors:v,collisionDetection:ys,onDragEnd:I,children:[L,ee,B]}),t[62]=v,t[63]=I,t[64]=L,t[65]=ee,t[66]=V):V=t[66];let te=V,ne=e.projectSortOrder!==`manual`,re=r.hostId,ie=r.remoteState,H=e.hostRegistry,U;t[67]===r.normalizedPath?U=t[68]:(U=Ln(r.normalizedPath)||r.normalizedPath,t[67]=r.normalizedPath,t[68]=U);let oe;t[69]!==r.normalizedPath||t[70]!==e.homeDirectory?(oe=cr(r.normalizedPath,e.homeDirectory),t[69]=r.normalizedPath,t[70]=e.homeDirectory,t[71]=oe):oe=t[71];let se=h||_,ce=e.projectReorderEnabled??!1,le=!a,ue=a||void 0,de;t[72]!==te||t[73]!==h||t[74]!==i.length||t[75]!==n?(de=(0,$.jsx)(`div`,{className:`space-y-0 pt-0 pb-0.5`,children:i.length>0?te:h?(0,$.jsx)(`div`,{className:`box-border w-full py-1.5 text-left typography-ui-label font-normal text-muted-foreground/80 animate-pulse select-none`,style:{paddingLeft:_o(1)},role:`status`,"aria-live":`polite`,children:n(`sessions.sidebar.project.loadingSessions`)}):(0,$.jsx)(`div`,{className:Eo,children:n(`sessions.sidebar.empty.noSessions.title`)})}),t[72]=te,t[73]=h,t[74]=i.length,t[75]=n,t[76]=de):de=t[76];let fe;t[77]!==ue||t[78]!==de?(fe=(0,$.jsx)(Ai,{"data-sidebar-collapse":!0,className:`h-[var(--collapsible-panel-height)] transition-[height] duration-200 ease-out data-[starting-style]:h-0 data-[ending-style]:h-0 data-[open]:animate-none data-[closed]:animate-none motion-reduce:transition-none`,inert:ue,children:de}),t[77]=ue,t[78]=de,t[79]=fe):fe=t[79];let pe;t[80]!==le||t[81]!==fe?(pe=(0,$.jsx)(Mi,{open:le,children:fe}),t[80]=le,t[81]=fe,t[82]=pe):pe=t[82];let me;return t[83]!==a||t[84]!==P||t[85]!==E||t[86]!==O||t[87]!==M||t[88]!==A||t[89]!==w||t[90]!==r.color||t[91]!==r.hostId||t[92]!==r.icon||t[93]!==r.iconImage||t[94]!==r.remoteState||t[95]!==l||t[96]!==e.alwaysShowActions||t[97]!==e.hideDirectoryControls||t[98]!==e.hostRegistry||t[99]!==e.isActiveProject||t[100]!==e.isRepo||t[101]!==e.mobileVariant||t[102]!==e.openSidebarMenuKey||t[103]!==e.setOpenSidebarMenuKey||t[104]!==ne||t[105]!==U||t[106]!==oe||t[107]!==se||t[108]!==ce||t[109]!==pe?(me=(0,$.jsx)(Ec,{id:l,disabled:ne,hostId:re,remoteState:ie,hostRegistry:H,projectLabel:U,projectDescription:oe,projectIcon:r.icon,projectColor:r.color,projectIconImage:r.iconImage,isCollapsed:a,isActiveProject:e.isActiveProject,isSessionsLoading:se,isRepo:e.isRepo,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,onToggle:w,onNewSession:E,onNewWorktreeSession:O,onSyncSessions:A,onRenameStart:M,onClose:P,showCreateButtons:!0,openSidebarMenuKey:e.openSidebarMenuKey,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,reorderEnabled:ce,children:pe}),t[83]=a,t[84]=P,t[85]=E,t[86]=O,t[87]=M,t[88]=A,t[89]=w,t[90]=r.color,t[91]=r.hostId,t[92]=r.icon,t[93]=r.iconImage,t[94]=r.remoteState,t[95]=l,t[96]=e.alwaysShowActions,t[97]=e.hideDirectoryControls,t[98]=e.hostRegistry,t[99]=e.isActiveProject,t[100]=e.isRepo,t[101]=e.mobileVariant,t[102]=e.openSidebarMenuKey,t[103]=e.setOpenSidebarMenuKey,t[104]=ne,t[105]=U,t[106]=oe,t[107]=se,t[108]=ce,t[109]=pe,t[110]=me):me=t[110],me});function sx(e){let t=pt(e.path);return t?[t]:[]}function cx(e){return e.isMain}function lx(e){return e.id}function ux(e){return[e.id,e]}function dx(e){return e.id}function fx(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.toLocaleString(Mr(),{month:`short`})} ${t.getDate()}, ${t.getFullYear()}, ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function px(e){if(e.info.role===`user`)return``;let t=typeof e.info.providerID==`string`?e.info.providerID.trim():``,n=typeof e.info.modelID==`string`?e.info.modelID.trim():``;return t&&n?`${t}/${n}`:n||t}function mx(e){let t=e.info.role===`user`?`User`:`Assistant`,n=fx(e.info.time?.created),r=px(e),i=n&&r?`${n} (${r})`:n||r;return i?`**${t}**\n\n*${i}*`:`**${t}**`}function hx(e){return e.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``)}function gx(e){let t=mx(e),n=hx(e.parts).trim();return n?`${t}\n\n${n}`:``}function _x(e,t){let n=`#`.repeat(Math.min(t+1,6)),r=e.agent?` — ${e.agent}`:``,i=[`${n} Sub-agent: ${e.title}${r}\n\n---\n\n`+e.records.map(gx).filter(Boolean).join(`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
`)];for(let n of e.children)i.push(_x(n,t+1));return i.join(`
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
`)}function vx(e,t,n){let r=`# ${t?.trim()||`Session`}\n\n*Exported on ${new Date().toISOString().split(`T`)[0]}*\n\n---\n\n`+e.map(gx).filter(Boolean).join(`
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
`);if(n&&n.length>0){let e=n.map(e=>_x(e,1)).join(`
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
`);r+=`
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
`+e}return r}function yx(e,t){let n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function bx(e,t){let n=await I(t,e);if(n)return n;if(!ae())return null;try{let n=await U()?.vscode?.saveMarkdown?.({fileName:t,content:e});if(!n||n.saved!==!0)return null;let r=typeof n.path==`string`?n.path.trim():``;return r.length>0?r:null}catch{return null}}async function xx(e){let t=U()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await _(e)?!0:S(e)}function Sx(){return Un()}function Cx(e){return`${(e?.trim()||`session`).normalize(`NFKC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`session`}-${new Date().toISOString().split(`T`)[0]}.md`}function wx(e){let t=(0,Q.c)(35),{session:n,title:r,projectLabel:i,project:a,branch:o,directory:s,time:c}=e,{t:l}=Pr(),d;t[0]===s?d=t[1]:(d=e=>s?e.directories.get(s)?.status?.current:void 0,t[0]=s,t[1]=d);let f=$i(d),m;t[2]!==s||t[3]!==n.model?(m=e=>{let t=n.model;return t?e.directoryScoped[An(s)]?.providers.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.id)?.name??t.id:null},t[2]=s,t[3]=n.model,t[4]=m):m=t[4];let g=Nn(m),_;if(t[5]!==l){let e=Et.getQueryData([`desktop-host-inventory`,u()]),n=p(),r=h(),i=n.startsWith(`host:`)?n.slice(5):null,a=e?.hosts.find(e=>i?e.id===i:!!(r&&fe(r,de(e))));_=a?he(a.label):x()?l(`desktopHostSwitcher.instance.local`):null,t[5]=l,t[6]=_}else _=t[6];let v=_,y=!!(o&&f&&f!==`HEAD`&&f!==o),b;t[7]===r?b=t[8]:(b=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:r}),t[7]=r,t[8]=b);let S;t[9]===c?S=t[10]:(S=(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:c}),t[9]=c,t[10]=S);let C;t[11]!==b||t[12]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,S]}),t[11]=b,t[12]=S,t[13]=C):C=t[13];let w;t[14]!==a||t[15]!==i?(w=i?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(vl,{project:a}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:i})]}):null,t[14]=a,t[15]=i,t[16]=w):w=t[16];let T;t[17]===v?T=t[18]:(T=v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:v})]}):null,t[17]=v,t[18]=T);let E;t[19]===o?E=t[20]:(E=o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:o})]}):null,t[19]=o,t[20]=E);let D;t[21]!==f||t[22]!==y||t[23]!==l?(D=y?(0,$.jsxs)(`div`,{className:`flex items-start gap-2 typography-meta text-status-warning`,children:[(0,$.jsx)(X,{name:`error-warning`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:l(`sessions.sidebar.session.hover.differentBranch`,{branch:f??``})})]}):null,t[21]=f,t[22]=y,t[23]=l,t[24]=D):D=t[24];let O;t[25]===g?O=t[26]:(O=g?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`ai-agent`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:g})]}):null,t[25]=g,t[26]=O);let k;return t[27]!==n.id||t[28]!==D||t[29]!==O||t[30]!==C||t[31]!==w||t[32]!==T||t[33]!==E?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 text-left`,"data-session-hover-details":n.id,children:[C,w,T,E,D,O]}),t[27]=n.id,t[28]=D,t[29]=O,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=k):k=t[34],k}var Tx=(e,t)=>{if(!t)return Array.from(e);let n=[],r=new Set;for(let i of e){r.has(i)||(r.add(i),n.push(i));let e=t.get(i);if(e)for(let t of e)r.has(t)||(r.add(t),n.push(t))}return n},Ex=ke()((e,t)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{t().enabled||e({enabled:!0})},disable:()=>{e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{t().enabled?e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):e({enabled:!0})},toggleSelected:(n,r,i)=>{let a=t(),o=new Set(a.selectedIds),s=a.scopeKey,c=a.anchorId;r!==null&&a.scopeKey!==null&&r!==a.scopeKey?(o.clear(),s=r,c=null):s===null&&r!==null&&(s=r);let l=i&&i.length>0?[n,...i]:[n];if(o.has(n)){for(let e of l)o.delete(e);c===n&&(c=null)}else{for(let e of l)o.add(e);c=n}o.size===0?e({selectedIds:o,scopeKey:null,anchorId:null}):e({selectedIds:o,scopeKey:s,anchorId:c})},setRange:(n,r,i,a,o)=>{let s=t();if(i.length===0)return;let c=n&&i.includes(n)?n:i[0],l=i.indexOf(c),u=i.indexOf(r);if(l<0||u<0)return;let[d,f]=l<=u?[l,u]:[u,l],p=Tx(i.slice(d,f+1),o),m=a!==null&&s.scopeKey!==null&&a!==s.scopeKey?new Set:new Set(s.selectedIds);for(let e of p)m.add(e);e({selectedIds:m,scopeKey:a??s.scopeKey,anchorId:c})},replaceAll:(t,n)=>{if(t.length===0){e({selectedIds:new Set,scopeKey:null,anchorId:null});return}e({selectedIds:new Set(t),scopeKey:n,anchorId:t[0]??null})},clear:()=>{e({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{let r=t();if(r.selectedIds.size===0||n.length===0)return;let i=new Set(r.selectedIds);for(let e of n)i.delete(e);i.size!==r.selectedIds.size&&(i.size===0?e({selectedIds:i,scopeKey:null,anchorId:null}):e({selectedIds:i}))}})),Dx=!1,Ox=new Set,kx=!1;function Ax(){for(let e of Ox)e()}function jx(e){Dx!==e&&(Dx=e,Ax())}function Mx(e){e.key===`Shift`&&jx(!0)}function Nx(e){e.key===`Shift`&&jx(!1)}function Px(){jx(!1)}function Fx(){kx||typeof window>`u`||(kx=!0,window.addEventListener(`keydown`,Mx),window.addEventListener(`keyup`,Nx),window.addEventListener(`blur`,Px))}function Ix(e){return Fx(),Ox.add(e),()=>{Ox.delete(e)}}function Lx(){return Dx}function Rx(){return!1}function zx(){return(0,Z.useSyncExternalStore)(Ix,Lx,Rx)}var Bx=!1,Vx=!1,Hx=new Set;function Ux(){Hx.forEach(e=>e())}function Wx(e){Bx!==e&&(Bx=e,Ux())}function Gx(e){return vr()?e.key===`Meta`:e.key===`Control`}var Kx=(({setVisible:e,schedule:t=(e,t)=>setTimeout(e,t),cancel:n=e=>clearTimeout(e)})=>{let r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{press(){r||(r=!0,a(),i=t(()=>{i=null,r&&e(!0)},500))},release(){r=!1,a(),e(!1)}}})({setVisible:Wx});function qx(e){Gx(e)&&Kx.press()}function Jx(){Kx.release()}function Yx(e){Gx(e)&&Jx()}function Xx(){document.visibilityState!==`visible`&&Jx()}function Zx(){Vx||typeof window>`u`||(Vx=!0,window.addEventListener(`keydown`,qx),window.addEventListener(`keyup`,Yx),window.addEventListener(`blur`,Jx),document.addEventListener(`visibilitychange`,Xx))}function Qx(e){return Zx(),Hx.add(e),()=>Hx.delete(e)}function $x(){return Bx}function eS(){return!1}function tS(){return(0,Z.useSyncExternalStore)(Qx,$x,eS)}var nS=(e,t,n)=>{let r=e.session.title?.trim()||e.session.id;return`\n\n--- RESULT ${n+1}: ${r} ---\n${t.trim()}\n--- END RESULT ${n+1} ---`},rS=(e,t)=>Jn.getState().getWorktreeMetadata(e)?.projectDirectory??t,iS=e=>e.type===`assistant`?Qo(e.content??[]).trim():``,aS=async e=>{let t=e.directory??void 0,n=xe(e.session.id,t);if(n.length===0&&e.directory){let t=await Se.withDirectory(e.directory,()=>Se.getSdkClient().message.list({sessionID:e.session.id,limit:50})),n=Array.isArray(t.data)?t.data:[];for(let e=n.length-1;e>=0;--e){let t=iS(n[e]);if(t)return t}return``}for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.role===`assistant`)return Qo(be(r.id,t)).trim()}return``};function oS({session:e,open:t,onOpenChange:n}){let{t:r}=Pr(),i=bn(),a=hn(e=>e.activeSessions),o=hn(e=>e.archivedSessions),s=Nn(e=>e.providers),c=Nn(e=>e.currentProviderId),l=Nn(e=>e.currentModelId),u=Nn(e=>e.currentAgentName),[d,f]=Z.useState(c??``),[p,m]=Z.useState(l??``),[h,g]=Z.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:tu()}]:[]),[_,v]=Z.useState(``),[y,b]=Z.useState(u??``),[x,S]=Z.useState([]),[C,w]=Z.useState(!1),T=Z.useMemo(()=>ru(e.title),[e.title]),E=Z.useMemo(()=>{let t=new Map;for(let e of i)t.set(e.id,e);for(let e of a)t.set(e.id,e);for(let e of o)t.set(e.id,e);return e.id&&t.set(e.id,e),Array.from(t.values())},[a,o,i,e]);Z.useEffect(()=>{if(!t||!T)return;let n=Jn.getState().getDirectoryForSession(e.id),r=rS(e.id,n),i=E.map(e=>{let t=ru(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=Jn.getState().getDirectoryForSession(e.id)??vn(e),i=rS(e.id,n);return r&&i&&r!==i?null:{session:e,directory:n,projectDirectory:i}}).filter(e=>e!==null).sort((e,t)=>(e.session.time?.created??0)-(t.session.time?.created??0));S(i)},[E,t,T,e.id]);let D=s.find(e=>e.id===d)?.models.find(e=>e.id===p),O=D?.variants?Object.keys(D.variants):[],k=!!(T&&d&&p&&x.length>0&&!C),A=Z.useCallback(e=>{g([e]),f(e.providerID),m(e.modelID),v(``)},[]),j=h[0]?.displayName||h[0]?.modelID||r(`multirun.fusion.model.placeholder`);return(0,$.jsx)($r,{open:t,onOpenChange:n,children:(0,$.jsxs)(Xr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Zr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(Qr,{children:r(`multirun.fusion.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`max-w-full`,children:(0,$.jsx)(iu,{selectedModels:h,onAdd:A,onUpdate:(e,t)=>A(t),onRemove:()=>{g([]),f(``),m(``),v(``)},maxModels:1,addButtonLabel:j,showChips:!1,addButtonClassName:`h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`,dropdownSide:`bottom`,dropdownClassName:`w-[min(28rem,calc(100vw-8rem))]`,triggerIcon:d||p?(0,$.jsx)(Ho,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(Fs,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(Ps,{size:`lg`,className:`h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5`,children:[(0,$.jsx)(X,{name:`brain-ai-3`,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(js,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(Ns,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(Ms,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(Ms,{value:e,children:e},e))]})]}):null,(0,$.jsx)(nu,{value:y,onChange:b,portalToBody:!0,className:`h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-foreground`,children:r(`multirun.fusion.sources.label`,{count:x.length})}),(0,$.jsx)(`div`,{className:`max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1`,children:x.map(e=>{let t=ru(e.session.title);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta`,children:[(0,$.jsx)(Ho,{modelId:t?.modelID,providerId:t?.providerID,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.session.title||e.session.id}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(t=>t.filter(t=>t.session.id!==e.session.id)),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},e.session.id)})})]}),(0,$.jsxs)(Yr,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>n(!1),children:r(`multirun.fusion.actions.cancel`)}),(0,$.jsx)(q,{onClick:async()=>{if(!(!T||!d||!p)){w(!0);try{let e=await Promise.all(x.map(e=>aS(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){Y.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=eu(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([Ji(`session.fusion.visible`),Ji(`session.fusion.instructions`)]),c=await Jn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);Jn.getState().setCurrentSession(c.id,i),n(!1),await Se.sendMessage({id:c.id,providerID:d,modelID:p,variant:_||void 0,agent:y||void 0,text:o,additionalParts:[{text:s,synthetic:!0},...t.map((e,t)=>({text:nS(e.source,e.text,t),synthetic:!0})),{text:`
|
|
167
|
+
|
|
168
|
+
--- FUSION INPUTS END ---
|
|
169
|
+
Now write the final fused answer.`,synthetic:!0}],directory:i??Se.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),Y.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function sS(e){let t=(0,Q.c)(13),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:Er,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var cS=e(Be(),1),lS=null,uS=!1,dS=(e,t=fo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:eo(e):e,fS=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},pS=()=>{lS&&=(fS(lS),null)},mS=(e,t)=>{pS(),ur(!0);let n=dS(e);if(!n)return;uS=!0;let r;try{r=Vt(n.sessionId)}finally{uS=!1}lS={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,cS.flushSync)(()=>{fo.getState().setFocus(n)}),typeof window<`u`&&(lS.fallbackTimer=window.setTimeout(()=>{hS(n)},150))},hS=e=>{let t=lS,n=dS(e);if(!t||!Ja(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{lS===t&&Bt()===t.intent&&(lS=null,Zn(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{lS===t&&Bt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},gS=e=>{if(lS)return;let t=fo.getState();t.setFocus(dS(e,t.focus))};Ht(e=>{if(uS)return;let t=lS;if(t?.intent===e)return;t&&pS();let n=fo.getState();n.setFocus(dS(e.sessionId,n.focus))});var _S=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},vS=Z.memo(function(e){let t=(0,Q.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=J(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=J(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(X,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:jS,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(ti,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ri,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),yS=Z.memo(function(e){let t=(0,Q.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=zx(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=J(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(X,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:MS,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)(ti,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ri,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),bS=Z.memo(function(e){let t=(0,Q.c)(3),{number:n}=e;if(!tS())return null;let r=vr()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(zi,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function xS(e){let{t}=Pr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:w,handleUnshareSession:T,setOpenSidebarMenuKey:E,renamingFolderId:D,getFoldersForScope:O,getSessionFolderId:k,removeSessionFromFolder:A,addSessionToFolder:j,createFolderAndStartRename:M,handleDeleteSession:N,mobileVariant:P,alwaysShowActions:F,renderSessionNode:I,secondaryMeta:R,renderContext:z=`project`,subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,childRenderExtrasFor:ne,liveSessionById:re,shortcutNumber:ie=null,settledSessionIds:H,setSessionSettled:U}=e,oe=!!R?.projectLabel,se=!!R?.branchLabel,ce=Dn(e=>e.displayMode),le=Z.useMemo(()=>ae(),[]),ue=ce===`minimal`||le,de=Z.useMemo(()=>L(),[]),fe=Z.useContext(Mt),pe=le?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,he=le,_e=z===`pinned`&&c.has(r.session.id),ve=!_e&&!s&&!P&&!R?.slim,ye=`h-5 w-5`,be=`h-3.5 w-3.5`,xe=(ve||_e?1:0)+ +!!he+1,Se=xe>=3?`group-hover:pr-18 group-focus-within:pr-18`:xe>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,we=F?le?Se:xe>=2?`pr-12`:`pr-8`:Se,Ee=Z.useRef(!1),De=Z.useRef(!1),[Oe,ke]=Z.useState(!1),Ae=Z.useRef(f);Ae.current=f;let je=Z.useRef(null),[Pe,W]=Z.useState(m),[ze,Be]=Z.useState(f===r.session.id),Ue=Z.useRef(null),We=Z.useRef(null),Ge=Z.useRef(null),Ke=r.session,qe=re.get(Ke.id)??Ke,Ye=!!qe.metadata?.yuri?.assistant,Xe=pt(Ke.directory??null)??pt(a??null),Ze=wn(Xe??void 0,{bootstrap:!1}),Qe=ms(),$e=Ex(e=>e.enabled),et=Ex(Z.useMemo(()=>e=>e.selectedIds.has(Ke.id),[Ke.id])),tt=Ex(e=>e.toggleSelected),nt=Ex(e=>e.setRange),[rt,it]=Z.useState(!1),[at,ot]=Z.useState(!0),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState(!1),dt=`${z}:${s?`archived`:`active`}:${Ke.id}`,ft=Sr(Z.useMemo(()=>e=>!!e.sessionMemoryState.get(xn(Ke.id))?.isZombie,[Ke.id])),mt=gr(Ke.id),ht=ir(Ke.id,Xe??void 0,{bootstrap:!1}),gt=Qn(Ke.id,Xe??void 0,{bootstrap:!1}),_t=Z.useMemo(()=>({scope:z,sessionId:Ke.id,projectId:o??null}),[o,z,Ke.id]),vt=Z.useMemo(()=>$a(_t)??``,[_t]),yt=Z.useRef(null),bt=fo(Z.useMemo(()=>e=>Ja(e.focus,_t),[_t]));Z.useLayoutEffect(()=>{if(!bt)return;let e=yt.current;e&&(P?e.scrollIntoView({block:`nearest`,inline:`nearest`}):tx(e)),hS(_t)},[bt,P,_t]);let xt=qe.title||t(`sessions.sidebar.session.untitled`),St=cc(sc(qe)),Ct=qe.metadata?.yuri?.titleRefresh,wt=typeof Ct?.lastError==`string`?Ct.lastError:null,Tt=typeof Ct?.failedAt==`number`?Ct.failedAt:null;Z.useEffect(()=>{!wt||Tt===null||console.warn(`[session-title] generation failed for ${Ke.id}: ${wt}`)},[Ke.id,wt,Tt]);let Et=typeof Ct?.generationExpiresAt==`number`&&Number.isFinite(Ct.generationExpiresAt)?Ct.generationExpiresAt:0,[Dt,Ot]=Z.useState(0),kt=Z.useMemo(()=>Math.max(0,Et-Date.now()),[Et]),[,At,jt]=Ft(()=>Ot(Et),kt,{immediate:!1}),Nt=Ct?.isGenerating===!0;Z.useEffect(()=>(Nt&&Et>Date.now()&&At(),jt),[Nt,Et,At,jt]);let Pt=r.children.length>0||!!(qe.hasChildren??Ke.hasChildren),It=c.has(Ke.id),Lt=!!H?.has(Ke.id),Rt=dt,zt=u?!0:l.has(Rt),Bt=!!qe.parentID,Vt=z===`pinned`,Ht=gn(Ke.id),K=Ht>0&&!Bt,Ut=jn(qe)||Date.now(),Wt=Ao(Ut),Gt=Co(Ut),[Kt,qt]=Z.useState(!1),[Jt,Yt]=Z.useState(!1),Xt=Kt,Zt=Z.useMemo(()=>ru(qe.title)!==null,[qe.title]),[Qt,en]=Z.useState(!1),tn=Z.useMemo(()=>_S(r).length,[r]),nn=G(e=>{let t=Xe??``,n=(ge()??Te(t,Ze)).getTranscript(Ce(t,e)),r=Ze.getState().session.find(t=>t.id===e)?.revert?.messageID;return $t({sessionID:e,messages:me(n),parts:n.partsByMessageID,revertMessageID:r}).list}),rn=G(async e=>{let n=[],r=0;for(let i of e)try{await Qe.ensureSessionRenderable(i.session.id);let e=nn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await rn(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=_S(i).length+1}return{children:n,skipped:r}}),an=G(e=>{e<=0||Y.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),on=G(async e=>{if(!Xe){Y.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await Qe.ensureSessionRenderable(Ke.id);let n=nn(Ke.id);if(n.length===0){Y.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await rn(r.children);i=e.children,a=e.skipped}let o=vx(n,qe.title??null,i),s=Cx(qe.title??null),c=await bx(o,s);if(c){Y.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Sx()),onClick:()=>{xx(c).then(e=>{e||Y.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),an(a);return}yx(o,s),Y.success(t(`sessions.sidebar.session.export.success`)),an(a)}),sn=G(async()=>{if(r.children.length>0){ot(!0),it(!0);return}await on(!1)}),cn=G(()=>{Xe&&ee(`desktop_open_session_mini_chat_window`,{sessionId:Ke.id,directory:Xe,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Z.useLayoutEffect(()=>{if(f!==Ke.id){ze&&Be(!1),Ue.current===Ke.id&&(Ue.current=null);return}!ze||Ue.current===Ke.id||(Ue.current=Ke.id,W(m),queueMicrotask(()=>Ge.current?.select()))},[f,m,Ke.id,ze]);let ln=G(e=>{if(!e&&je.current){let{id:e,title:t}=je.current;je.current=null,Be(!0),p(e),g(t)}}),un=G(e=>{qt(e)}),dn=G(e=>{e.preventDefault(),e.stopPropagation()}),fn=G(e=>{e.preventDefault(),e.stopPropagation()}),mn=G(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(Ke.id)}),hn=!!U&&!!(R?.card||R?.slim)&&!s&&!Bt,_n=G(e=>{if(e.preventDefault(),e.stopPropagation(),E(null),hn&&U){U(Ke.id,!Lt);return}N(Ke,{archivedBucket:s})}),vn=G(e=>{e.preventDefault(),e.stopPropagation(),E(null),N(Ke,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),yn=G(e=>{e.preventDefault(),e.stopPropagation(),E(null),x(Ke.id)}),bn=G(()=>{!Xe||st||(ct(!0),(async()=>{try{await Qe.refreshSessionTranscript(Ke.id,{directory:Xe}),Y.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{ct(!1)}})())}),Sn=G(e=>{e.preventDefault(),e.stopPropagation()}),Cn=G(e=>{e.preventDefault(),e.stopPropagation()}),En=G(e=>{e.preventDefault(),e.stopPropagation(),fe?.vscode?.executeCommand(`yuri.openSessionInEditor`,Ke.id,xt)}),On=G(e=>{if(Ee.current){Ee.current=!1;return}if($e){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Ex.getState().anchorId,n=new Map;n.set(Ke.id,_S(r)),nt(t,Ke.id,e,Xe??null,n);return}tt(Ke.id,Xe??null,_S(r));return}b(Ke.id,Xe,o,z)}),kn=G(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;On(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!P&&(t.focus({preventScroll:!0}),De.current=!0)}),An=G(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!$e)&&(Ee.current=!0)}),Mn=G(e=>{De.current=e.pointerType===`mouse`,P&&e.pointerType===`touch`&&ke(!0)}),Nn=G(e=>{P&&e.pointerType===`touch`&&ke(!1)}),Pn=G(e=>{e.key!==`Enter`||!De.current||(e.preventDefault(),e.stopPropagation(),Be(!0),p(Ke.id),g(xt))}),Ln=G(e=>{if(On(e),!De.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{De.current=!0,t.focus({preventScroll:!0})})}),Rn=G(()=>{De.current=!1}),zn=G(()=>{!zt&&!lt&&(ut(!0),Qe.loadChildren(Ke.id,Xe).catch(()=>Y.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>ut(!1))),y(Rt)});if(f===Ke.id&&ze){let e=async()=>{v();try{await In(Ke.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:_o(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:We,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Pe)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Ge,value:Pe,onChange:e=>W(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`check`,className:`size-3.5`})})]}),ue?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Pt&&!Vt&&!Bt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:zt?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Wt}),oe?(0,$.jsx)(`span`,{className:`truncate`,children:R?.projectLabel}):null,se?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:R?.branchLabel})]}):null]})})]})},Ke.id)}let Bn=mt,Vn=Nt&&Et>Date.now()&&Dt!==Et,Hn=ht.length,Un=gt.length>0,Wn=!Un&&!Bn&&K,Gn=!!R?.card,Kn=!!R?.slim,qn=Un||Hn>0,Jn=!qn&&Bn,Yn=bt||et,Xn=Gn&&Wn,Zn=!Gn&&(Un||Bn||Wn),$n=t(Un?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),er=R?.runStartedAt??null,tr=qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":$n,title:$n,children:[(0,$.jsx)(X,{name:Un?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:$n})]}):Jn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)(Sl,{size:10,arcColor:`var(--status-info)`}),er===null?null:(0,$.jsx)(Cl,{startedAt:er})]}):(0,$.jsx)(`span`,{className:J(`text-[10px] leading-none tabular-nums`,Yn?`text-foreground/70`:`text-muted-foreground/70`),children:Gt}),nr=!F||le,rr=nr?J(`group-hover:invisible group-focus-within:invisible`,Xt&&`invisible`):Xt?`invisible`:``,ar=Un?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(X,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):Bn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Sl,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),or=!Vt&&!Bt&&Pt,sr=or&&!F&&!lt,cr=_o(Math.max(0,i-1)),lr=or?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":zt,"aria-busy":lt,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),zn()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),zn())},style:{minWidth:14,minHeight:14,left:cr},className:J(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,ue?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,sr?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(zt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:lt?(0,$.jsx)(Sl,{size:12}):zt?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,ur=ft?(0,$.jsx)(X,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,dr=(0,$.jsx)(Ne,{children:(0,$.jsx)(Je,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(Re,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(D||Ae.current),style:{color:`var(--surface-elevated-foreground)`},className:J(gi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(Ke.id),className:`[&>svg]:mr-1`,children:[It?(0,$.jsx)(X,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(X,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(It?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),Bt?null:(0,$.jsxs)(e,{onClick:()=>{Ht>0?Tn(Ke.id):pn(Ke.id,Xe||void 0).catch(()=>Y.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:Ht>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(Ht>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{je.current={id:Ke.id,title:xt}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Fn()&&!qe.share?(0,$.jsxs)(e,{onClick:()=>S(qe),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Fn()&&qe.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{qe.share?.url&&w(qe.share.url,Ke.id)},className:`[&>svg]:mr-1`,children:C===Ke.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>T(Ke.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{sn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!Xe||st,onClick:()=>{bn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`refresh`,className:J(`mr-1 h-4 w-4`,st&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Zt?(0,$.jsxs)(e,{onClick:()=>en(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(sS,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,Xe&&!s?(()=>{let o=O(Xe),s=k(Xe,Ke.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?A(Xe,Ke.id):j(Xe,t.id,Ke.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(X,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=M(Xe);e&&j(Xe,e.id,Ke.id)},children:[(0,$.jsx)(X,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{A(Xe,Ke.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,de?(0,$.jsxs)(e,{disabled:!Xe,onClick:cn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:hn&&Lt?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>U?.(Ke.id,!1),children:[(0,$.jsx)(X,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>hn&&U?U(Ke.id,!0):N(Ke,{archivedBucket:s}),children:[(0,$.jsx)(X,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>N(Ke,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(Fe,{className:J(vi,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(Ie,{className:J(_i,e),...t}),Sub:Le,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(Ve,{className:J(hi,e),...n,children:[t,(0,$.jsx)(X,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(Ne,{children:(0,$.jsx)(Je,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(Re,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(gi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Rc,{sessionId:Ke.id,sessionDirectory:Xe??null,sessionTitle:xt,children:(0,$.jsxs)(Me,{open:Kt,onOpenChange:un,onOpenChangeComplete:ln,children:[(0,$.jsxs)(He,{render:(0,$.jsx)(Sc,{ref:yt,active:bt,selected:et,"data-session-row":Ke.id,"data-session-scope":Xe??``,"data-session-focus-scope":z,"data-session-focus-key":vt,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:kn,className:J(bt&&!et&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,et&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!bt&&!et&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Kn&&`py-1`)}),children:[lr,(0,$.jsx)(qc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ri,{onOpenChange:Yt,children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsxs)(Dc,{type:`button`,"data-session-title":!0,onPointerDown:Mn,onPointerUp:Nn,onPointerCancel:Nn,onMouseDown:An,onKeyDown:Pn,onBlur:Rn,onClick:Ln,onDoubleClick:e=>{e.stopPropagation(),!P&&L()&&cn()},className:J(Oe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Gn&&`gap-0.5`,!Gn&&we),children:[Gn?(0,$.jsxs)(`div`,{className:J(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,we),children:[(0,$.jsx)(vl,{project:R?.project}),Xn&&!qn?(0,$.jsx)(Qc,{}):null,(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate text-xs leading-4`,Yn?`text-foreground/80`:`text-muted-foreground`),children:R?.projectLabel}),(0,$.jsx)(`span`,{className:J(`shrink-0`,rr),children:tr})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Kn?(0,$.jsx)(vl,{project:R?.project}):null,(0,$.jsx)(`div`,{className:J(`block min-w-0 flex-1 truncate text-foreground`,Kn?`typography-meta`:Gn?`text-[0.8125rem]`:`typography-ui-label`,Kn&&!Yn&&`text-muted-foreground`,Xn?`font-medium`:`font-normal`,Vn&&`animate-text-shimmer`),"aria-busy":Vn||void 0,children:vo(xt,d)}),St?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:St}):null,Kn?(0,$.jsx)(`span`,{className:J(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,rr),children:Gt}):null,Ye?(0,$.jsx)(X,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,Hn>0&&!Gn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(X,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:Hn})]}):null,Zn?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,nr?J(`group-hover:hidden group-focus-within:hidden`,Xt?`hidden`:``):Xt?`invisible`:``),children:ar}):null,ie?(0,$.jsx)(bS,{number:ie}):null]}),Gn?(0,$.jsxs)(`div`,{className:J(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Yn?`text-foreground/60`:`text-muted-foreground/60`),children:[se?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R?.branchLabel})]}):R?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):R?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),It?(0,$.jsx)(X,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),le?null:(0,$.jsx)(ti,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:Jt?(0,$.jsx)(wx,{session:qe,title:xt,time:Gt,projectLabel:R?.projectLabel,project:R?.project,branch:r.worktree?.branch??R?.branchLabel,directory:Xe}):null})]})})}),ur&&!P?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,ue?`right-0`:`right-[30px]`),children:ur}):null,(0,$.jsxs)(Uc,{visible:Xt||F&&!le,className:J(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Xt||F&&!le?`opacity-100`:J(`opacity-0`,pe),Gn&&`top-1.5 translate-y-0`),children:[ve?(0,$.jsx)(vS,{pinned:It,pinLabel:t(It?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:ye,iconSizeClass:be,onPointerDown:dn,onMouseDown:fn,onPin:mn}):null,_e?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:dn,onMouseDown:fn,onClick:yn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(X,{name:`pushpin-2-fill`,className:be})})}),(0,$.jsx)(ti,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,he?(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,ye),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:Sn,onMouseDown:Cn,onClick:En,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(X,{name:`external-link`,className:be})})}),(0,$.jsx)(ti,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(yS,{archiveLabel:t(hn&&Lt?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:hn&&Lt,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:ye,iconSizeClass:be,revealClassName:ue&&!F&&!Xt?J(`opacity-0`,pe):`opacity-100`,onPointerDown:dn,onMouseDown:fn,onArchive:_n,onDelete:vn})]})]}),dr]})}),!Vt&&Pt&&zt?r.children.map(e=>{let t=ne?ne(e):{subtreeContainsActive:B,subtreeContainsEditing:V,menuOpenSessionId:te,nodeStructureKey:``};return I(e,i+1,Xe??a,o,s,void 0,z,t)}):null,(0,$.jsx)($r,{open:rt,onOpenChange:it,children:(0,$.jsxs)(Xr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(Jr,{children:[(0,$.jsx)(Zr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Qr,{children:t(tn===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:tn})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:at,onChange:e=>ot(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Yr,{children:[(0,$.jsx)(q,{type:`button`,onClick:()=>it(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,onClick:()=>{it(!1),on(at)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Zt?(0,$.jsx)(oS,{session:qe,open:Qt,onOpenChange:en}):null]},Ke.id)}var SS=e=>pt(e.session.directory??null),CS=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),wS=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},TS=e=>e.menuOpenSessionId??wS(e),ES=(e,t,n)=>t?n.has(e.node.session.id)?!0:Mc(e.node,t):!1,DS=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(DS(e.children[a],t.children[a],n,r,i))return!0;return!1},OS=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&bc(a)!==bc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(OS(e.children[i],t.children[i],n,r))return!0;return!1},kS=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return DS(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||DS(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},AS=Z.memo(xS,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||SS(e.node)!==SS(t.node)||!CS(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&OS(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&DS(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&kS(e,t)||e.currentSessionId!==t.currentSessionId&&(ES(e,e.currentSessionId,e.subtreeContainsActive)||ES(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(ES(e,e.editingId,e.subtreeContainsEditing)||ES(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(ES(e,e.editingId,e.subtreeContainsEditing)||ES(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(Mc(e.node,e.copiedSessionId)||Mc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=TS(e),r=TS(t);if(Mc(e.node,n)||Mc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=TS(e),r=TS(t);if(Mc(e.node,n)||Mc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function jS(e){return e.stopPropagation()}function MS(e){return e.stopPropagation()}function NS(e){let t=(0,Q.c)(71),{t:n}=Pr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=$r,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Xr,m=!1,h=`max-w-sm gap-5`,l=Jr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Zr,{children:a}),t[18]=a,t[19]=p),c=Qr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Yr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function PS(e){let t=(0,Q.c)(57),{t:n}=Pr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Zr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Qr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(Jr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Yr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Xr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)($r,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function FS(e){let t=(0,Q.c)(36),{t:n}=Pr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Zr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Qr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Jr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Yr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Xr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)($r,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var IS=e=>{let t=(0,Q.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Pr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(wi,{children:[(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(yi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(xi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(Si,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(Si,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Ci,{}),(0,$.jsxs)(Si,{onClick:s,children:[(0,$.jsx)(X,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(Si,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ri,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(ti,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ri,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},LS=e=>{let{t}=Pr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Ex(e=>e.enabled),d=Ex(e=>e.selectedIds.size),f=d>0,p=Ex(e=>e.selectedIds),m=Ex(e=>e.scopeKey),h=Z.useCallback(()=>{Ex.getState().toggleMode()},[]),g=Z.useCallback(()=>{Ex.getState().disable()},[]),_=Z.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Z.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Z.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Z.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Z.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Z.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Z.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Z.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)wl({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&$c({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Ex.getState().clear()}},[c,_,p,t]),T=Z.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Z.useCallback(async()=>{l(null),await w()},[w]);return Z.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Ex.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Ex.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Ex.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},RS=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],zS=Z.memo(function(e){let t=(0,Q.c)(9),{value:n,onChange:r}=e,{t:i}=Pr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=RS.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:J(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(X,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:J(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),BS=e=>{let t=(0,Q.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`text-[12px] tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function VS(e){let t=(0,Q.c)(20),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Pr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(US),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map(HS)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Vc,{className:`size-20`}),t[4]=e):e=t[4];let n;t[5]===a?n=t[6]:(n=a(`sessions.sidebar.task.empty`),t[5]=a,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1 pt-6 pb-2`,children:[e,(0,$.jsx)(`div`,{className:`${Eo} !text-center`,children:n})]}),t[7]=n,t[8]=r),r}let u;t[9]!==n.active||t[10]!==r?(u=n.active.map(r),t[9]=n.active,t[10]=r,t[11]=u):u=t[11];let d=u,f;t[12]!==l||t[13]!==n.active.length||t[14]!==i||t[15]!==d||t[16]!==s?(f=i&&n.active.length>1?(0,$.jsx)(fc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:WS,onSessionsReordered:i,children:d}):d,t[12]=l,t[13]=n.active.length,t[14]=i,t[15]=d,t[16]=s,t[17]=f):f=t[17];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`div`,{className:`-ml-1 -mr-1 space-y-0.5`,children:f}),t[18]=f,t[19]=p),p}function HS(e){return[e,null]}function US(e){return e.node.session.id}var WS=()=>{};function GS(e){let t=(0,Q.c)(21),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Pr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(X,{name:`archive`,className:`-ml-1 mr-0.5 size-3.5 shrink-0 text-foreground/55`}),t[2]=d):d=t[2];let f;t[3]===n.settledTotal?f=t[4]:(f=(0,$.jsx)(BS,{count:n.settledTotal}),t[3]=n.settledTotal,t[4]=f);let p;t[5]!==i||t[6]!==r||t[7]!==u||t[8]!==f?(p=(0,$.jsx)(ib,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,leadingIcon:d,accessory:f}),t[5]=i,t[6]=r,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m;t[10]!==n.settled||t[11]!==l||t[12]!==a||t[13]!==r||t[14]!==c||t[15]!==o||t[16]!==s?(m=r?(0,$.jsxs)(`div`,{className:`-ml-1 -mr-2 max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`box-border flex w-full items-center gap-[3px] rounded-md px-2 py-1.5 text-left typography-meta text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`-ml-0.5 size-4 shrink-0`}),s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})]}):null]}):null,t[10]=n.settled,t[11]=l,t[12]=a,t[13]=r,t[14]=c,t[15]=o,t[16]=s,t[17]=m):m=t[17];let h;return t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[p,m]}),t[18]=p,t[19]=m,t[20]=h):h=t[20],h}var KS={ids:[],baseline:{}},qS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,JS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!qS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},YS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},XS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=pt(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},ZS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},QS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=ZS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:ZS(n,e,o,i)??s};function $S(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var eC=`yuri.sessions.sidebarView`,tC=`yuri.sessions.projectCollapse`,nC=`yuri.sessions.groupOrder`,rC=`yuri.sessions.groupCollapse`,iC=`yuri.sessions.activeSessionByProject`,aC=`yuri.sessions.expandedParents.v2`,oC=`yuri.sessions.expandedParents`,sC=De(st()),cC=e=>{try{let t=sC.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},lC=e=>{try{let t=sC.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},uC=e=>{try{let t=sC.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},dC=(e,t,n)=>{let r=new Set;for(let t of e){let e=pt(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=pt(t.path)?.toLowerCase();e&&r.add(e)}return r},fC=(e,t,n)=>{if(e.time?.archived)return!0;let r=pt(vn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},pC=new Set,mC=[],hC={},gC=(e,t)=>{let n=Z.useRef(e);return n.current=e,Z.useMemo(()=>(...e)=>n.current(...e),[t])},_C=Z.memo(function(e){let t=(0,Q.c)(3),{onOpenChange:n}=e,r=Ol(je(yC)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Nl,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),vC=Z.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Pr(),[s,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(``),h=Z.useRef(null),g=Z.useRef(null),[_,v]=Z.useState(null),[y,b]=Z.useState(``),[x,S]=Z.useState(null),[w,T]=Z.useState(new Set),E=Z.useMemo(()=>sC,[]),[D,O]=Z.useState(new Set),[k,A]=Z.useState(new Map),[j,M]=Z.useState(new Map),N=K(e=>e.isNewWorktreeDialogOpen),P=K(e=>e.setNewWorktreeDialogOpen),[F,I]=Z.useState(null),[L,R]=Z.useState(null),[z,ee]=Z.useState(``),[B,V]=Z.useState(null),[te,ne]=Z.useState(null),[re,ie]=Z.useState(null),H=tn(),U=En(),oe=nl(),se=Xc(),ce=pl(),le=Rn(),ue=K(e=>e.sidebarView),de=K(e=>e.setSidebarView);Z.useEffect(()=>{let e=st().getItem(eC);e!==null&&(st().removeItem(eC),K.getState().sidebarView===`projects`&&vc(e)!==`projects`&&de(vc(e)))},[de]);let[fe,pe]=Z.useState({settledOpen:!1,settledLimit:30}),me=Z.useRef(new Map),he=Z.useRef(new Map),ge=G(e=>{de(e),Ze({sidebarView:e})}),[_e,ve]=Z.useState(()=>cC(rC)),[ye,be]=Z.useState(()=>uC(nC)),[xe,Se]=Z.useState(()=>lC(iC)),Ce=Z.useRef(null);Z.useEffect(()=>c(e=>{m(e)&&(Ce.current=null,ve(cC(rC)),be(uC(nC)),Se(lC(iC)),O(cC(tC)),T(cC(aC)))}),[]);let[we,Te]=Z.useState(new Map),Ee=Z.useRef(0),De=et(e=>e.homeDirectory),Oe=et(e=>e.currentDirectory),ke=et(e=>e.setDirectory),Ae=fn(e=>e.projects),je=Z.useMemo(()=>Ae.filter(e=>!e.hostId),[Ae]),Me=Z.useMemo(()=>Ae.filter(e=>e.hostId).map(Dr),[Ae]),[Ne,Pe]=Z.useState(()=>new Map),Fe=G((e,t)=>{Pe(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Ie=Jc(a),[Le,W]=Z.useState(new Map),Re=G((e,t)=>{W(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),ze=fn(e=>e.activeProjectId),Be=fn(e=>e.removeProject),Ve=fn(e=>e.setActiveProjectIdOnly),He=fn(e=>e.updateProjectMeta),Ue=fn(e=>e.reorderProjectsById),We=K(e=>e.setActiveMainTab),Ge=K(e=>e.activeMainTab),Ke=Ma(),qe=K(e=>e.setSettingsDialogOpen),Je=K(e=>e.toggleHelpDialog),Ye=K(e=>e.setSessionSwitcherOpen),Xe=K(e=>e.setScheduledTasksDialogOpen),Qe=K(e=>e.notifyOnSubtasks),$e=K(e=>e.showDeletionDialog),tt=K(e=>e.setShowDeletionDialog),nt=ja(f,120),rt=Z.useMemo(()=>nt.trim().toLowerCase(),[nt]),it=rt.length>0,at=Ol(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ot=nn(e=>e.collapsedFolderIds),ct=nn(e=>e.foldersMap),lt=nn(e=>e.sessionOrderByScope),ut=nn(e=>e.sessionOrderActivityByScope),dt=nn(e=>e.getFoldersForScope),ft=nn(e=>e.createFolder),mt=nn(e=>e.renameFolder),ht=nn(e=>e.deleteFolder),gt=nn(e=>e.addSessionToFolder),_t=nn(e=>e.addSessionsToFolder),vt=nn(e=>e.removeSessionFromFolder),yt=nn(e=>e.removeSessionsFromFolders),bt=nn(e=>e.toggleFolderCollapse),xt=nn(e=>e.getSessionFolderId),St=nn(e=>e.reorderSessions);Gy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let Ct=Z.useMemo(()=>new Map,[]),Et=bn({enabled:a,includeChildren:!0}),Dt=Fc({enabled:a}),Ot=sl({enabled:a}),kt=un(e=>a?e.index.session.unseenCount:hC),At=Z.useMemo(()=>ae(),[]),jt=hn(e=>e.status),Mt=hn(e=>e.activeSessions),Nt=hn(e=>e.archivedSessions),Pt=hn(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Ft=hn(e=>e.archivedLoadingDirectories),It=Z.useDeferredValue(Mt),Lt=Z.useDeferredValue(Nt),Rt=Jn(e=>e.currentSessionId),zt=ln(e=>e.remoteSession!==null)?null:Rt,Ut=fo(e=>e.focus),Wt=Z.useSyncExternalStore(Ht,Bt,Bt),Gt=Jn(e=>!!e.newSessionDraft?.open),Kt=Jn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),qt=Z.useMemo(()=>!e&&Ge===`chat`&&Kt&&Wt.sessionId===null?{projectId:Kt,revision:Wt.revision}:null,[e,Ge,Kt,Wt]),Jt=Jn(e=>e.setCurrentSession),Yt=Jn(e=>e.updateSessionTitle),Xt=Jn(e=>e.shareSession),Zt=Jn(e=>e.unshareSession),Qt=Jn(e=>e.worktreeMetadata),$t=Jn(e=>e.availableWorktreesByProject),rn=Jn(e=>e.openNewSessionDraft),an=G(t=>{let n=Me.find(e=>e.id===(t?.selectedProjectId??fn.getState().activeProjectId));if(n){uc(n,e).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}ln.getState().clearRemoteSession(),rn(t),At&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),on=Z.useMemo(()=>dC(je,$t,{includeWorktrees:!At}),[$t,At,je]),cn=Z.useMemo(()=>{let e=new Map(Et.map(e=>[e.id,e])),t=It.map(t=>{let n=e.get(t.id);return n?en(n,t):t}),n=new Set(t.map(e=>e.id));return Et.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>fC(e,on,{allowUnknownDirectory:!At,allowEmptyDirectorySet:!At}))},[It,At,on,Et]),dn=Z.useMemo(()=>Et.map(e=>{let t=pt(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[Et]),pn=Z.useRef(Et);Z.useEffect(()=>{pn.current=Et},[dn,Et]);let mn=Z.useMemo(()=>new Map(Et.map(e=>[e.id,e])),[Et]);Z.useEffect(()=>{let e=null,t=wt(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=fn.getState().projects.find(e=>e.id===t.projectId),n=pt(e?.path??null);if(!n)return;let r=[n];(Jn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=pt(e.path);t&&r.push(t)}),_n(r,pn.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let gn=Z.useMemo(()=>C(),[]),xn=vu(e=>e.sidebarBrandName.trim().length>0),{isTablet:Sn,isDesktop:Cn}=pi(),wn=e||Sn,{buildGroupSearchText:Tn,filterSessionNodesForSearch:On,buildGroupedSessions:kn}=Yc({homeDirectory:De,worktreeMetadata:Qt,pinnedSessionIds:H,gitBranches:Ct,isVSCode:At}),{scheduleCollapsedProjectsPersist:An,hasRestoredProjectCollapse:Mn}=Qy({isVSCode:At,safeStorage:E,keys:{sessionExpanded:aC,sessionExpandedLegacy:oC,projectCollapse:tC,groupOrder:nC,projectActiveSession:iC,groupCollapse:rC},groupOrderByProject:ye,activeSessionByProject:xe,collapsedGroups:_e,setExpandedParents:T,setCollapsedProjects:O}),Nn=Z.useMemo(()=>[...cn].sort((e,t)=>ko(e,t,H)),[cn,H]),Pn=Z.useMemo(()=>{let e=new Map;return Nn.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>ko(e,t,H))),e},[Nn,H]),Fn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),In=Z.useMemo(()=>je.find(e=>e.id===x)??null,[je,x]),zn=Z.useCallback(e=>{x&&He(x,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[x,He]),Bn=Z.useCallback(()=>{P(!0)},[P]),Vn=Z.useCallback((t,n)=>{if(We(`chat`),e&&Ye(!1),!n?.remote){if(n?.sessionId){Jt(n.sessionId,t);return}rn({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,rn,We,Jt,Ye]),Hn=G(()=>{let e=Ol.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=Ol.getState();if(t){Y.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){Y.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Un=Z.useCallback(()=>{e&&Ye(!1),qe(!0)},[e,Ye,qe]),Wn=G(()=>{let t=Me.find(e=>e.id===fn.getState().activeProjectId);if(t){uc(t,e).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}ln.getState().clearRemoteSession(),We(`chat`),rn(),e&&Ye(!1)}),Gn=Z.useCallback(()=>{if(!e){We(`schedule`);return}Xe(!0),Ye(!1)},[e,We,Xe,Ye]),qn=Z.useCallback(()=>{Ur(),e&&Ye(!1)},[e,Ye]),Yn=Jn(e=>e.archiveSession),Xn=Jn(e=>e.archiveSessions),{copiedSessionId:Zn,handleSessionSelect:Qn,handleSessionDoubleClick:er,handleSaveEdit:tr,handleCancelEdit:nr,handleShareSession:rr,handleCopyShareUrl:ir,handleUnshareSession:ar,handleDeleteSession:or,confirmDeleteSession:sr}=Ky({activeProjectId:ze,currentDirectory:Oe,currentSessionId:zt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ve,setDirectory:ke,setActiveMainTab:We,setSessionSwitcherOpen:Ye,setCurrentSession:Jt,updateSessionTitle:Yt,shareSession:Xt,unshareSession:Zt,archiveSession:Yn,archiveSessions:Xn,childrenMap:Pn,showDeletionDialog:$e,setDeleteSessionConfirm:V,deleteSessionConfirm:B,setEditingId:v,setEditTitle:b,editingId:_,editTitle:y}),ur=Z.useCallback((e,t,n,r=`project`)=>{ln.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===zt){Vt(e),gS(i),Qn(e,t,n);return}mS(i,()=>Qn(e,t,n))},[Qn,zt]);Z.useEffect(()=>()=>{pS()},[]);let dr=Z.useCallback(()=>{if(!te)return;let{scopeKey:e,folderId:t}=te;ne(null),ht(e,t)},[te,ht]);Z.useEffect(()=>{if(!zt)return;let e=cn.find(e=>e.id===zt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{E.setItem(aC,JSON.stringify(Array.from(n)))}catch{}return n})},[zt,cn,E]);let fr=Z.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{E.setItem(aC,JSON.stringify(Array.from(n)))}catch{}return n})},[E]),pr=Z.useCallback((e,t)=>{if(!e)return null;t&&ot.has(t)&&bt(t);let n=ft(e,o(`sessions.sidebar.folder.newFolderName`),t);return R(n.id),ee(n.name),n},[ot,bt,ft,o]),mr=G(ur),hr=G(er),gr=G(tr),_r=G(nr),vr=G(rr),yr=G(ir),br=G(ar),xr=G(or),Sr=G(pr),Cr=G((e,t,n,r)=>{let i=bl(),a=Math.max(i,n)+7;if(M(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=pt(e.directory??null);if(!o)return;let s=hn.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&yn(o)}),wr=G(e=>{M(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),Tr=G(e=>{M(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),Er=Z.useMemo(()=>e=>{let t=je.find(t=>t.id===e),n=pt(t?.path??null);if(!n)return[];let r=[n];return At||($t.get(n)??[]).forEach(e=>{let t=pt(e.path);t&&r.push(t)}),r},[$t,At,je]),Or=G(e=>{let t=Er(e);if(t.length===0)return;let n=hn.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&_n(r,pn.current)}),kr=G(e=>{let t=je.find(t=>t.id===e);t&&(async()=>{let e=[];if(!At)try{e=(await zs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=pt(t.path);e=r?Jn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=XS(t.path,e,{currentDirectory:Oe,workspaceRoot:t.path,includeWorktrees:!At});n.length!==0&&await sn(n,pn.current)})()});Z.useEffect(()=>{if(!Mn)return;let e=hn.getState(),t=je.flatMap(t=>D.has(t.id)?[]:Er(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&_n(t,pn.current)},[D,Er,Mn,je]);let Ar=G(()=>{Ee.current=Date.now()+150,M(new Map),O(()=>{let e=new Set(je.map(e=>e.id));try{E.setItem(tC,JSON.stringify(Array.from(e)))}catch{}return At||An(e),e})}),jr=G(()=>{Ee.current=Date.now()+150,M(new Map),O(()=>{let e=new Set;try{E.setItem(tC,JSON.stringify([]))}catch{}return At||An(e),e});let e=hn.getState().loadedDirectories,t=je.flatMap(t=>Er(t.id).filter(t=>!e.has(t)));t.length>0&&_n(t,pn.current)}),Mr=G(e=>{Ee.current=Date.now()+150,Tr(e),O(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Or(e))):n.add(e);try{E.setItem(tC,JSON.stringify(Array.from(n)))}catch{}return At||An(n),n})}),Nr=G(e=>{Ee.current=Date.now()+150,Or(e),O(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{E.setItem(tC,JSON.stringify(Array.from(n)))}catch{}return At||An(n),n})}),Fr=Z.useMemo(()=>je.map(e=>({...e,normalizedPath:pt(e.path)})).filter(e=>!!e.normalizedPath),[je]),Ir=Z.useMemo(()=>new Map(Fr.map(e=>[e.id,Ln(e.normalizedPath)||e.normalizedPath])),[Fr]),Lr=Z.useMemo(()=>Fr.map(e=>e.normalizedPath),[Fr]),Rr=Z.useMemo(()=>{let e=new Set(Fr.map(e=>e.normalizedPath));if(!At)for(let t of $t.values())for(let n of t){let t=pt(n.path);t&&e.add(t)}return[...e].sort()},[$t,At,Fr]),zr=Z.useRef(null);Z.useEffect(()=>{let e=new Set(Rr),t=zr.current;if(zr.current=e,!t)return;let n=Rr.filter(e=>!t.has(e));if(n.length===0)return;let r=hn.getState().loadedDirectories,i=pt(Oe),a=Fr.find(e=>e.id===ze)??Fr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),At||($t.get(a.normalizedPath)??[]).forEach(e=>{let t=pt(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&_n(s,pn.current)},[ze,$t,Oe,At,Fr,Rr]);let Br=Zi(a?Lr:mC);eb({normalizedProjects:Fr,activeProjectId:ze,gitRepoStatus:Br,setProjectRepoStatus:A,setProjectRootBranches:Te,enabled:a});let Vr=Z.useMemo(()=>Fl(cn,Fr,$t,At,Lt),[Lt,$t,At,Fr,cn]),{getSessionsForProject:Hr,getArchivedSessionsForProject:Wr}=tb({ownership:Vr}),Gr=Pt||jt===`idle`||jt===`loading`,Kr=Z.useRef(!1);ze&&k.has(ze)&&(Kr.current=!!k.get(ze));let qr=Dn(e=>e.projectSortOrder),Jr=Z.useMemo(()=>tl(Fr,qr),[Fr,qr]),{projectSections:Yr,groupSearchDataByGroup:Xr,sectionsForRender:Zr,searchMatchCount:Qr}=Hy({normalizedProjects:Jr,getSessionsForProject:Hr,getArchivedSessionsForProject:Wr,availableWorktreesByProject:$t,projectRepoStatus:k,projectRootBranches:we,lastRepoStatus:Kr.current,buildGroupedSessions:kn,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,filterSessionNodesForSearch:On,buildGroupSearchText:Tn,foldersMap:ct}),$r=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});Uy({projectSections:Yr,activeProjectId:ze,activeSessionByProject:xe,setActiveSessionByProject:Se,currentSessionId:zt,handleSessionSelect:Qn,newSessionDraftOpen:Gt,mobileVariant:e,openNewSessionDraft:rn,setActiveMainTab:We,setSessionSwitcherOpen:Ye});let{getOrderedGroups:ei}=Wy(ye),ti=Z.useRef(!1);Z.useEffect(()=>{if(ti.current||Yr.length===0)return;let e=Yr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&ve(t=>new Set([...t,...e])),ti.current=!0},[Yr]);let ni=Z.useMemo(()=>{let e=new Map,t=new Map;return Yr.forEach(n=>{let r=Ln(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[Yr]);Z.useLayoutEffect(()=>{if(!zt){gS(null);return}let e=fo.getState().focus;if(e?.sessionId===zt){e.scope===`project`&&!e.projectId&&gS({...e,projectId:ni.get(zt)?.projectId??null});return}gS({scope:`project`,sessionId:zt,projectId:ni.get(zt)?.projectId??null})},[zt,ni]);let ri=Z.useMemo(()=>At?[]:Oc(cn,H,lt[wc]),[At,H,cn,lt]),ii=G((e,t)=>{_||St(wc,li.map(e=>e.node.session.id),e,t,{}).catch(()=>Y.error(o(`sessions.order.saveFailed`)))}),ai=Z.useMemo(()=>it?[]:zc(cn,H,Ot,kt),[it,H,Ot,cn,kt]),{pinnedItems:oi,inProgressItems:si}=Z.useMemo(()=>{let e=e=>{let t=ni.get(e.id),n=pt(e.directory??null),r={session:e,children:[],worktree:Qt.get(e.id)??null};if(it&&On([r],rt).length===0)return null;let i=Vr.bySessionId.get(e.id),a=i?Jr.find(e=>e.id===i.projectId):void 0,o=a?Ln(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=hc({projectLabel:o,owner:i,sessionWorktree:Qt.get(e.id)??null,worktrees:a?$t.get(a.normalizedPath)??[]:[],projectRootBranch:i?we.get(i.projectId)??(a?Br.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:At})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:At?[]:t(ri),inProgressItems:t(ai)}},[$t,On,Br,it,ai,At,rt,ri,we,Vr,ni,Jr,Qt]),ci=Z.useMemo(()=>Me.flatMap(e=>Ne.get(e.id)??[]),[Me,Ne]),li=Z.useMemo(()=>Tl([...oi,...ci.filter(e=>e.pinned)],e=>e.node.session.id,lt[wc]),[oi,ci,lt]),ui=Z.useMemo(()=>[...si,...ci.filter(e=>!e.pinned)].sort((e,t)=>jn(t.node.session)-jn(e.node.session)),[si,ci]),di=!e&&!At&&!r&&!i,fi=di&&ue===`tasks`&&!it,mi=xl(Ot,a&&di),[hi,gi]=Z.useState(KS),_i=Z.useMemo(()=>fi?yl({sessions:cn,pinnedSessionIds:H,settledSessionIds:oe,indexedSessionIds:se?.indexedIds??null,settledAtBySessionId:se?.settledAtById,runningSessionIds:Ot,pendingRequestSessionIds:le,unseenBySession:kt}):null,[le,H,Ot,cn,oe,se,fi,kt]),vi=Z.useMemo(()=>{let e=_i?.settled.filter(e=>!oe.has(e.id));return e?.length?new Set([...oe,...e.map(e=>e.id)]):oe},[_i,oe]),yi=G(e=>({activityAt:jn(e),running:Ot.has(e.id),attention:Pc(e.id,le,kt)})),bi=Z.useMemo(()=>{if(!_i)return null;let e=JS(_i.active,e=>e.id,yi,hi);return e===_i.active?_i:{..._i,active:e}},[_i,yi,hi]),xi=G((e,t)=>{if(_||!bi)return;let n=new Map(bi.active.map(e=>[e.id,e])),r=YS(bi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?yi(t):void 0});r&&gi(r)}),Si=G((e,t,n)=>{if(!fi||Ge!==`chat`||zt!==e||Bt()!==n)return;let r=[...ri,...bi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){pS(),gS(null),rn();return}let a=Vr.bySessionId.get(i.id);ur(i.id,a?.scopeDirectory??pt(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),Ci=G((e,t)=>{if(!t&&_i?.settled.some(t=>t.id===e&&t.time?.archived)){Kn(e);return}if(!t||!fi||zt!==e){ce(e,t);return}let n=[...ri,...bi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Bt();ce(e,!0,{onSuccess:()=>Si(e,i?.id??null,a)})}),wi=di?Ci:void 0,Ti=Z.useMemo(()=>{if(!bi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(Jr.map(e=>[e.id,Ln(e.normalizedPath)||e.normalizedPath])),n=he.current,r=new Map(Jr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of Jr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=me.current,s=new Map,c=n=>o=>{let c=Vr.bySessionId.get(o.id),l=ni.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??pt(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?Br.get(m):void 0,g=Qt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?we.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?cr(m,De):null,x=g,S=n?mi.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=fe.settledOpen?bi.settled.slice(0,fe.settledLimit):[],u={pinned:ri.map(c(!0)),active:bi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:bi.settled.length};return me.current=s,u},[Br,De,ri,we,mi,Vr,ni,Jr,o,bi,fe.settledLimit,fe.settledOpen,Qt]),{git:Ei}=Tt(),Di=$i(e=>e.ensureStatus),Oi=Z.useMemo(()=>{if(!Ti)return mC;let e=new Map(Jr.map(e=>[e.id,e.normalizedPath])),t=new Set;for(let n of[Ti.pinned,Ti.active,Ti.settled])for(let r of n){if(r.secondaryMeta?.branchState!==`loading`||!r.projectId)continue;let n=e.get(r.projectId);n&&t.add(n)}return t.size?[...t].sort():mC},[Jr,Ti]),ki=Oi.join(`\0`);Z.useEffect(()=>{if(!(!a||!fi||!Ei))for(let e of Oi)Di(e,Ei)},[Di,Ei,a,ki,fi]);let Ai=Z.useMemo(()=>{if(!Ti)return li;let e=new Map(Ti.pinned.map(e=>[e.node.session.id,e]));return li.map(t=>e.get(t.node.session.id)??t)},[li,Ti]),ji=Z.useMemo(()=>{if(!bi||!Ti)return[];let e=new Map([...Ti.active,...Ti.settled].map(e=>[e.node.session.id,e]));return yc(bi,fe).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:pt(vn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[bi,Ti,fe]),Mi=Z.useMemo(()=>Zr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Zr]),Ni=Z.useMemo(()=>{let e=it?Mi.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Xr.get(e)?.filteredNodes??[]}))})):Mi;if(!i)return e;let t=e.find(e=>e.project.id===ze)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[ze,Xr,it,Mi,i]),Pi=Z.useMemo(()=>Hc({sections:Ni,foldersMap:ct,getOrderedGroups:ei,pinnedSessionIds:H,sessionOrderByScope:lt,sessionOrderActivityByScope:ut}),[ct,ei,Ni,H,ut,lt]),Fi=Z.useMemo(()=>_c({targets:Pi,collapsedProjectIds:D,collapsedGroupKeys:_e,collapsedFolderIds:ot,visibleSessionCountByGroup:j,defaultVisibleSessionCount:bl(),hasSessionSearchQuery:it,alwaysVisibleSessionIds:Dt}),[Dt,ot,_e,D,it,Pi,j]),Ii=Z.useMemo(()=>it?[]:(fi?li:[...li,...ui]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:pt(vn(n))??e.groupDirectory??null,visibleIndex:t}}),[it,ui,li,fi]),[Li,Ri]=Z.useState(null),zi=Z.useCallback(e=>{Ri(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Bi=Z.useMemo(()=>{if(!Li)return Ii;let e=new Set(Li);return Ii.filter(t=>e.has(t.sessionId))},[Ii,Li]),Vi=Z.useMemo(()=>!a&&Ce.current?Ce.current:{pinned:Bi,project:fi?ji:Fi},[a,ji,fi,Bi,Fi]);Z.useLayoutEffect(()=>{a&&(Ce.current=Vi)},[a,Vi]);let Hi=Z.useMemo(()=>e?[]:co({pinnedTargets:Vi.pinned,projectTargets:fi?Vi.project:Ae.flatMap(e=>e.hostId?Le.get(e.id)??[]:Vi.project.filter(t=>t.projectId===e.id))}),[e,fi,Vi,Ae,Le]),Ui=Z.useCallback(t=>{let n=Me.find(e=>e.id===t.projectId);if(n&&Ie.registry){let r=Ne.get(n.id)?.find(e=>e.identity===t.sessionId);lc(n,Ie.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}We(`chat`),Ye(!1),t.scope===`project`&&t.projectId&&Ve(t.projectId),ur(t.sessionId,t.directory,t.projectId,t.scope)},[ur,We,Ve,Ye,Me,Ie.registry,Ne,e]);Z.useLayoutEffect(()=>io({targets:Hi,activate:Ui}),[Ui,Hi]);let Wi=Z.useMemo(()=>{let e=new Map;return Hi.forEach(t=>{let n=$a({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Xa(Hi,t)??0)}),e},[Hi]),Gi=Z.useMemo(()=>{if(!zt||it)return[];let e=[],t=(n,r)=>{if(n.session.id===zt){e.push({scope:`pinned`,sessionId:zt,projectId:r});return}n.children.forEach(e=>t(e,r))};return li.forEach(e=>t(e.node,e.projectId)),si.forEach(e=>t(e.node,e.projectId)),e},[zt,it,si,li]),Ki=Z.useMemo(()=>{if(!zt)return[];let e=[],t=(n,r)=>{if(n.session.id===zt){e.push({scope:`project`,sessionId:zt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Yr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[zt,Yr]);Z.useLayoutEffect(()=>ao({pinned:Vi.pinned,project:Vi.project}),[Vi]),Z.useLayoutEffect(()=>{!a||Gr||gS(QS({currentSessionId:zt,focus:Ut,pinnedFocuses:Gi,projectFocuses:Ki,fallbackProjectId:zt?ni.get(zt)?.projectId??null:null}))},[zt,a,Gr,Ki,Gi,Ut,ni]);let qi=Z.useMemo(()=>{let e=Ut?.sessionId?ni.get(Ut.sessionId)?.projectId??null:null;return $S(Ut,Pi,e)},[Pi,Ut,ni]),Ji=Z.useRef(null),Yi=Z.useRef(null);Z.useEffect(()=>{Yi.current&&Yi.current!==zt&&(Yi.current=null)},[zt]),Z.useLayoutEffect(()=>{if(!qi?.projectId)return;let e=qi.sessionId,t=Wt.sessionId===e;if(!(!t&&zt!==e)){if(t){if(Ji.current===Wt.revision)return;Ji.current=Wt.revision,Yi.current=e}else{if(Yi.current===e)return;Yi.current=e}if(Nr(qi.projectId),qi.groupKey&&ve(e=>{if(!e.has(qi.groupKey))return e;let t=new Set(e);return t.delete(qi.groupKey),t}),qi.folderAncestorIds?.forEach(e=>{let t=nn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),qi.groupKey&&qi.visibleIndex!==void 0){let e=qi.visibleIndex+1;M(t=>{if((t.get(qi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(qi.groupKey,e),n})}}},[zt,qi,Wt]);let Xi=gC((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(AS,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:zt,pinnedSessionIds:H,settledSessionIds:vi,setSessionSettled:wi,expandedParents:w,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,notifyOnSubtasks:Qe,editingId:_,setEditingId:v,editTitle:y,setEditTitle:b,handleSaveEdit:gr,handleCancelEdit:_r,toggleParent:fr,handleSessionSelect:mr,handleSessionDoubleClick:hr,togglePinnedSession:U,handleShareSession:vr,copiedSessionId:Zn,handleCopyShareUrl:yr,handleUnshareSession:br,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,renamingFolderId:L,getFoldersForScope:dt,getSessionFolderId:xt,removeSessionFromFolder:vt,addSessionToFolder:gt,createFolderAndStartRename:Sr,handleDeleteSession:xr,mobileVariant:e,alwaysShowActions:wn,renderSessionNode:Xi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??pC,subtreeContainsEditing:c?.subtreeContainsEditing??pC,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:mn,shortcutNumber:Wi.get($a({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...Wi])),Qi=Z.useCallback(e=>{wr(e),ve(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[wr]),ea=Z.useCallback(e=>{let t=Er(e);if(t.length===0)return;let n=hn.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&$n(r)},[Er]),ta=G((e,t,n,r,i)=>{let a=e.folderScopeKey??pt(e.directory??null);a&&St(a,t,n,r,i).catch(()=>Y.error(o(`sessions.order.saveFailed`)))}),na=G((e,t,n)=>{e.isArchivedBucket&&_e.has(t)&&n&&ea(n),Qi(t)}),ra=Z.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(pc,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Er(r).some(e=>Ft.has(e))),projectId:r,projectLabel:r?Ir.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:it,normalizedSessionSearchQuery:rt,groupSearchDataByGroup:Xr,visibleSessionCount:j.get(n),collapsedGroups:_e,collapsedFolderIds:ot,toggleFolderCollapse:bt,renameFolder:mt,deleteFolder:ht,showDeletionDialog:$e,setDeleteFolderConfirm:ne,renderSessionNode:Xi,projectRepoStatus:k,lastRepoStatus:Kr.current,showMoreGroupSessions:Cr,resetGroupSessionLimit:wr,mobileVariant:e,alwaysShowActions:wn,activeProjectId:ze,setActiveProjectIdOnly:Ve,setActiveMainTab:We,setSessionSwitcherOpen:Ye,openNewSessionDraft:an,addSessionToFolder:gt,createFolderAndStartRename:Sr,renamingFolderId:L,renameFolderDraft:z,setRenameFolderDraft:ee,setRenamingFolderId:R,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:lt,sessionOrderActivityByScope:ut,onReorderSessions:ta,currentSessionId:zt,shortcutTargetSessionId:qi?.groupKey===n?qi.sessionId:null,shortcutTargetVisibleIndex:qi?.groupKey===n?qi.visibleIndex??null:null,editingId:_,editTitle:y,openSidebarMenuKey:F,liveSessionById:mn,alwaysVisibleSessionIds:Dt,onToggleCollapsedGroup:na,dragHandleProps:a,scrollContainerRef:s}),[it,rt,Xr,Ir,Ft,Er,j,_e,ot,bt,mt,ht,$e,Xi,k,Cr,wr,e,wn,ze,Ve,We,Ye,an,gt,Sr,L,z,H,w,lt,ut,ta,zt,qi,_,y,F,mn,Dt,na]),ia=fi?(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:lr.requestDirectoryDialog,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}):null,aa=di?(0,$.jsx)(zS,{value:ue,onChange:ge}):void 0,oa=e=>Xi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),sa=fi&&Ti?(0,$.jsx)(VS,{items:Ti,renderTaskRow:oa,onSessionsReordered:xi}):void 0,ca=fi&&Ti?(0,$.jsx)(GS,{items:Ti,open:fe.settledOpen,onToggle:()=>pe(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>pe(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:oa}):void 0,la=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(mb,{collapseAllProjects:Ar,expandAllProjects:jr}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`-mr-0.5 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:lr.requestDirectoryDialog,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]}),ua=gn&&xn&&!At&&!it?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(bf,{className:`min-w-0 flex-1`}),(0,$.jsx)(ol,{className:`ml-auto shrink-0`})]})}):null,da=!At&&!it,fa=da&&Cn&&!e,pa=fi?[]:ui,ma=!it&&(li.length>0||pa.length>0),ha=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:Wn,children:[(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ge===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Gn,children:[(0,$.jsx)(X,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Dy,{}):null]}),Ke.data?.supported&&Ke.data?.enabled?(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ge===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:qn,children:[(0,$.jsx)(ul,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Hl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Oy,{}):null]})]}):null,(0,$.jsx)(Du,{sidebar:!0,mobile:e})]}),ga=di&&!it,_a=ma?(0,$.jsx)(ab,{isFirst:ga,hideHeader:fi,items:Ai,reorderEnabled:!0,onSessionsReordered:ii,inProgressItems:pa,renderSessionNode:Xi,currentSessionId:zt,editingId:_,openSidebarMenuKey:F,onVisibleSessionIdsChange:zi}):null,va=da&&!fa||ma&&!ga?(0,$.jsxs)($.Fragment,{children:[da&&!fa?(0,$.jsxs)($.Fragment,{children:[e&&xn?(0,$.jsx)(bf,{}):null,ha]}):null,ga?null:_a]}):null,ya=!!(L||_||x),{selectionModeEnabled:ba,hasSelection:xa,selectedIdsSize:Sa,bulkScopeIsArchived:Ca,derivedSelectionScope:wa,bulkScopeFolders:Ta,bulkCanRemoveFromFolder:Ea,handleExitSelectionMode:Da,handleBulkMoveToFolder:Oa,handleBulkCreateFolderAndMove:ka,handleBulkRemoveFromFolder:Aa,handleBulkDelete:Na,confirmBulkDelete:Pa}=LS({isInlineEditing:ya,showDeletionDialog:$e,foldersMap:ct,addSessionsToFolder:_t,removeSessionsFromFolders:yt,createFolderAndStartRename:pr,archiveSessions:Xn,setBulkDeleteConfirm:ie});return(0,$.jsxs)(`div`,{ref:h,className:J(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(rb,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:it,searchMatchCount:Qr}),ua,fa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:ha}):null,a?(0,$.jsx)(ax,{remoteProjects:Me,hostRegistry:Ie.registry,remoteCatalogLoading:Ie.catalog.isLoading,remoteCatalogError:Ie.catalog.error?.message,projectOrderIds:tl(Ae,qr).map(e=>e.id),onRemoteActivityItems:Fe,remoteSearch:f,onRemoteNavigationTargets:Re,topContent:va,tabLeadingContent:ga?_a:void 0,hasLeadingSection:va!==null&&!ga&&(li.length>0||si.length>0),headerAccessory:fi?ia:la,headerSwitch:aa,taskContent:sa,taskFooter:ca,sectionsForRender:Mi,projectSections:Yr,activeProjectId:ze,projectRevealTarget:qt,showOnlyMainWorkspace:i,hasSessionSearchQuery:it,emptyState:Fn,searchEmptyState:$r,renderGroupSessions:ra,homeDirectory:De,collapsedProjects:D,hideDirectoryControls:r,projectRepoStatus:k,mobileVariant:e,alwaysShowActions:wn,toggleProject:Mr,setActiveProjectIdOnly:Ve,setActiveMainTab:We,setSessionSwitcherOpen:Ye,openNewSessionDraft:an,openNewWorktreeDialog:Bn,syncProjectSessions:kr,openProjectEditDialog:S,removeProject:Be,projectReorderEnabled:qr===`manual`,reorderProjects:Ue,projectSortOrder:qr,getOrderedGroups:ei,setGroupOrderByProject:be,openSidebarMenuKey:F,setOpenSidebarMenuKey:I,isInlineEditing:ya}):null,ba&&xa?(0,$.jsx)(IS,{selectedCount:Sa,scopeKey:wa,scopeFolders:Ta,archivedBucket:Ca,onMoveToFolder:Oa,onCreateFolderAndMove:ka,onRemoveFromFolder:Aa,canRemoveFromFolder:Ea,onDelete:Na,onDone:Da}):null,(0,$.jsx)(Ny,{normalizedProjects:Fr,ownership:Vr,enabled:a}),(0,$.jsx)(Yb,{onOpenSettings:Un,onOpenShortcuts:Je,onOpenUpdate:Hn,showRuntimeButtons:!At,showUpdateButton:at}),s?(0,$.jsx)(_C,{onOpenChange:l}):null,In?(0,$.jsx)(nb,{open:!0,onOpenChange:e=>{e||S(null)},project:In,onSave:zn}):null,N?(0,$.jsx)(ps,{open:!0,onOpenChange:P,onWorktreeCreated:Vn}):null,(0,$.jsx)(ml,{}),(0,$.jsx)(bu,{}),(0,$.jsx)(NS,{value:B,setValue:V,showDeletionDialog:$e,setShowDeletionDialog:tt,onConfirm:sr}),(0,$.jsx)(FS,{value:te,setValue:ne,onConfirm:dr}),(0,$.jsx)(PS,{value:re,setValue:ie,showDeletionDialog:$e,setShowDeletionDialog:tt,onConfirm:Pa})]})});function yC(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var bC=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,xC=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},SC=()=>{let{t:e}=Pr(),[t,n]=Z.useState(!1),[r,i]=Z.useState(),[a,o]=Z.useState(null),[s,c]=Z.useState([]),[l,u]=Z.useState(!1),[d,f]=Z.useState(!1),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),[_,v]=Z.useState(new Set),y=Jn(e=>e.getWorktreeMetadata),b=Jn(e=>e.newSessionDraft),x=Jn(e=>e.setNewSessionDraftTarget),S=Jn(e=>e.setDraftBootstrapPendingDirectory),C=dr,w=Jn(e=>e.archiveSessions),T=K(e=>e.showDeletionDialog),E=K(e=>e.setShowDeletionDialog),D=et(e=>e.currentDirectory),O=et(e=>e.homeDirectory),k=fn(e=>e.projects),A=fn(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=pi(),P=j||M||N,F=Z.useMemo(()=>xC((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Z.useCallback(e=>{let t=xC(e.projectDirectory)||F;return{id:(k.find(e=>xC(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Z.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,V=p||!z,te=Z.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),ne=Z.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),re=Z.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);wl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Z.useEffect(()=>lr.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){re(e);return}te(e)}),[te,T,re]),Z.useEffect(()=>lr.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Z.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(xC(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(xC(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Ls(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=xC(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=xC(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Z.useEffect(()=>{R||u(!1)},[R]);let ie=Z.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=xC(t.path),o=xC(i.path);try{await Rs(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=xC(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),xC(D)===a&&o&&et.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return Y.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:bC(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),ae=Z.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ie(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);Y.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:bC(i)})})()},[R,l,ie,e]),H=Z.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){ae(a.worktree,t),ne();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){Y.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}$c({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else wl({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else wl({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&ae(a.worktree,t),z&&r.length>0&&$c({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(Y.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:bC(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&ae(a.worktree,t),ne()}finally{m(!1)}}},[a,d,C,w,ne,ee,z,ae,e]),U=a?.worktree??s[0]?.metadata??null,oe=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,se=a?(0,$.jsxs)(`div`,{className:J(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:J(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:J(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),U?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:U.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:U?cr(U.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,ce=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,le=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{V||f(e=>!e)},disabled:V,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,V?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,ue=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[le,ce]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:H,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:ne,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:H,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),de=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Os,{open:!!a,onClose:()=>{p||ne()},title:de,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:ue}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[oe&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:oe}),se]})}):(0,$.jsx)($r,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;ne()}},children:(0,$.jsxs)(Xr,{className:J(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(Jr,{children:[(0,$.jsxs)(Zr,{className:J(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(X,{name:`delete-bin`,className:`h-5 w-5`}),de]}),oe&&(0,$.jsx)(Qr,{children:oe})]}),(0,$.jsx)(`div`,{className:J(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:se}),(0,$.jsx)(Yr,{className:`mt-2 gap-2 pt-1 pb-1`,children:ue})]})}),(0,$.jsx)(_l,{open:t,onOpenChange:n,origin:r})]})},CC=Z.createContext(null),wC=e=>{let t=(0,Q.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(CC.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},TC=xa(()=>zt(()=>import(`./TerminalView-DFQ5LQFM.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([84,1,3,2,4,5,6,7,8,9,40,24,10,41,42,25,22,26,43,14,11,13,12,15,16,17,18,19,20,21,23,27,85,44,45,86,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,87,67,88,70,89,90,91,92,93,94,95,96,97,98]))),EC=xa(()=>zt(()=>import(`./DiagramView-D4CKBzKi.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([99,1,3,2,10,12,13,14,4,5,6,7,8,9,11,15,16,17,18,19,20,21,22,23,24,25,26,27,46,60,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,70,89,85,100,101]))),DC=xa(()=>zt(()=>import(`./SettingsView-nMaFvRQ8.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([102,1,2,3,4,5,6,7,8,9,40,24,10,41,42,25,22,26,43,14,11,13,12,15,16,17,18,19,20,21,103,44,23,27,45,104,46,39,47,48,49,50,51,52,53,54,55,56,57,58,59,60,105,87,64,65,106,67,107,88,108,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),OC=xa(()=>zt(()=>import(`./SettingsWindow-DFw624ap.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([184,1,10,11,39,2,5,3,4,6,7,8,9,40,24,41,42,25,22,26,43,14,13,12,15,16,17,18,19,20,21,44,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,102,103,104,60,105,87,64,65,106,67,107,88,108,109,110,111,112,113,68,29,30,31,32,33,34,35,36,37,38,114,71,72,73,115,116,117,76,70,77,78,118,119,120,121,122,123,124,125,126,127,128,61,62,129,130,90,91,92,93,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,63,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,81,179,180,181,182,183]))),kC=xa(()=>zt(()=>import(`./MultiRunWindow-CpPHLNh6.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([185,1,10,11,39,2,5,3,4,6,7,8,9,40,24,41,42,25,22,26,43,14,13,12,15,16,17,18,19,20,21,44,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,186,105,87,106,88,111,112,114,187,117,139,188,189,190,191,161,61,67,72,78,162,163,192,193,194,151,126,158,63,91,92,93,125,127,128,62,178,195,130]))),AC=xa(()=>zt(()=>import(`./AssistantView-BB_CRg4L.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([196,1,3,2,10,11,16,17,18,23,5,6,7,8,9,24,25,22,26,27,20,39,4,40,41,42,43,14,13,12,15,19,21,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,197,88,119,167,120,198,105,87,61,74,75,199,76,70,77,78,79,165,64,65,73,166,161,67,72,162,163,200,128,62,112,192,193,194,189,190,201,69,152,153,202,203,204,205,206,207,208,168,135,136,209,210,211,212,110,109]))),jC=()=>{let e=K(e=>e.isSidebarOpen),t=K(e=>e.isRightSidebarOpen),n=K(e=>e.isBottomTerminalOpen),r=K(e=>e.setRightSidebarOpen),i=K(e=>e.setBottomTerminalOpen),a=K(e=>e.activeMainTab),o=K(e=>e.setIsMobile),s=K(e=>e.isSessionSwitcherOpen),c=K(e=>e.isSettingsDialogOpen),l=K(e=>e.setSettingsDialogOpen),u=K(e=>e.isMultiRunLauncherOpen),d=K(e=>e.setMultiRunLauncherOpen),[f,p]=Z.useState(c),[m,h]=Z.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=pi(),v=Z.useRef(!1),y=Z.useRef(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(!1),[w,T]=Z.useState(!1),[E,D]=Z.useState(!1),O=Z.useCallback(e=>{x(e),K.getState().setSessionSwitcherOpen(e)},[]),k=Z.useRef(!1),A=Z.useRef(typeof window>`u`?0:window.innerWidth),j=Kr(-A.current),M=(0,Z.useRef)(0),N=Kr(A.current),P=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Z.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),qr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Z.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),qr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Z.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Z.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Z.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Z.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),K.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Z.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Jn.getState(),r=K.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Z.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Z.useEffect(()=>{K.getState().isMobile!==g&&o(g)},[g,o]),Z.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,K.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=K.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=K.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Z.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Z.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(mg,{isActive:!S})});case`diff`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)($l,{})});case`terminal`:return n?null:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(TC,{})});case`files`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(hp,{})});case`diagram`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(EC,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,ee=L||R||z,B=a===`chat`,V=!ee&&!c;return(0,$.jsx)(Bi,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:J(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(jc,{}),(0,$.jsx)(yy,{}),(0,$.jsx)(Cy,{}),(0,$.jsx)(SC,{}),(0,$.jsx)(gc,{}),g?(0,$.jsxs)(wC,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!ee&&(0,$.jsx)(Zd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:J(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Po,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Po,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(AC,{})})})}),V&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(al,{children:(0,$.jsx)(Po,{children:(0,$.jsx)(Zl,{})})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(al,{children:(0,$.jsx)(Po,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Po,{children:(0,$.jsx)(au,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(As.div,{className:J(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(Po,{children:(0,$.jsx)(vC,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(As.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(Po,{children:(0,$.jsx)(al,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(mg,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(Po,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(DC,{onClose:()=>l(!1)})})})}),(0,$.jsx)(Po,{children:(0,$.jsx)(gl,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(vf,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(yf,{}),children:(0,$.jsx)(vC,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:ee?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(Po,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:z?(0,$.jsx)(Wl,{}):R?(0,$.jsx)(AC,{}):(0,$.jsx)(Xl,{})})})}):(0,$.jsx)(al,{children:(0,$.jsxs)(_y,{header:(0,$.jsx)(Zd,{}),footer:(0,$.jsx)(lf,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(Po,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(TC,{})})}):null}),children:[V&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(Po,{children:(0,$.jsx)(Zl,{})})}),V&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(Po,{children:I})})]})})})]}),(0,$.jsx)(Z.Suspense,{fallback:null,children:f&&(0,$.jsx)(OC,{open:c,onOpenChange:l})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:m&&(0,$.jsx)(kC,{open:u,onOpenChange:d})})]})]})})},MC=9e4,NC=15e3,PC=3e5,FC=[2e3,5e3],IC=6e4,LC=12e4,RC=3e5,zC=4,BC=432e5,VC=`yuri.github-pr-status`,HC=e=>e===`closed`||e===`merged`,UC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},WC=(e,t,n)=>`${e}::${t}`,GC=new Map,KC=new Map,qC=new Set,JC=new Map,YC=2,XC=0,ZC=[],QC=()=>XC<YC?(XC+=1,Promise.resolve()):new Promise(e=>{ZC.push(e)}),$C=()=>{let e=ZC.shift();if(e){e();return}XC=Math.max(0,XC-1)},ew=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),tw=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,nw=e=>{let t=tw(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},rw=(e,t)=>Object.entries(e).filter(([,e])=>nw(e)===t).map(([e])=>e),iw=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},aw=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},ow=(e,t,n)=>{let r=rw(e,t),i=r.map(t=>aw(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=aw(e[n]);if(a&&nw(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&aw(e)));return o?aw(o):i.find(e=>!!e.remoteName)||(i[0]??null)},sw=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:tw(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),cw=e=>({...ew(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),lw=ke()(Ae((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:ew()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??ew();return{entries:{...e.entries,[t]:iw(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??ew();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),GC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=KC.get(n)??[];i.push(r),KC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),FC.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<PC)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}HC(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(UC(r.status)?IC:r.status?.checks&&r.status.checks.state!==`pending`?RC:LC)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},NC);GC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=GC.get(n);typeof i==`number`&&window.clearInterval(i),GC.delete(n);let a=KC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),KC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=nw(a);if(!a||!o)return;let s=rw(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=JC.get(o)??0;if(!r?.force&&Date.now()-l<MC||qC.has(o))return;let u=ow(i.entries,o,n);if(u){if(qC.add(o),JC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),qC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),qC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await QC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{$C()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=tw(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{qC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await $y(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:WC(t,n,e.remoteName??null)}).filter(e=>!!e))),zC,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??ew();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:VC,storage:lt(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=tw(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<BC}).map(([e,t])=>[e,sw(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,cw(t)]))}}})),uw=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},dw=e=>{let t=(0,Q.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},fw=e=>{let t=(0,Q.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Pr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(mw,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?uw(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(dw,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(dw,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(dw,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Gr,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},pw=e=>{let t=(0,Q.c)(104),{onClose:n}=e,{t:r}=Pr(),[i,a]=Z.useState(`memory`),[o,s]=Z.useState(`idle`),c=Jn(hw),l=Sr(gw),u=wr(),d=Sn(),[f,p]=Z.useState(_w),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>ve(()=>{p(_e())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Z.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=ge(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(vw):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(Ce(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(yw)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=lw(bw),[y,b]=Z.useState(xw),[x,S]=Z.useState(Sw),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(Ye()),S(at())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Z.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Z.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(Cw),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let V=B,te;t[46]===_?te=t[47]:(te=Object.keys(_),t[46]=_,t[47]=te);let ne=te.length,re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Ye(),vscode:at()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=re):re=t[48];let ie=re,ae;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ae={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=ae):ae=t[49];let H;t[50]===i?H=t[51]:(H=i===`memory`?(0,$.jsx)(X,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(X,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=H);let U;t[52]===r?U=t[53]:(U=r(`memoryDebugPanel.title`),t[52]=r,t[53]=U);let oe;t[54]===U?oe=t[55]:(oe=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:U}),t[54]=U,t[55]=oe);let se;t[56]!==H||t[57]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H,oe]}),t[56]=H,t[57]=oe,t[58]=se):se=t[58];let ce;t[59]===i?ce=t[60]:(ce=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`xs`,variant:`ghost`,onClick:ie,children:(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{size:`xs`,variant:`ghost`,onClick:()=>{tt(),b(Ye()),S(at())},children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=ce);let le;t[61]===n?le=t[62]:(le=n?(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=le);let ue;t[63]!==ce||t[64]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,le]}),t[63]=ce,t[64]=le,t[65]=ue):ue=t[65];let de;t[66]!==se||t[67]!==ue?(de=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[se,ue]}),t[66]=se,t[67]=ue,t[68]=de):de=t[68];let fe;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(fe={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=fe):fe=t[69];let pe=i===`memory`?`secondary`:`ghost`,me;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>a(`memory`),t[70]=me):me=t[70];let he;t[71]===r?he=t[72]:(he=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=he);let ye;t[73]!==pe||t[74]!==he?(ye=(0,$.jsx)(q,{size:`sm`,variant:pe,className:`flex-1`,onClick:me,children:he}),t[73]=pe,t[74]=he,t[75]=ye):ye=t[75];let be=i===`streaming`?`secondary`:`ghost`,xe;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>a(`streaming`),t[76]=xe):xe=t[76];let Se;t[77]===r?Se=t[78]:(Se=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=Se);let we;t[79]!==be||t[80]!==Se?(we=(0,$.jsx)(q,{size:`sm`,variant:be,className:`flex-1`,onClick:xe,children:Se}),t[79]=be,t[80]=Se,t[81]=we):we=t[81];let Te;t[82]!==ye||t[83]!==we?(Te=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:fe,children:[ye,we]}),t[82]=ye,t[83]=we,t[84]=Te):Te=t[84];let Ee;t[85]!==i||t[86]!==ne||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==V||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(Ee=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${ne} / ${Wo.MAX_SESSIONS}`}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Zo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Wo.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Gr,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:V.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(X,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ri,{children:[(0,$.jsx)(ei,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(ww),Object.keys(_),V.map(Tw),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(ti,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:ie,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(dw,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(fw,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(fw,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=ne,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=V,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=Ee):Ee=t[99];let De;return t[100]!==de||t[101]!==Te||t[102]!==Ee?(De=(0,$.jsxs)(No,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:ae,children:[de,Te,Ee]}),t[100]=de,t[101]=Te,t[102]=Ee,t[103]=De):De=t[103],De};function mw(e,t){return e+t.count}function hw(e){return e.currentSessionId}function gw(e){return e.sessionMemoryState}function _w(){return _e()}function vw(e){return e.scope}function yw(e){return!!e}function bw(e){return e.totalRequestCount}function xw(){return Ye()}function Sw(){return at()}function Cw(e,t){return t.lastAccessed-e.lastAccessed}function ww(e){return{id:e.id,title:e.title}}function Tw(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var Ew=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=K.getState();if(e)return;let n=Gi();n&&t(n)||L()&&ee(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},Dw=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},Ow=async()=>{let e=Dw()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},kw=`yuri:menu-action`,Aw=`yuri:check-for-updates`,jw=e=>typeof e?.listen==`function`?`bridge`:`dom`,Mw=e=>{let t=Jn(e=>e.openNewSessionDraft),n=K(e=>e.toggleCommandPalette),r=K(e=>e.setCommandPaletteOpen),i=K(e=>e.toggleHelpDialog),a=K(e=>e.toggleSidebar),o=K(e=>e.setSessionSwitcherOpen),s=K(e=>e.setActiveMainTab),c=K(e=>e.setSettingsDialogOpen),l=K(e=>e.setSettingsPage),u=K(e=>e.setAboutDialogOpen),d=K(e=>e.toggleContextPanel),f=K(e=>e.setRightSidebarOpen),p=K(e=>e.setRightSidebarTab),m=K(e=>e.toggleBottomTerminal),h=K(e=>e.setBottomTerminalExpanded),g=Ol(e=>e.checkForUpdates),{setThemeMode:_}=oi(),{t:v}=Pr(),y=Z.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=jw(b),S=Z.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=Ol.getState();if(t){Y.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||Y.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Z.useCallback(()=>{lr.requestDirectoryDialog()},[]),w=Z.useCallback(e=>{so(e,Jn.getState().currentSessionId,e=>{s(`chat`),o(!1),Jn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Z.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=fn.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Z.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),fs();break;case`change-workspace`:C();break;case`close-tab-or-window`:Ew();break;case`toggle-right-sidebar`:{let e=Gi();e&&d(e);break}case`open-right-sidebar-git`:{let e=Gi();e&&K.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Gi();e&&K.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!K.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&Ow();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Za();break;case`zoom-out`:Qa();break;case`zoom-reset`:uo();break;case`go-back`:et.getState().goBack();break;case`go-forward`:et.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:ho().catch(()=>{Y.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Z.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(kw,e),window.addEventListener(Aw,t),()=>{window.removeEventListener(kw,e),window.removeEventListener(Aw,t)}},[E,S,x]),Z.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},Nw=(e,t)=>e<t?-1:+(e>t),Pw=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(Nw)]).sort(([e],[t])=>Nw(e,t)));async function Fw({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var Iw=`yuri:tray-action`,Lw=3e4,Rw=120,zw=20,Bw=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},Vw=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},Hw=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},Uw=e=>jn(e),Ww=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},Gw=(e,t,n,r)=>{if(!e)return``;let i=Qt(t,n,e),a=Ww(i?i.path:e),o=Pn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of $i.getState().directories)if(Pn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>Pn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},Kw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Xs.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Zs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:tc(n.label??t),value:Qs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},qw=async()=>{try{if(x())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&fe(t,e))return`Local Yuri`;let n=(await se()).hosts.find(e=>t?fe(t,de(e)):!1);return n?.label?.trim()?he(n.label.trim()):`Instance`}catch{return``}},Jw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=ye()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(Pn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:Vw(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:Hw(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},Yw=()=>{let e=hn.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>Uw(t)-Uw(e)).slice(0,zw).forEach(e=>{let n=vn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=vn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},Xw=e=>{let t=Jw(),n=un.getState().index.session,r=hn.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Cr.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=fn.getState().projects,d=Jn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>Uw(t)-Uw(e)).slice(0,zw).map(e=>{let r=[e.id,...o(e.id)],i=vn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:Gw(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=K.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:Kw(),dockBadgeCount:h}},Zw=()=>{Z.useEffect(()=>{if(!Bw()||!L())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=Xw(r),i=JSON.stringify(n);i!==t&&(t=i,ee(`desktop_tray_update`,n))};qw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=Nn.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=Yw();return o=Pw(t),a=Fw({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await Se.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{Bn(e,t,[...n])}}).finally(()=>{a=null;let t=Yw();!e&&s()&&Pw(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},Rw))},u=new Map,d=()=>{if(e)return;let t;try{t=ye()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=ye().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=un.subscribe(()=>l()),m=hn.subscribe(()=>{l(),s()&&Pw(Yw())!==o&&c()}),h=fn.subscribe(()=>l()),g=Jn.subscribe(()=>l()),_=$i.subscribe(()=>l()),v=K.subscribe(()=>l()),y=Cr.subscribe(()=>l()),b=s(),x=Nn.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Xs.subscribe(()=>l());Xs.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Xs.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Xs.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Xs.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Xs.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},Lw);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Z.useEffect(()=>{if(!Bw()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&sr(e.sessionId,e.id,e.response).catch(()=>{Y.error(`Failed to respond to permission request`)})},n=null;return e(Iw,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},Qw=`/api/notifications/stream`,$w=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),eT=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},tT=e=>{let t=(0,Q.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||C()||!y()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(Qw));return e.onmessage=nT,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Z.useEffect(r,i)};function nT(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=K.getState();if(!n.nativeNotificationsEnabled)return;let r=eT(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&$w()||U()?.notifications?.notifyAgentCompletion(r))}var rT=`pwa-install-toast-shown`,iT=`pwa-install-toast-dismissed`,aT=()=>{let e=(0,Q.c)(6),{browserTab:t}=pu(),{t:n}=Pr(),r=Z.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Z.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!y()||!t)return;let e=null,n=null,i=()=>{n!==null&&(Y.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&Y.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=st(),c=ct();Bc({dismissed:s.getItem(iT),sessionShown:c.getItem(rT),hasActiveToast:n!==null})&&(c.setItem(rT,`true`),n=Y.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{st().setItem(iT,`true`),i()}}}))},s=()=>{e=null,i(),Y.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Z.useEffect(o,s)},oT=0;function sT(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++oT,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(K.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;zt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-CkjjVHYQ.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([213,1,3,2,19,8,9,20,39,5,4,6,7,40,24,10,41,42,25,22,26,43,14,11,13,12,15,16,17,18,21,44,23,27,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59])).then(({applyRemoteProjectRoute:i})=>{if(n===oT)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===oT)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Jn.getState().setCurrentSession(t,r)}var cT=({open:e,onOpenChange:t})=>{let{t:n}=Pr(),[r,i]=Z.useState(null),[a,o]=Z.useState(null);Z.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await jr())})()},[e]),Z.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)($r,{open:e,onOpenChange:t,children:(0,$.jsx)(Xr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(Mo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},lT=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},uT=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},dT=()=>{let e=Il(e=>e.completeAuth),[t,n]=Z.useState(`working`),[r,i]=Z.useState(`Completing MCP authorization...`);return Z.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=lT(t,`code`),a=du(t),o=ou(t),s=lT(t,`error`),c=lT(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(uT(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(q,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},fT=()=>{let e=hn(e=>e.startupSyncProgress.active),t=hn(e=>e.startupSyncProgress.phase),n=hn(e=>e.startupSyncProgress.completed),r=hn(e=>e.startupSyncProgress.total),{locale:i,t:a}=Pr(),[o,s]=Z.useState(!0),c=Yt(i).startingApi;Z.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Z.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},pT=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function mT(e){let t=(0,Q.c)(21),{transition:n,ready:r}=e,{t:i}=Pr(),a=So(!0),[o,s]=Z.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=pT(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Z.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(Mo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var hT=xa(()=>zt(()=>import(`./OnboardingScreen-BecSplt9.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([214,1,4,2,5,3,6,7,8,9,40,24,10,41,42,25,22,26,43,14,11,13,12,15,16,17,18,19,20,21,44,23,27,45,39,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,117,146,67]))),gT=36e5,_T=12e5,vT=()=>{let e=(0,Q.c)(3),t=K(TT),n=K(ET),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(cT,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},yT=e=>{let t=(0,Q.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Pr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(q,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},bT=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,xT=()=>{if(typeof window>`u`||!Lo())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},ST=()=>typeof window>`u`?!1:window.location.pathname===fu,CT=e=>{let t=(0,Q.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=et(DT),o=Jn(OT),s=Jn(kT),c=ms(),l=Z.useRef(null),u;t[0]===n.directory?u=t[1]:(u=bT(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=bT(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Z.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(to,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Zl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Ia,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function wT({apis:e}){Z.useEffect(()=>{oe(`App:mounted`),ce()},[]),Z.useEffect(()=>or(),[]);let t=Nn(e=>e.initializeApp),n=Nn(e=>e.isInitialized),r=Nn(e=>e.isConnected),i=Jn(e=>e.error),a=Jn(e=>e.clearError),o=Jn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=et(e=>e.currentDirectory),l=et(e=>e.setDirectory),u=et(e=>e.isSwitchingDirectory),[d,p]=Z.useState(!1),m=Pl(e=>e.refreshStatus),[h,g]=Z.useState(()=>e.runtime.isVSCode),[_,v]=Z.useState(!1),[y,S]=Z.useState(!1),[w,T]=Z.useState(0),[O,A]=Z.useState(0),[j,M]=Z.useState({epoch:0,startedAt:0}),[P,I]=Z.useState(!1),L=Z.useRef(!1),z=K(e=>e.wideChatLayoutEnabled),B=K(e=>e.mobileKeyboardMode),V=Z.useMemo(()=>C(),[]),ne=hn(e=>e.hasCachedSessionIndex),re=hn(e=>e.hasHydratedSessionIndex),[ae,U]=Z.useState(()=>te()),[se,le]=Z.useState(()=>{let e=ie();return e===null?null:F({isDesktopShell:!0,bootOutcome:e})}),ue=Z.useRef(!1),de=Z.useMemo(()=>xT(),[]),fe=!de||_,pe=Z.useMemo(()=>ST(),[]);Z.useEffect(()=>(Xe(d),()=>{Xe(!1)}),[d]),Z.useEffect(()=>{Ut(B)},[B]),Z.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Z.useEffect(()=>{let e=Ba(e=>{f(e)&&(V&&M(e=>({epoch:e.epoch+1,startedAt:Date.now()})),cl(e),A(e=>e+1),S(!1),T(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[V]),Z.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,z),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[z]),Z.useEffect(()=>(H(e),()=>H(null)),[e]),Z.useEffect(()=>{if(de)return;let t=!1;return rn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,de,m]),lo();let me=ae===`valid`,he=se?.screen===`main`,[ge,_e]=Z.useState(!1);Z.useEffect(()=>{if(!fe||!N({isDesktopShell:V,isInitialized:V&&he?ne||n&&re:n,bootOutcomeKnown:me,bootViewIsMain:he}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),_e(!0)},300)):_e(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[fe,V,n,me,he,ne,re]),Z.useEffect(()=>{if(!V||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[V,ae]),Z.useEffect(()=>{if(!fe||V)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[fe,V,n]),Z.useEffect(()=>{if(!fe||h)return;let e=!1;return rn().then(()=>{if(!e)return t()}),()=>{e=!0}},[fe,t,h]),Z.useEffect(()=>{if(!fe||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=Nn.getState();if(n.isInitialized){S(!1);return}if(r+=1,await rn(),!e)return;await n.initializeApp();let o=Nn.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[fe,w,n,h]),Z.useEffect(()=>{fe&&n&&S(!1)},[fe,n]),Z.useEffect(()=>{if(!fe||!y)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[fe,y]),qa({enabled:fe&&!h,source:`startupRecovery`}),Z.useEffect(()=>{u||h||r&&Se.setDirectory(s)},[s,u,r,h]),Z.useEffect(()=>{if(!de||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Ro},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[de]),Z.useEffect(()=>{!de?.directory||h||s!==de.directory&&l(de.directory,{showOverlay:!1})},[s,de,h,l]),Z.useEffect(()=>{if(!de||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&K.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[de]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;sT(t??{})},t=e=>{let t=e.detail;zt(async()=>{let{openSessionFromDeepLink:e}=await import(`./openSessionFromDeepLink-Cm-ztlpD.js`);return{openSessionFromDeepLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,14,11,13,12,15,16,17,18,19,21,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({openSessionFromDeepLink:e})=>e(t??{}))},n=b()?.handleProbe(e=>zt(async()=>{let{probeSessionLink:e}=await import(`./openSessionFromDeepLink-Cm-ztlpD.js`);return{probeSessionLink:e}},__vite__mapDeps([215,20,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,39,4,40,41,42,43,14,11,13,12,15,16,17,18,19,21,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,208])).then(({probeSessionLink:t})=>t(e))),r=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Ur(t.trim())},i=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&zt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-r3g3DfXq.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([168,1,23,5,3,2,6,7,8,9,24,10,25,22,26,27,20,135,136])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-session-link`,t),window.addEventListener(`yuri:open-assistant`,r),window.addEventListener(`yuri:open-scheduled-task`,i),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-session-link`,t),n?.(),window.removeEventListener(`yuri:open-assistant`,r),window.removeEventListener(`yuri:open-scheduled-task`,i)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=et.getState().currentDirectory,{activeProjectId:t,projects:n}=fn.getState(),r=n.find(e=>e.id===t)??null;ee(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(ln.getState().remoteSession)return;let e=Jn.getState().currentSessionId;e&&Tn(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;K.getState().setActiveMainTab(`chat`),K.getState().setSessionSwitcherOpen(!1);let s=fn.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=ln.getState().remoteSession,c=s.activeProjectId;Vl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&ln.getState().remoteSession===t&&fn.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=ln.getState().remoteSession;o&&t&&await Bl(t.location,o)}).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),ln.getState().openRemoteSession(c,e,null),o&&Bl(e,o).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}ln.getState().clearRemoteSession(),Jn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=fn.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Z.useEffect(()=>{typeof window>`u`||!fe||!n||u||ue.current||(ue.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[fe,n,u]),Ka({enabled:fe}),tT({enabled:fe}),aT(),mo(),Zc(),Mw(G(()=>{p(e=>!e)})),Z.useEffect(()=>{E()&&Jt().then(async e=>{e&&await D(e)}).catch(console.warn)},[]),Z.useEffect(()=>{if(!n||!E()||L.current)return;L.current=!0;let e=!1,t=null,r=null;Ol.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=Ol.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(gT))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=Ol.getState().lastChecked;t!=null&&Date.now()-t<_T||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),Zw(),Z.useEffect(()=>{if(de)return;let e=e=>{tr(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[de]),Z.useEffect(()=>{de||i&&setTimeout(()=>a(),5e3)},[a,de,i]),Z.useEffect(()=>{if(!V||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=te();if(r!==`not-injected`){if(e=!0,U(r),r===`valid`){let e=ie();e&&le(F({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[V,ae]);let ve=G(async()=>{if(R({isDesktopShell:C(),isDesktopLocalOriginActive:x()})){await k();return}window.location.reload()}),ye=G(async()=>{if(!P){S(!1),I(!0);try{await rn(),await Nn.getState().initializeApp()}finally{I(!1)}Nn.getState().isInitialized||T(e=>e+1)}}),be=e=>{if(e.screen===`recovery`)return e.variant};if(V&&se&&se.screen!==`main`){if(se.screen===`chooser`)return(0,$.jsx)(Po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(hT,{mode:`first-launch`,onCliAvailable:ve,onChooseRemote:()=>{}})})})});let e=be(se),t=se.screen===`recovery`&&`url`in se?se.url:void 0;return(0,$.jsx)(Po,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(hT,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:ve})})})})}if(de)return Cn(),(0,$.jsx)(Po,{children:(0,$.jsx)(er,{sdk:Se.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(po,{apis:e,children:(0,$.jsx)(ni,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(CT,{embeddedSessionChat:de,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:fe})})})})},O)});if(pe)return(0,$.jsx)(Po,{children:(0,$.jsx)(dT,{})});if(y&&!n&&!h&&!de)return(0,$.jsx)(Po,{children:(0,$.jsx)(yT,{onRetry:()=>{ye()},isRetrying:P})});let xe=!n&&!V;return(0,$.jsx)(Po,{children:(0,$.jsx)(er,{sdk:Se.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(po,{apis:e,children:(0,$.jsx)(dl,{ready:ge&&n&&fe,children:(0,$.jsx)(ih,{children:(0,$.jsx)(ni,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:V?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(to,{embeddedBackgroundWorkEnabled:fe}),(0,$.jsx)(rl,{}),(0,$.jsx)(mc,{}),(0,$.jsx)(kc,{}),(0,$.jsx)(jC,{}),V&&(0,$.jsx)(mT,{transition:j,ready:n&&r}),(0,$.jsx)(fT,{}),(0,$.jsx)(Ia,{}),!xe&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xc,{}),(0,$.jsx)(Tc,{}),(0,$.jsx)(Kc,{}),(0,$.jsx)(vT,{}),d&&(0,$.jsx)(pw,{onClose:()=>p(!1)})]})]})})})})})},O)})}function TT(e){return e.isAboutDialogOpen}function ET(e){return e.setAboutDialogOpen}function DT(e){return e.currentDirectory}function OT(e){return e.currentSessionId}function kT(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var AT=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Fr(),C()&&xr(),Ga({runtimeKey:p(),initializeAppearance:Qe,syncSettings:$e,applyDirectory:go,startWatchers:()=>{ro(),Ua(),La()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var jT=document.getElementById(`root`);if(!jT)throw Error(`Root element not found`);(0,ju.createRoot)(jT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Ra,{children:(0,$.jsx)(Nr,{children:(0,$.jsx)(Fa,{children:(0,$.jsx)(no,{children:(0,$.jsx)(Va,{children:(0,$.jsx)(Ha,{children:(0,$.jsx)(wT,{apis:AT})})})})})})})}));
|